Browse Source

Merge branch 'need/cygx_1063' of http://8.136.199.33:3000/hongze/hongze_clpt

zhangchuanxing 1 tuần trước cách đây
mục cha
commit
31a1befc08

+ 93 - 1
controllers/banner.go

@@ -58,12 +58,28 @@ func (this *BannerNoLoginController) List() {
 	for _, v := range bannerImgList {
 		mapImg[v.ImgId] = v
 	}
-	//chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
+	//var chartUserTokenByMobile string
+	//if user.Mobile != "" {
+	//	chartUserTokenByMobile, _ = services.GetUserTokenByMobile(user.Mobile)
+	//}
+	//if chartUserTokenByMobile == "" {
+	//	chartUserTokenByMobile = "aiPos"
+	//}
+	//
+	//if user.CompanyId == 1 {
+	//	chartUserTokenByMobile += "&isCustomer=1" // 潜在客户标识
+	//} else {
+	//	chartUserTokenByMobile += "&isCustomer=0"
+	//}
+
 	var listA []*models.CygxBannerResp
 	var listB []*models.CygxBannerResp
 	var listC []*models.CygxBannerResp
 	for _, v := range list {
 		v.BannerUrlResp = services.GetBannerUrlBody(v.Link)
+		//if strings.Contains(v.Link, "aiPos") {
+		//	v.Link += "?token=" + chartUserTokenByMobile
+		//}
 		if v.ListType == "A" {
 			listA = append(listA, v)
 		} else if v.ListType == "B" {
@@ -313,3 +329,79 @@ func (this *BannerController) YxSurvey() {
 	br.Success = true
 	br.Msg = "记录成功"
 }
+
+// @Title 记录点击信息
+// @Description 记录点击信息
+// @Param	request	body cygx.CygxBannerIdReq true "type json string"
+// @Success 200 Ret=200 记录成功
+// @router /add/stop_time/ai_poc [post]
+func (this *BannerController) StopTime() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.CygxBannerStopTimeReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	stopTime := req.StopTime
+	if stopTime == 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,id不可为空"
+		return
+	}
+	go services.AddAddCygxBannerStopTimeAiPoc(user, stopTime)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "记录成功"
+}
+
+// @Title 列表
+// @Description 列表接口
+// @Success Ret=200 {object} cygx.CygxBannerListResp
+// @router /ai_poc/config [get]
+func (this *BannerController) AiPocConfig() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	resp := new(models.CygxAiPocConfigResp)
+
+	var chartUserTokenByMobile string
+	if user.Mobile != "" {
+		chartUserTokenByMobile, _ = services.GetUserTokenByMobile(user.Mobile)
+	}
+	if chartUserTokenByMobile == "" {
+		chartUserTokenByMobile = "aiPos"
+	}
+
+	if user.CompanyId == 1 {
+		resp.IsCustomer = 1
+	} else {
+		resp.IsCustomer = 0
+	}
+	resp.VmpUrl = "https://ai_poc.saas.hzinsights.com/sr/ticker/BMY.N?token=" + chartUserTokenByMobile
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 4 - 0
controllers/user.go

@@ -438,6 +438,10 @@ func (this *UserController) ApplyTryOut() {
 		// FICC研报小程序弹窗
 		title = "周期股语音播报"
 		source = utils.CYGX_OBJ_FICC_REPORT_XCX
+	} else if tryType == utils.VMP_AI_POC {
+		// vmp 平台美股追踪看板
+		title = "美股追踪"
+		source = utils.VMP_AI_POC
 	}
 
 	//缓存校验

+ 9 - 0
models/banner.go

@@ -19,6 +19,10 @@ type CygxBannerIdReq struct {
 	BannerId int `description:"BannerId"`
 }
 
+type CygxBannerStopTimeReq struct {
+	StopTime int `description:"停留时长"`
+}
+
 type GetCygxBannerImgRespDetailResp struct {
 	Detail *CygxBannerResp
 }
@@ -94,3 +98,8 @@ func GetCygxBannerImgList() (items []*CygxBannerImgResp, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+type CygxAiPocConfigResp struct {
+	IsCustomer int    `description:"是否为潜在,1是,0否,默认否"`
+	VmpUrl     string `description:"策略平台地址"`
+}

+ 23 - 0
models/banner_history.go

@@ -27,3 +27,26 @@ func AddCygxBannerHistory(item *CygxBannerHistory) (lastId int64, err error) {
 	lastId, err = o.Insert(item)
 	return
 }
+
+type CygxBannerStopTimeAiPoc struct {
+	HistoryId        int `orm:"column(history_id);pk"`
+	StopTime         int `description:"停留时长"`
+	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:网页"`
+}
+
+// vmp AiPoc 模版停留时长
+func AddCygxBannerStopTimeAiPoc(item *CygxBannerStopTimeAiPoc) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 1 - 0
models/db.go

@@ -78,6 +78,7 @@ func init() {
 		new(CygxAboutUsVideoHistory),
 		new(CygxTacticsTimeLineHistory),
 		new(CygxBannerHistory),
+		new(CygxBannerStopTimeAiPoc),
 		new(CygxReportHistoryRecordLog),
 		new(CygxUserLabel),
 		new(CygxInviteCompany),

+ 18 - 0
routers/commentsRouter.go

@@ -304,6 +304,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "StopTime",
+            Router: `/add/stop_time/ai_poc`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerController"],
         beego.ControllerComments{
             Method: "YxSurvey",
@@ -313,6 +322,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "AiPocConfig",
+            Router: `/ai_poc/config`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerNoLoginController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:BannerNoLoginController"],
         beego.ControllerComments{
             Method: "List",

+ 29 - 0
services/banner.go

@@ -1,6 +1,7 @@
 package services
 
 import (
+	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 	"strconv"
@@ -73,3 +74,31 @@ func AddCygxBannerHistory(user *models.WxUserItem, bannerId int) (err error) {
 	_, err = models.AddCygxBannerHistory(historyRecord)
 	return
 }
+
+func AddAddCygxBannerStopTimeAiPoc(user *models.WxUserItem, stopTime int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
+		}
+	}()
+	historyRecord := new(models.CygxBannerStopTimeAiPoc)
+	historyRecord.UserId = user.UserId
+	historyRecord.StopTime = stopTime
+	historyRecord.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	historyRecord.RealName = user.RealName
+	if sellerItem != nil {
+		historyRecord.SellerName = sellerItem.RealName
+	}
+	_, err = models.AddCygxBannerStopTimeAiPoc(historyRecord)
+	return
+}

+ 1 - 0
utils/constants.go

@@ -270,6 +270,7 @@ const (
 	CYGX_OBJ_ASKSERIEVIDEO      string = "askserievideo"      // 对象类型:问答系列视频
 	CYGX_OBJ_FICC_REPORT        string = "ficcreport"         // 对象类型:FICC研报
 	CYGX_OBJ_FICC_REPORT_XCX    string = "ficcreportxcx"      // 对象类型:FICC研报小程序
+	VMP_AI_POC                  string = "VmpAiPoc"           // 对象类型:策略平台 VMP_AI_POC
 )
 
 const (