feat: H5链接配对群ID与客服订单详情扩展(指定响应/罚款)
This commit is contained in:
@@ -35,6 +35,53 @@ def _full_local_avatar(relative_url):
|
||||
return relative_url
|
||||
|
||||
|
||||
def build_merchant_link_chat_meta(order, link_merchant_uid):
|
||||
"""H5 商家链接页群聊:新单走配对群,旧单或无打手时回落 group_{orderId}"""
|
||||
pair_id = resolve_pair_group_id(order)
|
||||
legacy_id = f'group_{order.OrderID}'
|
||||
group_id = pair_id or legacy_id
|
||||
dashou_uid = order.PlayerID or ''
|
||||
self_user_id = f'B{link_merchant_uid}' if link_merchant_uid else ''
|
||||
shangjia_biaoshi = ''
|
||||
try:
|
||||
if order.Platform == 2 and getattr(order, 'shangjia_kuozhan', None):
|
||||
mid = order.shangjia_kuozhan.MerchantID
|
||||
if mid:
|
||||
shangjia_biaoshi = f'Sj{mid}'
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
'group_id': group_id,
|
||||
'is_pair_group': bool(pair_id),
|
||||
'legacy_group_id': legacy_id,
|
||||
'self_user_id': self_user_id,
|
||||
'dashou_biaoshi': f'Ds{dashou_uid}' if dashou_uid else '',
|
||||
'shangjia_biaoshi': shangjia_biaoshi,
|
||||
'you_dashou': bool(dashou_uid),
|
||||
}
|
||||
|
||||
|
||||
def subscribe_merchant_link_chat(order, link_merchant_uid):
|
||||
"""链接页有打手时,预订阅 B{商家} 与打手到对应群(新旧群 ID 均兼容)"""
|
||||
meta = build_merchant_link_chat_meta(order, link_merchant_uid)
|
||||
if not meta.get('you_dashou'):
|
||||
return meta, True
|
||||
appkey = _get_self_goeasy_appkey()
|
||||
secret = _get_self_goeasy_secret()
|
||||
if not appkey:
|
||||
return meta, False
|
||||
user_ids = []
|
||||
if meta.get('self_user_id'):
|
||||
user_ids.append(meta['self_user_id'])
|
||||
if meta.get('dashou_biaoshi'):
|
||||
user_ids.append(meta['dashou_biaoshi'])
|
||||
group_ids = [meta['group_id']]
|
||||
if meta.get('legacy_group_id') and meta['legacy_group_id'] != meta['group_id']:
|
||||
group_ids.append(meta['legacy_group_id'])
|
||||
ok = _subscribe_users_to_group(user_ids, group_ids, appkey, secret)
|
||||
return meta, ok
|
||||
|
||||
|
||||
def resolve_pair_group_id(order):
|
||||
"""打手+商家/老板配对群 ID,与前端 resolveLocalGroupId 一致(同两人共用一个群)"""
|
||||
dashou_uid = order.PlayerID or ''
|
||||
|
||||
Reference in New Issue
Block a user