Browse Source

fix:bug

token_replace
黄梓健 5 years ago
parent
commit
261ca26c50
  1. 2
      controllers/client/auction.go
  2. 18
      controllers/pc/auction.go
  3. 7
      controllers/pc/bully_screen.go
  4. 41
      controllers/pc/lottery_draw.go
  5. 68
      controllers/pc/order_draw.go
  6. 34
      controllers/pc/reward.go
  7. 57
      controllers/pc/shake_red_envelope.go
  8. 13
      controllers/pc/sign.go
  9. 43
      controllers/pc/tug_war.go
  10. 46
      controllers/pc/upper_wall.go
  11. 30
      controllers/pc/vote.go
  12. 12
      models/auction_history.go
  13. 4
      models/new_auction_activity.go
  14. 6
      models/reward_history.go
  15. 42
      services/bully_reward/dao.go
  16. 14
      services/lottery/lottery.go
  17. 6
      services/lottery/order.go
  18. 1
      utils/code/code.go

2
controllers/client/auction.go

@ -162,7 +162,7 @@ func (t *AuctionCtl) ExistRecord() {
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
record := new(models.AuctionResultRecord)
exist, err = record.GetByUserIdAndAuctionId(uid, auctionId, activity.RehearsalId)
exist, err = record.GetByUserIdAndAuctionId(uid, auctionId, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"show": exist,

18
controllers/pc/auction.go

@ -76,7 +76,6 @@ func (t *AuctionCtl) StopAuction() {
_, err = models.Get(activity, auction.ActivityId)
t.CheckErr(err)
// todo: 记录用户最高价
if auction.AuctionModel == define.INCR_AUCTION {
history := new(models.AuctionHistory)
_, err := history.GetHighestMoney(activity.RehearsalId, auction.Id, activity.ArchId) // 区分彩排数据
@ -142,7 +141,6 @@ func (t *AuctionCtl) StopAuction() {
t.SUCCESS("操作成功")
}
// 增加数据
func (t *AuctionCtl) History() {
auctionId := t.MustGetInt64("auction_activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
@ -152,12 +150,17 @@ func (t *AuctionCtl) History() {
t.CheckErr(err)
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍不存在")
activity := models.Activity{}
exist, err = models.Get(activity, auction.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
orderBy := "money asc"
if auction.AuctionModel == "加价竞拍" {
orderBy = "money desc"
}
histories, err := models.GetAuctionHistoriesByAuctionId(auctionId, rehearsalId, orderBy)
histories, err := models.GetAuctionHistoriesByAuctionId(auctionId, rehearsalId, orderBy, activity.ArchId)
t.CheckErr(err)
userIdMap := make(map[int64]struct{}, 0) // 去重操作
@ -180,7 +183,12 @@ func (t *AuctionCtl) List() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
auctions, err := models.GetAuctionsByActivityId(activityId, "created_at asc")
activity := models.Activity{}
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
auctions, err := models.GetAuctionsByActivityId(activityId)
t.CheckErr(err)
// 更具某个数据进行
upIds := make([]int64, 0)
@ -189,7 +197,7 @@ func (t *AuctionCtl) List() {
upIds = append(upIds, item.Id)
}
}
upH, err := models.GetAuctionHistoriesByAuctionIds(upIds, rehearsalId, "money desc")
upH, err := models.GetAuctionHistoriesByAuctionIds(upIds, rehearsalId, activity.ArchId)
t.CheckErr(err)
for i := range auctions {

7
controllers/pc/bully_screen.go

@ -31,8 +31,8 @@ func (t *BullyScreenCtl) WaitReview() {
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
//根据霸屏服务得id获取待审核得霸屏列表
t.CheckErr(bully_reward_service.CheckBullyScreenStatus(bullyScreenServer.Id))
result, err := bully_reward_service.GetBullyScreenReview(bullyScreenServer.Id, activity.RehearsalId)
//t.CheckErr(bully_reward_service.CheckBullyScreenStatus(bullyScreenServer.Id))
result, err := bully_reward_service.GetBullyScreenReview(bullyScreenServer.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
@ -47,7 +47,6 @@ func (t *BullyScreenCtl) Review() {
status := t.MustGetBool("status")
ids := strings.Split(t.MustGet("ids"), "|")
activityId := t.MustGetInt64("activity_id")
//rehearsalId := t.MustGetInt64("rehearsal_id")
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
@ -118,7 +117,7 @@ func (t *BullyScreenCtl) Blacklist() {
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏活动不存在")
//根据霸屏服务得id获取待审核得霸屏列表
result, err := bully_reward_service.GetBullyScreenBlacklist(bullyScreenServer.Id, activity.RehearsalId)
result, err := bully_reward_service.GetBullyScreenBlacklist(bullyScreenServer.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.DisplayByData(map[string]interface{}{

41
controllers/pc/lottery_draw.go

@ -117,9 +117,6 @@ func (t *LotteryDrawCtl) StopRoll() {
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在")
//if ladder.Status != define.StatusRunning {
// t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR)
//}
// 通知直播开始抽奖
if activity.RehearsalId == 0 {
live := new(models.LiveConfig)
@ -155,10 +152,6 @@ func (t *LotteryDrawCtl) Stop() {
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在")
//if ladder.Status != define.StatusRunning {
// t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR)
//}
ladder.Status = define.StatusEnding
ladder.UpdatedAt = time.Now()
ladder.RollNum = 0
@ -197,7 +190,7 @@ func (t *LotteryDrawCtl) List() {
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
result, err := lottery_service.GetLotteryAndLadder(activityId, activity.RehearsalId)
result, err := lottery_service.GetLotteryAndLadder(activityId, activity.RehearsalId, activity.ArchId)
t.JSON(map[string]interface{}{
"total": len(result),
@ -227,13 +220,13 @@ func (t *LotteryDrawCtl) Users() {
ruleId := t.MustGetInt64("lottery_draw_rule_id")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.Get(customer, customerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
//customer := new(models.Customer)
//exist, err := models.Get(customer, customerId)
//t.CheckErr(err)
//t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err = models.Get(activity, activityId)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
@ -248,10 +241,10 @@ func (t *LotteryDrawCtl) Users() {
recordIds := make([]int64, 0)
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT {
// 去重标志
recordIds, err = models.GetUserIdsByLotteryDrawRuleId(ruleId, activity.RehearsalId, area.Id)
recordIds, err = models.GetUserIdsByLotteryDrawRuleId(ruleId, activity.RehearsalId, area.Id, activity.ArchId)
t.CheckErr(err)
}
result, err := lottery_service.GetLotteryUsersResult(area.Id, activity.Id, activity.RehearsalId, recordIds)
result, err := lottery_service.GetLotteryUsersResult(area.Id, activity.Id, activity.RehearsalId, activity.ArchId, recordIds)
t.CheckErr(err)
t.JSON(map[string]interface{}{
@ -386,9 +379,23 @@ func (t *LotteryDrawCtl) Lottery() {
//获取中奖名单
func (t *LotteryDrawCtl) ListOfWinners() {
ruleId := t.MustGetInt64("lottery_draw_rule_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
result, err := lottery_service.GetWinnersResult(ruleId, rehearsalId)
rule := &models.LotteryDrawRule{}
exist, err := models.Get(rule, ruleId)
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在")
lottery := &models.LotteryDrawActivity{}
exist, err = models.Get(lottery, rule.LotteryDrawActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在")
activity := &models.Activity{}
exist, err = models.Get(activity, lottery.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
result, err := lottery_service.GetWinnersResult(ruleId, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"total": len(result),

68
controllers/pc/order_draw.go

@ -111,11 +111,11 @@ type OrderLadderResult struct {
func (t *OrderDrawCtl) List() {
activityId := t.MustGetInt64("activity_id")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.Get(customer, customerId)
//
area := &models.AreaStore{}
exist, err := area.GetByCustomerId(customerId, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
activity := new(models.Activity)
exist, err = models.Get(activity, activityId)
@ -135,16 +135,6 @@ func (t *OrderDrawCtl) List() {
"a.id=r.order_draw_activity_id and r.is_delete=0").
Where("a.is_delete=0 and a.activity_id=?", activityId).Find(&result)
// 多地区的一个坑:分配给主会场的area_id不是主账号的area_id
area := new(models.AreaStore)
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activityId)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())
}
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
ruleIds := make([]int64, 0)
for _, v := range result {
ruleIds = append(ruleIds, v.OrderDrawRuleId)
@ -164,7 +154,8 @@ func (t *OrderDrawCtl) List() {
records := make([]map[string]int64, 0)
err = core.GetXormAuto().Table(new(models.OrderDrawRecord)).Alias("r").
Select("r.order_draw_rule_ladder_id as ladder_id, count(id) as num").
Where("is_delete=0 and rehearsal_id=?", activity.RehearsalId).
Where("is_delete=0 and rehearsal_id=? and arch_id=? and area_id=?",
activity.RehearsalId, activity.ArchId, area.Id).
In("r.order_draw_rule_ladder_id", ladderIds).GroupBy("ladder_id").Find(&records)
t.CheckErr(err)
@ -229,8 +220,8 @@ func (t *OrderDrawCtl) Users() {
session := core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o").
Select("o.buyer_id as user_id, u.nickname as username, u.avatar").Distinct("o.buyer_id").
Join("LEFT", new(models.User).Alias("u"), "o.buyer_id=u.id and u.is_delete=0").
Where("o.activity_id=? and o.is_delete=0 and o.rehearsal_id=?",
activityId, activity.RehearsalId)
Where("o.activity_id=? and o.is_delete=0 and o.rehearsal_id=? and o.arch_id=?", activityId,
activity.RehearsalId, activity.ArchId)
moduleService, exist, err := activity_service.GetModuleService(define.MODULE_ORDERLY, activity.Id)
t.CheckErr(err)
@ -238,8 +229,8 @@ func (t *OrderDrawCtl) Users() {
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT {
recordIds := make([]int64, 0)
err = core.GetXormAuto().Table(new(models.OrderDrawRecord)).Select("user_id").
Where("order_draw_rule_id=? and rehearsal_id=? and is_delete=0",
ruleId, activity.RehearsalId).Find(&recordIds)
Where("order_draw_rule_id=? and rehearsal_id=? and arch_id=? and is_delete=0",
ruleId, activity.RehearsalId, activity.ArchId).Find(&recordIds)
t.CheckErr(err)
session = session.NotIn("o.buyer_id", recordIds)
}
@ -359,10 +350,24 @@ type WinnerResult struct {
}
func (t *OrderDrawCtl) ListOfWinners() {
orderDrawRuleId := t.MustGetInt64("order_draw_rule_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
ruleId := t.MustGetInt64("order_draw_rule_id")
rule := &models.OrderDrawRule{}
exist, err := models.Get(rule, ruleId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在")
lottery := models.OrderDrawActivity{}
exist, err = models.Get(lottery, rule.OrderDrawActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在")
activity := models.Activity{}
exist, err = models.Get(activity, lottery.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
result, err := lottery_service.GetOrderWinnersResult(orderDrawRuleId, rehearsalId)
result, err := lottery_service.GetOrderWinnersResult(rule.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"total": len(result),
@ -383,15 +388,20 @@ type OrdersResult struct {
func (t *OrderDrawCtl) Orders() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
activity := models.Activity{}
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
orders := make([]*OrdersResult, 0)
err := core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o").
err = core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o").
Select("o.area_name, o.goods_name, o.buyer_id as user_id, u.nickname, l.extra_data as extra_data, o.created_at").
Distinct("o.id").Join("LEFT", new(models.InvitationLetter).Alias("l"),
"o.buyer_id=l.user_id and o.activity_id=l.activity_id and l.is_delete=0").
Join("LEFT", new(models.User).Alias("u"), "u.id=o.buyer_id and u.is_delete=0").
Where("o.is_delete=0 and o.activity_id=? and o.rehearsal_id=?", activityId, rehearsalId).
"o.buyer_id=l.user_id and o.activity_id=l.activity_id and l.arch_id=o.arch_id").
Join("LEFT", new(models.User).Alias("u"), "u.id=o.buyer_id").
Where("o.is_delete=0 and o.activity_id=? and o.rehearsal_id=? and o.arch_id=?",
activityId, activity.RehearsalId, activity.ArchId).
Asc("o.created_at").Find(&orders)
t.CheckErr(err)
@ -404,8 +414,8 @@ func (t *OrderDrawCtl) Orders() {
}
// 下订单人数
buyerCount, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=?",
activityId, rehearsalId).Distinct("buyer_id").Count(new(models.CustomerOrder))
buyerCount, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and arch_id=?",
activityId, activity.RehearsalId, activity.ArchId).Distinct("buyer_id").Count(new(models.CustomerOrder))
t.CheckErr(err)
t.JSON(map[string]interface{}{

34
controllers/pc/reward.go

@ -20,15 +20,19 @@ type RewardCtl struct {
//获取最新的打赏记录
func (t *RewardCtl) Latest() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
activity := models.Activity{}
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
//获取打赏服务得id
server := new(models.RewardServer)
exist, err := server.GetByActivityId(activityId)
exist, err = server.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在")
result, err := bully_reward_service.GetRewardLatest(server.Id, rehearsalId)
result, err := bully_reward_service.GetRewardLatest(server.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
if result == nil || result.Id == 0 {
t.JSON(result)
@ -49,18 +53,23 @@ func (t *RewardCtl) Latest() {
//获取待审核列表
func (t *RewardCtl) WaitReview() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
//rehearsalId := t.MustGetInt64("rehearsal_id")
activity := models.Activity{}
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
//获取打赏服务得id
server := new(models.RewardServer)
exist, err := server.GetByActivityId(activityId)
exist, err = server.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在")
//// todo: 检查订单
//t.CheckErr(bully_reward_service.CheckRewardStatus(server.Id))
result, err := bully_reward_service.GetRewardReview(server.Id, rehearsalId)
result, err := bully_reward_service.GetRewardReview(server.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
//根据打赏服务得id获取待审核得打赏列表
@ -138,13 +147,14 @@ func (t *RewardCtl) Amount() {
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
//获取打赏服务得id
server := new(models.RewardServer)
exist, err = server.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在")
totalAmount, err := new(models.RewardHistory).SumMoney(server.Id, activity.RehearsalId)
totalAmount, err := new(models.RewardHistory).SumMoney(server.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.DisplayByData(map[string]interface{}{
@ -155,17 +165,21 @@ func (t *RewardCtl) Amount() {
// 黑名单
func (t *RewardCtl) Blacklist() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
// 获取打赏的服务id
server := new(models.RewardServer)
exist, err := server.GetByActivityId(activityId)
exist, err = server.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在")
// 根据打赏服务id获取待审核的名单
// status=true 代表审核不通过还是通过
// 目前表示不通过,bully_screen也一样
result, err := bully_reward_service.GetRewardBlacklist(server.Id, rehearsalId)
result, err := bully_reward_service.GetRewardBlacklist(server.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{

57
controllers/pc/shake_red_envelope.go

@ -150,10 +150,10 @@ func (t *ShakeRedEnvelopeCtl) List() {
activityId := t.MustGetInt64("activity_id")
customerId := t.MustGetUID()
customer := new(models.Customer)
exist, err := models.Get(customer, customerId)
area := new(models.AreaStore)
exist, err := area.GetByCustomerId(customerId, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在")
activity := new(models.Activity)
exist, err = models.Get(activity, activityId)
@ -168,14 +168,6 @@ func (t *ShakeRedEnvelopeCtl) List() {
for _, v := range list {
aIds = append(aIds, v.Id)
}
area := new(models.AreaStore)
if customer.Pid == 0 {
exist, err = area.GetMainAreaById(activityId)
} else {
exist, err = area.GetAreaStoreById(t.MustGetAreaId())
}
t.CheckErr(err)
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在")
rules := make([]*models.ShakeRedEnvelopeRule, 0)
err = core.GetXormAuto().Where("is_delete=0 and area_id=?", area.Id).In("shake_red_envelope_activity_id", aIds).Find(&rules)
@ -246,12 +238,27 @@ type ShakeRedEnvelopeRecordAndUser struct {
// 参数优化
func (t *ShakeRedEnvelopeCtl) Winners() {
ruleId := t.MustGetInt64("shake_red_envelope_rule_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
rule := &models.ShakeRedEnvelopeRule{}
exist, err := models.Get(rule, ruleId)
t.CheckErr(err)
t.Assert(exist, code.MSG_SHAKERB_RULE_NOT_EXIST, "红包规则不存在")
redEnvelope := &models.ShakeRedEnvelopeActivity{}
exist, err = models.Get(redEnvelope, rule.ShakeRedEnvelopeActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_SHAKERB_RULE_NOT_EXIST, "红包活动不存在")
activity := models.Activity{}
exist, err = models.Get(activity, redEnvelope.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
records := make([]*ShakeRedEnvelopeRecordAndUser, 0)
err := core.GetXormAuto().Table(new(models.ShakeRedEnvelopeRecord)).Alias("r").
err = core.GetXormAuto().Table(new(models.ShakeRedEnvelopeRecord)).Alias("r").
Join("LEFT", models.Alias(new(models.User), "u"), "r.user_id=u.id and u.is_delete=0").
Where("r.shake_red_envelope_rule_id=? and is_draw<>-1 and r.is_delete=0 and r.rehearsal_id=?",
ruleId, rehearsalId).OrderBy("r.created_at desc").Find(&records)
Where("r.shake_red_envelope_rule_id=? and is_draw<>-1 and r.is_delete=0 and r.rehearsal_id=? and r.arch_id=?",
ruleId, activity.RehearsalId, activity.ArchId).OrderBy("r.created_at desc").Find(&records)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"total": len(records),
@ -262,19 +269,29 @@ func (t *ShakeRedEnvelopeCtl) Winners() {
// 统计摇红包参与人数和剩余红包数量
func (t *ShakeRedEnvelopeCtl) Count() {
ruleId := t.MustGetInt64("shake_red_envelope_rule_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
rule := new(models.ShakeRedEnvelopeRule)
exist, err := models.Get(rule, ruleId)
t.CheckErr(err)
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "摇红包轮次不存在")
numU, err := core.GetXormAuto().Where("is_delete=0 and shake_red_envelope_rule_id=? and rehearsal_id=?",
ruleId, rehearsalId).Count(new(models.ShakeRedEnvelopeUser))
redEnvelope := &models.ShakeRedEnvelopeActivity{}
exist, err = models.Get(redEnvelope, rule.ShakeRedEnvelopeActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_SHAKERB_RULE_NOT_EXIST, "红包活动不存在")
activity := models.Activity{}
exist, err = models.Get(activity, redEnvelope.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
numU, err := core.GetXormAuto().Where("is_delete=0 and shake_red_envelope_rule_id=? and rehearsal_id=? and arch_id=?",
ruleId, activity.RehearsalId, activity.ArchId).Count(new(models.ShakeRedEnvelopeUser))
t.CheckErr(err)
numR, err := core.GetXormAuto().Where("is_delete=0 and is_draw=-1 and shake_red_envelope_rule_id=? and rehearsal_id=?",
ruleId, rehearsalId).Count(new(models.ShakeRedEnvelopeRecord))
numR, err := core.GetXormAuto().Where("is_delete=0 and is_draw=-1 and shake_red_envelope_rule_id=? "+
" and rehearsal_id=? and arch_id=?", ruleId, activity.RehearsalId, activity.ArchId).
Count(new(models.ShakeRedEnvelopeRecord))
t.CheckErr(err)
t.JSON(map[string]interface{}{

13
controllers/pc/sign.go

@ -74,14 +74,18 @@ type SignResult struct {
//处理签到信息
func (t *SignCtl) SignInfo() {
aid := t.MustGetInt64("activity_id")
//activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
activityId := t.MustGetInt64("activity_id")
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
result := make([]*SignResult, 0)
session := core.GetXormAuto().Table(new(models.SignHistory)).Alias("h").
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
Where("h.is_delete=0 and h.activity_id=? and rehearsal_id=?", aid, rehearsalId)
Where("h.is_delete=0 and h.activity_id=? and rehearsal_id=? and arch_id=?",
activity.Id, activity.RehearsalId, activity.ArchId)
if t.PageSize > 0 { // 增加分页
session.Limit(t.PageSize, t.Page*t.PageSize)
}
@ -98,6 +102,7 @@ func (t *SignCtl) SignInfo() {
// 实名签到信息
func (t *SignCtl) RealSignInfo() {
aid := t.MustGetInt64("activity_id")
activity := &models.Activity{}
exist, err := models.Get(activity, aid)
t.CheckErr(err)

43
controllers/pc/tug_war.go

@ -163,17 +163,27 @@ func (t *TugOfWarCtl) Team() {
func (t *TugOfWarCtl) Member() {
baheId := t.MustGetInt64("bahe_activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
bahe := models.TugOfWar{}
exist, err := models.Get(bahe, baheId)
t.CheckErr(err)
t.Assert(exist, code.MSG_TUGWAR_NOT_EXIST, "拔河不存在")
activity := new(models.Activity)
exist, err = models.Get(activity, bahe.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
teams := make([]*models.BaheTeam, 0)
err := core.GetXormAuto().Where("is_delete=0 and bahe_activity_id=?", baheId).Find(&teams)
err = core.GetXormAuto().Where("is_delete=0 and bahe_activity_id=?", baheId).Find(&teams)
t.CheckErr(err)
var total int64 = 0
for index := range teams {
members := make([]*models.BaheTeamMember, 0)
num, err := core.GetXormAuto().Where("is_delete=0 and team_id=? and rehearsal_id=?",
teams[index].Id, rehearsalId).Desc("score").Asc("sort_time").FindAndCount(&members)
num, err := core.GetXormAuto().Where("is_delete=0 and team_id=? and rehearsal_id=? and arch_id=?",
teams[index].Id, activity.RehearsalId, activity.ArchId).Desc("score").
Asc("sort_time").FindAndCount(&members)
t.CheckErr(err)
total += num
teams[index].Members = members
@ -195,22 +205,32 @@ type BaheScoreResult struct {
}
func (t *TugOfWarCtl) Score() {
baheActivityId := t.MustGetInt64("bahe_activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
baheId := t.MustGetInt64("bahe_activity_id")
bahe := models.TugOfWar{}
exist, err := models.Get(bahe, baheId)
t.CheckErr(err)
t.Assert(exist, code.MSG_TUGWAR_NOT_EXIST, "拔河不存在")
activity := new(models.Activity)
exist, err = models.Get(activity, bahe.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
teams := make([]*BaheScoreResult, 0)
err := core.GetXormAuto().Table(new(models.BaheTeam)).Alias("t").
err = core.GetXormAuto().Table(new(models.BaheTeam)).Alias("t").
Select("sum(m.score) as total_score, t.id, t.activity_id, t.bahe_activity_id, t.bahe_team_name").
Join("LEFT", new(models.BaheTeamMember).Alias("m"),
"t.id=m.team_id and m.is_delete=0 and m.rehearsal_id=?", rehearsalId).
Where("t.is_delete=0 and t.bahe_activity_id=?", baheActivityId).
"t.id=m.team_id and m.is_delete=0 and m.rehearsal_id=? and arch_id=?",
activity.RehearsalId, activity.ArchId).Where("t.is_delete=0 and t.bahe_activity_id=?", baheId).
GroupBy("t.id").Find(&teams)
t.CheckErr(err)
for index := range teams {
members := make([]*models.BaheTeamMember, 0)
err = core.GetXormAuto().Where("is_delete=0 and team_id=? and rehearsal_id=?", teams[index].Id, rehearsalId).
Desc("score").Asc("sort_time").Find(&members)
err = core.GetXormAuto().Where("is_delete=0 and team_id=? and rehearsal_id=? and arch_id=?",
teams[index].Id, activity.RehearsalId, activity.ArchId).Desc("score").
Asc("sort_time").Find(&members)
t.CheckErr(err)
teams[index].Members = members
}
@ -222,6 +242,7 @@ func (t *TugOfWarCtl) Score() {
func (t *TugOfWarCtl) List() {
activityId := t.MustGetInt64("activity_id")
bahes := make([]*models.TugOfWar, 0)
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).
Asc("created_at").Find(&bahes)

46
controllers/pc/upper_wall.go

@ -25,12 +25,17 @@ type UpperWallResult struct {
//获取所有已审核的上墙消息
func (t *UpperWallCtl) List() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
result := make([]*UpperWallResult, 0)
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
err = core.GetXormAuto().Table("ox_upper_wall").Alias("w").
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
Where("w.is_delete=0 and w.status=3 and w.activity_id=? and w.rehearsal_id=?", activityId, rehearsalId).
Where("w.is_delete=0 and w.status=3 and w.activity_id=? and w.rehearsal_id=? and arch_id=?",
activityId, activity.RehearsalId, activity.ArchId).
OrderBy("w.review_time desc").Find(&result)
t.CheckErr(err)
@ -43,13 +48,18 @@ func (t *UpperWallCtl) List() {
//获取待审核列表
func (t *UpperWallCtl) WaitReview() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
//根据霸屏服务得id获取待审核得霸屏列表
result := make([]*UpperWallResult, 0)
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
err = core.GetXormAuto().Table("ox_upper_wall").Alias("w").
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
Where("w.is_delete=0 and w.status=0 and w.activity_id=? and w.rehearsal_id=?", activityId, rehearsalId).
Where("w.is_delete=0 and w.status=0 and w.activity_id=? and w.rehearsal_id=? and arch_id=?",
activityId, activity.RehearsalId, activity.ArchId).
OrderBy("w.review_time desc").Find(&result)
t.CheckErr(err)
@ -64,7 +74,6 @@ func (t *UpperWallCtl) Review() {
idList := t.MustGet("ids")
status := t.MustGetBool("status")
uid := t.MustGetUID()
ids := strings.Split(idList, "|")
customer := new(models.Customer)
@ -118,14 +127,17 @@ func (t *UpperWallCtl) Review() {
//获取黑名单列表
func (t *UpperWallCtl) Blacklist() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
result := make([]*UpperWallResult, 0)
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
result := make([]*UpperWallResult, 0)
err = core.GetXormAuto().Table("ox_upper_wall").Alias("w").
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
Where("w.is_delete=0 and w.status=1 and w.status=1 and w.rehearsal_id=? and w.activity_id=?",
rehearsalId, activityId).OrderBy("review_time desc").Find(&result)
Where("w.is_delete=0 and w.status=1 and w.rehearsal_id=? and w.activity_id=? and w.arch_id=?",
activity.RehearsalId, activity.Id, activity.ArchId).OrderBy("review_time desc").Find(&result)
t.CheckErr(err)
t.JSON(map[string]interface{}{
@ -137,10 +149,14 @@ func (t *UpperWallCtl) Blacklist() {
//获取目前上墙得总条数
func (t *UpperWallCtl) Total() {
activityId := t.MustGetInt64("activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=3",
activityId, rehearsalId).Count(new(models.UpperWall))
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and arch_id=? and status=3",
activityId, activity.RehearsalId, activity.ArchId).Count(new(models.UpperWall))
t.CheckErr(err)
t.JSON(map[string]interface{}{

30
controllers/pc/vote.go

@ -66,7 +66,8 @@ func (t *VoteCtl) ReadyVote() {
t.CheckErr(err)
}
_, err = vote.UpdateStatusById(vote.Id, define.StatusReady)
vote.VoteStatus = define.StatusReady
_, err = models.Update(voteId, vote, "vote_status")
t.CheckErr(err)
t.SUCCESS("success")
}
@ -82,6 +83,7 @@ func (t *VoteCtl) StartVote() {
if vote.VoteStatus != define.StatusReady {
t.ERROR(fmt.Sprintf("该活动%s", vote.VoteStatus), code.MSG_ERR)
}
// 将所有被投票人置0
vote.VoteStatus = define.StatusRunning
vote.UpdatedAt = time.Now()
if vote.VoteLastTime == "" {
@ -89,8 +91,7 @@ func (t *VoteCtl) StartVote() {
}
duration, _ := strconv.ParseInt(vote.VoteLastTime, 10, 64)
vote.VoteEndTime = time.Now().Unix() + duration
_, err = core.GetXormAuto().Where("is_delete=0 and id=?", voteId).
Cols("vote_status", "vote_end_time", "updated_at").Update(vote)
_, err = models.Update(voteId, vote, "vote_status", "vote_end_time")
t.CheckErr(err)
t.SUCCESS("操作成功")
}
@ -111,8 +112,7 @@ func (t *VoteCtl) StopVote() {
vote.VoteStatus = define.StatusEnding
vote.UpdatedAt = time.Now()
vote.VoteEndTime = 0
_, err = core.GetXormAuto().Where("is_delete=0 and id=?", voteId).
Cols("vote_status", "updated_at", "vote_end_time").Update(vote)
_, err = models.Update(voteId, vote, "vote_status", "vote_end_time")
t.CheckErr(err)
t.SUCCESS("操作成功")
@ -121,9 +121,19 @@ func (t *VoteCtl) StopVote() {
//获取参与人数
func (t *VoteCtl) JoinTotal() {
voteActivityId := t.MustGetInt64("vote_activity_id")
rehearsalId := t.MustGetInt64("rehearsal_id")
total, err := core.GetXormAuto().Distinct("user_id").Where("vote_activity_id=? and rehearsal_id=? and is_delete=0",
voteActivityId, rehearsalId).Count(new(models.NewVoteActivityHistory))
vote := models.NewVoteActivity{}
exist, err := models.Get(vote, voteActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_VOTE_ACTIVITY_NOT_EXIST, "投票活动不存在")
activity := new(models.Activity)
exist, err = models.Get(activity, vote.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
total, err := core.GetXormAuto().Distinct("user_id").Where("vote_activity_id=? and rehearsal_id=? "+
" and is_delete=0", voteActivityId, activity.RehearsalId, activity.ArchId).Count(new(models.NewVoteActivityHistory))
t.CheckErr(err)
t.JSON(total)
}
@ -159,10 +169,10 @@ func (t *VoteCtl) List() {
//获取投票的前几(头像、姓名、票数)
func (t *VoteCtl) History() {
voteActivityId := t.MustGetInt64("vote_activity_id")
voteId := t.MustGetInt64("vote_activity_id")
total := t.MustGetInt("total")
ladders, err := models.GetNewVoteTopByVoteActivityId(voteActivityId, total)
ladders, err := models.GetNewVoteTopByVoteActivityId(voteId, total)
t.CheckErr(err)
t.JSON(ladders)
}

12
models/auction_history.go

@ -44,16 +44,16 @@ func (t *AuctionHistory) CountHistory(rid, aid int64) (int64, error) {
return core.GetXormAuto().Where("auction_activity_id = ? and rehearsal_id=? and is_delete=0", aid, rid).Count(t)
}
func GetAuctionHistoriesByAuctionId(aid, rid int64, orderBy string) ([]*AuctionHistory, error) {
func GetAuctionHistoriesByAuctionId(aid, rid int64, orderBy string, archId interface{}) ([]*AuctionHistory, error) {
histories := make([]*AuctionHistory, 0)
err := core.GetXormAuto().Where("is_delete=0 and auction_activity_id=? and rehearsal_id=?", aid, rid).
OrderBy(orderBy).Find(&histories)
err := core.GetXormAuto().Where("is_delete=0 and auction_activity_id=? and rehearsal_id=? and arch_id=?",
aid, rid, archId).OrderBy(orderBy).Find(&histories)
return histories, err
}
func GetAuctionHistoriesByAuctionIds(ids []int64, rid int64, orderBy string) ([]*AuctionHistory, error) {
func GetAuctionHistoriesByAuctionIds(ids []int64, rid int64, archId interface{}) ([]*AuctionHistory, error) {
histories := make([]*AuctionHistory, 0)
err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=?", rid).
In("auction_activity_id", ids).OrderBy(orderBy).Find(&histories)
err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=? and arch_id=?", rid, archId).
In("auction_activity_id", ids).Desc("money").Find(&histories)
return histories, err
}

4
models/new_auction_activity.go

@ -76,9 +76,9 @@ func UpdateAuctionStatusByActivityId(aid int64) (int64, error) {
Update(&NewAuctionActivity{Status: define.StatusNotBegin})
}
func GetAuctionsByActivityId(aid int64, orderBy string) ([]*NewAuctionActivity, error) {
func GetAuctionsByActivityId(aid int64) ([]*NewAuctionActivity, error) {
auctions := make([]*NewAuctionActivity, 0)
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).
OrderBy(orderBy).Find(&auctions)
Asc("created_at").Find(&auctions)
return auctions, err
}

6
models/reward_history.go

@ -70,7 +70,7 @@ func GetExpireRewardHistory() ([]*RewardHistory, error) {
return result, err
}
func (t *RewardHistory) SumMoney(serverId, rehearsalId interface{}) (float64, error) {
return core.GetXormAuto().Where("reward_server_id=? and status=3 and is_delete=0 "+
" and rehearsal_id=?", serverId, rehearsalId).Sum(t, "amount")
func (t *RewardHistory) SumMoney(serverId, rehearsalId, archId interface{}) (float64, error) {
return core.GetXormAuto().Where("reward_server_id=? and status=3 and is_delete=0 and rehearsal_id=? and arch_id=?",
serverId, rehearsalId, archId).Sum(t, "amount")
}

42
services/bully_reward/dao.go

@ -40,33 +40,30 @@ type RewardResult struct {
User *models.User `json:"user" xorm:"extends"`
}
func GetRewardLatest(serverId, rehearsalId int64) (*RewardResult, error) {
func GetRewardLatest(serverId, rehearsalId int64, archId interface{}) (*RewardResult, error) {
result := new(RewardResult)
_, err := core.GetXormAuto().Table(new(models.RewardHistory)).Alias("h").
Join("LEFT", new(models.User).Alias("u"),
"h.user_id=u.id and u.is_delete=0").
Where("h.is_delete=0 and h.status=2 and h.reward_server_id=? and h.rehearsal_id=?",
serverId, rehearsalId).Desc("h.review_time").Get(result)
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
Where("h.is_delete=0 and h.status=2 and h.reward_server_id=? and h.rehearsal_id=? and h.arch_id=?",
serverId, rehearsalId, archId).Desc("h.review_time").Get(result)
return result, err
}
func GetRewardReview(serverId, rehearsalId int64) ([]*RewardResult, error) {
func GetRewardReview(serverId, rehearsalId int64, archId interface{}) ([]*RewardResult, error) {
result := make([]*RewardResult, 0)
err := core.GetXormAuto().Table(new(models.RewardHistory)).Alias("h").
Join("LEFT", new(models.User).Alias("u"),
"h.user_id=u.id and u.is_delete=0").
Where("h.is_delete=0 and h.status=0 and h.reward_server_id=? and h.rehearsal_id=?",
serverId, rehearsalId).Desc("h.created_at").Find(&result)
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
Where("h.is_delete=0 and h.status=0 and h.reward_server_id=? and h.rehearsal_id=? and h.arch_id=?",
serverId, rehearsalId, archId).Desc("h.created_at").Find(&result)
return result, err
}
func GetRewardBlacklist(serverId, rehearsalId int64) ([]*RewardResult, error) {
func GetRewardBlacklist(serverId, rehearsalId int64, archId interface{}) ([]*RewardResult, error) {
result := make([]*RewardResult, 0)
err := core.GetXormAuto().Table(new(models.RewardHistory)).Alias("h").
Join("LEFT", new(models.User).Alias("u"),
"h.user_id=u.id and u.is_delete=0").
Where("h.is_delete=0 and h.status=1 and h.reward_server_id=? and h.rehearsal_id=?",
serverId, rehearsalId).Desc("h.review_time").Find(&result)
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
Where("h.is_delete=0 and h.status=1 and h.reward_server_id=? and h.rehearsal_id=? and arch_id=?",
serverId, rehearsalId, archId).Desc("h.review_time").Find(&result)
return result, err
}
@ -111,22 +108,21 @@ type BullyScreenResult struct {
User *models.User `json:"user" xorm:"extends"`
}
func GetBullyScreenReview(bullyScreenServerId, rehearsalId int64) ([]*BullyScreenResult, error) {
func GetBullyScreenReview(bullyScreenServerId, rehearsalId int64, archId interface{}) ([]*BullyScreenResult, error) {
result := make([]*BullyScreenResult, 0)
err := core.GetXormAuto().Table(new(models.BullyScreenHistory)).Alias("h").
Join("LEFT", new(models.User).Alias("u"),
"h.user_id=u.id and u.is_delete=0").
Where("h.bully_screen_server_id=? and h.is_delete=0 and h.status=0 and h.rehearsal_id=?",
bullyScreenServerId, rehearsalId).Desc("h.created_at").Find(&result)
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
Where("h.bully_screen_server_id=? and h.is_delete=0 and h.status=0 and h.rehearsal_id=? and h.arch_id=?",
bullyScreenServerId, rehearsalId, archId).Desc("h.created_at").Find(&result)
return result, err
}
func GetBullyScreenBlacklist(bullyScreenServerId, rehearsalId int64) ([]*BullyScreenResult, error) {
func GetBullyScreenBlacklist(bullyScreenServerId, rehearsalId int64, archId interface{}) ([]*BullyScreenResult, error) {
result := make([]*BullyScreenResult, 0)
err := core.GetXormAuto().Table(new(models.BullyScreenHistory)).Alias("h").
Join("LEFT", new(models.User).Alias("u"), "u.id=h.user_id and u.is_delete=0").
Where("h.is_delete=0 and h.bully_screen_server_id=? and h.status=1 and h.rehearsal_id=?",
bullyScreenServerId, rehearsalId).Desc("review_time").Find(&result)
Where("h.is_delete=0 and h.bully_screen_server_id=? and h.status=1 and h.rehearsal_id=? and h.arch_id=?",
bullyScreenServerId, rehearsalId, archId).Desc("review_time").Find(&result)
return result, err
}

14
services/lottery/lottery.go

@ -79,7 +79,7 @@ type LotteryLadderResult struct {
PrizeNumber int64 `json:"prize_number"`
}
func GetLotteryAndLadder(activityId, rehearsalId interface{}) ([]*LotteryListResult, error) {
func GetLotteryAndLadder(activityId, rehearsalId, archId interface{}) ([]*LotteryListResult, error) {
result := make([]*LotteryListResult, 0)
err := core.GetXormAuto().Table(new(models.LotteryDrawActivity)).Alias("a").
Select("a.id as lottery_draw_activity_id, r.id as lottery_draw_rule_id, a.lottery_draw_activity_name").
@ -111,7 +111,7 @@ func GetLotteryAndLadder(activityId, rehearsalId interface{}) ([]*LotteryListRes
records := make([]map[string]int64, 0)
err = core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Alias("r").
Select("r.lottery_draw_rule_ladder_id as ladder_id, count(r.id) as num").
Where("is_delete=0 and rehearsal_id=?", rehearsalId).
Where("is_delete=0 and rehearsal_id=? and arch_id=?", rehearsalId, archId).
In("r.lottery_draw_rule_ladder_id", ladderIds).GroupBy("ladder_id").Find(&records)
if err != nil {
return nil, err
@ -182,11 +182,11 @@ type WinnersResult struct {
PrizeName string `json:"prize_name"`
}
func GetWinnersResult(ruleId, rehearsalId interface{}) ([]*WinnersResult, error) {
func GetWinnersResult(ruleId, rehearsalId, archId interface{}) ([]*WinnersResult, error) {
result := make([]*WinnersResult, 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=?", ruleId, rehearsalId).
Find(&result)
err := core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Alias("r").
Join("LEFT", new(models.User).Alias("u"), "u.id=r.user_id").
Where("r.is_delete=0 and r.lottery_draw_rule_id=? and r.rehearsal_id=? and r.arch_id=?",
ruleId, rehearsalId, archId).Find(&result)
return result, err
}

6
services/lottery/order.go

@ -37,13 +37,13 @@ func GetOrderLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehears
}
func GetOrderWinnersResult(ruleId, rehearsalId interface{}) ([]*WinnersResult, error) {
func GetOrderWinnersResult(ruleId, rehearsalId, archId 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)
Where("r.is_delete=0 and r.order_draw_rule_id=? and r.rehearsal_id=? and r.arch_id=?",
ruleId, rehearsalId, archId).Find(&result)
if err != nil {
return nil, err
}

1
utils/code/code.go

@ -50,6 +50,7 @@ const (
MSG_REWARD_NOT_EXIST = 6002 // 打赏不存
MSG_VOTE_HISTORY_EXIST = 7001 // 投票历史存在
MSG_VOTE_LADDER_NOT_EXIST = 7002 // 投票人不存在
MSG_VOTE_ACTIVITY_NOT_EXIST = 7003 // 投票活动不存在
MSG_SHAKERB_NOT_EXIST = 8000 // 摇红包不存在
MSG_SHAKERB_RECORD_NOT_EXIST = 8001 // 摇红包不存在
MSG_SHAKERB_RULE_NOT_EXIST = 8002 // 红包规则不存在

Loading…
Cancel
Save