黄梓健 5 years ago
parent
commit
c375b3820f
  1. 8
      controllers/pc/order_draw.go
  2. 13
      services/lottery/order.go

8
controllers/pc/order_draw.go

@ -360,14 +360,8 @@ func (t *OrderDrawCtl) ListOfWinners() {
orderDrawRuleId := t.MustGetInt64("order_draw_rule_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
result := make([]*WinnerResult, 0)
err := core.GetXormAuto().Table(new(models.OrderDrawRecord)).Alias("r").
Select("r.user_id, u.nickname as username, u.phone as user_phone, u.avatar, r.prize_name").
Join("LEFT", new(models.User).Alias("u"), "u.id=r.user_id and u.is_delete=0").
Where("r.is_delete=0 and r.order_draw_rule_id=? and r.rehearsal_id=?",
orderDrawRuleId, rehearsalId).Find(&result)
result, err := lottery_service.GetOrderWinnersResult(orderDrawRuleId, rehearsalId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"total": len(result),
"list": result,

13
services/lottery/order.go

@ -36,3 +36,16 @@ func GetOrderLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehears
return userIds, nil
}
func GetOrderWinnersResult(ruleId, rehearsalId interface{}) ([]*WinnersResult, error) {
result := make([]*WinnersResult, 0)
err := core.GetXormAuto().Table(new(models.OrderDrawRecord)).Alias("r").
Select("r.user_id, u.nickname as username, u.phone as user_phone, u.avatar, r.prize_name").
Join("LEFT", new(models.User).Alias("u"), "u.id=r.user_id and u.is_delete=0").
Where("r.is_delete=0 and r.order_draw_rule_id=? and r.rehearsal_id=?",
ruleId, rehearsalId).Find(&result)
if err != nil {
return nil, err
}
return result, nil
}
Loading…
Cancel
Save