diff --git a/controllers/client/activity.go b/controllers/client/activity.go index 4453cfe..5c5445d 100644 --- a/controllers/client/activity.go +++ b/controllers/client/activity.go @@ -35,7 +35,7 @@ func (t *ActivityCtl) ModuleCurrent() { uid := t.MustGetUID() activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/client/auction.go b/controllers/client/auction.go index 2566e9f..a864dab 100644 --- a/controllers/client/auction.go +++ b/controllers/client/auction.go @@ -27,24 +27,24 @@ func (t *AuctionCtl) Auction() { } auction := new(models.NewAuctionActivity) - exist, err := models.GetById(auction, auctionId) + exist, err := models.Get(auction, auctionId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") t.CheckRunning(auction.Status) activity := new(models.Activity) - exist, err = models.GetById(activity, auction.ActivityId) + exist, err = models.Get(activity, auction.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) user := new(models.User) - exist, err = models.GetById(user, uid) + exist, err = models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") area := new(models.AreaStore) - exist, err = models.GetById(area, user.AreaId) + exist, err = models.Get(area, user.AreaId) t.CheckErr(err) t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") @@ -148,12 +148,12 @@ func (t *AuctionCtl) ExistRecord() { uid := t.MustGetUID() auction := new(models.NewAuctionActivity) - exist, err := models.GetById(auction, auctionId) + exist, err := models.Get(auction, auctionId) t.CheckErr(err) t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍活动不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, auction.ActivityId) + exist, err = models.Get(activity, auction.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -171,7 +171,7 @@ func (t *AuctionCtl) UserAuctions() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/client/barrage.go b/controllers/client/barrage.go index 611d634..716153e 100644 --- a/controllers/client/barrage.go +++ b/controllers/client/barrage.go @@ -31,13 +31,13 @@ func (t *BarrageCtl) Send() { //查询该活动的所属客户 activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") //查询当前的用户信息 user := new(models.User) - exist, err = models.GetById(user, uid) + exist, err = models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") @@ -52,7 +52,7 @@ func (t *BarrageCtl) Send() { t.CheckErr(err) customer := new(models.Customer) - exist, err = models.GetById(customer, customerId) + exist, err = models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") diff --git a/controllers/client/bully_screen.go b/controllers/client/bully_screen.go index 70f45d6..d3c8ae5 100644 --- a/controllers/client/bully_screen.go +++ b/controllers/client/bully_screen.go @@ -26,7 +26,7 @@ func (t *BullyScreenCtl) PaScreen() { style := t.MustGetInt("style") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -44,7 +44,7 @@ func (t *BullyScreenCtl) PaScreen() { //查询用户信息 user := new(models.User) - exist, err = models.GetById(user, uid) + exist, err = models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") diff --git a/controllers/client/calorie.go b/controllers/client/calorie.go index 4f9ba2a..e337b9e 100644 --- a/controllers/client/calorie.go +++ b/controllers/client/calorie.go @@ -19,12 +19,12 @@ func (t *CalorieCtl) Shake() { uid := t.MustGetUID() calorie := new(models.Calorie) - exist, err := models.GetById(calorie, calorieId) + exist, err := models.Get(calorie, calorieId) t.CheckErr(err) t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, calorie.ActivityId) + exist, err = models.Get(activity, calorie.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) diff --git a/controllers/client/good.go b/controllers/client/good.go index fc58957..f50f3c7 100644 --- a/controllers/client/good.go +++ b/controllers/client/good.go @@ -66,7 +66,7 @@ func (t *GoodCtl) ListOrder() { statusList := strings.Split(status, ",") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -125,17 +125,17 @@ func (t *GoodCtl) Order() { } activity := new(models.Activity) - exist, err := models.GetById(activity, param.ActivityId) + exist, err := models.Get(activity, param.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") area := new(models.AreaStore) - exist, err = models.GetById(area, param.AreaId) + exist, err = models.Get(area, param.AreaId) t.CheckErr(err) t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") user := new(models.User) - exist, err = models.GetById(user, userId) + exist, err = models.Get(user, userId) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") diff --git a/controllers/client/invite_envelope.go b/controllers/client/invite_envelope.go index 087d1ae..8c4b96b 100644 --- a/controllers/client/invite_envelope.go +++ b/controllers/client/invite_envelope.go @@ -19,7 +19,7 @@ func (t *InvitationLetterCtl) Invite() { answer := t.MustGet("answer") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -47,7 +47,7 @@ func (t *InvitationLetterCtl) Setting() { uid := t.MustGetUID() activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/client/live.go b/controllers/client/live.go index 11c38a3..90b5512 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -115,17 +115,17 @@ func (t *LiveCtl) SendLiveRedPack() { } activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") area := new(models.AreaStore) - exist, err = models.GetById(area, areaId) + exist, err = models.Get(area, areaId) t.CheckErr(err) t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") user := models.User{} - exist, err = models.GetById(&user, userId) + exist, err = models.Get(&user, userId) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") @@ -177,13 +177,13 @@ func (t *LiveCtl) GetLiveRedPack() { userId := t.MustGetUID() rule := new(models.LiveRedEnvelopeRule) - exist, err := models.GetById(rule, ruleId) + exist, err := models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_SHAKERB_RULE_NOT_EXIST, "红包规则不存在") t.Assert(rule.Status == 1, code.MSG_SHAKERB_RULE_NOT_EXIST, "红包规则尚未生效") user := models.User{} - exist, err = models.GetById(&user, userId) + exist, err = models.Get(&user, userId) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "不存在用户") diff --git a/controllers/client/login.go b/controllers/client/login.go index 02d53fd..b4c655d 100644 --- a/controllers/client/login.go +++ b/controllers/client/login.go @@ -34,17 +34,17 @@ func (t *UserCtl) EntryLogin() { t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在") area := new(models.AreaStore) - exist, err = models.GetById(area, entryPeople.AreaId) + exist, err = models.Get(area, entryPeople.AreaId) t.CheckErr(err) t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") customer := new(models.Customer) - exist, err = models.GetById(customer, entryPeople.Pid) + exist, err = models.Get(customer, entryPeople.Pid) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") @@ -69,7 +69,7 @@ func (t *UserCtl) WxLogin() { customerId := t.DefaultInt64("customer_id", activity.CustomerId) customer := new(models.Customer) - exist, err = models.GetById(customer, customerId) + exist, err = models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") @@ -187,12 +187,12 @@ func (t *UserCtl) DebugLogin() { activityId := t.DefaultInt64("activity_id", 5) user := new(models.User) - exist, err := models.GetById(user, uid) + exist, err := models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") customer := new(models.Customer) - exist, err = models.GetById(customer, customerId) + exist, err = models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") @@ -243,7 +243,7 @@ func (t *UserAuthCtl) SaveUserInfo() { _, err := user.SaveUserInfo(uid) t.CheckErr(err) // - //exist, err := models.GetById(&user, uid) + //exist, err := models.Get(&user, uid) //t.CheckErr(err) //t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") diff --git a/controllers/client/lottery.go b/controllers/client/lottery.go index 855f5f9..1712347 100644 --- a/controllers/client/lottery.go +++ b/controllers/client/lottery.go @@ -60,7 +60,7 @@ func (t *LotteryCtl) CheckLottery() { ladderId := t.MustGetInt64("lottery_draw_ladder_id") ladder := new(models.LotteryDrawRuleLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") @@ -89,12 +89,12 @@ func (t *LotteryCtl) Winners() { ladderId := t.MustGetInt64("lottery_draw_ladder_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") ladder := new(models.LotteryDrawRuleLadder) - exist, err = models.GetById(ladder, ladderId) + exist, err = models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") @@ -125,12 +125,12 @@ func (t *LotteryCtl) Users() { areaId := t.MustGetInt64("area_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") ladder := new(models.LotteryDrawRuleLadder) - exist, err = models.GetById(ladder, ladderId) + exist, err = models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") diff --git a/controllers/client/order_entry.go b/controllers/client/order_entry.go index bb6618c..b514f82 100644 --- a/controllers/client/order_entry.go +++ b/controllers/client/order_entry.go @@ -48,13 +48,13 @@ func (t *OrderEntryCtl) Order() { entryId := t.MustGetUID() activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) entryPerson := new(models.OrderEntryPerson) - exist, err = models.GetById(entryPerson, entryId) + exist, err = models.Get(entryPerson, entryId) t.CheckErr(err) t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在") @@ -64,7 +64,7 @@ func (t *OrderEntryCtl) Order() { t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") good := new(models.CustomerGoods) - exist, err = models.GetById(good, goodId) + exist, err = models.Get(good, goodId) t.CheckErr(err) t.Assert(exist, code.MSG_DATA_NOT_EXIST, "商品不存在") @@ -176,7 +176,7 @@ func (t *OrderEntryCtl) EntryOrders() { t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -220,7 +220,7 @@ func (t *OrderEntryCtl) UserOrders() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/client/reward.go b/controllers/client/reward.go index a12cbc3..e5cf7eb 100644 --- a/controllers/client/reward.go +++ b/controllers/client/reward.go @@ -37,7 +37,7 @@ func (t *RewardCtl) Reward() { } activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -51,7 +51,7 @@ func (t *RewardCtl) Reward() { //查询用户信息 user := new(models.User) - exist, err = models.GetById(user, uid) + exist, err = models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") @@ -94,7 +94,7 @@ func (t *RewardCtl) List() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/client/shake_red_envelope.go b/controllers/client/shake_red_envelope.go index 55aca5b..e836bbc 100644 --- a/controllers/client/shake_red_envelope.go +++ b/controllers/client/shake_red_envelope.go @@ -21,7 +21,7 @@ type ShakeRedEnvelopeCtl struct { func (t *ShakeRedEnvelopeCtl) Status() { ruleId := t.MustGetInt64("shake_red_envelope_rule_id") rule := new(models.ShakeRedEnvelopeRule) - exist, err := models.GetById(rule, ruleId) + exist, err := models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_SHAKERB_RECORD_NOT_EXIST, "摇红包规则不存在") t.JSON(map[string]interface{}{ @@ -37,7 +37,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() { // 查询摇红包规则 rule := new(models.ShakeRedEnvelopeRule) - exist, err := models.GetById(rule, ruleId) + exist, err := models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_SHAKERB_RULE_NOT_EXIST, "摇红包规则不存在") t.CheckRunning(rule.ShakeRedEnvelopeStatus) @@ -49,7 +49,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() { t.Assert(exist, code.MSG_SHAKERB_NOT_EXIST, "摇红包不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, envelope.ActivityId) + exist, err = models.Get(activity, envelope.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -76,7 +76,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() { // 查询用户 user := new(models.User) - exist, err = models.GetById(user, userId) + exist, err = models.Get(user, userId) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") @@ -145,7 +145,7 @@ func (t *ShakeRedEnvelopeCtl) UserRedEnvelopes() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + 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) diff --git a/controllers/client/sign.go b/controllers/client/sign.go index 42b283a..b32258c 100644 --- a/controllers/client/sign.go +++ b/controllers/client/sign.go @@ -38,12 +38,12 @@ func (t *SignCtl) CheckSign() { } activity := models.Activity{} - exist, err = models.GetById(&activity, activityId) + exist, err = models.Get(&activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "主活动不存在") customer := models.Customer{} - exist, err = models.GetById(&customer, activity.CustomerId) + exist, err = models.Get(&customer, activity.CustomerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") @@ -100,17 +100,17 @@ func (t *SignCtl) Sign() { //根据activity_id查找主活动的信息 activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") area := new(models.AreaStore) - exist, err = models.GetById(area, areaId) + exist, err = models.Get(area, areaId) t.CheckErr(err) t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") user := new(models.User) - exist, err = models.GetById(user, uid) + exist, err = models.Get(user, uid) logger.Error("user:===>%+v", user) logger.Error("token:==>%v", t.MustGet("token")) logger.Error("user_id:===>%v", uid) diff --git a/controllers/client/tug_war.go b/controllers/client/tug_war.go index 5a7f0c5..b5b5ce6 100644 --- a/controllers/client/tug_war.go +++ b/controllers/client/tug_war.go @@ -32,13 +32,13 @@ func (t *TugOfWarCtl) Status() { uid := t.MustGetUID() // 找到活动 bahe := new(models.TugOfWar) - exist, err := models.GetById(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.GetById(activity, bahe.ActivityId) + exist, err = models.Get(activity, bahe.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存") @@ -52,7 +52,7 @@ func (t *TugOfWarCtl) Status() { t.CheckErr(err) rank := 1 team := new(models.BaheTeam) - exist, err = models.GetById(team, member.TeamId) + exist, err = models.Get(team, member.TeamId) t.CheckErr(err) t.Assert(exist, code.MSG_TUGWAR_TEAM_NOT_EXIST, "队伍不存在") @@ -93,13 +93,13 @@ func (t *TugOfWarCtl) Shake() { score := t.MustGetInt64("score") // 增加的分数 bahe := new(models.TugOfWar) - exist, err := models.GetById(bahe, baheId) + exist, err := models.Get(bahe, baheId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河活动不存在") t.CheckRunning(bahe.Status) activity := new(models.Activity) - exist, err = models.GetById(activity, bahe.ActivityId) + exist, err = models.Get(activity, bahe.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -147,7 +147,7 @@ func (t *TugOfWarCtl) JoinTeam() { uid := t.MustGetUID() bahe := new(models.TugOfWar) - exist, err := models.GetById(bahe, baheActivityId) + exist, err := models.Get(bahe, baheActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_TUGWAR_TEAM_OVER_LIMIT, "拔河不存在") if bahe.Status == define.StatusEnding { @@ -155,7 +155,7 @@ func (t *TugOfWarCtl) JoinTeam() { } activity := new(models.Activity) - exist, err = models.GetById(activity, bahe.ActivityId) + exist, err = models.Get(activity, bahe.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -189,7 +189,7 @@ func (t *TugOfWarCtl) JoinTeam() { // done: 均等分配 + 人数限制 user := new(models.User) - exist, err = models.GetById(user, uid) + exist, err = models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") diff --git a/controllers/client/upper_wall.go b/controllers/client/upper_wall.go index 7050243..fe0f7f4 100644 --- a/controllers/client/upper_wall.go +++ b/controllers/client/upper_wall.go @@ -25,7 +25,7 @@ func (t *UpperWallCtl) Send() { //获取主活动信息 activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -39,7 +39,7 @@ func (t *UpperWallCtl) Send() { //获取用信息 user := new(models.User) - exist, err = models.GetById(user, uid) + exist, err = models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") @@ -71,7 +71,7 @@ func (t *UpperWallCtl) List() { uid := t.MustGetUID() activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") list := make([]*UWListResult, 0) diff --git a/controllers/client/vote.go b/controllers/client/vote.go index d3cebdc..68ce0fd 100644 --- a/controllers/client/vote.go +++ b/controllers/client/vote.go @@ -20,18 +20,18 @@ func (t *VoteCtl) Vote() { //检查是否可以投票 ladder := new(models.NewVoteActivityLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_VOTE_LADDER_NOT_EXIST, "投票人不存在") vote := new(models.NewVoteActivity) - exist, err = models.GetById(vote, ladder.VoteActivityId) + exist, err = models.Get(vote, ladder.VoteActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") t.CheckRunning(vote.VoteStatus) activity := new(models.Activity) - exist, err = models.GetById(activity, vote.ActivityId) + exist, err = models.Get(activity, vote.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -77,7 +77,7 @@ func (t *VoteCtl) List() { // 该活动是否进行中 activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -98,7 +98,7 @@ func (t *VoteCtl) Detail() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/common/im.go b/controllers/common/im.go index 4de1607..62b10f5 100644 --- a/controllers/common/im.go +++ b/controllers/common/im.go @@ -126,4 +126,5 @@ func (t *ImTestCtl) SendGood() { logger.Error("直播商品子订单信息发送异常异常", err) } } + t.SUCCESS("发送成功") } diff --git a/controllers/pc/activity.go b/controllers/pc/activity.go index 51e5725..ad2ccae 100644 --- a/controllers/pc/activity.go +++ b/controllers/pc/activity.go @@ -37,7 +37,7 @@ func (t *ActivityCtl) StartActivity() { limit := t.DefaultInt64("limit", 10) activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -84,7 +84,7 @@ func (t *ActivityCtl) StopActivity() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/pc/auction.go b/controllers/pc/auction.go index d6f3199..6170d9a 100644 --- a/controllers/pc/auction.go +++ b/controllers/pc/auction.go @@ -22,7 +22,7 @@ type AuctionCtl struct { func (t *AuctionCtl) ReadyAuction() { auctionId := t.MustGetInt64("auction_activity_id") auction := new(models.NewAuctionActivity) - exist, err := models.GetById(auction, auctionId) + exist, err := models.Get(auction, auctionId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") if auction.Status != define.StatusNotBegin { @@ -40,7 +40,7 @@ func (t *AuctionCtl) StartAuction() { auctionId := t.MustGetInt64("auction_activity_id") auction := new(models.NewAuctionActivity) - exist, err := models.GetById(auction, auctionId) + exist, err := models.Get(auction, auctionId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") //彩排 @@ -62,7 +62,7 @@ func (t *AuctionCtl) StopAuction() { auctionId := t.MustGetInt64("auction_activity_id") rehearsalId := t.MustGetInt64("rehearsal_id") auction := new(models.NewAuctionActivity) - exist, err := models.GetById(auction, auctionId) + exist, err := models.Get(auction, auctionId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "竞拍活动不存在") @@ -83,7 +83,7 @@ func (t *AuctionCtl) StopAuction() { t.CheckErr(err) user := new(models.User) - exist, err := models.GetById(user, history.UserId) + exist, err := models.Get(user, history.UserId) t.CheckErr(err) if exist { record := new(models.AuctionResultRecord) @@ -148,7 +148,7 @@ func (t *AuctionCtl) History() { rehearsalId := t.MustGetInt64("rehearsal_id") auction := new(models.NewAuctionActivity) - exist, err := models.GetById(auction, auctionId) + exist, err := models.Get(auction, auctionId) t.CheckErr(err) t.Assert(exist, code.MSG_AUCTION_NOT_EXIST, "竞拍不存在") diff --git a/controllers/pc/barrage.go b/controllers/pc/barrage.go index ba944e4..02318a4 100644 --- a/controllers/pc/barrage.go +++ b/controllers/pc/barrage.go @@ -28,7 +28,7 @@ func (t *BarrageCtl) SaveSetting() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/pc/bully_screen.go b/controllers/pc/bully_screen.go index d814125..5a3eee7 100644 --- a/controllers/pc/bully_screen.go +++ b/controllers/pc/bully_screen.go @@ -23,7 +23,7 @@ func (t *BullyScreenCtl) WaitReview() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -114,7 +114,7 @@ func (t *BullyScreenCtl) Blacklist() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -165,7 +165,7 @@ func (t *BullyScreenCtl) Latest() { activityId := t.MustGetInt64("activity_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") diff --git a/controllers/pc/calorie.go b/controllers/pc/calorie.go index 3e19542..59015f9 100644 --- a/controllers/pc/calorie.go +++ b/controllers/pc/calorie.go @@ -19,7 +19,7 @@ func (t *CalorieCtl) Ready() { calorieId := t.MustGetInt64("calorie_id") calorie := new(models.Calorie) - exist, err := models.GetById(calorie, calorieId) + exist, err := models.Get(calorie, calorieId) t.CheckErr(err) t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里活动不存在") if calorie.Status != define.StatusNotBegin { @@ -27,7 +27,7 @@ func (t *CalorieCtl) Ready() { } activity := new(models.Activity) - exist, err = models.GetById(activity, calorie.ActivityId) + exist, err = models.Get(activity, calorie.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -45,14 +45,14 @@ func (t *CalorieCtl) Start() { calorieId := t.MustGetInt64("calorie_id") calorie := new(models.Calorie) - exist, err := models.GetById(calorie, calorieId) + exist, err := models.Get(calorie, calorieId) t.CheckErr(err) t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里活动不存在") if calorie.Status != define.StatusReady { t.ERROR(fmt.Sprintf("该活动%s", calorie.Status), code.MSG_MODULE_STATUS_ERROR) } activity := new(models.Activity) - exist, err = models.GetById(activity, calorie.ActivityId) + exist, err = models.Get(activity, calorie.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -67,7 +67,7 @@ func (t *CalorieCtl) Stop() { calorieId := t.MustGetInt64("calorie_id") calorie := new(models.Calorie) - exist, err := models.GetById(calorie, calorieId) + exist, err := models.Get(calorie, calorieId) t.CheckErr(err) t.Assert(exist, code.MSG_CALORIE_NOT_EXIST, "卡路里活动不存在") if calorie.Status != define.StatusRunning { @@ -75,7 +75,7 @@ func (t *CalorieCtl) Stop() { } activity := new(models.Activity) - exist, err = models.GetById(activity, calorie.ActivityId) + exist, err = models.Get(activity, calorie.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -136,13 +136,13 @@ func (t *CalorieCtl) Count() { limit := t.DefaultInt("limit", 10) activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) calorie := new(models.Calorie) - exist, err = models.GetById(calorie, calorieId) + exist, err = models.Get(calorie, calorieId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "卡路里不存在") diff --git a/controllers/pc/login.go b/controllers/pc/login.go index 249a6ba..26275d5 100644 --- a/controllers/pc/login.go +++ b/controllers/pc/login.go @@ -64,7 +64,7 @@ func (t *UserCtl) Checkin() { func (t *UserCtl) DebugLogin() { customerId := t.DefaultInt64("customer_id", 1) customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) 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 62edffd..34c5275 100644 --- a/controllers/pc/lottery_draw.go +++ b/controllers/pc/lottery_draw.go @@ -25,7 +25,7 @@ func (t *LotteryDrawCtl) Start() { activityId := t.MustGetInt64("activity_id") ladder := new(models.LotteryDrawRuleLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") @@ -55,7 +55,7 @@ func (t *LotteryDrawCtl) StartRoll() { num := t.MustGetInt64("num") ladder := new(models.LotteryDrawRuleLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") @@ -79,7 +79,7 @@ func (t *LotteryDrawCtl) StopRoll() { num := t.MustGetInt64("num") ladder := new(models.LotteryDrawRuleLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") @@ -103,7 +103,7 @@ func (t *LotteryDrawCtl) Stop() { activityId := t.MustGetInt64("activity_id") ladder := new(models.LotteryDrawRuleLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") @@ -151,12 +151,12 @@ func (t *LotteryDrawCtl) List() { customerId := t.MustGetUID() customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -254,12 +254,12 @@ func (t *LotteryDrawCtl) Users() { customerId := t.MustGetUID() customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -309,12 +309,12 @@ func (t *LotteryDrawCtl) Lottery() { customerId := t.MustGetUID() customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -330,13 +330,13 @@ func (t *LotteryDrawCtl) Lottery() { t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在") rule := new(models.LotteryDrawRule) - exist, err = models.GetById(rule, ruleId) + exist, err = models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_DATA_NOT_EXIST, "抽奖规则不存在") // 查询奖品 ladder := new(models.LotteryDrawRuleLadder) - exist, err = models.GetById(ladder, ladderId) + exist, err = models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_DATA_NOT_EXIST, "抽奖等级不存在") t.CheckRunning(ladder.Status) diff --git a/controllers/pc/order_draw.go b/controllers/pc/order_draw.go index 1764317..8466ae2 100644 --- a/controllers/pc/order_draw.go +++ b/controllers/pc/order_draw.go @@ -25,7 +25,7 @@ func (t *OrderDrawCtl) Switch() { status := t.MustGetInt("status") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -52,7 +52,7 @@ func (t *OrderDrawCtl) Start() { ladderId := t.MustGetInt64("order_draw_ladder_id") ladder := new(models.OrderDrawRuleLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在") @@ -74,7 +74,7 @@ func (t *OrderDrawCtl) Stop() { ladderId := t.MustGetInt64("order_draw_ladder_id") ladder := new(models.OrderDrawRuleLadder) - exist, err := models.GetById(ladder, ladderId) + exist, err := models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在") @@ -114,12 +114,12 @@ func (t *OrderDrawCtl) List() { customerId := t.MustGetUID() customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -222,7 +222,7 @@ func (t *OrderDrawCtl) Users() { ruleId := t.MustGetInt64("order_draw_rule_id") activity := new(models.Activity) - exist, err := models.GetById(activity, activityId) + exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") @@ -262,12 +262,12 @@ func (t *OrderDrawCtl) Draw() { customerId := t.MustGetUID() customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -282,14 +282,14 @@ func (t *OrderDrawCtl) Draw() { t.Assert(exist, code.MSG_DATA_NOT_EXIST, "地区不存在") rule := new(models.OrderDrawRule) - exist, err = models.GetById(rule, ruleId) + exist, err = models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_ORDER_RULE_NOT_EXIST, "订单抽奖规则不存在") //t.CheckRunning(rule.OrderDrawStatus) // 查询奖品 ladder := new(models.OrderDrawRuleLadder) - exist, err = models.GetById(ladder, ladderId) + exist, err = models.Get(ladder, ladderId) t.CheckErr(err) t.Assert(exist, code.MSG_ORDER_LADDER_NOT_EXIST, "订单抽奖等级不存在") t.CheckRunning(ladder.Status) diff --git a/controllers/pc/reward.go b/controllers/pc/reward.go index e1e5bbe..a15da01 100644 --- a/controllers/pc/reward.go +++ b/controllers/pc/reward.go @@ -110,7 +110,7 @@ func (t *RewardCtl) Review() { t.CheckErr(err) user := new(models.User) - exist, err = models.GetById(user, v.UserId) + exist, err = models.Get(user, v.UserId) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") @@ -125,7 +125,7 @@ func (t *RewardCtl) Review() { uid := t.MustGetUID() customer := new(models.Customer) - exist, err = models.GetById(customer, uid) + exist, err = models.Get(customer, uid) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") diff --git a/controllers/pc/shake_red_envelope.go b/controllers/pc/shake_red_envelope.go index b0ea269..f32b8f0 100644 --- a/controllers/pc/shake_red_envelope.go +++ b/controllers/pc/shake_red_envelope.go @@ -21,19 +21,19 @@ func (t *ShakeRedEnvelopeCtl) Ready() { ruleId := t.MustGetInt64("shake_red_envelope_rule_id") rule := new(models.ShakeRedEnvelopeRule) - exist, err := models.GetById(rule, ruleId) + exist, err := models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "摇红包不存在") if rule.ShakeRedEnvelopeStatus != define.StatusNotBegin { t.ERROR(fmt.Sprintf("该活动%s", rule.ShakeRedEnvelopeStatus), code.MSG_ERR) } envelope := new(models.ShakeRedEnvelopeActivity) - exist, err = models.GetById(envelope, rule.ShakeRedEnvelopeActivityId) + exist, err = models.Get(envelope, rule.ShakeRedEnvelopeActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_SHAKERB_NOT_EXIST, "摇红包不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, envelope.ActivityId) + exist, err = models.Get(activity, envelope.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -60,7 +60,7 @@ func (t *ShakeRedEnvelopeCtl) Start() { //根据摇红包规则id查找该条记录并且更给状态 rule := new(models.ShakeRedEnvelopeRule) - exist, err := models.GetById(rule, ruleId) + exist, err := models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "摇红包不存在") @@ -70,7 +70,7 @@ func (t *ShakeRedEnvelopeCtl) Start() { t.Assert(exist, code.MSG_SHAKERB_NOT_EXIST, "摇红包不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, envelope.ActivityId) + exist, err = models.Get(activity, envelope.ActivityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -102,7 +102,7 @@ func (t *ShakeRedEnvelopeCtl) Stop() { uid := t.MustGetUID() rule := new(models.ShakeRedEnvelopeRule) - exist, err := models.GetById(rule, ruleId) + exist, err := models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") @@ -130,12 +130,12 @@ func (t *ShakeRedEnvelopeCtl) List() { customerId := t.MustGetUID() customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") activity := new(models.Activity) - exist, err = models.GetById(activity, activityId) + exist, err = models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status) @@ -244,7 +244,7 @@ func (t *ShakeRedEnvelopeCtl) Count() { rehearsalId := t.MustGetInt64("rehearsal_id") rule := new(models.ShakeRedEnvelopeRule) - exist, err := models.GetById(rule, ruleId) + exist, err := models.Get(rule, ruleId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "摇红包轮次不存在") diff --git a/controllers/pc/tug_war.go b/controllers/pc/tug_war.go index 88c054a..ddb38cf 100644 --- a/controllers/pc/tug_war.go +++ b/controllers/pc/tug_war.go @@ -20,7 +20,7 @@ func (t *TugOfWarCtl) Ready() { // 准备中 baheId := t.MustGetInt64("bahe_activity_id") bahe := new(models.TugOfWar) - exist, err := models.GetById(bahe, baheId) + exist, err := models.Get(bahe, baheId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") if bahe.Status != define.StatusNotBegin { @@ -70,7 +70,7 @@ func (t *TugOfWarCtl) Start() { baheId := t.MustGetInt64("bahe_activity_id") bahe := new(models.TugOfWar) - exist, err := models.GetById(bahe, baheId) + exist, err := models.Get(bahe, baheId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") if bahe.Status != define.StatusReady { @@ -86,7 +86,7 @@ func (t *TugOfWarCtl) Stop() { baheId := t.MustGetInt64("bahe_activity_id") bahe := new(models.TugOfWar) - exist, err := models.GetById(bahe, baheId) + exist, err := models.Get(bahe, baheId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河不存在") if bahe.Status != define.StatusRunning { @@ -111,7 +111,7 @@ func (t *TugOfWarCtl) Team() { t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区信息异常") bahe := new(models.TugOfWar) - exist, err = models.GetById(bahe, baheId) + exist, err = models.Get(bahe, baheId) t.CheckErr(err) t.Assert(exist, code.MSG_TUGWAR_NOT_EXIST, "拔河不存在") diff --git a/controllers/pc/upper_wall.go b/controllers/pc/upper_wall.go index 1be0951..ce6dbc7 100644 --- a/controllers/pc/upper_wall.go +++ b/controllers/pc/upper_wall.go @@ -68,7 +68,7 @@ func (t *UpperWallCtl) Review() { ids := strings.Split(idList, "|") customer := new(models.Customer) - exist, err := models.GetById(customer, uid) + exist, err := models.Get(customer, uid) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") diff --git a/controllers/pc/vote.go b/controllers/pc/vote.go index 653d487..b2d9cf3 100644 --- a/controllers/pc/vote.go +++ b/controllers/pc/vote.go @@ -46,7 +46,7 @@ func (t *VoteCtl) Qrcode() { func (t *VoteCtl) ReadyVote() { voteId := t.MustGetInt64("vote_activity_id") vote := new(models.NewVoteActivity) - exist, err := models.GetById(vote, voteId) + exist, err := models.Get(vote, voteId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") if vote.VoteStatus != define.StatusNotBegin { @@ -76,7 +76,7 @@ func (t *VoteCtl) ReadyVote() { func (t *VoteCtl) StartVote() { voteId := t.MustGetInt64("vote_activity_id") vote := new(models.NewVoteActivity) - exist, err := models.GetById(vote, voteId) + exist, err := models.Get(vote, voteId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") @@ -101,7 +101,7 @@ func (t *VoteCtl) StopVote() { voteId := t.MustGetInt64("vote_activity_id") vote := new(models.NewVoteActivity) - exist, err := models.GetById(vote, voteId) + exist, err := models.Get(vote, voteId) t.CheckErr(err) t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "投票活动不存在") diff --git a/controllers/pc/ws.go b/controllers/pc/ws.go index f815b40..70f0b2c 100644 --- a/controllers/pc/ws.go +++ b/controllers/pc/ws.go @@ -18,7 +18,7 @@ func (t *WsCtl) Ops() { customerId := t.MustGetUID() activityId, _ := t.GetInt64("activity_id") customer := new(models.Customer) - exist, err := models.GetById(customer, customerId) + exist, err := models.Get(customer, customerId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") diff --git a/models/base.go b/models/base.go index 39c6004..eb6df4c 100644 --- a/models/base.go +++ b/models/base.go @@ -2,12 +2,10 @@ package models import ( "fmt" - + "github.com/ouxuanserver/osmanthuswine/src/core" "github.com/xormplus/xorm" "reflect" "strings" - - "github.com/ouxuanserver/osmanthuswine/src/core" ) func Condition(condition map[string]interface{}) *xorm.Session { @@ -63,9 +61,18 @@ func AliasTableName(bean interface{}, alias string) string { return fmt.Sprintf("%s as %s", tn, alias) } -func GetById(bean interface{}, id int64) (bool, error) { +func Get(bean interface{}, id int64) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and id=?", id).Get(bean) } + func Add(bean interface{}) (int64, error) { return core.GetXormAuto().InsertOne(bean) } + +func Update(bean interface{}, field ...string) (int64, error) { + if len(field) > 0 { + return core.GetXormAuto().Cols(field...).Update(bean) + } else { + return core.GetXormAuto().Update(bean) + } +} diff --git a/models/customer_order.go b/models/customer_order.go index cb1ebac..9baa96f 100644 --- a/models/customer_order.go +++ b/models/customer_order.go @@ -30,6 +30,7 @@ type CustomerOrder struct { PayAmount float64 `json:"pay_amount" xorm:"not null default 0.00 comment('支付金额') DECIMAL(18)"` Postage float64 `json:"postage" xorm:"not null default 0.00 comment('邮费[0免邮]') DECIMAL(18)"` Status int `json:"status" xorm:"not null default 0 comment('订单状态[0未支付1已支付2待发货3已发货4确认收货5申请退款6已退款]')"` + // 快递信息 Receiver string `json:"receiver" xorm:"not null default '' comment('收件人') VARCHAR(128)"` Address string `json:"address" xorm:"not null default '' comment('收件人地址') VARCHAR(255)"` @@ -60,16 +61,13 @@ func (t *CustomerOrder) SoftDeleteById(id int64) (int64, error) { return core.GetXormAuto().Where("id=?", id).Cols("is_delete").Update(t) } -func (t *CustomerOrder) Add() (int64, error) { - return core.GetXormAuto().InsertOne(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) { - return core.GetXormAuto().Where("created_at >= ? and activity_id=? and rehearsal_id=? and is_delete=0", + 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) } diff --git a/services/activity/activity.go b/services/activity/activity.go index 74bf52d..3a40727 100644 --- a/services/activity/activity.go +++ b/services/activity/activity.go @@ -76,7 +76,7 @@ func GetActivitiesByCustomerId(cid int64) ([]*models.Activity, error) { func GetActivityById(id int64) (*models.Activity, bool, error) { activity := new(models.Activity) - exist, err := models.GetById(activity, id) + exist, err := models.Get(activity, id) if err != nil || !exist { return nil, exist, err } diff --git a/services/pay/handle.go b/services/pay/handle.go index 0ef1b61..6d7201d 100644 --- a/services/pay/handle.go +++ b/services/pay/handle.go @@ -7,6 +7,7 @@ import ( "hudongzhuanjia/logger" "hudongzhuanjia/models" im_service "hudongzhuanjia/services/im" + "hudongzhuanjia/utils/define" "time" ) @@ -17,10 +18,6 @@ func HandleSuccess(param *OrderDelayQueueParam) (err error) { var exist bool if param.Order.GoodType == 4 { // 直播商品 customerOrder := new(models.CustomerOrder) - if customerOrder.Status == 1 { - return errors.New("商品已经支付") - } - _, err := customerOrder.UpdateStatusBy(param.Order.OutTradeNo, 0, 1) if err != nil { return errors.New("更新状态发送错误") @@ -51,7 +48,7 @@ func HandleSuccess(param *OrderDelayQueueParam) (err error) { } activity := new(models.Activity) - exist, err = models.GetById(activity, param.Order.ActivityId) + exist, err = models.Get(activity, param.Order.ActivityId) if err != nil || !exist { return errors.New("互动信息异常") } @@ -61,6 +58,9 @@ func HandleSuccess(param *OrderDelayQueueParam) (err error) { if err != nil { return err } + if !exist || gift.OrderGiftSwitch == define.StatusClose { + return + } prize := new(models.UserPrize) prize.UserId = param.Order.UserId @@ -74,26 +74,32 @@ func HandleSuccess(param *OrderDelayQueueParam) (err error) { prize.Status = 1 prize.CreatedAt = time.Now() prize.UpdatedAt = time.Now() - if exist { - if gift.Num < 0 { - } else if gift.Num > 0 { - count, err := new(models.CustomerOrder). - Count(activity.Id, activity.RehearsalId, customerOrder.CreatedAt) - if err != nil { - err = fmt.Errorf("订单人数统计失败: err->%v, out_trade_no->%v", err, param.Order.OutTradeNo) - return err - } - - if gift.Num <= int(count) { // 人数足够 - return nil - } - } - // gift.Num = 0 and - _, err = prize.Add() + if gift.Num > 0 { + count, err := new(models.CustomerOrder). + Count(activity.Id, activity.RehearsalId, customerOrder.CreatedAt) if err != nil { - err = fmt.Errorf("奖品添加失败: err->%v, out_trade_no->%v", err, param.Order.OutTradeNo) + err = fmt.Errorf("订单人数统计失败: err->%v, out_trade_no->%v", err, param.Order.OutTradeNo) + logger.Error(err) return err } + + if gift.Num <= int(count) { // 人数足够 + return + } + } + _, err = prize.Add() + if err != nil { + err = fmt.Errorf("奖品添加失败: err->%v, out_trade_no->%v", err, param.Order.OutTradeNo) + logger.Error(err) + return err + } + + customerOrder.UserPrizeId = prize.Id + _, err = models.Update(customerOrder, "user_prize_id") + if err != nil { + err = fmt.Errorf("奖品记录添加失败: err-> %v, out_trade_no-> %v, prize_id->%v", err, param.Order.OutTradeNo, prize.Id) + logger.Error(err) + return err } } else if param.Order.GoodType == 3 { // 直播红包 info := new(models.LiveRedEnvelopeRule)