cancel_log.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "time"
  5. )
  6. type CancelLog struct {
  7. ID int64 `gorm:"column:id;type:bigint(20)" json:"id"` // 主键
  8. ClientOpenID string `gorm:"column:client_open_id;type:varchar(255)" json:"client_open_id"`
  9. MerchantOpenID string `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"`
  10. MerchantID int64 `gorm:"column:merchant_id;type:bigint(20)" json:"merchant_id"` // 商户卡id
  11. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"`
  12. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"`
  13. CreatedAt time.Time `gorm:"column:created_at;type:datetime" json:"created_at"`
  14. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime" json:"updated_at"`
  15. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime" json:"deleted_at"`
  16. }
  17. func (m *CancelLog) TableName() string {
  18. return "cancel_log"
  19. }
  20. func (u *CancelLog) Create() (CancelLog, error) {
  21. var doc CancelLog
  22. var err error
  23. doc = *u
  24. err = orm.ShMysql.Table(u.TableName()).Create(&doc).Error
  25. if err != nil {
  26. return doc, err
  27. }
  28. return doc, nil
  29. }
  30. func (u *CancelLog) GetNumber() int {
  31. var count int
  32. tableCount := orm.ShMysql.Table(u.TableName()).Where("client_open_id = ? and merchant_id = ?", u.ClientOpenID, u.MerchantID)
  33. tableCount.Count(&count)
  34. return count
  35. }