确认收款失败后跳过该商户,再点收款可换号。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-14 22:48:00 +08:00
parent 0271eca248
commit 728bac58ee
3 changed files with 35 additions and 6 deletions

View File

@@ -1444,14 +1444,19 @@ def reconcile_shenhe_wechat_bills(shenhe_danhao):
)
continue
# 已失败记录:仍问一遍微信,防本地误标
# 已失败记录:仅当微信实际已到账才复活;
# 勿把 WAIT_USER_CONFIRM 再甩给前端(确认页受限后本地已放弃该户,必须换下一商户)
if rec.zhuangtai == 2:
wx_data = query_wechat_transfer_bill(rec.tixian_id)
if wx_data is None or wx_data.get('_not_found'):
continue
action, payload = _sync_record_from_wx_query(rec, wx_data)
if action in (RECONCILE_COMPLETED, RECONCILE_WAIT_CONFIRM):
if action == RECONCILE_COMPLETED:
return action, payload
logger.warning(
'本地已失败单忽略微信待确认 shenhe=%s bill=%s mch=%s action=%s',
shenhe_danhao, rec.tixian_id, rec.mch_id, action,
)
continue
if pending_with_package:

View File

@@ -414,6 +414,12 @@ def process_audit_collect(request):
[c.get('MCHID') for c in prefer_cfgs],
)
mch_cfgs = prefer_cfgs
elif failed_mchs and not prefer_cfgs:
# 可用商户都失败过:仍按原序再试一轮(例如限额日切后可能恢复)
logger.warning(
'可用商户均曾失败,按原序再试 shenhe=%s failed=%s',
shenhe_danhao, sorted(failed_mchs),
)
_log_wx_collect(
'开始轮换',
shenhe=shenhe_danhao,

View File

@@ -13256,11 +13256,18 @@ class TixianQueRenAutoView(APIView):
mark_transfer_success(auto_record, with_accounting=True)
return Response({'code': 0, 'msg': '提现成功', 'data': None})
# 用户取消或失败
# 用户取消或失败(确认页被微信限额/受限常见)
raw_fail = (request.data.get('fail_reason') or request.data.get('errMsg') or '').strip()
fail_reason = (raw_fail or '用户取消收款')[:500]
abandoned_mch = (auto_record.mch_id or '').strip()
auto_record.zhuangtai = 2
auto_record.fail_reason = '用户取消收款'
auto_record.fail_reason = fail_reason
auto_record.save(update_fields=['zhuangtai', 'fail_reason'])
release_collect_quota_for_record(auto_record)
logger.error(
'【微信官方收款】确认失败已放弃商户 | bill=%s | mch_id=%s | reason=%s',
tixian_id, abandoned_mch, fail_reason,
)
if is_audit_flow:
# 新审核流程:申请时已扣款,取消不退余额,审核单恢复 6 待收款,可再次点收款
@@ -13271,9 +13278,11 @@ class TixianQueRenAutoView(APIView):
shenhe_danhao=auto_record.shenhe_danhao,
)
audit.tixian_auto_id = None
if hasattr(audit, 'dakuan_mch_id'):
audit.dakuan_mch_id = ''
sync_audit_and_jilu_status(
audit, 6,
fail_reason='用户取消收款,可重新发起',
fail_reason='确认收款失败,可换其他商户重试',
)
except TixianShenheJilu.DoesNotExist:
logger.warning(f'确认取消但审核记录不存在: {auto_record.shenhe_danhao}')
@@ -13299,7 +13308,16 @@ class TixianQueRenAutoView(APIView):
zuzhang.save()
decrease_tixian_daily_stat(auto_record.leixing, auto_record.shijidaozhang)
return Response({'code': 0, 'msg': '提现已取消', 'data': None})
# 告知前端可立刻再调 tixiansq会跳过刚失败的 mch_id 换下一户
return Response({
'code': 0,
'msg': '已记录失败,可换商户重试',
'data': {
'can_retry_switch': bool(is_audit_flow),
'abandoned_mch_id': abandoned_mch,
'fail_reason': fail_reason,
},
})
except Exception as e:
logger.error(f'提现确认异常: {str(e)}', exc_info=True)