diff --git a/Server/application/job/DeviceListJob.php b/Server/application/job/DeviceListJob.php index fbf5964b..df48783e 100644 --- a/Server/application/job/DeviceListJob.php +++ b/Server/application/job/DeviceListJob.php @@ -78,7 +78,7 @@ class DeviceListJob if ($hasNextPage) { // 缓存页码信息,设置有效期1天 $nextPageIndex = $pageIndex + 1; - Cache::set($cacheKey, $nextPageIndex, 86400); + Cache::set($cacheKey, $nextPageIndex, 600); Log::info("更新缓存页码: {$nextPageIndex}, 缓存键: {$cacheKey}"); // 添加下一页任务到队列 @@ -87,7 +87,7 @@ class DeviceListJob Log::info("已添加下一页任务到队列: 页码 {$nextPageIndex}"); } else { // 处理完所有页面,重置页码并释放队列锁 - Cache::set($cacheKey, 0, 86400); + Cache::set($cacheKey, 0, 600); Cache::rm($queueLockKey); Log::info("所有设备列表页面处理完毕,重置页码为0,释放队列锁: {$queueLockKey}"); } diff --git a/Server/application/job/FriendTaskJob.php b/Server/application/job/FriendTaskJob.php index 3caed9ef..03ec65bb 100644 --- a/Server/application/job/FriendTaskJob.php +++ b/Server/application/job/FriendTaskJob.php @@ -82,9 +82,9 @@ class FriendTaskJob $data = $response['data']; // 判断是否有下一页 - if (!empty($data) && count($data['results']) > 0) { + if (!empty($data) && count($data['results']) > 0 && $pageIndex < 2) { // 更新缓存中的页码,设置10分钟过期 - Cache::set('friendTaskPage', $pageIndex + 1, 86400); + Cache::set('friendTaskPage', $pageIndex + 1, 600); Log::info('更新缓存,下一页页码:' . ($pageIndex + 1) . ',缓存时间:10分钟'); // 有下一页,将下一页任务添加到队列 @@ -93,7 +93,7 @@ class FriendTaskJob Log::info('添加下一页任务到队列,页码:' . $nextPageIndex); } else { // 没有下一页,重置缓存,设置10分钟过期 - Cache::set('friendTaskPage', 0, 86400); + Cache::set('friendTaskPage', 0, 600); Log::info('获取完成,重置缓存,缓存时间:10分钟'); } diff --git a/Server/application/job/GroupFriendsJob.php b/Server/application/job/GroupFriendsJob.php index f1eb3b5b..54cf56e9 100644 --- a/Server/application/job/GroupFriendsJob.php +++ b/Server/application/job/GroupFriendsJob.php @@ -107,7 +107,7 @@ class GroupFriendsJob // 判断是否有下一页 if ($processedCount < $totalCount) { // 更新缓存中的页码,设置一天过期 - Cache::set('groupFriendsPage', $pageIndex + 1, 86400); + Cache::set('groupFriendsPage', $pageIndex + 1, 600); //Log::info('更新缓存,下一页页码:' . ($pageIndex + 1) . ',缓存时间:1天'); // 有下一页,将下一页任务添加到队列 @@ -116,7 +116,7 @@ class GroupFriendsJob Log::info('添加下一页任务到队列,页码:' . $nextPageIndex); } else { // 没有下一页,重置缓存,设置一天过期 - Cache::set('groupFriendsPage', 0, 86400); + Cache::set('groupFriendsPage', 0, 600); Log::info('获取完成,重置缓存,缓存时间:1天'); } diff --git a/Server/application/job/WechatChatroomJob.php b/Server/application/job/WechatChatroomJob.php index 0977530c..d5b25b02 100644 --- a/Server/application/job/WechatChatroomJob.php +++ b/Server/application/job/WechatChatroomJob.php @@ -6,7 +6,7 @@ use app\command\WechatChatroomCommand; use think\facade\Log; use think\facade\Cache; use think\Queue; -use app\common\BusinessLogic; +use app\api\controller\WechatChatroomController; class WechatChatroomJob { @@ -49,14 +49,14 @@ class WechatChatroomJob } // 调用业务逻辑获取微信聊天室列表 - $logic = new BusinessLogic(); - $result = $logic->wechatChatroomList($pageIndex, $pageSize, $isDel); - - if ($result['code'] == 1) { - $dataCount = count($result['data']['list']); - $totalCount = $result['data']['total']; - - Log::info("微信聊天室列表获取成功,当前页:{$pageIndex},获取数量:{$dataCount},总数量:{$totalCount}"); + $logic = new WechatChatroomController(); + $result = $logic->getlist(['pageIndex' => $pageIndex, 'pageSize' => $pageSize],true, $isDel); + $response = json_decode($result, true); + $data = $response['data']; + // 判断是否有下一页 + if (!empty($data) && count($data['results']) > 0 && empty($response['isUpdate'])) { + $dataCount = count($data['results']); + $totalCount = $data['total']; // 计算是否还有下一页 $hasNextPage = ($pageIndex + 1) * $pageSize < $totalCount; @@ -64,7 +64,7 @@ class WechatChatroomJob if ($hasNextPage) { // 缓存页码信息,设置有效期1天 $nextPageIndex = $pageIndex + 1; - Cache::set($cacheKey, $nextPageIndex, 86400); + Cache::set($cacheKey, $nextPageIndex, 600); Log::info("更新缓存页码: {$nextPageIndex}, 缓存键: {$cacheKey}"); // 添加下一页任务到队列 @@ -73,13 +73,13 @@ class WechatChatroomJob Log::info("已添加下一页任务到队列: 页码 {$nextPageIndex}"); } else { // 处理完所有页面,重置页码并释放队列锁 - Cache::set($cacheKey, 0, 86400); + Cache::set($cacheKey, 0, 600); Cache::rm($queueLockKey); Log::info("所有微信聊天室列表页面处理完毕,重置页码为0,释放队列锁: {$queueLockKey}"); } } else { // API调用出错,记录错误并释放队列锁 - Log::error("微信聊天室列表获取失败: " . $result['msg']); + Log::error("微信聊天室列表获取失败: " . $response['msg']); Cache::rm($queueLockKey); Log::info("由于错误释放队列锁: {$queueLockKey}"); } diff --git a/Server/application/job/WechatFriendJob.php b/Server/application/job/WechatFriendJob.php index 902e2c10..5e9228ab 100644 --- a/Server/application/job/WechatFriendJob.php +++ b/Server/application/job/WechatFriendJob.php @@ -87,8 +87,8 @@ class WechatFriendJob // 更新缓存中的页码和最后一个好友ID,设置1天过期 $nextPageIndex = $pageIndex + 1; - Cache::set($pageIndexCacheKey, $nextPageIndex, 86400); - Cache::set($preFriendIdCacheKey, $lastFriendId, 86400); + Cache::set($pageIndexCacheKey, $nextPageIndex, 600); + Cache::set($preFriendIdCacheKey, $lastFriendId, 600); Log::info("更新缓存,下一页页码:{$nextPageIndex},最后好友ID:{$lastFriendId},缓存键: {$pageIndexCacheKey}, {$preFriendIdCacheKey}"); @@ -98,8 +98,8 @@ class WechatFriendJob Log::info("已添加下一页任务到队列: 页码 {$nextPageIndex}"); } else { // 没有下一页,重置缓存并释放队列锁 - Cache::set($pageIndexCacheKey, 0, 86400); - Cache::set($preFriendIdCacheKey, '', 86400); + Cache::set($pageIndexCacheKey, 0, 600); + Cache::set($preFriendIdCacheKey, '', 600); Cache::rm($queueLockKey); Log::info("所有微信好友列表页面处理完毕,重置页码为0,释放队列锁: {$queueLockKey}"); }