18 lines
763 B
Plaintext
18 lines
763 B
Plaintext
# 从营销方案直接生成促销码(toolbar 工具按钮调用)
|
||
mkt_id = params_kw.get('id', '')
|
||
if not mkt_id:
|
||
return {"widgettype": "Error", "options": {"title": "操作失败", "message": "缺少方案ID", "cwidth": 16, "cheight": 9, "timeout": 3}}
|
||
|
||
result = await generate_promo_code(request, {"marketing_id": mkt_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}}
|