修正字段名不同的问题

This commit is contained in:
TermiNexus committed 2026-06-19 22:15:46 +08:00
1 parent a06202d297
commit a7f43a4e74
8 files changed
+18 -174

No files matched your search

-156
View File
@@ -918,162 +918,6 @@ class KefuGetDashouDetailView(APIView):
'''class KefuGetDashouDetailView(APIView):
"""
客服获取打手详情接口
请求:POST /yonghu/kefuhqdsxq
参数:{
"phone": "客服手机号",
"uid": "打手ID (yonghuid)"
}
认证:JWT
返回:code=0 + 打手信息 + 会员列表
"""
permission_classes = [IsAuthenticated]
parser_classes = [JSONParser]
def post(self, request):
# 1. 获取参数
username = request.data.get('phone', '').strip()
uid = request.data.get('uid', '').strip()
if not username or not uid:
return Response({'code': 401, 'msg': '认证失败'}, status=status.HTTP_401_UNAUTHORIZED)
# 2. 客服身份验证
current_user = request.user
# 2. 公共权限校验(验证客服身份,获取权限列表)
kefu, permissions = verify_kefu_permission(request, username)
if kefu is None:
return permissions # 直接返回错误响应
# 3. 检查是否拥有打手管理相关权限(至少一个)
required_perms = {'001aa', '001bb', '001cc', '001dd', '001ee', '001ff', '001gg'}
if not any(p in permissions for p in required_perms):
return Response({'code': 403, 'msg': '您没有权限查看打手列表'})
# 3. 查询打手主表和扩展表
try:
# 使用 select_related 预加载 dashou_profile,减少数据库查询
user_main = User.query.select_related('DashouProfile').get(
UserUID=uid
)
except User.DoesNotExist:
return Response({'code': 404, 'msg': '打手不存在'}, status=status.HTTP_404_NOT_FOUND)
# 验证用户类型是否为打手(可选,但建议验证)
# 如果该用户没有打手扩展表,则返回空信息(但前端会显示未注册)
try:
dashou = user_main.DashouProfile
except ObjectDoesNotExist:
# 用户存在但未注册打手身份,返回基本信息
user_info = {
'yonghuid': user_main.UserUID,
'avatar': user_main.Avatar or '',
'zaixianzhuangtai': 0,
'zhanghaozhuangtai': 0,
'zhuangtai': 0,
'nicheng': '',
'chenghao': '',
'dianhua': '',
'wechat': '',
'phone': user_main.Phone or '',
'CreateTime': user_main.UserCreateTime,
'ip': user_main.IP or '',
'jiedanzongliang': 0,
'chengjiaozongliang': 0,
'tuikuanliang': 0,
'jinrijiedan': 0,
'yue': 0.00,
'zonge': 0.00,
'jifen': 0,
'yajin': 0.00,
'jinrishouyi': 0.00,
'jinyueshouyi': 0.00,
'yaoqingren': '',
'jieshao': '',
}
member_list = []
return Response({
'code': 0,
'data': {
'user_info': user_info,
'member_list': member_list
}
})
# 4. 构建打手信息
user_info = {
'yonghuid': user_main.UserUID,
'avatar': user_main.Avatar or '',
'zaixianzhuangtai': dashou.zaixianzhuangtai,
'zhanghaozhuangtai': dashou.zhanghaozhuangtai,
'zhuangtai': dashou.zhuangtai,
'nicheng': dashou.nicheng or '',
'chenghao': dashou.chenghao or '',
'dianhua': dashou.dianhua or '',
'wechat': dashou.wechat or '',
'phone': user_main.Phone or '',
'CreateTime': user_main.UserCreateTime,
'ip': user_main.IP or '',
'jiedanzongliang': dashou.jiedanzongliang,
'chengjiaozongliang': dashou.chengjiaozongliang,
'tuikuanliang': dashou.tuikuanliang,
'jinrijiedan': dashou.jinrijiedan,
'yue': float(dashou.yue) if dashou.yue else 0.00,
'zonge': float(dashou.zonge) if dashou.zonge else 0.00,
'jifen': dashou.jifen,
'yajin': float(dashou.yajin) if dashou.yajin else 0.00,
'jinrishouyi': float(dashou.jinrishouyi) if dashou.jinrishouyi else 0.00,
'jinyueshouyi': float(dashou.jinyueshouyi) if dashou.jinyueshouyi else 0.00,
'yaoqingren': dashou.yaoqingren or '',
'jieshao': dashou.jieshao or '',
}
# 5. 查询打手会员信息(仅未过期)
member_records = Huiyuangoumai.query.filter(
yonghu_id=uid
).order_by('-CreateTime')
member_list = []
for record in member_records:
# 调用模型方法检查是否过期
if hasattr(record, 'jiance_shifou_daoqi'):
is_expired = record.jiance_shifou_daoqi()
else:
# 如果方法不存在,简单判断
is_expired = record.daoqi_time < timezone.now() if record.daoqi_time else True
if not is_expired:
# 获取会员详情
try:
huiyuan = Huiyuan.query.get(huiyuan_id=record.huiyuan_id)
huiyuan_name = huiyuan.jieshao
except Huiyuan.DoesNotExist:
huiyuan_name = '未知会员'
member_list.append({
'id': record.id,
'huiyuan_name': huiyuan_name,
'daoqi_time': record.daoqi_time,
'is_active': record.huiyuan_zhuangtai == 1,
})
return Response({
'code': 0,
'data': {
'user_info': user_info,
'member_list': member_list
}
})'''
class KefuUpdateDashouView(APIView):
"""
客服修改打手信息接口
+1 -1
View File
@@ -2554,7 +2554,7 @@ class KehuTianxieDingdanView(APIView):
# 如果是指定打手,设置zhiding_id
if zhiding_dashou and zhuangtai_xin == 7:
dingdan_obj.zhiding_id = zhiding_dashou
dingdan_obj.AssignedID = zhiding_dashou
dingdan_obj.save()
logger.info(
+4 -4
View File
@@ -1379,7 +1379,7 @@ class JiedanView(APIView):
# 🔥 新增:调用打手每日统计(成交)
try:
update_dashou_daily_by_action(
UserID=jiedan_dashou_id,
yonghuid=jiedan_dashou_id,
amount=dashou_fencheng,
action=2 # 2 表示成交(结算)
)
@@ -2473,7 +2473,7 @@ class ShangjiaJiesuanView(APIView):
# 新增:调用打手每日统计(成交)
try:
update_dashou_daily_by_action(
UserID=jiedan_dashou_id,
yonghuid=jiedan_dashou_id,
amount=dashou_fencheng,
action=2 # 2 表示成交(结算)
)
@@ -6251,7 +6251,7 @@ class ZxsjghdsView(APIView):
if dashou_id:
try:
update_dashou_daily_by_action(
UserID=dashou_id,
yonghuid=dashou_id,
amount=dashou_fencheng,
action=3 # 3=退款
)
@@ -6443,7 +6443,7 @@ class ShangjiaFakuaiXiugaiView(APIView):
return Response({'code': 403, 'msg': '商家状态异常'}, status=status.HTTP_403_FORBIDDEN)
operation = request.data.get('operation')
dingdan_id = request.data.get('OrderID')
dingdan_id = request.data.get('dingdan_id') or request.data.get('OrderID')
if not dingdan_id:
return Response({'code': 400, 'msg': '缺少订单ID'}, status=status.HTTP_400_BAD_REQUEST)
+4 -4
View File
@@ -6332,12 +6332,12 @@ class DsqrgmdhView(APIView):
return Response({'code': 500, 'msg': '打手信息不存在,无法充值押金'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
elif leixing == 4:
if fadan_obj.zhuangtai not in [1, 3]:
if fadan_obj.Status not in [1, 3]:
return Response({'code': 400, 'msg': '罚单状态不可缴纳'}, status=status.HTTP_400_BAD_REQUEST)
fadan_obj.zhuangtai = 2
fadan_obj.save(update_fields=['zhuangtai'])
fadan_obj.Status = 2
fadan_obj.save(update_fields=['Status'])
response_data['fadan_id'] = fadan_obj.id
response_data['fadan_status'] = fadan_obj.zhuangtai
response_data['fadan_status'] = fadan_obj.Status
# ========== 修改点2: 使用最新的分红处理方法 ==========
success, msg = process_fadan_fenhong(fadan_obj.id)
+5 -5
View File
@@ -2478,8 +2478,8 @@ class ShopOrderManageView(APIView):
'jine': float(order.Amount) if order.Amount else 0.00,
'dashou_fencheng': float(order.PlayerCommission) if order.PlayerCommission else 0.00,
'jiedan_dashou_id': order.PlayerID or '',
'dashou_liuyan': order.dashou_liuyan or '',
'zhiding_id': order.zhiding_id or '',
'dashou_liuyan': order.PlayerRemark or '',
'zhiding_id': order.AssignedID or '',
'shangpin_id': order.ProductID or '',
'tupian': order.ImageURL or '',
'jieshao': order.Description or '',
@@ -2555,7 +2555,7 @@ class ShopRefundView(APIView):
try:
# 通过扩展表确认归属,并 select_related 获取订单主表
pingtai_ext = PlatformOrderExt.query.select_related('Order').get(
dianpu_id=shop_id,
ShopID=shop_id,
Order__OrderID=dingdan_id
)
order = pingtai_ext.Order
@@ -2802,7 +2802,7 @@ class ShopForceCompleteView(APIView):
try:
# 通过平台扩展表确认订单属于本店铺
pingtai_ext = PlatformOrderExt.query.select_related('Order').get(
dianpu_id=shop_id,
ShopID=shop_id,
Order__OrderID=dingdan_id
)
order = pingtai_ext.Order
@@ -2951,7 +2951,7 @@ class ShopTransferHallView(APIView):
# ---------- 3. 验证订单归属 ----------
try:
pingtai_ext = PlatformOrderExt.query.select_related('Order').get(
dianpu_id=shop_id,
ShopID=shop_id,
Order__OrderID=dingdan_id
)
order = pingtai_ext.Order
+1 -1
View File
@@ -9527,7 +9527,7 @@ class KefuForceCompleteView(APIView):
# 7. 更新订单状态
order.Status = 3
order.AssignedCS = phone
order.save(update_fields=['zhuangtai', 'clkf'])
order.save(update_fields=['Status', 'AssignedCS'])
if order.Platform == 1:
+2 -2
View File
@@ -193,6 +193,6 @@ def _get_local_partner_info(order):
logger.error(f"获取商家信息失败: {e}")
return None, None, None
else:
if order.user1_id:
return order.user1_id, "用户", _full_local_avatar('')
if order.User1ID:
return order.User1ID, "用户", _full_local_avatar('')
return None, None, None
+1 -1
View File
@@ -89,7 +89,7 @@ class GoEasyService:
"""
# user1_id 是老板/商家标识 (从订单中获取)
# user2_id 是打手标识
user1_id = order.user1_id
user1_id = order.User1ID
user2_id = f"Ds{dashou_yonghuid}"
if not user1_id or not user2_id: