feat: 点单横幅/个人中心背景 page_key,并 seed 转盘菜单
新增 accept_order_banner2、boss_center;菜单定义写入 product.turntable,不影响现有俱乐部数据隔离。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,26 +11,44 @@ from rest_framework.response import Response
|
||||
# 定稿 B 方案 page_key
|
||||
LUNBO_PAGE_ORDER_POOL = 'order_pool'
|
||||
LUNBO_PAGE_ACCEPT_ORDER = 'accept_order'
|
||||
LUNBO_PAGE_ACCEPT_BANNER2 = 'accept_order_banner2' # 点单页第二横幅轮播(如 UFO banner2)
|
||||
LUNBO_PAGE_MERCHANT_HOME = 'merchant_home'
|
||||
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_ORDER_POOL, '抢单池'),
|
||||
(LUNBO_PAGE_ACCEPT_ORDER, '点单页'),
|
||||
(LUNBO_PAGE_ACCEPT_ORDER, '点单页主轮播'),
|
||||
(LUNBO_PAGE_ACCEPT_BANNER2, '点单页横幅轮播'),
|
||||
(LUNBO_PAGE_MERCHANT_HOME, '商家首页'),
|
||||
(LUNBO_PAGE_DASHOU_CENTER, '打手个人中心背景'),
|
||||
(LUNBO_PAGE_BOSS_CENTER, '点单个人中心背景'),
|
||||
]
|
||||
|
||||
|
||||
def normalize_page_key(page_key, image_type=1):
|
||||
key = (page_key or '').strip()
|
||||
if key in LUNBO_CENTER_BG_KEYS or key in LUNBO_CAROUSEL_KEYS:
|
||||
return key
|
||||
if image_type == 2:
|
||||
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
|
||||
|
||||
|
||||
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):
|
||||
if resolve_club_scope(request) == DATA_SCOPE_ALL:
|
||||
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
|
||||
club_id = _display_club_id(request)
|
||||
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)
|
||||
return [row.ImageURL for row in qs.order_by('id') if row.ImageURL]
|
||||
|
||||
|
||||
@@ -69,9 +69,11 @@ KEFU_MENU_ROW_DEFS = [
|
||||
'perm_codes': ['2200a']},
|
||||
{'page_id': 'product.type-zone', 'name': '商品类型专区管理', 'path': '/product/type-zone', 'parent_id': 'product', 'sort_order': 92,
|
||||
'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']},
|
||||
{'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']},
|
||||
{'page_id': 'member', 'name': '会员管理', 'path': '', 'parent_id': '', 'sort_order': 100},
|
||||
{'page_id': 'member.list', 'name': '会员管理', 'path': '/member/list', 'parent_id': 'member', 'sort_order': 101,
|
||||
|
||||
@@ -16,8 +16,8 @@ from jituan.services.display_config import (
|
||||
get_lunbo_urls,
|
||||
list_response_meta,
|
||||
list_tupianpeizhi_by_type,
|
||||
LUNBO_PAGE_DASHOU_CENTER,
|
||||
LUNBO_PAGE_OPTIONS,
|
||||
lunbo_image_type_for_page,
|
||||
normalize_page_key,
|
||||
TUPIAN_TYPE_LABELS,
|
||||
upsert_tupianpeizhi_single,
|
||||
@@ -44,7 +44,7 @@ class ClubLunboListView(APIView):
|
||||
return Response({'code': 403, 'msg': '无权限管理轮播图'})
|
||||
|
||||
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)
|
||||
return Response({
|
||||
'code': 0,
|
||||
@@ -79,7 +79,7 @@ class ClubLunboManageView(APIView):
|
||||
action = (request.data.get('action') or '').strip()
|
||||
club_id = resolve_effective_club_id(request, request.user)
|
||||
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':
|
||||
tupian_url = (request.data.get('tupian_url') or '').strip()
|
||||
|
||||
Reference in New Issue
Block a user