用户决策(2026-09-06): 1. 折扣率允许大于1:平台可加价卖产品给客户(如存储缺省1.5); 也可小于1让利(如百炼模型0.9,供应商有折扣传导给客户) 2. 解析规则:确定客户→查客户专属折扣;查不到→'*'通配兜底;再无→1.0 旧实现bug:专属与通配OR混查取全局min——专属0.95+通配0.8返回0.8, 专属记录形同虚设 改动: - init.py sor_get_min_product_discount: 两步查询(专属层min→通配层min) - init.py add/update_discount_detail: 上限1→9.9999(DB double(5,4)约束) - discount_setting/save_discount.dspy: 兜底记录识别'*'+NULL两种形态; 「客户折扣率不得高于通用折扣率」校验保留(加价语义下=单客户价不贵于通用价) - marketing_discount_setting/save_discount.dspy: >1上限放开,保留<基准约束 - generate_qr.dspy: 同上放开 - index.ui: placeholder 0~1→'>1加价 <1折扣',dec_len 2→4 本地mock测试5场景全过:专属优先/通配兜底/无记录1.0/exact_match不兜底/层内min
65 lines
1.7 KiB
Plaintext
65 lines
1.7 KiB
Plaintext
from ahserver.serverenv import ServerEnv
|
||
|
||
params_kw.discount = float(params_kw.discount)
|
||
# 2026-09-06: 折扣率允许 >1(加价促销场景),上限 9.9999(DB double(5,4))
|
||
if params_kw.discount <= 0 or params_kw.discount > 9.9999:
|
||
e = Exception(f'discount({params_kw.discount}) invalid, must be in (0, 9.9999]')
|
||
exception(f'{e}')
|
||
raise e
|
||
|
||
if params_kw.valid_term[-1] not in ['D', 'M', 'Y']:
|
||
e = Exception(f'valid_term must ends with "D", "M" or "Y"')
|
||
exception(f'{e}')
|
||
raise e
|
||
cnt = int(params_kw.valid_term[:-1])
|
||
if cnt < 0:
|
||
e = Exception(f'valid_term({params_kw.valid_term}) invalid')
|
||
exception(f'{e}')
|
||
raise e
|
||
|
||
if not params_kw.expired_date:
|
||
params_kw.expired_date = '9999-12-31'
|
||
x = await discount_qrcode(request, params_kw)
|
||
|
||
env = ServerEnv()
|
||
qr_url = env.entire_url('/idfile') + f'?path={x.qr_webpath}'
|
||
|
||
return {
|
||
"widgettype": "VBox",
|
||
"options": {
|
||
"width": "100%",
|
||
"height": "100%"
|
||
},
|
||
"subwidgets": [
|
||
{
|
||
"widgettype": "Image",
|
||
"options": {
|
||
"width": "340px",
|
||
"height": "340px",
|
||
"url": qr_url
|
||
}
|
||
}, {
|
||
"widgettype": "HBox",
|
||
"options": {
|
||
"width": "100%",
|
||
"cheight": 2
|
||
},
|
||
"subwidgets": [
|
||
{
|
||
"widgettype": "Text",
|
||
"options": {
|
||
"otext": "折扣:",
|
||
"i18n": True,
|
||
"cwidth": 3
|
||
}
|
||
},{
|
||
"widgettype": "Text",
|
||
"options":{
|
||
"text": x.discount
|
||
}
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|