fix: 抢单押金校验计入提现冻结中押金

押金提现申请后余额已扣,仅抢单接口把审核中/待收款冻结额加回可用;提现与换人等其它场景仍只认实际余额。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-17 01:50:45 +08:00
parent 60fdf8c427
commit 52009a54a9
2 changed files with 56 additions and 5 deletions

View File

@@ -542,7 +542,7 @@ class QiangdanView(APIView):
if order.GrabRequirement == 1:
return self._validate_huiyuan_requirement(order, dashou_yonghuid)
elif order.GrabRequirement == 2:
return self._validate_yajin_requirement(order, dashou_profile)
return self._validate_yajin_requirement(order, dashou_profile, dashou_yonghuid)
return {'success': True, 'message': '验证通过'}
def _validate_huiyuan_requirement(self, order, dashou_yonghuid):
@@ -567,11 +567,26 @@ class QiangdanView(APIView):
return {'success': True, 'message': '会员验证通过'}
return {'success': False, 'message': '未开通对应会员或会员已过期,无法抢此订单'}
def _validate_yajin_requirement(self, order, dashou_profile):
def _validate_yajin_requirement(self, order, dashou_profile, dashou_yonghuid=None):
"""
押金抢单:余额 + 提现冻结中押金均可用于抢单门槛。
提现/后台换人等其它场景仍只认实际 yajin 余额。
"""
from users.tixian_shenhe_services import pending_yajin_withdraw_frozen_amount
yajin_required = order.CommissionReq or 0
dashou_yajin = dashou_profile.yajin or 0
if dashou_yajin < yajin_required:
return {'success': False, 'message': f'押金不足,需要{yajin_required}元,当前有{dashou_yajin}'}
balance = dashou_profile.yajin or 0
yonghuid = dashou_yonghuid or getattr(
getattr(dashou_profile, 'user', None), 'UserUID', None
)
frozen = pending_yajin_withdraw_frozen_amount(yonghuid) if yonghuid else Decimal('0')
effective = Decimal(str(balance)) + Decimal(str(frozen))
required = Decimal(str(yajin_required))
if effective < required:
return {
'success': False,
'message': f'押金不足,需要{required}元,当前可用{effective}',
}
return {'success': True, 'message': '押金验证通过'}
def _execute_qiangdan(self, order, dashou_profile, dashou_yonghuid):