私域操盘手 - 调整微信账号限制记录至模型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> </DialogHeader>
<ScrollArea className="max-h-[400px]"> <ScrollArea className="max-h-[400px]">
<div className="space-y-4"> <div className="space-y-4">
{accountSummary && accountSummary.restrictions.map((record) => ( {accountSummary?.restrictions?.length > 0 ? (
<div key={record.id} className="border-b pb-4 last:border-0"> accountSummary.restrictions.map((record) => (
<div className="flex justify-between items-start"> <div key={record.id} className="border-b pb-4 last:border-0">
<div className={`text-sm ${getRestrictionLevelColor(record.level)}`}> <div className="flex justify-between items-start">
{record.reason} <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> </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>
))} )}
</div> </div>
</ScrollArea> </ScrollArea>
</DialogContent> </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\WechatAccount as WechatAccountModel;
use app\common\model\WechatFriendShip as WechatFriendShipModel; use app\common\model\WechatFriendShip as WechatFriendShipModel;
use app\common\model\WechatRestricts as WechatRestrictsModel;
use app\cunkebao\controller\BaseController; use app\cunkebao\controller\BaseController;
use library\ResponseHelper; use library\ResponseHelper;
@@ -60,27 +61,21 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
} }
/** /**
* TODO 获取限制记录 * 获取限制记录
* *
* @param string $wechatId * @param string $wechatId
* @return array * @return array
*/ */
protected function getRestrict(string $wechatId): array protected function getRestrict(string $wechatId): array
{ {
return [ return WechatRestrictsModel::alias('r')
[ ->field(
'id' => 1, [
'level' => 2, 'r.id', 'r.restrictTime date', 'r.level', 'r.reason'
'reason' => '频繁添加好友', ]
'date' => date('Y-m-d H:i:s', strtotime('-1 day')), )
], ->where('r.wechatId', $wechatId)->select()
[ ->toArray();
'id' => 2,
'level' => 3,
'reason' => '营销内容违规',
'date' => date('Y-m-d H:i:s', strtotime('-1 day')),
],
];
} }
/** /**
@@ -92,7 +87,7 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
*/ */
protected function getDateDiff(string $wechatId): int 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)); $registerDate = new \DateTime($this->getRegisterDate($wechatId));
$interval = date_diff($currentData, $registerDate); $interval = date_diff($currentData, $registerDate);
@@ -208,7 +203,7 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController
*/ */
protected function getTodayNewFriendCount(string $ownerWechatId): int protected function getTodayNewFriendCount(string $ownerWechatId): int
{ {
return WechatFriendShipModel::where( compact('ownerWechatId') ) return WechatFriendShipModel::where(compact('ownerWechatId'))
->whereBetween('createTime', ->whereBetween('createTime',
[ [
strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 00:00:00')),