# 从营销方案直接生成促销码(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}}