feat: 公告按页、身份标签、拼多多订单号、派单与抢单改造
This commit is contained in:
@@ -58,10 +58,13 @@ def _display_club_id(request):
|
||||
return resolve_effective_club_id(request, None)
|
||||
|
||||
|
||||
def get_gonggao_content(request, notice_type=1):
|
||||
def get_gonggao_content(request, notice_type=1, page_key=None):
|
||||
from config.models import Gonggao
|
||||
club_id = _display_club_id(request)
|
||||
obj = Gonggao.query.filter(club_id=club_id, NoticeType=notice_type).first()
|
||||
pk = normalize_page_key(page_key, image_type=1) if page_key else LUNBO_PAGE_ORDER_POOL
|
||||
obj = Gonggao.query.filter(club_id=club_id, page_key=pk).first()
|
||||
if not obj and notice_type:
|
||||
obj = Gonggao.query.filter(club_id=club_id, NoticeType=notice_type).first()
|
||||
return obj.Content if obj and obj.Content else ''
|
||||
|
||||
|
||||
@@ -131,6 +134,7 @@ def copy_display_config(template_club_id, new_club_id):
|
||||
for row in Gonggao.query.filter(club_id=template_club_id):
|
||||
Gonggao.query.create(
|
||||
club_id=new_club_id,
|
||||
page_key=getattr(row, 'page_key', None) or 'order_pool',
|
||||
NoticeType=row.NoticeType,
|
||||
Content=row.Content,
|
||||
)
|
||||
|
||||
110
jituan/services/identity_tag.py
Normal file
110
jituan/services/identity_tag.py
Normal file
@@ -0,0 +1,110 @@
|
||||
"""身份装饰标签查询与组装(与考核称号、订单需求标签分离)。"""
|
||||
import json
|
||||
|
||||
from jituan.models import IdentityTag, IdentityTagBind
|
||||
|
||||
SHENFEN_DASHOU = 1
|
||||
SHENFEN_GUANSHI = 2
|
||||
SHENFEN_SHANGJIA = 3
|
||||
SHENFEN_ZUZHANG = 4
|
||||
|
||||
|
||||
def _tag_texiao(tag):
|
||||
if tag.texiao_json:
|
||||
try:
|
||||
return json.loads(tag.texiao_json)
|
||||
except (TypeError, ValueError, json.JSONDecodeError):
|
||||
pass
|
||||
return {
|
||||
'color': tag.color or '#000000',
|
||||
'flash': bool(tag.flash_enabled),
|
||||
}
|
||||
|
||||
|
||||
def format_tag_item(tag):
|
||||
return {
|
||||
'id': tag.id,
|
||||
'mingcheng': tag.name,
|
||||
'texiao_json': _tag_texiao(tag),
|
||||
}
|
||||
|
||||
|
||||
def get_identity_tags_for_user(club_id, yonghuid, shenfen):
|
||||
"""单用户单身份装饰标签列表。"""
|
||||
binds = (
|
||||
IdentityTagBind.query.filter(
|
||||
club_id=club_id, yonghuid=yonghuid, shenfen=shenfen,
|
||||
)
|
||||
.select_related('tag')
|
||||
.order_by('tag__sort_order', 'tag__id')
|
||||
)
|
||||
result = []
|
||||
for b in binds:
|
||||
tag = b.tag
|
||||
if tag.status != 1:
|
||||
continue
|
||||
result.append(format_tag_item(tag))
|
||||
return result
|
||||
|
||||
|
||||
def batch_identity_tags(club_id, yonghuid_shenfen_pairs):
|
||||
"""
|
||||
批量查询:[(yonghuid, shenfen), ...] -> {(yonghuid, shenfen): [tags]}
|
||||
"""
|
||||
if not yonghuid_shenfen_pairs:
|
||||
return {}
|
||||
yonghuids = {p[0] for p in yonghuid_shenfen_pairs}
|
||||
shenfens = {p[1] for p in yonghuid_shenfen_pairs}
|
||||
binds = (
|
||||
IdentityTagBind.query.filter(
|
||||
club_id=club_id, yonghuid__in=yonghuids, shenfen__in=shenfens,
|
||||
)
|
||||
.select_related('tag')
|
||||
.order_by('tag__sort_order', 'tag__id')
|
||||
)
|
||||
out = {}
|
||||
pair_set = set(yonghuid_shenfen_pairs)
|
||||
for b in binds:
|
||||
key = (b.yonghuid, b.shenfen)
|
||||
if key not in pair_set:
|
||||
continue
|
||||
if b.tag.status != 1:
|
||||
continue
|
||||
out.setdefault(key, []).append(format_tag_item(b.tag))
|
||||
return out
|
||||
|
||||
|
||||
def get_my_identity_tags(user, club_id):
|
||||
"""当前用户各已激活身份的装饰标签。"""
|
||||
uid = user.UserUID
|
||||
data = {'dashou': [], 'guanshi': [], 'zuzhang': [], 'shangjia': []}
|
||||
|
||||
try:
|
||||
dp = user.DashouProfile
|
||||
if dp.zhanghaozhuangtai == 1:
|
||||
data['dashou'] = get_identity_tags_for_user(club_id, uid, SHENFEN_DASHOU)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
gp = user.GuanshiProfile
|
||||
if gp.zhuangtai == 1:
|
||||
data['guanshi'] = get_identity_tags_for_user(club_id, uid, SHENFEN_GUANSHI)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
zp = user.ZuzhangProfile
|
||||
if zp.zhuangtai == 1:
|
||||
data['zuzhang'] = get_identity_tags_for_user(club_id, uid, SHENFEN_ZUZHANG)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
sp = user.ShopProfile
|
||||
if sp.zhuangtai == 1:
|
||||
data['shangjia'] = get_identity_tags_for_user(club_id, uid, SHENFEN_SHANGJIA)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return data
|
||||
Reference in New Issue
Block a user