私域操盘手 - 调整微信账号限制记录至模型WechatRestrictsModel

This commit is contained in:
柳清爽
2025-05-14 15:00:21 +08:00
parent 798b0d7854
commit 2ad1b99ea3
3 changed files with 44 additions and 26 deletions

View File

@@ -1010,17 +1010,23 @@ export default function WechatAccountDetailPage() {
</DialogHeader>
<ScrollArea className="max-h-[400px]">
<div className="space-y-4">
{accountSummary && accountSummary.restrictions.map((record) => (
<div key={record.id} className="border-b pb-4 last:border-0">
<div className="flex justify-between items-start">
<div className={`text-sm ${getRestrictionLevelColor(record.level)}`}>
{record.reason}
{accountSummary?.restrictions?.length > 0 ? (
accountSummary.restrictions.map((record) => (
<div key={record.id} className="border-b pb-4 last:border-0">
<div className="flex justify-between items-start">
<div className={`text-sm ${getRestrictionLevelColor(record.level)}`}>
{record.reason}
</div>
<Badge variant="outline">{formatDateTime(record.date)}</Badge>
</div>
<div className="text-sm text-gray-500 mt-1">{formatDateTime(record.date)}</div>
</div>
<Badge variant="outline">{formatDateTime(record.date)}</Badge>
</div>
<div className="text-sm text-gray-500 mt-1">{formatDateTime(record.date)}</div>
))
) : (
<div className="text-center py-8 text-green-500">
</div>
))}
)}
</div>
</ScrollArea>
</DialogContent>

View File

@@ -0,0 +1,17 @@
<?php
namespace app\common\model;
use think\Model;
/**
* 微信风险受限记录
*/
class WechatRestricts extends Model
{
const LEVEL_WARNING = 2;
const LEVEL_ERROR = 3;
// 设置数据表名
protected $name = 'wechat_restricts';
}

View File

@@ -4,6 +4,7 @@ namespace app\cunkebao\controller\wechat;
use app\common\model\WechatAccount as WechatAccountModel;
use app\common\model\WechatFriendShip as WechatFriendShipModel;
use app\common\model\WechatRestricts as WechatRestrictsModel;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
@@ -60,27 +61,21 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
}
/**
* TODO 获取限制记录
* 获取限制记录
*
* @param string $wechatId
* @return array
*/
protected function getRestrict(string $wechatId): array
{
return [
[
'id' => 1,
'level' => 2,
'reason' => '频繁添加好友',
'date' => date('Y-m-d H:i:s', strtotime('-1 day')),
],
[
'id' => 2,
'level' => 3,
'reason' => '营销内容违规',
'date' => date('Y-m-d H:i:s', strtotime('-1 day')),
],
];
return WechatRestrictsModel::alias('r')
->field(
[
'r.id', 'r.restrictTime date', 'r.level', 'r.reason'
]
)
->where('r.wechatId', $wechatId)->select()
->toArray();
}
/**
@@ -92,7 +87,7 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
*/
protected function getDateDiff(string $wechatId): int
{
$currentData = new \DateTime(date('Y-m-d H:i:s', time()));
$currentData = new \DateTime(date('Y-m-d H:i:s', time()));
$registerDate = new \DateTime($this->getRegisterDate($wechatId));
$interval = date_diff($currentData, $registerDate);
@@ -208,7 +203,7 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
*/
protected function getTodayNewFriendCount(string $ownerWechatId): int
{
return WechatFriendShipModel::where( compact('ownerWechatId') )
return WechatFriendShipModel::where(compact('ownerWechatId'))
->whereBetween('createTime',
[
strtotime(date('Y-m-d 00:00:00')),