Browse Source

归档

token_replace
黄梓健 5 years ago
parent
commit
a81a2aa69b
  1. 8
      controllers/client/activity.go
  2. 9
      controllers/client/auction.go
  3. 1
      controllers/client/barrage.go
  4. 1
      controllers/client/bully_screen.go
  5. 5
      controllers/client/good.go
  6. 2
      controllers/client/invite_envelope.go
  7. 10
      controllers/client/live.go
  8. 25
      controllers/client/lottery.go
  9. 40
      controllers/client/order_entry.go
  10. 3
      controllers/client/reward.go
  11. 2
      controllers/client/shake_red_envelope.go
  12. 4
      controllers/client/sign.go
  13. 6
      controllers/client/tug_war.go
  14. 4
      controllers/client/upper_wall.go
  15. 11
      controllers/client/vote.go
  16. 18
      controllers/client/wx.go
  17. 26
      controllers/pc/auction.go
  18. 4
      controllers/pc/bully_screen.go
  19. 7
      models/auction_history.go
  20. 7
      models/auction_player.go
  21. 16
      models/auction_result_record.go
  22. 1
      models/barrage_history.go
  23. 4
      models/base.go
  24. 5
      models/bully_screen_history.go
  25. 18
      models/customer_order.go
  26. 5
      models/live_viewer.go
  27. 11
      models/lottery_draw_record.go
  28. 17
      models/new_vote_activity_history.go
  29. 1
      models/reward_history.go
  30. 18
      models/shake_red_envelope_record.go
  31. 11
      models/shake_red_envelope_user.go
  32. 1
      models/upper_wall.go
  33. 18
      services/auction/auction.go
  34. 2
      services/bahe/tug_war.go
  35. 16
      services/bully_reward/dao.go
  36. 3
      services/calorie/calorie.go
  37. 12
      services/lottery/lottery.go
  38. 5
      services/pay/handle.go
  39. 31
      services/red_envelope/red_envelop.go
  40. 6
      services/upper_wall/upper_wall.go

8
controllers/client/activity.go

@ -42,15 +42,15 @@ func (t *ActivityCtl) ModuleCurrent() {
var data map[string]interface{}
switch moduleName {
case define.MODULE_TUGWAR: // 拔河
data, err = bahe_service.GetCurrentTugWar(activity.Id, activity.ArchId, uid, activity.RehearsalId)
data, err = bahe_service.GetCurrentTugWar(activity.Id, uid, activity.RehearsalId, activity.ArchId)
case define.MODULE_CALORIE: // 卡路里
data, err = calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId)
data, err = calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId, activity.ArchId)
case define.MODULE_SHAKRB: // 摇红包
// 没有初始状态 // 记下参与人数
data, err = red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId)
data, err = red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId, activity.ArchId)
case define.MODULE_AUCTION:
// 竞拍
data, err = auction_service.GetCurrentAuction(activityId, activity.RehearsalId, t.MustGetUID())
data, err = auction_service.GetCurrentAuction(activityId, activity.RehearsalId, uid, activity.ArchId)
case define.MODULE_VOTE:
data, err = vote_service.GetCurrentVote(activityId, uid, activity.RehearsalId)
case define.MODULE_BULLYS:

9
controllers/client/auction.go

