feat: 营销方案CRUD添加「生成促销码」工具按钮 — 选中方案后一键生成该用户的促销码

This commit is contained in:
yumoqing 2026-08-05 16:26:42 +08:00
parent 7dbac3bfdb
commit 1e771df6e5
2 changed files with 36 additions and 0 deletions

View File

@ -50,6 +50,11 @@
"selected_row": true, "selected_row": true,
"label": "产品明细", "label": "产品明细",
"icon": "{{entire_url('/bricks/imgs/list.svg')}}" "icon": "{{entire_url('/bricks/imgs/list.svg')}}"
},
{
"name": "gen_promo",
"selected_row": true,
"label": "生成促销码"
} }
] ]
}, },
@ -68,6 +73,20 @@
"options": { "options": {
"url": "{{entire_url('../marketing_discount_setting')}}" "url": "{{entire_url('../marketing_discount_setting')}}"
} }
},
{
"wid": "self",
"event": "gen_promo",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "生成促销码",
"cwidth": 16,
"cheight": 10
},
"options": {
"url": "{{entire_url('../api/gen_promo_from_mkt.dspy')}}?marketing_id=${id}$"
}
} }
], ],
"new_data_url": "{{entire_url('/discount/api/marketing_create.dspy')}}", "new_data_url": "{{entire_url('/discount/api/marketing_create.dspy')}}",

View File

@ -0,0 +1,17 @@
# 从营销方案直接生成促销码toolbar 工具按钮调用)
marketing_id = params_kw.get('marketing_id', '')
if not marketing_id:
return {"widgettype": "Error", "options": {"title": "操作失败", "message": "缺少方案ID", "cwidth": 16, "cheight": 9, "timeout": 3}}
result = await generate_promo_code(request, {"marketing_id": marketing_id})
if result.get("status") == "success":
return {
"widgettype": "Message",
"options": {
"title": "促销码已生成",
"message": "促销码: " + result["code"],
"type": "success",
"timeout": 5
}
}
return {"widgettype": "Error", "options": {"title": "操作失败", "message": str(result.get("message", "")), "cwidth": 16, "cheight": 9, "timeout": 3}}