互动
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
1009 B

package client
import (
"github.com/ouxuanserver/osmanthuswine/src/core"
"hudongzhuanjia/controllers"
"hudongzhuanjia/models"
)
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("兑奖成功")
}