feat(api): 添加导出数据枚举字段中文标签转换功能
- 在导出数据转换函数中新增多字段枚举值解析和映射为中文标签 - 支持订单类型、状态、支付方式、支付状态等多个枚举字段转换 - 增加立减金、红包相关渠道及状态枚举转换 - 新增结算类型、供应商类型、领取方式等特殊枚举转换 - 更新字段标签映射,保持导出字段中文描述一致性 - 统一处理不同数据源(ds)的枚举映射,区分ymt与marketing标签
This commit is contained in:
parent
36aff7a377
commit
da0c764646
|
|
@ -1008,6 +1008,167 @@ func transformRow(ds string, fields []string, vals []string) []string {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
f := fields[i]
|
f := fields[i]
|
||||||
|
v := vals[i]
|
||||||
|
|
||||||
|
// ==================== 枚举转换 ====================
|
||||||
|
// order.type - 订单类型
|
||||||
|
if f == "order.type" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if ds == "ymt" {
|
||||||
|
if label, ok := constants.YMTOrderType[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if label, ok := constants.MarketingOrderType[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order.status - 订单状态
|
||||||
|
if f == "order.status" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if ds == "ymt" {
|
||||||
|
if label, ok := constants.YMTOrderStatus[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if label, ok := constants.MarketingOrderStatus[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order.pay_type - 支付方式
|
||||||
|
if f == "order.pay_type" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.MarketingPayType[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
} else if n == 0 {
|
||||||
|
vals[i] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order.pay_status - 支付状态
|
||||||
|
if f == "order.pay_status" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if ds == "ymt" {
|
||||||
|
if label, ok := constants.YMTPayStatus[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if label, ok := constants.MarketingPayStatus[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order.use_coupon - 是否使用优惠券
|
||||||
|
if f == "order.use_coupon" {
|
||||||
|
switch v {
|
||||||
|
case "1":
|
||||||
|
vals[i] = "是"
|
||||||
|
case "2", "0":
|
||||||
|
vals[i] = "否"
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order.deliver_status - 投递状态
|
||||||
|
if f == "order.deliver_status" {
|
||||||
|
switch v {
|
||||||
|
case "1":
|
||||||
|
vals[i] = "待投递"
|
||||||
|
case "2":
|
||||||
|
vals[i] = "已投递"
|
||||||
|
case "3":
|
||||||
|
vals[i] = "投递失败"
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order.is_inner - 供应商类型
|
||||||
|
if f == "order.is_inner" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.YMTIsInner[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order_voucher.channel / voucher.channel - 立减金渠道
|
||||||
|
if f == "order_voucher.channel" || f == "voucher.channel" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.OrderVoucherChannel[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order_voucher.status - 立减金状态
|
||||||
|
if f == "order_voucher.status" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if ds == "ymt" {
|
||||||
|
if label, ok := constants.YMTOrderVoucherStatus[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if label, ok := constants.MarketingOrderVoucherStatus[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order_voucher.receive_mode / voucher.receive_mode - 领取方式
|
||||||
|
if f == "order_voucher.receive_mode" || f == "voucher.receive_mode" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.OrderVoucherReceiveMode[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order_cash.channel - 红包渠道
|
||||||
|
if f == "order_cash.channel" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.OrderCashChannel[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order_cash.receive_status - 红包领取状态
|
||||||
|
if f == "order_cash.receive_status" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.OrderCashReceiveStatus[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// order_digit.order_type - 数字订单类型
|
||||||
|
if f == "order_digit.order_type" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.OrderDigitOrderType[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// activity.settlement_type - 结算类型
|
||||||
|
if f == "activity.settlement_type" || f == "plan.settlement_type" {
|
||||||
|
if n := parseIntVal(v); n >= 0 {
|
||||||
|
if label, ok := constants.YMTSettlementType[n]; ok {
|
||||||
|
vals[i] = label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 特殊字段转换 ====================
|
||||||
// 解密/转换订单 key
|
// 解密/转换订单 key
|
||||||
if f == "order.key" {
|
if f == "order.key" {
|
||||||
if ds == "ymt" {
|
if ds == "ymt" {
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,7 @@ func AllLabels() map[string]string {
|
||||||
"order_digit.create_time": "创建时间",
|
"order_digit.create_time": "创建时间",
|
||||||
"order_digit.update_time": "更新时间",
|
"order_digit.update_time": "更新时间",
|
||||||
"order_digit.code": "验证码",
|
"order_digit.code": "验证码",
|
||||||
// "order_digit.sms_channel": "短信渠道", // 字段不再对外展示和导出
|
"order_digit.sms_channel": "短信渠道",
|
||||||
"goods_voucher_batch.channel_batch_no": "渠道批次号",
|
"goods_voucher_batch.channel_batch_no": "渠道批次号",
|
||||||
"goods_voucher_batch.voucher_subject_id": "主体配置ID",
|
"goods_voucher_batch.voucher_subject_id": "主体配置ID",
|
||||||
"goods_voucher_batch.id": "ID",
|
"goods_voucher_batch.id": "ID",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue