Commit 4d1ddf6c by imwangxiaozhou

fix(wecom客户群编排服务): 处理已删除客户记录复活的场景

更新已重新出现的已删除客户记录的状态与信息,避免创建重复的客户群条目,并记录对应的操作日志。
1 parent 6b8a4364
......@@ -371,6 +371,32 @@ class WeComCustomerGroupOrchestrationService:
record.customer_name = customer_name
continue
customer_name = str(item.get("contact_name") or item.get("display_name") or "")
existing = (
self.db.query(WeComCustomerGroup)
.filter(
WeComCustomerGroup.bot_id == bot_id,
WeComCustomerGroup.customer_contact_id == cid,
)
.first()
)
if existing is not None:
existing.is_deleted = False
existing.group_status = "pending"
existing.customer_name = customer_name
existing.group_id = None
existing.group_name = None
existing.group_create_request_id = None
existing.member_bot_ids = [m.bot_id for m in member_bots]
logger.info(
format_job_log(
"全量对比复活已删除客户:机器人[%s] 客户[%s](contact_id=%s)"
% (bot.bot_name or bot.bot_id, customer_name or "-", cid)
)
)
self.db.flush()
continue
new_record = WeComCustomerGroup(
customer_contact_id=cid,
customer_name=customer_name,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!