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

57 lines
1.3 KiB

package client
import (
"github.com/ouxuanserver/osmanthuswine/src/core"
"hudongzhuanjia/controllers"
"hudongzhuanjia/models"
"hudongzhuanjia/utils/code"
)
type LotteryCtl struct {
controllers.AuthorCtl
}
func (t *LotteryCtl) UserLotteries() {
uid := t.MustGetUID()
userPrizes := make([]*models.UserPrize, 0)
err := core.GetXormAuto().Where("is_delete=0 and user_id=? ", uid).Desc("created_at").Find(&userPrizes)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"list": userPrizes,
"total": len(userPrizes),
})
}
func (t *LotteryCtl) CashLottery() {
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("兑奖成功")
}
func (t *LotteryCtl) CheckLottery() {
uid := t.MustGetUID()
ladderId := t.MustGetInt64("lottery_draw_ladder_id")
record := new(models.LotteryDrawRecord)
exist, err := record.GetByUserIdAndLadderId(uid, ladderId)
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_DRAW_NOT_HIT, "没有中奖")
t.JSON(record)
}