feat: 点单横幅/个人中心背景 page_key,并 seed 转盘菜单

新增 accept_order_banner2、boss_center;菜单定义写入 product.turntable,不影响现有俱乐部数据隔离。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-22 20:21:16 +08:00
parent 6a107e873d
commit 43ad221c67
5 changed files with 46 additions and 10 deletions

View File

@@ -619,6 +619,7 @@ class ModifyProductTypeZoneView(APIView):
shenhezhuangtai=shenhezhuangtai, shenhezhuangtai=shenhezhuangtai,
paixu=0, paixu=0,
club_id=club_id, club_id=club_id,
tupian_url=(request.data.get('tupian_url') or '').strip(),
) )
return Response({'code': 0, 'msg': '添加成功', 'data': {'id': zhuanqu.id, 'club_id': club_id}}) return Response({'code': 0, 'msg': '添加成功', 'data': {'id': zhuanqu.id, 'club_id': club_id}})
except Exception as e: except Exception as e:
@@ -670,6 +671,12 @@ class ModifyProductTypeZoneView(APIView):
except (TypeError, ValueError): except (TypeError, ValueError):
return Response({'code': 400, 'msg': '审核状态无效必须为1或2'}) return Response({'code': 400, 'msg': '审核状态无效必须为1或2'})
if 'tupian_url' in request.data:
new_url = (request.data.get('tupian_url') or '').strip()
old_url = getattr(zhuanqu, 'tupian_url', None) or ''
if new_url != old_url:
changes['tupian_url'] = new_url
if not changes: if not changes:
return Response({'code': 400, 'msg': '未做任何修改'}) return Response({'code': 400, 'msg': '未做任何修改'})

View File

