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