fix: 严格校验体验会员不可提现,抢单按会员类型匹配

展示层 clumber 与提现/抢单权限分离:佣金提现须正式会员并双重拦截体验期;抢单走 resolve_order_membership_ids + 总会员包含判断。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-08 14:26:16 +08:00
parent abfe497ddc
commit b54904a9f2
5 changed files with 106 additions and 22 deletions

View File

@@ -178,13 +178,13 @@ def calc_fee_amounts(jine, feilv):
def check_dashou_has_valid_huiyuan(yonghuid):
"""
打手至少持有一个未过期会员(Huiyuangoumai + jiance_shifou_daoqi 同步状态
打手至少持有一个未过期会员(含体验,用于接单等场景
返回 (True, '') 或 (False, 原因)
"""
records = Huiyuangoumai.query.filter(yonghu_id=yonghuid)
if not records.exists():
return False, '您暂无会员记录,无法提现'
return False, '您暂无会员记录,无法操作'
for record in records:
is_expired = record.jiance_shifou_daoqi()
@@ -193,8 +193,27 @@ def check_dashou_has_valid_huiyuan(yonghuid):
return False, '您的会员已全部过期,请先续费后再操作'
def check_dashou_has_formal_huiyuan_for_withdraw(yonghuid):
"""
打手佣金提现/收款:必须持有未过期的正式会员。
体验会员期内一律拒绝;体验到期后须购买正式会员。
"""
from jituan.services.member_recharge import (
dashou_has_active_formal_huiyuan,
dashou_in_active_trial_period,
)
if dashou_has_active_formal_huiyuan(yonghuid):
return True, ''
if dashou_in_active_trial_period(yonghuid):
return False, '体验会员不可提现佣金,请购买正式会员'
if not Huiyuangoumai.query.filter(yonghu_id=yonghuid).exists():
return False, '您暂无会员记录,无法提现'
return False, '您的会员已全部过期,请购买正式会员后提现'
TRIAL_COMMISSION_WITHDRAW_MSG = (
'体验会员期间不可提现佣金,请升级正式会员或待体验到期'
'体验会员不可提现佣金,请购买正式会员'
)
@@ -228,7 +247,7 @@ def validate_withdraw_eligibility(user_main, leixing, jine):
return False, '有订单进行中,请完成后提现', {}
if dashou.jifen != 10:
return False, '积分不足10分请补充积分后提现', {}
huiyuan_ok, huiyuan_msg = check_dashou_has_valid_huiyuan(yonghuid)
huiyuan_ok, huiyuan_msg = check_dashou_has_formal_huiyuan_for_withdraw(yonghuid)
if not huiyuan_ok:
return False, huiyuan_msg, {}
trial_ok, trial_msg = check_dashou_trial_blocks_commission_withdraw(yonghuid)
@@ -357,7 +376,7 @@ def validate_collect_eligibility(user_main, leixing):
return False, '您有订单进行中,请完成后再收款'
if dashou.jifen != 10:
return False, '积分不足10分无法收款'
huiyuan_ok, huiyuan_msg = check_dashou_has_valid_huiyuan(yonghuid)
huiyuan_ok, huiyuan_msg = check_dashou_has_formal_huiyuan_for_withdraw(yonghuid)
if not huiyuan_ok:
return False, huiyuan_msg
trial_ok, trial_msg = check_dashou_trial_blocks_commission_withdraw(yonghuid)

View File

@@ -71,6 +71,7 @@ from ..tixian_shenhe_services import (
mark_transfer_success, release_collect_quota_for_record,
close_audit_wechat_failed, query_wechat_transfer_bill,
check_shijidaozhang_within_limit,
check_dashou_has_formal_huiyuan_for_withdraw,
check_dashou_trial_blocks_commission_withdraw,
WX_STATE_FAIL, WX_STATE_SUCCESS, WX_STATE_WAIT, WX_STATE_CANCELING,
)
@@ -295,12 +296,12 @@ class ShoukuanXinxiShangchuanView(APIView):
return None
# ========== 订单状态常量(请根据您的实际业务修改)==========
# 假设状态值:已完成=9已退款=10示例实际以您的项目为准
ORDER_STATUS_COMPLETED = 3 # 订单已完成
ORDER_STATUS_REFUNDED = 5 # 订单已退款
ORDER_STATUS_FAIL = 6
# 进行中状态(不可提现)例如:待接单、已接单、进行中等,您需要定义排除列表
# ========== 订单状态常量(请根据您的实际业务修改)==========
# 假设状态值:已完成=9已退款=10示例实际以您的项目为准
ORDER_STATUS_COMPLETED = 3 # 订单已完成
ORDER_STATUS_REFUNDED = 5 # 订单已退款
ORDER_STATUS_FAIL = 6
# 进行中状态(不可提现)例如:待接单、已接单、进行中等,您需要定义排除列表
FORBIDDEN_STATUS_FOR_WITHDRAW = [1, 2, 3, 4, 5, 6, 7, 8] # 除已完成和已退款外的所有状态
@@ -533,6 +534,10 @@ class TixianShenqingView(APIView):
if dashou.yue < jine:
return {'code': 13, 'msg': f'余额不足,当前余额: {dashou.yue}'}
formal_ok, formal_msg = check_dashou_has_formal_huiyuan_for_withdraw(user_main.UserUID)
if not formal_ok:
return {'code': 14, 'msg': formal_msg}
trial_ok, trial_msg = check_dashou_trial_blocks_commission_withdraw(user_main.UserUID)
if not trial_ok:
return {'code': 16, 'msg': trial_msg}