@@ -81,11 +81,17 @@ class ShangpinGonggaoView(APIView):
""" """
try: try:
logger.info("收到商品公告和轮播图请求") logger.info("收到商品公告和轮播图请求")
from jituan.services.display_config import get_gonggao_content, get_lunbo_urls, normalize_page_key from jituan.services.display_config import (
get_gonggao_content,
get_lunbo_urls,
lunbo_image_type_for_page,
normalize_page_key,
)
page_key = normalize_page_key(request.data.get('page_key'), image_type=1) page_key = normalize_page_key(request.data.get('page_key'), image_type=1)
image_type = lunbo_image_type_for_page(page_key)
gonggao_content = get_gonggao_content(request, notice_type=1, page_key=page_key) gonggao_content = get_gonggao_content(request, notice_type=1, page_key=page_key)
lunbo_urls = get_lunbo_urls(request, page_key=page_key, image_type=1) lunbo_urls = get_lunbo_urls(request, page_key=page_key, image_type=image_type)
response_data = { response_data = {
"shangpingonggao": gonggao_content, "shangpingonggao": gonggao_content,
"shangpinlunbo": lunbo_urls, "shangpinlunbo": lunbo_urls,

View File

@@ -11,26 +11,44 @@ from rest_framework.response import Response
# 定稿 B 方案 page_key # 定稿 B 方案 page_key
LUNBO_PAGE_ORDER_POOL = 'order_pool' LUNBO_PAGE_ORDER_POOL = 'order_pool'
LUNBO_PAGE_ACCEPT_ORDER = 'accept_order' LUNBO_PAGE_ACCEPT_ORDER = 'accept_order'
LUNBO_PAGE_ACCEPT_BANNER2 = 'accept_order_banner2' # 点单页第二横幅轮播(如 UFO banner2
LUNBO_PAGE_MERCHANT_HOME = 'merchant_home' LUNBO_PAGE_MERCHANT_HOME = 'merchant_home'
LUNBO_PAGE_DASHOU_CENTER = 'dashou_center' LUNBO_PAGE_DASHOU_CENTER = 'dashou_center'
LUNBO_PAGE_BOSS_CENTER = 'boss_center' # 点单端「我的」顶区背景
LUNBO_CENTER_BG_KEYS = {LUNBO_PAGE_DASHOU_CENTER, LUNBO_PAGE_BOSS_CENTER}
LUNBO_CAROUSEL_KEYS = {
LUNBO_PAGE_ORDER_POOL,
LUNBO_PAGE_ACCEPT_ORDER,
LUNBO_PAGE_ACCEPT_BANNER2,
LUNBO_PAGE_MERCHANT_HOME,
}
LUNBO_PAGE_OPTIONS = [ LUNBO_PAGE_OPTIONS = [
(LUNBO_PAGE_ORDER_POOL, '抢单池'), (LUNBO_PAGE_ORDER_POOL, '抢单池'),
(LUNBO_PAGE_ACCEPT_ORDER, '点单页'), (LUNBO_PAGE_ACCEPT_ORDER, '点单页主轮播'),
(LUNBO_PAGE_ACCEPT_BANNER2, '点单页横幅轮播'),
(LUNBO_PAGE_MERCHANT_HOME, '商家首页'), (LUNBO_PAGE_MERCHANT_HOME, '商家首页'),
(LUNBO_PAGE_DASHOU_CENTER, '打手个人中心背景'), (LUNBO_PAGE_DASHOU_CENTER, '打手个人中心背景'),
(LUNBO_PAGE_BOSS_CENTER, '点单个人中心背景'),
] ]
def normalize_page_key(page_key, image_type=1): def normalize_page_key(page_key, image_type=1):
key = (page_key or '').strip() key = (page_key or '').strip()
if key in LUNBO_CENTER_BG_KEYS or key in LUNBO_CAROUSEL_KEYS:
return key
if image_type == 2: if image_type == 2:
return LUNBO_PAGE_DASHOU_CENTER return LUNBO_PAGE_DASHOU_CENTER
if key in {LUNBO_PAGE_ORDER_POOL, LUNBO_PAGE_ACCEPT_ORDER, LUNBO_PAGE_MERCHANT_HOME}:
return key
return LUNBO_PAGE_ORDER_POOL return LUNBO_PAGE_ORDER_POOL
def lunbo_image_type_for_page(page_key):
"""个人中心背景页用 ImageType=2其余轮播用 1。"""
pk = normalize_page_key(page_key, image_type=1)
return 2 if pk in LUNBO_CENTER_BG_KEYS else 1
def forbid_display_write_in_all_scope(request): def forbid_display_write_in_all_scope(request):
if resolve_club_scope(request) == DATA_SCOPE_ALL: if resolve_club_scope(request) == DATA_SCOPE_ALL:
return Response({'code': 403, 'msg': '请在子公司视图下修改展示配置'}) return Response({'code': 403, 'msg': '请在子公司视图下修改展示配置'})
@@ -73,6 +91,9 @@ def get_lunbo_urls(request, page_key=None, image_type=1):
from config.models import Lunbo from config.models import Lunbo
club_id = _display_club_id(request) club_id = _display_club_id(request)
pk = normalize_page_key(page_key, image_type=image_type) pk = normalize_page_key(page_key, image_type=image_type)
# 个人中心背景页一律 ImageType=2避免误传 image_type=1 读不到
if pk in LUNBO_CENTER_BG_KEYS:
image_type = 2
qs = Lunbo.query.filter(club_id=club_id, ImageType=image_type, page_key=pk) qs = Lunbo.query.filter(club_id=club_id, ImageType=image_type, page_key=pk)
return [row.ImageURL for row in qs.order_by('id') if row.ImageURL] return [row.ImageURL for row in qs.order_by('id') if row.ImageURL]

View File

@@ -69,9 +69,11 @@ KEFU_MENU_ROW_DEFS = [
'perm_codes': ['2200a']}, 'perm_codes': ['2200a']},
{'page_id': 'product.type-zone', 'name': '商品类型专区管理', 'path': '/product/type-zone', 'parent_id': 'product', 'sort_order': 92, {'page_id': 'product.type-zone', 'name': '商品类型专区管理', 'path': '/product/type-zone', 'parent_id': 'product', 'sort_order': 92,
'perm_codes': ['7007a']}, 'perm_codes': ['7007a']},
{'page_id': 'product.data', 'name': '商品数据分析', 'path': '/product/data', 'parent_id': 'product', 'sort_order': 93, {'page_id': 'product.turntable', 'name': '转盘活动', 'path': '/product/turntable', 'parent_id': 'product', 'sort_order': 93,
'perm_codes': ['2200a']}, 'perm_codes': ['2200a']},
{'page_id': 'product.fake-orders', 'name': '假单管理', 'path': '/product/fake-orders', 'parent_id': 'product', 'sort_order': 94, {'page_id': 'product.data', 'name': '商品数据分析', 'path': '/product/data', 'parent_id': 'product', 'sort_order': 94,
'perm_codes': ['2200a']},
{'page_id': 'product.fake-orders', 'name': '假单管理', 'path': '/product/fake-orders', 'parent_id': 'product', 'sort_order': 95,
'perm_codes': ['2200a']}, 'perm_codes': ['2200a']},
{'page_id': 'member', 'name': '会员管理', 'path': '', 'parent_id': '', 'sort_order': 100}, {'page_id': 'member', 'name': '会员管理', 'path': '', 'parent_id': '', 'sort_order': 100},
{'page_id': 'member.list', 'name': '会员管理', 'path': '/member/list', 'parent_id': 'member', 'sort_order': 101, {'page_id': 'member.list', 'name': '会员管理', 'path': '/member/list', 'parent_id': 'member', 'sort_order': 101,

View File

@@ -16,8 +16,8 @@ from jituan.services.display_config import (
get_lunbo_urls, get_lunbo_urls,
list_response_meta, list_response_meta,
list_tupianpeizhi_by_type, list_tupianpeizhi_by_type,
LUNBO_PAGE_DASHOU_CENTER,
LUNBO_PAGE_OPTIONS, LUNBO_PAGE_OPTIONS,
lunbo_image_type_for_page,
normalize_page_key, normalize_page_key,
TUPIAN_TYPE_LABELS, TUPIAN_TYPE_LABELS,
upsert_tupianpeizhi_single, upsert_tupianpeizhi_single,
@@ -44,7 +44,7 @@ class ClubLunboListView(APIView):
return Response({'code': 403, 'msg': '无权限管理轮播图'}) return Response({'code': 403, 'msg': '无权限管理轮播图'})
page_key = normalize_page_key(request.data.get('page_key'), image_type=1) page_key = normalize_page_key(request.data.get('page_key'), image_type=1)
image_type = 2 if page_key == LUNBO_PAGE_DASHOU_CENTER else 1 image_type = lunbo_image_type_for_page(page_key)
urls = get_lunbo_urls(request, page_key=page_key, image_type=image_type) urls = get_lunbo_urls(request, page_key=page_key, image_type=image_type)
return Response({ return Response({
'code': 0, 'code': 0,
@@ -79,7 +79,7 @@ class ClubLunboManageView(APIView):
action = (request.data.get('action') or '').strip() action = (request.data.get('action') or '').strip()
club_id = resolve_effective_club_id(request, request.user) club_id = resolve_effective_club_id(request, request.user)
page_key = normalize_page_key(request.data.get('page_key'), image_type=1) page_key = normalize_page_key(request.data.get('page_key'), image_type=1)
image_type = 2 if page_key == LUNBO_PAGE_DASHOU_CENTER else 1 image_type = lunbo_image_type_for_page(page_key)
if action == 'delete': if action == 'delete':
tupian_url = (request.data.get('tupian_url') or '').strip() tupian_url = (request.data.get('tupian_url') or '').strip()