Procházet zdrojové kódy

Merge branch 'dev/1.0.2_fu' of jianyu/personnelBehavior into feature/v1.0.2

fuwencai před 1 rokem
rodič
revize
8cb9cfc2c9

+ 1 - 1
api/hello/v1/personnel.go

@@ -23,7 +23,7 @@ type PersonnelInsertReq struct {
 	Url             string                 `json:"url" dc:"地址"`
 	ChainName       string                 `json:"chain_name" v:"required"  dc:"公链名称"`
 	Port            string                 `json:"port" `
-	Refer           string                 `json:"refer" dc:"跳转前页面"`
+	Refer           string                 `json:"pageRefer" dc:"跳转前页面"`
 	SearchWord      string                 `json:"search_word"  dc:"搜索词" `
 	Filter          string                 `json:"filter"  dc:"搜索条件"`
 	BreakData       map[string]interface{} `json:"breakData"  dc:"额外数据"`

+ 21 - 12
internal/controller/personnel/personnel.go

@@ -2,6 +2,7 @@ package personnel
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"context"
 	"encoding/json"
 	"github.com/gogf/gf/v2/frame/g"
@@ -40,19 +41,7 @@ func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq)
 	in.Source = common.If(req.Source == "undefined", "", req.Source).(string)
 	in.Url = common.If(req.Url == "undefined", "", req.Url).(string)
 	in.AppId = common.If(req.AppId == "undefined", "", req.AppId).(string)
-	if req.BreakData != nil && len(req.BreakData) > 0 {
-		// 处理page_name 和product_name
-		if pageName, ok := req.BreakData["page_name"]; ok && pageName != "" && pageName != "undefined" && in.PageName == "" {
-			in.PageName = common.InterfaceToStr(pageName)
-		}
-		if productName, ok := req.BreakData["product_name"]; ok && productName != "" && productName != "undefined" && in.ProductName == "" {
-			in.ProductName = common.InterfaceToStr(productName)
-		}
-		breakData, _ := json.Marshal(req.BreakData)
-		in.BreakData = string(breakData)
-	}
 	in.AppVersion = common.If(req.AppVersion == "undefined", "", req.AppVersion).(string)
-
 	sessionGet, err := model.UserSessionCtx.Get(ctx)
 	if err == nil {
 		session := sessionGet.JySession
@@ -85,6 +74,26 @@ func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq)
 	//A24112  新增字段
 	in.Port = utils.GetUserPort(r)                             // 行为端口 wx,Android,ios,pc,h5
 	in.Refer = g.RequestFromCtx(ctx).GetHeader("pageReferrer") // 跳转前页面
+	if req.BreakData != nil && len(req.BreakData) > 0 {
+		// 处理page_name 和product_name
+		if pageName, ok := req.BreakData["page_name"]; ok && pageName != "" && pageName != "undefined" && in.PageName == "" {
+			in.PageName = common.InterfaceToStr(pageName)
+		}
+		if productName, ok := req.BreakData["product_name"]; ok && productName != "" && productName != "undefined" && in.ProductName == "" {
+			in.ProductName = common.InterfaceToStr(productName)
+		}
+		// 小程序 如果有id 存解密后的id
+		if bid, ok := req.BreakData["id"]; ok && bid != "" && bid != "undefined" && in.BiddingId == "" {
+			biddingId := encrypt.CommonDecodeArticle("content", common.InterfaceToStr(bid))[0]
+			in.BiddingId = common.InterfaceToStr(biddingId)
+		}
+		breakData, _ := json.Marshal(req.BreakData)
+		in.BreakData = string(breakData)
+	}
+	// 小程序的refer是从body里面取的
+	if in.Refer == "" && req.Refer != "" && req.Refer != "undefined" {
+		in.Refer = req.Refer
+	}
 	in.MiniProgramCode = g.RequestFromCtx(ctx).GetHeader("miniProgramCode")
 	in.SearchWord = req.SearchWord // 搜索词
 	in.Filter = req.Filter         // 搜索条件