代码优化

This commit is contained in:
wong
2025-07-22 16:03:09 +08:00
parent 3bd7290846
commit 00b56f75fe

View File

@@ -1228,12 +1228,13 @@ class Adapter implements WeChatServiceInterface
public function syncTrafficSourceUser()
{
$sql = "insert into ck_traffic_source(`identifier`,companyId,`fromd`,`sourceId`)
$sql = "insert into ck_traffic_source(`identifier`,companyId,`fromd`,`sourceId`,`createTime`)
SELECT
f.wechatId identifier,
c.departmentId companyId,
f.ownerNickname fromd,
f.ownerWechatId sourceId
f.ownerWechatId sourceId,
f.createTime createTime
FROM
s2_wechat_friend f
LEFT JOIN s2_wechat_account a ON f.wechatAccountId = a.id
@@ -1260,19 +1261,20 @@ class Adapter implements WeChatServiceInterface
public function syncTrafficSourceGroup()
{
$sql = "insert into ck_traffic_source(`identifier`,companyId,`fromd`,`sourceId`)
SELECT
m.wechatId identifier,
c.departmentId companyId,
r.nickname fromd,
f.ownerWechatId sourceId
FROM
s2_wechat_chatroom_member m
JOIN s2_wechat_chatroom r ON m.chatroomId = r.chatroomId
LEFT JOIN s2_wechat_account a ON a.id = r.wechatAccountId
LEFT JOIN s2_company_account c on c.id = a.deviceAccountId
ORDER BY m.id DESC
GROUP BY m.wechatId
$sql = "insert into ck_traffic_source(`identifier`,companyId,`fromd`,`sourceId`,`createTime`)
SELECT
m.wechatId identifier,
c.departmentId companyId,
r.nickname fromd,
m.chatroomId sourceId,
m.createTime createTime
FROM
s2_wechat_chatroom_member m
JOIN s2_wechat_chatroom r ON m.chatroomId = r.chatroomId
LEFT JOIN s2_wechat_account a ON a.id = r.wechatAccountId
LEFT JOIN s2_company_account c on c.id = a.deviceAccountId
ORDER BY m.id DESC
GROUP BY m.wechatId
LIMIT ?, ?
ON DUPLICATE KEY UPDATE
identifier=VALUES(identifier),