修复了管理员无法进后台的问题

This commit is contained in:
2026-06-19 01:58:34 +08:00
parent 5b9436b994
commit d71a81f279
22 changed files with 4396 additions and 4295 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -70,12 +70,12 @@ class BindDianpuView(APIView):
return Response({'code': 400, 'msg': '店铺ID不能为空'})
user = request.user
if not hasattr(user, 'yonghuid'):
if not hasattr(user, 'UserUID'):
return Response({'code': 500, 'msg': '用户身份信息异常'})
# 先获取 User 对象(不加锁,仅用于校验存在性)
try:
user_main = User.query.get(UserUID=user.yonghuid)
user_main = User.query.get(UserUID=user.UserUID)
except User.DoesNotExist:
return Response({'code': 404, 'msg': '用户不存在'})
@@ -92,7 +92,7 @@ class BindDianpuView(APIView):
try:
with transaction.atomic():
# 重新获取加锁的用户对象(确保并发安全)
user_main_locked = User.objects.select_for_update().get(UserUID=user.yonghuid)
user_main_locked = User.objects.select_for_update().get(UserUID=user.UserUID)
dianpu_locked = Dianpu.objects.select_for_update().get(id=dianpu_id)
# 再次校验店铺状态(防止事务期间被修改)
@@ -121,7 +121,7 @@ class BindDianpuView(APIView):
dianpu_locked.bangding_yonghushu = F('bangding_yonghushu') + 1
dianpu_locked.save(update_fields=['bangding_yonghushu'])
logger.info(f"用户 {user.yonghuid} 绑定店铺 {dianpu_id} 成功")
logger.info(f"用户 {user.UserUID} 绑定店铺 {dianpu_id} 成功")
return Response({'code': 200, 'msg': '绑定成功'})
except Exception as e:
@@ -396,7 +396,7 @@ class ShangdianLoginView(APIView):
# 10. 构造返回数据
data = {
'token': token,
'yonghuid': user_main.yonghuid,
'yonghuid': user_main.UserUID,
'dianpu_mingcheng': dianpu.dianpu_mingcheng,
'dianpu_touxiang': dianpu.dianpu_touxiang or '',
'erweima_url': dianpu.erweima_url or ''
@@ -2589,7 +2589,7 @@ class ShopRefundView(APIView):
if dashou_id:
try:
dashou_user = User.query.get(UserUID=dashou_id)
dashou_profile = dashou_user.dashou_profile
dashou_profile = dashou_user.DashouProfile
dashou_profile.tuikuanliang += 1
dashou_profile.zhuangtai = 1
dashou_profile.save()
@@ -2832,7 +2832,7 @@ class ShopForceCompleteView(APIView):
# ---------- 更新打手余额和统计 ----------
try:
dashou_user = User.query.get(UserUID=dashou_id)
dashou_profile = dashou_user.dashou_profile
dashou_profile = dashou_user.DashouProfile
dashou_profile.chengjiaozongliang += 1
dashou_profile.yue += dashou_fencheng
dashou_profile.zonge += dashou_fencheng