xingzai 1 gadu atpakaļ
vecāks
revīzija
4eee3123a9

+ 23 - 0
controllers/config.go

@@ -215,3 +215,26 @@ func (this *ConfigController) KeyWordLog() {
 	br.Success = true
 	br.Msg = "新增成功"
 }
+
+// @Title 关于我们浏览记录
+// @Description 关于我们浏览记录接口
+// @Success 200
+// @router /aboutUs/addHistory [post]
+func (this *ConfigController) AboutUsAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	go services.AddCygxAboutUsVideoHistory(user)
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功!"
+}

+ 28 - 0
models/about_us_video_history.go

@@ -0,0 +1,28 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxAboutUsVideoHistory struct {
+	Id               int `orm:"column(id);pk"`
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+// 添加历史信息
+func AddCygxAboutUsVideoHistory(item *CygxAboutUsVideoHistory) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 1 - 0
models/db.go

@@ -140,6 +140,7 @@ func init() {
 		new(CygxArticleCategoryMapping),
 		new(CygxReportMappingCygx),
 		new(CygxReportMappingGroup),
+		new(CygxAboutUsVideoHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 9 - 0
routers/commentsRouter.go

@@ -574,6 +574,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ConfigController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ConfigController"],
+        beego.ControllerComments{
+            Method: "AboutUsAdd",
+            Router: `/aboutUs/addHistory`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ConfigController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ConfigController"],
         beego.ControllerComments{
             Method: "DescriptionOfResearch",

+ 29 - 0
services/config.go

@@ -4,7 +4,9 @@ import (
 	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
 	"strconv"
+	"time"
 )
 
 // 是否展示限免标签
@@ -79,3 +81,30 @@ func init1231() {
 		go models.AddCygxActivitySpecialTripBill(itemBill)
 	}
 }
+
+// 添加关于我们浏览记录
+func AddCygxAboutUsVideoHistory(user *models.WxUserItem) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
+		}
+	}()
+	historyRecord := new(models.CygxAboutUsVideoHistory)
+	historyRecord.UserId = user.UserId
+	historyRecord.CreateTime = time.Now()
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	historyRecord.RealName = user.RealName
+	historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
+	if sellerItem != nil {
+		historyRecord.SellerName = sellerItem.RealName
+	}
+	_, err = models.AddCygxAboutUsVideoHistory(historyRecord)
+	return
+}

+ 3 - 4
services/page_history_record.go

@@ -10,7 +10,7 @@ import (
 	"time"
 )
 
-func AddCygxPageHistoryRecord(user *models.WxUserItem, Ctx *context.Context)  {
+func AddCygxPageHistoryRecord(user *models.WxUserItem, Ctx *context.Context) {
 	item := new(models.CygxPageHistoryRecord)
 	item.UserId = user.UserId
 	item.CreateTime = time.Now()
@@ -24,7 +24,7 @@ func AddCygxPageHistoryRecord(user *models.WxUserItem, Ctx *context.Context)  {
 	if index != -1 {
 		item.Parameter = item.Router[index+1:]
 	}
-	if Ctx.Input.Method() == "POST" {
+	if Ctx.Input.Method() == "POST" && string(Ctx.Input.RequestBody) != "" {
 		item.Parameter = string(Ctx.Input.RequestBody)
 		var pr models.PageRouter
 		err := json.Unmarshal(Ctx.Input.RequestBody, &pr)
@@ -46,11 +46,10 @@ func AddCygxPageHistoryRecord(user *models.WxUserItem, Ctx *context.Context)  {
 		}
 	}
 
-
 	_, err := models.AddCygxPageHistoryRecord(item)
 	if err != nil {
 		fmt.Println(err)
 		utils.FileLog.Info(err.Error())
 		return
 	}
-}
+}

+ 1 - 0
utils/constants.go

@@ -27,6 +27,7 @@ const (
 	DefaultHeadimgurl = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/P5qLR2zzfBdKItp3eX2Du1tvq9Ba.jpg"
 	ApiAuthorization  = "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkiLCJwaG9uZV9udW1iZXIiOiIxMjM0NTY3ODkiLCJuYW1lIjoi5YW25LuWIiwiZW50cmFuY2UiOiJwYXNzd3dvcmQiLCJpYXQiOjE2MzQ4NzA1OTQsImV4cCI6MTYzNDg3NDE5NH0.tho2L9jsbDPn8ltEGUVDve_nHsh0Kzf6ZrSz0RcZ0ag"
 	ApiUrl            = "https://vmp.hzinsights.com/v2api/"
+	REGISTER_PLATFORM = 1 // 来源 1小程序,2:网页
 )
 
 // 手机号,电子邮箱正则