fix: 老板订单详情查询打手表现字段错误导致接单后整页500
dingdanxiangqing2 误用 OrderID 过滤 DashouBiaoxian(应为 dingdan_id),有人接单即服务器内部错误,打手信息无法返回。同步修正结算写入 fanche_cishu 与评分整数累加。不影响其它俱乐部业务分支。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -593,17 +593,22 @@ class DingdanXiangqingView2(APIView):
|
||||
dashou_touxiang = dashou_user.Avatar or ''
|
||||
try:
|
||||
dashou_nicheng = dashou_user.DashouProfile.nicheng or ''
|
||||
except UserDashou.DoesNotExist:
|
||||
except Exception:
|
||||
# 无打手扩展档案时仍返回打手 UID / 头像
|
||||
pass
|
||||
biaoxian = DashouBiaoxian.query.filter(
|
||||
OrderID=dingdan_id,
|
||||
dashou_id=jiedan_dashou_id
|
||||
).first()
|
||||
if biaoxian:
|
||||
if biaoxian.jiedan_time:
|
||||
jiedan_time = biaoxian.jiedan_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
if biaoxian.tijiao_time:
|
||||
tijiao_time = biaoxian.tijiao_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
# DashouBiaoxian 外键字段是 dingdan(列 dingdan_id),勿用 OrderID(会 FieldError → 整单详情 500)
|
||||
try:
|
||||
biaoxian = DashouBiaoxian.query.filter(
|
||||
dingdan_id=dingdan_id,
|
||||
dashou_id=jiedan_dashou_id
|
||||
).first()
|
||||
if biaoxian:
|
||||
if biaoxian.jiedan_time:
|
||||
jiedan_time = biaoxian.jiedan_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
if biaoxian.tijiao_time:
|
||||
tijiao_time = biaoxian.tijiao_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
except Exception as e:
|
||||
logger.warning(f"读取打手表现失败 dingdan={dingdan_id}: {e}")
|
||||
|
||||
# 老板自己的评价(如果已经结算过,可能已有评价)
|
||||
laoban_pingjia = pingtai_ext.BossReview or ''
|
||||
@@ -611,14 +616,17 @@ class DingdanXiangqingView2(APIView):
|
||||
fuwu_taidu = None
|
||||
fanche_cishu = None
|
||||
if jiedan_dashou_id and zhuangtai in [3, 4, 5, 6]: # 已完成或退款相关状态才可能有评价
|
||||
biaoxian = DashouBiaoxian.query.filter(
|
||||
OrderID=dingdan_id,
|
||||
dashou_id=jiedan_dashou_id
|
||||
).first()
|
||||
if biaoxian:
|
||||
shangxian_sudu = biaoxian.shangxian_sudu
|
||||
fuwu_taidu = biaoxian.fuwu_taidu
|
||||
fanche_cishu = biaoxian.fanche_cishu
|
||||
try:
|
||||
biaoxian = DashouBiaoxian.query.filter(
|
||||
dingdan_id=dingdan_id,
|
||||
dashou_id=jiedan_dashou_id
|
||||
).first()
|
||||
if biaoxian:
|
||||
shangxian_sudu = biaoxian.shangxian_sudu
|
||||
fuwu_taidu = biaoxian.fuwu_taidu
|
||||
fanche_cishu = biaoxian.fanche_cishu
|
||||
except Exception as e:
|
||||
logger.warning(f"读取结算评价失败 dingdan={dingdan_id}: {e}")
|
||||
|
||||
data = {
|
||||
'zhuangtai': zhuangtai,
|
||||
@@ -716,13 +724,13 @@ class JiedanView2(APIView):
|
||||
pingfen_records = PlayerRating.query.filter(PlayerID=jiedan_dashou_id)
|
||||
if pingfen_records.exists():
|
||||
pf = pingfen_records.first()
|
||||
pf.TotalScore += Decimal(str(fuwu_taidu))
|
||||
pf.RatingCount += 1
|
||||
pf.TotalScore = int(pf.TotalScore or 0) + int(fuwu_taidu)
|
||||
pf.RatingCount = int(pf.RatingCount or 0) + 1
|
||||
pf.save()
|
||||
else:
|
||||
PlayerRating.query.create(
|
||||
PlayerID=jiedan_dashou_id,
|
||||
TotalScore=Decimal(str(fuwu_taidu)),
|
||||
TotalScore=int(fuwu_taidu),
|
||||
RatingCount=1
|
||||
)
|
||||
|
||||
@@ -800,16 +808,15 @@ class JiedanView2(APIView):
|
||||
except Exception as e:
|
||||
logger.error(f"商品/店铺统计失败: {e}")
|
||||
|
||||
# 14. 🆕 写入打手表现表(结算评价)
|
||||
# 14. 写入打手表现表(结算评价);字段名须与 record_dashou_biaoxian 一致
|
||||
if jiedan_dashou_id:
|
||||
record_dashou_biaoxian(
|
||||
dingdan_id=dingdan_id,
|
||||
dashou_id=jiedan_dashou_id,
|
||||
xingwei=3, # 3=结算
|
||||
fanche_RatingCount=fanche_cishu,
|
||||
fanche_cishu=fanche_cishu,
|
||||
shangxian_sudu=shangxian_sudu,
|
||||
fuwu_taidu=fuwu_taidu
|
||||
# bankuai 暂不传入,后续可从订单商品关联
|
||||
)
|
||||
|
||||
# 15. 返回成功
|
||||
|
||||
Reference in New Issue
Block a user