完成后台多俱乐部数据隔离:订单/会员/财务/板块,并添加星之界初始化命令

This commit is contained in:
XingQue
2026-06-24 22:59:08 +08:00
parent 8154b2639d
commit 65613af195
7 changed files with 273 additions and 184 deletions

View File

@@ -7084,17 +7084,17 @@ class KefuGetOrderListView(APIView):
)
from orders.models import PlatformOrderExt
# 旧 /yonghu/kfhqddlb 不按俱乐部过滤,与改造前行为一致
stats_qs = order_scope_qs(None).filter(q_conditions)
# 按俱乐部过滤订单列表
stats_qs = order_scope_qs(request).filter(q_conditions)
stats = stats_qs.aggregate(
total_orders=Count('id'),
completed_orders=Count('id', filter=Q(Status=3)),
refund_orders=Count('id', filter=Q(Status=5)),
pending_orders=Count('id', filter=Q(Status__in=[4, 8]))
)
status_counts = count_order_status_buckets(q_conditions, request=None)
status_counts = count_order_status_buckets(q_conditions, request)
list_qs = order_scope_qs(None).filter(q_conditions).order_by('-CreateTime')
list_qs = order_scope_qs(request).filter(q_conditions).order_by('-CreateTime')
total_count, orders_page = paginate_fluent_query(list_qs, page, page_size)
if total_count > 0 and not orders_page:
start = (max(1, page) - 1) * page_size
@@ -7256,16 +7256,16 @@ class KefuGetShangjiaOrderListView(APIView):
)
from orders.models import MerchantOrderExt
stats_qs = order_scope_qs(None).filter(q_conditions)
stats_qs = order_scope_qs(request).filter(q_conditions)
stats = stats_qs.aggregate(
total_orders=Count('id'),
completed_orders=Count('id', filter=Q(Status=3)),
refund_orders=Count('id', filter=Q(Status=5)),
pending_orders=Count('id', filter=Q(Status__in=[4, 8]))
)
status_counts = count_order_status_buckets(q_conditions, request=None)
status_counts = count_order_status_buckets(q_conditions, request)
list_qs = order_scope_qs(None).filter(q_conditions).order_by('-CreateTime')
list_qs = order_scope_qs(request).filter(q_conditions).order_by('-CreateTime')
total_count, orders_page = paginate_fluent_query(list_qs, page, page_size)
if total_count > 0 and not orders_page:
start = (max(1, page) - 1) * page_size
@@ -9118,6 +9118,11 @@ class KefuGetOrderDetailView(APIView):
logger.exception(f"[kefuhqddxq] 订单查询异常 dingdan_id={dingdan_id}")
return Response({'code': 500, 'msg': '服务器错误'}, status=500)
from jituan.services.club_user_access import forbid_if_order_out_of_scope
deny = forbid_if_order_out_of_scope(request, dingdan_obj)
if deny:
return deny
# 4. 构建基础数据
try:
response_data = {