fix: 商品分成字段名兼容,修复后台默认/自定义分成无法回显与保存
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -696,6 +696,9 @@ 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_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()
|
||||
|
||||
Reference in New Issue
Block a user