fix: 总榜按无效人数排行;总会员ID匹配与子类型展开修复
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -71,12 +71,16 @@ def get_bundle_included_ids(club_id, bundle_huiyuan_id):
|
||||
|
||||
if not club_id or not bundle_huiyuan_id:
|
||||
return []
|
||||
return list(
|
||||
ClubHuiyuanBundleInclude.query.filter(
|
||||
club_id=club_id,
|
||||
bundle_huiyuan_id=bundle_huiyuan_id,
|
||||
).values_list('included_huiyuan_id', flat=True)
|
||||
)
|
||||
for bid in expand_huiyuan_id_variants(bundle_huiyuan_id):
|
||||
ids = list(
|
||||
ClubHuiyuanBundleInclude.query.filter(
|
||||
club_id=club_id,
|
||||
bundle_huiyuan_id=bid,
|
||||
).values_list('included_huiyuan_id', flat=True)
|
||||
)
|
||||
if ids:
|
||||
return ids
|
||||
return []
|
||||
|
||||
|
||||
def _membership_club_candidates(yonghu_id, club_id=None, record_club_id=None):
|
||||
@@ -123,10 +127,11 @@ def resolve_bundle_included_ids(bundle_huiyuan_id, club_id=None, yonghu_id=None,
|
||||
def _included_huiyuan_id_set(included_ids):
|
||||
included_set = set()
|
||||
for x in included_ids or []:
|
||||
sx = normalize_huiyuan_id(x)
|
||||
if sx:
|
||||
included_set.add(sx)
|
||||
included_set.add(sx.lstrip('0') or '0')
|
||||
for variant in expand_huiyuan_id_variants(x):
|
||||
sx = normalize_huiyuan_id(variant)
|
||||
if sx:
|
||||
included_set.add(sx)
|
||||
included_set.add(sx.lstrip('0') or '0')
|
||||
return included_set
|
||||
|
||||
|
||||
@@ -159,10 +164,13 @@ def _record_club_id(record, club_id=None):
|
||||
|
||||
|
||||
def is_bundle_huiyuan(huiyuan_id):
|
||||
try:
|
||||
return bool(Huiyuan.query.get(huiyuan_id=huiyuan_id).is_bundle)
|
||||
except Huiyuan.DoesNotExist:
|
||||
hid = normalize_huiyuan_id(huiyuan_id)
|
||||
if not hid:
|
||||
return False
|
||||
for bid in Huiyuan.query.filter(is_bundle=True).values_list('huiyuan_id', flat=True):
|
||||
if huiyuan_ids_match(bid, hid):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _membership_record_active(record):
|
||||
@@ -188,18 +196,13 @@ def user_has_huiyuan_access(yonghu_id, required_huiyuan_id, club_id=None):
|
||||
def _record_valid(rec):
|
||||
return _membership_record_active(rec)
|
||||
|
||||
req_set = {req, req.lstrip('0') or '0'}
|
||||
for rec in Huiyuangoumai.query.filter(yonghu_id=yonghu_id):
|
||||
if _record_valid(rec) and huiyuan_ids_match(rec.huiyuan_id, req):
|
||||
if not _record_valid(rec):
|
||||
continue
|
||||
if huiyuan_ids_match(rec.huiyuan_id, req):
|
||||
return True
|
||||
|
||||
bundle_ids = set(
|
||||
Huiyuan.query.filter(is_bundle=True).values_list('huiyuan_id', flat=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
|
||||
if is_bundle_huiyuan(rec.huiyuan_id):
|
||||
included = resolve_bundle_included_ids(
|
||||
rec.huiyuan_id,
|
||||
club_id=club_id,
|
||||
|
||||
Reference in New Issue
Block a user