互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.8 KiB

  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const UserTransferTN = TableNamePrefix + "user_transfer"
  7. type UserTransfer struct {
  8. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  9. CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"`
  10. UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"`
  11. IsDelete int `json:"is_delete" xorm:"not null default 0 comment('是否删除') TINYINT(1)"`
  12. DeviceInfo string `json:"device_info" xorm:"not null default '' comment('设备信息') VARCHAR(32)"`
  13. NonceStr string `json:"nonce_str" xorm:"not null default '' comment('随机字符串') VARCHAR(32)"`
  14. PartnerTradeNo string `json:"partner_trade_no" xorm:"not null default '' comment('商户订单号') VARCHAR(32)"`
  15. PaymentNo string `json:"payment_no" xorm:"not null default '' comment('微信付款单号') VARCHAR(64)"`
  16. PaymentTime string `json:"payment_time" xorm:"not null default '' comment('企业付款成功时间') VARCHAR(32)"`
  17. Status int `json:"status" xorm:"not null default 0 comment('0未处理1处理中2转账成功3转账失败4查询尝试失败') TINYINT(1)"`
  18. Reason string `json:"reason" xorm:"not null default '' comment('转账失败原因') VARCHAR(255)"`
  19. OpenId string `json:"open_id" xorm:"not null default '' comment('用户open_id') VARCHAR(64)"`
  20. PaymentAmount int `json:"payment_amount" xorm:"not null default 0 comment('转账金额,单位分') INT(18)"`
  21. TransferTime string `json:"transfer_time" xorm:"not null default '' comment('转账时间') VARCHAR(32)"`
  22. Desc string `json:"desc" xorm:"not null default '' comment('备注') VARCHAR(128)"`
  23. ErrMsg string `json:"err_msg" xorm:"not null default '' comment('错误信息') VARCHAR(255)"`
  24. }
  25. func (t *UserTransfer) TableName() string {
  26. return UserTransferTN
  27. }
  28. func GetUserTransferByStatus(status ...int) ([]*UserTransfer, error) {
  29. transfers := make([]*UserTransfer, 0)
  30. err := core.GetXormAuto().Where("is_delete=0").In("status", status).Find(&transfers)
  31. return transfers, err
  32. }
  33. func (t *UserTransfer) Add() (int64, error) {
  34. return core.GetXormAuto().InsertOne(t)
  35. }
  36. func (t *UserTransfer) GetByPartnerTradeNo(partnerTradeNo string) (bool, error) {
  37. return core.GetXormAuto().Where("is_delete=0 and partner_trade_no=?", partnerTradeNo).Get(t)
  38. }
  39. func (t *UserTransfer) UpdateByPartnerTradeNo(partnerTradeNo string) (int64, error) {
  40. return core.GetXormAuto().Where("is_delete=0 and partner_trade_no=?", partnerTradeNo).Update(t)
  41. }
  42. func (t *UserTransfer) UpdateErrMsg(partnerTradeNo, msg string) (int64, error) {
  43. return core.GetXormAuto().Where("is_delete=0 and partner_trade_no=?", partnerTradeNo).Update(&UserTransfer{ErrMsg: msg})
  44. }