feat: 商品/专区/店铺按俱乐部分离,工单统计与点单手机号认证

商品与专区、店铺增加 club_id(历史默认 xq);列表按俱乐部过滤;工单列表返回待办统计;新增 hqshouji/rzwlsjh 手机号查询与认证接口。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-21 01:55:14 +08:00
parent 7c6e14db01
commit d5b8ff5b8a
15 changed files with 332 additions and 80 deletions

View File

@@ -141,9 +141,6 @@ class GetProductBaseDataView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 获取所有商品类型(按 paixu 升序)
type_qs = ShangpinLeixing.query.all().order_by('paixu')
@@ -166,12 +163,19 @@ class GetProductBaseDataView(APIView):
'product_count': product_count,
})
# 获取所有专区(按 paixu 升序
zone_qs = ShangpinZhuanqu.query.all().order_by('paixu')
# 获取专区(按俱乐部隔离;集团汇总看全部
from jituan.services.club_context import filter_club_char_field
zone_qs = filter_club_char_field(
ShangpinZhuanqu.query.all().order_by('paixu'), request, field='club_id'
)
_zone_counts = {
item['zhuanqu_id']: item['cnt']
for item in Shangpin.query.filter(
dianpu__isnull=True, dianpu_leixing__isnull=True, zhuanqu_id__isnull=False
for item in filter_club_char_field(
Shangpin.query.filter(
dianpu__isnull=True, dianpu_leixing__isnull=True, zhuanqu_id__isnull=False
),
request,
field='club_id',
).values('zhuanqu_id').annotate(cnt=Count('id'))
}
zone_list = []
@@ -184,6 +188,7 @@ class GetProductBaseDataView(APIView):
'paixu': z.paixu,
'shenhezhuangtai': z.shenhezhuangtai,
'product_count': product_count,
'club_id': getattr(z, 'club_id', '') or '',
})
# 获取所有会员(只需 ID、介绍、价格
@@ -235,9 +240,6 @@ class GetProductListView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 获取参数
leixing_id = request.data.get('leixing_id')
@@ -257,11 +259,13 @@ class GetProductListView(APIView):
except:
return Response({'code': 400, 'msg': '分页参数错误'})
# 🔥 修改:构建查询集,增加公共商品筛选(店铺为空且店铺商品类型为空
# 🔥 公共商品 + 按俱乐部隔离(集团汇总看全部
from jituan.services.club_context import filter_club_char_field
qs = Shangpin.query.filter(
dianpu__isnull=True, # 所属店铺为空
dianpu_leixing__isnull=True # 店铺商品类型为空
)
qs = filter_club_char_field(qs, request, field='club_id')
if leixing_id:
try:
@@ -323,8 +327,10 @@ class GetProductListView(APIView):
'jiage': str(p.jiage),
'kucun': p.kucun,
'zhenshi_xiaoliang': p.zhenshi_xiaoliang,
'duiwai_xiaoliang': p.duiwai_xiaoliang,
'tupian_url': p.tupian_url or '',
'jieshao': p.jieshao or '',
'club_id': getattr(p, 'club_id', '') or '',
})
return Response({
@@ -365,9 +371,6 @@ class GetProductListView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 获取所有商品类型(按 paixu 升序)
type_qs = ShangpinLeixing.query.all().order_by('paixu')
@@ -454,9 +457,6 @@ class GetProductListView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 获取参数
leixing_id = request.data.get('leixing_id')
@@ -578,9 +578,6 @@ class SaveProductOrderView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
sort_type = request.data.get('type', '').strip().lower()
if sort_type not in ('leixing', 'zhuanqu'):
@@ -643,9 +640,6 @@ class AddProductView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 获取表单字段
biaoqian = request.data.get('biaoqian', '').strip()
@@ -774,6 +768,8 @@ class AddProductView(APIView):
# 创建商品
try:
from jituan.services.club_write import resolve_club_id_for_write
club_id = resolve_club_id_for_write(request)
with transaction.atomic():
product = Shangpin.query.create(
biaoqian=biaoqian,
@@ -793,6 +789,7 @@ class AddProductView(APIView):
ewai_dashou_fencheng=ewai_fencheng,
paixu=0, # 新商品默认排序最后
shenhezhuangtai=1, # 正常状态
club_id=club_id,
)
except Exception as e:
logger.error(f"创建商品失败: {str(e)}", exc_info=True)
@@ -843,9 +840,6 @@ class DeleteProductView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 查询商品是否存在
try:
@@ -908,9 +902,6 @@ class GetProductDetailView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 查询商品
try:
@@ -992,9 +983,6 @@ class UpdateProductView(APIView):
return permissions
if '2200a' not in permissions:
return Response({'code': 403, 'msg': '无权限管理商品'})
scope_err = block_non_group_catalog_scope(request)
if scope_err:
return Response({'code': 400, 'msg': scope_err})
# 使用事务,将 select_for_update 放在事务内
with transaction.atomic():

View File

@@ -142,8 +142,10 @@ class ShopListView(APIView):
zhengqu_zonge_min = request.data.get('zhengqu_zonge_min')
zhengqu_zonge_max = request.data.get('zhengqu_zonge_max')
# 4. 构建查询集(先查店铺,预加载关联凭证)
# 4. 构建查询集(先查店铺,预加载关联凭证;按俱乐部隔离
from jituan.services.club_context import filter_club_char_field
queryset = Dianpu.query.select_related('pingzheng').all()
queryset = filter_club_char_field(queryset, request, field='club_id')
if dianpu_mingcheng:
queryset = queryset.filter(dianpu_mingcheng__icontains=dianpu_mingcheng)
@@ -189,6 +191,7 @@ class ShopListView(APIView):
'kaiqi_meiri_xiane': dianpu.kaiqi_meiri_xiane,
'pingzheng__yonghu': pingzheng.yonghu, # 用户ID
'pingzheng__zhanghao': pingzheng.zhanghao, # 登录账号
'club_id': getattr(dianpu, 'club_id', '') or '',
})
# 获取默认配置ID=1不存在则创建
@@ -327,6 +330,7 @@ class ShopModifyView(APIView):
mima=mima,
is_active=True
)
from jituan.services.club_write import resolve_club_id_for_write
dianpu = Dianpu.query.create(
pingzheng=pingzheng,
dianpu_mingcheng=dianpu_mingcheng,
@@ -336,6 +340,7 @@ class ShopModifyView(APIView):
shouyi_choucheng_feilv=request.data.get('shouyi_choucheng_feilv', 0),
kaiqi_meiri_xiane=request.data.get('kaiqi_meiri_xiane', False),
meiri_tixian_xiane=request.data.get('meiri_tixian_xiane', 0),
club_id=resolve_club_id_for_write(request),
)
return Response({'code': 0, 'msg': '店铺创建成功', 'dianpu_id': dianpu.id})
except IntegrityError as e:
@@ -458,8 +463,10 @@ class ShopListForProductView(APIView):
# 店铺状态筛选1正常0封禁不传则全部
zhuangtai = request.data.get('zhuangtai')
# ---------- 构建查询集关联凭证表获取用户ID ----------
# ---------- 构建查询集关联凭证表获取用户ID;按俱乐部隔离 ----------
from jituan.services.club_context import filter_club_char_field
shops = Dianpu.query.select_related('pingzheng').all()
shops = filter_club_char_field(shops, request, field='club_id')
# 状态筛选:只接受 0 或 1
if zhuangtai is not None: