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.
51 lines
1.7 KiB
51 lines
1.7 KiB
package lottery_service
|
|
|
|
import (
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
"hudongzhuanjia/models"
|
|
"hudongzhuanjia/utils/define"
|
|
)
|
|
|
|
func GetOrderLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehearsalId, areaId interface{}) ([]int64, error) {
|
|
var err error
|
|
var userIds = make([]int64, 0)
|
|
var recordIds = make([]int64, 0)
|
|
if repeat == define.MODULE_BESIDE_REPEAT {
|
|
//查询已经中奖的用户,剔除已经中奖的用户
|
|
err = core.GetXormAuto().Table(new(models.OrderDrawRecord)).Select("user_id").
|
|
Where("order_draw_rule_id=? and rehearsal_id=? and is_delete=0",
|
|
ruleId, rehearsalId).Find(&recordIds)
|
|
} else {
|
|
// 不去除
|
|
err = core.GetXormAuto().Table(new(models.OrderDrawRecord)).Select("user_id").
|
|
Where("order_draw_rule_ladder_id=? and rehearsal_id=?",
|
|
ladderId, rehearsalId).Find(&recordIds)
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = core.GetXormAuto().Table(new(models.CustomerOrder)).
|
|
Select("buyer_id as user_id").Distinct("buyer_id").
|
|
Where("activity_id=? and rehearsal_id=? and area_id=? and is_delete=0",
|
|
activityId, rehearsalId, areaId).NotIn("buyer_id", recordIds).
|
|
Find(&userIds)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
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
|
|
}
|