fix(api): 修复营销系统非直充类型字段过滤逻辑
- 在导出字段时,非直充类型(type!=1)移除充值时间和卡密字段 - 添加日志记录被移除字段及原因 - 在元数据接口中过滤营销系统非直充类型下的充值时间和卡密字段 - 保证字段显示和导出的一致性
This commit is contained in:
parent
3002590491
commit
d962481289
|
|
@ -232,7 +232,7 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
// 不再使用白名单过滤,直接使用所有字段
|
// 不再使用白名单过滤,直接使用所有字段
|
||||||
filtered = normalized
|
filtered = normalized
|
||||||
// 易码通立减金:保留 order_voucher.grant_time,移除红包领取时间列,避免"领取时间"为空
|
// 易码通立减金:保留 order_voucher.grant_time,移除红包领取时间列,避免“领取时间”为空
|
||||||
if ds == "ymt" && tv == 3 {
|
if ds == "ymt" && tv == 3 {
|
||||||
deduped := make([]string, 0, len(filtered))
|
deduped := make([]string, 0, len(filtered))
|
||||||
removed := []string{}
|
removed := []string{}
|
||||||
|
|
@ -248,6 +248,22 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
filtered = deduped
|
filtered = deduped
|
||||||
}
|
}
|
||||||
|
// 营销系统:非直充类型(type!=1)时移除recharge_time和card_code字段
|
||||||
|
if ds == "marketing" && tv != 1 {
|
||||||
|
deduped := make([]string, 0, len(filtered))
|
||||||
|
removed := []string{}
|
||||||
|
for _, tf := range filtered {
|
||||||
|
if tf == "order.recharge_time" || tf == "order.card_code" {
|
||||||
|
removed = append(removed, tf)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
deduped = append(deduped, tf)
|
||||||
|
}
|
||||||
|
if len(removed) > 0 {
|
||||||
|
logging.JSON("INFO", map[string]interface{}{"event": "fields_filtered_non_direct_charge", "removed": removed, "reason": "非直充类型不导出充值时间和卡密"})
|
||||||
|
}
|
||||||
|
filtered = deduped
|
||||||
|
}
|
||||||
labels := FieldLabels()
|
labels := FieldLabels()
|
||||||
// 字段匹配校验(数量与顺序)
|
// 字段匹配校验(数量与顺序)
|
||||||
if len(filtered) != len(fs) {
|
if len(filtered) != len(fs) {
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,16 @@ func MetadataHandler(meta, marketing, ymt *sql.DB) http.Handler {
|
||||||
for i := range tables {
|
for i := range tables {
|
||||||
var visible []fieldInfo
|
var visible []fieldInfo
|
||||||
for _, f := range tables[i].Fields {
|
for _, f := range tables[i].Fields {
|
||||||
if !f.Hidden {
|
if f.Hidden {
|
||||||
visible = append(visible, f)
|
continue
|
||||||
}
|
}
|
||||||
|
// 营销系统:recharge_time和card_code字段只在直充类型(type=1)时才显示
|
||||||
|
if ds == "marketing" && ot != "1" {
|
||||||
|
if f.Key == "order.recharge_time" || f.Key == "order.card_code" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
visible = append(visible, f)
|
||||||
}
|
}
|
||||||
tables[i].Fields = visible
|
tables[i].Fields = visible
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue