diff --git a/controllers/author.go b/controllers/author.go index 83fabc6..ec40a64 100644 --- a/controllers/author.go +++ b/controllers/author.go @@ -15,11 +15,11 @@ type AuthorCtl struct { func (t *AuthorCtl) Prepare() { t.BaseCtl.Prepare() - skip, _ := t.GetInt("skip") - if skip == 1 { + skip, _ := t.GetInt64("skip") + if skip != 0 { t.claims = &jwt.Claims{ AccountType: "customer", - AccountId: 1, + AccountId: skip, CustomerId: 1, CustomerPid: 0, ActivityId: 1, diff --git a/controllers/client/upper_wall.go b/controllers/client/upper_wall.go index fe7e291..f70dda9 100644 --- a/controllers/client/upper_wall.go +++ b/controllers/client/upper_wall.go @@ -4,6 +4,7 @@ import ( "fmt" "hudongzhuanjia/controllers" "hudongzhuanjia/models" + "hudongzhuanjia/services/upper_wall" "hudongzhuanjia/utils/code" "time" ) @@ -56,14 +57,6 @@ func (t *UpperWallCtl) Send() { t.SUCCESS("成功") } -type UpperWallResult struct { - Id int64 `json:"id"` - Content string `json:"content"` - Img string `json:"img"` - Category string `json:"category"` - Status int `json:"status"` -} - func (t *UpperWallCtl) List() { activityId := t.MustGetInt64("activity_id") userId := t.MustGetUID() @@ -73,8 +66,7 @@ func (t *UpperWallCtl) List() { t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") - list := make([]*UpperWallResult, 0) - err = models.GetUpperWallResultByUserIdAndActivityId(list, userId, activity.Id, activity.RehearsalId) + list, err := upper_wall.GetUpperWallResult(userId, activity.Id, activity.RehearsalId) t.CheckErr(err) t.JSON(map[string]interface{}{ "list": list, diff --git a/controllers/pc/auction.go b/controllers/pc/auction.go index 1375d6c..2d2433d 100644 --- a/controllers/pc/auction.go +++ b/controllers/pc/auction.go @@ -239,7 +239,7 @@ func (t *AuctionCtl) Qrcode() { rehearsalId := t.MustGetInt("rehearsal_id") area := new(models.AreaStore) - exist, err := area.GetByCustomerId(uid) + exist, err := area.GetByCustomerId(uid, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") diff --git a/controllers/pc/calorie.go b/controllers/pc/calorie.go index 6d7f90b..d589a8b 100644 --- a/controllers/pc/calorie.go +++ b/controllers/pc/calorie.go @@ -102,7 +102,7 @@ func (t *CalorieCtl) Qrcode() { calorieId := t.MustGetInt64("calorie_id") area := new(models.AreaStore) - exist, err := area.GetByCustomerId(uid) + exist, err := area.GetByCustomerId(uid, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") diff --git a/controllers/pc/lottery_draw.go b/controllers/pc/lottery_draw.go index 61cdcd8..d0bccf6 100644 --- a/controllers/pc/lottery_draw.go +++ b/controllers/pc/lottery_draw.go @@ -186,7 +186,7 @@ func (t *LotteryDrawCtl) Users() { t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") area := new(models.AreaStore) - exist, err = area.GetByCustomerId(customerId) + exist, err = area.GetByCustomerId(customerId, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") @@ -229,7 +229,7 @@ func (t *LotteryDrawCtl) Lottery() { // 多地区设置 area := new(models.AreaStore) - exist, err = area.GetByCustomerId(customerId) + exist, err = area.GetByCustomerId(customerId, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在") diff --git a/controllers/pc/order_draw.go b/controllers/pc/order_draw.go index 546a747..cf54da6 100644 --- a/controllers/pc/order_draw.go +++ b/controllers/pc/order_draw.go @@ -272,7 +272,7 @@ func (t *OrderDrawCtl) Draw() { t.CheckRunning(activity.Status) area := new(models.AreaStore) - exist, err = area.GetByCustomerId(customerId) + exist, err = area.GetByCustomerId(customerId, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在") diff --git a/controllers/pc/reward.go b/controllers/pc/reward.go index 61be1fa..df1c58b 100644 --- a/controllers/pc/reward.go +++ b/controllers/pc/reward.go @@ -74,14 +74,8 @@ func (t *RewardCtl) WaitReview() { func (t *RewardCtl) Review() { status := t.MustGetBool("status") ids := strings.Split(t.MustGet("ids"), "|") - activityId := t.MustGetInt64("activity") uid := t.MustGetUID() - activity := new(models.Activity) - exist, err := models.Get(activity, activityId) - t.CheckErr(err) - t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") - result, err := models.GetRewardHistoryByIds(ids) t.CheckErr(err) @@ -105,7 +99,7 @@ func (t *RewardCtl) Review() { _, err = models.Update(v.Id, v, "status") t.CheckErr(err) - if activity.RehearsalId != 0 && v.Type == 0 { // 线下h5彩排不需要金额 + if v.RehearsalId != 0 && v.Type == 0 { // 线下h5彩排不需要金额 continue } diff --git a/controllers/pc/shake_red_envelope.go b/controllers/pc/shake_red_envelope.go index f32b8f0..7543b51 100644 --- a/controllers/pc/shake_red_envelope.go +++ b/controllers/pc/shake_red_envelope.go @@ -199,7 +199,7 @@ func (t *ShakeRedEnvelopeCtl) Qrcode() { ruleId := t.MustGetInt64("shake_red_envelope_rule_id") area := new(models.AreaStore) - exist, err := area.GetByCustomerId(customerId) + exist, err := area.GetByCustomerId(customerId, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") diff --git a/controllers/pc/sign.go b/controllers/pc/sign.go index 1782d22..69d2c45 100644 --- a/controllers/pc/sign.go +++ b/controllers/pc/sign.go @@ -23,7 +23,7 @@ func (t *SignCtl) Qrcode() { signUpId := t.MustGetInt64("sign_rule_id") area := new(models.AreaStore) - exist, err := area.GetByCustomerId(uid) + exist, err := area.GetByCustomerId(uid, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") diff --git a/controllers/pc/tug_war.go b/controllers/pc/tug_war.go index 5280f0e..a252e6c 100644 --- a/controllers/pc/tug_war.go +++ b/controllers/pc/tug_war.go @@ -102,19 +102,23 @@ func (t *TugOfWarCtl) Stop() { func (t *TugOfWarCtl) Team() { baheId := t.MustGetInt64("bahe_activity_id") - 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.Get(bahe, baheId) + 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, "互动不存在") + + area := new(models.AreaStore) + exist, err = area.GetByCustomerId(customerId, bahe.ActivityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区信息异常") + //获取队伍信息: 名字、二维码、颜色 teams := make([]*models.BaheTeam, 0) total, err := core.GetXormAuto().Where("is_delete=0 and bahe_activity_id=?", bahe.Id).FindAndCount(&teams) @@ -132,7 +136,7 @@ func (t *TugOfWarCtl) Team() { "customer_id": customerId, "bahe_activity_id": bahe.Id, "bahe_team_id": teams[index].Id, - "rehearsal_id": rehearsalId, + "rehearsal_id": activity.RehearsalId, }) t.CheckErr(err) teams[index].Qrcode = qrcode @@ -144,7 +148,7 @@ func (t *TugOfWarCtl) Team() { "customer_id": customerId, "bahe_activity_id": bahe.Id, "bahe_team_id": 0, - "rehearsal_id": rehearsalId, + "rehearsal_id": activity.RehearsalId, }) t.CheckErr(err) } diff --git a/controllers/pc/upper_wall.go b/controllers/pc/upper_wall.go index 9117485..ec304fc 100644 --- a/controllers/pc/upper_wall.go +++ b/controllers/pc/upper_wall.go @@ -152,19 +152,23 @@ func (t *UpperWallCtl) Total() { // 跳到主页 func (t *UpperWallCtl) Qrcode() { activityId := t.MustGetInt64("activity_id") - rehearsalId := t.MustGetInt64("rehearsal_id") uid := t.MustGetUID() + activity := new(models.Activity) + exist, err := models.Get(activity, activityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动信息异常") + area := new(models.AreaStore) - exist, err := area.GetByCustomerId(uid) + exist, err = area.GetByCustomerId(uid, activityId) t.CheckErr(err) - t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") + 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, + "rehearsal_id": activity.RehearsalId, }) t.CheckErr(err) diff --git a/controllers/pc/vote.go b/controllers/pc/vote.go index 14f6ea4..7e2689e 100644 --- a/controllers/pc/vote.go +++ b/controllers/pc/vote.go @@ -24,7 +24,7 @@ func (t *VoteCtl) Qrcode() { uid := t.MustGetUID() area := new(models.AreaStore) - exist, err := area.GetByCustomerId(uid) + exist, err := area.GetByCustomerId(uid, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常") diff --git a/log/hdzj.log b/log/hdzj.log index da5a458..a6ed321 100644 --- a/log/hdzj.log +++ b/log/hdzj.log @@ -100,3 +100,6 @@ 2020-05-22 15:06:18.656 ERROR logger/logger.go:87 微信响应次数: 1 2020-05-22 15:08:27.956 ERROR logger/logger.go:87 微信响应次数: 1 2020-05-22 15:08:56.782 ERROR logger/logger.go:87 微信响应次数: 2 +2020-05-22 16:08:14.919 ERROR logger/logger.go:87 获取过期打赏错误原因Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +2020-05-22 16:08:14.920 ERROR logger/logger.go:87 定时任务错误原因Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +2020-05-22 16:35:51.409 ERROR logger/logger.go:87 check err{error 25 0 sql: expected 3 arguments, got 2} diff --git a/models/area_store.go b/models/area_store.go index 19802bd..cf8b3d0 100644 --- a/models/area_store.go +++ b/models/area_store.go @@ -26,8 +26,8 @@ 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) GetByCustomerId(customerId, activityId interface{}) (bool, error) { + return core.GetXormAuto().Where("is_delete=0 and customer_id=? and activity_id=?", customerId, activityId).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/upper_wall.go b/models/upper_wall.go index e35367e..2820ebb 100644 --- a/models/upper_wall.go +++ b/models/upper_wall.go @@ -1,7 +1,6 @@ package models import ( - "github.com/ouxuanserver/osmanthuswine/src/core" "time" ) @@ -22,11 +21,3 @@ type UpperWall struct { CreatedAt time.Time `json:"created_at" xorm:"created" description:"创建时间"` UpdatedAt time.Time `json:"updated_at" xorm:"updated" description:"更新时间"` } - -func GetUpperWallResultByUserIdAndActivityId(obj, userId, activityId, rehearsalId interface{}) error { - return core.GetXormAuto().Table(new(UpperWall)). - Select("id, content, img, category, status"). - Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=?", - userId, activityId, rehearsalId). - OrderBy("created_at desc").Find(&obj) -} diff --git a/services/activity/module.go b/services/activity/module.go index 4df58be..6153696 100644 --- a/services/activity/module.go +++ b/services/activity/module.go @@ -27,7 +27,7 @@ func GetModuleService(moduleName, activityId interface{}) (*models.ActivityModul module := new(models.ActivityModuleService) exist, err := core.GetXormAuto().Table(module).Alias("s"). Join("LEFT", new(models.ModuleServiceHistory).Alias("h"), - "s.service_module_history_id=h.id and h.name=?"). + "s.service_module_history_id=h.id"). Where("s.activity_id=? and s.is_delete=0 and h.name=?", activityId, moduleName). Get(module) return module, exist, err diff --git a/services/lottery/lottery.go b/services/lottery/lottery.go index 910a40b..a9ad480 100644 --- a/services/lottery/lottery.go +++ b/services/lottery/lottery.go @@ -20,7 +20,8 @@ type LotteryUser struct { func GetLotteryUsers(ids []int64) ([]*LotteryUser, error) { users := make([]*LotteryUser, 0) - err := core.GetXormAuto().Select("id as user_id, nickname as username, avatar, phone"). + err := core.GetXormAuto().Table(new(models.User)). + Select("id as user_id, nickname as username, avatar, phone"). In("id", ids).Find(&users) return users, err } @@ -56,7 +57,7 @@ func GetLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehearsalId, } err = core.GetXormAuto().Table(new(models.SignHistory)).Select("user_id"). Where("is_delete=0 and rehearsal_id=? and area_id=? and activity_id=?", - activityId, rehearsalId, areaId).NotIn("user_id", recordIds).Find(&userIds) + rehearsalId, areaId, activityId).NotIn("user_id", recordIds).Find(&userIds) return userIds, nil } diff --git a/services/upper_wall/upper_wall.go b/services/upper_wall/upper_wall.go new file mode 100644 index 0000000..9e0f47d --- /dev/null +++ b/services/upper_wall/upper_wall.go @@ -0,0 +1,24 @@ +package upper_wall + +import ( + "github.com/ouxuanserver/osmanthuswine/src/core" + "hudongzhuanjia/models" +) + +type UpperWallResult struct { + Id int64 `json:"id"` + Content string `json:"content"` + Img string `json:"img"` + Category string `json:"category"` + Status int `json:"status"` +} + +func GetUpperWallResult(userId, activityId, rehearsalId 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). + OrderBy("created_at desc").Find(&result) + return result, err +}