From 46d64fbf921bbbb038e0bcf9c721912fd98eddd4 Mon Sep 17 00:00:00 2001 From: XingQue Date: Thu, 23 Jul 2026 19:41:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=95=86=E5=93=81=E5=88=86=E6=88=90?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D=E5=85=BC=E5=AE=B9=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=90=8E=E5=8F=B0=E9=BB=98=E8=AE=A4/=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=88=86=E6=88=90=E6=97=A0=E6=B3=95=E5=9B=9E?= =?UTF-8?q?=E6=98=BE=E4=B8=8E=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- backend/views/products.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/backend/views/products.py b/backend/views/products.py index 83e17a2..3992386 100644 --- a/backend/views/products.py +++ b/backend/views/products.py @@ -696,7 +696,10 @@ class AddProductView(APIView): huiyuan_id = request.data.get('huiyuan_id', '').strip() yongjin_str = request.data.get('yongjin', '0') fencheng_type = request.data.get('fencheng_type', 'default') - ewai_PlayerCommission_str = request.data.get('ewai_PlayerCommission', '0') + # 兼容列表页 ewai_dashou_fencheng 与旧字段 ewai_PlayerCommission + ewai_PlayerCommission_str = request.data.get('ewai_dashou_fencheng') + if ewai_PlayerCommission_str is None or ewai_PlayerCommission_str == '': + ewai_PlayerCommission_str = request.data.get('ewai_PlayerCommission', '0') jieshao = request.data.get('jieshao', '').strip() xiadan_xuzhi = request.data.get('xiadan_xuzhi', '').strip() # 图片文件 @@ -989,7 +992,10 @@ class GetProductDetailView(APIView): 'huiyuan_id': product.huiyuan_id, 'yongjin': str(product.yongjin) if product.yongjin is not None else None, 'tupian_url': product.tupian_url, - 'kaioi_ewai_PlayerCommission': product.kaioi_ewai_dashou_fencheng, + # 兼容两套字段名(客服详情页用 kaioi_ewai_dashou_fencheng) + 'kaioi_ewai_dashou_fencheng': bool(product.kaioi_ewai_dashou_fencheng), + 'ewai_dashou_fencheng': str(product.ewai_dashou_fencheng) if product.ewai_dashou_fencheng is not None else '0', + 'kaioi_ewai_PlayerCommission': bool(product.kaioi_ewai_dashou_fencheng), 'ewai_PlayerCommission': str(product.ewai_dashou_fencheng) if product.ewai_dashou_fencheng is not None else '0', 'CreateTime': product.CreateTime.isoformat() if product.CreateTime else None, 'shenhezhuangtai': product.shenhezhuangtai, @@ -1110,16 +1116,26 @@ class UpdateProductView(APIView): except: yongjin = Decimal('0') - # ---------- 3. 打手分成 ---------- - kaioi_ewai = request.data.get('kaioi_ewai_PlayerCommission') == 'true' + # ---------- 3. 打手分成(兼容详情页字段名与旧 PlayerCommission 别名) ---------- + raw_kaioi = request.data.get('kaioi_ewai_dashou_fencheng') + if raw_kaioi is None: + raw_kaioi = request.data.get('kaioi_ewai_PlayerCommission') + kaioi_ewai = str(raw_kaioi).strip().lower() in ('1', 'true', 'yes', 'on') + ewai_fencheng = Decimal('0') if kaioi_ewai: + raw_amt = request.data.get('ewai_dashou_fencheng') + if raw_amt is None or raw_amt == '': + raw_amt = request.data.get('ewai_PlayerCommission', 0) try: - ewai_fencheng = Decimal(str(request.data.get('ewai_PlayerCommission', 0))) + ewai_fencheng = Decimal(str(raw_amt)) if ewai_fencheng < 0: return Response({'code': 400, 'msg': '分成金额不能为负数'}) - except: + except Exception: return Response({'code': 400, 'msg': '分成金额格式错误'}) + else: + # 默认分成:清空固定金额,下单按俱乐部利率算 + ewai_fencheng = None jieshao = request.data.get('jieshao', '').strip() xiadan_xuzhi = request.data.get('xiadan_xuzhi', '').strip()