好友/群聊迁移优化

This commit is contained in:
wong
2025-11-28 16:04:29 +08:00
parent 5691d78004
commit 0244871fc1
2 changed files with 24 additions and 23 deletions

View File

@@ -84,25 +84,25 @@ class DataProcessing extends BaseController
if (!empty($wechatFriendId)){ if (!empty($wechatFriendId)){
$dsta = WechatFriendModel::where(['id' => $wechatFriendId,'wechatAccountId' => $wechatAccountId])->find(); $data = WechatFriendModel::where(['id' => $wechatFriendId,'wechatAccountId' => $wechatAccountId])->find();
$msg = '好友转移成功'; $msg = '好友转移成功';
if(empty($ddta)){ if(empty($data)){
return ResponseHelper::error('好友不存在'); return ResponseHelper::error('好友不存在');
} }
} }
if (!empty($wechatChatroomId)){ if (!empty($wechatChatroomId)){
$dsta = WechatChatroomModel::where(['id' => $wechatChatroomId,'wechatAccountId' => $wechatAccountId])->find(); $data = WechatChatroomModel::where(['id' => $wechatChatroomId,'wechatAccountId' => $wechatAccountId])->find();
$msg = '群聊转移成功'; $msg = '群聊转移成功';
if(empty($ddta)){ if(empty($data)){
return ResponseHelper::error('群聊不存在'); return ResponseHelper::error('群聊不存在');
} }
} }
$dsta->accountId = $toAccountId; $data->accountId = $toAccountId;
$dsta->updateTime = time(); $data->updateTime = time();
$dsta->save(); $data->save();
break; break;
case 'CmdNewMessage': case 'CmdNewMessage':
if(empty($friendMessage) && empty($chatroomMessage)){ if(empty($friendMessage) && empty($chatroomMessage)){

View File

@@ -307,7 +307,7 @@ class Adapter implements WeChatServiceInterface
$conf = array_merge($task_info['reqConf'], ['task_name' => $task_info['name'], 'tags' => $tags]); $conf = array_merge($task_info['reqConf'], ['task_name' => $task_info['name'], 'tags' => $tags]);
$this->createFriendAddTask($accountId, $task['phone'], $conf); $this->createFriendAddTask($accountId, $task['phone'], $conf, $task['remark']);
$friendAddTaskCreated = true; $friendAddTaskCreated = true;
$task['processed_wechat_ids'] = $task['processed_wechat_ids'] . ',' . $wechatId; // 处理失败任务用,用于过滤已处理的微信号 $task['processed_wechat_ids'] = $task['processed_wechat_ids'] . ',' . $wechatId; // 处理失败任务用,用于过滤已处理的微信号
break; break;
@@ -951,28 +951,29 @@ class Adapter implements WeChatServiceInterface
} }
// 创建添加好友任务/执行添加 // 创建添加好友任务/执行添加
public function createFriendAddTask(int $wechatAccountId, string $phone, array $conf) public function createFriendAddTask(int $wechatAccountId, string $phone, array $conf, $remark = '')
{ {
if (empty($wechatAccountId) || empty($phone) || empty($conf)) { if (empty($wechatAccountId) || empty($phone) || empty($conf)) {
return; return;
} }
switch ($conf['remarkType']) { if (empty($remark)){
case 'phone': switch ($conf['remarkType']) {
$remark = $phone . '-' . $conf['task_name']; case 'phone':
break; $remark = $phone . '-' . $conf['task_name'];
case 'nickname': break;
$remark = ''; case 'nickname':
break; $remark = '';
case 'source': break;
$remark = $conf['task_name']; case 'source':
break; $remark = $conf['task_name'];
default: break;
$remark = ''; default:
break; $remark = '';
break;
}
} }
$tags = []; $tags = [];
if (!empty($conf['tags'])) { if (!empty($conf['tags'])) {
if (is_array($conf['tags'])) { if (is_array($conf['tags'])) {