merchant.active.draw.product.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "github.com/shopspring/decimal"
  5. "time"
  6. )
  7. // 中奖活动商品 库存,中奖率
  8. type MerchantActiveDrawProduct struct {
  9. ID int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
  10. MerchantOpenID string `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"`
  11. DrawProductName string `gorm:"column:draw_product_name;type:varchar(255)" json:"draw_product_name"` // 抽奖名称
  12. DrawOdds decimal.Decimal `gorm:"column:draw_odds;type:decimal(10,2)" json:"draw_odds"` // 中奖概率
  13. Stock int `gorm:"column:stock;type:int(11)" json:"stock"` // 剩余库存
  14. Version int `gorm:"column:version;type:int(11)" json:"version"` // Version
  15. IsPrize bool `gorm:"column:is_prize;type:tinyint(1)" json:"is_prize"` // 是否需要兑奖 谢谢惠顾不需要兑奖
  16. DrawUrl string `gorm:"column:draw_url;type:varchar(255)" json:"draw_url"` // 中奖图片
  17. TotalStock int `gorm:"column:total_stock;type:int(11)" json:"total_stock"` // 总库存
  18. ActiveConfigID int64 `gorm:"column:active_config_id;type:bigint(20)" json:"active_config_id"` // 关联活动
  19. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"` // 创建者
  20. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"` // 更新者
  21. CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` // 创建时间
  22. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` // 最后更新时间
  23. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
  24. }
  25. func (m *MerchantActiveDrawProduct) TableName() string {
  26. return "merchant_active_draw_product"
  27. }
  28. func (u *MerchantActiveDrawProduct) Create() (MerchantActiveDrawProduct, error) {
  29. var doc MerchantActiveDrawProduct
  30. var err error
  31. doc = *u
  32. err = orm.ShMysql.Table(u.TableName()).Create(&doc).Error
  33. if err != nil {
  34. return doc, err
  35. }
  36. return doc, nil
  37. }