fix: 抢单列表身份标签 club 回退与 dashou 称号
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
"""身份装饰标签查询与组装(与考核称号、订单需求标签分离)。"""
|
||||
import json
|
||||
|
||||
from django.db.models import Q
|
||||
|
||||
from jituan.constants import CLUB_ID_DEFAULT
|
||||
from jituan.models import IdentityTag, IdentityTagBind
|
||||
|
||||
SHENFEN_DASHOU = 1
|
||||
@@ -29,12 +32,24 @@ def format_tag_item(tag):
|
||||
}
|
||||
|
||||
|
||||
def _club_id_filter(club_id):
|
||||
"""按俱乐部查绑定;非默认俱乐部时回退 xq / 空,兼容集团历史数据。"""
|
||||
q = Q(club_id=club_id)
|
||||
if club_id and club_id != CLUB_ID_DEFAULT:
|
||||
q |= Q(club_id=CLUB_ID_DEFAULT) | Q(club_id__isnull=True) | Q(club_id='')
|
||||
elif club_id == CLUB_ID_DEFAULT:
|
||||
q |= Q(club_id__isnull=True) | Q(club_id='')
|
||||
return q
|
||||
|
||||
|
||||
def get_identity_tags_for_user(club_id, yonghuid, shenfen):
|
||||
"""单用户单身份装饰标签列表。"""
|
||||
binds = (
|
||||
IdentityTagBind.query.filter(
|
||||
club_id=club_id, yonghuid=yonghuid, shenfen=shenfen,
|
||||
yonghuid=yonghuid,
|
||||
shenfen=shenfen,
|
||||
)
|
||||
.filter(_club_id_filter(club_id))
|
||||
.select_related('tag')
|
||||
.order_by('tag__sort_order', 'tag__id')
|
||||
)
|
||||
@@ -57,19 +72,26 @@ def batch_identity_tags(club_id, 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,
|
||||
yonghuid__in=yonghuids,
|
||||
shenfen__in=shenfens,
|
||||
)
|
||||
.filter(_club_id_filter(club_id))
|
||||
.select_related('tag')
|
||||
.order_by('tag__sort_order', 'tag__id')
|
||||
)
|
||||
out = {}
|
||||
pair_set = set(yonghuid_shenfen_pairs)
|
||||
seen = {}
|
||||
for b in binds:
|
||||
key = (b.yonghuid, b.shenfen)
|
||||
if key not in pair_set:
|
||||
continue
|
||||
if b.tag.status != 1:
|
||||
continue
|
||||
tag_id = b.tag.id
|
||||
if seen.get(key, set()).intersection({tag_id}):
|
||||
continue
|
||||
seen.setdefault(key, set()).add(tag_id)
|
||||
out.setdefault(key, []).append(format_tag_item(b.tag))
|
||||
return out
|
||||
|
||||
|
||||
Reference in New Issue
Block a user