P0防双笔:查不清绝不新建第二笔;新增提现抽成利润统计接口。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-16 19:49:38 +08:00
parent 52e777c3a0
commit fc93f1c8fc
4 changed files with 374 additions and 65 deletions

View File

@@ -421,17 +421,19 @@ def process_audit_collect(request):
# 选户:绑定用户仅 1 户;未绑定按 priority。
# 仅「商户整户日/月额度」+ 查单确认未建单 才静默换号;其它失败立刻回前端。
# 跨次仅跳过「整户额度」失败过的商户,个人限额/IP/余额失败不跨次换号。
if not is_user_bound and len(mch_cfgs) > 1:
failed_mchs = set(
TixianAutoRecord.objects.filter(
shenhe_danhao=shenhe_danhao, zhuangtai=2,
).exclude(mch_id='').values_list('mch_id', flat=True)
)
prefer_cfgs = [c for c in mch_cfgs if c.get('MCHID') not in failed_mchs]
failed_quota_mchs = set()
for fr, mid in TixianAutoRecord.objects.filter(
shenhe_danhao=shenhe_danhao, zhuangtai=2,
).exclude(mch_id='').values_list('fail_reason', 'mch_id'):
if mid and _is_wx_mch_total_quota_exhausted('', fr or ''):
failed_quota_mchs.add(mid)
prefer_cfgs = [c for c in mch_cfgs if c.get('MCHID') not in failed_quota_mchs]
if prefer_cfgs and len(prefer_cfgs) < len(mch_cfgs):
logger.warning(
'收款优先未失败商户 shenhe=%s skip=%s try=%s',
shenhe_danhao, sorted(failed_mchs),
'收款优先未触整户额度商户 shenhe=%s skip=%s try=%s',
shenhe_danhao, sorted(failed_quota_mchs),
[c.get('MCHID') for c in prefer_cfgs],
)
mch_cfgs = prefer_cfgs