Browse Source

cash_lottery

master
黄梓健 5 years ago
parent
commit
21dd4a5a38
  1. 21
      controllers/client/lottery.go
  2. 10
      models/user_prize.go

21
controllers/client/lottery.go

@ -22,3 +22,24 @@ func (t *LotteryCtl) UserLotteries() {
"total": len(userPrizes),
})
}
func (t *LotteryCtl) CashLotteries() {
uid := t.MustGetUID()
prizeId := t.MustGetInt64("prize_id")
name := t.MustGet("name")
phone := t.MustGet("phone")
wxNo := t.MustGet("wx_no")
address := t.MustGet("address")
prize := new(models.UserPrize)
prize.Id = prizeId
prize.UserId = uid
prize.Name = name
prize.Phone = phone
prize.WxNo = wxNo
prize.Address = address
prize.Status = 1
err := prize.Update("name", "phone", "wx_no", "address", "status")
t.CheckErr(err)
t.SUCCESS("兑奖成功")
}

10
models/user_prize.go

@ -16,6 +16,11 @@ type UserPrize struct {
PrizeName string `json:"prize_name" xorm:"not null default('') comment('奖品名字') VARCHAR(128)"`
PrizeImg string `json:"prize_img" xorm:"not null default('') comment('奖品图片') VARCHAR(255)"`
PrizeType int `json:"prize_type" xorm:"not null default(0) comment('订单来源1普通抽奖2订单抽奖3订单送礼4直播下单') INT(11)"`
Status int `json:"status" xorm:"not null default 0 comment('是否兑奖0否1是') TINYINT(1)"`
Name string `json:"name" xorm:"not null default '' comment('姓名') VARCHAR(128)"`
Phone string `json:"phone" xorm:"not null default '' comment('电话号码') VARCHAR(128)"`
WxNo string `json:"wx_no" xorm:"not null default '' comment('微信号') VARCHAR(128)"`
Address string `json:"address" xorm:"not null default '' comment('地址') VARCHAR(128)"`
IsDelete bool `json:"is_delete" 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 comment('更新时间') DATETIME"`
@ -33,3 +38,8 @@ func (t *UserPrize) SoftDeleteById(id int64) (int64, error) {
func (t *UserPrize) Add() (int64, error) {
return core.GetXormAuto().InsertOne(t)
}
func (t *UserPrize) Update(fields ...string) error {
_, err := core.GetXormAuto().Where("is_delete=0 and id = ? and user_id =?", t.Id, t.UserId).Cols(fields...).Update(t)
return err
}
Loading…
Cancel
Save