fix: 押金提现不再封号,统一加强打手/收款校验

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-08 21:06:28 +08:00
parent ad33ee6c86
commit 1ffd92758d
2 changed files with 78 additions and 56 deletions

View File

@@ -73,6 +73,8 @@ from ..tixian_shenhe_services import (
check_shijidaozhang_within_limit,
check_dashou_has_formal_huiyuan_for_withdraw,
check_dashou_trial_blocks_commission_withdraw,
validate_withdraw_eligibility,
validate_payment_info_for_withdraw,
WX_STATE_FAIL, WX_STATE_SUCCESS, WX_STATE_WAIT, WX_STATE_CANCELING,
)
from ..tixian_shenhe_views import process_audit_collect
@@ -392,14 +394,19 @@ class TixianShenqingView(APIView):
return Response({'code': 6, 'msg': '提现金额过低,扣除手续费后无实际到账'},
status=status.HTTP_400_BAD_REQUEST)
# 3. 根据提现类型执行校验和扣款
nicheng = ''
pay_ok, pay_msg = validate_payment_info_for_withdraw(user_main)
if not pay_ok:
return Response({'code': 7, 'msg': pay_msg},
status=status.HTTP_400_BAD_REQUEST)
ok, elig_msg, extra = validate_withdraw_eligibility(user_main, leixing, jine)
if not ok:
return Response({'code': 8, 'msg': elig_msg},
status=status.HTTP_400_BAD_REQUEST)
# 3. 根据提现类型扣款(资格已在 validate_withdraw_eligibility 校验)
nicheng = extra.get('nicheng', '')
if leixing == 1:
result = self._check_dashou_commission_withdraw(user_main, jine)
if result['code'] != 0:
return Response(result, status=status.HTTP_400_BAD_REQUEST)
nicheng = result['data']['nicheng']
# 扣款(佣金)
with transaction.atomic():
profile = UserDashou.objects.select_for_update().get(user=user_main)
if profile.yue < jine:
@@ -407,65 +414,46 @@ class TixianShenqingView(APIView):
profile.yue = F('yue') - jine
profile.save()
elif leixing == 2:
result = self._check_guanshi_dividend_withdraw(user_main, jine)
if result['code'] != 0:
return Response(result, status=status.HTTP_400_BAD_REQUEST)
with transaction.atomic():
profile = UserGuanshi.objects.select_for_update().get(user=user_main)
if profile.yue < jine:
return Response({'code': 22, 'msg': '余额不足'})
profile.yue = F('yue') - jine
profile.save()
nicheng = "管事用户"
nicheng = extra.get('nicheng') or '管事用户'
elif leixing == 3:
result = self._check_zuzhang_withdraw(user_main, jine)
if result['code'] != 0:
return Response(result, status=status.HTTP_400_BAD_REQUEST)
with transaction.atomic():
profile = UserZuzhang.objects.select_for_update().get(user=user_main)
if profile.ketixian_jine < jine:
return Response({'code': 32, 'msg': '可提现金额不足'})
profile.ketixian_jine = F('ketixian_jine') - jine
profile.save()
nicheng = user_main.nicheng if hasattr(user_main, 'nicheng') else ''
nicheng = extra.get('nicheng') or ''
elif leixing == 4:
result = self._check_shenheguan_withdraw(user_main, jine)
if result['code'] != 0:
return Response(result, status=status.HTTP_400_BAD_REQUEST)
with transaction.atomic():
profile = UserShenheguan.objects.select_for_update().get(user=user_main)
if profile.yue < jine:
return Response({'code': 42, 'msg': '可提现金额不足'})
profile.yue = F('yue') - jine
profile.save()
nicheng = "审核官"
nicheng = extra.get('nicheng') or '审核官'
elif leixing == 5:
# 打手押金提现(退出)
result = self._check_dashou_yajin_withdraw(user_main, jine)
if result['code'] != 0:
return Response(result, status=status.HTTP_400_BAD_REQUEST)
# 打手押金提现:仅扣押金,走审核流程,不再封禁账号
with transaction.atomic():
profile = UserDashou.objects.select_for_update().get(user=user_main)
if profile.yajin < jine:
return Response({'code': 53, 'msg': '押金余额不足'})
profile.yajin = F('yajin') - jine
# 押金提现后封禁打手账号
profile.zhanghaozhuangtai = 0 # 0表示禁用
profile.save()
nicheng = profile.nicheng or ''
profile.save(update_fields=['yajin'])
nicheng = extra.get('nicheng') or profile.nicheng or ''
elif leixing == 6:
# 商家余额提现(退出)
result = self._check_shangjia_withdraw(user_main, jine)
if result['code'] != 0:
return Response(result, status=status.HTTP_400_BAD_REQUEST)
with transaction.atomic():
profile = UserShangjia.objects.select_for_update().get(user=user_main)
if profile.yue < jine:
return Response({'code': 63, 'msg': '商家余额不足'})
profile.yue = F('yue') - jine
# 注意:是否封禁商家账号?根据需求,用户未明确要求封禁,暂时只扣款,可后续扩展。
profile.save()
nicheng = profile.nicheng or ''
nicheng = extra.get('nicheng') or profile.nicheng or ''
# 4. 创建提现记录(先扣款后创建,确保资金安全)
try:
@@ -529,7 +517,7 @@ class TixianShenqingView(APIView):
return {'code': 11, 'msg': '打手账号已被封禁,无法提现'}
if dashou.zhuangtai != 1:
return {'code': 12, 'msg': '您有订单进行中,请完成后提现'}
if dashou.jifen != 10:
if dashou.jifen < 10:
return {'code': 15, 'msg': '积分不足10分请补充积分后提现'}
if dashou.yue < jine:
return {'code': 13, 'msg': f'余额不足,当前余额: {dashou.yue}'}