feat: 只看审核按俱乐部隔离,商品管理支持俱乐部视图
未绑店出货开关按 club_id 配置;后台商品列表可在具体小程序下管理并切换审核展示。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -421,17 +421,38 @@ class ShopPublicTypeAndAuditView(APIView):
|
||||
logger.exception("查询公共商品类型失败")
|
||||
return Response({'code': 500, 'msg': '服务器错误,请稍后重试'})
|
||||
|
||||
# ---------- 获取审核模式配置 ----------
|
||||
audit_config = DianpuShangpinShenheShezhi.query.filter(id=1).first()
|
||||
kaiqi_shenhe = audit_config.kaiqi_shenhe if audit_config else False
|
||||
zhi_kan_shenhe = getattr(audit_config, 'zhi_kan_shenhe', True) if audit_config else True
|
||||
# ---------- 获取本俱乐部审核模式配置 ----------
|
||||
from jituan.services.club_write import resolve_club_id_for_write
|
||||
from shop.services.shenhe_config import get_or_create_shenhe_config
|
||||
from jituan.constants import DATA_SCOPE_ALL
|
||||
from jituan.services.club_context import resolve_club_scope
|
||||
|
||||
if resolve_club_scope(request) == DATA_SCOPE_ALL:
|
||||
# 集团汇总:不自动创建,返回默认值提示前端切到具体俱乐部
|
||||
return Response({
|
||||
'code': 0,
|
||||
'data': {
|
||||
'public_types': type_list,
|
||||
'kaiqi_shenhe': False,
|
||||
'zhi_kan_shenhe': True,
|
||||
'club_scoped': False,
|
||||
'msg': '请切换到具体俱乐部查看/修改审核展示开关',
|
||||
}
|
||||
})
|
||||
|
||||
club_id = resolve_club_id_for_write(request)
|
||||
audit_config = get_or_create_shenhe_config(club_id)
|
||||
kaiqi_shenhe = audit_config.kaiqi_shenhe
|
||||
zhi_kan_shenhe = bool(getattr(audit_config, 'zhi_kan_shenhe', True))
|
||||
|
||||
return Response({
|
||||
'code': 0,
|
||||
'data': {
|
||||
'public_types': type_list,
|
||||
'kaiqi_shenhe': kaiqi_shenhe,
|
||||
'zhi_kan_shenhe': bool(zhi_kan_shenhe),
|
||||
'zhi_kan_shenhe': zhi_kan_shenhe,
|
||||
'club_id': club_id,
|
||||
'club_scoped': True,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -640,18 +661,28 @@ class ShopProductModifyView(APIView):
|
||||
if kaiqi is None:
|
||||
return Response({'code': 400, 'msg': '缺少参数 kaiqi_shenhe'})
|
||||
|
||||
from jituan.constants import DATA_SCOPE_ALL
|
||||
from jituan.services.club_context import resolve_club_scope
|
||||
from jituan.services.club_write import resolve_club_id_for_write
|
||||
from shop.services.shenhe_config import get_or_create_shenhe_config
|
||||
|
||||
if resolve_club_scope(request) == DATA_SCOPE_ALL:
|
||||
return Response({'code': 400, 'msg': '请先切换到具体俱乐部再修改审核模式'})
|
||||
|
||||
try:
|
||||
config, _ = DianpuShangpinShenheShezhi.objects.select_for_update().get_or_create(id=1)
|
||||
club_id = resolve_club_id_for_write(request)
|
||||
config = get_or_create_shenhe_config(club_id)
|
||||
config = DianpuShangpinShenheShezhi.objects.select_for_update().get(pk=config.pk)
|
||||
config.kaiqi_shenhe = bool(kaiqi)
|
||||
config.save(update_fields=['kaiqi_shenhe'])
|
||||
return Response({'code': 0, 'msg': '审核模式已更新'})
|
||||
return Response({'code': 0, 'msg': '审核模式已更新', 'data': {'club_id': club_id}})
|
||||
except Exception as e:
|
||||
logger.exception("更新审核模式失败")
|
||||
return Response({'code': 500, 'msg': '服务器错误'})
|
||||
|
||||
@transaction.atomic
|
||||
def _update_zhi_kan_shenhe(self, request, user_perms):
|
||||
"""点单端:未绑店用户是否按身份只看审核专用商品。"""
|
||||
"""点单端:未绑店用户是否按身份只看审核专用商品(按俱乐部)。"""
|
||||
if not has_perm_code(user_perms, '1199ab'):
|
||||
return Response({'code': 403, 'msg': '无权限修改只看审核开关'})
|
||||
|
||||
@@ -659,11 +690,21 @@ class ShopProductModifyView(APIView):
|
||||
if val is None:
|
||||
return Response({'code': 400, 'msg': '缺少参数 zhi_kan_shenhe'})
|
||||
|
||||
from jituan.constants import DATA_SCOPE_ALL
|
||||
from jituan.services.club_context import resolve_club_scope
|
||||
from jituan.services.club_write import resolve_club_id_for_write
|
||||
from shop.services.shenhe_config import get_or_create_shenhe_config
|
||||
|
||||
if resolve_club_scope(request) == DATA_SCOPE_ALL:
|
||||
return Response({'code': 400, 'msg': '请先切换到具体俱乐部再修改只看审核开关'})
|
||||
|
||||
try:
|
||||
config, _ = DianpuShangpinShenheShezhi.objects.select_for_update().get_or_create(id=1)
|
||||
club_id = resolve_club_id_for_write(request)
|
||||
config = get_or_create_shenhe_config(club_id)
|
||||
config = DianpuShangpinShenheShezhi.objects.select_for_update().get(pk=config.pk)
|
||||
config.zhi_kan_shenhe = bool(val)
|
||||
config.save(update_fields=['zhi_kan_shenhe'])
|
||||
return Response({'code': 0, 'msg': '只看审核开关已更新'})
|
||||
return Response({'code': 0, 'msg': '只看审核开关已更新', 'data': {'club_id': club_id}})
|
||||
except Exception:
|
||||
logger.exception("更新只看审核开关失败")
|
||||
return Response({'code': 500, 'msg': '服务器错误'})
|
||||
|
||||
Reference in New Issue
Block a user