feat: 后台添加商家 + 龙先生 lsx 俱乐部/邀请链种子

支持客服按用户UID开通商家(分俱乐部校验);新增 seed_club_lsx、seed_lsx_invite_data。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-23 21:29:22 +08:00
parent 46d64fbf92
commit cddd231dc2
6 changed files with 313 additions and 1 deletions

View File

@@ -0,0 +1,66 @@
"""一键初始化龙先生电竞(lsx)俱乐部(默认不批量给所有客服加任职)。"""
from django.core.management import call_command
from django.core.management.base import BaseCommand
from jituan.models import Club
class Command(BaseCommand):
help = '创建龙先生电竞俱乐部(lsx);任职请单独 seed_admin_assignments --phone ...'
def add_arguments(self, parser):
parser.add_argument(
'--wx-appid', default='wx7ff90e9d024fcdb8', help='龙先生电竞小程序 appid',
)
parser.add_argument(
'--assignments',
action='store_true',
help='同时给 --phone 指定客服加 lsx 任职(需配合 --phone',
)
parser.add_argument(
'--phone', type=str, default='', help='与 --assignments 联用:客服手机号',
)
def handle(self, *args, **options):
wx_appid = (options.get('wx_appid') or '').strip()
club_id = 'lsx'
name = '龙先生电竞'
if Club.query.filter(club_id=club_id).exists():
self.stdout.write(self.style.WARNING(f'俱乐部 {club_id} 已存在,跳过 create_club'))
club = Club.query.filter(club_id=club_id).first()
if club and wx_appid and (club.wx_appid or '') != wx_appid:
club.wx_appid = wx_appid
club.save(update_fields=['wx_appid'])
self.stdout.write(f'已更新 {club_id}.wx_appid = {wx_appid}')
else:
self.stdout.write(f'创建俱乐部 {club_id} ...')
call_command(
'create_club',
club_id,
name=name,
wx_appid=wx_appid,
)
if options.get('assignments'):
phone = (options.get('phone') or '').strip()
if not phone:
self.stdout.write(self.style.WARNING(
'未指定 --phone跳过任职。示例'
'python manage.py seed_club_lsx --assignments --phone 你的手机号'
))
else:
call_command(
'seed_admin_assignments',
club_id=club_id,
phone=phone,
)
else:
self.stdout.write(
'未加任职。需要时在后台「数据范围」配置,或:'
'python manage.py seed_admin_assignments --phone 手机号 --club-id lsx'
)
self.stdout.write(self.style.SUCCESS(
f'龙先生电竞 {club_id} 就绪。请在后台「俱乐部配置」检查支付密钥与 wx_appid。'
))