k.zhang 1 年間 前
コミット
fd3acabf08

+ 7 - 1
apis/shanghu/merchant.card.go

@@ -34,6 +34,7 @@ func CreateMerchantCard(c *gin.Context) {
 		return
 	}
 
+	//"json: cannot unmarshal string into Go struct field CreateMerchantCardRequest.cancel_number of type int"
 	//"json: cannot unmarshal string into Go struct field CreateMerchantCardRequest.inventory of type int64"
 	//"json: cannot unmarshal bool into Go struct field CreateMerchantCardRequest.merchant_card_time of type string"
 	//"json: cannot unmarshal string into Go struct field CreateMerchantCardRequest.inventory of type int64"
@@ -73,7 +74,12 @@ func CreateMerchantCard(c *gin.Context) {
 	}
 	sqlData.UseRule = inData.UseRule
 	sqlData.MerchantCardName = inData.MerchantCardName
-	sqlData.CancelNumber = inData.CancelNumber
+
+	sqlData.CancelNumber, err = strconv.Atoi(inData.CancelNumber)
+	if err != nil {
+		app.Error(c, 400, err, err.Error())
+		return
+	}
 
 	_, err = sqlData.Create()
 	if err != nil {

+ 1 - 1
apis/shanghu/models/card.go

@@ -18,7 +18,7 @@ type CreateMerchantCardRequest struct {
 	UseRule           string  `json:"use_rule"`            // 使用规则
 	Picture           string  `json:"picture"`             // 图片
 	RebateRate        string  `json:"rebate_rate"`         // 佣金比例
-	CancelNumber      int     `json:"cancel_number"`       //核销次数
+	CancelNumber      string  `json:"cancel_number"`       //核销次数
 }
 
 type GetMerchantCardRequest struct {

+ 6 - 6
models/shanghu/merchant_card.go

@@ -20,12 +20,12 @@ type MerchantCard struct {
 	UseRule           string    `gorm:"column:use_rule;type:varchar(255)" json:"use_rule"`                          // 使用规则
 	Picture           string    `gorm:"column:picture;type:varchar(255)" json:"picture"`                            // 图片
 	RebateRate        int64     `gorm:"column:rebate_rate;type:int(11)" json:"rebate_rate"`                         // 佣金比例
-	CancelNumber      int       `gorm:"column:cancel_number;type:int(11)" json:"cancel_number"`
-	CreateBy          int64     `gorm:"column:create_by;type:bigint(20)" json:"create_by"`                 // 创建者
-	UpdateBy          int64     `gorm:"column:update_by;type:bigint(20)" json:"update_by"`                 // 更新者
-	CreatedAt         time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`              // 创建时间
-	UpdatedAt         time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`              // 最后更新时间
-	DeletedAt         time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
+	CancelNumber      int       `gorm:"column:cancel_number;type:int(11)" json:"cancel_number"`                     //
+	CreateBy          int64     `gorm:"column:create_by;type:bigint(20)" json:"create_by"`                          // 创建者
+	UpdateBy          int64     `gorm:"column:update_by;type:bigint(20)" json:"update_by"`                          // 更新者
+	CreatedAt         time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`                       // 创建时间
+	UpdatedAt         time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`                       // 最后更新时间
+	DeletedAt         time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"`          // 删除时间
 }
 
 func (m *MerchantCard) TableName() string {