From 4c0dd35205747216f7dcfa4d7e9ff9534ae92273 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Tue, 19 May 2020 17:59:42 +0800 Subject: [PATCH] add rehearsal_id --- controllers/client/auction.go | 7 ++++++- controllers/client/bully_screen.go | 12 ++++++++++-- controllers/client/order_entry.go | 12 ++++++++++-- controllers/client/reward.go | 15 ++++++++++----- controllers/client/shake_red_envelope.go | 9 ++++++++- controllers/client/upper_wall.go | 6 ++++-- controllers/pc/reward.go | 4 ++-- models/shake_red_envelope_record.go | 5 +++-- services/auction/auction.go | 9 +++++---- services/bully_reward/dao.go | 8 +++++--- 10 files changed, 63 insertions(+), 24 deletions(-) diff --git a/controllers/client/auction.go b/controllers/client/auction.go index 8ac2de0..2566e9f 100644 --- a/controllers/client/auction.go +++ b/controllers/client/auction.go @@ -170,7 +170,12 @@ func (t *AuctionCtl) UserAuctions() { uid := t.MustGetUID() activityId := t.MustGetInt64("activity_id") - records, err := auction_service.GetUserAuctions(activityId, uid) + activity := new(models.Activity) + exist, err := models.GetById(activity, activityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") + + records, err := auction_service.GetUserAuctions(activityId, activity.RehearsalId, uid) t.CheckErr(err) t.JSON(map[string]interface{}{ "list": records, diff --git a/controllers/client/bully_screen.go b/controllers/client/bully_screen.go index 555ad9e..70f45d6 100644 --- a/controllers/client/bully_screen.go +++ b/controllers/client/bully_screen.go @@ -52,8 +52,13 @@ func (t *BullyScreenCtl) PaScreen() { // todo:微信直接付款 // 调用微信统一下单接口 amount := bullyScreenServer.Price * second - res, err := pay_service.UnifiedOrder("欧轩互动-霸屏支付", user.Openid, int64(amount*100), 1, user.Id, activityId) - t.CheckErr(err) + + var res = make(map[string]interface{}, 0) + res["out_trade_no"] = "" + if activity.RehearsalId == 0 { + res, err = pay_service.UnifiedOrder("欧轩互动-霸屏支付", user.Openid, int64(amount*100), 1, user.Id, activityId) + t.CheckErr(err) + } history := &models.BullyScreenHistory{ OutTradeNo: res["out_trade_no"].(string), @@ -73,6 +78,9 @@ func (t *BullyScreenCtl) PaScreen() { CreatedAt: time.Now(), UpdatedAt: time.Now(), } + if activity.RehearsalId != 0 { + history.Status = 0 + } _, err = core.GetXormAuto().InsertOne(history) t.CheckErr(err) t.JSON(res) diff --git a/controllers/client/order_entry.go b/controllers/client/order_entry.go index 286606a..bb6618c 100644 --- a/controllers/client/order_entry.go +++ b/controllers/client/order_entry.go @@ -217,11 +217,19 @@ type UserOrdersResult struct { // 用户查看订单列表 func (t *OrderEntryCtl) UserOrders() { uid := t.MustGetUID() + activityId := t.MustGetInt64("activity_id") + + activity := new(models.Activity) + exist, err := models.GetById(activity, activityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") orders := make([]UserOrdersResult, 0) 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"). - Desc("o.created_at").Where("o.buyer_id=? and o.is_delete=0", uid) + 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) if t.PageSize > 0 { s = s.Limit(t.PageSize, t.Page*t.PageSize) diff --git a/controllers/client/reward.go b/controllers/client/reward.go index f37bc90..a12cbc3 100644 --- a/controllers/client/reward.go +++ b/controllers/client/reward.go @@ -78,7 +78,7 @@ func (t *RewardCtl) Reward() { UpdatedAt: time.Now(), } - if _type == 1 || activity.RehearsalId != 0 { // 彩排或者直播不需要审核 + if activity.RehearsalId != 0 { // 彩排不需要支付 history.Status = 0 } @@ -93,15 +93,20 @@ func (t *RewardCtl) List() { uid := t.MustGetUID() activityId := t.MustGetInt64("activity_id") + activity := new(models.Activity) + exist, err := models.GetById(activity, activityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") + rs := new(models.RewardServer) - exist, err := rs.GetByActivityId(activityId) + exist, err = rs.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") - // todo: 检查订单 - t.CheckErr(bully_reward_service.CheckRewardStatus(rs.Id)) + ////// todo: 检查订单 + //t.CheckErr(bully_reward_service.CheckRewardStatus(rs.Id)) - list, err := bully_reward_service.GetRewardList(uid, rs.Id) + list, err := bully_reward_service.GetRewardList(uid, activity.RehearsalId, rs.Id) t.CheckErr(err) t.JSON(map[string]interface{}{ "total": len(list), diff --git a/controllers/client/shake_red_envelope.go b/controllers/client/shake_red_envelope.go index d4481e1..55aca5b 100644 --- a/controllers/client/shake_red_envelope.go +++ b/controllers/client/shake_red_envelope.go @@ -141,7 +141,14 @@ func (t *ShakeRedEnvelopeCtl) Shake() { // 用户红包 func (t *ShakeRedEnvelopeCtl) UserRedEnvelopes() { - records, err := models.GetRedEnvelopesByUserId(t.MustGetUID()) + uid := t.MustGetUID() + activityId := t.MustGetInt64("activity_id") + + activity := new(models.Activity) + exist, err := models.GetById(activity, activityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "活动不存在") + records, err := models.GetRedEnvelopesByUserId(uid, activityId, activity.RehearsalId) t.CheckErr(err) t.JSON(map[string]interface{}{ "list": records, diff --git a/controllers/client/upper_wall.go b/controllers/client/upper_wall.go index 8d2e206..7050243 100644 --- a/controllers/client/upper_wall.go +++ b/controllers/client/upper_wall.go @@ -75,8 +75,10 @@ func (t *UpperWallCtl) List() { t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") list := make([]*UWListResult, 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=?", uid, activityId, activity.RehearsalId). + 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=?", + uid, activityId, activity.RehearsalId). OrderBy("created_at desc").Find(&list) t.CheckErr(err) t.JSON(map[string]interface{}{ diff --git a/controllers/pc/reward.go b/controllers/pc/reward.go index 985ea12..e1e5bbe 100644 --- a/controllers/pc/reward.go +++ b/controllers/pc/reward.go @@ -59,8 +59,8 @@ func (t *RewardCtl) WaitReview() { t.CheckErr(err) t.Assert(exist, code.MSG_REWARD_NOT_EXIST, "打赏不存在") - // todo: 检查订单 - t.CheckErr(bully_reward_service.CheckRewardStatus(server.Id)) + //// todo: 检查订单 + //t.CheckErr(bully_reward_service.CheckRewardStatus(server.Id)) result, err := bully_reward_service.GetRewardReview(server.Id, rehearsalId) t.CheckErr(err) diff --git a/models/shake_red_envelope_record.go b/models/shake_red_envelope_record.go index 031e7a1..cf302ff 100644 --- a/models/shake_red_envelope_record.go +++ b/models/shake_red_envelope_record.go @@ -70,9 +70,10 @@ func (t *ShakeRedEnvelopeRecord) UpdateById(id int64, field ...string) (int64, e return core.GetXormAuto().Where("is_delete=0 and id=?", id).Cols(field...).Update(t) } -func GetRedEnvelopesByUserId(userId int64) ([]*ShakeRedEnvelopeRecord, error) { +func GetRedEnvelopesByUserId(userId, activityId, rehearsalId int64) ([]*ShakeRedEnvelopeRecord, error) { records := make([]*ShakeRedEnvelopeRecord, 0) - err := core.GetXormAuto().Where("user_id=? and is_delete=0 and is_draw<>-1", userId). + err := core.GetXormAuto().Where("user_id=? and rehearsal_id=? and activity_id=? and "+ + "is_delete=0 and is_draw<>-1", rehearsalId, activityId, userId). Desc("created_at").Find(&records) for index := range records { records[index].IsValid = true diff --git a/services/auction/auction.go b/services/auction/auction.go index 2eccd9c..465da61 100644 --- a/services/auction/auction.go +++ b/services/auction/auction.go @@ -92,12 +92,13 @@ type UserAuctionsResult struct { Unit int64 `json:"unit"` } -func GetUserAuctions(activityId, userId int64) ([]*UserAuctionsResult, error) { +func GetUserAuctions(activityId, rehearsalId, userId int64) ([]*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=?", activityId, userId). - Desc("r.created_at").Find(&records) + 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) return records, err } diff --git a/services/bully_reward/dao.go b/services/bully_reward/dao.go index 1cf4d40..afb5778 100644 --- a/services/bully_reward/dao.go +++ b/services/bully_reward/dao.go @@ -27,10 +27,12 @@ type RewardListResult struct { Status int `json:"status"` } -func GetRewardList(userId, rewardId int64) ([]*RewardListResult, error) { +func GetRewardList(userId, rehearsalId, rewardId int64) ([]*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 status <> -1", userId, rewardId). + 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) return list, err }