Browse Source

fix:新增中文客户点击量详情接口

Roc 1 year ago
parent
commit
f2ebeca43d
3 changed files with 155 additions and 3 deletions
  1. 95 3
      controllers/company_user.go
  2. 42 0
      models/company/company_user.go
  3. 18 0
      routers/commentsRouter.go

+ 95 - 3
controllers/company_user.go

@@ -3098,7 +3098,6 @@ Loop:
 // @Param   TxtType   query   int  true       "类型0全部,1权益,2ficc"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   LastViewTime   query   string  true       "最近一次的阅读时间,没有的话,那就是获取最新数据"
-// @Param   CompanyId   query   int  true       "客户id"
 // @Success 200 {object} company.ViewReportListResp
 // @router /view/report/list [get]
 func (this *CompanyUserController) ViewReportList() {
@@ -3118,8 +3117,7 @@ func (this *CompanyUserController) ViewReportList() {
 	txtType, _ := this.GetInt("TxtType")
 	pageSize, _ := this.GetInt("PageSize")
 	lastViewTime := this.GetString("LastViewTime")
-	companyId, _ := this.GetInt("CompanyId")
-	if userId <= 0 && companyId <= 0 {
+	if userId <= 0 {
 		br.Msg = "参数错误"
 		return
 	}
@@ -6263,3 +6261,97 @@ func (this *CompanyUserController) UpadteUserYanxuanPermission() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// ListByReport
+// @Title 联系人列表
+// @Description 联系人列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   CompanyId   query   int  true       "公司id,必填"
+// @Param   SortParam	query	int	false	"排序字段:1-点击量;2-点击时间"
+// @Param   SortType	query	int	false	"排序方式:1-倒序;2-正序"
+// @Success 200 {object} company.CompanyUserListResp
+// @router /user/listByReport [get]
+func (this *CompanyUserController) ListByReport() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	companyId, _ := this.GetInt("CompanyId")
+
+	sortParam, _ := this.GetInt("SortParam", 2)
+	sortType, _ := this.GetInt("SortType", 1)
+
+	if companyId <= 0 {
+		br.Msg = "请选择客户"
+		br.ErrMsg = "客户参数错误"
+		return
+	}
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var order string
+	sortArr := []int{1, 2}
+	if utils.InArrayByInt(sortArr, sortParam) && utils.InArrayByInt(sortArr, sortType) {
+		pMap := map[int]string{1: "ficc_view_total", 2: "ficc_last_view_time"}
+		tMap := map[int]string{1: "DESC", 2: "ASC"}
+		order = fmt.Sprintf(` ORDER BY %s %s`, pMap[sortParam], tMap[sortType])
+	}
+
+	total, err := company.GetCompanyUserCount(companyId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
+		return
+	}
+
+	list, err := company.GetCompanyUserListByReport(companyId, startSize, pageSize, order)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	respList := make([]*company.CompanyViewResp, 0)
+	for i := range list {
+		v := &company.CompanyViewResp{
+			UserId:       int(list[i].UserId),
+			UserName:     list[i].RealName,
+			Mobile:       list[i].Mobile,
+			Email:        list[i].Email,
+			ViewTotal:    list[i].FiccViewTotal,
+			LastViewTime: list[i].FiccLastViewTime.Format(utils.FormatDateTime),
+		}
+		if v.LastViewTime == "0001-01-01 00:00:00" {
+			v.LastViewTime = ""
+		}
+		respList = append(respList, v)
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := &company.CompanyViewPageListResp{
+		Paging: page,
+		List:   respList,
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 42 - 0
models/company/company_user.go

@@ -480,3 +480,45 @@ func GetViewReportListByDate(startDate, endDate string) (items []*ViewReportList
 
 	return
 }
+
+// CompanyViewResp
+// @Description: 客户报告阅读统计
+type CompanyViewResp struct {
+	UserId       int    `description:"联系人ID"`
+	UserName     string `description:"联系人姓名"`
+	Mobile       string `description:"手机号"`
+	Email        string `description:"邮箱地址"`
+	ViewTotal    int    `description:"累计点击量"`
+	LastViewTime string `description:"创建时间"`
+}
+
+// CompanyViewPageListResp 客户-点击量分页列表响应体
+type CompanyViewPageListResp struct {
+	List   []*CompanyViewResp
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+// GetCompanyUserListByReport
+// @Description: 根据报告阅读情况获取联系人列表
+// @author: Roc
+// @datetime 2024-02-01 16:07:59
+// @param companyId int
+// @param startSize int
+// @param pageSize int
+// @param order string
+// @return items []*CompanyUser
+// @return err error
+func GetCompanyUserListByReport(companyId, startSize, pageSize int, order string) (items []*CompanyUser, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM wx_user  WHERE company_id = ? `
+
+	if order != "" {
+		sql += order
+	} else {
+		sql += ` ORDER BY create_time DESC`
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, companyId, startSize, pageSize).QueryRows(&items)
+
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -7207,6 +7207,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/overseas_custom:OverseasCustomController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/overseas_custom:OverseasCustomController"],
+        beego.ControllerComments{
+            Method: "CustomOverseasLabelSet",
+            Router: `/custom/overseas_label_set`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/overseas_custom:OverseasCustomController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/overseas_custom:OverseasCustomController"],
         beego.ControllerComments{
             Method: "CustomStatusSet",
@@ -9925,6 +9934,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
+        beego.ControllerComments{
+            Method: "ListByReport",
+            Router: `/user/listByReport`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
         beego.ControllerComments{
             Method: "GetOtherProduct",