fix: 组队复用抢单配对群,不再另建 group_订单
This commit is contained in:
@@ -179,23 +179,6 @@ def _set_dashou_busy(uid: str, busy: bool):
|
||||
UserDashou.objects.filter(user=u).update(zhuangtai=0 if busy else 1)
|
||||
|
||||
|
||||
def _subscribe_uids_to_order_group(order_id: str, uids: list):
|
||||
"""订阅 Ds{uid} 到 group_{order_id}。失败只打日志。"""
|
||||
try:
|
||||
from utils.chat_utils import _subscribe_users_to_group, _get_self_goeasy_appkey, _get_self_goeasy_secret
|
||||
appkey = _get_self_goeasy_appkey()
|
||||
secret = _get_self_goeasy_secret()
|
||||
if not appkey:
|
||||
return False
|
||||
user_ids = [f'Ds{u}' for u in uids if u]
|
||||
if not user_ids:
|
||||
return False
|
||||
return _subscribe_users_to_group(user_ids, [f'group_{order_id}'], appkey, secret)
|
||||
except Exception as e:
|
||||
logger.warning('组队拉群失败 order=%s: %s', order_id, e)
|
||||
return False
|
||||
|
||||
|
||||
def _dashou_display_name(uid: str) -> str:
|
||||
try:
|
||||
from users.business_models import User
|
||||
@@ -222,9 +205,9 @@ def _dashou_display_name(uid: str) -> str:
|
||||
|
||||
def _sync_team_order_group_chat(order, dashou_uids: list, *, announce_uid=None, announce_text=None):
|
||||
"""
|
||||
组队群统一 group_{订单ID}:
|
||||
- 订阅:打手们 + 商家/老板(派单方)
|
||||
- 可选:发送入队/开组系统消息,触发监听中用户实时收到
|
||||
组队复用抢单配对群(不另建 group_{订单}):
|
||||
- 订阅:打手们 + 商家/老板到原群
|
||||
- 可选:在原群发开组/入队公告
|
||||
"""
|
||||
oid = (getattr(order, 'OrderID', None) or '').strip()
|
||||
if not oid:
|
||||
@@ -237,13 +220,14 @@ def _sync_team_order_group_chat(order, dashou_uids: list, *, announce_uid=None,
|
||||
_get_self_goeasy_secret,
|
||||
_get_local_partner_info,
|
||||
_full_local_avatar,
|
||||
resolve_order_chat_group_id,
|
||||
)
|
||||
appkey = _get_self_goeasy_appkey()
|
||||
secret = _get_self_goeasy_secret()
|
||||
if not appkey:
|
||||
return False
|
||||
|
||||
group_id = f'group_{oid}'
|
||||
group_id = resolve_order_chat_group_id(order) or f'group_{oid}'
|
||||
user_ids = []
|
||||
for u in dashou_uids or []:
|
||||
u = (u or '').strip()
|
||||
@@ -261,7 +245,7 @@ def _sync_team_order_group_chat(order, dashou_uids: list, *, announce_uid=None,
|
||||
|
||||
ok = _subscribe_users_to_group(user_ids, [group_id], appkey, secret)
|
||||
if not ok:
|
||||
logger.warning('组队订阅群失败 order=%s users=%s', oid, user_ids)
|
||||
logger.warning('组队订阅群失败 order=%s group=%s users=%s', oid, group_id, user_ids)
|
||||
|
||||
if announce_uid and announce_text:
|
||||
sender_id = f'Ds{announce_uid}'
|
||||
@@ -281,7 +265,7 @@ def _sync_team_order_group_chat(order, dashou_uids: list, *, announce_uid=None,
|
||||
announce_text, None, group_name=group_name, order_id=oid,
|
||||
)
|
||||
if not sent:
|
||||
logger.warning('组队群消息发送失败 order=%s text=%s', oid, announce_text)
|
||||
logger.warning('组队群消息发送失败 order=%s group=%s text=%s', oid, group_id, announce_text)
|
||||
return bool(ok and sent)
|
||||
return bool(ok)
|
||||
except Exception as e:
|
||||
@@ -380,7 +364,7 @@ def open_recruit(
|
||||
order,
|
||||
[leader_uid],
|
||||
announce_uid=leader_uid,
|
||||
announce_text=f'{name} 已开启组队招募,请在组队群沟通',
|
||||
announce_text=f'{name} 已开启组队招募,可在本群沟通',
|
||||
)
|
||||
_log(club_id, oid, rec.id, leader_uid, 'open', f'mode={mode} need={need} display={display}')
|
||||
return rec
|
||||
|
||||
Reference in New Issue
Block a user