fix: 会员充值链路加固(体验资格、积分分红、czjilu审计、余额抵扣)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -290,26 +290,7 @@ class DashouHuiyuanList(APIView):
|
||||
)
|
||||
} if _huiyuan_ids else {}
|
||||
|
||||
# 批量预取 2:当前用户已购 Huiyuangoumai,按 huiyuan_id 索引
|
||||
_goumai_map = {
|
||||
gm.huiyuan_id: gm
|
||||
for gm in Huiyuangoumai.query.filter(
|
||||
yonghu_id=yonghuid,
|
||||
huiyuan_id__in=_huiyuan_ids,
|
||||
)
|
||||
} if _huiyuan_ids else {}
|
||||
|
||||
# 批量预取 3:当前用户在本俱乐部已支付正式会员的 huiyuan_id 集合
|
||||
_formal_paid_set = set(
|
||||
Czjilu.query.filter(
|
||||
yonghuid=yonghuid,
|
||||
huiyuan_id__in=_huiyuan_ids,
|
||||
leixing=1,
|
||||
zhuangtai=3,
|
||||
club_id=club_id,
|
||||
is_trial=False,
|
||||
).values_list('huiyuan_id', flat=True)
|
||||
) if _huiyuan_ids else set()
|
||||
from jituan.services.member_recharge import can_purchase_trial
|
||||
|
||||
def _local_sellable(cp_row, is_trial):
|
||||
"""单行 ClubHuiyuanPrice 计算 sellable/price/days(避免重复查询)。"""
|
||||
@@ -330,17 +311,9 @@ class DashouHuiyuanList(APIView):
|
||||
return True, price, days
|
||||
|
||||
def _local_can_trial(huiyuan_id):
|
||||
"""基于已预取的数据判断体验会员是否可购。"""
|
||||
cp_row = _club_price_map.get(huiyuan_id)
|
||||
trial_sellable, _, _ = _local_sellable(cp_row, is_trial=True)
|
||||
if not trial_sellable:
|
||||
return False
|
||||
goumai = _goumai_map.get(huiyuan_id)
|
||||
if goumai and goumai.has_used_trial:
|
||||
return False
|
||||
if huiyuan_id in _formal_paid_set:
|
||||
return False
|
||||
return True
|
||||
"""与下单/履约共用 can_purchase_trial。"""
|
||||
ok, _ = can_purchase_trial(yonghuid, huiyuan_id, club_id)
|
||||
return ok
|
||||
|
||||
huiyuan_list = []
|
||||
for huiyuan in huiyuan_queryset:
|
||||
|
||||
Reference in New Issue
Block a user