Browse Source

Merge branch 'crm/crm_16.5' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 3 months ago
parent
commit
4b3c232086

+ 6 - 0
controllers/cygx/user.go

@@ -316,6 +316,7 @@ func (this *UserController) List() {
 		UserRemindListMap := cygxService.GetCygxUserRemindListMap(userIdArr)
 		mapIsUserMaker := cygxService.GetCompanyProductIsUserMakerByCompanyIds(companyIds) //根据公司ID获取近四周之内有决策人互动的客户
 		userHaveMoveMap := services.GetWxUserHaveMoveMap(mobilesSlice)                     // 处理用户是否移动过按钮回显
+		userLabelMap := cygxService.GetUserLabelByUserIdArr(userIdArr)                     // 根据多个userId 获取每个UserId最新的十条数据
 
 		for k, v := range list {
 			for _, vsplit := range splitList {
@@ -343,6 +344,11 @@ func (this *UserController) List() {
 			if v.Mobile != "" {
 				v.HaveMoveButton = userHaveMoveMap[v.Mobile]
 			}
+			if len(userLabelMap[int(v.UserId)]) == 0 {
+				list[k].RaiLabelList = make([]*cygx.WxUserRaiLabelListResp, 0)
+			} else {
+				list[k].RaiLabelList = userLabelMap[int(v.UserId)]
+			}
 		}
 		for k := range list {
 			list[k].InteractionNum = list[k].HistoryNum + list[k].CountNum + list[k].IndustryFllowNum + list[k].DepartmentFollowNum + list[k].KeyWordNum + list[k].OnLineNum + list[k].OfficeNum + list[k].ChartNum + list[k].TripNum + list[k].RoadshowVideoNum + list[k].ActivityVideoNum + list[k].ActivityVoiceNum + list[k].YanxuanspecialNum

+ 110 - 0
controllers/cygx/user_rai_label.go

@@ -0,0 +1,110 @@
+package cygx
+
+import (
+	"encoding/json"
+	"hongze/hz_crm_api/controllers"
+	"hongze/hz_crm_api/models"
+	"hongze/hz_crm_api/models/cygx"
+	"time"
+)
+
+// 权益用户标签
+type UserRaiLabelController struct {
+	controllers.BaseAuthController
+}
+
+// @Title 销售输入标签
+// @Description 销售输入标签接口
+// @Param	request	body cygx.WxUserRaiLabelAddReq true "type json string"
+// @Success 200 {object} "保存成功"
+// @router /use_rai_label/add [post]
+func (this *UserRaiLabelController) Add() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req cygx.WxUserRaiLabelAddReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	userId := req.UserId
+	label := req.Label
+	wxUser, err := models.GetWxUserItemByUserId(userId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, GetWxUserItemByUserId  Err:" + err.Error()
+		return
+	}
+	item := new(cygx.WxUserRaiLabel)
+	item.UserId = wxUser.UserId
+	item.RealName = wxUser.RealName
+	item.Mobile = wxUser.Mobile
+	item.Email = wxUser.Email
+	item.CompanyId = wxUser.CompanyId
+	item.CompanyName = wxUser.CompanyName
+	item.Label = label
+	item.SysUserId = AdminUser.AdminId
+	item.SysUserRealName = AdminUser.RealName
+	item.SourceType = 6
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	err = cygx.AddWxUserRaiLabel(item)
+	if err != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "保存失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "操作成功"
+}
+
+// @Title 删除销售输入标签
+// @Description 删除销售输入标签接口
+// @Param	request	body cygx.WxUserRaiLabelAddReq true "type json string"
+// @Success 200 {object} "保存成功"
+// @router /use_rai_label/delte [post]
+func (this *UserRaiLabelController) Delte() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req cygx.WxUserRaiLabelIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	raiLabelId := req.RaiLabelId
+	err = cygx.DeleteWxUserRaiLabel(raiLabelId)
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "操作成功"
+}

+ 6 - 1
controllers/statistic_company_merge.go

@@ -2106,6 +2106,8 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 			if pidIndex == 0 {
 				cellG := rowTitle.AddCell()
 				cellG.Value = "不续约归因"
+				cellH := rowTitle.AddCell()
+				cellH.Value = "详细说明"
 			}
 
 			for _, item := range listDate {
@@ -2126,7 +2128,10 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 				cellFData.Value = fmt.Sprint(item.Money)
 				if pidIndex == 0 {
 					cellGData := row.AddCell()
-					cellGData.Value = item.Content
+					cellGData.Value = item.AscribeContent
+
+					cellHData := row.AddCell()
+					cellHData.Value = item.Content
 				}
 			}
 		}

+ 45 - 44
models/cygx/cygx_user.go

@@ -12,50 +12,51 @@ import (
 )
 
 type CygxCompanyUser struct {
-	UserId                      int64  `orm:"column(user_id);pk"`
-	Mobile                      string `description:"手机号"`
-	Email                       string `description:"邮箱"`
-	CompanyId                   int    `description:"公司id"`
-	CompanyName                 string `description:"公司名称"`
-	RealName                    string `description:"姓名"`
-	CreatedTime                 string `description:"创建时间"`
-	IsMaker                     int    `description:"是否决策人,1:是,0:否"`
-	IsRegister                  bool   `description:"是否注册,true:已注册,false:未注册"`
-	Status                      string `description:"客户状态"`
-	RegisterTime                string `description:"注册时间"`
-	SellerName                  string `description:"销售名称"`
-	InteractionNum              int    `description:"互动量"`
-	CompanyInteractionNum       int    `description:"企业互动量"`
-	CompanyInteractionNumSeller int    `description:"销售可见企业互动量"`
-	Labels                      string `description:"标签,用英文,隔开"`
-	ActivityLabel               string `description:"活动标签,用英文,隔开"`
-	IsShowSee                   bool   `description:"是否展示查看"`
-	IsShowSeeNum                int    `description:"是否展示查看"`
-	HistoryNum                  int    `description:"报告阅读"`
-	CountNum                    int    `description:"报告收藏"`
-	IndustryFllowNum            int    `description:"产业关注"`
-	DepartmentFollowNum         int    `description:"作者关注"`
-	KeyWordNum                  int    `description:"搜索关键词"`
-	OnLineNum                   int    `description:"线上互动活动"`
-	OfficeNum                   int    `description:"线下互动活动"`
-	ChartNum                    int    `description:"图表收藏数量"`
-	TripNum                     int    `description:"图表数量"`
-	RoadshowVideoNum            int    `description:"产业视频播放量"`
-	ActivityVideoNum            int    `description:"活动视频播放量"`
-	ActivityVoiceNum            int    `description:"活动音频播放量"`
-	YanxuanspecialNum           int    `description:"研选专栏查看数量"`
-	RsCalendarNum               int    `description:"1V1 路演数量"`
-	FeedbackNum                 int    `description:"交流反馈数量"`
-	PackageType                 int    `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
-	TryStage                    int    `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
-	Content                     string `description:"备注信息"`
-	IsRemind                    bool   `description:"是否添加互动提醒"`
-	IsSubscribeCygx             int    `description:"是否关注了查研观向微信公众号: 0-未关注; 1-已关注"`
-	IsSubscribeMfyx             int    `description:"是否关注了买方研选微信公众号: 0-未关注; 1-已关注"`
-	IsUserMaker                 int    `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
-	HaveMoveButton              bool   `description:"是否移动过"`
-	MfyxIsBinding               bool   `description:"买方研选是否绑定"`
-	Position                    string `description:"职位"`
+	UserId                      int64                     `orm:"column(user_id);pk"`
+	Mobile                      string                    `description:"手机号"`
+	Email                       string                    `description:"邮箱"`
+	CompanyId                   int                       `description:"公司id"`
+	CompanyName                 string                    `description:"公司名称"`
+	RealName                    string                    `description:"姓名"`
+	CreatedTime                 string                    `description:"创建时间"`
+	IsMaker                     int                       `description:"是否决策人,1:是,0:否"`
+	IsRegister                  bool                      `description:"是否注册,true:已注册,false:未注册"`
+	Status                      string                    `description:"客户状态"`
+	RegisterTime                string                    `description:"注册时间"`
+	SellerName                  string                    `description:"销售名称"`
+	InteractionNum              int                       `description:"互动量"`
+	CompanyInteractionNum       int                       `description:"企业互动量"`
+	CompanyInteractionNumSeller int                       `description:"销售可见企业互动量"`
+	Labels                      string                    `description:"标签,用英文,隔开"`
+	ActivityLabel               string                    `description:"活动标签,用英文,隔开"`
+	IsShowSee                   bool                      `description:"是否展示查看"`
+	IsShowSeeNum                int                       `description:"是否展示查看"`
+	HistoryNum                  int                       `description:"报告阅读"`
+	CountNum                    int                       `description:"报告收藏"`
+	IndustryFllowNum            int                       `description:"产业关注"`
+	DepartmentFollowNum         int                       `description:"作者关注"`
+	KeyWordNum                  int                       `description:"搜索关键词"`
+	OnLineNum                   int                       `description:"线上互动活动"`
+	OfficeNum                   int                       `description:"线下互动活动"`
+	ChartNum                    int                       `description:"图表收藏数量"`
+	TripNum                     int                       `description:"图表数量"`
+	RoadshowVideoNum            int                       `description:"产业视频播放量"`
+	ActivityVideoNum            int                       `description:"活动视频播放量"`
+	ActivityVoiceNum            int                       `description:"活动音频播放量"`
+	YanxuanspecialNum           int                       `description:"研选专栏查看数量"`
+	RsCalendarNum               int                       `description:"1V1 路演数量"`
+	FeedbackNum                 int                       `description:"交流反馈数量"`
+	PackageType                 int                       `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
+	TryStage                    int                       `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
+	Content                     string                    `description:"备注信息"`
+	IsRemind                    bool                      `description:"是否添加互动提醒"`
+	IsSubscribeCygx             int                       `description:"是否关注了查研观向微信公众号: 0-未关注; 1-已关注"`
+	IsSubscribeMfyx             int                       `description:"是否关注了买方研选微信公众号: 0-未关注; 1-已关注"`
+	IsUserMaker                 int                       `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
+	HaveMoveButton              bool                      `description:"是否移动过"`
+	MfyxIsBinding               bool                      `description:"买方研选是否绑定"`
+	Position                    string                    `description:"职位"`
+	RaiLabelList                []*WxUserRaiLabelListResp `description:"权益用户标签列表'"`
 }
 
 type CompanyUserListResp struct {

+ 95 - 0
models/cygx/wx_user_rai_label.go

@@ -0,0 +1,95 @@
+package cygx
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_crm_api/utils"
+	"time"
+)
+
+type WxUserRaiLabel struct {
+	RaiLabelId      int       `orm:"column(rai_label_id);pk"`
+	UserId          int       `description:"用户ID"`
+	RealName        string    `description:"用户实际名称"`
+	Mobile          string    `description:"手机号"`
+	Email           string    `description:"邮箱"`
+	CompanyId       int       `description:"公司id"`
+	CompanyName     string    `description:"公司名称"`
+	Label           string    `description:"标签内容"`
+	SourceId        int       `description:"来源ID"`
+	SourceType      int       `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
+	SysUserId       int       `description:"创建人id"`
+	SysUserRealName string    `description:"创建人名称"`
+	CreateTime      time.Time `description:"创建时间"`
+	ModifyTime      time.Time `description:"更新时间"`
+}
+
+type WxUserRaiLabelListResp struct {
+	UserId     int    `description:"用户ID"`
+	RaiLabelId int    `description:"ID"`
+	Label      string `description:"标签内容"`
+	SourceType int    `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
+}
+
+type WxUserRaiLabelAddReq struct {
+	UserId int    `description:"用户ID"`
+	Label  string `description:"标签内容"`
+}
+
+type WxUserRaiLabelIdReq struct {
+	RaiLabelId int `description:"ID"`
+}
+
+// 添加
+func AddWxUserRaiLabel(item *WxUserRaiLabel) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	_, err = o.Insert(item)
+	return
+}
+
+// DeleteWxUserRaiLabel 根据主键ID删除数据
+func DeleteWxUserRaiLabel(raiLabelId int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` DELETE FROM wx_user_rai_label WHERE rai_label_id = ? `
+	_, err = o.Raw(sql, raiLabelId).Exec()
+	return
+}
+
+// GetWxUserRaiLabelListByUserIds 根据多个userId 获取每个UserId最新的十条数据
+func GetWxUserRaiLabelListByUserIds(userIdArr []int) (list []*WxUserRaiLabelListResp, err error) {
+	lenArr := len(userIdArr)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			t.rai_label_id,
+			t.user_id,
+			t.label,
+			t.source_type 
+		FROM
+			(
+			SELECT
+				rai_label_id,
+				user_id,
+				label,
+				source_type,
+				create_time,
+				@row_number :=
+			IF
+				( @prev_user_id = user_id, @row_number + 1, 1 ) AS rank,
+				@prev_user_id := user_id 
+			FROM
+				wx_user_rai_label,
+				( SELECT @row_number := 0, @prev_user_id := NULL ) AS vars 
+			WHERE
+				user_id IN ( ` + utils.GetOrmInReplace(lenArr) + ` ) 
+			ORDER BY
+				user_id DESC 
+			) AS t 
+		WHERE
+			t.rank <= 10 
+		ORDER BY
+			t.create_time DESC  `
+	_, err = o.Raw(sql, userIdArr).QueryRows(&list)
+	return
+}

+ 1 - 0
models/db.go

@@ -489,6 +489,7 @@ func initCygx() {
 		new(cygx.CygxUserFeedback),
 		new(cygx.CygxReportSelectionThirdName),
 		new(cygx.CygxGushouTimeLine),
+		new(cygx.WxUserRaiLabel),
 	)
 }
 

+ 18 - 0
routers/commentsRouter.go

@@ -3328,6 +3328,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:UserRaiLabelController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:UserRaiLabelController"],
+        beego.ControllerComments{
+            Method: "Add",
+            Router: `/use_rai_label/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:UserRaiLabelController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:UserRaiLabelController"],
+        beego.ControllerComments{
+            Method: "Delte",
+            Router: `/use_rai_label/delte`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"],
         beego.ControllerComments{
             Method: "ApprovalLogList",

+ 1 - 0
routers/router.go

@@ -165,6 +165,7 @@ func init() {
 				&cygx.RaiServeCoAntroller{},
 				&cygx.UserFeedbackController{},
 				&cygx.GushouTimeLineController{},
+				&cygx.UserRaiLabelController{},
 			),
 		),
 		web.NSNamespace("/advisory",

+ 32 - 0
services/cygx/user_rai_label.go

@@ -0,0 +1,32 @@
+package cygx
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/services/alarm_msg"
+)
+
+// GetUserLabelByUserIdArr 根据多个userId 获取每个UserId最新的十条数据
+func GetUserLabelByUserIdArr(userIdArr []int) (mapRsp map[int][]*cygx.WxUserRaiLabelListResp) {
+	if len(userIdArr) == 0 {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint("根据多个userId 获取每个UserId最新的十条数据失败:"+err.Error(), "userIdArr", userIdArr), 2)
+		}
+	}()
+	labelList, e := cygx.GetWxUserRaiLabelListByUserIds(userIdArr)
+	if e != nil {
+		err = errors.New("GetWxUserRaiLabelListByUserIds, Err: " + e.Error())
+		return
+	}
+	mapRsp = make(map[int][]*cygx.WxUserRaiLabelListResp)
+	for _, v := range labelList {
+		mapRsp[v.UserId] = append(mapRsp[v.UserId], v)
+	}
+	return
+}