From 77e1d3f293f1366639efa379c4adbae128de9071 Mon Sep 17 00:00:00 2001 From: XingQue Date: Wed, 24 Jun 2026 23:05:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20seed=5Fadmin=5Fassignments?= =?UTF-8?q?=20=E7=94=A8=20KefuProfile=20=E7=AD=9B=E9=80=89=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D=E8=B4=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jituan/management/commands/seed_admin_assignments.py | 3 ++- jituan/management/commands/seed_club_xzj.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jituan/management/commands/seed_admin_assignments.py b/jituan/management/commands/seed_admin_assignments.py index c3cf88f..05106ab 100644 --- a/jituan/management/commands/seed_admin_assignments.py +++ b/jituan/management/commands/seed_admin_assignments.py @@ -30,7 +30,8 @@ class Command(BaseCommand): role_code = options['role_code'] dry_run = options['dry_run'] - kefu_users = User.query.filter(UserType='kefu') + # UserType 是属性不是 DB 字段,通过 KefuProfile 关联筛选客服账号 + kefu_users = User.query.filter(KefuProfile__isnull=False).select_related('KefuProfile') created = 0 skipped = 0 diff --git a/jituan/management/commands/seed_club_xzj.py b/jituan/management/commands/seed_club_xzj.py index 0014ea7..9856c4b 100644 --- a/jituan/management/commands/seed_club_xzj.py +++ b/jituan/management/commands/seed_club_xzj.py @@ -34,7 +34,12 @@ class Command(BaseCommand): if not options.get('skip_assignments'): self.stdout.write('分配客服数据范围 ...') - call_command('seed_admin_assignments', club_id=club_id) + try: + call_command('seed_admin_assignments', club_id=club_id) + except Exception as e: + self.stdout.write(self.style.WARNING( + f'客服数据范围分配失败(可稍后在后台「数据范围」页手动配置): {e}' + )) self.stdout.write(self.style.SUCCESS( f'星之界 {club_id} 就绪。请在后台「俱乐部配置」检查支付密钥,并在 xzj 视图下单独改轮播/会员价。'