|
@@ -6,7 +6,7 @@ import (
|
|
"context"
|
|
"context"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
- v1 "personnelBehavior/api/hello/v1"
|
|
|
|
|
|
+ v1 "personnelBehavior/api/personnel/v1"
|
|
"personnelBehavior/internal/model"
|
|
"personnelBehavior/internal/model"
|
|
"personnelBehavior/internal/service"
|
|
"personnelBehavior/internal/service"
|
|
"personnelBehavior/internal/utils"
|
|
"personnelBehavior/internal/utils"
|
|
@@ -107,3 +107,98 @@ func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq)
|
|
g.RequestFromCtx(ctx).Response.WriteJson(res)
|
|
g.RequestFromCtx(ctx).Response.WriteJson(res)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// Behaviors 数组
|
|
|
|
+func (p *personnel) Behaviors(ctx context.Context, req *v1.PersonnelBehaviorReq) (res *utils.ResponseRes, err error) {
|
|
|
|
+ res = &utils.ResponseRes{}
|
|
|
|
+ bs := req.BS
|
|
|
|
+ g.Log().Info(ctx, bs)
|
|
|
|
+ if len(bs) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, b := range bs {
|
|
|
|
+ var in model.PersonnelInsertInput
|
|
|
|
+ var sessionGet *model.Context
|
|
|
|
+ g.Log().Info(model.Ctx, "--Statistics--接收参数--", b, g.RequestFromCtx(ctx).Header)
|
|
|
|
+ in.ActionId = common.If(b.ActionId == "undefined", "", b.ActionId).(string)
|
|
|
|
+ in.ActionType = common.If(b.ActionType == "undefined", "", b.ActionType).(string)
|
|
|
|
+ in.BreakerId = common.If(b.BreakerId == "undefined", "", b.BreakerId).(string)
|
|
|
|
+ in.BreakerName = common.If(b.BreakerName == "undefined", "", b.BreakerName).(string)
|
|
|
|
+ in.OrderId = common.If(b.OrderId == "undefined", "", b.OrderId).(string)
|
|
|
|
+ in.OrderTime = common.If(b.OrderTime == "undefined", "", b.OrderTime).(string)
|
|
|
|
+ in.PayTime = common.If(b.PayTime == "undefined", "", b.PayTime).(string)
|
|
|
|
+ in.PayWay = common.If(b.PayWay == "undefined", "", b.PayWay).(string)
|
|
|
|
+ in.Price = b.Price
|
|
|
|
+ in.Product = common.If(b.Product == "undefined", "", b.Product).(string)
|
|
|
|
+ in.ProductName = common.If(b.ProductName == "undefined", "", b.ProductName).(string)
|
|
|
|
+ in.PageId = common.If(b.PageId == "undefined", "", b.PageId).(string)
|
|
|
|
+ in.PageName = common.If(b.PageName == "undefined", "", b.PageName).(string)
|
|
|
|
+ in.Desc = common.If(b.Desc == "undefined", "", b.Desc).(string)
|
|
|
|
+ in.Source = common.If(b.Source == "undefined", "", b.Source).(string)
|
|
|
|
+ in.Url = common.If(b.Url == "undefined", "", b.Url).(string)
|
|
|
|
+ in.AppId = common.If(b.AppId == "undefined", "", b.AppId).(string)
|
|
|
|
+ in.AppVersion = common.If(b.AppVersion == "undefined", "", b.AppVersion).(string)
|
|
|
|
+ sessionGet, err = model.UserSessionCtx.Get(ctx)
|
|
|
|
+ if err == nil {
|
|
|
|
+ session := sessionGet.JySession
|
|
|
|
+ if session != nil && session.MgoUserId != "" {
|
|
|
|
+ in.UserId = session.MgoUserId
|
|
|
|
+ in.PositionId = session.PositionId
|
|
|
|
+ in.Phone = session.Phone
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //匿名用户id
|
|
|
|
+ in.JYTrustedId = utils.GetTrustedId(g.RequestFromCtx(ctx))
|
|
|
|
+ in.Date = time.Now().Unix()
|
|
|
|
+ //浏览器信息
|
|
|
|
+ r := g.RequestFromCtx(ctx).Request
|
|
|
|
+ in.Ip = common.GetIp(r)
|
|
|
|
+ if in.Url == "" {
|
|
|
|
+ in.Url = r.Referer()
|
|
|
|
+ }
|
|
|
|
+ if strings.Contains(in.Url, "article") || strings.Contains(in.Url, "nologin") {
|
|
|
|
+ in.BiddingId, in.Source = utils.GetDetailPageId(in.Url)
|
|
|
|
+ }
|
|
|
|
+ userAgent := utils.GetUserAgentInfo(r)
|
|
|
|
+ in.Browser = userAgent.BrowserName
|
|
|
|
+ in.BrowserVersion = userAgent.BrowserVersion
|
|
|
|
+ in.Os = userAgent.OsName
|
|
|
|
+ in.OsVersion = userAgent.OsVersion
|
|
|
|
+ in.Platform = userAgent.Platform
|
|
|
|
+ in.UserAgent = r.UserAgent()
|
|
|
|
+ in.ChainName = b.ChainName
|
|
|
|
+ //A24112 新增字段
|
|
|
|
+ in.Port = utils.GetUserPort(r) // 行为端口 wx,Android,ios,pc,h5
|
|
|
|
+ in.Refer = g.RequestFromCtx(ctx).GetHeader("pageReferrer") // 跳转前页面
|
|
|
|
+ if b.BreakData != nil && len(b.BreakData) > 0 {
|
|
|
|
+ // 处理page_name 和product_name
|
|
|
|
+ if pageName, ok := b.BreakData["page_name"]; ok && pageName != "" && pageName != "undefined" && in.PageName == "" {
|
|
|
|
+ in.PageName = common.InterfaceToStr(pageName)
|
|
|
|
+ }
|
|
|
|
+ if productName, ok := b.BreakData["product_name"]; ok && productName != "" && productName != "undefined" && in.ProductName == "" {
|
|
|
|
+ in.ProductName = common.InterfaceToStr(productName)
|
|
|
|
+ }
|
|
|
|
+ // 小程序 如果有id 存解密后的id
|
|
|
|
+ if bid, ok := b.BreakData["id"]; ok && bid != "" && bid != "undefined" && in.BiddingId == "" {
|
|
|
|
+ biddingId := encrypt.CommonDecodeArticle("content", common.InterfaceToStr(bid))[0]
|
|
|
|
+ in.BiddingId = common.InterfaceToStr(biddingId)
|
|
|
|
+ }
|
|
|
|
+ breakData, _ := json.Marshal(b.BreakData)
|
|
|
|
+ in.BreakData = string(breakData)
|
|
|
|
+ }
|
|
|
|
+ // 小程序的refer是从body里面取的
|
|
|
|
+ if in.Refer == "" && b.Refer != "" && b.Refer != "undefined" {
|
|
|
|
+ in.Refer = b.Refer
|
|
|
|
+ }
|
|
|
|
+ in.MiniProgramCode = g.RequestFromCtx(ctx).GetHeader("miniProgramCode")
|
|
|
|
+ in.SearchWord = b.SearchWord // 搜索词
|
|
|
|
+ in.Filter = b.Filter // 搜索条件
|
|
|
|
+ err = service.Personnel().BatchInsertRecords(ctx, &in)
|
|
|
|
+ if err != nil {
|
|
|
|
+ res.Msg = err.Error()
|
|
|
|
+ g.Log().Error(ctx, "数据传入异常:", err.Error())
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ res.Data = bs
|
|
|
|
+ return
|
|
|
|
+}
|