From 1e771df6e54181d5f085a9f0acae7286736567c8 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 5 Aug 2026 16:26:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=90=A5=E9=94=80=E6=96=B9=E6=A1=88CRU?= =?UTF-8?q?D=E6=B7=BB=E5=8A=A0=E3=80=8C=E7=94=9F=E6=88=90=E4=BF=83?= =?UTF-8?q?=E9=94=80=E7=A0=81=E3=80=8D=E5=B7=A5=E5=85=B7=E6=8C=89=E9=92=AE?= =?UTF-8?q?=20=E2=80=94=20=E9=80=89=E4=B8=AD=E6=96=B9=E6=A1=88=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E9=94=AE=E7=94=9F=E6=88=90=E8=AF=A5=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E4=BF=83=E9=94=80=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json/discount_marketing_list.json | 19 +++++++++++++++++++ wwwroot/api/gen_promo_from_mkt.dspy | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 wwwroot/api/gen_promo_from_mkt.dspy diff --git a/json/discount_marketing_list.json b/json/discount_marketing_list.json index 5e995fa..d587e75 100644 --- a/json/discount_marketing_list.json +++ b/json/discount_marketing_list.json @@ -50,6 +50,11 @@ "selected_row": true, "label": "产品明细", "icon": "{{entire_url('/bricks/imgs/list.svg')}}" + }, + { + "name": "gen_promo", + "selected_row": true, + "label": "生成促销码" } ] }, @@ -68,6 +73,20 @@ "options": { "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')}}", diff --git a/wwwroot/api/gen_promo_from_mkt.dspy b/wwwroot/api/gen_promo_from_mkt.dspy new file mode 100644 index 0000000..7d0280f --- /dev/null +++ b/wwwroot/api/gen_promo_from_mkt.dspy @@ -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}}