wangkaiyue 3 роки тому
батько
коміт
bfad370ebc

+ 1 - 1
handler/award/subvip.go

@@ -23,7 +23,7 @@ func GivenSubVip(userId string, subVip SubVip) (err error) {
 	if err == nil {
 		AddAwardRecord(AwardRecord{
 			UserId:       userId,
-			Award:        AwardPoints,
+			Award:        AwardSubVip,
 			Num:          gconv.Int(subVip.Num),
 			GetWay:       subVip.Desc,
 			ActivityCode: subVip.ActivityCode,

+ 29 - 19
services/activity/award/service.go

@@ -1,10 +1,13 @@
 package award
 
 import (
+	. "app.yhyue.com/moapp/jybase/api"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"app.yhyue.com/moapp/message/handler/award"
-	"github.com/gogf/gf/v2/frame/g"
+	"encoding/json"
+	"fmt"
 	"github.com/gogf/gf/v2/util/gconv"
+	"log"
 )
 
 type AwardRouter struct {
@@ -13,23 +16,30 @@ type AwardRouter struct {
 }
 
 func (a *AwardRouter) Awardlist() {
-	rdata := map[string]interface{}{}
-	code := a.GetString("code") //inviteRegister:邀请注册 freePlan:投标人专属免费计划
-	userid := gconv.String(a.GetSession("userId"))
-	aw := a.GetString("award")
-	pSize := gconv.Int(a.GetString("pageSize"))
-	pNum := gconv.Int(a.GetString("pageNum"))
-	if pSize == 0 && pNum == 0 {
-		pSize = -1
-		pNum = 1
+	userId := gconv.String(a.GetSession("userId"))
+	rData, errMsg := func() (map[string]interface{}, error) {
+		reqParam := map[string]interface{}{}
+		if err := json.Unmarshal(a.Body(), &reqParam); err != nil || len(reqParam) == 0 {
+			return nil, fmt.Errorf("请求参数异常")
+		}
+		code := gconv.String(reqParam["code"]) //inviteRegister:邀请注册 freePlan:投标人专属免费计划
+		aw := gconv.String(reqParam["award"])
+
+		pSize := gconv.Int(reqParam["pageSize"])
+		pNum := gconv.Int(reqParam["pageNum"])
+		if pSize == 0 && pNum == 0 {
+			pSize = -1
+			pNum = 1
+		}
+		data, total, hasNext := award.GetActivityAwardList(userId, code, aw, pSize, pNum)
+		return map[string]interface{}{
+			"list":    data,
+			"total":   total,
+			"hasNext": hasNext,
+		}, nil
+	}()
+	if errMsg != nil {
+		log.Printf("AwardRouter Awardlist  %s error:%s\n", userId, errMsg.Error())
 	}
-	data, total, hasNext := award.GetActivityAwardList(userid, code, aw, pSize, pNum)
-	rdata["list"] = data
-	rdata["total"] = total
-	rdata["hasNext"] = hasNext
-	a.ServeJson(g.Map{
-		"error_code": 0,
-		"error_msg":  "",
-		"data":       rdata,
-	})
+	a.ServeJson(NewResult(rData, errMsg))
 }

+ 8 - 3
services/activity/bidderPlan/services.go

@@ -4,6 +4,7 @@ import (
 	. "app.yhyue.com/moapp/jybase/api"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"app.yhyue.com/moapp/message/handler/activity"
+	"encoding/json"
 	"fmt"
 	"github.com/gogf/gf/v2/util/gconv"
 	"log"
@@ -67,11 +68,15 @@ func (act *Activity) Receive() {
 		if !activity.JyBidderPlan.FastClickCheck(userId) {
 			return false, fmt.Errorf("操作频繁")
 		}
+		reqParam := map[string]interface{}{}
+		if err := json.Unmarshal(act.Body(), &reqParam); err != nil || len(reqParam) == 0 {
+			return false, fmt.Errorf("请求参数异常")
+		}
 		//校验是否达标
-		t := act.GetString("type")
+		t := gconv.String(reqParam["type"])
 		var err error
 		if t == "mission" { //任务奖励
-			switch act.GetString("value") {
+			switch gconv.String(reqParam["value"]) {
 			case "subscribe":
 				err = activity.JyBidderPlan.MissionsSubscribeGiven(userId)
 			case "invite":
@@ -82,7 +87,7 @@ func (act *Activity) Receive() {
 				return false, fmt.Errorf("未知请求")
 			}
 		} else { //活动进度额外奖励
-			err = activity.JyBidderPlan.ScheduleGiven(userId, gconv.Int(act.GetString("value")))
+			err = activity.JyBidderPlan.ScheduleGiven(userId, gconv.Int(reqParam["value"]))
 		}
 		if err != nil {
 			return false, err