diff --git a/Cunkebao/app/wechat-accounts/page.tsx b/Cunkebao/app/wechat-accounts/page.tsx index c831b383..e814b928 100644 --- a/Cunkebao/app/wechat-accounts/page.tsx +++ b/Cunkebao/app/wechat-accounts/page.tsx @@ -20,9 +20,23 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from " import { toast } from "@/components/ui/use-toast" import { Progress } from "@/components/ui/progress" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" -import { fetchWechatAccountList, refreshWechatAccounts, transferWechatFriends, transformWechatAccount } from "@/api/wechat-accounts" +import { fetchWechatAccountList, refreshWechatAccounts, transferWechatFriends } from "@/api/wechat-accounts" import { WechatAccount } from "@/types/wechat-account" +// 定义接口以匹配新的数据结构 +interface WechatAccountResponse { + id: number + wechatId: string + nickname: string + avatar: string + times: number + addedCount: number + wechatStatus: number + totalFriend: number + deviceMemo: string + activeTime: string +} + export default function WechatAccountsPage() { const router = useRouter() const [accounts, setAccounts] = useState([]) @@ -49,7 +63,23 @@ export default function WechatAccountsPage() { if (response && response.code === 200 && response.data) { // 转换数据格式 - const wechatAccounts = response.data.list.map(transformWechatAccount); + const wechatAccounts = response.data.list.map((item: any) => { + const account: WechatAccount = { + id: item.id.toString(), + wechatId: item.wechatId, + nickname: item.nickname, + avatar: item.avatar, + remainingAdds: item.times - item.addedCount, + todayAdded: item.addedCount, + status: item.wechatStatus === 1 ? "normal" as const : "abnormal" as const, + friendCount: item.totalFriend, + deviceName: item.deviceMemo, + lastActive: item.activeTime, + maxDailyAdds: item.times, + deviceId: item.id.toString(), + }; + return account; + }); setAccounts(wechatAccounts); setTotalAccounts(response.data.total); } else { @@ -279,7 +309,10 @@ export default function WechatAccountsPage() { {account.todayAdded}/{account.maxDailyAdds} - +
所属设备:{account.deviceName || '未知设备'}
diff --git a/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php index 81cce9c1..3554d3aa 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php @@ -18,16 +18,14 @@ use library\ResponseHelper; class GetWechatsOnDevicesV1Controller extends BaseController { /** - * TODO 计算今日可添加好友数量 + * 计算今日可添加好友数量 * * @param string $wechatId * @return int */ protected function getCanAddFriendCount(string $wechatId): int { - $canAddFriendCount = 20; // 最多限制 20 次 - - return $canAddFriendCount < 0 ? 0 : $canAddFriendCount; + return 20; // 最多限制 20 次 } /** @@ -71,7 +69,7 @@ class GetWechatsOnDevicesV1Controller extends BaseController */ protected function getWhereOnDevice(string $wechatId): string { - return DeviceModel::alias('d') + return (string)DeviceModel::alias('d') ->where( [ 'l.wechatId' => $wechatId, @@ -79,7 +77,7 @@ class GetWechatsOnDevicesV1Controller extends BaseController ] ) ->join('device_wechat_login l', 'd.id = l.deviceId') - ->value('d.imei'); + ->value('d.memo'); } /** @@ -150,7 +148,7 @@ class GetWechatsOnDevicesV1Controller extends BaseController } /** - * 获取设备最新活跃时间 + * TODO 获取设备最新活跃时间 * * @param string $wechatId * @return string @@ -191,9 +189,12 @@ class GetWechatsOnDevicesV1Controller extends BaseController protected function getOnlineWechatList(array $where): \think\Paginator { $query = WechatAccountModel::alias('w') - ->field([ - 'w.id', 'w.wechatId', 'w.nickname', 'w.avatar', 'w.s2_wechatAccountId' - ]) + ->field( + [ + 'w.id', 'w.nickname', 'w.avatar', + 'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatId', + ] + ) ->order('w.id desc'); foreach ($where as $key => $value) {