recharge_cancel_log.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "time"
  5. )
  6. type RechargeCancelLog struct {
  7. ID int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" 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. QuantityPre int `gorm:"column:quantity_pre;type:int(11)" json:"quantity_pre"` // 核销前数量
  11. QuantityAfter int `gorm:"column:quantity_after;type:int(11)" json:"quantity_after"` // 核销后数量
  12. Quantity int `gorm:"column:quantity;type:int(11)" json:"quantity"` // 数量
  13. Operator string `gorm:"column:operator;type:varchar(255)" json:"operator"` // operator 操作人
  14. RechargeID int64 `gorm:"column:recharge_id;type:bigint(20)" json:"recharge_id"`
  15. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"`
  16. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"`
  17. CreatedAt time.Time `gorm:"column:created_at;type:datetime" json:"created_at"`
  18. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime" json:"updated_at"`
  19. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime;default:null" json:"deleted_at"`
  20. }
  21. func (m *RechargeCancelLog) TableName() string {
  22. return "recharge_cancel_log"
  23. }
  24. // list 接口使用
  25. func (m *RechargeCancelLog) RechargeCancelLogByClientList(pageSize int, pageIndex int) ([]RechargeCancelLog, int, error) {
  26. var doc []RechargeCancelLog
  27. table := orm.ShMysql.Table(m.TableName())
  28. table = table.Where("client_open_id = ? ", m.ClientOpenID)
  29. var count int
  30. if err := table.Select("*").Order("id desc").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
  31. return nil, 0, err
  32. }
  33. table.Count(&count)
  34. return doc, count, nil
  35. }
  36. // list 接口使用
  37. func (m *RechargeCancelLog) RechargeCancelLogByMerchantList(pageSize int, pageIndex int) ([]RechargeCancelLog, int, error) {
  38. var doc []RechargeCancelLog
  39. table := orm.ShMysql.Table(m.TableName())
  40. table = table.Where("merchant_open_id = ? ", m.MerchantOpenID)
  41. var count int
  42. if err := table.Select("*").Order("id desc").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
  43. return nil, 0, err
  44. }
  45. table.Count(&count)
  46. return doc, count, nil
  47. }