|
|
@ -27,22 +27,22 @@ func (t *LotteryCtl) UserLotteries() { |
|
|
|
} |
|
|
|
|
|
|
|
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") |
|
|
|
record := new(models.LotteryDrawRecord) |
|
|
|
exist, err := record.GetByUserPrizeId(prizeId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_DRAW_RECORD_NOT_EXIST, "中奖记录不存在") |
|
|
|
record.Name = name |
|
|
|
record.Phone = phone |
|
|
|
record.WxNo = wxNo |
|
|
|
record.Address = address |
|
|
|
record.Status = 1 |
|
|
|
_, err = record.Update(record.Id, "name", "phone", "wx_no", "address", "status") |
|
|
|
t.CheckErr(err) |
|
|
|
t.SUCCESS("兑奖成功") |
|
|
|
} |
|
|
@ -51,20 +51,28 @@ func (t *LotteryCtl) CheckLottery() { |
|
|
|
uid := t.MustGetUID() |
|
|
|
ladderId := t.MustGetInt64("lottery_draw_ladder_id") |
|
|
|
|
|
|
|
ladder := new(models.LotteryDrawRuleLadder) |
|
|
|
exist, err := models.GetById(ladder, ladderId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
|
record := new(models.LotteryDrawRecord) |
|
|
|
exist, err := record.GetByUserIdAndLadderId(uid, ladderId) |
|
|
|
exist, err = record.GetByUserIdAndLadderId(uid, ladderId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_DRAW_NOT_HIT, "没有中奖") |
|
|
|
t.JSON(record) |
|
|
|
t.JSON(map[string]interface{}{ |
|
|
|
"record": record, |
|
|
|
"ladder": ladder, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
type WinnersResult struct { |
|
|
|
UserId int64 `json:"user_id"` |
|
|
|
UserName string `json:"user_name"` |
|
|
|
UserPhone string `json:"user_phone"` |
|
|
|
Avatar string `json:"avatar"` |
|
|
|
PrizeName string `json:"prize_name"` |
|
|
|
} |
|
|
|
//type WinnersResult struct {
|
|
|
|
// UserId int64 `json:"user_id"`
|
|
|
|
// UserName string `json:"user_name"`
|
|
|
|
// UserPhone string `json:"user_phone"`
|
|
|
|
// Avatar string `json:"avatar"`
|
|
|
|
// PrizeName string `json:"prize_name"`
|
|
|
|
//}
|
|
|
|
|
|
|
|
//获取中奖名单
|
|
|
|
func (t *LotteryCtl) Winners() { |
|
|
@ -81,16 +89,17 @@ func (t *LotteryCtl) Winners() { |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
|
result := make([]*WinnersResult, 0) |
|
|
|
err = core.GetXormAuto().Table("ox_lottery_draw_record").Alias("record"). |
|
|
|
result := make([]*LotteryUsersResult, 0) |
|
|
|
err = core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Alias("record"). |
|
|
|
Join("LEFT", new(models.User).Alias("user"), "user.id=record.user_id and user.is_delete=0"). |
|
|
|
Where("record.is_delete=0 and record.lottery_draw_rule_id=? and record.rehearsal_id=?", ladder.LotteryDrawRuleId, |
|
|
|
Where("record.is_delete=0 and record.lottery_draw_rule_ladder_id=? and record.rehearsal_id=?", ladderId, |
|
|
|
activity.RehearsalId). |
|
|
|
Find(&result) |
|
|
|
t.CheckErr(err) |
|
|
|
t.JSON(map[string]interface{}{ |
|
|
|
"total": len(result), |
|
|
|
"list": result, |
|
|
|
"total": len(result), |
|
|
|
"ladder": ladder, |
|
|
|
"list": result, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|