进行了 GVSDSDK 迁移,可能存在诸多问题
This commit is contained in:
@@ -62,7 +62,8 @@ from orders.models import (
|
||||
Lilubiao, Pingfen, Tuikuanjilu
|
||||
)
|
||||
from products.models import Shangpin, ShangpinLeixing, Huiyuangoumai
|
||||
from users.models import UserMain, UserDashou, UserShangjia, UserBoss
|
||||
from users.models import UserDashou, UserShangjia, UserBoss
|
||||
from gvsdsdk.models import User
|
||||
from rank.models import DashouBiaoxian, Chenghao, DingdanBiaoqian, YonghuChenghao
|
||||
from config.models import (
|
||||
Szjilu, ShangjiaLianjie
|
||||
@@ -240,7 +241,7 @@ class WechatPayNotifyView(APIView):
|
||||
if hasattr(dingdan, 'pingtai_kuozhan'):
|
||||
laoban_id = dingdan.pingtai_kuozhan.laoban_id
|
||||
if laoban_id:
|
||||
user_main = UserMain.query.filter(yonghuid=laoban_id).first()
|
||||
user_main = User.query.filter(yonghuid=laoban_id).first()
|
||||
if user_main and hasattr(user_main, 'boss_profile'):
|
||||
boss = user_main.boss_profile
|
||||
boss.zonge = (boss.zonge or 0) + (dingdan.jine or 0)
|
||||
@@ -524,7 +525,7 @@ class PaymentVerifyView(APIView):
|
||||
# 更新老板扩展表
|
||||
laoban_id = dingdan.pingtai_kuozhan.laoban_id if hasattr(dingdan, 'pingtai_kuozhan') else None
|
||||
if laoban_id:
|
||||
user_main = UserMain.query.filter(yonghuid=laoban_id).first()
|
||||
user_main = User.query.filter(yonghuid=laoban_id).first()
|
||||
if user_main and hasattr(user_main, 'boss_profile'):
|
||||
boss = user_main.boss_profile
|
||||
boss.zonge = (boss.zonge or 0) + (dingdan.jine or 0)
|
||||
@@ -710,7 +711,7 @@ class CreateOrderView(APIView):
|
||||
zhiding_id_value = None
|
||||
if zhiding:
|
||||
# 查询主表中是否存在该打手
|
||||
zhiding_user = UserMain.query.filter(
|
||||
zhiding_user = User.query.filter(
|
||||
yonghuid=zhiding,
|
||||
#user_type='dashou'
|
||||
).first()
|
||||
@@ -1348,7 +1349,7 @@ class JiedanView(APIView):
|
||||
# 7. 更新打手扩展表(如果有打手ID和分成)
|
||||
if jiedan_dashou_id and dashou_fencheng > 0:
|
||||
# 查询打手用户
|
||||
dashou_user = UserMain.query.filter(yonghuid=jiedan_dashou_id).first()
|
||||
dashou_user = User.query.filter(yonghuid=jiedan_dashou_id).first()
|
||||
|
||||
if dashou_user:
|
||||
# 查询打手扩展表
|
||||
@@ -1511,7 +1512,7 @@ class DingdanXiangqingView2(APIView):
|
||||
jiedan_time = ''
|
||||
tijiao_time = ''
|
||||
if jiedan_dashou_id:
|
||||
dashou_user = UserMain.query.filter(yonghuid=jiedan_dashou_id).first()
|
||||
dashou_user = User.query.filter(yonghuid=jiedan_dashou_id).first()
|
||||
if dashou_user:
|
||||
dashou_touxiang = dashou_user.avatar or ''
|
||||
try:
|
||||
@@ -1660,7 +1661,7 @@ class JiedanView2(APIView):
|
||||
|
||||
# 9. 更新打手收益与状态
|
||||
if jiedan_dashou_id and dashou_fencheng > 0:
|
||||
dashou_user = UserMain.query.filter(yonghuid=jiedan_dashou_id).first()
|
||||
dashou_user = User.query.filter(yonghuid=jiedan_dashou_id).first()
|
||||
if dashou_user:
|
||||
try:
|
||||
dashou_ext = dashou_user.dashou_profile
|
||||
@@ -1915,11 +1916,11 @@ class ShangjiaPaifaView(APIView):
|
||||
zhiding_dashou = None
|
||||
if zhiding_uid:
|
||||
try:
|
||||
zhiding_user = UserMain.query.get(yonghuid=zhiding_uid)
|
||||
zhiding_user = User.query.get(yonghuid=zhiding_uid)
|
||||
zhiding_dashou = zhiding_user.dashou_profile
|
||||
if zhiding_dashou.zhanghaozhuangtai != 1:
|
||||
return Response({'code': 400, 'msg': '指定打手状态异常'})
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
return Response({'code': 400, 'msg': '指定用户不存在'})
|
||||
except UserDashou.DoesNotExist:
|
||||
return Response({'code': 400, 'msg': '指定用户不是打手'})
|
||||
@@ -2221,7 +2222,7 @@ class ShangjiaDingdanXiangqingView(APIView):
|
||||
dashou_nicheng = ''
|
||||
dashou_avatar = ''
|
||||
if dashou_yonghuid:
|
||||
dashou_user = UserMain.query.filter(
|
||||
dashou_user = User.query.filter(
|
||||
yonghuid=dashou_yonghuid
|
||||
).select_related('dashou_profile').first()
|
||||
if dashou_user:
|
||||
@@ -2425,9 +2426,9 @@ class ShangjiaJiesuanView(APIView):
|
||||
# ========== 本地订单正常结算给打手 ==========
|
||||
# 查询打手信息
|
||||
try:
|
||||
dashou_user = UserMain.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou = dashou_user.dashou_profile
|
||||
except (UserMain.DoesNotExist, UserDashou.DoesNotExist):
|
||||
except (User.DoesNotExist, UserDashou.DoesNotExist):
|
||||
return Response({
|
||||
'code': 8,
|
||||
'msg': '接单打手不存在或信息不完整',
|
||||
@@ -2767,7 +2768,7 @@ class ShangjiaTuikuanShenqingView(APIView):
|
||||
# ====== 原有功能:更新打手状态 ======
|
||||
if dingdan.jiedan_dashou_id:
|
||||
try:
|
||||
dashou_main = UserMain.query.filter(
|
||||
dashou_main = User.query.filter(
|
||||
yonghuid=dingdan.jiedan_dashou_id
|
||||
).first()
|
||||
if dashou_main and hasattr(dashou_main, 'dashou_profile'):
|
||||
@@ -2850,9 +2851,9 @@ class ShangjiaChufaShenqingView(APIView):
|
||||
with transaction.atomic():
|
||||
# 验证打手身份
|
||||
try:
|
||||
dashou_user = UserMain.query.get(yonghuid=dashou_id)
|
||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
||||
dashou = dashou_user.dashou_profile
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
return Response({
|
||||
'code': 5,
|
||||
'msg': '打手用户不存在',
|
||||
@@ -3028,7 +3029,7 @@ class DashouDingdanHuoquView(APIView):
|
||||
zhiding_ids = {item['zhiding_id'] for item in dingdan_list if item.get('zhiding_id')}
|
||||
zhiding_info = {}
|
||||
if zhiding_ids:
|
||||
dashou_query = UserMain.query.filter(
|
||||
dashou_query = User.query.filter(
|
||||
yonghuid__in=zhiding_ids
|
||||
).select_related('dashou_profile').annotate(
|
||||
nicheng=F('dashou_profile__nicheng')
|
||||
@@ -3078,10 +3079,10 @@ class DashouDingdanHuoquView(APIView):
|
||||
if sj['shangjia_id']:
|
||||
yonghuid_set.add(sj['shangjia_id'])
|
||||
|
||||
# 将 yonghuid 字符串转换为 UserMain 的主键 id
|
||||
# 将 yonghuid 字符串转换为 User 的主键 id
|
||||
user_id_map = {}
|
||||
if yonghuid_set:
|
||||
users = UserMain.query.filter(yonghuid__in=yonghuid_set).values('id', 'yonghuid')
|
||||
users = User.query.filter(yonghuid__in=yonghuid_set).values('id', 'yonghuid')
|
||||
for u in users:
|
||||
user_id_map[u['yonghuid']] = u['id']
|
||||
|
||||
@@ -3346,8 +3347,8 @@ def send_group_message(
|
||||
def check_user_permission(identity_type, uid, order):
|
||||
"""验证用户身份、账号状态、以及是否属于该订单"""
|
||||
try:
|
||||
user = UserMain.query.get(yonghuid=uid)
|
||||
except UserMain.DoesNotExist:
|
||||
user = User.query.get(yonghuid=uid)
|
||||
except User.DoesNotExist:
|
||||
return False, '用户不存在'
|
||||
|
||||
if identity_type == 'dashou':
|
||||
@@ -4672,11 +4673,11 @@ class AdGengHuanDaShou(APIView):
|
||||
|
||||
# 8. 验证新打手ID是否存在,并且是打手身份
|
||||
try:
|
||||
new_dashou_user = UserMain.query.get(
|
||||
new_dashou_user = User.query.get(
|
||||
yonghuid=new_dashou_id,
|
||||
#user_type='dashou'
|
||||
)
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
return Response(
|
||||
{'code': 404, 'message': '打手不存在或不是打手身份', 'data': None},
|
||||
status=status.HTTP_404_NOT_FOUND
|
||||
@@ -4767,7 +4768,7 @@ class AdGengHuanDaShou(APIView):
|
||||
if old_dashou_id:
|
||||
try:
|
||||
# 查询原打手主表
|
||||
old_dashou_user = UserMain.query.get(
|
||||
old_dashou_user = User.query.get(
|
||||
yonghuid=old_dashou_id,
|
||||
#user_type='dashou'
|
||||
)
|
||||
@@ -4781,7 +4782,7 @@ class AdGengHuanDaShou(APIView):
|
||||
old_dashou_profile.save()
|
||||
|
||||
logger.info(f"成功更新原打手{old_dashou_id}状态")
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
# 原打手不存在,继续执行不影响更换
|
||||
logger.warning(f"原打手{old_dashou_id}不存在,跳过更新")
|
||||
except AttributeError:
|
||||
@@ -4911,7 +4912,7 @@ class AdQiangZhiJieDan(APIView):
|
||||
if jiedan_dashou_id:
|
||||
try:
|
||||
# 查询打手用户主表
|
||||
dashou_user = UserMain.query.get(
|
||||
dashou_user = User.query.get(
|
||||
yonghuid=jiedan_dashou_id,
|
||||
#user_type='dashou'
|
||||
)
|
||||
@@ -4938,7 +4939,7 @@ class AdQiangZhiJieDan(APIView):
|
||||
dashou_profile.save()
|
||||
logger.info(f"强制结单成功,打手{jiedan_dashou_id}结算分成:{dashou_fencheng}")
|
||||
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
# 打手用户不存在,记录日志但不影响强制结单
|
||||
logger.warning(f"强制结单:打手{jiedan_dashou_id}不存在,跳过打手结算")
|
||||
except AttributeError:
|
||||
@@ -4954,7 +4955,7 @@ class AdQiangZhiJieDan(APIView):
|
||||
|
||||
if shangjia_id:
|
||||
# 查询商家用户主表
|
||||
shangjia_user = UserMain.query.get(
|
||||
shangjia_user = User.query.get(
|
||||
yonghuid=shangjia_id,
|
||||
#user_type='shop'
|
||||
)
|
||||
@@ -4971,7 +4972,7 @@ class AdQiangZhiJieDan(APIView):
|
||||
except DingdanShangjia.DoesNotExist:
|
||||
# 商家订单扩展表不存在,跳过商家更新
|
||||
logger.warning(f"强制结单:订单{dingdan_id}商家扩展表不存在,跳过商家更新")
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
# 商家用户不存在,跳过商家更新
|
||||
logger.warning(f"强制结单:商家{shangjia_id}不存在,跳过商家更新")
|
||||
except AttributeError:
|
||||
@@ -5087,7 +5088,7 @@ class AdJuJueTuiKuan(APIView):
|
||||
if jiedan_dashou_id:
|
||||
try:
|
||||
# 查询打手用户主表
|
||||
dashou_user = UserMain.query.get(
|
||||
dashou_user = User.query.get(
|
||||
yonghuid=jiedan_dashou_id,
|
||||
#user_type='dashou'
|
||||
)
|
||||
@@ -5114,7 +5115,7 @@ class AdJuJueTuiKuan(APIView):
|
||||
dashou_profile.save()
|
||||
logger.info(f"拒绝退款成功,打手{jiedan_dashou_id}结算分成:{dashou_fencheng}")
|
||||
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
# 打手用户不存在,记录日志但不影响操作
|
||||
logger.warning(f"拒绝退款:打手{jiedan_dashou_id}不存在,跳过打手结算")
|
||||
except AttributeError:
|
||||
@@ -5130,7 +5131,7 @@ class AdJuJueTuiKuan(APIView):
|
||||
|
||||
if shangjia_id:
|
||||
# 查询商家用户主表
|
||||
shangjia_user = UserMain.query.get(
|
||||
shangjia_user = User.query.get(
|
||||
yonghuid=shangjia_id,
|
||||
#user_type='shop'
|
||||
)
|
||||
@@ -5147,7 +5148,7 @@ class AdJuJueTuiKuan(APIView):
|
||||
except DingdanShangjia.DoesNotExist:
|
||||
# 商家订单扩展表不存在,跳过商家更新
|
||||
logger.warning(f"拒绝退款:订单{dingdan_id}商家扩展表不存在,跳过商家更新")
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
# 商家用户不存在,跳过商家更新
|
||||
logger.warning(f"拒绝退款:商家{shangjia_id}不存在,跳过商家更新")
|
||||
except AttributeError:
|
||||
@@ -5318,7 +5319,7 @@ class AdTongYiTuiKuanShangJia(APIView):
|
||||
if jiedan_dashou_id:
|
||||
try:
|
||||
# 查询打手用户主表
|
||||
dashou_user = UserMain.query.get(
|
||||
dashou_user = User.query.get(
|
||||
yonghuid=jiedan_dashou_id,
|
||||
#user_type='dashou'
|
||||
)
|
||||
@@ -5332,7 +5333,7 @@ class AdTongYiTuiKuanShangJia(APIView):
|
||||
dashou_profile.save()
|
||||
logger.info(f"同意退款成功,打手{jiedan_dashou_id}退款订单+1")
|
||||
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
# 打手用户不存在,记录日志但不影响操作
|
||||
logger.warning(f"同意退款:打手{jiedan_dashou_id}不存在,跳过打手更新")
|
||||
except AttributeError:
|
||||
@@ -5343,7 +5344,7 @@ class AdTongYiTuiKuanShangJia(APIView):
|
||||
if shangjia_id:
|
||||
try:
|
||||
# 查询商家用户主表
|
||||
shangjia_user = UserMain.query.get(
|
||||
shangjia_user = User.query.get(
|
||||
yonghuid=shangjia_id,
|
||||
#user_type='shop'
|
||||
)
|
||||
@@ -5360,7 +5361,7 @@ class AdTongYiTuiKuanShangJia(APIView):
|
||||
shangjia_profile.save()
|
||||
logger.info(f"同意退款成功,商家{shangjia_id}退款订单+1,余额增加:{jine}")
|
||||
|
||||
except UserMain.DoesNotExist:
|
||||
except User.DoesNotExist:
|
||||
# 商家用户不存在,记录日志但不影响操作
|
||||
logger.warning(f"同意退款:商家{shangjia_id}不存在,跳过商家更新")
|
||||
except AttributeError:
|
||||
@@ -5528,25 +5529,25 @@ class AdTongYiTuiKuanPingTai(APIView):
|
||||
# 14. 更新打手扩展表
|
||||
if jiedan_dashou_id:
|
||||
try:
|
||||
dashou_user = UserMain.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou_profile = dashou_user.dashou_profile
|
||||
dashou_profile.zhuangtai = 1 # 打手状态设为空闲
|
||||
dashou_profile.tuikuanliang += 1
|
||||
dashou_profile.save()
|
||||
except (UserMain.DoesNotExist, AttributeError):
|
||||
except (User.DoesNotExist, AttributeError):
|
||||
logger.warning(f"平台退款:打手{jiedan_dashou_id}不存在或扩展信息缺失,跳过")
|
||||
|
||||
# 15. 更新老板扩展表
|
||||
if laoban_id:
|
||||
try:
|
||||
laoban_user = UserMain.query.get(yonghuid=laoban_id)
|
||||
laoban_user = User.query.get(yonghuid=laoban_id)
|
||||
laoban_profile = laoban_user.boss_profile
|
||||
laoban_profile.alltui += 1
|
||||
laoban_profile.zonge -= jine
|
||||
if laoban_profile.zonge < 0:
|
||||
laoban_profile.zonge = 0
|
||||
laoban_profile.save()
|
||||
except (UserMain.DoesNotExist, AttributeError):
|
||||
except (User.DoesNotExist, AttributeError):
|
||||
logger.warning(f"平台退款:老板{laoban_id}不存在或扩展信息缺失,跳过")
|
||||
|
||||
# 16. 更新收支记录表(id=1)
|
||||
@@ -5864,12 +5865,12 @@ class AdJuJueJieSuan(APIView):
|
||||
|
||||
# 8. 更新打手扩展表
|
||||
try:
|
||||
dashou_user = UserMain.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou_profile = dashou_user.dashou_profile
|
||||
dashou_profile.zhuangtai = 1 # 打手状态设为正常
|
||||
dashou_profile.tuikuanliang += 1 # 退款订单总量+1
|
||||
dashou_profile.save()
|
||||
except (UserMain.DoesNotExist, AttributeError) as e:
|
||||
except (User.DoesNotExist, AttributeError) as e:
|
||||
logger.warning(f"拒绝结算:打手{jiedan_dashou_id}信息更新失败 - {str(e)}")
|
||||
|
||||
return Response({'code': 0, 'message': '拒绝结算成功', 'data': None})
|
||||
@@ -5946,12 +5947,12 @@ class AdZhuanYiDaTing(APIView):
|
||||
# 如果有接单打手,更新其扩展表
|
||||
if jiedan_dashou_id:
|
||||
try:
|
||||
dashou_user = UserMain.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou_user = User.query.get(yonghuid=jiedan_dashou_id)
|
||||
dashou_profile = dashou_user.dashou_profile
|
||||
dashou_profile.zhuangtai = 1
|
||||
dashou_profile.tuikuanliang += 1
|
||||
dashou_profile.save()
|
||||
except (UserMain.DoesNotExist, AttributeError) as e:
|
||||
except (User.DoesNotExist, AttributeError) as e:
|
||||
logger.warning(f"转移大厅:打手{jiedan_dashou_id}信息更新失败 - {str(e)}")
|
||||
|
||||
return Response({'code': 0, 'message': '转移大厅成功', 'data': None})
|
||||
@@ -6224,12 +6225,12 @@ class ZxsjghdsView(APIView):
|
||||
# 6.2 释放打手
|
||||
if dashou_id:
|
||||
try:
|
||||
dashou_user = UserMain.query.get(yonghuid=dashou_id)
|
||||
dashou_user = User.query.get(yonghuid=dashou_id)
|
||||
dashou_profile = dashou_user.dashou_profile
|
||||
dashou_profile.tuikuanliang = (dashou_profile.tuikuanliang or 0) + 1
|
||||
dashou_profile.zhuangtai = 1 # 空闲
|
||||
dashou_profile.save(update_fields=['tuikuanliang', 'zhuangtai'])
|
||||
except (UserMain.DoesNotExist, ObjectDoesNotExist):
|
||||
except (User.DoesNotExist, ObjectDoesNotExist):
|
||||
logger.warning(f"打手 {dashou_id} 不存在或扩展表缺失,跳过更新")
|
||||
|
||||
# 6.3 更新退款记录
|
||||
|
||||
Reference in New Issue
Block a user