Browse Source

fix:bug

token_replace
黄梓健 5 years ago
parent
commit
e8377b37ad
  1. 14
      controllers/pc/order_draw.go
  2. 4
      services/activity/module.go
  3. 14
      services/lottery/order.go

14
controllers/pc/order_draw.go

@ -21,7 +21,16 @@ type OrderDrawCtl struct {
// 屏蔽
func (t *OrderDrawCtl) Block() {
activityId := t.MustGetInt("activity_id")
status := t.MustGet("status")
module, exist, err := activity_service.GetModuleService(define.MODULE_ORDERLY, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "模块不存在")
module.BesideRepeat = status
_, err = models.Update(module.Id, module, "beside_repeat")
t.CheckErr(err)
t.SUCCESS("操作成功")
}
// 开启订单活动
@ -286,7 +295,8 @@ func (t *OrderDrawCtl) Draw() {
t.CheckRunning(ladder.Status)
count, err := core.GetXormAuto().Where("order_draw_rule_id=? and order_draw_rule_ladder_id=? "+
"and rehearsal_id=? and is_delete=0", ruleId, ladderId, activity.RehearsalId).Count(new(models.OrderDrawRecord))
"and rehearsal_id=? and arch_id=? and is_delete=0", ruleId, ladderId, activity.RehearsalId, activity.ArchId).
Count(new(models.OrderDrawRecord))
t.CheckErr(err)
prizeNum := ladder.PrizeNumber - int(count)
if prizeNum <= 0 || prizeNum < number {
@ -296,7 +306,7 @@ func (t *OrderDrawCtl) Draw() {
module, exist, err := activity_service.GetModuleService(define.MODULE_ORDERLY, activity.Id)
t.CheckErr(err)
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "模块服务不存在")
userIds, err := lottery_service.GetOrderLotteryUserIds(module.BesideRepeat, activity.Id, rule.Id, ladder.Id, activity.RehearsalId, area.Id)
userIds, err := lottery_service.GetOrderLotteryUserIds(module.BesideRepeat, activity.Id, rule.Id, ladder.Id, activity.RehearsalId, area.Id, activity.ArchId)
if len(userIds) < number {
t.ERROR("订单抽奖人数不足", code.MSG_LOTTERY_PEOPLE_NOT_ENOUGH)
}

4
services/activity/module.go

@ -25,9 +25,9 @@ import (
//}
func GetModuleService(moduleName, activityId interface{}) (*models.ActivityModuleService, bool, error) {
module := new(models.ActivityModuleService)
module := &models.ActivityModuleService{}
exist, err := core.GetXormAuto().Table(module).Alias("s").
Join("LEFT", new(models.ModuleServiceHistory).Alias("h"),
Join("LEFT", (&models.ModuleServiceHistory{}).Alias("h"),
"s.service_module_history_id=h.id").
Where("s.activity_id=? and s.is_delete=0 and h.name=?", activityId, moduleName).
Get(module)

14
services/lottery/order.go

@ -7,20 +7,20 @@ import (
"github.com/ouxuanserver/osmanthuswine/src/core"
)
func GetOrderLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehearsalId, areaId interface{}) ([]int, error) {
func GetOrderLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehearsalId, areaId, archId interface{}) ([]int, error) {
var err error
var userIds = make([]int, 0)
var recordIds = make([]int, 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)
Where("order_draw_rule_id=? and rehearsal_id=? and arch_id=? and is_delete=0",
ruleId, rehearsalId, archId).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)
Where("order_draw_rule_ladder_id=? and rehearsal_id=? and arch_id=? and is_delete=0",
ladderId, rehearsalId, archId).Find(&recordIds)
}
if err != nil {
return nil, err
@ -28,8 +28,8 @@ func GetOrderLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehears
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).
Where("activity_id=? and rehearsal_id=? and area_id=? and arch_id=? and is_delete=0",
activityId, rehearsalId, areaId, archId).NotIn("buyer_id", recordIds).
Find(&userIds)
if err != nil {
return nil, err

Loading…
Cancel
Save