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

5 years ago
5 years ago
5 years ago
5 years ago
  1. package client
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "hudongzhuanjia/controllers"
  5. "hudongzhuanjia/models"
  6. )
  7. type LotteryCtl struct {
  8. controllers.AuthorCtl
  9. }
  10. func (t *LotteryCtl) UserLotteries() {
  11. uid := t.MustGetUID()
  12. userPrizes := make([]*models.UserPrize, 0)
  13. err := core.GetXormAuto().Where("is_delete=0 and user_id=? ", uid).Desc("created_at").Find(&userPrizes)
  14. t.CheckErr(err)
  15. t.JSON(map[string]interface{}{
  16. "list": userPrizes,
  17. "total": len(userPrizes),
  18. })
  19. }
  20. func (t *LotteryCtl) CashLottery() {
  21. uid := t.MustGetUID()
  22. prizeId := t.MustGetInt64("prize_id")
  23. name := t.MustGet("name")
  24. phone := t.MustGet("phone")
  25. wxNo := t.MustGet("wx_no")
  26. address := t.MustGet("address")
  27. prize := new(models.UserPrize)
  28. prize.Id = prizeId
  29. prize.UserId = uid
  30. prize.Name = name
  31. prize.Phone = phone
  32. prize.WxNo = wxNo
  33. prize.Address = address
  34. prize.Status = 1
  35. err := prize.Update("name", "phone", "wx_no", "address", "status")
  36. t.CheckErr(err)
  37. t.SUCCESS("兑奖成功")
  38. }