Commit 92daf560 by imwangxiaozhou Committed by 胡悦

fix(企微客户群运营): 记录超时失败的客户群创建请求并完善测试用例

新增_record_failed_customer_group方法,将超时失败的客户群创建记录持久化到数据库,同时更新对应测试以验证该逻辑
1 parent 019d952d
......@@ -276,6 +276,8 @@ class WeComCustomerGroupOrchestrationService:
request.status = "failed"
request.fail_reason = "timeout"
self._notify_group_create_timeout(request)
if request.customer_contact_id:
self._record_failed_customer_group(request)
processed += 1
continue
......@@ -986,6 +988,34 @@ class WeComCustomerGroupOrchestrationService:
record.is_deleted = False
self.db.flush()
def _record_failed_customer_group(self, request: WeComGroupCreateRequest) -> None:
if not request.customer_contact_id:
return
record = (
self.db.query(WeComCustomerGroup)
.filter(WeComCustomerGroup.customer_contact_id == request.customer_contact_id)
.first()
)
if record is None:
record = WeComCustomerGroup(
customer_contact_id=request.customer_contact_id,
member_bot_ids=list(request.member_bot_ids or []),
is_deleted=False,
)
self.db.add(record)
record.customer_name = request.customer_name
record.bot_id = request.bot_id
record.bot_code = request.bot_code
record.group_id = None
record.group_name = request.group_name
record.group_status = "failed"
record.group_create_request_id = request.id
record.member_bot_ids = list(request.member_bot_ids or [])
record.is_deleted = False
self.db.flush()
def _build_group_name(self, position_name: str | None, customer_contact_id: str) -> str:
base_name = str(position_name or "").strip() or customer_contact_id
return f"{base_name}服务群"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!