From 525286110c9dd2ff1e8605515da8508e76f8cf13 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Mon, 18 May 2020 14:48:40 +0800 Subject: [PATCH] team --- controllers/pc/auction.go | 19 +++++++++++++++---- controllers/pc/calorie.go | 6 ++++++ controllers/pc/shake_red_envelope.go | 6 ++++++ controllers/pc/sign.go | 6 ++++++ controllers/pc/tug_war.go | 9 ++++++++- controllers/pc/upper_wall.go | 6 ++++++ controllers/pc/vote.go | 16 +++++++++++++--- models/area_store.go | 3 +++ models/shake_red_envelope_record.go | 2 +- 9 files changed, 64 insertions(+), 9 deletions(-) diff --git a/controllers/pc/auction.go b/controllers/pc/auction.go index 0ee3c06..d6f3199 100644 --- a/controllers/pc/auction.go +++ b/controllers/pc/auction.go @@ -231,11 +231,22 @@ func (t *AuctionCtl) Records() { //获取二维码 func (t *AuctionCtl) Qrcode() { //将服务器得地址和activity_id,动态生成二维码 + uid := t.MustGetUID() + activityId := t.MustGetInt64("activity_id") + auctionId := t.MustGetInt64("auction_activity_id") + rehearsalId := t.MustGetInt("rehearsal_id") + + area := new(models.AreaStore) + exist, err := area.GetByCustomerId(uid) + t.CheckErr(err) + t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") + qrcode, err := utils.GenH5Qrcode(define.H5Auction, map[string]interface{}{ - "activity_id": t.MustGetInt64("activity_id"), - "customer_id": t.MustGetUID(), - "auction_id": t.MustGetInt64("auction_activity_id"), - "rehearsal_id": t.MustGetInt64("rehearsal_id"), + "activity_id": activityId, + "area_id": area.Id, + "customer_id": uid, + "auction_id": auctionId, + "rehearsal_id": rehearsalId, }) t.CheckErr(err) t.JSON(map[string]interface{}{ diff --git a/controllers/pc/calorie.go b/controllers/pc/calorie.go index 990a11e..3e19542 100644 --- a/controllers/pc/calorie.go +++ b/controllers/pc/calorie.go @@ -102,9 +102,15 @@ func (t *CalorieCtl) Qrcode() { uid := t.MustGetUID() calorieId := t.MustGetInt64("calorie_id") + area := new(models.AreaStore) + exist, err := area.GetByCustomerId(uid) + t.CheckErr(err) + t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") + qrcode, err := utils.GenH5Qrcode(define.H5Calorie, map[string]interface{}{ "activity_id": activityId, "customer_id": uid, + "area_id": area.Id, "calorie_id": calorieId, }) t.CheckErr(err) diff --git a/controllers/pc/shake_red_envelope.go b/controllers/pc/shake_red_envelope.go index bb4915b..b0ea269 100644 --- a/controllers/pc/shake_red_envelope.go +++ b/controllers/pc/shake_red_envelope.go @@ -198,9 +198,15 @@ func (t *ShakeRedEnvelopeCtl) Qrcode() { rehearsalId := t.MustGetInt64("rehearsal_id") ruleId := t.MustGetInt64("shake_red_envelope_rule_id") + area := new(models.AreaStore) + exist, err := area.GetByCustomerId(customerId) + t.CheckErr(err) + t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") + //将服务器得地址和activity_id,动态生成二维码 qrcode, err := utils.GenH5Qrcode(define.H5ShakeRb, map[string]interface{}{ "activity_id": activityId, + "area_id": area.Id, "customer_id": customerId, "rule_id": ruleId, "rehearsal_id": rehearsalId, diff --git a/controllers/pc/sign.go b/controllers/pc/sign.go index ea15623..1782d22 100644 --- a/controllers/pc/sign.go +++ b/controllers/pc/sign.go @@ -22,9 +22,15 @@ func (t *SignCtl) Qrcode() { uid := t.MustGetUID() signUpId := t.MustGetInt64("sign_rule_id") + area := new(models.AreaStore) + exist, err := area.GetByCustomerId(uid) + t.CheckErr(err) + t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") + //将服务器得地址和activity_id,动态生成二维码 qrcode, err := utils.GenH5Qrcode(define.H5SignIn, map[string]interface{}{ "activity_id": activityId, + "area_id": area.Id, "customer_id": uid, "sign_rule_id": signUpId, }) diff --git a/controllers/pc/tug_war.go b/controllers/pc/tug_war.go index b584c45..88c054a 100644 --- a/controllers/pc/tug_war.go +++ b/controllers/pc/tug_war.go @@ -105,8 +105,13 @@ func (t *TugOfWarCtl) Team() { rehearsalId := t.MustGetInt64("rehearsal_id") customerId := t.MustGetUID() + area := new(models.AreaStore) + exist, err := area.GetByCustomerId(customerId) + t.CheckErr(err) + t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区信息异常") + bahe := new(models.TugOfWar) - exist, err := models.GetById(bahe, baheId) + exist, err = models.GetById(bahe, baheId) t.CheckErr(err) t.Assert(exist, code.MSG_TUGWAR_NOT_EXIST, "拔河不存在") @@ -122,6 +127,7 @@ func (t *TugOfWarCtl) Team() { // 非随机模式,自选队伍 for index := range teams { qrcode, err = utils.GenH5Qrcode(define.H5TugOfWar, map[string]interface{}{ + "area_id": area.Id, "activity_id": bahe.ActivityId, "customer_id": customerId, "bahe_activity_id": bahe.Id, @@ -133,6 +139,7 @@ func (t *TugOfWarCtl) Team() { } } else { qrcode, err = utils.GenH5Qrcode(define.H5TugOfWar, map[string]interface{}{ + "area_id": area.Id, "activity_id": bahe.ActivityId, "customer_id": customerId, "bahe_activity_id": bahe.Id, diff --git a/controllers/pc/upper_wall.go b/controllers/pc/upper_wall.go index c7a94e0..1be0951 100644 --- a/controllers/pc/upper_wall.go +++ b/controllers/pc/upper_wall.go @@ -155,8 +155,14 @@ func (t *UpperWallCtl) Qrcode() { rehearsalId := t.MustGetInt64("rehearsal_id") uid := t.MustGetUID() + area := new(models.AreaStore) + exist, err := area.GetByCustomerId(uid) + t.CheckErr(err) + t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") + qrcode, err := utils.GenH5Qrcode(define.H5Index, map[string]interface{}{ "activity_id": activityId, + "area_id": area.Id, "customer_id": uid, "rehearsal_id": rehearsalId, }) diff --git a/controllers/pc/vote.go b/controllers/pc/vote.go index 1fd4b24..653d487 100644 --- a/controllers/pc/vote.go +++ b/controllers/pc/vote.go @@ -19,10 +19,20 @@ type VoteCtl struct { //二维码 func (t *VoteCtl) Qrcode() { + activityId := t.MustGetInt64("activity_id") + voteActivityId := t.MustGetInt64("vote_activity_id") + uid := t.MustGetUID() + + area := new(models.AreaStore) + exist, err := area.GetByCustomerId(uid) + t.CheckErr(err) + t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") + qrcode, err := utils.GenH5Qrcode(define.H5Vote, map[string]interface{}{ - "activity_id": t.MustGetInt64("activity_id"), - "customer_id": t.MustGetUID(), - "vote_activity_id": t.MustGetInt64("vote_activity_id"), + "activity_id": activityId, + "area_id": area.Id, + "customer_id": uid, + "vote_activity_id": voteActivityId, }) t.CheckErr(err) diff --git a/models/area_store.go b/models/area_store.go index c7c4bff..19802bd 100644 --- a/models/area_store.go +++ b/models/area_store.go @@ -26,6 +26,9 @@ func (t *AreaStore) TableName() string { return AreaStoreTableName } +func (t *AreaStore) GetByCustomerId(customerId interface{}) (bool, error) { + return core.GetXormAuto().Where("is_delete=0 and customer_id=?", customerId).Get(t) +} func (t *AreaStore) GetAreaStoreById(id int64) (bool, error) { return core.GetXormAuto().Where("id=? and is_delete=0", id).Get(t) } diff --git a/models/shake_red_envelope_record.go b/models/shake_red_envelope_record.go index 0e88955..031e7a1 100644 --- a/models/shake_red_envelope_record.go +++ b/models/shake_red_envelope_record.go @@ -62,7 +62,7 @@ func (t *ShakeRedEnvelopeRecord) Count(aid, rid, said, srid int64, status int64) } func (t *ShakeRedEnvelopeRecord) GetByRuleId(ruleId, rehearsalId, _type interface{}) (bool, error) { - return core.GetXormAuto().Where("is_delete=0 and is_draw=-1 and red_envelope_type = ? "+ + return core.GetXormAuto().Where("is_delete=0 and is_draw=-1 and red_envelope_type = ? and "+ "shake_red_envelope_rule_id=? and rehearsal_id=?", _type, ruleId, rehearsalId).Get(t) }