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()