refactor(api): 优化立减金打开方式映射逻辑

- 将 voucher.is_webview 的打开方式映射从 switch 改为统一的map查询
- 在 constants 中新增 VoucherOpenMode 映射表,提升代码可维护性
- 移除冗余的分支判断,代码更简洁清晰
- 保持功能一致,确保映射结果不变
This commit is contained in:
zhouyonggao 2025-12-18 15:28:20 +08:00
parent aa3df428b1
commit 7b7dcc66d6
2 changed files with 11 additions and 7 deletions

View File

@ -1133,13 +1133,10 @@ func transformRow(ds string, fields []string, vals []string) []string {
}
// voucher.is_webview - 打开方式
if f == "voucher.is_webview" {
switch v {
case "0":
vals[i] = "微信小程序"
case "1":
vals[i] = "公众号"
case "2":
vals[i] = "通用"
if n := parseIntVal(v); n >= 0 {
if label, ok := constants.VoucherOpenMode[n]; ok {
vals[i] = label
}
}
continue
}

View File

@ -122,6 +122,13 @@ var MarketingRechargeType = map[int]string{
2: "组合商品充值",
}
// VoucherOpenMode 立减金打开方式映射
var VoucherOpenMode = map[int]string{
0: "微信小程序",
1: "公众号",
2: "通用",
}
// ==================== 通用枚举 ====================
// ThirdPartyType 第三方类型映射