fix: 抢单池体验会员按正式展示,修复 czjilu 权益被总会员逻辑短路
ddhq 仅展示层变通;qiangdan 仍按会员类型校验,提现仍禁体验会员。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -106,23 +106,21 @@ def user_has_huiyuan_access(yonghu_id, required_huiyuan_id, club_id=None):
|
||||
bundle_ids = set(
|
||||
Huiyuan.query.filter(is_bundle=True).values_list('huiyuan_id', flat=True)
|
||||
)
|
||||
if not bundle_ids:
|
||||
return False
|
||||
|
||||
req_set = {req, req.lstrip('0') or '0'}
|
||||
for rec in Huiyuangoumai.query.filter(yonghu_id=yonghu_id, huiyuan_id__in=bundle_ids):
|
||||
if not _record_valid(rec):
|
||||
continue
|
||||
cid = club_id or rec.club_id or ''
|
||||
included = get_bundle_included_ids(cid, rec.huiyuan_id)
|
||||
included_set = set()
|
||||
for x in included:
|
||||
sx = normalize_huiyuan_id(x)
|
||||
if sx:
|
||||
included_set.add(sx)
|
||||
included_set.add(sx.lstrip('0') or '0')
|
||||
if req_set & included_set:
|
||||
return True
|
||||
if bundle_ids:
|
||||
req_set = {req, req.lstrip('0') or '0'}
|
||||
for rec in Huiyuangoumai.query.filter(yonghu_id=yonghu_id, huiyuan_id__in=bundle_ids):
|
||||
if not _record_valid(rec):
|
||||
continue
|
||||
cid = club_id or rec.club_id or ''
|
||||
included = get_bundle_included_ids(cid, rec.huiyuan_id)
|
||||
included_set = set()
|
||||
for x in included:
|
||||
sx = normalize_huiyuan_id(x)
|
||||
if sx:
|
||||
included_set.add(sx)
|
||||
included_set.add(sx.lstrip('0') or '0')
|
||||
if req_set & included_set:
|
||||
return True
|
||||
|
||||
if _czjilu_grants_huiyuan_access(yonghu_id, req, club_id):
|
||||
return True
|
||||
@@ -199,42 +197,38 @@ def resolve_order_membership_id(order_dict):
|
||||
return ids[0] if ids else ''
|
||||
|
||||
|
||||
def _prune_clumber_items(yonghu_id, items, club_id=None):
|
||||
"""clumber 只保留用户当前真有权限的会员(含总会员子类型)。"""
|
||||
if not items:
|
||||
return []
|
||||
from collections import defaultdict
|
||||
|
||||
groups = defaultdict(list)
|
||||
for item in items:
|
||||
hid = normalize_huiyuan_id(item.get('huiyuanid') or item.get('huiyuan_id'))
|
||||
if not hid:
|
||||
continue
|
||||
core = hid.lstrip('0') or '0'
|
||||
groups[core].append(item)
|
||||
|
||||
kept = []
|
||||
for group_items in groups.values():
|
||||
sample_hid = group_items[0].get('huiyuanid') or group_items[0].get('huiyuan_id')
|
||||
if user_has_huiyuan_access(yonghu_id, sample_hid, club_id=club_id):
|
||||
kept.extend(group_items)
|
||||
return kept
|
||||
def _clumber_covers_required_ids(user_clumber, required_ids):
|
||||
"""抢单池展示:clumber 是否包含本单所需会员(体验条目与正式同格式)。"""
|
||||
if not user_clumber or not required_ids:
|
||||
return False
|
||||
for rid in required_ids:
|
||||
for item in user_clumber:
|
||||
hid = item.get('huiyuanid') or item.get('huiyuan_id')
|
||||
if huiyuan_ids_match(hid, rid):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def resolve_grab_pool_member_display(order_dict, yonghu_id, club_id=None, user_clumber=None):
|
||||
"""
|
||||
抢单池展示(仅老端 UI,不影响 /qiangdan 真实校验):
|
||||
- 本单有对应会员(含体验)→ yaoqiuleixing=0,老端显示分佣/可抢
|
||||
- 本单无对应会员 → yaoqiuleixing=1 + huiyuan_id,老端显示未开通
|
||||
禁止「有任意会员就放开全部单」。
|
||||
【仅抢单池 dddhq 展示】体验会员按正式会员返回,让老端能看见分佣/可抢。
|
||||
- 本单有所需会员(体验=正式)→ yaoqiuleixing=0
|
||||
- 本单无对应会员 → yaoqiuleixing=1,显示未开通
|
||||
真实抢单走 /qiangdan;提现走正式会员+禁体验,与此无关。
|
||||
"""
|
||||
grab_req = int(order_dict.get('GrabRequirement') or 0)
|
||||
membership_id = resolve_order_membership_id(order_dict)
|
||||
if grab_req != 1:
|
||||
return grab_req, membership_id or '', True
|
||||
|
||||
if user_clumber is None:
|
||||
_, user_clumber = ensure_grab_pool_clumber(yonghu_id, club_id=club_id)
|
||||
|
||||
required_ids = resolve_order_membership_ids(order_dict)
|
||||
has_access = user_has_huiyuan_access_any(yonghu_id, required_ids, club_id=club_id)
|
||||
if not has_access:
|
||||
has_access = _clumber_covers_required_ids(user_clumber, required_ids)
|
||||
|
||||
if has_access:
|
||||
return 0, membership_id or '', True
|
||||
return 1, membership_id or '', False
|
||||
@@ -354,8 +348,8 @@ def _build_clumber_from_paid_czjilu(yonghu_id):
|
||||
|
||||
def ensure_grab_pool_clumber(yonghu_id, club_id=None):
|
||||
"""
|
||||
【仅抢单池展示】同步权益并构造 clumber,供老小程序按 huiyuan_id 逐单匹配。
|
||||
不得用于提现/收款等权限校验;提现须走 check_dashou_has_formal_huiyuan_for_withdraw。
|
||||
【仅抢单池 dddhq 展示】体验会员与正式会员同格式写入 clumber。
|
||||
不得用于提现;提现须 check_dashou_has_formal_huiyuan_for_withdraw。
|
||||
"""
|
||||
from jituan.services.member_recharge import sync_member_entitlements_for_user
|
||||
|
||||
@@ -376,7 +370,6 @@ def ensure_grab_pool_clumber(yonghu_id, club_id=None):
|
||||
if core not in seen_cores:
|
||||
items.append(it)
|
||||
seen_cores.add(core)
|
||||
items = _prune_clumber_items(yonghu_id, items, club_id=club_id)
|
||||
return bool(items), items
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user