From ff5b13e7173234a0558d7106062758475695bb17 Mon Sep 17 00:00:00 2001 From: XingQue Date: Fri, 26 Jun 2026 05:38:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(jituan):=20=E4=BF=B1=E4=B9=90=E9=83=A8?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=B1=BB=E5=9E=8B/=E8=80=83=E6=A0=B8?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=8C=89=E8=A7=86=E5=9B=BE=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jituan/services/club_kaohe_chenghao.py | 22 ++++++++++++++++++++-- jituan/services/club_shangpin_leixing.py | 21 +++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/jituan/services/club_kaohe_chenghao.py b/jituan/services/club_kaohe_chenghao.py index d1c9741..42c1dec 100644 --- a/jituan/services/club_kaohe_chenghao.py +++ b/jituan/services/club_kaohe_chenghao.py @@ -1,15 +1,20 @@ """俱乐部抢单池标签筛选区配置(全局考核称号由集团定义)。""" -from jituan.constants import CLUB_ID_DEFAULT +from jituan.constants import DATA_SCOPE_ALL from jituan.models import ClubKaoheChenghaoConfig from jituan.services.club_context import ( club_id_for_write, resolve_club_id_from_request, resolve_club_scope, ) -from jituan.constants import DATA_SCOPE_ALL +from jituan.constants import CLUB_ID_DEFAULT from rank.models import Chenghao CLUB_WRITE_SCOPE_MSG = '当前为集团汇总视图,请先在顶栏切换到具体俱乐部后再操作' +CLUB_READ_SCOPE_MSG = '请先在顶栏切换到具体小程序/俱乐部后再操作' + + +def club_read_blocked(request): + return resolve_club_scope(request) == DATA_SCOPE_ALL def club_write_blocked(request): @@ -43,6 +48,13 @@ def filter_chenghao_ids_for_pool(club_id, chenghao_ids): def build_club_kaohe_admin_list(request, bankuai_id=None): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'list': [], + 'scope': resolve_club_scope(request), + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) qs = Chenghao.objects.filter(leixing='dashou') @@ -68,6 +80,12 @@ def build_club_kaohe_admin_list(request, bankuai_id=None): def build_club_kaohe_catalog(request, bankuai_id=None): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'catalog': [], + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) qs = Chenghao.objects.filter(leixing='dashou') diff --git a/jituan/services/club_shangpin_leixing.py b/jituan/services/club_shangpin_leixing.py index 721d2bb..80b8a8f 100644 --- a/jituan/services/club_shangpin_leixing.py +++ b/jituan/services/club_shangpin_leixing.py @@ -5,20 +5,24 @@ import uuid from django.db import transaction -from jituan.constants import CLUB_ID_DEFAULT +from jituan.constants import CLUB_ID_DEFAULT, DATA_SCOPE_ALL from jituan.models import ClubShangpinLeixingConfig from jituan.services.club_context import ( club_id_for_write, resolve_club_id_from_request, resolve_club_scope, ) -from jituan.constants import DATA_SCOPE_ALL from products.models import ShangpinLeixing from utils.oss_utils import delete_from_oss, upload_to_oss, validate_image logger = logging.getLogger(__name__) CLUB_WRITE_SCOPE_MSG = '当前为集团汇总视图,请先在顶栏切换到具体俱乐部后再操作' +CLUB_READ_SCOPE_MSG = '请先在顶栏切换到具体小程序/俱乐部后再操作' + + +def club_read_blocked(request): + return resolve_club_scope(request) == DATA_SCOPE_ALL def club_write_blocked(request): @@ -76,6 +80,13 @@ def build_club_leixing_list_for_api(club_id): def build_club_leixing_admin_list(request): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'list': [], + 'scope': resolve_club_scope(request), + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) enabled = [] @@ -95,6 +106,12 @@ def build_club_leixing_admin_list(request): def build_club_leixing_catalog(request): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'catalog': [], + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) catalog = []