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 视图下单独改轮播/会员价。'