Browse Source

add rehearsal_id

master
黄梓健 5 years ago
parent
commit
4c0dd35205
  1. 7
      controllers/client/auction.go
  2. 12
      controllers/client/bully_screen.go
  3. 12
      controllers/client/order_entry.go
  4. 15
      controllers/client/reward.go
  5. 9
      controllers/client/shake_red_envelope.go
  6. 6
      controllers/client/upper_wall.go
  7. 4
      controllers/pc/reward.go
  8. 5
      models/shake_red_envelope_record.go
  9. 9
      services/auction/auction.go
  10. 8
      services/bully_reward/dao.go

7
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,

12
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)

12
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)

15
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),

9
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,

6
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{}{

4
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)

5
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

9
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
}

8
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
}

Loading…
Cancel
Save