feat: 组队大厅返回队长结算率/被罚款率
与订单列表同口径,按招募与订单俱乐部兜底查询打手成交统计。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -623,7 +623,6 @@ def serialize_recruit_public(rec, order=None, *, include_game_ids=False) -> dict
|
|||||||
from orders.models import Order, MerchantOrderExt
|
from orders.models import Order, MerchantOrderExt
|
||||||
from jituan.services.order_deal import order_auto_settle_payload
|
from jituan.services.order_deal import order_auto_settle_payload
|
||||||
from jituan.models import DashouDealStat
|
from jituan.models import DashouDealStat
|
||||||
from jituan.services.deal_stats import serialize_dashou_stat
|
|
||||||
from users.business_models import User
|
from users.business_models import User
|
||||||
from backend.utils import fmt_datetime
|
from backend.utils import fmt_datetime
|
||||||
|
|
||||||
@@ -698,15 +697,24 @@ def serialize_recruit_public(rec, order=None, *, include_game_ids=False) -> dict
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
row = DashouDealStat.query.filter(club_id=rec.club_id, dashou_uid=rec.leader_uid).first()
|
# 队长打手结算率/被罚款率(有样本才返回,与订单列表口径一致)
|
||||||
if row and int(row.order_count or 0) > 0:
|
from jituan.services.deal_stats import miniapp_dashou_deal_payload
|
||||||
s = serialize_dashou_stat(row)
|
leader_uid = (rec.leader_uid or '').strip()
|
||||||
data['leader_deal_stat'] = {
|
club_ids = []
|
||||||
'deal_rate': s['deal_rate'],
|
for cid in (
|
||||||
'fined_rate': s['fined_rate'],
|
(rec.club_id or '').strip(),
|
||||||
'deal_rate_text': f"{round(s['deal_rate'] * 100, 1)}%",
|
(getattr(order, 'ClubID', None) or '').strip() if order else '',
|
||||||
'fined_rate_text': f"{round(s['fined_rate'] * 100, 1)}%",
|
):
|
||||||
}
|
if cid and cid not in club_ids:
|
||||||
|
club_ids.append(cid)
|
||||||
|
dashou_row = None
|
||||||
|
if leader_uid and club_ids:
|
||||||
|
for cid in club_ids:
|
||||||
|
dashou_row = DashouDealStat.query.filter(club_id=cid, dashou_uid=leader_uid).first()
|
||||||
|
if dashou_row and int(dashou_row.order_count or 0) > 0:
|
||||||
|
break
|
||||||
|
dashou_row = None
|
||||||
|
data['leader_deal_stat'] = miniapp_dashou_deal_payload(dashou_row)
|
||||||
|
|
||||||
if include_game_ids:
|
if include_game_ids:
|
||||||
from orders.models import TeamMember
|
from orders.models import TeamMember
|
||||||
|
|||||||
Reference in New Issue
Block a user