fix: 加/赠会员下拉仅展示本俱乐部已上架会员
This commit is contained in:
1 parent
e62f6c7b90
commit
0e890257bf
4 files changed
+96
-19
No files matched your search
+11
-5
@@ -344,11 +344,17 @@ class GetGuanliDetailView(APIView):
|
||||
permanent_enabled = guanshi.fenghong_erci_enabled
|
||||
permanent_amount = str(guanshi.fenghong_erci) if guanshi.fenghong_erci else '0'
|
||||
|
||||
# 获取所有会员(用于前端选择)
|
||||
all_members = list(Huiyuan.query.all().values('huiyuan_id', 'jieshao', 'jiage', 'guanshifc'))
|
||||
for m in all_members:
|
||||
m['jiage'] = str(m['jiage'])
|
||||
m['guanshifc'] = str(m['guanshifc'])
|
||||
# 本俱乐部已上架会员(用于分红配置选择,不展示集团未上架类型)
|
||||
from jituan.services.club_member_admin import (
|
||||
list_club_enabled_huiyuan_options,
|
||||
resolve_club_id_for_huiyuan_options,
|
||||
)
|
||||
from users.business_models import User as _BizUser
|
||||
_target = _BizUser.query.filter(UserUID=yonghuid).first()
|
||||
all_members = list_club_enabled_huiyuan_options(
|
||||
resolve_club_id_for_huiyuan_options(request, _target),
|
||||
extra_fields=['jiage', 'guanshifc'],
|
||||
)
|
||||
|
||||
# 获取多次分红配置(按次数和会员组织,按俱乐部隔离)
|
||||
from jituan.services.club_penalty import resolve_gsfenhong_club_id
|
||||
|
||||
+35
-9
@@ -348,8 +348,13 @@ class KefuGetDashouListView(APIView):
|
||||
})
|
||||
|
||||
has_more = (offset + len(dashou_list)) < total_dashou
|
||||
huiyuan_options = list(
|
||||
Huiyuan.query.all().order_by('huiyuan_id').values('huiyuan_id', 'jieshao')
|
||||
from jituan.services.club_member_admin import (
|
||||
list_club_enabled_huiyuan_options,
|
||||
resolve_club_id_for_huiyuan_options,
|
||||
)
|
||||
# 只返回本俱乐部已上架会员,不展示集团全量
|
||||
huiyuan_options = list_club_enabled_huiyuan_options(
|
||||
resolve_club_id_for_huiyuan_options(request),
|
||||
)
|
||||
|
||||
meta = list_response_meta(request)
|
||||
@@ -448,8 +453,14 @@ class KefuGetDashouDetailView(APIView):
|
||||
'jieshao': '',
|
||||
}
|
||||
member_list = []
|
||||
# 仍然需要返回 all_members 和 permissions
|
||||
all_members = list(Huiyuan.query.all().values('huiyuan_id', 'jieshao'))
|
||||
# 仍然需要返回 all_members 和 permissions(仅本店已上架)
|
||||
from jituan.services.club_member_admin import (
|
||||
list_club_enabled_huiyuan_options,
|
||||
resolve_club_id_for_huiyuan_options,
|
||||
)
|
||||
all_members = list_club_enabled_huiyuan_options(
|
||||
resolve_club_id_for_huiyuan_options(request),
|
||||
)
|
||||
return Response({
|
||||
'code': 0,
|
||||
'data': {
|
||||
@@ -522,21 +533,27 @@ class KefuGetDashouDetailView(APIView):
|
||||
'huiyuan_id': record.huiyuan_id, # 用于删除操作
|
||||
})
|
||||
|
||||
# 7. 查询所有会员类型(用于前端添加会员)
|
||||
all_members = list(Huiyuan.query.all().values('huiyuan_id', 'jieshao'))
|
||||
|
||||
from jituan.services.gift_huiyuan import list_gift_huiyuan_for_admin
|
||||
gift_member_list = list_gift_huiyuan_for_admin(uid)
|
||||
|
||||
from jituan.services.club_context import resolve_club_id_from_request, resolve_club_scope
|
||||
from jituan.constants import DATA_SCOPE_ALL
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
from jituan.services.club_member_admin import (
|
||||
list_club_enabled_huiyuan_options,
|
||||
resolve_club_id_for_huiyuan_options,
|
||||
)
|
||||
from users.services.change_guanshi import get_or_create_quota, quota_payload, list_change_logs
|
||||
|
||||
if resolve_club_scope(request) == DATA_SCOPE_ALL:
|
||||
quota_club = get_user_club_id(user_main)
|
||||
else:
|
||||
quota_club = resolve_club_id_from_request(request)
|
||||
|
||||
# 7. 本俱乐部已上架会员(用于前端添加/赠送会员下拉,不回落集团全量)
|
||||
all_members = list_club_enabled_huiyuan_options(
|
||||
resolve_club_id_for_huiyuan_options(request, user_main),
|
||||
)
|
||||
quota = get_or_create_quota(quota_club, uid)
|
||||
change_guanshi_quota = quota_payload(quota)
|
||||
change_guanshi_logs = list_change_logs(quota_club, uid, page=1, page_size=20)
|
||||
@@ -847,8 +864,11 @@ class KefuUpdateDashouView(APIView):
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
from jituan.services.member_recharge import extend_member_entitlement_admin, get_club_huiyuan_row
|
||||
player_club = get_user_club_id(dashou_user)
|
||||
row = get_club_huiyuan_row(player_club, huiyuan_id, require_enabled=False)
|
||||
days = int(value) if value else int(row.formal_days or 30) if row else 30
|
||||
# 必须本俱乐部已上架,禁止加集团未上架类型
|
||||
row = get_club_huiyuan_row(player_club, huiyuan_id, require_enabled=True)
|
||||
if not row:
|
||||
return Response({'code': 400, 'msg': '该会员未在本俱乐部上架,无法添加'})
|
||||
days = int(value) if value else int(row.formal_days or 30)
|
||||
record, err = extend_member_entitlement_admin(
|
||||
dashou_id, huiyuan_id, days, player_club,
|
||||
)
|
||||
@@ -1672,6 +1692,12 @@ class DashouGiftHuiyuanSaveView(APIView):
|
||||
if not huiyuan_id:
|
||||
return Response({'code': 400, 'msg': '缺少会员ID'})
|
||||
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
from jituan.services.member_recharge import get_club_huiyuan_row
|
||||
player_club = get_user_club_id(dashou_user)
|
||||
if not get_club_huiyuan_row(player_club, huiyuan_id, require_enabled=True):
|
||||
return Response({'code': 400, 'msg': '该会员未在本俱乐部上架,无法赠送'})
|
||||
|
||||
rec, created, jifen_info, err = upsert_gift_huiyuan(
|
||||
yonghu_id=dashou_id,
|
||||
huiyuan_id=huiyuan_id,
|
||||
|
||||
@@ -338,11 +338,17 @@ class GetZuzhangDetailView(APIView):
|
||||
permanent_enabled = zuzhang.kaioi_ewai_fenhong
|
||||
permanent_amount = str(zuzhang.ewai_fenhong_jine) if zuzhang.ewai_fenhong_jine else '0'
|
||||
|
||||
# 获取所有会员(用于前端选择)
|
||||
all_members = list(Huiyuan.query.all().values('huiyuan_id', 'jieshao', 'jiage', 'zuzhangfc'))
|
||||
for m in all_members:
|
||||
m['jiage'] = str(m['jiage'])
|
||||
m['zuzhangfc'] = str(m['zuzhangfc'])
|
||||
# 本俱乐部已上架会员(分红配置选择,不展示集团未上架类型)
|
||||
from jituan.services.club_member_admin import (
|
||||
list_club_enabled_huiyuan_options,
|
||||
resolve_club_id_for_huiyuan_options,
|
||||
)
|
||||
from users.business_models import User as _BizUser
|
||||
_target = _BizUser.query.filter(UserUID=yonghuid).first()
|
||||
all_members = list_club_enabled_huiyuan_options(
|
||||
resolve_club_id_for_huiyuan_options(request, _target),
|
||||
extra_fields=['jiage', 'zuzhangfc'],
|
||||
)
|
||||
|
||||
# 获取多次分红配置(按次数和会员组织,按俱乐部隔离)
|
||||
from jituan.services.club_penalty import resolve_gsfenhong_club_id
|
||||
|
||||
@@ -21,6 +21,45 @@ def club_write_blocked(request):
|
||||
return resolve_club_scope(request) == DATA_SCOPE_ALL
|
||||
|
||||
|
||||
def list_club_enabled_huiyuan_options(club_id, extra_fields=None):
|
||||
"""
|
||||
本俱乐部已上架会员下拉选项(ClubHuiyuanPrice.is_enabled=True)。
|
||||
无上架记录时返回空列表——加/赠会员场景不回落集团全量 Huiyuan。
|
||||
"""
|
||||
cid = (club_id or '').strip()
|
||||
if not cid:
|
||||
return []
|
||||
enabled_ids = list(
|
||||
ClubHuiyuanPrice.query.filter(club_id=cid, is_enabled=True)
|
||||
.values_list('huiyuan_id', flat=True)
|
||||
)
|
||||
if not enabled_ids:
|
||||
return []
|
||||
fields = ['huiyuan_id', 'jieshao']
|
||||
for f in (extra_fields or []):
|
||||
if f and f not in fields:
|
||||
fields.append(f)
|
||||
rows = list(
|
||||
Huiyuan.query.filter(huiyuan_id__in=enabled_ids)
|
||||
.order_by('huiyuan_id')
|
||||
.values(*fields)
|
||||
)
|
||||
for m in rows:
|
||||
for k in ('jiage', 'guanshifc', 'zuzhangfc'):
|
||||
if k in m and m[k] is not None:
|
||||
m[k] = str(m[k])
|
||||
return rows
|
||||
|
||||
|
||||
def resolve_club_id_for_huiyuan_options(request, target_user=None):
|
||||
"""单店用顶栏俱乐部;集团汇总时优先用目标用户所属俱乐部。"""
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
|
||||
if resolve_club_scope(request) == DATA_SCOPE_ALL and target_user is not None:
|
||||
return (get_user_club_id(target_user) or '').strip()
|
||||
return (resolve_club_id_from_request(request) or '').strip()
|
||||
|
||||
|
||||
def _price_row_to_dict(row):
|
||||
if not row:
|
||||
return {}
|
||||
|
||||
Reference in new issue
Block a user