|
@@ -5,11 +5,14 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
|
"context"
|
|
|
"encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "github.com/araddon/dateparse"
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
v1 "personnelBehavior/api/personnel/v1"
|
|
|
"personnelBehavior/internal/model"
|
|
|
"personnelBehavior/internal/service"
|
|
|
"personnelBehavior/internal/utils"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -23,6 +26,13 @@ type personnel struct{}
|
|
|
// Statistics 统计信息保存
|
|
|
func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq) (res *utils.ResponseRes, err error) {
|
|
|
var in model.PersonnelInsertInput
|
|
|
+ g.Log().Info(model.Ctx, "-------", req.Date)
|
|
|
+ t, e := dateparse.ParseAny(strings.TrimSpace(req.Date))
|
|
|
+ if e == nil && t.Unix() > 946656000 {
|
|
|
+ in.Date = t
|
|
|
+ } else {
|
|
|
+ in.Date = time.Now()
|
|
|
+ }
|
|
|
res = &utils.ResponseRes{}
|
|
|
g.Log().Info(model.Ctx, "--Statistics--接收参数--", req, g.RequestFromCtx(ctx).Header)
|
|
|
in.ActionId = common.If(req.ActionId == "undefined", "", req.ActionId).(string)
|
|
@@ -54,7 +64,6 @@ func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq)
|
|
|
}
|
|
|
//匿名用户id
|
|
|
in.JYTrustedId = utils.GetTrustedId(g.RequestFromCtx(ctx))
|
|
|
- in.Date = time.Now().Unix()
|
|
|
//浏览器信息
|
|
|
r := g.RequestFromCtx(ctx).Request
|
|
|
in.Ip = common.GetIp(r)
|
|
@@ -91,6 +100,12 @@ func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq)
|
|
|
breakData, _ := json.Marshal(req.BreakData)
|
|
|
in.BreakData = string(breakData)
|
|
|
}
|
|
|
+ if req.BData != "" {
|
|
|
+ if in.BreakData != "" {
|
|
|
+ in.BreakData += ","
|
|
|
+ }
|
|
|
+ in.BreakData += fmt.Sprintf("action_name=%s", req.BData)
|
|
|
+ }
|
|
|
// 小程序的refer是从body里面取的
|
|
|
if in.Refer == "" && req.Refer != "" && req.Refer != "undefined" {
|
|
|
in.Refer = req.Refer
|
|
@@ -150,7 +165,16 @@ func (p *personnel) Behaviors(ctx context.Context, req *v1.PersonnelBehaviorReq)
|
|
|
}
|
|
|
//匿名用户id
|
|
|
in.JYTrustedId = utils.GetTrustedId(g.RequestFromCtx(ctx))
|
|
|
- in.Date = time.Now().Unix()
|
|
|
+ in.Date = time.Now()
|
|
|
+ if b.Date != "" {
|
|
|
+ dateInt64, e := strconv.ParseInt(b.Date, 10, 64)
|
|
|
+ if e == nil {
|
|
|
+ dateInt64 = dateInt64 / 1000 //毫秒转换成秒
|
|
|
+ if dateInt64 > 946656000 {
|
|
|
+ in.Date = time.Unix(dateInt64, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//浏览器信息
|
|
|
r := g.RequestFromCtx(ctx).Request
|
|
|
in.Ip = common.GetIp(r)
|