fix: 自动结算写入对齐 USE_TZ;lxs 打手注册同步开通管事
order_deal 不再 make_aware 入库以免 MySQL 报错;龙先生打手注册成功时创建管事且邀请人与打手相同。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
46
users/services/lxs_dashou_guanshi.py
Normal file
46
users/services/lxs_dashou_guanshi.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""龙先生(lxs):打手注册成功时同步开通管事。
|
||||
|
||||
管事邀请人 = 打手邀请人(邀请该用户的管事 UID)。
|
||||
其它俱乐部不处理。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from utils.invitationcode_utils import CreateInvitationCode
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LXS_CLUB_ID = 'lxs'
|
||||
|
||||
|
||||
def ensure_lxs_guanshi_on_dashou_register(user, inviter_uid, club_id):
|
||||
"""
|
||||
仅 club_id=lxs:若尚无管事身份则创建。
|
||||
返回新建或已有的 UserGuanshi;非 lxs / 参数不全则返回 None。
|
||||
"""
|
||||
from users.models import UserGuanshi
|
||||
|
||||
if (club_id or '').strip() != LXS_CLUB_ID:
|
||||
return None
|
||||
if not user:
|
||||
return None
|
||||
|
||||
existing = UserGuanshi.query.filter(user=user).first()
|
||||
if existing:
|
||||
return existing
|
||||
|
||||
inviter = (inviter_uid or '').strip()[:7] or None
|
||||
yaoqingma = CreateInvitationCode(str(user.UserUID))
|
||||
profile = UserGuanshi.query.create(
|
||||
user=user,
|
||||
yaoqingma=yaoqingma,
|
||||
yaoqingren=inviter,
|
||||
)
|
||||
logger.info(
|
||||
'lxs 打手注册同步开通管事 uid=%s yaoqingren=%s yaoqingma=%s',
|
||||
getattr(user, 'UserUID', ''),
|
||||
inviter,
|
||||
yaoqingma,
|
||||
)
|
||||
return profile
|
||||
@@ -580,7 +580,11 @@ class DashouZhuceView(APIView):
|
||||
pass
|
||||
|
||||
|
||||
# 5.3 创建管事扩展表
|
||||
# 5.3 龙先生:同步开通管事,邀请人与打手邀请人相同
|
||||
from users.services.lxs_dashou_guanshi import ensure_lxs_guanshi_on_dashou_register
|
||||
ensure_lxs_guanshi_on_dashou_register(
|
||||
current_user, guanshi_yonghuid, club_id,
|
||||
)
|
||||
|
||||
# 5.4 更新主表的用户类型 (如果需要,可以设为'dashou',或保持原逻辑)
|
||||
# current_user.UserType = 'dashou' # 根据你的业务逻辑决定
|
||||
@@ -613,10 +617,14 @@ class DashouZhuceView(APIView):
|
||||
|
||||
# 6. 注册成功,返回信息 (新注册用户没有会员记录,clumber返回空列表)
|
||||
fanhui_data = self.zhuangbeiFanhuiShuju(dashou_profile, current_user, is_new=True)
|
||||
if (club_id or '').strip() == 'lxs':
|
||||
ok_msg = '注册成功!已开通打手、管事身份。'
|
||||
else:
|
||||
ok_msg = '注册成功!'
|
||||
return Response({
|
||||
'code': 200,
|
||||
'message': '注册成功!已开通打手、管事身份。',
|
||||
'msg': '注册成功!已开通打手、管事身份。',
|
||||
'message': ok_msg,
|
||||
'msg': ok_msg,
|
||||
'data': fanhui_data
|
||||
})
|
||||
|
||||
@@ -921,7 +929,11 @@ class WechatLoginAndDashouRegisterView(APIView):
|
||||
|
||||
# 创建商家扩展表
|
||||
|
||||
# 创建管事扩展表
|
||||
# 龙先生:同步开通管事,邀请人与打手邀请人相同
|
||||
from users.services.lxs_dashou_guanshi import ensure_lxs_guanshi_on_dashou_register
|
||||
ensure_lxs_guanshi_on_dashou_register(
|
||||
user_main, guanshi_yonghuid, club_id,
|
||||
)
|
||||
|
||||
# 更新原管事的邀请数量
|
||||
locked_guanshi = UserGuanshi.objects.select_for_update().get(pk=guanshi_profile.pk)
|
||||
@@ -946,9 +958,13 @@ class WechatLoginAndDashouRegisterView(APIView):
|
||||
# 6. 准备返回数据
|
||||
response_data = self.zhuangbeiFanhuiShuju(user_main, dashou_profile, token)
|
||||
|
||||
if (club_id or '').strip() == 'lxs':
|
||||
ok_msg = '登录并注册成功!已开通打手、管事等身份。'
|
||||
else:
|
||||
ok_msg = '登录并注册成功!'
|
||||
return Response({
|
||||
'code': 0,
|
||||
'msg': '登录并注册成功!已开通打手、管事等身份。',
|
||||
'msg': ok_msg,
|
||||
'data': response_data
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user