diff --git a/internal/biz/bo/order_bo.go b/internal/biz/bo/order_bo.go index d84e2d7..00f60a3 100644 --- a/internal/biz/bo/order_bo.go +++ b/internal/biz/bo/order_bo.go @@ -16,7 +16,7 @@ type OrderBo struct { Status vo.OrderStatus AppID string MerchantNo string - Channel vo.OrderChannel + Channel vo.Channel CreateTime *time.Time UpdateTime *time.Time } @@ -27,7 +27,7 @@ type OrderCreateReqBo struct { ProductNo string Account string AccountType vo.OrderAccountType - Channel vo.OrderChannel + Channel vo.Channel AppID string MerchantNo string } diff --git a/internal/biz/bo/product_bo.go b/internal/biz/bo/product_bo.go index b14b938..c17310f 100644 --- a/internal/biz/bo/product_bo.go +++ b/internal/biz/bo/product_bo.go @@ -1,17 +1,20 @@ package bo -import "time" +import ( + "time" + "voucher/internal/biz/vo" +) // ProductBo 领域实体Bo结构,字段和模型字段保持一致 type ProductBo struct { - ID int32 - Name string - ProductNo string - BatchName string - BatchNo string - AppID string - MerchantNo string - Channel bool - CreateTime time.Time - UpdateTime time.Time + ID int32 + Name string + ProductNo string + BatchName string + BatchNo string + AppID string + MerchantNo string + Channel vo.Channel + CreateTime *time.Time + UpdateTime *time.Time } diff --git a/internal/biz/vo/channel.go b/internal/biz/vo/channel.go new file mode 100644 index 0000000..374d9d4 --- /dev/null +++ b/internal/biz/vo/channel.go @@ -0,0 +1,32 @@ +package vo + +type Channel uint8 + +const ( + OrderChannelWechat Channel = iota + 1 + OrderChannelAlipay +) + +var OrderChannelMap = map[Channel]string{ + OrderChannelWechat: "微信", + OrderChannelAlipay: "支付宝", +} + +func (s Channel) GetText() string { + if t, ok := OrderChannelMap[s]; ok { + return t + } + return "" +} + +func (s Channel) GetValue() uint8 { + return uint8(s) +} + +func (s Channel) IsWeChat() bool { + return s == OrderChannelWechat +} + +func (s Channel) IsAlipay() bool { + return s == OrderChannelAlipay +} diff --git a/internal/biz/vo/order_channel.go b/internal/biz/vo/order_channel.go deleted file mode 100644 index ba48d51..0000000 --- a/internal/biz/vo/order_channel.go +++ /dev/null @@ -1,32 +0,0 @@ -package vo - -type OrderChannel uint8 - -const ( - OrderChannelWechat OrderChannel = iota + 1 - OrderChannelAlipay -) - -var OrderChannelMap = map[OrderChannel]string{ - OrderChannelWechat: "微信", - OrderChannelAlipay: "支付宝", -} - -func (s OrderChannel) GetText() string { - if t, ok := OrderChannelMap[s]; ok { - return t - } - return "" -} - -func (s OrderChannel) GetValue() uint8 { - return uint8(s) -} - -func (s OrderChannel) IsWeChat() bool { - return s == OrderChannelWechat -} - -func (s OrderChannel) IsAlipay() bool { - return s == OrderChannelAlipay -} diff --git a/internal/data/model/product.gen.go b/internal/data/model/product.gen.go index 890f74b..a10afb1 100644 --- a/internal/data/model/product.gen.go +++ b/internal/data/model/product.gen.go @@ -12,16 +12,16 @@ const TableNameProduct = "product" // Product mapped from table type Product struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` - Name string `gorm:"column:name;not null;comment:商品名称" json:"name"` // 商品名称 - ProductNo string `gorm:"column:product_no;not null;comment:商品编号" json:"product_no"` // 商品编号 - BatchName string `gorm:"column:batch_name;not null;comment:批次名称" json:"batch_name"` // 批次名称 - BatchNo string `gorm:"column:batch_no;not null;comment:立减金批次号" json:"batch_no"` // 立减金批次号 - AppID string `gorm:"column:app_id;not null;comment:批次所属应用" json:"app_id"` // 批次所属应用 - MerchantNo string `gorm:"column:merchant_no;not null;comment:商户号,创建批次的商户号" json:"merchant_no"` // 商户号,创建批次的商户号 - Channel bool `gorm:"column:channel;not null;comment:1:微信 2:支付宝" json:"channel"` // 1:微信 2:支付宝 - CreateTime time.Time `gorm:"column:create_time;not null" json:"create_time"` - UpdateTime time.Time `gorm:"column:update_time" json:"update_time"` + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` + Name string `gorm:"column:name;not null;comment:商品名称" json:"name"` // 商品名称 + ProductNo string `gorm:"column:product_no;not null;comment:商品编号" json:"product_no"` // 商品编号 + BatchName string `gorm:"column:batch_name;not null;comment:批次名称" json:"batch_name"` // 批次名称 + BatchNo string `gorm:"column:batch_no;not null;comment:立减金批次号" json:"batch_no"` // 立减金批次号 + AppID string `gorm:"column:app_id;not null;comment:批次所属应用" json:"app_id"` // 批次所属应用 + MerchantNo string `gorm:"column:merchant_no;not null;comment:商户号,创建批次的商户号" json:"merchant_no"` // 商户号,创建批次的商户号 + Channel uint8 `gorm:"column:channel;not null;comment:1:微信 2:支付宝" json:"channel"` // 1:微信 2:支付宝 + CreateTime *time.Time `gorm:"column:create_time;not null" json:"create_time"` + UpdateTime *time.Time `gorm:"column:update_time" json:"update_time"` } // TableName Product's table name