修复 seed_admin_assignments 用 KefuProfile 筛选客服账号

This commit is contained in:
XingQue
2026-06-24 23:05:06 +08:00
parent 65613af195
commit 77e1d3f293
2 changed files with 8 additions and 2 deletions

View File

@@ -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

View File

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