feat(jituan): 订单列表修复、财务 club 过滤、数据范围 API

This commit is contained in:
XingQue
2026-06-24 06:07:41 +08:00
parent 32486a6e77
commit c42f979082
6 changed files with 161 additions and 66 deletions

View File

@@ -0,0 +1,41 @@
"""回填订单 ClubID空值设为 xq"""
from django.core.management.base import BaseCommand
from django.db import transaction
from jituan.constants import CLUB_ID_DEFAULT
from orders.models import Order
class Command(BaseCommand):
help = '回填 Order.ClubID空或缺省设为 xq'
def add_arguments(self, parser):
parser.add_argument(
'--dry-run',
action='store_true',
help='仅统计不落库',
)
def handle(self, *args, **options):
dry_run = options.get('dry_run', False)
updated = 0
skipped = 0
for order in Order.query.all().only('id', 'OrderID', 'ClubID'):
current = getattr(order, 'ClubID', None) or ''
if current:
skipped += 1
continue
if dry_run:
self.stdout.write(f'[dry-run] {order.OrderID} -> ClubID={CLUB_ID_DEFAULT}')
updated += 1
continue
with transaction.atomic():
order.ClubID = CLUB_ID_DEFAULT
order.save(update_fields=['ClubID'])
updated += 1
suffix = 'dry-run' if dry_run else ''
self.stdout.write(self.style.SUCCESS(f'完成{suffix}:更新 {updated},跳过 {skipped}'))