merchant.active.group.by.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "github.com/shopspring/decimal"
  5. "time"
  6. )
  7. type MerchantActiveGroupBuy struct {
  8. ID int64 `gorm:"column:id;type:bigint(20);primary_key" json:"id"`
  9. ActiveConfigID int64 `gorm:"column:active_config_id;type:bigint(20)" json:"active_config_id"` // 关联活动
  10. GroupBuyName string `gorm:"column:group_buy_name;type:varchar(255)" json:"group_buy_name"` // 拼团名
  11. GroupBuyMode int `gorm:"column:group_buy_mode;type:int(11)" json:"group_buy_mode"` // 拼团模式 1-真实拼团 2-虚拟拼团
  12. MerchantOpenID string `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"`
  13. OriginalPrice decimal.Decimal `gorm:"column:original_price;type:decimal(10,2)" json:"original_price"` // 原价
  14. GroupBuyOneNum int `gorm:"column:group_buy_one_num;type:int(11)" json:"group_buy_one_num"` // 人数
  15. GroupBuyOnePrice decimal.Decimal `gorm:"column:group_buy_one_price;type:decimal(10,2)" json:"group_buy_one_price"` // 价格
  16. GroupBuyTwoNum int `gorm:"column:group_buy_two_num;type:int(11)" json:"group_buy_two_num"` // 人数
  17. GroupBuyTwoPrice decimal.Decimal `gorm:"column:group_buy_two_price;type:decimal(10,2)" json:"group_buy_two_price"` // 价格
  18. GroupBuyThreeNum int `gorm:"column:group_buy_three_num;type:int(11)" json:"group_buy_three_num"`
  19. GroupBuyThreePrice decimal.Decimal `gorm:"column:group_buy_three_price;type:decimal(10,2)" json:"group_buy_three_price"`
  20. GroupBuyFourNum int `gorm:"column:group_buy_four_num;type:int(11)" json:"group_buy_four_num"`
  21. GroupBuyFourPrice decimal.Decimal `gorm:"column:group_buy_four_price;type:decimal(10,2)" json:"group_buy_four_price"`
  22. GroupBuyUrl string `gorm:"column:group_buy_url;type:varchar(255)" json:"group_buy_url"` // 图片
  23. GroupBuyBigUrl string `gorm:"column:group_buy_big_url;type:varchar(255)" json:"group_buy_big_url"` // 大图
  24. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"` // 创建者
  25. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"` // 更新者
  26. CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` // 创建时间
  27. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` // 最后更新时间
  28. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
  29. }
  30. func (m *MerchantActiveGroupBuy) TableName() string {
  31. return "merchant_active_group_buy"
  32. }
  33. func (u *MerchantActiveGroupBuy) Create() (MerchantActiveGroupBuy, error) {
  34. var doc MerchantActiveGroupBuy
  35. var err error
  36. doc = *u
  37. err = orm.ShMysql.Table(u.TableName()).Create(&doc).Error
  38. if err != nil {
  39. return doc, err
  40. }
  41. return doc, nil
  42. }