actvie.client.account.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "time"
  5. )
  6. type ActiveClientAccount 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. ReviewAmount string `gorm:"column:review_amount;type:decimal(10,2)" json:"review_amount"` // 待核销金额
  10. Version int `gorm:"column:version;type:int(11)" json:"version"` // Version
  11. Amount string `gorm:"column:amount;type:decimal(10,2)" json:"amount"` // 可提现金额
  12. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"` // 创建者
  13. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"` // 更新者
  14. CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` // 创建时间
  15. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` // 最后更新时间
  16. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
  17. }
  18. func (m *ActiveClientAccount) TableName() string {
  19. return "active_client_account"
  20. }
  21. func (m *ActiveClientAccount) GetMerchantAccount() (ActiveClientAccount, error) {
  22. var doc ActiveClientAccount
  23. table := orm.ShMysql.Table(m.TableName())
  24. table = table.Where("client_open_id = ? ", m.ClientOpenID)
  25. if err := table.Select("*").First(&doc).Error; err != nil {
  26. return doc, err
  27. }
  28. return doc, nil
  29. }
  30. func (m *ActiveClientAccount) Create() (ActiveClientAccount, error) {
  31. var doc ActiveClientAccount
  32. var err error
  33. doc = *m
  34. err = orm.ShMysql.Table(m.TableName()).Create(&doc).Error
  35. if err != nil {
  36. return doc, err
  37. }
  38. return doc, nil
  39. }