merchant.account.log.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "github.com/shopspring/decimal"
  5. "time"
  6. )
  7. type MerchantAccountLog struct {
  8. ID int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // 主键
  9. ReviewAmountAfter decimal.Decimal `gorm:"column:review_amount_after;type:decimal(10,2)" json:"review_amount_after"` // 审核资金 交易后
  10. ReviewAmountPre decimal.Decimal `gorm:"column:review_amount_pre;type:decimal(10,2)" json:"review_amount_pre"` // 审核资金 交易前
  11. AmountPre decimal.Decimal `gorm:"column:amount_pre;type:decimal(10,2)" json:"amount_pre"` // 交易前
  12. AmountAfter decimal.Decimal `gorm:"column:amount_after;type:decimal(10,2)" json:"amount_after"` // 交易后
  13. TransType int `gorm:"column:trans_type;type:int(11)" json:"trans_type"` // 交易类型 0-买卡入账 1-拼团入账 2-提现
  14. MerchantOpenID string `gorm:"column:merchant_open_id;type:varchar(255)" json:"merchant_open_id"` // 商户openid
  15. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"` // 创建者
  16. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"` // 更新者
  17. CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` // 创建时间
  18. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` // 最后更新时间
  19. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
  20. Amount decimal.Decimal `gorm:"column:amount;type:decimal(10,2)" json:"amount"` // 交易金额
  21. PayTransId int64 `gorm:"column:pay_trans_id;type:bigint(20)" json:"pay_trans_id"` // 交易id
  22. }
  23. func (m *MerchantAccountLog) TableName() string {
  24. return "merchant_account_log"
  25. }
  26. const (
  27. MerchantAccountLogTransTypeCard = 0 //霸王卡入账
  28. MerchantAccountLogTransTypeGroupBuy = 1 //拼团入账
  29. MerchantAccountLogTransTypeCashOut = 2 //提现
  30. )
  31. // 获取
  32. func (m *MerchantAccountLog) GetAccountLogNum() int {
  33. var count int
  34. tableCount := orm.ShMysql.Table(m.TableName()).Where("trans_type = ? and pay_trans_id = ?", m.TransType, m.PayTransId)
  35. tableCount.Count(&count)
  36. return count
  37. }