@ -50,12 +50,13 @@ func (t *AuctionCtl) Auction() {
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
player := new(models.AuctionPlayer)
exist, err = player.GetByAuctionIdAndUid(auction.Id, uid, activity.RehearsalId)
exist, err = player.GetByAuctionIdAndUid(auction.Id, uid, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍编号不存在")
history := new(models.AuctionHistory)
history.AuctionActivityId = auction.Id
history.ArchId = activity.ArchId
history.AuctionGoodsName = auction.AuctionGoodsName
history.ActivityId = activity.Id
history.RehearsalId = activity.RehearsalId
@ -76,7 +77,7 @@ func (t *AuctionCtl) Auction() {
if auction.AuctionModel == "加价竞拍" {
maxHistory := new(models.AuctionHistory)
exist, err := maxHistory.GetHighestMoney(activity.RehearsalId, auction.Id)
exist, err := maxHistory.GetHighestMoney(activity.RehearsalId, auction.Id, activity.ArchId)
t.CheckErr(err)
if exist && (history.Money < maxHistory.Money || history.UserId != maxHistory.UserId) {
history.IsDelete = true
@ -103,7 +104,7 @@ func (t *AuctionCtl) Auction() {
} else { // 减价竞拍
record := new(models.AuctionResultRecord)
count, err := record.CountHistory(activity.RehearsalId, auction.Id)
count, err := record.CountHistory(activity.RehearsalId, auction.Id, activity.ArchId)
t.CheckErr(err)
if int(count) >= auction.GoodsNum {
t.ERROR("所有商品已经竞拍完毕", code.MSG_ERR)
@ -178,7 +179,7 @@ func (t *AuctionCtl) UserAuctions() {
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
records, err := auction_service.GetUserAuctions(activityId, activity.RehearsalId, uid)
records, err := auction_service.GetUserAuctions(activityId, activity.RehearsalId, uid, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"list": records,

1
controllers/client/barrage.go

@ -45,6 +45,7 @@ func (t *BarrageCtl) Send() {
ActivityId: activityId,
UserId: uid,
Content: content,
ArchId: activity.ArchId,
CreateAt: time.Now(),
UpdateAt: time.Now(),
}

1
controllers/client/bully_screen.go

@ -58,6 +58,7 @@ func (t *BullyScreenCtl) PaScreen() {
history := models.BullyScreenHistory{
OutTradeNo: res["out_trade_no"].(string),
BullyScreenServerId: bullyScreenServer.Id,
ArchId: activity.ArchId,
ActivityId: activityId,
UserId: user.Id,
Nickname: user.Nickname,

5
controllers/client/good.go

@ -86,7 +86,7 @@ func (t *GoodCtl) ListOrder() {
}
orders, err := models.GetCustomerOrdersByActivityId(uid, activity.Id, activity.RehearsalId,
areaId, statusList, t.Page, t.PageSize)
areaId, statusList, t.Page, t.PageSize, activity.ArchId)
t.CheckErr(err)
orderNos := make([]string, 0)
for _, order := range orders {
@ -217,6 +217,7 @@ func (t *GoodCtl) Order() {
order := models.CustomerOrder{
OrderNo: fmt.Sprint(define.DefaultOrderNo + int(count)),
ActivityId: activity.Id,
ArchId: activity.ArchId,
AreaId: area.Id,
AreaName: area.Name,
RehearsalId: activity.RehearsalId,
@ -261,7 +262,6 @@ func (t *GoodCtl) Order() {
// 为支付的重新支付
func (t *GoodCtl) Reorder() {
outTradeNo := t.MustGet("out_trade_no")
res, err := pay_service.ReOrder(outTradeNo)
t.CheckErr(err)
t.JSON(res)
@ -271,7 +271,6 @@ func (t *GoodCtl) Reorder() {
// 申请退款
func (t *GoodCtl) RefundOrder() {
outTradeNo := t.MustGet("out_trade_no")
order := new(models.CustomerOrder)
exist, err := order.GetByOutTradeNO(outTradeNo)
t.CheckErr(err)

2
controllers/client/invite_envelope.go

@ -51,7 +51,7 @@ func (t *InvitationLetterCtl) Setting() {
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
letter := new(models.InvitationLetter)
exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId)
exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请")

10
controllers/client/live.go

@ -201,6 +201,7 @@ func (t *LiveCtl) SendLiveRedPack() {
ShakeRedEnvelopeType: 1,
ShakeRedEnvelopeRuleId: rule.Id,
AreaId: areaId,
ArchId: activity.ArchId,
Name: user.Nickname + "发红包",
UserId: user.Id,
Amount: utils.Float64CusDecimal(float64(v)/float64(100), 2),
@ -226,13 +227,18 @@ func (t *LiveCtl) GetLiveRedPack() {
t.Assert(exist, code.MSG_SHAKERB_RULE_NOT_EXIST, "红包规则不存在")
t.Assert(rule.Status == 1, code.MSG_SHAKERB_RULE_NOT_EXIST, "红包规则尚未生效")
activity := models.Activity{}
exist, err = models.Get(activity, rule.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
user := models.User{}
exist, err = models.Get(&user, userId)
t.CheckErr(err)
t.Assert(exist, code.MSG_USER_NOT_EXIST, "不存在用户")
record := new(models.ShakeRedEnvelopeRecord)
exist, err = record.GetByRuleId(ruleId, rule.RehearsalId, 1)
exist, err = record.GetByRuleId(ruleId, rule.RehearsalId, 1, activity.ArchId)
t.CheckErr(err)
t.Assert(exist, code.MSG_SHAKERB_RECORD_NOT_HIT, "红包领完了")
@ -251,5 +257,3 @@ func (t *LiveCtl) GetLiveRedPack() {
models.Update(record.Id, record, "mch_billno", "is_draw")
t.JSON(record)
}
// 订单

25
controllers/client/lottery.go

@ -63,13 +63,28 @@ func (t *LotteryCtl) CheckLottery() {
uid := t.MustGetUID()
ladderId := t.MustGetInt64("lottery_draw_ladder_id")
ladder := new(models.LotteryDrawRuleLadder)
ladder := &models.LotteryDrawRuleLadder{}
exist, err := models.Get(ladder, ladderId)
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在")
rule := &models.LotteryDrawRule{}
exist, err = models.Get(rule, ladder.LotteryDrawRuleId)
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_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在")
record := new(models.LotteryDrawRecord)
exist, err = record.GetByUserIdAndLadderId(uid, ladderId, ladder.RollNum)
exist, err = record.GetByUserIdAndLadderId(uid, ladderId, activity.ArchId, ladder.RollNum)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"record": record,
@ -93,7 +108,7 @@ func (t *LotteryCtl) Winners() {
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在")
result, err := lottery_service.GetLotteryUsersResultByRollNum(ladderId, activity.RehearsalId, ladder.RollNum)
result, err := lottery_service.GetLotteryUsersResultByRollNum(ladderId, activity.RehearsalId, activity.ArchId, ladder.RollNum)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"total": len(result),
@ -125,11 +140,11 @@ func (t *LotteryCtl) Users() {
recordIds := make([]int64, 0)
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT {
// 去重标志
recordIds, err = models.GetUserIdsByLotteryDrawRuleId(ladder.LotteryDrawRuleId, activity.RehearsalId, areaId)
recordIds, err = models.GetUserIdsByLotteryDrawRuleId(ladder.LotteryDrawRuleId, activity.RehearsalId, areaId, activity.ArchId)
t.CheckErr(err)
}
result, err := lottery_service.GetLotteryUsersResult(areaId, activity.Id, activity.RehearsalId, recordIds)
result, err := lottery_service.GetLotteryUsersResult(areaId, activity.Id, activity.RehearsalId, activity.ArchId, recordIds)
t.CheckErr(err)
t.JSON(map[string]interface{}{

40
controllers/client/order_entry.go

@ -2,7 +2,6 @@ package client
import (
"fmt"
"github.com/ouxuanserver/osmanthuswine/src/helper"
"hudongzhuanjia/controllers"
"hudongzhuanjia/models"
invitation_service "hudongzhuanjia/services/invitation"
@ -18,13 +17,18 @@ type OrderEntryCtl struct {
controllers.AuthorCtl
}
// 录入人员
// 商品 == > 用户查看所有商品
func (t *OrderEntryCtl) List() {
uid := t.MustGetUID()
activityId := t.MustGetInt64("activity_id")
goods := make([]*models.CustomerGoods, 0)
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).
Asc("created_at").Find(&goods)
entryPerson := new(models.OrderEntryPerson)
exist, err := models.Get(entryPerson, uid)
t.CheckErr(err)
t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在")
goods, err := models.GetGoodsByActivityId(activityId, entryPerson.AreaId)
t.CheckErr(err)
for index := range goods {
url := fmt.Sprintf("%s/PcClient/Client/OrderEntryCtl/order?"+
@ -86,6 +90,7 @@ func (t *OrderEntryCtl) Order() {
prize.ActivityName = activity.Name
prize.PrizeName = gift.GiftName
prize.PrizeImg = gift.GiftPicUrl
prize.ArchId = activity.ArchId
prize.PrizeType = 3
prize.IsDelete = false
prize.CreatedAt = time.Now()
@ -98,8 +103,8 @@ func (t *OrderEntryCtl) Order() {
t.CheckErr(err)
}
} else if gift.Num > 0 {
count, err := core.GetXormAuto().Where("activity_id=? and rehearsal_id=? and is_delete=0",
activityId, activity.RehearsalId).Count(new(models.CustomerOrder))
count, err := core.GetXormAuto().Where("activity_id=? and rehearsal_id=? and arch_id=? and is_delete=0",
activityId, activity.RehearsalId, activity.ArchId).Count(new(models.CustomerOrder))
if err != nil {
session.Rollback()
t.CheckErr(err)
@ -117,6 +122,7 @@ func (t *OrderEntryCtl) Order() {
order := new(models.CustomerOrder)
order.UserPrizeId = prize.Id
order.AreaId = entryPerson.AreaId
order.ArchId = activity.ArchId
order.AreaName = area.Name
order.BuyerId = userId
order.GoodsId = goodId
@ -126,10 +132,8 @@ func (t *OrderEntryCtl) Order() {
order.OrderEntryPersonId = entryPerson.Id
order.GoodsName = good.Name
order.TotalAmount = good.Price
order.OutTradeNo = helper.CreateUUID()
order.OutTradeNo = utils.RandomStr(32)
order.IsDelete = false
order.UpdatedAt = time.Now()
order.CreatedAt = time.Now()
_, err = session.InsertOne(order)
if err != nil {
session.Rollback()
@ -144,13 +148,13 @@ func (t *OrderEntryCtl) Order() {
func (t *OrderEntryCtl) DeleteOrder() {
orderId := t.MustGetInt64("order_id")
order := new(models.CustomerOrder)
exist, err := core.GetXormAuto().Where("is_delete=0 and id=?", orderId).Get(order)
exist, err := models.Get(order, orderId)
t.CheckErr(err)
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "订单不存在")
_, err = new(models.CustomerOrder).SoftDeleteById(orderId)
_, err = models.Del(order, order.Id)
t.CheckErr(err)
if order.UserPrizeId != 0 {
_, err = new(models.UserPrize).SoftDeleteById(order.UserPrizeId)
if order.UserPrizeId > 0 {
_, err = models.Del(&models.UserPrize{}, order.UserPrizeId)
t.CheckErr(err)
}
t.SUCCESS("删除成功")
@ -188,9 +192,9 @@ func (t *OrderEntryCtl) EntryOrders() {
Join("LEFT", new(models.CustomerGoods).Alias("g"),
"o.goods_id=g.id and o.activity_id=g.activity_id and g.is_delete=0").
Join("LEFT", new(models.InvitationLetter).Alias("l"),
"l.user_id = o.buyer_id and o.activity_id=l.activity_id and l.is_delete=0").
Where("o.activity_id=? and o.order_entry_person_id=? and o.rehearsal_id=? and o.is_delete=0",
activityId, uid, activity.RehearsalId).Desc("o.created_at").Find(&list)
"l.user_id = o.buyer_id and o.activity_id=l.activity_id and o.arch_id=l.arch_id and l.is_delete=0").
Where("o.activity_id=? and o.order_entry_person_id=? and o.rehearsal_id=? and arch_id=? and o.is_delete=0",
activityId, uid, activity.RehearsalId, activity.ArchId).Desc("o.created_at").Find(&list)
t.CheckErr(err)
// 添加邀请函的内容
@ -229,8 +233,8 @@ func (t *OrderEntryCtl) UserOrders() {
s := core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o").
Join("LEFT", new(models.CustomerGoods).Alias("g"),
"o.goods_id=g.id and g.is_delete=0").
Where("o.buyer_id=? and o.is_delete=0 and o.activity_id=? and o.rehearsal_id=?",
uid, activity.Id, activity.RehearsalId)
Where("o.buyer_id=? and o.is_delete=0 and o.activity_id=? and o.rehearsal_id=? and o.arch_id=?",
uid, activity.Id, activity.RehearsalId, activity.ArchId)
if t.PageSize > 0 {
s = s.Limit(t.PageSize, t.Page*t.PageSize)

3
controllers/client/reward.go

@ -65,6 +65,7 @@ func (t *RewardCtl) Reward() {
history := models.RewardHistory{
OutTradeNo: res["out_trade_no"].(string),
ActivityId: activityId,
ArchId: activity.ArchId,
RewardServerId: rewardServer.Id,
CustomerId: activity.CustomerId,
UserId: user.Id,
@ -102,7 +103,7 @@ func (t *RewardCtl) List() {
t.CheckErr(err)
t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在")
list, err := bully_reward_service.GetRewardList(uid, activity.RehearsalId, rs.Id)
list, err := bully_reward_service.GetRewardList(uid, activity.RehearsalId, rs.Id, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"total": len(list),

2
controllers/client/shake_red_envelope.go

@ -150,7 +150,7 @@ func (t *ShakeRedEnvelopeCtl) UserRedEnvelopes() {
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "活动不存在")
records, err := models.GetRedEnvelopesByUserId(uid, activityId, activity.RehearsalId)
records, err := models.GetRedEnvelopesByUserId(uid, activityId, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"list": records,

4
controllers/client/sign.go

@ -150,13 +150,13 @@ func (t *SignCtl) Sign() {
if signUp.OnlyInvitation == 1 && _type == 0 { // 直播不需要进行邀请函
// 邀请函才能签到
letter := new(models.InvitationLetter)
exist, err := letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId)
exist, err := letter.GetByUserIdAndActivityId(uid, activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
t.Assert(exist, code.MSG_INVITE_LETTER_NOT_EXIST, "您没收到邀请函")
}
//检查是否已经签到了
history := new(models.SignHistory)
exist, err = history.GetByUserId(activityId, activity.ArchId, uid, activity.RehearsalId, area.Id)
exist, err = history.GetByUserId(activity.Id, activity.ArchId, uid, activity.RehearsalId, area.Id)
t.CheckErr(err)
if exist || history.Status == 2 {
t.ERROR("您已经签到过了", code.MSG_SIGN_HISTORY_EXIST)

6
controllers/client/tug_war.go

@ -31,7 +31,7 @@ func (t *TugOfWarCtl) Status() {
// 找到用户
member := new(models.BaheTeamMember)
exist, err = member.GetMemberByBaheIdAndUserId(uid, bahe.Id, activity.RehearsalId)
exist, err = member.GetMemberByBaheIdAndUserId(activity.ArchId, uid, bahe.Id, activity.RehearsalId)
t.CheckErr(err)
t.Assert(exist, code.MSG_TUGWAR_MEMBER_NOT_EXIST, "队员不存在")
@ -78,7 +78,7 @@ func (t *TugOfWarCtl) Shake() {
t.CheckRunning(activity.Status)
member := new(models.BaheTeamMember)
exist, err = member.GetMemberByBaheIdAndUserId(uid, baheId, activity.RehearsalId)
exist, err = member.GetMemberByBaheIdAndUserId(activity.ArchId, uid, baheId, activity.RehearsalId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ERR, "该用户尚未加入队伍")
@ -128,7 +128,7 @@ func (t *TugOfWarCtl) JoinTeam() {
// 判斷是否已經存在该用户
member := new(models.BaheTeamMember)
exist, err = member.GetMemberByBaheIdAndUserId(uid, bahe.Id, activity.RehearsalId)
exist, err = member.GetMemberByBaheIdAndUserId(activity.ArchId, uid, bahe.Id, activity.RehearsalId)
t.CheckErr(err)
if exist { // 存在改用户
t.JSON(map[string]interface{}{

4
controllers/client/upper_wall.go

@ -14,7 +14,6 @@ type UpperWallCtl struct {
}
//发送上墙消息
// todo: 支付接口
func (t *UpperWallCtl) Send() {
uid := t.MustGetUID()
activityId := t.MustGetInt64("activity_id")
@ -46,6 +45,7 @@ func (t *UpperWallCtl) Send() {
uw.RehearsalId = activity.RehearsalId
uw.ActivityId = activityId
uw.Category = fmt.Sprintf("%v", category)
uw.ArchId = activity.ArchId
uw.UserId = user.Id
uw.Content = content
uw.Img = img
@ -66,7 +66,7 @@ func (t *UpperWallCtl) List() {
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
list, err := upper_wall.GetUpperWallResult(userId, activity.Id, activity.RehearsalId)
list, err := upper_wall.GetUpperWallResult(userId, activity.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"list": list,

11
controllers/client/vote.go

@ -37,17 +37,17 @@ func (t *VoteCtl) Vote() {
t.CheckRunning(activity.Status)
history := new(models.NewVoteActivityHistory)
exist, err = history.ExistByLadderId(uid, ladderId, activity.RehearsalId)
exist, err = history.ExistByLadderId(uid, ladderId, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.Assert(!exist, code.MSG_VOTE_HISTORY_EXIST, "您已经投过票了")
if vote.Model == "单选" {
//检查是否已经投过票了
exist, err = history.ExistByVoteId(uid, vote.Id, activity.RehearsalId)
exist, err = history.ExistByVoteId(uid, vote.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.Assert(!exist, code.MSG_VOTE_HISTORY_EXIST, "您已经投过票了")
} else {
num, err := history.CountUser(uid, activity.RehearsalId, vote.Id)
num, err := history.CountUser(uid, activity.RehearsalId, vote.Id, activity.ArchId)
t.CheckErr(err)
if num >= vote.ModelNum {
t.ERROR(fmt.Sprintf("您投票人数已超过%d人", vote.ModelNum), code.MSG_ERR)
@ -64,7 +64,6 @@ func (t *VoteCtl) Vote() {
_, err = models.Add(history)
t.CheckErr(err)
// vote ladder total_number + 1
_, err = ladder.Incr(ladderId, 1)
t.CheckErr(err)
@ -107,8 +106,8 @@ func (t *VoteCtl) Detail() {
t.CheckErr(err)
histories := make([]*models.NewVoteActivityHistory, 0)
err = core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and vote_activity_id=?",
uid, activity.RehearsalId, voteActivityId).Find(&histories)
err = core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and vote_activity_id=? "+
" and arch_id=?", uid, activity.RehearsalId, voteActivityId, activity.ArchId).Find(&histories)
t.CheckErr(err)
for i := range ladders {

18
controllers/client/wx.go

@ -60,21 +60,3 @@ func (t *WxCtl) Ticket() {
"appid": define.AppId,
})
}
//type WechatPay struct {
//}
//func (t *WxCtl) Order() {
// userId := t.MustGetUID()
// content := t.MustGet("content")
// amount := t.MustGetInt("amount")
//
// user := new(models.User)
// exist, err := models.GetById(user, userId)
// t.CheckErr(err)
// t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
//
// ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":")
// res, err := pay_service.Order(content, ip[0], user.Openid, amount, 1, user.Id)
// t.JSON(res)
//}

26
controllers/pc/auction.go

@ -79,7 +79,7 @@ func (t *AuctionCtl) StopAuction() {
// todo: 记录用户最高价
if auction.AuctionModel == define.INCR_AUCTION {
history := new(models.AuctionHistory)
_, err := history.GetHighestMoney(activity.RehearsalId, auction.Id) // 区分彩排数据
_, err := history.GetHighestMoney(activity.RehearsalId, auction.Id, activity.ArchId) // 区分彩排数据
t.CheckErr(err)
user := new(models.User)
@ -89,12 +89,12 @@ func (t *AuctionCtl) StopAuction() {
if exist {
record.AuctionActivityId = auctionId
record.RehearsalId = history.RehearsalId // 彩排
record.ArchId = activity.ArchId
record.AuctionGoodsName = auction.AuctionGoodsName
record.ActivityId = auction.ActivityId
record.UserId = history.UserId
record.UserPhone = user.Phone
record.UserName = user.Nickname
record.ArchId = activity.ArchId
record.Unit = history.Unit
record.DealPrice = history.Money
record.PlayerCode = history.PlayerCode
@ -217,10 +217,18 @@ func (t *AuctionCtl) List() {
// 成交记录
func (t *AuctionCtl) Records() {
rehearsalId := t.MustGetInt64("rehearsal_id") // 彩排
auctionId := t.MustGetInt64("auction_activity_id")
auction := &models.NewAuctionActivity{}
exist, err := models.Get(auction, auctionId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍活动不存在")
records, err := models.GetAuctionRecordsByAuctionId(auctionId, rehearsalId, "created_at desc")
activity := &models.Activity{}
exist, err = models.Get(activity, auction.ActivityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "互动不存在")
records, err := models.GetAuctionRecordsByAuctionId(auctionId, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"records": records,
@ -234,10 +242,14 @@ func (t *AuctionCtl) Qrcode() {
uid := t.MustGetUID()
activityId := t.MustGetInt64("activity_id")
auctionId := t.MustGetInt64("auction_activity_id")
rehearsalId := t.MustGetInt("rehearsal_id")
activity := &models.Activity{}
exist, err := models.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "互动不存在")
area := new(models.AreaStore)
exist, err := area.GetByCustomerId(uid, activityId)
exist, err = area.GetByCustomerId(uid, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
@ -246,7 +258,7 @@ func (t *AuctionCtl) Qrcode() {
"area_id": area.Id,
"customer_id": uid,
"auction_id": auctionId,
"rehearsal_id": rehearsalId,
"rehearsal_id": activity.RehearsalId,
})
t.CheckErr(err)
t.JSON(map[string]interface{}{

4
controllers/pc/bully_screen.go

@ -142,7 +142,7 @@ func (t *BullyScreenCtl) Amount() {
t.CheckErr(err)
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
totalSecond, err := new(models.BullyScreenHistory).SumSecond(bullyScreenServer.Id, activity.RehearsalId)
totalSecond, err := new(models.BullyScreenHistory).SumSecond(bullyScreenServer.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
@ -165,7 +165,7 @@ func (t *BullyScreenCtl) Latest() {
t.CheckErr(err)
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
result, err := bully_reward_service.GetBullyScreenLatest(bullyScreenServer.Id, activity.RehearsalId)
result, err := bully_reward_service.GetBullyScreenLatest(bullyScreenServer.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
if result == nil || result.Id == 0 {
t.JSON(result)

7
models/auction_history.go

@ -13,6 +13,7 @@ type AuctionHistory struct {
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
UserId int64 `json:"user_id" xorm:"not null comment('用户表id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null comment('彩排id, 0是正式') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
PlayerId int64 `json:"player_id" xorm:"not null comment('竞拍者id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null comment('互动id') INT(11)"`
AreaId int64 `json:"area_id" xorm:"not null comment('地区id') INT(11)"`
@ -34,9 +35,9 @@ func (t *AuctionHistory) TableName() string {
return AuctionHistoryTableName
}
func (t *AuctionHistory) GetHighestMoney(rid, aid int64) (bool, error) {
return core.GetXormAuto().Where("auction_activity_id = ? and rehearsal_id=? and is_delete=0", aid, rid).
Desc("money").Asc("updated_at").Get(t)
func (t *AuctionHistory) GetHighestMoney(rid, aid int64, archId interface{}) (bool, error) {
return core.GetXormAuto().Where("auction_activity_id = ? and arch_id=? and rehearsal_id=? and is_delete=0",
aid, archId, rid).Desc("money").Asc("updated_at").Get(t)
}
func (t *AuctionHistory) CountHistory(rid, aid int64) (int64, error) {

7
models/auction_player.go

@ -12,6 +12,7 @@ type AuctionPlayer struct {
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
AuctionActivityId int64 `json:"auction_activity_id" xorm:"not null comment('竞拍活动id') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null comment('客户的id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id, 0正式数据') INT(11)"`
Code int64 `json:"code" xorm:"not null comment('竞拍参与人的代号') INT(11)"`
IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(0)"`
@ -23,7 +24,7 @@ func (t *AuctionPlayer) TableName() string {
return AuctionPlayerTableName
}
func (t *AuctionPlayer) GetByAuctionIdAndUid(aid, uid, rid int64) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and auction_activity_id=? and user_id=? and rehearsal_id=?",
aid, uid, rid).Get(t)
func (t *AuctionPlayer) GetByAuctionIdAndUid(aid, uid, rid int64, archId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and auction_activity_id=? and arch_id=? and user_id=? and rehearsal_id=?",
aid, archId, uid, rid).Get(t)
}

16
models/auction_result_record.go

@ -31,17 +31,19 @@ func (t *AuctionResultRecord) TableName() string {
return AuctionResultRecordTableName
}
func (t *AuctionResultRecord) 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 (t *AuctionResultRecord) CountHistory(rid, aid int64, archId interface{}) (int64, error) {
return core.GetXormAuto().Where("auction_activity_id=? and arch_id=? and rehearsal_id=? and is_delete=0",
aid, archId, rid).Count(t)
}
func GetAuctionRecordsByAuctionId(id, rid int64, orderBy string) ([]*AuctionResultRecord, error) {
func GetAuctionRecordsByAuctionId(id, rid int64, archId interface{}) ([]*AuctionResultRecord, error) {
records := make([]*AuctionResultRecord, 0)
err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=? and auction_activity_id=?", rid, id).
OrderBy(orderBy).Find(&records)
err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=? and auction_activity_id=? and arch_id=?", rid, id, archId).
Desc("created_at").Find(&records)
return records, err
}
func (t *AuctionResultRecord) GetByUserIdAndAuctionId(userId, auctionId, rehearsalId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and auction_activity_id=? and rehearsal_id=?", userId, auctionId, rehearsalId).Get(t)
func (t *AuctionResultRecord) GetByUserIdAndAuctionId(userId, auctionId, archId, rehearsalId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and auction_activity_id=? and arch_id=? and rehearsal_id=?",
userId, auctionId, archId, rehearsalId).Get(t)
}

1
models/barrage_history.go

@ -11,6 +11,7 @@ type BarrageHistory struct {
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null comment('主活动得id') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null comment('用户得id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
Content string `json:"content" xorm:"not null comment('内容') TEXT"`
IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
CreateAt time.Time `json:"create_at" xorm:"not null created comment('创建时间') DATETIME"`

4
models/base.go

@ -143,6 +143,10 @@ func Get(bean interface{}, id int64) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and id=?", id).Get(bean)
}
func Del(bean interface{}, id interface{}) (int64, error) {
return core.GetXormAuto().NoAutoCondition().ID(id).Delete(bean)
}
func Add(bean interface{}) (int64, error) {
return core.GetXormAuto().InsertOne(bean)
}

5
models/bully_screen_history.go

@ -17,6 +17,7 @@ type BullyScreenHistory struct {
BullyScreenServerId int64 `json:"bully_screen_server_id" xorm:"not null default 0 comment('霸屏服务得id') INT(11)"`
OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('微信订单号') VARCHAR(128)"`
CustomerId int64 `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户得id') INT(11)"`
Nickname string `json:"nickname" xorm:"not null default '' comment('发送者昵称') VARCHAR(128)"`
@ -66,9 +67,9 @@ func GetBullyScreenHistoryByIds(ids interface{}) ([]*BullyScreenHistory, error)
return result, err
}
func (t *BullyScreenHistory) SumSecond(serverId, rehearsalId interface{}) (float64, error) {
func (t *BullyScreenHistory) SumSecond(serverId, rehearsalId, archId interface{}) (float64, error) {
totalSecond, err := core.GetXormAuto().Where("bully_screen_server_id=? and status=3 and "+
" is_delete=false and rehearsal_id=?", serverId, rehearsalId).
" is_delete=false and rehearsal_id=? and arch_id=?", serverId, rehearsalId, archId).
Sum(new(BullyScreenHistory), "second")
return totalSecond, err
}

18
models/customer_order.go

@ -16,6 +16,7 @@ type CustomerOrder struct {
UserPrizeId int64 `json:"user_prize_id" xorm:"not null default 0 comment('用户奖品id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
AreaName string `json:"area_name" xorm:"not null default '' comment('地区名字') VARCHAR(255)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/0正式') BIGINT(20)"`
@ -58,26 +59,21 @@ func (t *CustomerOrder) TableName() string {
return CustomerOrderTableName
}
func (t *CustomerOrder) SoftDeleteById(id int64) (int64, error) {
t.IsDelete = true
return core.GetXormAuto().Where("id=?", id).Cols("is_delete").Update(t)
}
func (t *CustomerOrder) GetByOutTradeNO(outTradeNo string) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo).Get(t)
}
func (t *CustomerOrder) Count(activityId, rehearsalId int64, limitTime time.Time) (int64, error) {
func (t *CustomerOrder) Count(activityId, rehearsalId int64, limitTime time.Time, archId interface{}) (int64, error) {
return core.GetXormAuto().Where("user_prize_id=0 and created_at >= ? and "+
"activity_id=? and rehearsal_id=? and is_delete=0",
limitTime, activityId, rehearsalId).Count(t)
"activity_id=? and rehearsal_id=? and arch_id=? and is_delete=0",
limitTime, activityId, rehearsalId, archId).Count(t)
}
func GetCustomerOrdersByActivityId(userId, activityId, rehearsalId, areaId int64, status []string, page, pageSize int) ([]*CustomerOrder, error) {
func GetCustomerOrdersByActivityId(userId, activityId, rehearsalId, areaId int64, status []string, page, pageSize int, archId interface{}) ([]*CustomerOrder, error) {
orders := make([]*CustomerOrder, 0)
err := core.GetXormAuto().Where("is_delete=0 and buyer_id=? and activity_id=? and "+
"rehearsal_id=? and area_id=?", userId, activityId, rehearsalId, areaId).In("status", status).
Desc("created_at").Limit(pageSize, page*pageSize).Find(&orders)
"rehearsal_id=? and area_id=? and arch_id=?", userId, activityId, rehearsalId, areaId, archId).
In("status", status).Desc("created_at").Limit(pageSize, page*pageSize).Find(&orders)
return orders, err
}

5
models/live_viewer.go

@ -13,6 +13,7 @@ type LiveViewer struct {
CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
UpdatedAt time.Time `json:"updated_at" xorm:"not null updated default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"`
UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('活动id') INT(11)"`
LiveConfigId int64 `json:"live_config_id" xorm:"not null default 0 comment('直播id') INT(11)"`
}
@ -53,7 +54,9 @@ func (t *LiveViewer) Record(uid, aid, lid int64) error {
func GetLiveViewerByLiveConfigIds(ids interface{}) ([]*LiveViewer, error) {
viewers := make([]*LiveViewer, 0)
err := core.GetXormAuto().Where("is_delete=0").In("live_config_id", ids).Find(&viewers)
err := core.GetXormAuto().Table(&LiveViewer{}).Alias("l").Join("left", Alias(&Activity{}, "a"),
"a.id=l.activity_id and l.arch_id=a.arch_id").Where("is_delete=0").In("live_config_id", ids).
Find(&viewers)
return viewers, err
}

11
models/lottery_draw_record.go

@ -41,8 +41,9 @@ func (t *LotteryDrawRecord) TableName() string {
return LotteryDrawRecordTableName
}
func (t *LotteryDrawRecord) GetByUserIdAndLadderId(userId, ladderId interface{}, rollNum int) (bool, error) {
session := core.GetXormAuto().Where("is_delete=0 and user_id=? and lottery_draw_rule_ladder_id=?", userId, ladderId)
func (t *LotteryDrawRecord) GetByUserIdAndLadderId(userId, ladderId, archId interface{}, rollNum int) (bool, error) {
session := core.GetXormAuto().Where("is_delete=0 and user_id=? and lottery_draw_rule_ladder_id=? and arch_id=?",
userId, ladderId, archId)
defer session.Close()
if rollNum > 0 {
session.Where("roll_num=?", rollNum)
@ -66,11 +67,11 @@ func GetLotteryUsersResultByLotteryDrawRecord(obj, ladderId, rehearsalId interfa
return session.Find(&obj)
}
func GetUserIdsByLotteryDrawRuleId(ruleId, rehearsalId, areaId interface{}) ([]int64, error) {
func GetUserIdsByLotteryDrawRuleId(ruleId, rehearsalId, areaId, archId interface{}) ([]int64, error) {
recordIds := make([]int64, 0)
err := core.GetXormAuto().Table(new(LotteryDrawRecord)).Select("user_id").
Where("lottery_draw_rule_id=? and rehearsal_id=? and area_id=? and is_delete=0",
ruleId, rehearsalId, areaId).Find(&recordIds)
Where("lottery_draw_rule_id=? and rehearsal_id=? and area_id=? and arch_id=? and is_delete=0",
ruleId, rehearsalId, areaId, archId).Find(&recordIds)
return recordIds, err
}

17
models/new_vote_activity_history.go

@ -13,6 +13,7 @@ type NewVoteActivityHistory struct {
VoteActivityLadderId int64 `json:"vote_activity_ladder_id" xorm:"not null default(0) comment('投票活动对象') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null default(0) comment('投票人') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"`
CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间')"`
UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间')"`
@ -26,17 +27,17 @@ func (t *NewVoteActivityHistory) Alias(name string) string {
return Alias(t, name)
}
func (t *NewVoteActivityHistory) ExistByLadderId(uid, lid, rid int64) (bool, error) {
func (t *NewVoteActivityHistory) ExistByLadderId(uid, lid, rid int64, archId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_ladder_id=? and "+
" rehearsal_id=?", uid, lid, rid).Exist(t)
" rehearsal_id=? and arch_id=?", uid, lid, rid, archId).Exist(t)
}
func (t *NewVoteActivityHistory) ExistByVoteId(uid, vid, rid int64) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_id=? and rehearsal_id=?",
uid, vid, rid).Exist(t)
func (t *NewVoteActivityHistory) ExistByVoteId(uid, vid, rid int64, archId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_id=? and "+
" rehearsal_id=? and arch_id=?", uid, vid, rid, archId).Exist(t)
}
func (t *NewVoteActivityHistory) CountUser(uid, rid, vid int64) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and vote_activity_id=?",
uid, rid, vid).Count(t)
func (t *NewVoteActivityHistory) CountUser(uid, rid, vid int64, archId interface{}) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and "+
" vote_activity_id=? and arch_id=?", uid, rid, vid, archId).Count(t)
}

1
models/reward_history.go

@ -19,6 +19,7 @@ type RewardHistory struct {
CustomerId int64 `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"`
RewardServerId int64 `json:"reward_server_id" xorm:"not null default 0 comment('打赏服务id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/0正式') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户得id') INT(11)"`
Content string `json:"content" xorm:"not null comment('内容') text"`

18
models/shake_red_envelope_record.go

@ -39,10 +39,6 @@ func (t *ShakeRedEnvelopeRecord) ExistRecord(reid, srid, uid int64) (bool, error
"shake_red_envelope_rule_id=? and user_id=?", reid, srid, uid).Exist(t)
}
func (t *ShakeRedEnvelopeRecord) Add() (int64, error) {
return core.GetXormAuto().InsertOne(t)
}
func (t *ShakeRedEnvelopeRecord) Total(aid, rid, said, srid int64) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and "+
"shake_red_envelope_activity_id=? and shake_red_envelope_rule_id=?", aid, rid, said, srid).Count(t)
@ -60,19 +56,15 @@ func (t *ShakeRedEnvelopeRecord) Count(aid, rid, said, srid int64, status int64)
"shake_red_envelope_activity_id=? and shake_red_envelope_rule_id=?", status, aid, rid, said, srid).Count(t)
}
func (t *ShakeRedEnvelopeRecord) GetByRuleId(ruleId, rehearsalId, _type interface{}) (bool, error) {
func (t *ShakeRedEnvelopeRecord) GetByRuleId(ruleId, rehearsalId, _type, archId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and is_draw=-1 and shake_red_envelope_type = ? and "+
"shake_red_envelope_rule_id=? and rehearsal_id=?", _type, ruleId, rehearsalId).Get(t)
}
func (t *ShakeRedEnvelopeRecord) UpdateById(id int64, field ...string) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and id=?", id).Cols(field...).Update(t)
"shake_red_envelope_rule_id=? and rehearsal_id=? and arch_id=?", _type, ruleId, rehearsalId, archId).Get(t)
}
func GetRedEnvelopesByUserId(userId, activityId, rehearsalId int64) ([]*ShakeRedEnvelopeRecord, error) {
func GetRedEnvelopesByUserId(userId, activityId, rehearsalId int64, archId interface{}) ([]*ShakeRedEnvelopeRecord, error) {
records := make([]*ShakeRedEnvelopeRecord, 0)
err := core.GetXormAuto().Where("user_id=? and rehearsal_id=? and activity_id=? and "+
"is_delete=0 and is_draw<>-1", userId, rehearsalId, activityId).Desc("created_at").
err := core.GetXormAuto().Where("user_id=? and rehearsal_id=? and activity_id=? and arch_id=? and "+
"is_delete=0 and is_draw<>-1", userId, rehearsalId, activityId, archId).Desc("created_at").
Find(&records)
for index := range records {
records[index].IsValid = true

11
models/shake_red_envelope_user.go

@ -1,12 +1,16 @@
package models
import "time"
import (
"github.com/ouxuanserver/osmanthuswine/src/core"
"time"
)
const ShakeRedEnvelopeUserTableName = TableNamePrefix + "shake_red_envelope_user"
type ShakeRedEnvelopeUser struct {
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
ShakeRedEnvelopeActivityId int64 `json:"shake_red_envelope_activity_id" xrom:"not null comment('摇红包活动id') INT(11)"`
ShakeRedEnvelopeRuleId int64 `json:"shake_red_envelope_rule_id" xorm:"not null comment('轮次id') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null comment('用户id') INT(11)"`
@ -18,3 +22,8 @@ type ShakeRedEnvelopeUser struct {
func (t *ShakeRedEnvelopeUser) TableName() string {
return ShakeRedEnvelopeUserTableName
}
func (t *ShakeRedEnvelopeUser) Exist(userId, ruleId, archId, rehearsalId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and shake_red_envelope_rule_id=? and "+
" arch_id=? and rehearsal_id=?", userId, ruleId, archId, rehearsalId).Exist(t)
}

1
models/upper_wall.go

@ -9,6 +9,7 @@ type UpperWall struct {
Id int64 `json:"id" xorm:"pk autoincr INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null comment('主活动id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排、0正式') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
Category string `json:"category" xorm:"not null comment('类型[1文本|2图片|3图片+文本]') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null comment('用户得id') INT(11)"`
User *User `json:"user" xorm:"-" description:"用户信息"`

18
services/auction/auction.go

@ -9,7 +9,7 @@ import (
"time"
)
func GetCurrentAuction(aid, rid, uid int64) (map[string]interface{}, error) {
func GetCurrentAuction(aid, rid, uid int64, archId int) (map[string]interface{}, error) {
auction := new(models.NewAuctionActivity)
exist, err := auction.GetCurrent(aid)
if err != nil {
@ -22,7 +22,7 @@ func GetCurrentAuction(aid, rid, uid int64) (map[string]interface{}, error) {
// 计算当前价格 和 当前数量
if auction.AuctionModel == define.INCR_AUCTION { // 加价竞拍 最高价格
history := new(models.AuctionHistory)
exist, err = history.GetHighestMoney(rid, auction.Id)
exist, err = history.GetHighestMoney(rid, auction.Id, archId)
if err != nil {
return nil, err
}
@ -41,7 +41,7 @@ func GetCurrentAuction(aid, rid, uid int64) (map[string]interface{}, error) {
auction.CurrentMoney = money
}
record := new(models.AuctionResultRecord)
count, err := record.CountHistory(rid, aid)
count, err := record.CountHistory(rid, aid, archId)
if err != nil {
return nil, err
}
@ -49,7 +49,7 @@ func GetCurrentAuction(aid, rid, uid int64) (map[string]interface{}, error) {
}
player := new(models.AuctionPlayer)
exist, err = player.GetByAuctionIdAndUid(auction.Id, uid, rid)
exist, err = player.GetByAuctionIdAndUid(auction.Id, uid, rid, archId)
if err != nil {
return nil, err
}
@ -59,13 +59,15 @@ func GetCurrentAuction(aid, rid, uid int64) (map[string]interface{}, error) {
if session.Begin(); err != nil { // 开启事务
return nil, err
}
num, err := session.Where("is_delete=0 and auction_activity_id=? and rehearsal_id=?", auction.Id, rid).Count(player)
num, err := session.Where("is_delete=0 and auction_activity_id=? and arch_id=? and rehearsal_id=?",
auction.Id, archId, rid).Count(player)
if err != nil {
session.Rollback()
return nil, err
}
player.AuctionActivityId = auction.Id
player.UserId = uid
player.ArchId = archId
player.RehearsalId = rid
player.Code = num + 1
player.UpdatedAt = time.Now()
@ -92,13 +94,13 @@ type UserAuctionsResult struct {
Unit int64 `json:"unit"`
}
func GetUserAuctions(activityId, rehearsalId, userId int64) ([]*UserAuctionsResult, error) {
func GetUserAuctions(activityId, rehearsalId, userId int64, archId interface{}) ([]*UserAuctionsResult, error) {
records := make([]*UserAuctionsResult, 0)
err := core.GetXormAuto().Table(new(models.AuctionResultRecord)).Alias("r").
Select("r.id, a.id as auction_activity_id, a.auction_goods_name, a.goods_pic_url, r.deal_price, a.unit").
Join("LEFT", new(models.NewAuctionActivity).Alias("a"),
"a.id=r.auction_activity_id and a.is_delete=0").
Where("r.is_delete=0 and r.activity_id=? and r.user_id=? and r.rehearsal_id=?",
activityId, userId, rehearsalId).Desc("r.created_at").Find(&records)
Where("r.is_delete=0 and r.activity_id=? and r.arch_id=? and r.user_id=? and r.rehearsal_id=?",
activityId, archId, userId, rehearsalId).Desc("r.created_at").Find(&records)
return records, err
}

2
services/bahe/tug_war.go

@ -31,7 +31,7 @@ func GetMember(bid, rid, uid int64) (*models.BaheTeamMember, bool, error) {
return member, exist, err
}
func GetCurrentTugWar(activityId, archId, uid, rehearsalId interface{}) (map[string]interface{}, error) {
func GetCurrentTugWar(activityId, uid, rehearsalId interface{}, archId interface{}) (map[string]interface{}, error) {
bahe := new(models.TugOfWar)
exist, err := bahe.GetCurrent(activityId)
if err != nil {

16
services/bully_reward/dao.go

@ -27,13 +27,11 @@ type RewardListResult struct {
Status int `json:"status"`
}
func GetRewardList(userId, rehearsalId, rewardId int64) ([]*RewardListResult, error) {
func GetRewardList(userId, rehearsalId, rewardId int64, archId interface{}) ([]*RewardListResult, error) {
list := make([]*RewardListResult, 0)
err := core.GetXormAuto().Table(new(models.RewardHistory)).
Select("id, content, amount, status").
Where("is_delete=0 and user_id=? and reward_server_id=? and "+
" rehearsal_id=? and status <> -1", userId, rewardId, rehearsalId).
Desc("created_at").Find(&list)
err := core.GetXormAuto().Table(new(models.RewardHistory)).Select("id, content, amount, status").
Where("is_delete=0 and user_id=? and reward_server_id=? and rehearsal_id=? and arch_id=? and status <> -1",
userId, rewardId, rehearsalId, archId).Desc("created_at").Find(&list)
return list, err
}
@ -132,12 +130,12 @@ func GetBullyScreenBlacklist(bullyScreenServerId, rehearsalId int64) ([]*BullySc
return result, err
}
func GetBullyScreenLatest(bullyScreenServerId, rehearsalId int64) (*BullyScreenResult, error) {
func GetBullyScreenLatest(bullyScreenServerId, rehearsalId int64, archId interface{}) (*BullyScreenResult, error) {
result := new(BullyScreenResult)
_, 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.bully_screen_server_id=? and h.status=2 and h.rehearsal_id=? and h.is_delete=0",
bullyScreenServerId, rehearsalId).Desc("review_time").Get(result)
Where("h.bully_screen_server_id=? and h.status=2 and h.rehearsal_id=? and h.arch_id=? and h.is_delete=0",
bullyScreenServerId, rehearsalId, archId).Desc("review_time").Get(result)
return result, err
}

3
services/calorie/calorie.go

@ -7,7 +7,7 @@ import (
"time"
)
func GetCurrentCalorie(aid, uid, rid int64, archId interface{}) (map[string]interface{}, error) {
func GetCurrentCalorie(aid, uid, rid int64, archId int) (map[string]interface{}, error) {
calorie := new(models.Calorie)
exist, err := calorie.GetCurrent(aid)
if err != nil {
@ -25,6 +25,7 @@ func GetCurrentCalorie(aid, uid, rid int64, archId interface{}) (map[string]inte
calorieUser.ActivityId = aid
calorieUser.RehearsalId = rid
calorieUser.UserId = uid
calorieUser.ArchId = archId
calorieUser.CalorieId = calorie.Id
calorieUser.Score = 0
calorieUser.IsDelete = false

12
services/lottery/lottery.go

@ -143,12 +143,12 @@ type LotteryUsersResult struct {
Avatar string `json:"avatar"`
}
func GetLotteryUsersResultByRollNum(ladderId, rehearsalId interface{}, rollNum int) ([]*LotteryUsersResult, error) {
func GetLotteryUsersResultByRollNum(ladderId, rehearsalId, archId interface{}, rollNum int) ([]*LotteryUsersResult, error) {
users := make([]*LotteryUsersResult, 0)
session := 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_ladder_id=? and "+
"r.rehearsal_id=?", ladderId, rehearsalId)
Where("r.is_delete=0 and r.lottery_draw_rule_ladder_id=? and r.rehearsal_id=? and r.arch_id=?",
ladderId, rehearsalId, archId)
defer session.Close()
if rollNum > 0 {
session = session.Where("roll_num=?", rollNum)
@ -157,13 +157,13 @@ func GetLotteryUsersResultByRollNum(ladderId, rehearsalId interface{}, rollNum i
return users, err
}
func GetLotteryUsersResult(areaId, activityId, rehearsalId interface{}, ids []int64) ([]*LotteryUsersResult, error) {
func GetLotteryUsersResult(areaId, activityId, rehearsalId, archId interface{}, ids []int64) ([]*LotteryUsersResult, error) {
result := make([]*LotteryUsersResult, 0)
session := core.GetXormAuto().Table(new(models.SignHistory)).Alias("h").
Select("h.user_id, u.nickname as username, u.avatar").Distinct("h.user_id").
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete = 0").
Where("h.is_delete=0 and h.area_id=? and h.activity_id=? and h.rehearsal_id=?",
areaId, activityId, rehearsalId)
Where("h.is_delete=0 and h.area_id=? and h.activity_id=? and h.rehearsal_id=? and h.arch_id=?",
areaId, activityId, rehearsalId, archId)
if len(ids) >= 0 {
session = session.NotIn("h.user_id", ids)
}

5
services/pay/handle.go

@ -70,16 +70,15 @@ func HandleSuccess(order *models.UserOrder) error {
prize.ActivityId = order.ActivityId
prize.RehearsalId = activity.RehearsalId
prize.ActivityName = activity.Name
prize.ArchId = activity.ArchId
prize.PrizeName = gift.GiftName
prize.PrizeImg = gift.GiftPicUrl
prize.PrizeType = 4
prize.IsDelete = false
prize.Status = 1
prize.CreatedAt = time.Now()
prize.UpdatedAt = time.Now()
if gift.Num > 0 {
count, err := new(models.CustomerOrder).
Count(activity.Id, activity.RehearsalId, customerOrder.CreatedAt)
Count(activity.Id, activity.RehearsalId, customerOrder.CreatedAt, activity.ArchId)
if err != nil {
err = fmt.Errorf("订单人数统计失败: err->%v, out_trade_no->%v", err, order.OutTradeNo)
logger.Error(err)

31
services/red_envelope/red_envelop.go

@ -10,7 +10,7 @@ import (
"time"
)
func GetCurrentRB(aid, uid, rid int64) (map[string]interface{}, error) {
func GetCurrentRB(aid, uid, rid int64, archId int) (map[string]interface{}, error) {
// 信息 一轮只能有一个
rule := new(models.ShakeRedEnvelopeRule)
exist, err := rule.GetCurrent(aid)
@ -18,24 +18,25 @@ func GetCurrentRB(aid, uid, rid int64) (map[string]interface{}, error) {
return nil, err
}
if exist {
shakeUser := new(models.ShakeRedEnvelopeUser)
shakeUser.UserId = uid
shakeUser.ShakeRedEnvelopeActivityId = rule.ShakeRedEnvelopeActivityId
shakeUser.ShakeRedEnvelopeRuleId = rule.Id
shakeUser.RehearsalId = rid
shakeUser.CreatedAt = time.Now()
shakeUser.UpdateAt = time.Now()
shakeUser.IsDelete = 0
err := models.Save(map[string]interface{}{
"user_id=": uid,
"shake_red_envelope_activity_id=": rule.ShakeRedEnvelopeActivityId,
"shake_red_envelope_rule_id=": rule.Id,
"rehearsal_id=": rid,
}, shakeUser)
exist, err := shakeUser.Exist(uid, rule.Id, archId, rid)
if err != nil {
return nil, err
}
if !exist {
shakeUser.UserId = uid
shakeUser.ArchId = archId
shakeUser.ShakeRedEnvelopeActivityId = rule.ShakeRedEnvelopeActivityId
shakeUser.ShakeRedEnvelopeRuleId = rule.Id
shakeUser.RehearsalId = rid
shakeUser.CreatedAt = time.Now()
shakeUser.UpdateAt = time.Now()
shakeUser.IsDelete = 0
_, err = models.Add(shakeUser)
if err != nil {
return nil, err
}
}
return map[string]interface{}{
"rule": rule,
}, nil

6
services/upper_wall/upper_wall.go

@ -13,12 +13,12 @@ type UpperWallResult struct {
Status int `json:"status"`
}
func GetUpperWallResult(userId, activityId, rehearsalId interface{}) ([]*UpperWallResult, error) {
func GetUpperWallResult(userId, activityId, rehearsalId, archId interface{}) ([]*UpperWallResult, error) {
result := make([]*UpperWallResult, 0)
err := core.GetXormAuto().Table(new(models.UpperWall)).
Select("id, content, img, category, status").
Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=?",
userId, activityId, rehearsalId).
Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=? and arch_id=?",
userId, activityId, rehearsalId, archId).
OrderBy("created_at desc").Find(&result)
return result, err
}
Loading…
Cancel
Save