添加好友优化
This commit is contained in:
@@ -191,7 +191,6 @@ class Adapter implements WeChatServiceInterface
|
||||
}
|
||||
//筛选出设备在线微信在线
|
||||
$wechatIdAccountIdMap = $this->getWeChatIdsAccountIdsMapByDeviceIds($task_info['reqConf']['device']);
|
||||
|
||||
if (empty($wechatIdAccountIdMap)) {
|
||||
continue;
|
||||
}
|
||||
@@ -213,11 +212,9 @@ class Adapter implements WeChatServiceInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 判断24h内加的好友数量,friend_task 先固定10个人 getLast24hAddedFriendsCount
|
||||
$last24hAddedFriendsCount = $this->getLast24hAddedFriendsCount($wechatId);
|
||||
if ($last24hAddedFriendsCount >= 10) {
|
||||
if ($last24hAddedFriendsCount >= 20) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -233,14 +230,15 @@ class Adapter implements WeChatServiceInterface
|
||||
$task['processed_wechat_ids'] = $task['processed_wechat_ids'] . ',' . $wechatId; // 处理失败任务用,用于过滤已处理的微信号
|
||||
break;
|
||||
}
|
||||
Db::name('task_customer')
|
||||
$res = Db::name('task_customer')
|
||||
->where('id', $task['id'])
|
||||
->update([
|
||||
'status' => $friendAddTaskCreated ? 1 : 3,
|
||||
'fail_reason' => $friendAddTaskCreated ? '' : '已经是好友了',
|
||||
'processed_wechat_ids' => $task['processed_wechat_ids'],
|
||||
'updated_at' => time()
|
||||
]); // ~~不用管,回头再添加再判断即可~~
|
||||
'updateTime' => time()
|
||||
]);
|
||||
// ~~不用管,回头再添加再判断即可~~
|
||||
// 失败一定是另一个进程/定时器在检查的
|
||||
|
||||
}
|
||||
@@ -254,9 +252,9 @@ class Adapter implements WeChatServiceInterface
|
||||
|
||||
$tasks = Db::name('task_customer')
|
||||
->whereIn('status', [1,2])
|
||||
->where('updated_at', '>=', (time() - 86400 * 3))
|
||||
->where('updateTime', '>=', (time() - 86400 * 3))
|
||||
->limit(50)
|
||||
->order('updated_at DESC')
|
||||
->order('updateTime DESC')
|
||||
->select();
|
||||
|
||||
if (empty($tasks)) {
|
||||
@@ -296,7 +294,7 @@ class Adapter implements WeChatServiceInterface
|
||||
|
||||
Db::name('task_customer')
|
||||
->where('id', $task['id'])
|
||||
->update(['status' => 4, 'updated_at' => time()]);
|
||||
->update(['status' => 4, 'updateTime' => time()]);
|
||||
|
||||
$wechatFriendRecord = $this->getWeChatAccoutIdAndFriendIdByWeChatIdAndFriendPhone($passedWeChatId, $task['phone']);
|
||||
$msgConf = is_string($task_info['msgConf']) ? json_decode($task_info['msgConf'], 1) : $task_info['msgConf'];
|
||||
@@ -316,7 +314,7 @@ class Adapter implements WeChatServiceInterface
|
||||
if (isset($latestFriendTask['status']) && $latestFriendTask['status'] == 1) {
|
||||
Db::name('task_customer')
|
||||
->where('id', $task['id'])
|
||||
->update(['status' => 2, 'updated_at' => time()]);
|
||||
->update(['status' => 2, 'updateTime' => time()]);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -324,7 +322,7 @@ class Adapter implements WeChatServiceInterface
|
||||
if (isset($latestFriendTask['status']) && $latestFriendTask['status'] == 2) {
|
||||
Db::name('task_customer')
|
||||
->where('id', $task['id'])
|
||||
->update(['status' => 3, 'fail_reason' => $latestFriendTask['extra'] ?? '未知原因', 'updated_at' => time()]);
|
||||
->update(['status' => 3, 'fail_reason' => $latestFriendTask['extra'] ?? '未知原因', 'updateTime' => time()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user