From ab5885f2a025532ab19d2715dc5f0739d4225d6a Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Sat, 31 Jan 2026 15:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/MessageController.php | 16 +-- .../controller/WechatChatroomController.php | 8 +- .../controller/AiSettingsController.php | 2 +- .../chukebao/controller/MessageController.php | 122 +++++++++--------- .../application/common/model/TrafficPool.php | 2 +- .../common/model/TrafficSource.php | 2 +- .../common/model/TrafficSourcePackage.php | 2 +- .../common/model/TrafficSourcePackageItem.php | 2 +- Server/application/cunkebao/config/route.php | 13 +- .../cunkebao/controller/RFMController.php | 6 +- .../cunkebao/controller/TrafficController.php | 10 +- .../plan/PostExternalApiV1Controller.php | 4 +- .../plan/PosterWeChatMiniProgram.php | 12 +- ...ConvertedListWithInCompanyV1Controller.php | 2 +- ...PotentialListWithInCompanyV1Controller.php | 48 +++---- .../wechat/GetWechatProfileV1Controller.php | 2 +- .../workbench/WorkbenchController.php | 12 +- .../workbench/WorkbenchHelperController.php | 4 +- .../WorkbenchImportContactController.php | 4 +- .../job/WorkbenchGroupCreateJob.php | 2 +- .../application/job/WorkbenchGroupPushJob.php | 6 +- .../job/WorkbenchImportContactJob.php | 14 +- .../store/model/TrafficOrderModel.php | 2 +- .../application/superadmin/config/route.php | 10 +- .../controller/auth/AuthLoginController.php | 94 ++++---------- .../traffic/GetPoolListController.php | 2 +- .../Adapters/ChuKeBao/Adapter.php | 6 +- 27 files changed, 185 insertions(+), 224 deletions(-) diff --git a/Server/application/api/controller/MessageController.php b/Server/application/api/controller/MessageController.php index 0b449fde2..5ce747e35 100644 --- a/Server/application/api/controller/MessageController.php +++ b/Server/application/api/controller/MessageController.php @@ -110,7 +110,7 @@ class MessageController extends BaseController if (!empty($messageResponse)) { foreach ($messageResponse as $item) { if (is_array($item)) { - $this->saveMessage($item); + $this->saveMessage($item); } } } @@ -187,7 +187,7 @@ class MessageController extends BaseController if (!empty($response)) { foreach ($response as $item) { if (is_array($item)) { - $this->saveMessage($item); + $this->saveMessage($item); } } } @@ -300,7 +300,7 @@ class MessageController extends BaseController if (!empty($messageResponse)) { foreach ($messageResponse as $item) { if (is_array($item)) { - $this->saveChatroomMessage($item); + $this->saveChatroomMessage($item); } } } @@ -378,11 +378,11 @@ class MessageController extends BaseController if (!empty($response)) { foreach ($response as $item) { if (is_array($item)) { - $res = $this->saveChatroomMessage($item); - if(!$res){ - return errorJson('保存群聊消息失败'); + $res = $this->saveChatroomMessage($item); + if(!$res){ + return errorJson('保存群聊消息失败'); } - } + } } } @@ -472,7 +472,7 @@ class MessageController extends BaseController if (!empty($res) && empty($item['isSend']) && in_array($item['msgType'],[1,3,20,34,40,42,43,47,49])){ $friend = Db::name('wechat_friendship')->where('id',$item['wechatFriendId'])->find(); if (!empty($friend)){ - $trafficPoolId = Db::name('traffic_pool')->where('identifier',$friend['wechatId'])->value('id'); + $trafficPoolId = Db::name('traffic_pool_v1')->where('identifier',$friend['wechatId'])->value('id'); if (!empty($trafficPoolId)){ $data = [ 'type' => 4, diff --git a/Server/application/api/controller/WechatChatroomController.php b/Server/application/api/controller/WechatChatroomController.php index e4001bb3b..c47a00840 100644 --- a/Server/application/api/controller/WechatChatroomController.php +++ b/Server/application/api/controller/WechatChatroomController.php @@ -68,9 +68,9 @@ class WechatChatroomController extends BaseController $isUpdate = false; foreach ($response['results'] as $item) { if (is_array($item)) { - $updated = $this->saveChatroom($item); - if($updated && $isDel == 0){ - $isUpdate = true; + $updated = $this->saveChatroom($item); + if($updated && $isDel == 0){ + $isUpdate = true; } } } @@ -195,7 +195,7 @@ class WechatChatroomController extends BaseController if (!empty($response)) { foreach ($response as $item) { if (is_array($item)) { - $this->saveChatroomMember($item, $chatroomId); + $this->saveChatroomMember($item, $chatroomId); } } } diff --git a/Server/application/chukebao/controller/AiSettingsController.php b/Server/application/chukebao/controller/AiSettingsController.php index bef43ac21..3fe9da487 100644 --- a/Server/application/chukebao/controller/AiSettingsController.php +++ b/Server/application/chukebao/controller/AiSettingsController.php @@ -196,7 +196,7 @@ class AiSettingsController extends BaseController return ResponseHelper::error('参数缺失'); } //列出所有好友 - $row = Db::name('traffic_source_package_item')->alias('a') + $row = Db::name('traffic_source_package_item_v1')->alias('a') ->join('wechat_friendship f','a.identifier = f.wechatId and f.companyId = '.$companyId) ->join(['s2_wechat_account' => 'wa'],'f.ownerWechatId = wa.wechatId') ->whereIn('a.packageId' , $packageId) diff --git a/Server/application/chukebao/controller/MessageController.php b/Server/application/chukebao/controller/MessageController.php index 0f6b939a4..9ae05738d 100644 --- a/Server/application/chukebao/controller/MessageController.php +++ b/Server/application/chukebao/controller/MessageController.php @@ -31,74 +31,74 @@ class MessageController extends BaseController } // 直接查询好友ID列表 - $ids = Db::table('s2_wechat_friend') - ->where(['accountId' => $accountId, 'isDeleted' => 0]) - ->column('id'); - $friendIds = empty($ids) ? [0] : $ids; // 避免 IN 查询为空 + $ids = Db::table('s2_wechat_friend') + ->where(['accountId' => $accountId, 'isDeleted' => 0]) + ->column('id'); + $friendIds = empty($ids) ? [0] : $ids; // 避免 IN 查询为空 // 直接查询好友信息 - $friends = Db::table('s2_wechat_friend') - ->where(['accountId' => $accountId, 'isDeleted' => 0]) - ->column('id,nickname,avatar,conRemark,labels,groupId,wechatAccountId,wechatId,extendFields,phone,region,isTop'); + $friends = Db::table('s2_wechat_friend') + ->where(['accountId' => $accountId, 'isDeleted' => 0]) + ->column('id,nickname,avatar,conRemark,labels,groupId,wechatAccountId,wechatId,extendFields,phone,region,isTop'); // 直接查询群聊信息 - $chatrooms = Db::table('s2_wechat_chatroom') - ->where(['accountId' => $accountId, 'isDeleted' => 0]) - ->column('id,nickname,chatroomAvatar,chatroomId,isTop'); + $chatrooms = Db::table('s2_wechat_chatroom') + ->where(['accountId' => $accountId, 'isDeleted' => 0]) + ->column('id,nickname,chatroomAvatar,chatroomId,isTop'); - // 获取群聊ID列表 - $chatroomIds = array_keys($chatrooms); - if (empty($chatroomIds)) { - $chatroomIds = [0]; - } - - // 1. 查询群聊最新消息 - $chatroomMessages = []; - if (!empty($chatroomIds) && $chatroomIds[0] != 0) { - $chatroomIdsStr = implode(',', array_map('intval', $chatroomIds)); - $chatroomLatestQuery = " - SELECT wc.id as chatroomId, m.id, m.content, m.wechatChatroomId, m.createTime, m.wechatTime, m.wechatAccountId, - wc.nickname, wc.chatroomAvatar as avatar, wc.chatroomId, wc.isTop, 2 as msgType - FROM s2_wechat_chatroom wc - INNER JOIN ( - SELECT wechatChatroomId, MAX(wechatTime) as maxTime, MAX(id) as maxId - FROM s2_wechat_message - WHERE type = 2 AND wechatChatroomId IN ({$chatroomIdsStr}) - GROUP BY wechatChatroomId - ) latest ON wc.id = latest.wechatChatroomId - INNER JOIN s2_wechat_message m ON m.wechatChatroomId = latest.wechatChatroomId - AND m.wechatTime = latest.maxTime AND m.id = latest.maxId - WHERE wc.accountId = {$accountId} AND wc.isDeleted = 0 - "; - $chatroomMessages = Db::query($chatroomLatestQuery); - } + // 获取群聊ID列表 + $chatroomIds = array_keys($chatrooms); + if (empty($chatroomIds)) { + $chatroomIds = [0]; + } + + // 1. 查询群聊最新消息 + $chatroomMessages = []; + if (!empty($chatroomIds) && $chatroomIds[0] != 0) { + $chatroomIdsStr = implode(',', array_map('intval', $chatroomIds)); + $chatroomLatestQuery = " + SELECT wc.id as chatroomId, m.id, m.content, m.wechatChatroomId, m.createTime, m.wechatTime, m.wechatAccountId, + wc.nickname, wc.chatroomAvatar as avatar, wc.chatroomId, wc.isTop, 2 as msgType + FROM s2_wechat_chatroom wc + INNER JOIN ( + SELECT wechatChatroomId, MAX(wechatTime) as maxTime, MAX(id) as maxId + FROM s2_wechat_message + WHERE type = 2 AND wechatChatroomId IN ({$chatroomIdsStr}) + GROUP BY wechatChatroomId + ) latest ON wc.id = latest.wechatChatroomId + INNER JOIN s2_wechat_message m ON m.wechatChatroomId = latest.wechatChatroomId + AND m.wechatTime = latest.maxTime AND m.id = latest.maxId + WHERE wc.accountId = {$accountId} AND wc.isDeleted = 0 + "; + $chatroomMessages = Db::query($chatroomLatestQuery); + } - // 2. 查询好友最新消息 - $friendMessages = []; - if (!empty($friendIds) && $friendIds[0] != 0) { - $friendIdsStr = implode(',', array_map('intval', $friendIds)); - $friendLatestQuery = " - SELECT m.wechatFriendId, m.id, m.content, m.createTime, m.wechatTime, - f.wechatAccountId, 1 as msgType, 0 as isTop - FROM s2_wechat_message m - INNER JOIN ( - SELECT wechatFriendId, MAX(wechatTime) as maxTime, MAX(id) as maxId - FROM s2_wechat_message - WHERE type = 1 AND wechatFriendId IN ({$friendIdsStr}) - GROUP BY wechatFriendId - ) latest ON m.wechatFriendId = latest.wechatFriendId - AND m.wechatTime = latest.maxTime AND m.id = latest.maxId - INNER JOIN s2_wechat_friend f ON f.id = m.wechatFriendId - WHERE m.type = 1 AND m.wechatFriendId IN ({$friendIdsStr}) - "; - $friendMessages = Db::query($friendLatestQuery); - } + // 2. 查询好友最新消息 + $friendMessages = []; + if (!empty($friendIds) && $friendIds[0] != 0) { + $friendIdsStr = implode(',', array_map('intval', $friendIds)); + $friendLatestQuery = " + SELECT m.wechatFriendId, m.id, m.content, m.createTime, m.wechatTime, + f.wechatAccountId, 1 as msgType, 0 as isTop + FROM s2_wechat_message m + INNER JOIN ( + SELECT wechatFriendId, MAX(wechatTime) as maxTime, MAX(id) as maxId + FROM s2_wechat_message + WHERE type = 1 AND wechatFriendId IN ({$friendIdsStr}) + GROUP BY wechatFriendId + ) latest ON m.wechatFriendId = latest.wechatFriendId + AND m.wechatTime = latest.maxTime AND m.id = latest.maxId + INNER JOIN s2_wechat_friend f ON f.id = m.wechatFriendId + WHERE m.type = 1 AND m.wechatFriendId IN ({$friendIdsStr}) + "; + $friendMessages = Db::query($friendLatestQuery); + } - // 合并结果并排序 - $allMessages = array_merge($chatroomMessages, $friendMessages); - usort($allMessages, function ($a, $b) { - return $b['wechatTime'] <=> $a['wechatTime']; - }); + // 合并结果并排序 + $allMessages = array_merge($chatroomMessages, $friendMessages); + usort($allMessages, function ($a, $b) { + return $b['wechatTime'] <=> $a['wechatTime']; + }); // 计算总数 $totalCount = count($allMessages); diff --git a/Server/application/common/model/TrafficPool.php b/Server/application/common/model/TrafficPool.php index c7ce2450e..7ef550be6 100644 --- a/Server/application/common/model/TrafficPool.php +++ b/Server/application/common/model/TrafficPool.php @@ -10,7 +10,7 @@ use think\Model; class TrafficPool extends Model { // 设置数据表名 - protected $name = 'traffic_pool'; + protected $name = 'traffic_pool_v1'; // 自动写入时间戳 protected $autoWriteTimestamp = true; diff --git a/Server/application/common/model/TrafficSource.php b/Server/application/common/model/TrafficSource.php index 4b2ae6764..f3e3a1b05 100644 --- a/Server/application/common/model/TrafficSource.php +++ b/Server/application/common/model/TrafficSource.php @@ -18,7 +18,7 @@ class TrafficSource extends Model // 设置数据表名 - protected $name = 'traffic_source'; + protected $name = 'traffic_source_v1'; // 自动写入时间戳 protected $autoWriteTimestamp = true; diff --git a/Server/application/common/model/TrafficSourcePackage.php b/Server/application/common/model/TrafficSourcePackage.php index c9c5e6112..5ff3d5c6b 100644 --- a/Server/application/common/model/TrafficSourcePackage.php +++ b/Server/application/common/model/TrafficSourcePackage.php @@ -11,7 +11,7 @@ class TrafficSourcePackage extends Model { // 设置数据表名 - protected $name = 'traffic_source_package'; + protected $name = 'traffic_source_package_v1'; } \ No newline at end of file diff --git a/Server/application/common/model/TrafficSourcePackageItem.php b/Server/application/common/model/TrafficSourcePackageItem.php index 923d842ec..d72992dc7 100644 --- a/Server/application/common/model/TrafficSourcePackageItem.php +++ b/Server/application/common/model/TrafficSourcePackageItem.php @@ -11,7 +11,7 @@ class TrafficSourcePackageItem extends Model { // 设置数据表名 - protected $name = 'traffic_source_package_item'; + protected $name = 'traffic_source_package_item_v1'; } \ No newline at end of file diff --git a/Server/application/cunkebao/config/route.php b/Server/application/cunkebao/config/route.php index f1c7964e6..687578cfc 100644 --- a/Server/application/cunkebao/config/route.php +++ b/Server/application/cunkebao/config/route.php @@ -233,7 +233,18 @@ Route::group('v1/', function () { }); }); - + // 客户标签功能 + Route::group('tag', function () { + // 通过标识查询标签 + Route::post('query-by-identifiers', 'app\cunkebao\controller\tag\QueryTagsByIdentifiersController@index'); + Route::post('query-by-phone', 'app\cunkebao\controller\tag\QueryTagsByIdentifiersController@byPhone'); // 快捷方法:通过手机号查询 + Route::post('query-by-wechat', 'app\cunkebao\controller\tag\QueryTagsByIdentifiersController@byWechat'); // 快捷方法:通过微信号查询 + + // 通过标签查询用户 + Route::post('query-users-by-tags', 'app\cunkebao\controller\tag\QueryUsersByTagsController@index'); + Route::get('high-value-users', 'app\cunkebao\controller\tag\QueryUsersByTagsController@highValueUsers'); // 快捷方法:查询高价值用户 + Route::get('vip-users', 'app\cunkebao\controller\tag\QueryUsersByTagsController@vipUsers'); // 快捷方法:查询VIP用户 + }); })->middleware(['jwt']); diff --git a/Server/application/cunkebao/controller/RFMController.php b/Server/application/cunkebao/controller/RFMController.php index f9163db1a..0fb4daef5 100644 --- a/Server/application/cunkebao/controller/RFMController.php +++ b/Server/application/cunkebao/controller/RFMController.php @@ -170,7 +170,7 @@ class RFMController extends BaseController return $b['RFM_score'] <=> $a['RFM_score']; }); - // 6. 更新 ck_traffic_source 和 s2_wechat_friend 表的RFM值 + // 6. 更新 ck_traffic_source_v1 和 s2_wechat_friend 表的RFM值 $this->updateRfmToTables($results, $ownerWechatId); return [ @@ -352,7 +352,7 @@ class RFMController extends BaseController } /** - * 更新RFM值到 ck_traffic_source 和 s2_wechat_friend 表 + * 更新RFM值到 ck_traffic_source_v1 和 s2_wechat_friend 表 * * @param array $results RFM计算结果数组 * @param string|null $ownerWechatId 微信ID,用于过滤更新范围 @@ -366,7 +366,7 @@ class RFMController extends BaseController $fScore = (string)$result['F_score']; $mScore = (string)$result['M_score']; - // 更新 ck_traffic_source 表 + // 更新 ck_traffic_source_v1 表 // 根据 identifier 更新所有匹配的记录 $trafficSourceUpdate = [ 'R' => $rScore, diff --git a/Server/application/cunkebao/controller/TrafficController.php b/Server/application/cunkebao/controller/TrafficController.php index 548db171b..711214f45 100644 --- a/Server/application/cunkebao/controller/TrafficController.php +++ b/Server/application/cunkebao/controller/TrafficController.php @@ -25,8 +25,8 @@ class TrafficController extends BaseController $keyword = $this->request->param('keyword', ''); $companyId = $this->getUserInfo('companyId'); - $package = Db::name('traffic_source_package')->alias('tsp') - ->join('traffic_source_package_item tspi', 'tspi.packageId=tsp.id', 'left') + $package = Db::name('traffic_source_package_v1')->alias('tsp') + ->join('traffic_source_package_item_v1 tspi', 'tspi.packageId=tsp.id', 'left') ->whereIn('tsp.companyId', [$companyId, 0]) ->field('tsp.id,tsp.name,tsp.description,tsp.pic,tsp.isSys as type,tsp.createTime,count(tspi.id) as num') ->group('tsp.id'); @@ -412,7 +412,7 @@ class TrafficController extends BaseController 'wa.nickname', 'wa.avatar', 'wa.gender', 'wa.phone', 'wa.alias' ] ) - ->join('traffic_pool p', 'p.identifier=tspi.identifier', 'left') + ->join('traffic_pool_v1 p', 'p.identifier=tspi.identifier', 'left') ->join('wechat_account wa', 'tspi.identifier=wa.wechatId', 'left') ->where($where); @@ -424,7 +424,7 @@ class TrafficController extends BaseController foreach ($list as $k => &$v) { //流量池筛选 $package = TrafficSourcePackageItem::alias('tspi') - ->join('traffic_source_package p', 'tspi.packageId=p.id AND tspi.companyId=p.companyId') + ->join('traffic_source_package_v1 p', 'tspi.packageId=p.id AND tspi.companyId=p.companyId') ->where(['tspi.identifier' => $v['identifier']]) ->whereIn('tspi.companyId', [0, $v['companyId']]) ->column('p.name'); @@ -497,7 +497,7 @@ class TrafficController extends BaseController foreach ($list as $k => &$v) { // 获取好友所属的流量池包 $package = TrafficSourcePackageItem::alias('tspi') - ->join('traffic_source_package p', 'tspi.packageId=p.id AND tspi.companyId=p.companyId') + ->join('traffic_source_package_v1 p', 'tspi.packageId=p.id AND tspi.companyId=p.companyId') ->where(['tspi.identifier' => $v['identifier']]) ->whereIn('tspi.companyId', [0, $companyId]) ->column('p.name'); diff --git a/Server/application/cunkebao/controller/plan/PostExternalApiV1Controller.php b/Server/application/cunkebao/controller/plan/PostExternalApiV1Controller.php index 4edd546c4..6db49e5aa 100644 --- a/Server/application/cunkebao/controller/plan/PostExternalApiV1Controller.php +++ b/Server/application/cunkebao/controller/plan/PostExternalApiV1Controller.php @@ -96,9 +96,9 @@ class PostExternalApiV1Controller extends Controller $channelId = !empty($params['cid']) ? intval($params['cid']) : 0; - $trafficPool = Db::name('traffic_pool')->where('identifier', $identifier)->find(); + $trafficPool = Db::name('traffic_pool_v1')->where('identifier', $identifier)->find(); if (!$trafficPool) { - $trafficPoolId =Db::name('traffic_pool')->insertGetId([ + $trafficPoolId =Db::name('traffic_pool_v1')->insertGetId([ 'identifier' => $identifier, 'mobile' => !empty($params['phone']) ? $params['phone'] : '', 'createTime' => time() diff --git a/Server/application/cunkebao/controller/plan/PosterWeChatMiniProgram.php b/Server/application/cunkebao/controller/plan/PosterWeChatMiniProgram.php index 4ef33f1ad..756093cbe 100644 --- a/Server/application/cunkebao/controller/plan/PosterWeChatMiniProgram.php +++ b/Server/application/cunkebao/controller/plan/PosterWeChatMiniProgram.php @@ -113,10 +113,10 @@ class PosterWeChatMiniProgram extends Controller if ($result['errcode'] == 0 && isset($result['phone_info']['phoneNumber'])) { // TODO 拿到手机号之后的后续操作: - // 1. 先写入 ck_traffic_pool 表 identifier mobile 都是 用 phone字段的值 - $trafficPool = Db::name('traffic_pool')->where('identifier', $result['phone_info']['phoneNumber'])->find(); + // 1. 先写入 ck_traffic_pool_v1 表 identifier mobile 都是 用 phone字段的值 + $trafficPool = Db::name('traffic_pool_v1')->where('identifier', $result['phone_info']['phoneNumber'])->find(); if (!$trafficPool) { - Db::name('traffic_pool')->insert([ + Db::name('traffic_pool_v1')->insert([ 'identifier' => $result['phone_info']['phoneNumber'], 'mobile' => $result['phone_info']['phoneNumber'], 'createTime' => time() @@ -259,7 +259,7 @@ class PosterWeChatMiniProgram extends Controller continue; } $isPhone = preg_match('/^\+?\d{6,}$/', $identifier); - $trafficPool = Db::name('traffic_pool')->where('identifier', $identifier)->find(); + $trafficPool = Db::name('traffic_pool_v1')->where('identifier', $identifier)->find(); if (!$trafficPool) { $insertData = [ 'identifier' => $identifier, @@ -270,7 +270,7 @@ class PosterWeChatMiniProgram extends Controller } else { $insertData['wechatId'] = $identifier; } - Db::name('traffic_pool')->insert($insertData); + Db::name('traffic_pool_v1')->insert($insertData); } else { $updates = []; if ($isPhone && empty($trafficPool['mobile'])) { @@ -281,7 +281,7 @@ class PosterWeChatMiniProgram extends Controller } if (!empty($updates)) { $updates['updateTime'] = time(); - Db::name('traffic_pool')->where('id', $trafficPool['id'])->update($updates); + Db::name('traffic_pool_v1')->where('id', $trafficPool['id'])->update($updates); } } diff --git a/Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php b/Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php index b152c8dee..7321998ba 100644 --- a/Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php +++ b/Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php @@ -72,7 +72,7 @@ class GetConvertedListWithInCompanyV1Controller extends BaseController 'f.tags', 'f.createTime', TrafficSourceModel::STATUS_PASSED . ' status' ] ) - ->join('traffic_pool p', 'p.identifier=s.identifier') + ->join('traffic_pool_v1 p', 'p.identifier=s.identifier') ->join('wechat_account w', 'p.wechatId=w.wechatId') ->join('wechat_friendship f', 'w.wechatId=f.wechatId and f.deleteTime=0') ->order('s.id desc'); diff --git a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php index 434a1281d..c15dd3d86 100644 --- a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php +++ b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php @@ -83,10 +83,10 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController 'wa.nickname', 'wa.avatar', 'wa.gender', 'wa.phone', 'wa.alias' ] ) - ->join('traffic_source s', 'p.identifier=s.identifier') + ->join('traffic_source_v1 s', 'p.identifier=s.identifier') ->join('wechat_account wa', 'p.identifier=wa.wechatId', 'left') - ->join('traffic_source_package_item tspi', 'p.identifier = tspi.identifier AND s.companyId = tspi.companyId', 'left') - ->join('traffic_source_package tsp', 'tspi.packageId=tsp.id', 'left') + ->join('traffic_source_package_item_v1 tspi', 'p.identifier = tspi.identifier AND s.companyId = tspi.companyId', 'left') + ->join('traffic_source_package_v1 tsp', 'tspi.packageId=tsp.id', 'left') ->join('device_wechat_login d', 's.sourceId=d.wechatId', 'left') ->where($where); @@ -106,8 +106,8 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController if ($isPage) { foreach ($list as &$item) { //流量池筛选 - $package = Db::name('traffic_source_package_item')->alias('tspi') - ->join('traffic_source_package p', 'tspi.packageId=p.id AND tspi.companyId=p.companyId') + $package = Db::name('traffic_source_package_item_v1')->alias('tspi') + ->join('traffic_source_package_v1 p', 'tspi.packageId=p.id AND tspi.companyId=p.companyId') ->where(['tspi.identifier' => $item->identifier]) ->whereIn('tspi.companyId', [0, $item->companyId]) ->column('p.name'); @@ -181,7 +181,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController $data['lastMsgTime'] = ''; //来源 - $source = Db::name('traffic_source')->alias('ts') + $source = Db::name('traffic_source_v1')->alias('ts') ->field(['wa.nickname', 'wa.avatar', 'wa.gender', 'wa.phone', 'wa.wechatId', 'wa.alias', 'ts.createTime', 'wf.id as friendId', 'wf.wechatAccountId']) @@ -221,12 +221,12 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController //流量池 - $package = Db::name('traffic_source_package_item')->alias('tspi') + $package = Db::name('traffic_source_package_item_v1')->alias('tspi') ->join('traffic_source_package p', 'tspi.packageId=p.id AND tspi.companyId=p.companyId') ->where(['tspi.companyId' => $companyId, 'tspi.identifier' => $data['identifier']]) ->column('p.name'); - $package2 = Db::name('traffic_source_package_item')->alias('tspi') - ->join('traffic_source_package p', 'tspi.packageId=p.id') + $package2 = Db::name('traffic_source_package_item_v1')->alias('tspi') + ->join('traffic_source_package_v1 p', 'tspi.packageId=p.id') ->where(['tspi.companyId' => $companyId, 'tspi.identifier' => $data['identifier']]) ->column('p.name'); $packages = array_merge($package, $package2); @@ -328,7 +328,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController if (empty($userId)) { return json_encode(['code' => 500, 'msg' => '用户id不能为空']); } - $data = Db::name('traffic_pool')->alias('tp') + $data = Db::name('traffic_pool_v1')->alias('tp') ->join('wechat_friendship f', 'tp.wechatId=f.wechatId AND f.companyId=' . $companyId, 'left') ->join(['s2_wechat_friend' => 'wf'], 'f.wechatId=wf.wechatId', 'left') ->where(['tp.id' => $userId]) @@ -383,7 +383,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController } if (!empty($addPackageId)) { - $package = Db::name('traffic_source_package') + $package = Db::name('traffic_source_package_v1') ->where(['id' => $addPackageId, 'isDel' => 0]) ->whereIn('companyId', [$companyId, 0]) ->field('id,name') @@ -393,7 +393,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController } $packageId = $package['id']; } else { - $package = Db::name('traffic_source_package') + $package = Db::name('traffic_source_package_v1') ->where(['isDel' => 0, 'name' => $packageName]) ->whereIn('companyId', [$companyId, 0]) ->field('id,name') @@ -401,7 +401,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController if (!empty($package)) { return ResponseHelper::error('该流量池名称已存在'); } - $packageId = Db::name('traffic_source_package')->insertGetId([ + $packageId = Db::name('traffic_source_package_v1')->insertGetId([ 'userId' => $userId, 'companyId' => $companyId, 'name' => $packageName, @@ -424,8 +424,8 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController if (!is_array($userIds)) { return ResponseHelper::error('选择的用户类型错误'); } - $result = Db::name('traffic_pool')->alias('tp') - ->join('traffic_source tc', 'tp.identifier=tc.identifier') + $result = Db::name('traffic_pool_v1')->alias('tp') + ->join('traffic_source_v1 tc', 'tp.identifier=tc.identifier') ->whereIn('tp.id', $userIds) ->where(['companyId' => $companyId]) ->group('tp.identifier') @@ -513,7 +513,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController $batchRows = array_slice($result, $i, $batchSize); if (!empty($batchRows)) { // 2. 批量查询已存在的手机 - $existing = Db::name('traffic_source_package_item') + $existing = Db::name('traffic_source_package_item_v1') ->where(['companyId' => $companyId, 'packageId' => $packageId]) ->whereIn('identifier', $batchRows) ->field('identifier') @@ -533,7 +533,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController } // 4. 批量插入新数据 if (!empty($newData)) { - Db::name('traffic_source_package_item')->insertAll($newData); + Db::name('traffic_source_package_item_v1')->insertAll($newData); } } } @@ -549,7 +549,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController if (!empty($batchRows)) { $identifiers = array_column($batchRows, 'phone'); //流量池处理 - $existing = Db::name('traffic_pool') + $existing = Db::name('traffic_pool_v1') ->whereIn('identifier', $identifiers) ->column('identifier'); @@ -564,12 +564,12 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController } } if (!empty($newData)) { - Db::name('traffic_pool')->insertAll($newData); + Db::name('traffic_pool_v1')->insertAll($newData); } //流量池来源处理 $newData2 = []; - $existing2 = Db::name('traffic_source') + $existing2 = Db::name('traffic_source_v1') ->where(['companyId' => $companyId]) ->whereIn('identifier', $identifiers) ->column('identifier'); @@ -587,12 +587,12 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController } } if (!empty($newData2)) { - Db::name('traffic_source')->insertAll($newData2); + Db::name('traffic_source_v1')->insertAll($newData2); } //流量池包数据处理 $newData3 = []; - $existing3 = Db::name('traffic_source_package_item') + $existing3 = Db::name('traffic_source_package_item_v1') ->where(['companyId' => $companyId, 'packageId' => $packageId]) ->whereIn('identifier', $identifiers) ->field('identifier') @@ -608,7 +608,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController } } if (!empty($newData3)) { - Db::name('traffic_source_package_item')->insertAll($newData3); + Db::name('traffic_source_package_item_v1')->insertAll($newData3); } Db::commit(); @@ -638,7 +638,7 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController $isWechat = $this->request->param('isWechat', false); $companyId = $this->getUserInfo('companyId'); - $friend = Db::name('traffic_pool')->alias('tp') + $friend = Db::name('traffic_pool_v1')->alias('tp') ->join('wechat_friendship f', 'tp.wechatId=f.wechatId AND f.companyId='.$companyId, 'left') ->join(['s2_wechat_friend' => 'wf'], 'f.wechatId=wf.wechatId', 'left') ->where(['tp.id' => $userId]) diff --git a/Server/application/cunkebao/controller/wechat/GetWechatProfileV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatProfileV1Controller.php index ad7a7f5d5..cbd396104 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatProfileV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatProfileV1Controller.php @@ -55,7 +55,7 @@ class GetWechatProfileV1Controller extends BaseController { return (string)TrafficPoolModel::alias('p') ->field('t.id') - ->join('traffic_source s', 's.identifier = p.identifier') + ->join('traffic_source_v1 s', 's.identifier = p.identifier') ->where('p.wechatId', $wechatId) ->value('fromd'); } diff --git a/Server/application/cunkebao/controller/workbench/WorkbenchController.php b/Server/application/cunkebao/controller/workbench/WorkbenchController.php index 03c6a8250..9d5ed8b64 100644 --- a/Server/application/cunkebao/controller/workbench/WorkbenchController.php +++ b/Server/application/cunkebao/controller/workbench/WorkbenchController.php @@ -1002,8 +1002,8 @@ class WorkbenchController extends Controller // 处理普通流量池 if (!empty($normalPools)) { - $normalPoolList = Db::name('traffic_source_package')->alias('tsp') - ->leftJoin('traffic_source_package_item tspi', 'tspi.packageId = tsp.id and tspi.isDel = 0') + $normalPoolList = Db::name('traffic_source_package_v1')->alias('tsp') + ->leftJoin('traffic_source_package_item_v1 tspi', 'tspi.packageId = tsp.id and tspi.isDel = 0') ->whereIn('tsp.id', $normalPools) ->where('tsp.isDel', 0) ->whereIn('tsp.companyId', [$companyId, 0]) @@ -1042,8 +1042,8 @@ class WorkbenchController extends Controller } if (!empty($workbench->config->poolGroups)) { - $poolGroupsOptions = Db::name('traffic_source_package')->alias('tsp') - ->join('traffic_source_package_item tspi', 'tspi.packageId=tsp.id', 'left') + $poolGroupsOptions = Db::name('traffic_source_package_v1')->alias('tsp') + ->join('traffic_source_package_item_v1 tspi', 'tspi.packageId=tsp.id', 'left') ->whereIn('tsp.companyId', [$this->request->userInfo['companyId'], 0]) ->whereIn('tsp.id', $workbench->config->poolGroups) ->field('tsp.id,tsp.name,tsp.description,tsp.createTime,count(tspi.id) as num') @@ -2399,8 +2399,8 @@ class WorkbenchController extends Controller // 查询发布记录 $list = Db::name('workbench_import_contact_item')->alias('wici') - ->join('traffic_pool tp', 'tp.id = wici.poolId', 'left') - ->join('traffic_source tc', 'tc.identifier = tp.identifier', 'left') + ->join('traffic_pool_v1 tp', 'tp.id = wici.poolId', 'left') + ->join('traffic_source_v1 tc', 'tc.identifier = tp.identifier', 'left') ->join('wechat_account wa', 'wa.wechatId = tp.wechatId', 'left') ->field([ 'wici.id', diff --git a/Server/application/cunkebao/controller/workbench/WorkbenchHelperController.php b/Server/application/cunkebao/controller/workbench/WorkbenchHelperController.php index 7cf8b8e05..9115386d5 100644 --- a/Server/application/cunkebao/controller/workbench/WorkbenchHelperController.php +++ b/Server/application/cunkebao/controller/workbench/WorkbenchHelperController.php @@ -142,7 +142,7 @@ class WorkbenchHelperController extends Controller $keyword = $this->request->param('keyword', ''); $companyId = $this->request->userInfo['companyId']; - $baseQuery = Db::name('traffic_source_package')->alias('tsp') + $baseQuery = Db::name('traffic_source_package_v1')->alias('tsp') ->where('tsp.isDel', 0) ->whereIn('tsp.companyId', [$companyId, 0]); @@ -153,7 +153,7 @@ class WorkbenchHelperController extends Controller $total = (clone $baseQuery)->count(); $list = $baseQuery - ->leftJoin('traffic_source_package_item tspi', 'tspi.packageId = tsp.id and tspi.isDel = 0') + ->leftJoin('traffic_source_package_item_v1 tspi', 'tspi.packageId = tsp.id and tspi.isDel = 0') ->field('tsp.id,tsp.name,tsp.description,tsp.pic,tsp.companyId,COUNT(tspi.id) as itemCount,max(tspi.createTime) as latestImportTime') ->group('tsp.id') ->order('tsp.id', 'desc') diff --git a/Server/application/cunkebao/controller/workbench/WorkbenchImportContactController.php b/Server/application/cunkebao/controller/workbench/WorkbenchImportContactController.php index 1956d38d8..5e63e51d2 100644 --- a/Server/application/cunkebao/controller/workbench/WorkbenchImportContactController.php +++ b/Server/application/cunkebao/controller/workbench/WorkbenchImportContactController.php @@ -26,8 +26,8 @@ class WorkbenchImportContactController extends Controller // 查询发布记录 $list = Db::name('workbench_import_contact_item')->alias('wici') - ->join('traffic_pool tp', 'tp.id = wici.poolId', 'left') - ->join('traffic_source tc', 'tc.identifier = tp.identifier', 'left') + ->join('traffic_pool_v1 tp', 'tp.id = wici.poolId', 'left') + ->join('traffic_source_v1 tc', 'tc.identifier = tp.identifier', 'left') ->join('wechat_account wa', 'wa.wechatId = tp.wechatId', 'left') ->field([ 'wici.id', diff --git a/Server/application/job/WorkbenchGroupCreateJob.php b/Server/application/job/WorkbenchGroupCreateJob.php index dd846fe2c..ca20272bc 100644 --- a/Server/application/job/WorkbenchGroupCreateJob.php +++ b/Server/application/job/WorkbenchGroupCreateJob.php @@ -177,7 +177,7 @@ class WorkbenchGroupCreateJob // 处理普通流量池 if (!empty($normalPools)) { - $normalIdentifiers = Db::name('traffic_source_package_item') + $normalIdentifiers = Db::name('traffic_source_package_item_v1') ->whereIn('packageId', $normalPools) ->where('isDel', 0) ->group('identifier') diff --git a/Server/application/job/WorkbenchGroupPushJob.php b/Server/application/job/WorkbenchGroupPushJob.php index 771afc1f5..9d5473923 100644 --- a/Server/application/job/WorkbenchGroupPushJob.php +++ b/Server/application/job/WorkbenchGroupPushJob.php @@ -602,10 +602,10 @@ class WorkbenchGroupPushJob */ protected function getFriendsByNormalPools(array $packageIds, $companyId, array $ownerWechatIds = []) { - $query = Db::name('traffic_source_package_item') + $query = Db::name('traffic_source_package_item_v1') ->alias('tspi') - ->leftJoin('traffic_source_package tsp', 'tsp.id = tspi.packageId') - ->leftJoin('traffic_pool tp', 'tp.identifier = tspi.identifier') + ->leftJoin('traffic_source_package_v1 tsp', 'tsp.id = tspi.packageId') + ->leftJoin('traffic_pool_v1 tp', 'tp.identifier = tspi.identifier') ->leftJoin(['s2_wechat_friend' => 'wf'], 'wf.wechatId = tp.wechatId') ->leftJoin(['s2_wechat_account' => 'wa'], 'wa.id = wf.wechatAccountId') ->whereIn('tspi.packageId', $packageIds) diff --git a/Server/application/job/WorkbenchImportContactJob.php b/Server/application/job/WorkbenchImportContactJob.php index 95400d59c..992eeecff 100644 --- a/Server/application/job/WorkbenchImportContactJob.php +++ b/Server/application/job/WorkbenchImportContactJob.php @@ -339,15 +339,15 @@ class WorkbenchImportContactJob // 处理普通流量池 if (!empty($normalPools)) { //过滤已删除的数据 - $packageIds = Db::name('traffic_source_package') + $packageIds = Db::name('traffic_source_package_v1') ->where(['isDel' => 0]) ->whereIn('id', $normalPools) ->column('id'); if (!empty($packageIds)) { - $normalData = Db::name('traffic_source_package_item')->alias('tpi') - ->join('traffic_pool tp', 'tp.identifier = tpi.identifier') - ->join('traffic_source ts', 'ts.identifier = tpi.identifier','left') + $normalData = Db::name('traffic_source_package_item_v1')->alias('tpi') + ->join('traffic_pool_v1 tp', 'tp.identifier = tpi.identifier') + ->join('traffic_source_v1 ts', 'ts.identifier = tpi.identifier','left') ->join('workbench_import_contact_item wici', 'wici.poolId = tp.id AND wici.workbenchId = '.$workbench->id,'left') ->where('tp.mobile', '>',0) ->where('wici.id','null') @@ -389,10 +389,10 @@ class WorkbenchImportContactJob return []; } - // 从 s2_wechat_friend 表获取好友,然后关联 traffic_pool 表获取手机号 + // 从 s2_wechat_friend 表获取好友,然后关联 traffic_pool_v1 表获取手机号 $data = Db::table('s2_wechat_friend')->alias('wf') - ->join('traffic_pool tp', 'tp.wechatId = wf.wechatId', 'left') - ->join('traffic_source ts', 'ts.identifier = tp.identifier', 'left') + ->join('traffic_pool_v1 tp', 'tp.wechatId = wf.wechatId', 'left') + ->join('traffic_source_v1 ts', 'ts.identifier = tp.identifier', 'left') ->join('workbench_import_contact_item wici', 'wici.poolId = tp.id AND wici.workbenchId = '.$workbench->id, 'left') ->where('wf.ownerWechatId', 'in', $wechatIds) ->where('wf.isDeleted', 0) diff --git a/Server/application/store/model/TrafficOrderModel.php b/Server/application/store/model/TrafficOrderModel.php index 4d51d66f1..88221e1b6 100644 --- a/Server/application/store/model/TrafficOrderModel.php +++ b/Server/application/store/model/TrafficOrderModel.php @@ -6,6 +6,6 @@ use think\Model; class TrafficOrderModel extends Model { - protected $name = 'traffic_order'; + protected $name = 'traffic_order_v1'; } \ No newline at end of file diff --git a/Server/application/superadmin/config/route.php b/Server/application/superadmin/config/route.php index 337cdfcb6..49f22e823 100644 --- a/Server/application/superadmin/config/route.php +++ b/Server/application/superadmin/config/route.php @@ -3,10 +3,10 @@ use think\facade\Route; // 超级管理员认证相关路由(不需要鉴权) -Route::post('auth/login', 'app\superadmin\controller\auth\AuthLoginController@index'); +Route::post('v1/admin/auth/login', 'app\superadmin\controller\auth\AuthLoginController@index'); -// 需要登录认证的路由组 -Route::group('', function () { +// 需要登录认证的路由组(使用通用 JWT 中间件) +Route::group('v1/admin', function () { // 仪表盘概述 Route::group('dashboard', function () { Route::get('base', 'app\superadmin\controller\dashboard\GetBasestatisticsController@index'); @@ -33,7 +33,7 @@ Route::group('', function () { Route::get('detail', 'app\superadmin\controller\traffic\GetPoolDetailController@index'); }); - // 设备管理吗 + // 设备管理 Route::group('devices', function () { Route::get('add-results', 'app\superadmin\controller\devices\GetAddResultedDevicesController@index'); }); @@ -49,4 +49,4 @@ Route::group('', function () { Route::get('devices', 'app\superadmin\controller\company\GetCompanyDevicesForProfileController@index'); Route::get('subusers', 'app\superadmin\controller\company\GetCompanySubusersForProfileController@index'); }); -})->middleware(['app\superadmin\middleware\AdminAuth']); \ No newline at end of file +})->middleware(['jwt']); \ No newline at end of file diff --git a/Server/application/superadmin/controller/auth/AuthLoginController.php b/Server/application/superadmin/controller/auth/AuthLoginController.php index 0c52e2953..bd0fddb13 100644 --- a/Server/application/superadmin/controller/auth/AuthLoginController.php +++ b/Server/application/superadmin/controller/auth/AuthLoginController.php @@ -3,24 +3,13 @@ namespace app\superadmin\controller\auth; use app\common\model\Administrator as AdministratorModel; -use app\superadmin\controller\administrator\DeleteAdministratorController; +use app\common\util\JwtUtil; use library\ResponseHelper; use think\Controller; use think\Validate; -use think\facade\Cookie; class AuthLoginController extends Controller { - /** - * 创建登录令牌 - * @param DeleteAdministratorController $admin - * @return string - */ - protected function createToken(AdministratorModel $admin): string - { - return md5($admin->id . '|' . $admin->account . 'cunkebao_admin_secret'); - } - /** * 数据验证 * @@ -87,57 +76,6 @@ class AuthLoginController extends Controller return $this; } - /** - * 设置登录Cookie,有效期24小时 - * - * @param AdministratorModel $admin - * @return void - */ - protected function setCookie(AdministratorModel $admin): void - { - // 获取当前环境 - $env = app()->env->get('APP_ENV', 'production'); - - // 获取请求的域名 - $origin = $this->request->header('origin'); - $domain = ''; - - if ($origin) { - // 解析域名 - $parsedUrl = parse_url($origin); - if (isset($parsedUrl['host'])) { - // 如果是测试环境,使用完整的域名 - if ($env === 'testing') { - $domain = $parsedUrl['host']; - } else { - // 生产环境使用顶级域名 - $parts = explode('.', $parsedUrl['host']); - if (count($parts) > 1) { - $domain = '.' . $parts[count($parts) - 2] . '.' . $parts[count($parts) - 1]; - } - } - } - } - - // 设置cookie选项 - $options = [ - 'expire' => 86400, - 'path' => '/', - 'httponly' => true, - 'samesite' => 'None', // 允许跨域 - 'secure' => true // 仅 HTTPS 下有效 - ]; - - // 如果有域名,添加到选项 - if ($domain) { - $options['domain'] = $domain; - } - - // 设置cookies - Cookie::set('admin_id', $admin->id, $options); - Cookie::set('admin_token', $this->createToken($admin), $options); - } - /** * 管理员登录 * @@ -149,16 +87,28 @@ class AuthLoginController extends Controller $params = $this->request->only(['account', 'password']); $admin = $this->dataValidate($params)->getAdministrator($params); - $this->saveLoginInfo($admin)->setCookie($admin); + $this->saveLoginInfo($admin); - return ResponseHelper::success( - [ - 'id' => $admin->id, - 'name' => $admin->username, - 'account' => $admin->account, - 'token' => Cookie::get('admin_token') - ] - ); + // 生成 JWT 令牌(默认有效期 24 小时) + $expire = 86400; + $payload = [ + 'id' => $admin->id, + 'account' => $admin->account, + 'username' => $admin->username, + 'authId' => $admin->authId ?? 0, + 'role' => 'superadmin', + ]; + + $token = JwtUtil::createToken($payload, $expire); + + return ResponseHelper::success([ + 'id' => $admin->id, + 'name' => $admin->username, + 'account' => $admin->account, + 'authId' => $admin->authId ?? 0, + 'token' => $token, + 'token_expired' => time() + $expire, + ]); } catch (\Exception $e) { return ResponseHelper::error($e->getMessage(), $e->getCode()); } diff --git a/Server/application/superadmin/controller/traffic/GetPoolListController.php b/Server/application/superadmin/controller/traffic/GetPoolListController.php index d19ce5d36..7b5671264 100644 --- a/Server/application/superadmin/controller/traffic/GetPoolListController.php +++ b/Server/application/superadmin/controller/traffic/GetPoolListController.php @@ -84,7 +84,7 @@ class GetPoolListController extends BaseController 'wa.avatar', 'wa.gender', 'wa.nickname', 'wa.region', 'wt.tags' ]) - ->join('traffic_source ts', 'tp.identifier = ts.identifier', 'RIGHT') + ->join('traffic_source_v1 ts', 'tp.identifier = ts.identifier', 'RIGHT') ->join('company c', 'ts.companyId = c.companyId', 'LEFT') ->join('wechat_account wa', 'tp.wechatId = wa.wechatId', 'LEFT') ->join('wechat_tag wt', 'wa.wechatId = wt.wechatId', 'LEFT'); diff --git a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php index cef710d24..e2f67c977 100644 --- a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php +++ b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php @@ -1295,7 +1295,7 @@ class Adapter implements WeChatServiceInterface for ($i = 0; $i < $batchCount; $i++) { $offset = $i * $batchSize; - $sql = "INSERT IGNORE INTO ck_traffic_pool(`identifier`, `wechatId`, `mobile`) + $sql = "INSERT IGNORE INTO ck_traffic_pool_v1(`identifier`, `wechatId`, `mobile`) SELECT t.wechatId AS identifier, t.wechatId, (SELECT phone FROM s2_wechat_friend WHERE wechatId = t.wechatId LIMIT 1) AS mobile @@ -1565,7 +1565,7 @@ class Adapter implements WeChatServiceInterface public function syncTrafficSourceUser() { - $sql = "insert into ck_traffic_source(`identifier`,companyId,`fromd`,`sourceId`,`createTime`,`type`, `status`) + $sql = "insert into ck_traffic_source_v1(`identifier`,companyId,`fromd`,`sourceId`,`createTime`,`type`, `status`) SELECT f.wechatId identifier, c.departmentId companyId, @@ -1600,7 +1600,7 @@ class Adapter implements WeChatServiceInterface public function syncTrafficSourceGroup() { - $sql = "insert into ck_traffic_source(`identifier`,companyId,`fromd`,`sourceId`,`createTime`,`type`, `status`) + $sql = "insert into ck_traffic_source_v1(`identifier`,companyId,`fromd`,`sourceId`,`createTime`,`type`, `status`) SELECT m.wechatId identifier, c.departmentId companyId,