互动
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.

45 lines
2.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "time"
  4. "github.com/ouxuanserver/osmanthuswine/src/core"
  5. )
  6. const LiveRedPackInfoTN = TableNamePrefix + "live_red_envelope_rule"
  7. type LiveRedEnvelopeRule struct {
  8. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  9. IsDelete bool `json:"-" xorm:"not null default 0 comment('是否删除') TINYINT(1)"`
  10. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  11. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"`
  12. UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"`
  13. ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
  14. AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
  15. RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id') INT(11)"`
  16. GroupId string `json:"group_id" xorm:"not null default '' comment('聊天室地址') VARCHAR(128)"`
  17. Prompt string `json:"prompt" xorm:"not null default 0 comment('祝福语') VARCHAR(255)"`
  18. Amount float64 `json:"amount" xorm:"not null default 0 comment('红包金额') DECIMAL(18)"`
  19. Num int `json:"num" xorm:"not null default 0 comment('红包个数') INT(11)"`
  20. OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('订单号') VARCHAR(128)"`
  21. Status int `json:"status" xorm:"not null default 0 comment('-1已作废0尚未支付1支付成功/已推送')"`
  22. }
  23. func (t *LiveRedEnvelopeRule) TableName() string {
  24. return LiveRedPackInfoTN
  25. }
  26. func (t *LiveRedEnvelopeRule) Add() (int64, error) {
  27. return core.GetXormAuto().InsertOne(t)
  28. }
  29. func (t *LiveRedEnvelopeRule) GetByOutTradeNo(outTradeNo string) (bool, error) {
  30. return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo).Get(t)
  31. }
  32. func (t *LiveRedEnvelopeRule) UpdateStatusByOutTradeNo(outTradeNo string, status int) (int64, error) {
  33. t.Status = status
  34. return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo).
  35. Cols("status").Update(t)
  36. }