Browse Source

二维码

k.zhang 1 year ago
parent
commit
daf3884a71
3 changed files with 54 additions and 54 deletions
  1. 5 4
      apis/shanghu/merchant.card.go
  2. 25 25
      apis/shanghu/models/card.go
  3. 24 25
      models/shanghu/merchant_card.go

+ 5 - 4
apis/shanghu/merchant.card.go

@@ -517,6 +517,7 @@ func UpdateMerchantCardWXYZ(c *gin.Context) {
 		return
 	}
 
+	//"json: cannot unmarshal number -0.33279827286174424 into Go struct field WHXYStr.rotate of type int"
 	err = json.Unmarshal([]byte(inData.Whxy), &whxy)
 	if err != nil {
 		app.Error(c, 400, err, err.Error())
@@ -524,10 +525,10 @@ func UpdateMerchantCardWXYZ(c *gin.Context) {
 	}
 	for i := 0; i < len(whxy); i++ {
 		if !whxy[i].Y.IsZero() {
-			sqlData.W = whxy[i].W
-			sqlData.X = whxy[i].X
-			sqlData.Y = whxy[i].Y
-			sqlData.H = whxy[i].H
+			sqlData.W = whxy[i].W.String()
+			sqlData.X = whxy[i].X.String()
+			sqlData.Y = whxy[i].Y.String()
+			sqlData.H = whxy[i].H.String()
 		}
 	}
 	sqlData.ID = inData.MerchantCardId

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

@@ -28,23 +28,23 @@ type GetMerchantCardRequest struct {
 }
 
 type GetMerchantCardReply struct {
-	MerchantCardName  string          `json:"merchant_card_name"`  // 商户卡名称
-	MerchantOpenID    string          `json:"merchant_open_id"`    // openid
-	CardProjectData   string          `json:"card_project_data"`   // 项目
-	CardPrice         string          `json:"card_price"`          // 单价
-	ActivityEndTime   string          `json:"activity_end_time"`   // 活动结束时间
-	ActivityStartTime string          `json:"activity_start_time"` // 活动开始时间
-	MerchantCardTime  string          `json:"merchant_card_time"`  // 商户卡有效期
-	Inventory         int64           `json:"inventory"`           // 库存数量
-	QuotaNum          int64           `json:"quota_num"`           // 限购数量
-	UseRule           string          `json:"use_rule"`            // 使用规则
-	Picture           string          `json:"picture"`             // 图片
-	RebateRate        int64           `json:"rebate_rate"`
-	BackgroundImage   string          `json:"background_image"` //背景图
-	W                 decimal.Decimal `json:"w"`                // w
-	H                 decimal.Decimal `json:"h"`                // h
-	X                 decimal.Decimal `json:"x"`                // x
-	Y                 decimal.Decimal `json:"y"`                // y
+	MerchantCardName  string `json:"merchant_card_name"`  // 商户卡名称
+	MerchantOpenID    string `json:"merchant_open_id"`    // openid
+	CardProjectData   string `json:"card_project_data"`   // 项目
+	CardPrice         string `json:"card_price"`          // 单价
+	ActivityEndTime   string `json:"activity_end_time"`   // 活动结束时间
+	ActivityStartTime string `json:"activity_start_time"` // 活动开始时间
+	MerchantCardTime  string `json:"merchant_card_time"`  // 商户卡有效期
+	Inventory         int64  `json:"inventory"`           // 库存数量
+	QuotaNum          int64  `json:"quota_num"`           // 限购数量
+	UseRule           string `json:"use_rule"`            // 使用规则
+	Picture           string `json:"picture"`             // 图片
+	RebateRate        int64  `json:"rebate_rate"`
+	BackgroundImage   string `json:"background_image"` //背景图
+	W                 string `json:"w"`                // w
+	H                 string `json:"h"`                // h
+	X                 string `json:"x"`                // x
+	Y                 string `json:"y"`                // y
 
 }
 
@@ -139,12 +139,12 @@ type UpdateMerchantCardWHXYRequest struct {
 }
 
 type WHXYStr struct {
-	Type     string          `json:"type"`
-	URL      string          `json:"url"`
-	Y        decimal.Decimal `json:"y,omitempty"`
-	X        decimal.Decimal `json:"x,omitempty"`
-	W        decimal.Decimal `json:"w,omitempty"`
-	H        decimal.Decimal `json:"h,omitempty"`
-	Rotate   int             `json:"rotate,omitempty"`
-	SourceID any             `json:"sourceId,omitempty"`
+	Type string          `json:"type"`
+	URL  string          `json:"url"`
+	Y    decimal.Decimal `json:"y,omitempty"`
+	X    decimal.Decimal `json:"x,omitempty"`
+	W    decimal.Decimal `json:"w,omitempty"`
+	H    decimal.Decimal `json:"h,omitempty"`
+	//Rotate   int             `json:"rotate,omitempty"`
+	//SourceID any `json:"sourceId,omitempty"`
 }

+ 24 - 25
models/shanghu/merchant_card.go

@@ -3,35 +3,34 @@ package shanghu
 import (
 	orm "duoduo/database"
 	"duoduo/tools"
-	"github.com/shopspring/decimal"
 	"time"
 )
 
 type MerchantCard struct {
-	ID                int64           `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
-	MerchantCardName  string          `gorm:"column:merchant_card_name;type:varchar(255)" json:"merchant_card_name"`      // 商户卡名称
-	MerchantOpenID    string          `gorm:"column:merchant_open_id;type:varchar(255);NOT NULL" json:"merchant_open_id"` // openid
-	CardProjectData   string          `gorm:"column:card_project_data;type:json" json:"card_project_data"`                // 项目
-	CardPrice         string          `gorm:"column:card_price;type:decimal(10,2)" json:"card_price"`                     // 单价
-	ActivityEndTime   int64           `gorm:"column:activity_end_time;type:bigint(20)" json:"activity_end_time"`          // 活动结束时间
-	ActivityStartTime int64           `gorm:"column:activity_start_time;type:bigint(20)" json:"activity_start_time"`      // 活动开始时间
-	MerchantCardTime  int64           `gorm:"column:merchant_card_time;type:bigint(20)" json:"merchant_card_time"`        // 商户卡有效期
-	Inventory         int64           `gorm:"column:inventory;type:bigint(20)" json:"inventory"`                          // 库存数量
-	QuotaNum          int64           `gorm:"column:quota_num;type:int(11)" json:"quota_num"`                             // 限购数量
-	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"`          // 删除时间
-	BackgroundImage   string          `gorm:"column:background_image;type:varchar(255)" json:"background_image"`          //背景图
-	W                 decimal.Decimal `gorm:"column:w;type:decimal(16,2);default:null" json:"w"`                          // w
-	H                 decimal.Decimal `gorm:"column:h;type:decimal(16,2);default:null" json:"h"`                          // h
-	X                 decimal.Decimal `gorm:"column:x;type:decimal(16,2);default:null" json:"x"`                          // x
-	Y                 decimal.Decimal `gorm:"column:y;type:decimal(16,2);default:null" json:"y"`                          // y
+	ID                int64     `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
+	MerchantCardName  string    `gorm:"column:merchant_card_name;type:varchar(255)" json:"merchant_card_name"`      // 商户卡名称
+	MerchantOpenID    string    `gorm:"column:merchant_open_id;type:varchar(255);NOT NULL" json:"merchant_open_id"` // openid
+	CardProjectData   string    `gorm:"column:card_project_data;type:json" json:"card_project_data"`                // 项目
+	CardPrice         string    `gorm:"column:card_price;type:decimal(10,2)" json:"card_price"`                     // 单价
+	ActivityEndTime   int64     `gorm:"column:activity_end_time;type:bigint(20)" json:"activity_end_time"`          // 活动结束时间
+	ActivityStartTime int64     `gorm:"column:activity_start_time;type:bigint(20)" json:"activity_start_time"`      // 活动开始时间
+	MerchantCardTime  int64     `gorm:"column:merchant_card_time;type:bigint(20)" json:"merchant_card_time"`        // 商户卡有效期
+	Inventory         int64     `gorm:"column:inventory;type:bigint(20)" json:"inventory"`                          // 库存数量
+	QuotaNum          int64     `gorm:"column:quota_num;type:int(11)" json:"quota_num"`                             // 限购数量
+	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"`          // 删除时间
+	BackgroundImage   string    `gorm:"column:background_image;type:varchar(255)" json:"background_image"`          //背景图
+	W                 string    `gorm:"column:w;type:varchar(255);default:null" json:"w"`                           // w
+	H                 string    `gorm:"column:h;type:varchar(255);default:null" json:"h"`                           // h
+	X                 string    `gorm:"column:x;type:varchar(255);default:null" json:"x"`                           // x
+	Y                 string    `gorm:"column:y;type:varchar(255);default:null" json:"y"`                           // y
 }
 
 func (m *MerchantCard) TableName() string {