diff --git a/controllers/pc/order_draw.go b/controllers/pc/order_draw.go index 5f3526a..546a747 100644 --- a/controllers/pc/order_draw.go +++ b/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, diff --git a/services/lottery/order.go b/services/lottery/order.go index 227a298..2f96592 100644 --- a/services/lottery/order.go +++ b/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 +}