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.
48 lines
2.1 KiB
48 lines
2.1 KiB
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
)
|
|
|
|
const LiveRedPackInfoTN = TableNamePrefix + "live_red_envelope_rule"
|
|
|
|
type LiveRedEnvelopeRule struct {
|
|
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
|
|
IsDelete bool `json:"-" xorm:"not null default 0 comment('是否删除') TINYINT(1)"`
|
|
CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
|
|
UpdatedAt time.Time `json:"updated_at" xorm:"not null updated default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"`
|
|
|
|
UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"`
|
|
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
|
|
GroupId string `json:"group_id" xorm:"not null default '' comment('聊天室地址') VARCHAR(128)"`
|
|
Prompt string `json:"prompt" xorm:"not null default 0 comment('祝福语') VARCHAR(255)"`
|
|
Amount float64 `json:"amount" xorm:"not null default 0 comment('红包金额') DECIMAL(18)"`
|
|
OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('订单号') VARCHAR(128)"`
|
|
Error string `json:"error" xorm:"not null default '' comment('出现错误') VARCHAR(255)"`
|
|
Status int `json:"status" xorm:"not null default 0 comment('-1尚未支付0支付成功1已推送2已作废')"`
|
|
}
|
|
|
|
func (t *LiveRedEnvelopeRule) TableName() string {
|
|
return LiveRedPackInfoTN
|
|
}
|
|
|
|
func (t *LiveRedEnvelopeRule) Add() (int64, error) {
|
|
return core.GetXormAuto().InsertOne(t)
|
|
}
|
|
|
|
func GetLiveRedPackInfos(status int) ([]*LiveRedEnvelopeRule, error) {
|
|
infos := make([]*LiveRedEnvelopeRule, 0)
|
|
err := core.GetXormAuto().Where("is_delete=0 and status=?", status).Find(&infos)
|
|
return infos, err
|
|
}
|
|
|
|
func (t *LiveRedEnvelopeRule) GetByOutTradeNo(outTradeNo string) (bool, error) {
|
|
return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo).Get(t)
|
|
}
|
|
|
|
func (t *LiveRedEnvelopeRule) UpdateStatusByOutTradeNo(outTradeNo string, status int) (int64, error) {
|
|
t.Status = status
|
|
return core.GetXormAuto().Where("is_delete=0 and status=0 and out_trade_no=?", outTradeNo).Update(t)
|
|
}
|