Преглед на файлове

feat(daytask): 提现订单增加paymentInfo字段并兼容旧JSON收款信息

urban преди 11 часа
родител
ревизия
ef3ff1c1d2
променени са 2 файла, в които са добавени 34 реда и са изтрити 0 реда
  1. 1 0
      model/biz_modules/daytask/dt_finance.go
  2. 33 0
      service/daytask/dt_finance.go

+ 1 - 0
model/biz_modules/daytask/dt_finance.go

@@ -14,6 +14,7 @@ type DtWithdrawOrder struct {
 	ReceiveAmount   float64 `json:"receiveAmount" gorm:"column:receive_amount;type:decimal(18,2);default:0.00;comment:收款金额(原币种)"`
 	ReceiveCurrency string  `json:"receiveCurrency" gorm:"column:receive_currency;type:varchar(16);default:USDT;comment:收款币种"`
 	PaymentId       int64   `json:"paymentId" gorm:"column:payment_id;type:bigint;comment:收款方式ID"`
+	PaymentInfo     string  `json:"paymentInfo" gorm:"column:payment_info;type:text;comment:收款账户信息(JSON)"`
 	ReceiveAccount  string  `json:"receiveAccount" gorm:"column:receive_account;type:varchar(128);comment:收款账号"`
 	ReceiveName     string  `json:"receiveName" gorm:"column:receive_name;type:varchar(64);comment:收款人姓名"`
 	BankName        string  `json:"bankName" gorm:"column:bank_name;type:varchar(64);comment:银行名称"`

+ 33 - 0
service/daytask/dt_finance.go

@@ -1,6 +1,8 @@
 package daytask
 
 import (
+	"encoding/json"
+
 	model "go_server/model/biz_modules/daytask"
 	"go_server/model/common/response"
 	"go_server/service/base"
@@ -65,6 +67,37 @@ func (s *DtWithdrawOrderService) Find(c *gin.Context) {
 		response.Resp(c, err.Error())
 		return
 	}
+
+	// 兼容旧数据:从 paymentInfo 中解析收款信息,补充到新字段
+	type paymentInfo struct {
+		Type     string `json:"type"`
+		Name     string `json:"name"`
+		Account  string `json:"account"`
+		BankName string `json:"bankName"`
+	}
+	for i := range resp.List {
+		info := resp.List[i].PaymentInfo
+		if info == "" {
+			continue
+		}
+		var p paymentInfo
+		if err := json.Unmarshal([]byte(info), &p); err != nil {
+			continue
+		}
+		if resp.List[i].Channel == "" {
+			resp.List[i].Channel = p.Type
+		}
+		if resp.List[i].ReceiveAccount == "" {
+			resp.List[i].ReceiveAccount = p.Account
+		}
+		if resp.List[i].ReceiveName == "" {
+			resp.List[i].ReceiveName = p.Name
+		}
+		if resp.List[i].BankName == "" {
+			resp.List[i].BankName = p.BankName
+		}
+	}
+
 	response.Resp(c, map[string]interface{}{
 		"cols":   colInfo,
 		"list":   resp.List,