修复了已知的生产环境问题
This commit is contained in:
@@ -119,8 +119,8 @@ SIMPLE_JWT = {
|
|||||||
'LEEWAY': 0,
|
'LEEWAY': 0,
|
||||||
'AUTH_HEADER_TYPES': ('Bearer',),
|
'AUTH_HEADER_TYPES': ('Bearer',),
|
||||||
'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION',
|
'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION',
|
||||||
'USER_ID_FIELD': 'yonghuid',
|
'USER_ID_FIELD': 'UserUID',
|
||||||
'USER_ID_CLAIM': 'yonghuid',
|
'USER_ID_CLAIM': 'UserUID',
|
||||||
'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule',
|
'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule',
|
||||||
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
|
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
|
||||||
'TOKEN_TYPE_CLAIM': 'token_type',
|
'TOKEN_TYPE_CLAIM': 'token_type',
|
||||||
|
|||||||
@@ -581,7 +581,7 @@ class AddAdminUserView(APIView):
|
|||||||
# 生成唯一的 yonghuid(7位数字)
|
# 生成唯一的 yonghuid(7位数字)
|
||||||
while True:
|
while True:
|
||||||
yonghuid = str(random.randint(1000000, 9999999))
|
yonghuid = str(random.randint(1000000, 9999999))
|
||||||
if not User.query.filter(yonghuid=yonghuid).exists():
|
if not User.query.filter(UserUID=yonghuid).exists():
|
||||||
break
|
break
|
||||||
|
|
||||||
# 生成唯一的 openid(格式:admin_{时间戳}_{随机6位})
|
# 生成唯一的 openid(格式:admin_{时间戳}_{随机6位})
|
||||||
@@ -1064,7 +1064,7 @@ class KefuUpdateDashouView(APIView):
|
|||||||
|
|
||||||
# 3. 查询打手
|
# 3. 查询打手
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '打手不存在'})
|
return Response({'code': 404, 'msg': '打手不存在'})
|
||||||
@@ -1496,7 +1496,7 @@ class KefuGetShangjiaDetailView(APIView):
|
|||||||
|
|
||||||
# 查询商家
|
# 查询商家
|
||||||
try:
|
try:
|
||||||
shangjia = UserShangjia.query.select_related('user').get(user__yonghuid=yonghuid)
|
shangjia = UserShangjia.query.select_related('user').get(user__UserUID=yonghuid)
|
||||||
except UserShangjia.DoesNotExist:
|
except UserShangjia.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '商家不存在'})
|
return Response({'code': 404, 'msg': '商家不存在'})
|
||||||
|
|
||||||
@@ -1566,7 +1566,7 @@ class KefuUpdateShangjiaView(APIView):
|
|||||||
# 使用事务,select_for_update 必须在事务内
|
# 使用事务,select_for_update 必须在事务内
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
try:
|
try:
|
||||||
shangjia = UserShangjia.objects.select_for_update().get(user__yonghuid=yonghuid)
|
shangjia = UserShangjia.objects.select_for_update().get(user__UserUID=yonghuid)
|
||||||
except UserShangjia.DoesNotExist:
|
except UserShangjia.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '商家不存在'})
|
return Response({'code': 404, 'msg': '商家不存在'})
|
||||||
|
|
||||||
@@ -2968,7 +2968,7 @@ class GetGuanliDetailView(APIView):
|
|||||||
|
|
||||||
# 查询用户主表和管事扩展表
|
# 查询用户主表和管事扩展表
|
||||||
try:
|
try:
|
||||||
user = User.query.select_related('guanshi_profile', 'boss_profile').get(yonghuid=yonghuid)
|
user = User.query.select_related('guanshi_profile', 'boss_profile').get(UserUID=yonghuid)
|
||||||
guanshi = user.guanshi_profile
|
guanshi = user.guanshi_profile
|
||||||
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@@ -3015,7 +3015,7 @@ class GetGuanliDetailView(APIView):
|
|||||||
|
|
||||||
# 获取多次分红配置(按次数和会员组织)
|
# 获取多次分红配置(按次数和会员组织)
|
||||||
# 查询该管事的所有多次分红记录
|
# 查询该管事的所有多次分红记录
|
||||||
duoci_records = DuociFenhong.query.filter(yonghuid=yonghuid).order_by('cishu')
|
duoci_records = DuociFenhong.query.filter(UserUID=yonghuid).order_by('cishu')
|
||||||
custom_first = {} # 首次分红定制(cishu=1)
|
custom_first = {} # 首次分红定制(cishu=1)
|
||||||
extra_map = {} # 其他次数 { cishu: { huiyuan_id: { guanshi_fenhong, jieshao, jiage } } }
|
extra_map = {} # 其他次数 { cishu: { huiyuan_id: { guanshi_fenhong, jieshao, jiage } } }
|
||||||
|
|
||||||
@@ -3089,7 +3089,7 @@ class UpdateGuanliView(APIView):
|
|||||||
|
|
||||||
# 查询管事对象(不在事务外加锁,事务内加锁)
|
# 查询管事对象(不在事务外加锁,事务内加锁)
|
||||||
try:
|
try:
|
||||||
user = User.query.get(yonghuid=yonghuid)
|
user = User.query.get(UserUID=yonghuid)
|
||||||
guanshi = user.guanshi_profile
|
guanshi = user.guanshi_profile
|
||||||
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@@ -3100,7 +3100,7 @@ class UpdateGuanliView(APIView):
|
|||||||
# 开始事务,内部使用 select_for_update
|
# 开始事务,内部使用 select_for_update
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
# 重新获取加锁对象
|
# 重新获取加锁对象
|
||||||
user = User.objects.select_for_update().get(yonghuid=yonghuid)
|
user = User.objects.select_for_update().get(UserUID=yonghuid)
|
||||||
guanshi = user.guanshi_profile
|
guanshi = user.guanshi_profile
|
||||||
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
||||||
|
|
||||||
@@ -3196,7 +3196,7 @@ class UpdateGuanliView(APIView):
|
|||||||
# 4.2 首次定制分红(cishu=1)
|
# 4.2 首次定制分红(cishu=1)
|
||||||
if custom_first is not None and isinstance(custom_first, dict):
|
if custom_first is not None and isinstance(custom_first, dict):
|
||||||
# 获取当前所有首次定制记录
|
# 获取当前所有首次定制记录
|
||||||
existing_first = DuociFenhong.query.filter(yonghuid=yonghuid, cishu=1)
|
existing_first = DuociFenhong.query.filter(UserUID=yonghuid, cishu=1)
|
||||||
# 前端传来的定制字典 {会员ID: 金额}
|
# 前端传来的定制字典 {会员ID: 金额}
|
||||||
for huiyuan_id, amount in custom_first.items():
|
for huiyuan_id, amount in custom_first.items():
|
||||||
try:
|
try:
|
||||||
@@ -3205,7 +3205,7 @@ class UpdateGuanliView(APIView):
|
|||||||
continue
|
continue
|
||||||
if amount <= 0:
|
if amount <= 0:
|
||||||
# 金额为0或负数表示删除定制
|
# 金额为0或负数表示删除定制
|
||||||
DuociFenhong.query.filter(yonghuid=yonghuid, huiyuan=huiyuan_id, cishu=1).delete()
|
DuociFenhong.query.filter(UserUID=yonghuid, huiyuan=huiyuan_id, cishu=1).delete()
|
||||||
else:
|
else:
|
||||||
DuociFenhong.query.update_or_create(
|
DuociFenhong.query.update_or_create(
|
||||||
yonghuid=yonghuid,
|
yonghuid=yonghuid,
|
||||||
@@ -3256,7 +3256,7 @@ class UpdateGuanliView(APIView):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
# 删除不在 keep_set 中的额外次数记录
|
# 删除不在 keep_set 中的额外次数记录
|
||||||
existing_extra = DuociFenhong.query.filter(yonghuid=yonghuid, cishu__gte=2)
|
existing_extra = DuociFenhong.query.filter(UserUID=yonghuid, cishu__gte=2)
|
||||||
for record in existing_extra:
|
for record in existing_extra:
|
||||||
if (record.cishu, record.huiyuan) not in keep_set:
|
if (record.cishu, record.huiyuan) not in keep_set:
|
||||||
record.delete()
|
record.delete()
|
||||||
@@ -3660,7 +3660,7 @@ class GetZuzhangDetailView(APIView):
|
|||||||
|
|
||||||
# 查询组长主表、扩展表、老板扩展表(昵称)
|
# 查询组长主表、扩展表、老板扩展表(昵称)
|
||||||
try:
|
try:
|
||||||
user = User.query.select_related('zuzhang_profile', 'boss_profile').get(yonghuid=yonghuid)
|
user = User.query.select_related('zuzhang_profile', 'boss_profile').get(UserUID=yonghuid)
|
||||||
zuzhang = user.zuzhang_profile
|
zuzhang = user.zuzhang_profile
|
||||||
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@@ -3706,7 +3706,7 @@ class GetZuzhangDetailView(APIView):
|
|||||||
m['zuzhangfc'] = str(m['zuzhangfc'])
|
m['zuzhangfc'] = str(m['zuzhangfc'])
|
||||||
|
|
||||||
# 获取多次分红配置(按次数和会员组织)
|
# 获取多次分红配置(按次数和会员组织)
|
||||||
duoci_records = DuociFenhong.query.filter(yonghuid=yonghuid).order_by('cishu')
|
duoci_records = DuociFenhong.query.filter(UserUID=yonghuid).order_by('cishu')
|
||||||
custom_first = {} # 首次分红定制(cishu=1)
|
custom_first = {} # 首次分红定制(cishu=1)
|
||||||
extra_map = {} # 其他次数 { cishu: { huiyuan_id: { zuzhang_fenhong, jieshao, jiage } } }
|
extra_map = {} # 其他次数 { cishu: { huiyuan_id: { zuzhang_fenhong, jieshao, jiage } } }
|
||||||
|
|
||||||
@@ -3783,7 +3783,7 @@ class UpdateZuzhangView(APIView):
|
|||||||
|
|
||||||
# 查询组长对象
|
# 查询组长对象
|
||||||
try:
|
try:
|
||||||
user = User.query.get(yonghuid=yonghuid)
|
user = User.query.get(UserUID=yonghuid)
|
||||||
zuzhang = user.zuzhang_profile
|
zuzhang = user.zuzhang_profile
|
||||||
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
boss = user.boss_profile if hasattr(user, 'boss_profile') else None
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@@ -3879,7 +3879,7 @@ class UpdateZuzhangView(APIView):
|
|||||||
|
|
||||||
# 4.2 首次定制分红(cishu=1)
|
# 4.2 首次定制分红(cishu=1)
|
||||||
if custom_first is not None and isinstance(custom_first, dict):
|
if custom_first is not None and isinstance(custom_first, dict):
|
||||||
existing_first = DuociFenhong.query.filter(yonghuid=yonghuid, cishu=1)
|
existing_first = DuociFenhong.query.filter(UserUID=yonghuid, cishu=1)
|
||||||
for huiyuan_id, amount in custom_first.items():
|
for huiyuan_id, amount in custom_first.items():
|
||||||
try:
|
try:
|
||||||
amount = Decimal(str(amount))
|
amount = Decimal(str(amount))
|
||||||
@@ -3887,7 +3887,7 @@ class UpdateZuzhangView(APIView):
|
|||||||
continue
|
continue
|
||||||
if amount <= 0:
|
if amount <= 0:
|
||||||
# 删除定制(恢复默认)
|
# 删除定制(恢复默认)
|
||||||
DuociFenhong.query.filter(yonghuid=yonghuid, huiyuan=huiyuan_id, cishu=1).delete()
|
DuociFenhong.query.filter(UserUID=yonghuid, huiyuan=huiyuan_id, cishu=1).delete()
|
||||||
else:
|
else:
|
||||||
DuociFenhong.query.update_or_create(
|
DuociFenhong.query.update_or_create(
|
||||||
yonghuid=yonghuid,
|
yonghuid=yonghuid,
|
||||||
@@ -3936,7 +3936,7 @@ class UpdateZuzhangView(APIView):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
# 删除不在 keep_set 中的额外次数记录
|
# 删除不在 keep_set 中的额外次数记录
|
||||||
existing_extra = DuociFenhong.query.filter(yonghuid=yonghuid, cishu__gte=2)
|
existing_extra = DuociFenhong.query.filter(UserUID=yonghuid, cishu__gte=2)
|
||||||
for record in existing_extra:
|
for record in existing_extra:
|
||||||
if (record.cishu, record.huiyuan) not in keep_set:
|
if (record.cishu, record.huiyuan) not in keep_set:
|
||||||
record.delete()
|
record.delete()
|
||||||
@@ -5026,7 +5026,7 @@ class ShopModifyView(APIView):
|
|||||||
return Response({'code': 400, 'msg': '必填字段缺失(用户ID、账号、密码、店铺名称)'})
|
return Response({'code': 400, 'msg': '必填字段缺失(用户ID、账号、密码、店铺名称)'})
|
||||||
|
|
||||||
# 检查用户是否存在
|
# 检查用户是否存在
|
||||||
if not User.query.filter(yonghuid=yonghu_id).exists():
|
if not User.query.filter(UserUID=yonghu_id).exists():
|
||||||
return Response({'code': 404, 'msg': '用户不存在'})
|
return Response({'code': 404, 'msg': '用户不存在'})
|
||||||
|
|
||||||
# 检查凭证是否已存在
|
# 检查凭证是否已存在
|
||||||
@@ -5962,7 +5962,7 @@ class FaKuanChuangJianView(APIView):
|
|||||||
|
|
||||||
# 验证用户是否存在对应的扩展表
|
# 验证用户是否存在对应的扩展表
|
||||||
try:
|
try:
|
||||||
user = User.query.get(yonghuid=beichufa_id)
|
user = User.query.get(UserUID=beichufa_id)
|
||||||
profile_attr = SHENFEN_PROFILE_MAP.get(shenfen)
|
profile_attr = SHENFEN_PROFILE_MAP.get(shenfen)
|
||||||
if not profile_attr or not hasattr(user, profile_attr):
|
if not profile_attr or not hasattr(user, profile_attr):
|
||||||
return Response({'code': 400, 'msg': '该用户不是所选身份'})
|
return Response({'code': 400, 'msg': '该用户不是所选身份'})
|
||||||
@@ -6162,7 +6162,7 @@ class PunishDashouView(APIView):
|
|||||||
|
|
||||||
# 查询打手
|
# 查询打手
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou = dashou_user.dashou_profile
|
dashou = dashou_user.dashou_profile
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '打手用户不存在'})
|
return Response({'code': 404, 'msg': '打手用户不存在'})
|
||||||
@@ -6484,7 +6484,7 @@ class CaiwuView(APIView):
|
|||||||
amount_sum = Czjilu.query.filter(
|
amount_sum = Czjilu.query.filter(
|
||||||
create_time__gte=today_start,
|
create_time__gte=today_start,
|
||||||
create_time__lt=today_end,
|
create_time__lt=today_end,
|
||||||
yonghuid__in=new_huiyuan_user_ids,
|
UserUID__in=new_huiyuan_user_ids,
|
||||||
leixing=1,
|
leixing=1,
|
||||||
zhuangtai=3
|
zhuangtai=3
|
||||||
).aggregate(total=Sum('jine'))
|
).aggregate(total=Sum('jine'))
|
||||||
@@ -7946,7 +7946,7 @@ class KhgglView(APIView):
|
|||||||
queryset = UserShenheguan.query.select_related('user__dashou_profile')
|
queryset = UserShenheguan.query.select_related('user__dashou_profile')
|
||||||
|
|
||||||
if filter_yonghuid:
|
if filter_yonghuid:
|
||||||
queryset = queryset.filter(user__yonghuid=filter_yonghuid)
|
queryset = queryset.filter(user__UserUID=filter_yonghuid)
|
||||||
if filter_zhuangtai is not None:
|
if filter_zhuangtai is not None:
|
||||||
queryset = queryset.filter(zhuangtai=filter_zhuangtai)
|
queryset = queryset.filter(zhuangtai=filter_zhuangtai)
|
||||||
if filter_shenhe_zhuangtai is not None:
|
if filter_shenhe_zhuangtai is not None:
|
||||||
@@ -7960,7 +7960,7 @@ class KhgglView(APIView):
|
|||||||
shenheguan_ids = KaoheguanBankuai.query.filter(
|
shenheguan_ids = KaoheguanBankuai.query.filter(
|
||||||
bankuai_id__in=bankuai_ids
|
bankuai_id__in=bankuai_ids
|
||||||
).values_list('kaoheguan_id', flat=True)
|
).values_list('kaoheguan_id', flat=True)
|
||||||
queryset = queryset.filter(user__yonghuid__in=shenheguan_ids)
|
queryset = queryset.filter(user__UserUID__in=shenheguan_ids)
|
||||||
|
|
||||||
total = queryset.count()
|
total = queryset.count()
|
||||||
start = (page - 1) * page_size
|
start = (page - 1) * page_size
|
||||||
@@ -8070,7 +8070,7 @@ class ShgxgsjView(APIView):
|
|||||||
return Response({'code': 1, 'msg': '缺少用户ID'}, status=400)
|
return Response({'code': 1, 'msg': '缺少用户ID'}, status=400)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shenheguan = UserShenheguan.query.select_related('user').get(user__yonghuid=yonghuid)
|
shenheguan = UserShenheguan.query.select_related('user').get(user__UserUID=yonghuid)
|
||||||
except UserShenheguan.DoesNotExist:
|
except UserShenheguan.DoesNotExist:
|
||||||
return Response({'code': 1, 'msg': '审核官不存在'}, status=404)
|
return Response({'code': 1, 'msg': '审核官不存在'}, status=404)
|
||||||
|
|
||||||
@@ -8189,7 +8189,7 @@ class ZxkfghdsView(APIView):
|
|||||||
shangjia_ext = old_order.shangjia_kuozhan
|
shangjia_ext = old_order.shangjia_kuozhan
|
||||||
shangjia_id = shangjia_ext.shangjia_id
|
shangjia_id = shangjia_ext.shangjia_id
|
||||||
# 获取商家昵称用于新订单扩展表
|
# 获取商家昵称用于新订单扩展表
|
||||||
shangjia_user = User.query.get(yonghuid=shangjia_id)
|
shangjia_user = User.query.get(UserUID=shangjia_id)
|
||||||
shangjia_nicheng = shangjia_user.shop_profile.nicheng or f"商家{shangjia_id}"
|
shangjia_nicheng = shangjia_user.shop_profile.nicheng or f"商家{shangjia_id}"
|
||||||
except (ObjectDoesNotExist, UserShangjia.DoesNotExist):
|
except (ObjectDoesNotExist, UserShangjia.DoesNotExist):
|
||||||
logger.error(f"商家信息缺失,订单: {dingdan_id}")
|
logger.error(f"商家信息缺失,订单: {dingdan_id}")
|
||||||
@@ -8206,7 +8206,7 @@ class ZxkfghdsView(APIView):
|
|||||||
dashou_id = old_order.jiedan_dashou_id
|
dashou_id = old_order.jiedan_dashou_id
|
||||||
if dashou_id:
|
if dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.tuikuanliang += 1 # 退款次数+1
|
dashou_profile.tuikuanliang += 1 # 退款次数+1
|
||||||
dashou_profile.zhuangtai = 1 # 设为空闲
|
dashou_profile.zhuangtai = 1 # 设为空闲
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 4.2.27 on 2026-06-17 16:31
|
# Generated by Django 4.2.27 on 2026-06-17 21:18
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|||||||
@@ -2191,7 +2191,7 @@ class KehuGetDingdanLianjieView(APIView):
|
|||||||
# 获取商家昵称
|
# 获取商家昵称
|
||||||
shangjia_nicheng = ''
|
shangjia_nicheng = ''
|
||||||
try:
|
try:
|
||||||
user_main = User.query.get(yonghuid=lianjie_obj.yonghu_id)
|
user_main = User.query.get(UserUID=lianjie_obj.yonghu_id)
|
||||||
shangjia_obj = user_main.shop_profile
|
shangjia_obj = user_main.shop_profile
|
||||||
shangjia_nicheng = shangjia_obj.nicheng
|
shangjia_nicheng = shangjia_obj.nicheng
|
||||||
except (User.DoesNotExist, UserShangjia.DoesNotExist):
|
except (User.DoesNotExist, UserShangjia.DoesNotExist):
|
||||||
@@ -2473,7 +2473,7 @@ class KehuTianxieDingdanView(APIView):
|
|||||||
# 验证打手是否存在且有效
|
# 验证打手是否存在且有效
|
||||||
try:
|
try:
|
||||||
# 先查询用户主表
|
# 先查询用户主表
|
||||||
dashou_user = User.query.get(yonghuid=zhiding_dashou)
|
dashou_user = User.query.get(UserUID=zhiding_dashou)
|
||||||
logger.info(f"找到打手用户 - 用户ID: {zhiding_dashou}")
|
logger.info(f"找到打手用户 - 用户ID: {zhiding_dashou}")
|
||||||
|
|
||||||
# 通过反向关系获取打手扩展信息
|
# 通过反向关系获取打手扩展信息
|
||||||
@@ -2571,7 +2571,7 @@ class KehuTianxieDingdanView(APIView):
|
|||||||
|
|
||||||
# 获取商家信息用于返回
|
# 获取商家信息用于返回
|
||||||
try:
|
try:
|
||||||
user_main = User.query.get(yonghuid=lianjie_obj.yonghu_id)
|
user_main = User.query.get(UserUID=lianjie_obj.yonghu_id)
|
||||||
shangjia_obj = user_main.shop_profile
|
shangjia_obj = user_main.shop_profile
|
||||||
shangjia_mingcheng = shangjia_obj.nicheng
|
shangjia_mingcheng = shangjia_obj.nicheng
|
||||||
except:
|
except:
|
||||||
|
|||||||
67
fix_fk.py
Normal file
67
fix_fk.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""修复 yonghu_dianpu_bangding 表的 FK 约束"""
|
||||||
|
import MySQLdb
|
||||||
|
from app_secrets import DATABASE_HOST, DATABASE_PORT, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME
|
||||||
|
|
||||||
|
conn = MySQLdb.connect(
|
||||||
|
host=DATABASE_HOST, port=int(DATABASE_PORT),
|
||||||
|
user=DATABASE_USER, password=DATABASE_PASSWORD,
|
||||||
|
database=DATABASE_NAME, charset='utf8mb4'
|
||||||
|
)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# 1. 查看所有引用 User 表的 FK 约束
|
||||||
|
cursor.execute("""
|
||||||
|
SELECT CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
|
||||||
|
FROM information_schema.KEY_COLUMN_USAGE
|
||||||
|
WHERE TABLE_SCHEMA = %s AND REFERENCED_TABLE_NAME = 'User'
|
||||||
|
""", [DATABASE_NAME])
|
||||||
|
|
||||||
|
fks = cursor.fetchall()
|
||||||
|
print("引用 User 表的 FK 约束:")
|
||||||
|
for fk in fks:
|
||||||
|
print(f" {fk[0]}: {fk[1]}.{fk[2]} -> {fk[3]}.{fk[4]}")
|
||||||
|
|
||||||
|
# 2. 删除所有引用 User.UserUID 的 FK 约束(类型不兼容的)
|
||||||
|
for fk in fks:
|
||||||
|
if fk[4] == 'UserUID': # 引用了 UserUID (varchar) 而不是 UserUUID (binary)
|
||||||
|
constraint_name = fk[0]
|
||||||
|
table_name = fk[1]
|
||||||
|
print(f"\n删除不兼容 FK: {constraint_name} on {table_name}")
|
||||||
|
try:
|
||||||
|
cursor.execute(f"ALTER TABLE `{table_name}` DROP FOREIGN KEY `{constraint_name}`")
|
||||||
|
conn.commit()
|
||||||
|
print(f" 已删除 {constraint_name}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f" 删除失败: {e}")
|
||||||
|
|
||||||
|
# 3. 修改 yonghu_dianpu_bangding.UserUUID 列类型
|
||||||
|
print("\n修改 yonghu_dianpu_bangding.UserUUID 列类型...")
|
||||||
|
try:
|
||||||
|
cursor.execute("ALTER TABLE yonghu_dianpu_bangding MODIFY COLUMN UserUUID binary(16) NOT NULL")
|
||||||
|
conn.commit()
|
||||||
|
print(" 修改成功")
|
||||||
|
except Exception as e:
|
||||||
|
print(f" 修改失败: {e}")
|
||||||
|
|
||||||
|
# 4. 重新添加 FK 约束
|
||||||
|
print("\n重新添加 FK 约束...")
|
||||||
|
try:
|
||||||
|
cursor.execute("""
|
||||||
|
ALTER TABLE yonghu_dianpu_bangding
|
||||||
|
ADD CONSTRAINT yonghu_dianpu_bangding_UserUUID_fk
|
||||||
|
FOREIGN KEY (UserUUID) REFERENCES User(UserUUID)
|
||||||
|
""")
|
||||||
|
conn.commit()
|
||||||
|
print(" FK 约束添加成功")
|
||||||
|
except Exception as e:
|
||||||
|
print(f" FK 约束添加失败: {e}")
|
||||||
|
|
||||||
|
# 5. 验证
|
||||||
|
print("\n验证表结构:")
|
||||||
|
cursor.execute("DESCRIBE yonghu_dianpu_bangding")
|
||||||
|
for row in cursor.fetchall():
|
||||||
|
print(f" {row}")
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
print("\n完成!")
|
||||||
@@ -388,6 +388,15 @@ class User(QModel):
|
|||||||
def id(self):
|
def id(self):
|
||||||
return self.ID
|
return self.ID
|
||||||
|
|
||||||
|
@property
|
||||||
|
def shoujihao_renzheng(self):
|
||||||
|
"""兼容旧代码 — 手机号是否已认证"""
|
||||||
|
return self.PhoneVerified
|
||||||
|
|
||||||
|
@shoujihao_renzheng.setter
|
||||||
|
def shoujihao_renzheng(self, value):
|
||||||
|
self.PhoneVerified = bool(value)
|
||||||
|
|
||||||
def set_password(self, raw_password):
|
def set_password(self, raw_password):
|
||||||
self.SetPassword(raw_password)
|
self.SetPassword(raw_password)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 4.2.27 on 2026-06-17 16:31
|
# Generated by Django 4.2.27 on 2026-06-17 21:18
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ def process_expired_order(self, dingdan_id):
|
|||||||
if dashou_id:
|
if dashou_id:
|
||||||
try:
|
try:
|
||||||
# 查询打手用户主表
|
# 查询打手用户主表
|
||||||
dashou_user = User.query.filter(yonghuid=dashou_id).first()
|
dashou_user = User.query.filter(UserUID=dashou_id).first()
|
||||||
if dashou_user:
|
if dashou_user:
|
||||||
# 获取打手扩展表
|
# 获取打手扩展表
|
||||||
dashou_profile = getattr(dashou_user, 'dashou_profile', None)
|
dashou_profile = getattr(dashou_user, 'dashou_profile', None)
|
||||||
@@ -94,7 +94,7 @@ def process_expired_order(self, dingdan_id):
|
|||||||
shangjia_id = shangjia_kuozhan.shangjia_id
|
shangjia_id = shangjia_kuozhan.shangjia_id
|
||||||
if shangjia_id:
|
if shangjia_id:
|
||||||
# 查询商家用户
|
# 查询商家用户
|
||||||
shangjia_user = User.query.filter(yonghuid=shangjia_id).first()
|
shangjia_user = User.query.filter(UserUID=shangjia_id).first()
|
||||||
if shangjia_user:
|
if shangjia_user:
|
||||||
shangjia_profile = getattr(shangjia_user, 'shop_profile', None)
|
shangjia_profile = getattr(shangjia_user, 'shop_profile', None)
|
||||||
if shangjia_profile:
|
if shangjia_profile:
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ def settle_shangjia_order_guanshi_fenhong(order, dashou_id):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dashou = UserDashou.objects.select_related('user').get(user__yonghuid=dashou_id)
|
dashou = UserDashou.objects.select_related('user').get(user__UserUID=dashou_id)
|
||||||
except UserDashou.DoesNotExist:
|
except UserDashou.DoesNotExist:
|
||||||
logger.info(f"商家订单管事分红跳过: 打手{dashou_id}不存在")
|
logger.info(f"商家订单管事分红跳过: 打手{dashou_id}不存在")
|
||||||
return
|
return
|
||||||
@@ -166,7 +166,7 @@ def settle_shangjia_order_guanshi_fenhong(order, dashou_id):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
guanshi = UserGuanshi.objects.select_for_update().get(user__yonghuid=guanshi_id)
|
guanshi = UserGuanshi.objects.select_for_update().get(user__UserUID=guanshi_id)
|
||||||
UserGuanshi.objects.filter(id=guanshi.id).update(
|
UserGuanshi.objects.filter(id=guanshi.id).update(
|
||||||
yue=F('yue') + guanshi_fencheng,
|
yue=F('yue') + guanshi_fencheng,
|
||||||
chongzhifenrun=F('chongzhifenrun') + guanshi_fencheng,
|
chongzhifenrun=F('chongzhifenrun') + guanshi_fencheng,
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ class WechatPayNotifyView(APIView):
|
|||||||
if hasattr(dingdan, 'pingtai_kuozhan'):
|
if hasattr(dingdan, 'pingtai_kuozhan'):
|
||||||
laoban_id = dingdan.pingtai_kuozhan.laoban_id
|
laoban_id = dingdan.pingtai_kuozhan.laoban_id
|
||||||
if laoban_id:
|
if laoban_id:
|
||||||
user_main = User.query.filter(yonghuid=laoban_id).first()
|
user_main = User.query.filter(UserUID=laoban_id).first()
|
||||||
if user_main and hasattr(user_main, 'boss_profile'):
|
if user_main and hasattr(user_main, 'boss_profile'):
|
||||||
boss = user_main.boss_profile
|
boss = user_main.boss_profile
|
||||||
boss.zonge = (boss.zonge or 0) + (dingdan.jine or 0)
|
boss.zonge = (boss.zonge or 0) + (dingdan.jine or 0)
|
||||||
@@ -525,7 +525,7 @@ class PaymentVerifyView(APIView):
|
|||||||
# 更新老板扩展表
|
# 更新老板扩展表
|
||||||
laoban_id = dingdan.pingtai_kuozhan.laoban_id if hasattr(dingdan, 'pingtai_kuozhan') else None
|
laoban_id = dingdan.pingtai_kuozhan.laoban_id if hasattr(dingdan, 'pingtai_kuozhan') else None
|
||||||
if laoban_id:
|
if laoban_id:
|
||||||
user_main = User.query.filter(yonghuid=laoban_id).first()
|
user_main = User.query.filter(UserUID=laoban_id).first()
|
||||||
if user_main and hasattr(user_main, 'boss_profile'):
|
if user_main and hasattr(user_main, 'boss_profile'):
|
||||||
boss = user_main.boss_profile
|
boss = user_main.boss_profile
|
||||||
boss.zonge = (boss.zonge or 0) + (dingdan.jine or 0)
|
boss.zonge = (boss.zonge or 0) + (dingdan.jine or 0)
|
||||||
@@ -712,7 +712,7 @@ class CreateOrderView(APIView):
|
|||||||
if zhiding:
|
if zhiding:
|
||||||
# 查询主表中是否存在该打手
|
# 查询主表中是否存在该打手
|
||||||
zhiding_user = User.query.filter(
|
zhiding_user = User.query.filter(
|
||||||
yonghuid=zhiding,
|
UserUID=zhiding,
|
||||||
#user_type='dashou'
|
#user_type='dashou'
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
@@ -1349,7 +1349,7 @@ class JiedanView(APIView):
|
|||||||
# 7. 更新打手扩展表(如果有打手ID和分成)
|
# 7. 更新打手扩展表(如果有打手ID和分成)
|
||||||
if jiedan_dashou_id and dashou_fencheng > 0:
|
if jiedan_dashou_id and dashou_fencheng > 0:
|
||||||
# 查询打手用户
|
# 查询打手用户
|
||||||
dashou_user = User.query.filter(yonghuid=jiedan_dashou_id).first()
|
dashou_user = User.query.filter(UserUID=jiedan_dashou_id).first()
|
||||||
|
|
||||||
if dashou_user:
|
if dashou_user:
|
||||||
# 查询打手扩展表
|
# 查询打手扩展表
|
||||||
@@ -1512,7 +1512,7 @@ class DingdanXiangqingView2(APIView):
|
|||||||
jiedan_time = ''
|
jiedan_time = ''
|
||||||
tijiao_time = ''
|
tijiao_time = ''
|
||||||
if jiedan_dashou_id:
|
if jiedan_dashou_id:
|
||||||
dashou_user = User.query.filter(yonghuid=jiedan_dashou_id).first()
|
dashou_user = User.query.filter(UserUID=jiedan_dashou_id).first()
|
||||||
if dashou_user:
|
if dashou_user:
|
||||||
dashou_touxiang = dashou_user.avatar or ''
|
dashou_touxiang = dashou_user.avatar or ''
|
||||||
try:
|
try:
|
||||||
@@ -1661,7 +1661,7 @@ class JiedanView2(APIView):
|
|||||||
|
|
||||||
# 9. 更新打手收益与状态
|
# 9. 更新打手收益与状态
|
||||||
if jiedan_dashou_id and dashou_fencheng > 0:
|
if jiedan_dashou_id and dashou_fencheng > 0:
|
||||||
dashou_user = User.query.filter(yonghuid=jiedan_dashou_id).first()
|
dashou_user = User.query.filter(UserUID=jiedan_dashou_id).first()
|
||||||
if dashou_user:
|
if dashou_user:
|
||||||
try:
|
try:
|
||||||
dashou_ext = dashou_user.dashou_profile
|
dashou_ext = dashou_user.dashou_profile
|
||||||
@@ -1916,7 +1916,7 @@ class ShangjiaPaifaView(APIView):
|
|||||||
zhiding_dashou = None
|
zhiding_dashou = None
|
||||||
if zhiding_uid:
|
if zhiding_uid:
|
||||||
try:
|
try:
|
||||||
zhiding_user = User.query.get(yonghuid=zhiding_uid)
|
zhiding_user = User.query.get(UserUID=zhiding_uid)
|
||||||
zhiding_dashou = zhiding_user.dashou_profile
|
zhiding_dashou = zhiding_user.dashou_profile
|
||||||
if zhiding_dashou.zhanghaozhuangtai != 1:
|
if zhiding_dashou.zhanghaozhuangtai != 1:
|
||||||
return Response({'code': 400, 'msg': '指定打手状态异常'})
|
return Response({'code': 400, 'msg': '指定打手状态异常'})
|
||||||
@@ -2223,7 +2223,7 @@ class ShangjiaDingdanXiangqingView(APIView):
|
|||||||
dashou_avatar = ''
|
dashou_avatar = ''
|
||||||
if dashou_yonghuid:
|
if dashou_yonghuid:
|
||||||
dashou_user = User.query.filter(
|
dashou_user = User.query.filter(
|
||||||
yonghuid=dashou_yonghuid
|
UserUID=dashou_yonghuid
|
||||||
).select_related('dashou_profile').first()
|
).select_related('dashou_profile').first()
|
||||||
if dashou_user:
|
if dashou_user:
|
||||||
dashou_avatar = dashou_user.avatar or ''
|
dashou_avatar = dashou_user.avatar or ''
|
||||||
@@ -2426,7 +2426,7 @@ class ShangjiaJiesuanView(APIView):
|
|||||||
# ========== 本地订单正常结算给打手 ==========
|
# ========== 本地订单正常结算给打手 ==========
|
||||||
# 查询打手信息
|
# 查询打手信息
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou = dashou_user.dashou_profile
|
dashou = dashou_user.dashou_profile
|
||||||
except (User.DoesNotExist, UserDashou.DoesNotExist):
|
except (User.DoesNotExist, UserDashou.DoesNotExist):
|
||||||
return Response({
|
return Response({
|
||||||
@@ -2769,7 +2769,7 @@ class ShangjiaTuikuanShenqingView(APIView):
|
|||||||
if dingdan.jiedan_dashou_id:
|
if dingdan.jiedan_dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_main = User.query.filter(
|
dashou_main = User.query.filter(
|
||||||
yonghuid=dingdan.jiedan_dashou_id
|
UserUID=dingdan.jiedan_dashou_id
|
||||||
).first()
|
).first()
|
||||||
if dashou_main and hasattr(dashou_main, 'dashou_profile'):
|
if dashou_main and hasattr(dashou_main, 'dashou_profile'):
|
||||||
dashou_profile = dashou_main.dashou_profile
|
dashou_profile = dashou_main.dashou_profile
|
||||||
@@ -2851,7 +2851,7 @@ class ShangjiaChufaShenqingView(APIView):
|
|||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
# 验证打手身份
|
# 验证打手身份
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou = dashou_user.dashou_profile
|
dashou = dashou_user.dashou_profile
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -3030,7 +3030,7 @@ class DashouDingdanHuoquView(APIView):
|
|||||||
zhiding_info = {}
|
zhiding_info = {}
|
||||||
if zhiding_ids:
|
if zhiding_ids:
|
||||||
dashou_query = User.query.filter(
|
dashou_query = User.query.filter(
|
||||||
yonghuid__in=zhiding_ids
|
UserUID__in=zhiding_ids
|
||||||
).select_related('dashou_profile').annotate(
|
).select_related('dashou_profile').annotate(
|
||||||
nicheng=F('dashou_profile__nicheng')
|
nicheng=F('dashou_profile__nicheng')
|
||||||
).values('yonghuid', 'avatar', 'nicheng')
|
).values('yonghuid', 'avatar', 'nicheng')
|
||||||
@@ -3082,7 +3082,7 @@ class DashouDingdanHuoquView(APIView):
|
|||||||
# 将 yonghuid 字符串转换为 User 的主键 id
|
# 将 yonghuid 字符串转换为 User 的主键 id
|
||||||
user_id_map = {}
|
user_id_map = {}
|
||||||
if yonghuid_set:
|
if yonghuid_set:
|
||||||
users = User.query.filter(yonghuid__in=yonghuid_set).values('id', 'yonghuid')
|
users = User.query.filter(UserUID__in=yonghuid_set).values('id', 'yonghuid')
|
||||||
for u in users:
|
for u in users:
|
||||||
user_id_map[u['yonghuid']] = u['id']
|
user_id_map[u['yonghuid']] = u['id']
|
||||||
|
|
||||||
@@ -3347,7 +3347,7 @@ def send_group_message(
|
|||||||
def check_user_permission(identity_type, uid, order):
|
def check_user_permission(identity_type, uid, order):
|
||||||
"""验证用户身份、账号状态、以及是否属于该订单"""
|
"""验证用户身份、账号状态、以及是否属于该订单"""
|
||||||
try:
|
try:
|
||||||
user = User.query.get(yonghuid=uid)
|
user = User.query.get(UserUID=uid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return False, '用户不存在'
|
return False, '用户不存在'
|
||||||
|
|
||||||
@@ -4674,7 +4674,7 @@ class AdGengHuanDaShou(APIView):
|
|||||||
# 8. 验证新打手ID是否存在,并且是打手身份
|
# 8. 验证新打手ID是否存在,并且是打手身份
|
||||||
try:
|
try:
|
||||||
new_dashou_user = User.query.get(
|
new_dashou_user = User.query.get(
|
||||||
yonghuid=new_dashou_id,
|
UserUID=new_dashou_id,
|
||||||
#user_type='dashou'
|
#user_type='dashou'
|
||||||
)
|
)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@@ -4769,7 +4769,7 @@ class AdGengHuanDaShou(APIView):
|
|||||||
try:
|
try:
|
||||||
# 查询原打手主表
|
# 查询原打手主表
|
||||||
old_dashou_user = User.query.get(
|
old_dashou_user = User.query.get(
|
||||||
yonghuid=old_dashou_id,
|
UserUID=old_dashou_id,
|
||||||
#user_type='dashou'
|
#user_type='dashou'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -4913,7 +4913,7 @@ class AdQiangZhiJieDan(APIView):
|
|||||||
try:
|
try:
|
||||||
# 查询打手用户主表
|
# 查询打手用户主表
|
||||||
dashou_user = User.query.get(
|
dashou_user = User.query.get(
|
||||||
yonghuid=jiedan_dashou_id,
|
UserUID=jiedan_dashou_id,
|
||||||
#user_type='dashou'
|
#user_type='dashou'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -4956,7 +4956,7 @@ class AdQiangZhiJieDan(APIView):
|
|||||||
if shangjia_id:
|
if shangjia_id:
|
||||||
# 查询商家用户主表
|
# 查询商家用户主表
|
||||||
shangjia_user = User.query.get(
|
shangjia_user = User.query.get(
|
||||||
yonghuid=shangjia_id,
|
UserUID=shangjia_id,
|
||||||
#user_type='shop'
|
#user_type='shop'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -5089,7 +5089,7 @@ class AdJuJueTuiKuan(APIView):
|
|||||||
try:
|
try:
|
||||||
# 查询打手用户主表
|
# 查询打手用户主表
|
||||||
dashou_user = User.query.get(
|
dashou_user = User.query.get(
|
||||||
yonghuid=jiedan_dashou_id,
|
UserUID=jiedan_dashou_id,
|
||||||
#user_type='dashou'
|
#user_type='dashou'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -5132,7 +5132,7 @@ class AdJuJueTuiKuan(APIView):
|
|||||||
if shangjia_id:
|
if shangjia_id:
|
||||||
# 查询商家用户主表
|
# 查询商家用户主表
|
||||||
shangjia_user = User.query.get(
|
shangjia_user = User.query.get(
|
||||||
yonghuid=shangjia_id,
|
UserUID=shangjia_id,
|
||||||
#user_type='shop'
|
#user_type='shop'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -5320,7 +5320,7 @@ class AdTongYiTuiKuanShangJia(APIView):
|
|||||||
try:
|
try:
|
||||||
# 查询打手用户主表
|
# 查询打手用户主表
|
||||||
dashou_user = User.query.get(
|
dashou_user = User.query.get(
|
||||||
yonghuid=jiedan_dashou_id,
|
UserUID=jiedan_dashou_id,
|
||||||
#user_type='dashou'
|
#user_type='dashou'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -5345,7 +5345,7 @@ class AdTongYiTuiKuanShangJia(APIView):
|
|||||||
try:
|
try:
|
||||||
# 查询商家用户主表
|
# 查询商家用户主表
|
||||||
shangjia_user = User.query.get(
|
shangjia_user = User.query.get(
|
||||||
yonghuid=shangjia_id,
|
UserUID=shangjia_id,
|
||||||
#user_type='shop'
|
#user_type='shop'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -5529,7 +5529,7 @@ class AdTongYiTuiKuanPingTai(APIView):
|
|||||||
# 14. 更新打手扩展表
|
# 14. 更新打手扩展表
|
||||||
if jiedan_dashou_id:
|
if jiedan_dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.zhuangtai = 1 # 打手状态设为空闲
|
dashou_profile.zhuangtai = 1 # 打手状态设为空闲
|
||||||
dashou_profile.tuikuanliang += 1
|
dashou_profile.tuikuanliang += 1
|
||||||
@@ -5540,7 +5540,7 @@ class AdTongYiTuiKuanPingTai(APIView):
|
|||||||
# 15. 更新老板扩展表
|
# 15. 更新老板扩展表
|
||||||
if laoban_id:
|
if laoban_id:
|
||||||
try:
|
try:
|
||||||
laoban_user = User.query.get(yonghuid=laoban_id)
|
laoban_user = User.query.get(UserUID=laoban_id)
|
||||||
laoban_profile = laoban_user.boss_profile
|
laoban_profile = laoban_user.boss_profile
|
||||||
laoban_profile.alltui += 1
|
laoban_profile.alltui += 1
|
||||||
laoban_profile.zonge -= jine
|
laoban_profile.zonge -= jine
|
||||||
@@ -5865,7 +5865,7 @@ class AdJuJueJieSuan(APIView):
|
|||||||
|
|
||||||
# 8. 更新打手扩展表
|
# 8. 更新打手扩展表
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.zhuangtai = 1 # 打手状态设为正常
|
dashou_profile.zhuangtai = 1 # 打手状态设为正常
|
||||||
dashou_profile.tuikuanliang += 1 # 退款订单总量+1
|
dashou_profile.tuikuanliang += 1 # 退款订单总量+1
|
||||||
@@ -5947,7 +5947,7 @@ class AdZhuanYiDaTing(APIView):
|
|||||||
# 如果有接单打手,更新其扩展表
|
# 如果有接单打手,更新其扩展表
|
||||||
if jiedan_dashou_id:
|
if jiedan_dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.zhuangtai = 1
|
dashou_profile.zhuangtai = 1
|
||||||
dashou_profile.tuikuanliang += 1
|
dashou_profile.tuikuanliang += 1
|
||||||
@@ -6225,7 +6225,7 @@ class ZxsjghdsView(APIView):
|
|||||||
# 6.2 释放打手
|
# 6.2 释放打手
|
||||||
if dashou_id:
|
if dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.tuikuanliang = (dashou_profile.tuikuanliang or 0) + 1
|
dashou_profile.tuikuanliang = (dashou_profile.tuikuanliang or 0) + 1
|
||||||
dashou_profile.zhuangtai = 1 # 空闲
|
dashou_profile.zhuangtai = 1 # 空闲
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 4.2.27 on 2026-06-17 16:31
|
# Generated by Django 4.2.27 on 2026-06-17 21:18
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 4.2.27 on 2026-06-17 16:31
|
# Generated by Django 4.2.27 on 2026-06-17 21:18
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
@@ -9,9 +9,9 @@ class Migration(migrations.Migration):
|
|||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('products', '0001_initial'),
|
|
||||||
('rank', '0001_initial'),
|
('rank', '0001_initial'),
|
||||||
('shop', '0001_initial'),
|
('shop', '0001_initial'),
|
||||||
|
('products', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|||||||
@@ -607,7 +607,7 @@ class YajinHuitiao(View):
|
|||||||
# 8. 更新打手押金
|
# 8. 更新打手押金
|
||||||
try:
|
try:
|
||||||
# 通过用户ID查找打手(高效查询)
|
# 通过用户ID查找打手(高效查询)
|
||||||
dashou = UserDashou.query.get(user__yonghuid=order.yonghuid)
|
dashou = UserDashou.query.get(user__UserUID=order.yonghuid)
|
||||||
|
|
||||||
# 增加押金(使用Decimal确保精度)
|
# 增加押金(使用Decimal确保精度)
|
||||||
dashou.yajin += Decimal(str(order_amount_yuan))
|
dashou.yajin += Decimal(str(order_amount_yuan))
|
||||||
@@ -634,7 +634,7 @@ class YajinHuitiao(View):
|
|||||||
if fenhong_jine > 0:
|
if fenhong_jine > 0:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
guanshi = UserGuanshi.objects.select_for_update().get(
|
guanshi = UserGuanshi.objects.select_for_update().get(
|
||||||
user__yonghuid=guanshi_id
|
user__UserUID=guanshi_id
|
||||||
)
|
)
|
||||||
guanshi.yue += fenhong_jine
|
guanshi.yue += fenhong_jine
|
||||||
guanshi.chongzhifenrun += fenhong_jine
|
guanshi.chongzhifenrun += fenhong_jine
|
||||||
@@ -799,7 +799,7 @@ class YajinShibai(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid
|
UserUID=request.user.yonghuid
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -857,7 +857,7 @@ class YajinLunxun(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid
|
UserUID=request.user.yonghuid
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -1235,7 +1235,7 @@ class JifenHuitiao(View):
|
|||||||
# 8. 更新打手积分
|
# 8. 更新打手积分
|
||||||
try:
|
try:
|
||||||
# 通过用户ID查找打手
|
# 通过用户ID查找打手
|
||||||
dashou = UserDashou.query.get(user__yonghuid=order.yonghuid)
|
dashou = UserDashou.query.get(user__UserUID=order.yonghuid)
|
||||||
|
|
||||||
# 检查积分是否小于10
|
# 检查积分是否小于10
|
||||||
if dashou.jifen < 10:
|
if dashou.jifen < 10:
|
||||||
@@ -1343,7 +1343,7 @@ class JifenShibai(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid
|
UserUID=request.user.yonghuid
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -1408,7 +1408,7 @@ class JifenLunxun(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid
|
UserUID=request.user.yonghuid
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -1865,7 +1865,7 @@ class HuiyuanHuitiao(View):
|
|||||||
def add_first_buy_jifen(self, yonghuid):
|
def add_first_buy_jifen(self, yonghuid):
|
||||||
"""首次购买积分奖励(与原代码一致)"""
|
"""首次购买积分奖励(与原代码一致)"""
|
||||||
try:
|
try:
|
||||||
dashou = UserDashou.query.get(user__yonghuid=yonghuid)
|
dashou = UserDashou.query.get(user__UserUID=yonghuid)
|
||||||
dashou.jifen += 10
|
dashou.jifen += 10
|
||||||
dashou.save(update_fields=['jifen'])
|
dashou.save(update_fields=['jifen'])
|
||||||
logger.info(f"用户{yonghuid}首次购买会员,积分+10,当前积分: {dashou.jifen}")
|
logger.info(f"用户{yonghuid}首次购买会员,积分+10,当前积分: {dashou.jifen}")
|
||||||
@@ -1881,7 +1881,7 @@ class HuiyuanHuitiao(View):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 获取打手信息
|
# 获取打手信息
|
||||||
dashou = UserDashou.query.get(user__yonghuid=order.yonghuid)
|
dashou = UserDashou.query.get(user__UserUID=order.yonghuid)
|
||||||
guanshi_id = dashou.yaoqingren
|
guanshi_id = dashou.yaoqingren
|
||||||
if not guanshi_id:
|
if not guanshi_id:
|
||||||
logger.info(f"打手{order.yonghuid}没有邀请人,无分红")
|
logger.info(f"打手{order.yonghuid}没有邀请人,无分红")
|
||||||
@@ -1889,7 +1889,7 @@ class HuiyuanHuitiao(View):
|
|||||||
|
|
||||||
# 获取管事信息
|
# 获取管事信息
|
||||||
try:
|
try:
|
||||||
guanshi = UserGuanshi.query.get(user__yonghuid=guanshi_id)
|
guanshi = UserGuanshi.query.get(user__UserUID=guanshi_id)
|
||||||
except UserGuanshi.DoesNotExist:
|
except UserGuanshi.DoesNotExist:
|
||||||
logger.warning(f"管事信息不存在: {guanshi_id}")
|
logger.warning(f"管事信息不存在: {guanshi_id}")
|
||||||
return
|
return
|
||||||
@@ -1923,7 +1923,7 @@ class HuiyuanHuitiao(View):
|
|||||||
if zuzhang_id:
|
if zuzhang_id:
|
||||||
# 获取组长信息
|
# 获取组长信息
|
||||||
try:
|
try:
|
||||||
zuzhang = UserZuzhang.query.get(user__yonghuid=zuzhang_id)
|
zuzhang = UserZuzhang.query.get(user__UserUID=zuzhang_id)
|
||||||
except UserZuzhang.DoesNotExist:
|
except UserZuzhang.DoesNotExist:
|
||||||
logger.warning(f"组长信息不存在: {zuzhang_id}")
|
logger.warning(f"组长信息不存在: {zuzhang_id}")
|
||||||
zuzhang = None
|
zuzhang = None
|
||||||
@@ -2034,7 +2034,7 @@ class HuiyuanHuitiao(View):
|
|||||||
try:
|
try:
|
||||||
config = DuociFenhong.query.get(
|
config = DuociFenhong.query.get(
|
||||||
huiyuan=huiyuan,
|
huiyuan=huiyuan,
|
||||||
yonghuid=guanshi_id,
|
UserUID=guanshi_id,
|
||||||
cishu=cishu
|
cishu=cishu
|
||||||
)
|
)
|
||||||
return Decimal(str(config.guanshi_fenhong))
|
return Decimal(str(config.guanshi_fenhong))
|
||||||
@@ -2059,7 +2059,7 @@ class HuiyuanHuitiao(View):
|
|||||||
try:
|
try:
|
||||||
config = DuociFenhong.query.get(
|
config = DuociFenhong.query.get(
|
||||||
huiyuan=huiyuan,
|
huiyuan=huiyuan,
|
||||||
yonghuid=zuzhang_id,
|
UserUID=zuzhang_id,
|
||||||
cishu=cishu
|
cishu=cishu
|
||||||
)
|
)
|
||||||
return Decimal(str(config.zuzhang_fenhong))
|
return Decimal(str(config.zuzhang_fenhong))
|
||||||
@@ -2145,7 +2145,7 @@ class HuiyuanShibai(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid
|
UserUID=request.user.yonghuid
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -2210,7 +2210,7 @@ class HuiyuanLunxun(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid
|
UserUID=request.user.yonghuid
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -2646,7 +2646,7 @@ class ShangjiaHuitiao(View):
|
|||||||
# 更新商家余额
|
# 更新商家余额
|
||||||
try:
|
try:
|
||||||
# 通过用户ID查找商家(高效查询)
|
# 通过用户ID查找商家(高效查询)
|
||||||
shangjia = UserShangjia.query.get(user__yonghuid=order.yonghuid)
|
shangjia = UserShangjia.query.get(user__UserUID=order.yonghuid)
|
||||||
|
|
||||||
# 增加余额
|
# 增加余额
|
||||||
shangjia.yue += order_amount_yuan
|
shangjia.yue += order_amount_yuan
|
||||||
@@ -2750,7 +2750,7 @@ class ShangjiaShibai(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid,
|
UserUID=request.user.yonghuid,
|
||||||
leixing=4 # 确保是商家充值订单
|
leixing=4 # 确保是商家充值订单
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
@@ -2816,7 +2816,7 @@ class ShangjiaChenggong(APIView):
|
|||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(
|
order = Czjilu.query.get(
|
||||||
dingdan_id=dingdanid,
|
dingdan_id=dingdanid,
|
||||||
yonghuid=request.user.yonghuid,
|
UserUID=request.user.yonghuid,
|
||||||
leixing=4 # 商家充值类型
|
leixing=4 # 商家充值类型
|
||||||
)
|
)
|
||||||
except Czjilu.DoesNotExist:
|
except Czjilu.DoesNotExist:
|
||||||
@@ -5946,7 +5946,7 @@ class ZuzhangFenhongView(APIView):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
# 查询用户主表,并预加载 boss_profile
|
# 查询用户主表,并预加载 boss_profile
|
||||||
users = User.query.filter(yonghuid__in=guanshi_ids).select_related(
|
users = User.query.filter(UserUID__in=guanshi_ids).select_related(
|
||||||
'boss_profile'
|
'boss_profile'
|
||||||
).only(
|
).only(
|
||||||
'yonghuid', 'avatar',
|
'yonghuid', 'avatar',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 4.2.27 on 2026-06-17 16:31
|
# Generated by Django 4.2.27 on 2026-06-17 21:18
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ def check_dashou_biaoqian_required(order_id, dashou_yonghuid):
|
|||||||
|
|
||||||
# 2. 找到打手对应的用户记录
|
# 2. 找到打手对应的用户记录
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(yonghuid=dashou_yonghuid)
|
user = User.objects.get(UserUID=dashou_yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return False, '用户信息异常'
|
return False, '用户信息异常'
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ def validate_shenheguan(shenheguan_id, bankuai, fee, applicant_user):
|
|||||||
return True, ''
|
return True, ''
|
||||||
try:
|
try:
|
||||||
kg = UserShenheguan.objects.select_related('user').get(
|
kg = UserShenheguan.objects.select_related('user').get(
|
||||||
user__yonghuid=shenheguan_id,
|
user__UserUID=shenheguan_id,
|
||||||
zhuangtai=1
|
zhuangtai=1
|
||||||
)
|
)
|
||||||
except UserShenheguan.DoesNotExist:
|
except UserShenheguan.DoesNotExist:
|
||||||
@@ -210,7 +210,7 @@ def create_shenhe_jilu(user, tag_id, game_nick, remark, reapply, jilu_id=None, s
|
|||||||
if last_record.shenheguan_id != final_kg_id:
|
if last_record.shenheguan_id != final_kg_id:
|
||||||
if last_record.shenheguan_id:
|
if last_record.shenheguan_id:
|
||||||
UserShenheguan.objects.filter(
|
UserShenheguan.objects.filter(
|
||||||
user__yonghuid=last_record.shenheguan_id
|
user__UserUID=last_record.shenheguan_id
|
||||||
).update(shenhe_zhuangtai=0)
|
).update(shenhe_zhuangtai=0)
|
||||||
else:
|
else:
|
||||||
# 首次申请
|
# 首次申请
|
||||||
@@ -251,7 +251,7 @@ def create_shenhe_jilu(user, tag_id, game_nick, remark, reapply, jilu_id=None, s
|
|||||||
# 6. 更新考核官统计(仅当状态为审核中且有考核官)
|
# 6. 更新考核官统计(仅当状态为审核中且有考核官)
|
||||||
if record.zhuangtai == 0 and record.shenheguan_id:
|
if record.zhuangtai == 0 and record.shenheguan_id:
|
||||||
UserShenheguan.objects.filter(
|
UserShenheguan.objects.filter(
|
||||||
user__yonghuid=record.shenheguan_id
|
user__UserUID=record.shenheguan_id
|
||||||
).update(
|
).update(
|
||||||
shenhe_zongshu=F('shenhe_zongshu') + 1,
|
shenhe_zongshu=F('shenhe_zongshu') + 1,
|
||||||
shenhe_zhuangtai=1
|
shenhe_zhuangtai=1
|
||||||
@@ -351,7 +351,7 @@ def create_shenhe_jilu_from_temp(user, temp_data):
|
|||||||
|
|
||||||
# 释放旧考核官
|
# 释放旧考核官
|
||||||
if last.shenheguan_id != final_kg_id and last.shenheguan_id:
|
if last.shenheguan_id != final_kg_id and last.shenheguan_id:
|
||||||
UserShenheguan.objects.filter(user__yonghuid=last.shenheguan_id).update(shenhe_zhuangtai=0)
|
UserShenheguan.objects.filter(user__UserUID=last.shenheguan_id).update(shenhe_zhuangtai=0)
|
||||||
logger.info(f"释放旧考核官: {last.shenheguan_id}")
|
logger.info(f"释放旧考核官: {last.shenheguan_id}")
|
||||||
|
|
||||||
logger.info(f"更新审核记录成功: jilu_id={record.jilu_id}, 新次数={new_cishu}")
|
logger.info(f"更新审核记录成功: jilu_id={record.jilu_id}, 新次数={new_cishu}")
|
||||||
@@ -390,7 +390,7 @@ def create_shenhe_jilu_from_temp(user, temp_data):
|
|||||||
|
|
||||||
# 更新考核官状态
|
# 更新考核官状态
|
||||||
if record.zhuangtai == 0 and record.shenheguan_id:
|
if record.zhuangtai == 0 and record.shenheguan_id:
|
||||||
UserShenheguan.objects.filter(user__yonghuid=record.shenheguan_id).update(
|
UserShenheguan.objects.filter(user__UserUID=record.shenheguan_id).update(
|
||||||
shenhe_zongshu=F('shenhe_zongshu') + 1,
|
shenhe_zongshu=F('shenhe_zongshu') + 1,
|
||||||
shenhe_zhuangtai=1
|
shenhe_zhuangtai=1
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ class ShenheDatingDataView(APIView):
|
|||||||
|
|
||||||
records = []
|
records = []
|
||||||
for jl in jilu_list:
|
for jl in jilu_list:
|
||||||
user = User.objects.filter(yonghuid=jl.shenqingren_id).first()
|
user = User.objects.filter(UserUID=jl.shenqingren_id).first()
|
||||||
avatar = user.avatar if user else ''
|
avatar = user.avatar if user else ''
|
||||||
texiao_json = {}
|
texiao_json = {}
|
||||||
if jl.chenghao and jl.chenghao.texiao_miaoshu:
|
if jl.chenghao and jl.chenghao.texiao_miaoshu:
|
||||||
@@ -388,7 +388,7 @@ class ShenheXiangqingView(APIView):
|
|||||||
|
|
||||||
records = []
|
records = []
|
||||||
for jl in jilu_list:
|
for jl in jilu_list:
|
||||||
user = User.objects.filter(yonghuid=jl.shenqingren_id).first()
|
user = User.objects.filter(UserUID=jl.shenqingren_id).first()
|
||||||
avatar = user.avatar if user else ''
|
avatar = user.avatar if user else ''
|
||||||
texiao_json = {}
|
texiao_json = {}
|
||||||
if jl.chenghao and jl.chenghao.texiao_miaoshu:
|
if jl.chenghao and jl.chenghao.texiao_miaoshu:
|
||||||
@@ -495,7 +495,7 @@ class ShenheCaozuoView(APIView):
|
|||||||
|
|
||||||
# 授予标签
|
# 授予标签
|
||||||
if jilu.chenghao:
|
if jilu.chenghao:
|
||||||
yh = User.objects.get(yonghuid=jilu.shenqingren_id)
|
yh = User.objects.get(UserUID=jilu.shenqingren_id)
|
||||||
if not YonghuChenghao.objects.filter(yonghu=yh, chenghao=jilu.chenghao).exists():
|
if not YonghuChenghao.objects.filter(yonghu=yh, chenghao=jilu.chenghao).exists():
|
||||||
YonghuChenghao.objects.create(yonghu=yh, chenghao=jilu.chenghao)
|
YonghuChenghao.objects.create(yonghu=yh, chenghao=jilu.chenghao)
|
||||||
# 如果标签开启了金牌,同步更新打手称号
|
# 如果标签开启了金牌,同步更新打手称号
|
||||||
@@ -699,7 +699,7 @@ class KaoheJiluView(APIView):
|
|||||||
fail_reason = last_fail.yuanyin if last_fail else ''
|
fail_reason = last_fail.yuanyin if last_fail else ''
|
||||||
|
|
||||||
# 考核官头像
|
# 考核官头像
|
||||||
kg_user = User.objects.filter(yonghuid=jl.shenheguan_id).first()
|
kg_user = User.objects.filter(UserUID=jl.shenheguan_id).first()
|
||||||
kg_avatar = kg_user.avatar if kg_user else ''
|
kg_avatar = kg_user.avatar if kg_user else ''
|
||||||
|
|
||||||
data.append({
|
data.append({
|
||||||
@@ -882,7 +882,7 @@ class KaoheJiluListView(APIView):
|
|||||||
applicant_ids = {j.shenqingren_id for j in jilu_list}
|
applicant_ids = {j.shenqingren_id for j in jilu_list}
|
||||||
user_map = {}
|
user_map = {}
|
||||||
if applicant_ids:
|
if applicant_ids:
|
||||||
users = User.objects.filter(yonghuid__in=applicant_ids).select_related('dashou_profile')
|
users = User.objects.filter(UserUID__in=applicant_ids).select_related('dashou_profile')
|
||||||
for u in users:
|
for u in users:
|
||||||
avatar = u.avatar or ''
|
avatar = u.avatar or ''
|
||||||
nicheng = ''
|
nicheng = ''
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 4.2.27 on 2026-06-17 16:31
|
# Generated by Django 4.2.27 on 2026-06-17 21:18
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
@@ -131,7 +131,7 @@ class Migration(migrations.Migration):
|
|||||||
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||||
('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
|
('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
|
||||||
('dianpu', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.dianpu', verbose_name='关联店铺ID')),
|
('dianpu', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.dianpu', verbose_name='关联店铺ID')),
|
||||||
('yonghu', models.ForeignKey(db_column='UserUUID', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, to_field='UserUID', verbose_name='用户ID')),
|
('yonghu', models.ForeignKey(db_column='UserUUID', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户ID')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name': '用户店铺绑定关系',
|
'verbose_name': '用户店铺绑定关系',
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ class YonghuDianpuBangding(QModel):
|
|||||||
id = models.AutoField(primary_key=True, verbose_name='绑定自增ID')
|
id = models.AutoField(primary_key=True, verbose_name='绑定自增ID')
|
||||||
yonghu = models.ForeignKey(
|
yonghu = models.ForeignKey(
|
||||||
'gvsdsdk.User',
|
'gvsdsdk.User',
|
||||||
to_field='UserUID',
|
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
db_column='UserUUID',
|
db_column='UserUUID',
|
||||||
db_index=True,
|
db_index=True,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class BindDianpuView(APIView):
|
|||||||
|
|
||||||
# 先获取 User 对象(不加锁,仅用于校验存在性)
|
# 先获取 User 对象(不加锁,仅用于校验存在性)
|
||||||
try:
|
try:
|
||||||
user_main = User.query.get(yonghuid=user.yonghuid)
|
user_main = User.query.get(UserUID=user.yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '用户不存在'})
|
return Response({'code': 404, 'msg': '用户不存在'})
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class BindDianpuView(APIView):
|
|||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
# 重新获取加锁的用户对象(确保并发安全)
|
# 重新获取加锁的用户对象(确保并发安全)
|
||||||
user_main_locked = User.objects.select_for_update().get(yonghuid=user.yonghuid)
|
user_main_locked = User.objects.select_for_update().get(UserUID=user.yonghuid)
|
||||||
dianpu_locked = Dianpu.objects.select_for_update().get(id=dianpu_id)
|
dianpu_locked = Dianpu.objects.select_for_update().get(id=dianpu_id)
|
||||||
|
|
||||||
# 再次校验店铺状态(防止事务期间被修改)
|
# 再次校验店铺状态(防止事务期间被修改)
|
||||||
@@ -144,7 +144,7 @@ class ShopGoodsView(APIView):
|
|||||||
def post(self, request):
|
def post(self, request):
|
||||||
user = request.user
|
user = request.user
|
||||||
try:
|
try:
|
||||||
user_main = User.query.get(yonghuid=user.yonghuid)
|
user_main = User.query.get(UserUUID=user.UserUUID)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '用户不存在'})
|
return Response({'code': 404, 'msg': '用户不存在'})
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ class ShangdianLoginView(APIView):
|
|||||||
|
|
||||||
# 3. 验证用户主表是否存在
|
# 3. 验证用户主表是否存在
|
||||||
try:
|
try:
|
||||||
user_main = User.query.get(yonghuid=yonghuid)
|
user_main = User.query.get(UserUID=yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
logger.warning(f"登录失败:用户ID不存在 - {yonghuid}")
|
logger.warning(f"登录失败:用户ID不存在 - {yonghuid}")
|
||||||
return Response({'code': 404, 'msg': '账号或密码错误'})
|
return Response({'code': 404, 'msg': '账号或密码错误'})
|
||||||
@@ -1912,7 +1912,7 @@ class SubShopModifyView(APIView):
|
|||||||
return Response({'code': 400, 'msg': '必填字段缺失(user_uid, zhanghao, mima, dianpu_mingcheng)'})
|
return Response({'code': 400, 'msg': '必填字段缺失(user_uid, zhanghao, mima, dianpu_mingcheng)'})
|
||||||
|
|
||||||
# 检查用户是否存在
|
# 检查用户是否存在
|
||||||
if not User.query.filter(yonghuid=user_uid).exists():
|
if not User.query.filter(UserUID=user_uid).exists():
|
||||||
return Response({'code': 404, 'msg': '对应的小程序用户不存在'})
|
return Response({'code': 404, 'msg': '对应的小程序用户不存在'})
|
||||||
|
|
||||||
# 检查账号是否已占用
|
# 检查账号是否已占用
|
||||||
@@ -2588,7 +2588,7 @@ class ShopRefundView(APIView):
|
|||||||
# 更新打手统计(退款量+1,状态置为空闲)
|
# 更新打手统计(退款量+1,状态置为空闲)
|
||||||
if dashou_id:
|
if dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.tuikuanliang += 1
|
dashou_profile.tuikuanliang += 1
|
||||||
dashou_profile.zhuangtai = 1
|
dashou_profile.zhuangtai = 1
|
||||||
@@ -2831,7 +2831,7 @@ class ShopForceCompleteView(APIView):
|
|||||||
|
|
||||||
# ---------- 更新打手余额和统计 ----------
|
# ---------- 更新打手余额和统计 ----------
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.chengjiaozongliang += 1
|
dashou_profile.chengjiaozongliang += 1
|
||||||
dashou_profile.yue += dashou_fencheng
|
dashou_profile.yue += dashou_fencheng
|
||||||
@@ -2989,7 +2989,7 @@ class ShopTransferHallView(APIView):
|
|||||||
# ---------- 7. 释放本地打手 + 退款统计 ----------
|
# ---------- 7. 释放本地打手 + 退款统计 ----------
|
||||||
if current_dashou_id:
|
if current_dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_profile = UserDashou.query.get(user__yonghuid=current_dashou_id)
|
dashou_profile = UserDashou.query.get(user__UserUID=current_dashou_id)
|
||||||
dashou_profile.zhuangtai = 1 # 设为空闲
|
dashou_profile.zhuangtai = 1 # 设为空闲
|
||||||
dashou_profile.save()
|
dashou_profile.save()
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ def process_fadan_fenhong(fadan_id):
|
|||||||
|
|
||||||
# 直接增加商家余额(UserShangjia.yue)
|
# 直接增加商家余额(UserShangjia.yue)
|
||||||
try:
|
try:
|
||||||
shangjia = UserShangjia.objects.get(user__yonghuid=shenqing_chufa)
|
shangjia = UserShangjia.objects.get(user__UserUID=shenqing_chufa)
|
||||||
shangjia.yue += fenhong_jine
|
shangjia.yue += fenhong_jine
|
||||||
shangjia.save(update_fields=['yue'])
|
shangjia.save(update_fields=['yue'])
|
||||||
logger.info(f"商家 {shenqing_chufa} 余额增加 {fenhong_jine} 元")
|
logger.info(f"商家 {shenqing_chufa} 余额增加 {fenhong_jine} 元")
|
||||||
|
|||||||
@@ -201,18 +201,18 @@ class PhbHqsjView(APIView):
|
|||||||
if not yonghuids:
|
if not yonghuids:
|
||||||
return {}, {}
|
return {}, {}
|
||||||
|
|
||||||
users = User.objects.filter(yonghuid__in=yonghuids)
|
users = User.objects.filter(UserUID__in=yonghuids)
|
||||||
avatar_map = {u.yonghuid: u.avatar or '' for u in users}
|
avatar_map = {u.yonghuid: u.avatar or '' for u in users}
|
||||||
|
|
||||||
nick_map = {}
|
nick_map = {}
|
||||||
if shenfen == 'dashou':
|
if shenfen == 'dashou':
|
||||||
for p in UserDashou.objects.filter(user__yonghuid__in=yonghuids).select_related('user'):
|
for p in UserDashou.objects.filter(user__UserUID__in=yonghuids).select_related('user'):
|
||||||
nick_map[p.user.yonghuid] = p.nicheng or '用户'
|
nick_map[p.user.yonghuid] = p.nicheng or '用户'
|
||||||
elif shenfen == 'shangjia':
|
elif shenfen == 'shangjia':
|
||||||
for p in UserShangjia.objects.filter(user__yonghuid__in=yonghuids).select_related('user'):
|
for p in UserShangjia.objects.filter(user__UserUID__in=yonghuids).select_related('user'):
|
||||||
nick_map[p.user.yonghuid] = p.nicheng or '用户'
|
nick_map[p.user.yonghuid] = p.nicheng or '用户'
|
||||||
else:
|
else:
|
||||||
for b in UserBoss.objects.filter(user__yonghuid__in=yonghuids).select_related('user'):
|
for b in UserBoss.objects.filter(user__UserUID__in=yonghuids).select_related('user'):
|
||||||
nick_map[b.user.yonghuid] = b.nickname or '用户'
|
nick_map[b.user.yonghuid] = b.nickname or '用户'
|
||||||
|
|
||||||
return nick_map, avatar_map
|
return nick_map, avatar_map
|
||||||
|
|||||||
@@ -708,7 +708,7 @@ def release_collect_quota_for_record(auto_record):
|
|||||||
if not _quota_already_reserved_for_record(auto_record):
|
if not _quota_already_reserved_for_record(auto_record):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
user_main = User.query.get(yonghuid=auto_record.yonghuid)
|
user_main = User.query.get(UserUID=auto_record.yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
logger.error('回滚限额预占失败:用户不存在 %s', auto_record.yonghuid)
|
logger.error('回滚限额预占失败:用户不存在 %s', auto_record.yonghuid)
|
||||||
return
|
return
|
||||||
@@ -753,7 +753,7 @@ def apply_transfer_success_quota(auto_record):
|
|||||||
shijidaozhang = auto_record.shijidaozhang or decimal.Decimal('0.00')
|
shijidaozhang = auto_record.shijidaozhang or decimal.Decimal('0.00')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_main = User.query.get(yonghuid=auto_record.yonghuid)
|
user_main = User.query.get(UserUID=auto_record.yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
logger.error('打款成功累加限额失败:用户不存在 %s', auto_record.yonghuid)
|
logger.error('打款成功累加限额失败:用户不存在 %s', auto_record.yonghuid)
|
||||||
return
|
return
|
||||||
@@ -966,7 +966,7 @@ def close_audit_over_limit_refund(audit, auto_record=None, fail_reason='单笔
|
|||||||
if audit.zhuangtai in (2, 3, 5):
|
if audit.zhuangtai in (2, 3, 5):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
user_main = User.objects.select_for_update().get(yonghuid=audit.yonghuid)
|
user_main = User.objects.select_for_update().get(UserUID=audit.yonghuid)
|
||||||
refund_balance(user_main, audit.leixing, audit.shijidaozhang)
|
refund_balance(user_main, audit.leixing, audit.shijidaozhang)
|
||||||
sync_audit_and_jilu_status(
|
sync_audit_and_jilu_status(
|
||||||
audit, 3,
|
audit, 3,
|
||||||
@@ -1282,7 +1282,7 @@ def resolve_collect_context(yonghuid, tixianjilu_id=None, shenhe_danhao='', shen
|
|||||||
else:
|
else:
|
||||||
audit = TixianShenheJilu.query.get(
|
audit = TixianShenheJilu.query.get(
|
||||||
shenhe_danhao=shenhe_danhao,
|
shenhe_danhao=shenhe_danhao,
|
||||||
yonghuid=yonghuid,
|
UserUID=yonghuid,
|
||||||
)
|
)
|
||||||
except (TixianShenheJilu.DoesNotExist, TypeError, ValueError):
|
except (TixianShenheJilu.DoesNotExist, TypeError, ValueError):
|
||||||
return None, '审核记录不存在'
|
return None, '审核记录不存在'
|
||||||
@@ -1298,7 +1298,7 @@ def resolve_collect_context(yonghuid, tixianjilu_id=None, shenhe_danhao='', shen
|
|||||||
try:
|
try:
|
||||||
jilu = Tixianjilu.query.get(
|
jilu = Tixianjilu.query.get(
|
||||||
id=audit.tixianjilu_id,
|
id=audit.tixianjilu_id,
|
||||||
yonghuid=yonghuid,
|
UserUID=yonghuid,
|
||||||
) if audit.tixianjilu_id else None
|
) if audit.tixianjilu_id else None
|
||||||
except Tixianjilu.DoesNotExist:
|
except Tixianjilu.DoesNotExist:
|
||||||
jilu = None
|
jilu = None
|
||||||
@@ -1341,7 +1341,7 @@ def get_audit_for_collect(shenhe_danhao, yonghuid, shenhe_jilu_id=None):
|
|||||||
try:
|
try:
|
||||||
audit = TixianShenheJilu.objects.select_for_update().get(
|
audit = TixianShenheJilu.objects.select_for_update().get(
|
||||||
shenhe_danhao=shenhe_danhao,
|
shenhe_danhao=shenhe_danhao,
|
||||||
yonghuid=yonghuid,
|
UserUID=yonghuid,
|
||||||
)
|
)
|
||||||
except TixianShenheJilu.DoesNotExist:
|
except TixianShenheJilu.DoesNotExist:
|
||||||
return None, '审核记录不存在'
|
return None, '审核记录不存在'
|
||||||
|
|||||||
102
users/views.py
102
users/views.py
@@ -343,7 +343,7 @@ class WechatMiniProgramLoginView(APIView):
|
|||||||
user_id = timestamp_part + random_part
|
user_id = timestamp_part + random_part
|
||||||
|
|
||||||
if len(user_id) == 7 and user_id.isdigit():
|
if len(user_id) == 7 and user_id.isdigit():
|
||||||
if not User.query.filter(yonghuid=user_id).exists():
|
if not User.query.filter(UserUID=user_id).exists():
|
||||||
return user_id
|
return user_id
|
||||||
|
|
||||||
raise Exception('生成用户ID失败')
|
raise Exception('生成用户ID失败')
|
||||||
@@ -827,7 +827,7 @@ class HuoQuYaoQingRenView(APIView):
|
|||||||
|
|
||||||
# 3. 查询邀请人主表(头像)
|
# 3. 查询邀请人主表(头像)
|
||||||
try:
|
try:
|
||||||
inviter_main = User.query.get(yonghuid=yaoqingren_id)
|
inviter_main = User.query.get(UserUID=yaoqingren_id)
|
||||||
touxiang = inviter_main.avatar or ''
|
touxiang = inviter_main.avatar or ''
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -1081,7 +1081,7 @@ class ShangJiaXinXiView(APIView):
|
|||||||
|
|
||||||
# ------------------- 3. 从 ShangjiaRiTongji 获取今日统计 -------------------
|
# ------------------- 3. 从 ShangjiaRiTongji 获取今日统计 -------------------
|
||||||
try:
|
try:
|
||||||
today_stat = ShangjiaRiTongji.query.get(yonghuid=yonghuid, riqi=today)
|
today_stat = ShangjiaRiTongji.query.get(UserUID=yonghuid, riqi=today)
|
||||||
jinri_paifa_dingdan = today_stat.paifa_dingdan_shu
|
jinri_paifa_dingdan = today_stat.paifa_dingdan_shu
|
||||||
jinri_paifa_jine = float(today_stat.paifa_jine)
|
jinri_paifa_jine = float(today_stat.paifa_jine)
|
||||||
jinri_tuikuan_dingdan = today_stat.tuikuan_dingdan_shu
|
jinri_tuikuan_dingdan = today_stat.tuikuan_dingdan_shu
|
||||||
@@ -1096,7 +1096,7 @@ class ShangJiaXinXiView(APIView):
|
|||||||
|
|
||||||
# ------------------- 4. 从 ShangjiaRiTongji 获取本月统计 -------------------
|
# ------------------- 4. 从 ShangjiaRiTongji 获取本月统计 -------------------
|
||||||
month_stats = ShangjiaRiTongji.query.filter(
|
month_stats = ShangjiaRiTongji.query.filter(
|
||||||
yonghuid=yonghuid,
|
UserUID=yonghuid,
|
||||||
riqi__gte=this_month_start,
|
riqi__gte=this_month_start,
|
||||||
riqi__lte=today
|
riqi__lte=today
|
||||||
).aggregate(
|
).aggregate(
|
||||||
@@ -2161,7 +2161,7 @@ class TixianJiluHuoquViewV2(APIView):
|
|||||||
limit = 100
|
limit = 100
|
||||||
offset = (page - 1) * limit
|
offset = (page - 1) * limit
|
||||||
|
|
||||||
qs = Tixianjilu.query.filter(yonghuid=yonghuid)
|
qs = Tixianjilu.query.filter(UserUID=yonghuid)
|
||||||
if mode == 2:
|
if mode == 2:
|
||||||
# 自动提现:含新审核关联记录;zhuangtai>0 时按状态筛选
|
# 自动提现:含新审核关联记录;zhuangtai>0 时按状态筛选
|
||||||
if zhuangtai_filter > 0:
|
if zhuangtai_filter > 0:
|
||||||
@@ -3668,7 +3668,7 @@ class AdTongYiChuFa(APIView):
|
|||||||
|
|
||||||
# 11.2 查询打手扩展表(只是验证存在性)
|
# 11.2 查询打手扩展表(只是验证存在性)
|
||||||
try:
|
try:
|
||||||
dashou = UserDashou.query.get(user__yonghuid=chufajilu.dashouid)
|
dashou = UserDashou.query.get(user__UserUID=chufajilu.dashouid)
|
||||||
except UserDashou.DoesNotExist:
|
except UserDashou.DoesNotExist:
|
||||||
return Response(
|
return Response(
|
||||||
{'code': 404, 'message': '被处罚打手不存在', 'data': None},
|
{'code': 404, 'message': '被处罚打手不存在', 'data': None},
|
||||||
@@ -3698,7 +3698,7 @@ class AdTongYiChuFa(APIView):
|
|||||||
# 🔴【新增】11.5 返还打手积分(加5分)
|
# 🔴【新增】11.5 返还打手积分(加5分)
|
||||||
if chufajilu.jifen > 0:
|
if chufajilu.jifen > 0:
|
||||||
try:
|
try:
|
||||||
dashou = UserDashou.query.get(user__yonghuid=chufajilu.dashouid)
|
dashou = UserDashou.query.get(user__UserUID=chufajilu.dashouid)
|
||||||
|
|
||||||
# 🔴【新增】安全验证:必须积分小于等于5分才允许加分
|
# 🔴【新增】安全验证:必须积分小于等于5分才允许加分
|
||||||
if dashou.jifen <= 5: # 判断积分是否小于等于5分
|
if dashou.jifen <= 5: # 判断积分是否小于等于5分
|
||||||
@@ -3827,7 +3827,7 @@ class AdckyhxqView(APIView):
|
|||||||
}, status=status.HTTP_400_BAD_REQUEST)
|
}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# 查询用户主表 - 使用select_related优化查询
|
# 查询用户主表 - 使用select_related优化查询
|
||||||
user_main = User.query.filter(yonghuid=uid).first()
|
user_main = User.query.filter(UserUID=uid).first()
|
||||||
if not user_main:
|
if not user_main:
|
||||||
return Response({
|
return Response({
|
||||||
'code': 404,
|
'code': 404,
|
||||||
@@ -3856,7 +3856,7 @@ class AdckyhxqView(APIView):
|
|||||||
# 根据用户类型查询扩展信息
|
# 根据用户类型查询扩展信息
|
||||||
if user_type == 1: # 老板
|
if user_type == 1: # 老板
|
||||||
# 使用select_related预取boss_profile
|
# 使用select_related预取boss_profile
|
||||||
user_main = User.query.filter(yonghuid=uid).select_related('boss_profile').first()
|
user_main = User.query.filter(UserUID=uid).select_related('boss_profile').first()
|
||||||
if user_main.boss_profile:
|
if user_main.boss_profile:
|
||||||
boss_profile = user_main.boss_profile
|
boss_profile = user_main.boss_profile
|
||||||
user_info.update({
|
user_info.update({
|
||||||
@@ -3869,7 +3869,7 @@ class AdckyhxqView(APIView):
|
|||||||
|
|
||||||
elif user_type == 2: # 打手
|
elif user_type == 2: # 打手
|
||||||
# 使用select_related预取dashou_profile
|
# 使用select_related预取dashou_profile
|
||||||
user_main = User.query.filter(yonghuid=uid).select_related('dashou_profile').first()
|
user_main = User.query.filter(UserUID=uid).select_related('dashou_profile').first()
|
||||||
if user_main.dashou_profile:
|
if user_main.dashou_profile:
|
||||||
dashou_profile = user_main.dashou_profile
|
dashou_profile = user_main.dashou_profile
|
||||||
|
|
||||||
@@ -3928,7 +3928,7 @@ class AdckyhxqView(APIView):
|
|||||||
|
|
||||||
elif user_type == 3: # 管事
|
elif user_type == 3: # 管事
|
||||||
# 使用select_related预取guanshi_profile
|
# 使用select_related预取guanshi_profile
|
||||||
user_main = User.query.filter(yonghuid=uid).select_related('guanshi_profile').first()
|
user_main = User.query.filter(UserUID=uid).select_related('guanshi_profile').first()
|
||||||
if user_main.guanshi_profile:
|
if user_main.guanshi_profile:
|
||||||
guanshi_profile = user_main.guanshi_profile
|
guanshi_profile = user_main.guanshi_profile
|
||||||
user_info.update({
|
user_info.update({
|
||||||
@@ -3947,7 +3947,7 @@ class AdckyhxqView(APIView):
|
|||||||
|
|
||||||
elif user_type == 4: # 商家
|
elif user_type == 4: # 商家
|
||||||
# 使用select_related预取shop_profile
|
# 使用select_related预取shop_profile
|
||||||
user_main = User.query.filter(yonghuid=uid).select_related('shop_profile').first()
|
user_main = User.query.filter(UserUID=uid).select_related('shop_profile').first()
|
||||||
if user_main.shop_profile:
|
if user_main.shop_profile:
|
||||||
shop_profile = user_main.shop_profile
|
shop_profile = user_main.shop_profile
|
||||||
user_info.update({
|
user_info.update({
|
||||||
@@ -4061,7 +4061,7 @@ class AdcjxgView(APIView):
|
|||||||
}, status=status.HTTP_400_BAD_REQUEST)
|
}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# 查询用户主表
|
# 查询用户主表
|
||||||
user_main = User.query.filter(yonghuid=uid).first()
|
user_main = User.query.filter(UserUID=uid).first()
|
||||||
if not user_main:
|
if not user_main:
|
||||||
return Response({
|
return Response({
|
||||||
'code': 404,
|
'code': 404,
|
||||||
@@ -5457,7 +5457,7 @@ class WechatLoginAndDashouRegisterView(APIView):
|
|||||||
user_id = timestamp_part + random_part
|
user_id = timestamp_part + random_part
|
||||||
|
|
||||||
if len(user_id) == 7 and user_id.isdigit():
|
if len(user_id) == 7 and user_id.isdigit():
|
||||||
if not User.query.filter(yonghuid=user_id).exists():
|
if not User.query.filter(UserUID=user_id).exists():
|
||||||
return user_id
|
return user_id
|
||||||
|
|
||||||
raise Exception('生成用户ID失败')
|
raise Exception('生成用户ID失败')
|
||||||
@@ -5730,7 +5730,7 @@ class YonghuTixianShenheXiugaiView(APIView):
|
|||||||
try:
|
try:
|
||||||
tixian_record = Tixianjilu.objects.select_for_update().get(
|
tixian_record = Tixianjilu.objects.select_for_update().get(
|
||||||
id=tixian_id,
|
id=tixian_id,
|
||||||
yonghuid=current_yonghuid # 确保只能修改自己的记录
|
UserUID=current_yonghuid # 确保只能修改自己的记录
|
||||||
)
|
)
|
||||||
except Tixianjilu.DoesNotExist:
|
except Tixianjilu.DoesNotExist:
|
||||||
return Response({
|
return Response({
|
||||||
@@ -6158,7 +6158,7 @@ class ChufaJiluHuoquView(APIView):
|
|||||||
zhengju_mapping = {}
|
zhengju_mapping = {}
|
||||||
if dingdan_ids and shangjia_ids:
|
if dingdan_ids and shangjia_ids:
|
||||||
# 构建Q对象:dingdan_id在列表中 AND yonghuid在商家ID列表中
|
# 构建Q对象:dingdan_id在列表中 AND yonghuid在商家ID列表中
|
||||||
zhengju_q = Q(dingdan_id__in=dingdan_ids, yonghuid__in=shangjia_ids)
|
zhengju_q = Q(dingdan_id__in=dingdan_ids, UserUID__in=shangjia_ids)
|
||||||
zhengju_queryset = Chufatupian.query.filter(zhengju_q).values('dingdan_id', 'yonghuid', 'tupian')
|
zhengju_queryset = Chufatupian.query.filter(zhengju_q).values('dingdan_id', 'yonghuid', 'tupian')
|
||||||
|
|
||||||
for item in zhengju_queryset:
|
for item in zhengju_queryset:
|
||||||
@@ -6353,7 +6353,7 @@ class DashouShensuView(APIView):
|
|||||||
# 检查是否已经有申诉图片
|
# 检查是否已经有申诉图片
|
||||||
existing_shensu_tupian = Chufatupian.query.filter(
|
existing_shensu_tupian = Chufatupian.query.filter(
|
||||||
dingdan_id=chufa_record.dingdan_id,
|
dingdan_id=chufa_record.dingdan_id,
|
||||||
yonghuid=yonghuid
|
UserUID=yonghuid
|
||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
if existing_shensu_tupian:
|
if existing_shensu_tupian:
|
||||||
@@ -6600,7 +6600,7 @@ class ShangjiaChufaJiluHuoquView(APIView):
|
|||||||
shensu_mapping = {}
|
shensu_mapping = {}
|
||||||
if dingdan_ids and dashou_ids:
|
if dingdan_ids and dashou_ids:
|
||||||
# 构建Q对象:dingdan_id在列表中 AND yonghuid在打手ID列表中
|
# 构建Q对象:dingdan_id在列表中 AND yonghuid在打手ID列表中
|
||||||
shensu_q = Q(dingdan_id__in=dingdan_ids, yonghuid__in=dashou_ids)
|
shensu_q = Q(dingdan_id__in=dingdan_ids, UserUID__in=dashou_ids)
|
||||||
shensu_queryset = Chufatupian.query.filter(shensu_q).values('dingdan_id', 'yonghuid', 'tupian')
|
shensu_queryset = Chufatupian.query.filter(shensu_q).values('dingdan_id', 'yonghuid', 'tupian')
|
||||||
|
|
||||||
for item in shensu_queryset:
|
for item in shensu_queryset:
|
||||||
@@ -7064,7 +7064,7 @@ class KefuGetOrderListView(APIView):
|
|||||||
laoban_ids = [o.pingtai_kuozhan.laoban_id for o in orders_qs if hasattr(o, 'pingtai_kuozhan') and o.pingtai_kuozhan.laoban_id]
|
laoban_ids = [o.pingtai_kuozhan.laoban_id for o in orders_qs if hasattr(o, 'pingtai_kuozhan') and o.pingtai_kuozhan.laoban_id]
|
||||||
nickname_map = {}
|
nickname_map = {}
|
||||||
if laoban_ids:
|
if laoban_ids:
|
||||||
users = User.query.filter(yonghuid__in=laoban_ids).select_related('boss_profile').only(
|
users = User.query.filter(UserUID__in=laoban_ids).select_related('boss_profile').only(
|
||||||
'yonghuid', 'boss_profile__nickname'
|
'yonghuid', 'boss_profile__nickname'
|
||||||
)
|
)
|
||||||
for user in users:
|
for user in users:
|
||||||
@@ -7233,7 +7233,7 @@ class KefuGetShangjiaOrderListView(APIView):
|
|||||||
shangjia_ids = [o.shangjia_kuozhan.shangjia_id for o in orders_qs if hasattr(o, 'shangjia_kuozhan') and o.shangjia_kuozhan.shangjia_id]
|
shangjia_ids = [o.shangjia_kuozhan.shangjia_id for o in orders_qs if hasattr(o, 'shangjia_kuozhan') and o.shangjia_kuozhan.shangjia_id]
|
||||||
nickname_map = {}
|
nickname_map = {}
|
||||||
if shangjia_ids:
|
if shangjia_ids:
|
||||||
users = User.query.filter(yonghuid__in=shangjia_ids).select_related('shop_profile').only(
|
users = User.query.filter(UserUID__in=shangjia_ids).select_related('shop_profile').only(
|
||||||
'yonghuid', 'shop_profile__nicheng'
|
'yonghuid', 'shop_profile__nicheng'
|
||||||
)
|
)
|
||||||
for user in users:
|
for user in users:
|
||||||
@@ -7339,7 +7339,7 @@ class KefuChangeDashouView(APIView):
|
|||||||
|
|
||||||
# 5. 查询新打手
|
# 5. 查询新打手
|
||||||
try:
|
try:
|
||||||
new_dashou_user = User.query.get(yonghuid=new_dashou_id)
|
new_dashou_user = User.query.get(UserUID=new_dashou_id)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '打手不存在'}, status=status.HTTP_404_NOT_FOUND)
|
return Response({'code': 404, 'msg': '打手不存在'}, status=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
@@ -7401,7 +7401,7 @@ class KefuChangeDashouView(APIView):
|
|||||||
old_dashou_id = order.jiedan_dashou_id
|
old_dashou_id = order.jiedan_dashou_id
|
||||||
if old_dashou_id:
|
if old_dashou_id:
|
||||||
try:
|
try:
|
||||||
old_dashou_user = User.query.get(yonghuid=old_dashou_id)
|
old_dashou_user = User.query.get(UserUID=old_dashou_id)
|
||||||
old_dashou_profile = old_dashou_user.dashou_profile
|
old_dashou_profile = old_dashou_user.dashou_profile
|
||||||
old_dashou_profile.zhuangtai = 1 # 恢复空闲
|
old_dashou_profile.zhuangtai = 1 # 恢复空闲
|
||||||
old_dashou_profile.tuikuanliang += 1 # 原打手退款总量+1(业务逻辑)
|
old_dashou_profile.tuikuanliang += 1 # 原打手退款总量+1(业务逻辑)
|
||||||
@@ -7577,7 +7577,7 @@ class KefuPlatformRefundView(APIView):
|
|||||||
jiedan_dashou_id = order.jiedan_dashou_id
|
jiedan_dashou_id = order.jiedan_dashou_id
|
||||||
if jiedan_dashou_id:
|
if jiedan_dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.tuikuanliang += 1
|
dashou_profile.tuikuanliang += 1
|
||||||
dashou_profile.zhuangtai = 1 # 打手状态设为空闲
|
dashou_profile.zhuangtai = 1 # 打手状态设为空闲
|
||||||
@@ -7842,7 +7842,7 @@ class KefuRejectRefundView(APIView):
|
|||||||
# 7. 给打手结算(返还分成)
|
# 7. 给打手结算(返还分成)
|
||||||
if jiedan_dashou_id:
|
if jiedan_dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
# 增加打手相关统计数据
|
# 增加打手相关统计数据
|
||||||
dashou_profile.chengjiaozongliang += 1
|
dashou_profile.chengjiaozongliang += 1
|
||||||
@@ -7862,7 +7862,7 @@ class KefuRejectRefundView(APIView):
|
|||||||
shangjia_kuozhan = order.shangjia_kuozhan
|
shangjia_kuozhan = order.shangjia_kuozhan
|
||||||
shangjia_id = shangjia_kuozhan.shangjia_id
|
shangjia_id = shangjia_kuozhan.shangjia_id
|
||||||
if shangjia_id:
|
if shangjia_id:
|
||||||
shangjia_user = User.query.get(yonghuid=shangjia_id)
|
shangjia_user = User.query.get(UserUID=shangjia_id)
|
||||||
shangjia_profile = shangjia_user.shop_profile
|
shangjia_profile = shangjia_user.shop_profile
|
||||||
shangjia_profile.chengjiao += 1
|
shangjia_profile.chengjiao += 1
|
||||||
shangjia_profile.save()
|
shangjia_profile.save()
|
||||||
@@ -8019,7 +8019,7 @@ class KefuMerchantRefundView(APIView):
|
|||||||
# 更新打手
|
# 更新打手
|
||||||
if jiedan_dashou_id:
|
if jiedan_dashou_id:
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.tuikuanliang += 1
|
dashou_profile.tuikuanliang += 1
|
||||||
dashou_profile.zhuangtai = 1
|
dashou_profile.zhuangtai = 1
|
||||||
@@ -8029,7 +8029,7 @@ class KefuMerchantRefundView(APIView):
|
|||||||
|
|
||||||
# 更新商家
|
# 更新商家
|
||||||
try:
|
try:
|
||||||
shangjia_user = User.query.get(yonghuid=shangjia_id)
|
shangjia_user = User.query.get(UserUID=shangjia_id)
|
||||||
shangjia_profile = shangjia_user.shop_profile
|
shangjia_profile = shangjia_user.shop_profile
|
||||||
shangjia_profile.tuikuan += 1
|
shangjia_profile.tuikuan += 1
|
||||||
shangjia_profile.yue += jine
|
shangjia_profile.yue += jine
|
||||||
@@ -8156,7 +8156,7 @@ class KefuRejectSettlementView(APIView):
|
|||||||
|
|
||||||
# 5.3 更新打手扩展表
|
# 5.3 更新打手扩展表
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
dashou_user = User.query.get(UserUID=jiedan_dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
dashou_profile.zhuangtai = 1 # 打手状态设为空闲
|
dashou_profile.zhuangtai = 1 # 打手状态设为空闲
|
||||||
dashou_profile.tuikuanliang += 1 # 退款订单总量+1
|
dashou_profile.tuikuanliang += 1 # 退款订单总量+1
|
||||||
@@ -8240,7 +8240,7 @@ class KefuTransferHallView(APIView):
|
|||||||
|
|
||||||
|
|
||||||
if order.jiedan_dashou_id:
|
if order.jiedan_dashou_id:
|
||||||
UserDashou.query.filter(user__yonghuid=order.jiedan_dashou_id).update(zhuangtai=1)
|
UserDashou.query.filter(user__UserUID=order.jiedan_dashou_id).update(zhuangtai=1)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -8617,7 +8617,7 @@ class KefuUpdateDashouView(APIView):
|
|||||||
|
|
||||||
# 3. 查询打手是否存在
|
# 3. 查询打手是否存在
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id, user_type='dashou')
|
dashou_user = User.query.get(UserUID=dashou_id, user_type='dashou')
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '打手不存在'})
|
return Response({'code': 404, 'msg': '打手不存在'})
|
||||||
@@ -9189,11 +9189,11 @@ class KefuPunishmentDetailView(APIView):
|
|||||||
shensu_images = []
|
shensu_images = []
|
||||||
try:
|
try:
|
||||||
# 商家证据图片:上传者为请求人 (qingqiuid)
|
# 商家证据图片:上传者为请求人 (qingqiuid)
|
||||||
zhengju_qs = Chufatupian.query.filter(dingdan_id=dingdan_id, yonghuid=record.qingqiuid)
|
zhengju_qs = Chufatupian.query.filter(dingdan_id=dingdan_id, UserUID=record.qingqiuid)
|
||||||
zhengju_images = [item.tupian for item in zhengju_qs if item.tupian]
|
zhengju_images = [item.tupian for item in zhengju_qs if item.tupian]
|
||||||
|
|
||||||
# 打手申诉图片:上传者为打手 (dashouid)
|
# 打手申诉图片:上传者为打手 (dashouid)
|
||||||
shensu_qs = Chufatupian.query.filter(dingdan_id=dingdan_id, yonghuid=record.dashouid)
|
shensu_qs = Chufatupian.query.filter(dingdan_id=dingdan_id, UserUID=record.dashouid)
|
||||||
shensu_images = [item.tupian for item in shensu_qs if item.tupian]
|
shensu_images = [item.tupian for item in shensu_qs if item.tupian]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"查询图片失败: {e}")
|
logger.error(f"查询图片失败: {e}")
|
||||||
@@ -9294,7 +9294,7 @@ class KefuPunishmentActionView(APIView):
|
|||||||
# 可选验证打手存在
|
# 可选验证打手存在
|
||||||
if record.dashouid:
|
if record.dashouid:
|
||||||
try:
|
try:
|
||||||
dashou = UserDashou.query.get(user__yonghuid=record.dashouid)
|
dashou = UserDashou.query.get(user__UserUID=record.dashouid)
|
||||||
except UserDashou.DoesNotExist:
|
except UserDashou.DoesNotExist:
|
||||||
return Response({'code': 400, 'msg': '被处罚打手不存在'}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'code': 400, 'msg': '被处罚打手不存在'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
@@ -9315,7 +9315,7 @@ class KefuPunishmentActionView(APIView):
|
|||||||
# 返还积分
|
# 返还积分
|
||||||
if record.jifen > 0 and record.dashouid:
|
if record.jifen > 0 and record.dashouid:
|
||||||
try:
|
try:
|
||||||
dashou = UserDashou.query.get(user__yonghuid=record.dashouid)
|
dashou = UserDashou.query.get(user__UserUID=record.dashouid)
|
||||||
if dashou.jifen <= 1000: # 安全限制
|
if dashou.jifen <= 1000: # 安全限制
|
||||||
dashou.jifen += record.jifen
|
dashou.jifen += record.jifen
|
||||||
dashou.save()
|
dashou.save()
|
||||||
@@ -9410,7 +9410,7 @@ class KefuForceCompleteView(APIView):
|
|||||||
|
|
||||||
# 5. 给打手结算
|
# 5. 给打手结算
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou_profile = dashou_user.dashou_profile
|
dashou_profile = dashou_user.dashou_profile
|
||||||
# 原子更新(避免并发重复加)
|
# 原子更新(避免并发重复加)
|
||||||
dashou_profile.chengjiaozongliang = F('chengjiaozongliang') + 1
|
dashou_profile.chengjiaozongliang = F('chengjiaozongliang') + 1
|
||||||
@@ -9431,7 +9431,7 @@ class KefuForceCompleteView(APIView):
|
|||||||
# 通过 DingdanShangjia 获取商家ID
|
# 通过 DingdanShangjia 获取商家ID
|
||||||
shangjia_ext = order.shangjia_kuozhan # 假设 related_name='shangjia_kuozhan'
|
shangjia_ext = order.shangjia_kuozhan # 假设 related_name='shangjia_kuozhan'
|
||||||
if shangjia_ext and shangjia_ext.shangjia_id:
|
if shangjia_ext and shangjia_ext.shangjia_id:
|
||||||
shangjia_user = User.query.get(yonghuid=shangjia_ext.shangjia_id)
|
shangjia_user = User.query.get(UserUID=shangjia_ext.shangjia_id)
|
||||||
shangjia_profile = shangjia_user.shop_profile
|
shangjia_profile = shangjia_user.shop_profile
|
||||||
shangjia_profile.chengjiao = F('chengjiao') + 1
|
shangjia_profile.chengjiao = F('chengjiao') + 1
|
||||||
shangjia_profile.save(update_fields=['chengjiao'])
|
shangjia_profile.save(update_fields=['chengjiao'])
|
||||||
@@ -9874,7 +9874,7 @@ class KefuWithdrawDetailView(APIView):
|
|||||||
|
|
||||||
# 查询用户主表
|
# 查询用户主表
|
||||||
try:
|
try:
|
||||||
user = User.query.get(yonghuid=record.yonghuid)
|
user = User.query.get(UserUID=record.yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
@@ -10047,7 +10047,7 @@ class KefuWithdrawActionView(APIView):
|
|||||||
raise ValueError(f'提现记录{tixian_id}:审核记录非审核中状态')
|
raise ValueError(f'提现记录{tixian_id}:审核记录非审核中状态')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = User.objects.select_for_update().get(yonghuid=req_yonghuid)
|
user = User.objects.select_for_update().get(UserUID=req_yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
raise ValueError(f'用户{req_yonghuid}不存在')
|
raise ValueError(f'用户{req_yonghuid}不存在')
|
||||||
|
|
||||||
@@ -10100,7 +10100,7 @@ class KefuWithdrawActionView(APIView):
|
|||||||
raise ValueError(f'提现记录{tixian_id}:自动打款请走自动流程')
|
raise ValueError(f'提现记录{tixian_id}:自动打款请走自动流程')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = User.query.get(yonghuid=tixian.yonghuid)
|
user = User.query.get(UserUID=tixian.yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
raise ValueError(f'用户{tixian.yonghuid}不存在')
|
raise ValueError(f'用户{tixian.yonghuid}不存在')
|
||||||
|
|
||||||
@@ -10247,7 +10247,7 @@ class KefuPunishView(APIView):
|
|||||||
|
|
||||||
# 5. 查询打手
|
# 5. 查询打手
|
||||||
try:
|
try:
|
||||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
dashou_user = User.query.get(UserUID=dashou_id)
|
||||||
dashou = dashou_user.dashou_profile
|
dashou = dashou_user.dashou_profile
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return Response({'code': 404, 'msg': '打手用户不存在'}, status=status.HTTP_404_NOT_FOUND)
|
return Response({'code': 404, 'msg': '打手用户不存在'}, status=status.HTTP_404_NOT_FOUND)
|
||||||
@@ -10329,7 +10329,7 @@ class AdKftjView(APIView):
|
|||||||
timestamp = str(int(time.time()))[-5:]
|
timestamp = str(int(time.time()))[-5:]
|
||||||
rand = str(random.randint(0, 99)).zfill(2)
|
rand = str(random.randint(0, 99)).zfill(2)
|
||||||
uid = timestamp + rand
|
uid = timestamp + rand
|
||||||
if len(uid) == 7 and not User.query.filter(yonghuid=uid).exists():
|
if len(uid) == 7 and not User.query.filter(UserUID=uid).exists():
|
||||||
return uid
|
return uid
|
||||||
raise Exception('无法生成唯一用户ID')
|
raise Exception('无法生成唯一用户ID')
|
||||||
|
|
||||||
@@ -10645,7 +10645,7 @@ class WechatLoginAndGuanshiRegisterView(APIView):
|
|||||||
random_part = str(random.randint(0, 99)).zfill(2)
|
random_part = str(random.randint(0, 99)).zfill(2)
|
||||||
user_id = timestamp_part + random_part
|
user_id = timestamp_part + random_part
|
||||||
if len(user_id) == 7 and user_id.isdigit():
|
if len(user_id) == 7 and user_id.isdigit():
|
||||||
if not User.query.filter(yonghuid=user_id).exists():
|
if not User.query.filter(UserUID=user_id).exists():
|
||||||
return user_id
|
return user_id
|
||||||
raise Exception('生成用户ID失败')
|
raise Exception('生成用户ID失败')
|
||||||
|
|
||||||
@@ -11931,7 +11931,7 @@ class FaKuanPayPollView(APIView):
|
|||||||
if not dingdanid:
|
if not dingdanid:
|
||||||
return Response({'code': 400, 'message': '订单ID不能为空'})
|
return Response({'code': 400, 'message': '订单ID不能为空'})
|
||||||
|
|
||||||
order = Czjilu.query.get(dingdan_id=dingdanid, yonghuid=request.user.yonghuid)
|
order = Czjilu.query.get(dingdan_id=dingdanid, UserUID=request.user.yonghuid)
|
||||||
if order.zhuangtai == 3:
|
if order.zhuangtai == 3:
|
||||||
return Response({'code': 200, 'message': '支付成功'})
|
return Response({'code': 200, 'message': '支付成功'})
|
||||||
else:
|
else:
|
||||||
@@ -11954,7 +11954,7 @@ class FaKuanPayFailView(APIView):
|
|||||||
if not dingdanid:
|
if not dingdanid:
|
||||||
return Response({'code': 400, 'message': '订单ID不能为空'})
|
return Response({'code': 400, 'message': '订单ID不能为空'})
|
||||||
|
|
||||||
order = Czjilu.query.get(dingdan_id=dingdanid, yonghuid=request.user.yonghuid)
|
order = Czjilu.query.get(dingdan_id=dingdanid, UserUID=request.user.yonghuid)
|
||||||
if order.zhuangtai == 9: # 未支付
|
if order.zhuangtai == 9: # 未支付
|
||||||
order.delete()
|
order.delete()
|
||||||
logger.info(f"用户{request.user.yonghuid}删除未支付订单: {dingdanid}")
|
logger.info(f"用户{request.user.yonghuid}删除未支付订单: {dingdanid}")
|
||||||
@@ -12004,7 +12004,7 @@ class KaohePayView(APIView):
|
|||||||
|
|
||||||
# 1. 检查是否有未支付的考核订单
|
# 1. 检查是否有未支付的考核订单
|
||||||
"""unpaid_order = Czjilu.query.filter(
|
"""unpaid_order = Czjilu.query.filter(
|
||||||
yonghuid=user.yonghuid,
|
UserUID=user.yonghuid,
|
||||||
leixing=5,
|
leixing=5,
|
||||||
zhuangtai=9
|
zhuangtai=9
|
||||||
).exists()
|
).exists()
|
||||||
@@ -12366,10 +12366,10 @@ class KaohePayCallbackView(View):
|
|||||||
|
|
||||||
# 从临时表获取业务参数并创建审核记录
|
# 从临时表获取业务参数并创建审核记录
|
||||||
try:
|
try:
|
||||||
temp = KaohePayTemp.query.get(dingdan_id=out_trade_no, yonghuid=order.yonghuid)
|
temp = KaohePayTemp.query.get(dingdan_id=out_trade_no, UserUID=order.yonghuid)
|
||||||
logger.info(f"找到临时表记录: {out_trade_no}, 用户ID: {order.yonghuid}")
|
logger.info(f"找到临时表记录: {out_trade_no}, 用户ID: {order.yonghuid}")
|
||||||
|
|
||||||
user = User.query.get(yonghuid=order.yonghuid)
|
user = User.query.get(UserUID=order.yonghuid)
|
||||||
logger.info(f"获取用户信息成功: {user.yonghuid}")
|
logger.info(f"获取用户信息成功: {user.yonghuid}")
|
||||||
|
|
||||||
success, msg, record = create_shenhe_jilu_from_temp(user, temp)
|
success, msg, record = create_shenhe_jilu_from_temp(user, temp)
|
||||||
@@ -12486,7 +12486,7 @@ class KaohePayPollView(APIView):
|
|||||||
if not dingdanid:
|
if not dingdanid:
|
||||||
return Response({'code': 400, 'message': '订单ID不能为空'})
|
return Response({'code': 400, 'message': '订单ID不能为空'})
|
||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(dingdan_id=dingdanid, yonghuid=request.user.yonghuid, leixing=5)
|
order = Czjilu.query.get(dingdan_id=dingdanid, UserUID=request.user.yonghuid, leixing=5)
|
||||||
if order.zhuangtai == 3:
|
if order.zhuangtai == 3:
|
||||||
return Response({'code': 200, 'message': '支付成功'})
|
return Response({'code': 200, 'message': '支付成功'})
|
||||||
return Response({'code': 400, 'message': '订单尚未支付'})
|
return Response({'code': 400, 'message': '订单尚未支付'})
|
||||||
@@ -12503,7 +12503,7 @@ class KaohePayFailView(APIView):
|
|||||||
if not dingdanid:
|
if not dingdanid:
|
||||||
return Response({'code': 400, 'message': '订单ID不能为空'})
|
return Response({'code': 400, 'message': '订单ID不能为空'})
|
||||||
try:
|
try:
|
||||||
order = Czjilu.query.get(dingdan_id=dingdanid, yonghuid=request.user.yonghuid, leixing=5)
|
order = Czjilu.query.get(dingdan_id=dingdanid, UserUID=request.user.yonghuid, leixing=5)
|
||||||
if order.zhuangtai == 9:
|
if order.zhuangtai == 9:
|
||||||
order.delete()
|
order.delete()
|
||||||
return Response({'code': 200, 'message': '订单已删除'})
|
return Response({'code': 200, 'message': '订单已删除'})
|
||||||
@@ -12676,7 +12676,7 @@ class GuanshiContactView(APIView):
|
|||||||
|
|
||||||
# 4. 根据邀请人用户ID查询用户主表
|
# 4. 根据邀请人用户ID查询用户主表
|
||||||
try:
|
try:
|
||||||
inviter_user = User.query.get(yonghuid=inviter_yonghuid)
|
inviter_user = User.query.get(UserUID=inviter_yonghuid)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
logger.error(f"邀请人用户不存在: yonghuid={inviter_yonghuid}")
|
logger.error(f"邀请人用户不存在: yonghuid={inviter_yonghuid}")
|
||||||
return Response({
|
return Response({
|
||||||
@@ -12855,7 +12855,7 @@ class TixianQueRenAutoView(APIView):
|
|||||||
try:
|
try:
|
||||||
auto_record = TixianAutoRecord.objects.select_for_update().get(
|
auto_record = TixianAutoRecord.objects.select_for_update().get(
|
||||||
tixian_id=tixian_id,
|
tixian_id=tixian_id,
|
||||||
yonghuid=user_main.yonghuid,
|
UserUID=user_main.yonghuid,
|
||||||
)
|
)
|
||||||
except TixianAutoRecord.DoesNotExist:
|
except TixianAutoRecord.DoesNotExist:
|
||||||
return Response({'code': 4, 'msg': '提现记录不存在'}, status=status.HTTP_404_NOT_FOUND)
|
return Response({'code': 4, 'msg': '提现记录不存在'}, status=status.HTTP_404_NOT_FOUND)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ def establish_order_chat(dingdan_id):
|
|||||||
dashou_nickname = f'打手{dashou_uid[:6]}'
|
dashou_nickname = f'打手{dashou_uid[:6]}'
|
||||||
dashou_avatar_relative = ''
|
dashou_avatar_relative = ''
|
||||||
try:
|
try:
|
||||||
dashou_user = User.objects.get(yonghuid=dashou_uid)
|
dashou_user = User.objects.get(UserUID=dashou_uid)
|
||||||
dashou_avatar_relative = dashou_user.avatar or ''
|
dashou_avatar_relative = dashou_user.avatar or ''
|
||||||
dashou_profile = UserDashou.objects.get(user=dashou_user)
|
dashou_profile = UserDashou.objects.get(user=dashou_user)
|
||||||
if dashou_profile.nicheng:
|
if dashou_profile.nicheng:
|
||||||
@@ -166,7 +166,7 @@ def _get_local_partner_info(order):
|
|||||||
avatar_full = _full_local_avatar('')
|
avatar_full = _full_local_avatar('')
|
||||||
nickname = f'老板{laoban_id[:6]}'
|
nickname = f'老板{laoban_id[:6]}'
|
||||||
try:
|
try:
|
||||||
boss_user = User.objects.get(yonghuid=laoban_id)
|
boss_user = User.objects.get(UserUID=laoban_id)
|
||||||
avatar_full = _full_local_avatar(boss_user.avatar or '')
|
avatar_full = _full_local_avatar(boss_user.avatar or '')
|
||||||
boss_profile = UserBoss.objects.get(user=boss_user)
|
boss_profile = UserBoss.objects.get(user=boss_user)
|
||||||
if boss_profile.nickname:
|
if boss_profile.nickname:
|
||||||
@@ -184,7 +184,7 @@ def _get_local_partner_info(order):
|
|||||||
nickname = ext.sjnicheng or f'商家{shangjia_id[:6]}'
|
nickname = ext.sjnicheng or f'商家{shangjia_id[:6]}'
|
||||||
avatar_full = _full_local_avatar('')
|
avatar_full = _full_local_avatar('')
|
||||||
try:
|
try:
|
||||||
sj_user = User.objects.get(yonghuid=shangjia_id)
|
sj_user = User.objects.get(UserUID=shangjia_id)
|
||||||
avatar_full = _full_local_avatar(sj_user.avatar or '')
|
avatar_full = _full_local_avatar(sj_user.avatar or '')
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
49
verify_fixes.py
Normal file
49
verify_fixes.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""验证所有兼容性修复"""
|
||||||
|
import os; os.environ['DJANGO_SETTINGS_MODULE']='a_long_dianjing.settings'
|
||||||
|
import django; django.setup()
|
||||||
|
from gvsdsdk.models import User
|
||||||
|
from rest_framework_simplejwt.tokens import RefreshToken
|
||||||
|
from rest_framework_simplejwt.authentication import JWTAuthentication
|
||||||
|
from unittest.mock import Mock
|
||||||
|
|
||||||
|
u = User.objects.filter(UserName__isnull=False).first()
|
||||||
|
print(f'测试用户: {u.UserName}, UserUID: {u.UserUID}')
|
||||||
|
|
||||||
|
# 1. JWT 认证
|
||||||
|
refresh = RefreshToken.for_user(u)
|
||||||
|
access = refresh.access_token
|
||||||
|
print('1. JWT Token 生成成功')
|
||||||
|
|
||||||
|
auth = JWTAuthentication()
|
||||||
|
request = Mock()
|
||||||
|
request.META = {'HTTP_AUTHORIZATION': f'Bearer {access}'}
|
||||||
|
request._request = request
|
||||||
|
validated_user, _ = auth.authenticate(request)
|
||||||
|
print(f' JWT 验证成功: {validated_user.UserName}')
|
||||||
|
|
||||||
|
# 2. yonghuid 兼容属性
|
||||||
|
print(f'2. yonghuid: {u.yonghuid}')
|
||||||
|
|
||||||
|
# 3. dashou_profile
|
||||||
|
dp = u.dashou_profile
|
||||||
|
print(f'3. dashou_profile: {dp}')
|
||||||
|
|
||||||
|
# 4. shoujihao_renzheng
|
||||||
|
print(f'4. shoujihao_renzheng: {u.shoujihao_renzheng}')
|
||||||
|
|
||||||
|
# 5. user_type
|
||||||
|
print(f'5. user_type: {u.user_type}')
|
||||||
|
|
||||||
|
# 6. User.query.get(UserUID=...)
|
||||||
|
u2 = User.query.get(UserUID=u.UserUID)
|
||||||
|
print(f'6. User.query.get(UserUID=...) OK: {u2.UserName}')
|
||||||
|
|
||||||
|
# 7. user.id
|
||||||
|
print(f'7. user.id: {u.id}, bool: {bool(u.id)}')
|
||||||
|
|
||||||
|
# 8. has_role
|
||||||
|
print(f'8. has_role(dashou): {u.has_role("dashou")}')
|
||||||
|
|
||||||
|
print()
|
||||||
|
print('所有兼容性测试通过!')
|
||||||
Reference in New Issue
Block a user