client.active.draw.num.go 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "time"
  5. )
  6. type ClientActiveDrawNum struct {
  7. ID int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"`
  8. ActiveConfigID int64 `gorm:"column:active_config_id;type:bigint(20)" json:"active_config_id"`
  9. ClientOpenID string `gorm:"column:client_open_id;type:varchar(255)" json:"client_open_id"` // 邀请人
  10. ClientOpenIDInvited string `gorm:"column:client_open_id_invited;type:varchar(255)" json:"client_open_id_invited"` // 被邀请人
  11. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"` // 创建者
  12. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"` // 更新者
  13. CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` // 创建时间
  14. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` // 最后更新时间
  15. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
  16. }
  17. func (m *ClientActiveDrawNum) TableName() string {
  18. return "client_active_draw_num"
  19. }
  20. // 抽奖次数
  21. func (m *ClientActiveDrawNum) GetDrawNum() (int, error) {
  22. table := orm.ShMysql.Table(m.TableName())
  23. table = table.Where("client_open_id = ? and active_config_id = ? ", m.ClientOpenID, m.ActiveConfigID)
  24. var count int
  25. table.Count(&count)
  26. return count, nil
  27. }