ziwen 1 年之前
父節點
當前提交
f213a91205

+ 48 - 1
controllers/company.go

@@ -114,7 +114,17 @@ func (this *CompanyController) SearchList() {
 	}
 	// 查询当前销售是否有领取客户的权限
 	receiveEnabled, _ := services.CheckCompanyReceiveButton(sysUser.AdminId)
-
+	// 白嫖客户标记
+	scroungeList, err := company.GetScroungeCompany()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取白嫖客户信息失败,Err:" + err.Error()
+		return
+	}
+	scroungeMap := make(map[int]int)
+	for _, v := range scroungeList {
+		scroungeMap[v.CompanyId] = 1
+	}
 	/*
 		时长根据客户状态定义,
 		若为冻结客户或者流失客户,则展示冻结时长或流失时长;
@@ -125,6 +135,10 @@ func (this *CompanyController) SearchList() {
 		duration := ""
 		item := list[i]
 		itemStatus := item.Status
+		//白嫖客户标记
+		if _, ok := scroungeMap[item.CompanyId]; ok{
+			item.IsScrounge = 1
+		}
 		if !strings.Contains(item.Status, "/") {
 			if item.Status == utils.COMPANY_STATUS_FREEZE {
 				if item.FreezeEndDate != "" {
@@ -1708,6 +1722,24 @@ func (this *CompanyController) List() {
 	if companyLists == nil {
 		companyLists = make([]*company.CompanyListItem, 0)
 	}
+
+	// 白嫖客户标记
+	scroungeList, err := company.GetScroungeCompany()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取白嫖客户信息失败,Err:" + err.Error()
+		return
+	}
+	scroungeMap := make(map[int]int)
+	for _, v := range scroungeList {
+		scroungeMap[v.CompanyId] = 1
+	}
+	for i, v := range companyLists {
+		if _, ok := scroungeMap[v.CompanyId]; ok{
+			companyLists[i].IsScrounge = 1
+		}
+	}
+
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = companyLists
 	resp.StatusCount = statusItems
@@ -3346,6 +3378,21 @@ func (this *CompanyController) Detail() {
 		}
 	}
 
+	// 白嫖客户标记
+	scroungeList, err := company.GetScroungeCompany()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取白嫖客户信息失败,Err:" + err.Error()
+		return
+	}
+	scroungeMap := make(map[int]int)
+	for _, v := range scroungeList {
+		scroungeMap[v.CompanyId] = 1
+	}
+	if _, ok := scroungeMap[item.CompanyId]; ok{
+		item.IsScrounge = 1
+	}
+
 	resp.Item = item
 	resp.BtnItem = btnDetailItem
 	br.Ret = 200

+ 1 - 0
controllers/cygx/activity.go

@@ -434,6 +434,7 @@ func (this *ActivityCoAntroller) PreserveAndPublish() {
 			item.LastUpdatedTime = time.Now()
 			item.Scale = scale
 			item.IsExternalLabel = isExternalLabel
+			item.IsAllCustomerType = req.IsAllCustomerType
 			if len(labelList) == 1 {
 				item.IsCanAppointmentMinutes = labelList[0].IsCanAppointmentMinutes
 			} else {

+ 13 - 13
controllers/cygx/report_selection.go

@@ -317,7 +317,19 @@ func (this *ReportSelectionController) Detail() {
 	listMore, err := cygx.GetChartPermissionDetail(condition)
 	var list []*cygx.CygxReportSelectionChart
 	//排序方式修改
-	permissionNameList := []cygx.CygxChartPermissionName{{ChartPermissionName: "消费"}, {ChartPermissionName: "医药"}, {ChartPermissionName: "科技"}, {ChartPermissionName: "智造"}}
+	permissionNameList := []cygx.CygxChartPermissionName{}
+	//获取行业核心逻辑汇总
+	listChartLog, err := cygx.GetCygxReportSelectionChartLogRepList(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	mapChartLog := make(map[string]string)
+	for _, v := range listChartLog {
+		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
+		permissionNameList = append(permissionNameList, cygx.CygxChartPermissionName{v.ChartPermissionName})
+	}
 	for _, v := range permissionNameList {
 		for _, v2 := range listMore {
 			if v.ChartPermissionName == v2.ChartPermissionName {
@@ -335,18 +347,6 @@ func (this *ReportSelectionController) Detail() {
 		return
 	}
 
-	//获取行业核心逻辑汇总
-	listChartLog, err := cygx.GetCygxReportSelectionChartLogRepList(articleId)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	mapChartLog := make(map[string]string)
-	for _, v := range listChartLog {
-		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
-	}
-
 	//获取关联的文章信息
 	mapArticle := make(map[int]string)
 	listSelectionLog, err := cygx.GetReportSelectionlogListAll(articleId)

+ 80 - 6
controllers/cygx/user.go

@@ -619,8 +619,10 @@ func (this *UserController) TableList() {
 		{PermissionName: "关注的产业", Source: 5, TotalNum: countDetail.IndustryFllowNum},
 		{PermissionName: "关注的作者", Source: 6, TotalNum: countDetail.DepartmentFollowNum},
 		{PermissionName: "搜索", Source: 7, TotalNum: countDetail.KeyWordNum},
-		{PermissionName: "音视频播放", Source: 9, TotalNum: countDetail.RoadshowVideoNum + countDetail.ActivityVideoNum + countDetail.ActivityVoiceNum}}
-	resp := new(cygx.CygxUserTableListRep)
+		{PermissionName: "音视频播放", Source: 9, TotalNum: countDetail.RoadshowVideoNum + countDetail.ActivityVideoNum + countDetail.ActivityVoiceNum},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: countDetail.TagNum}}
+
+resp := new(cygx.CygxUserTableListRep)
 	resp.List = List
 	resp.UserName = wxUser.RealName
 	resp.Mobile = wxUser.Mobile
@@ -696,7 +698,16 @@ func (this *UserController) TableDetail() {
 	var NoMeetingNum int
 	var list []*cygx.UserInteraction
 
-	listTable := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: 10}, {PermissionName: "活动互动记录", Source: 2, TotalNum: 10}, {PermissionName: "收藏的报告", Source: 3, TotalNum: 10}, {PermissionName: "收藏图表", Source: 4, TotalNum: 10}, {PermissionName: "关注的产业", Source: 5, TotalNum: 10}, {PermissionName: "关注的作者", Source: 6, TotalNum: 10}, {PermissionName: "搜索", Source: 7, TotalNum: 10}, {PermissionName: "专项调研", Source: 8, TotalNum: 10}, {PermissionName: "音视频播放", Source: 9, TotalNum: 10}}
+	listTable := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: 10},
+		{PermissionName: "活动互动记录", Source: 2, TotalNum: 10},
+		{PermissionName: "收藏的报告", Source: 3, TotalNum: 10},
+		{PermissionName: "收藏图表", Source: 4, TotalNum: 10},
+		{PermissionName: "关注的产业", Source: 5, TotalNum: 10},
+		{PermissionName: "关注的作者", Source: 6, TotalNum: 10},
+		{PermissionName: "搜索", Source: 7, TotalNum: 10},
+		{PermissionName: "专项调研", Source: 8, TotalNum: 10},
+		{PermissionName: "音视频播放", Source: 9, TotalNum: 10},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: 10}}
 	for _, v := range listTable {
 		if v.Source == source {
 			checkSource = true
@@ -973,6 +984,19 @@ func (this *UserController) TableDetail() {
 			br.Msg = "获取搜索记录列表失败"
 			return
 		}
+	} else if source == 10 { //标签点击记录
+		total, err = cygx.GetCygxTagHistoryCountByUserId(userId)
+		if err != nil {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录失败"
+			return
+		}
+		list, err = cygx.GetCygxTagHistoryByUserId(userId, startSize, pageSize)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录列表失败"
+			return
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(cygx.UserInteractionListResp)
@@ -1895,6 +1919,12 @@ func (this *UserController) CompanyTableList() {
 		br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
 		return
 	}
+	tagNum, err := cygx.GetCygxTagHistoryCountByCompanyId(companyId,"")
+	if err != nil {
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		br.Msg = "获取搜索记录失败"
+		return
+	}
 	List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
 		{PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
 		{PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
@@ -1903,7 +1933,8 @@ func (this *UserController) CompanyTableList() {
 		{PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
 		{PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
 		{PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
-		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal}}
+		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum}}
 	resp := new(cygx.CygxUserTableListRep)
 	resp.List = List
 	resp.ComapnyName = comanyDetail.CompanyName
@@ -2296,6 +2327,23 @@ func (this *UserController) CompanyTableDetail() {
 			br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
 			return
 		}
+	} else if source == 10 { //标签点击记录
+		condition = ``
+		if keyWord != "" {
+			condition += ` AND  (a.mobile LIKE '%` + keyWord + `%' OR a.email LIKE '%` + keyWord + `%' OR a.real_name LIKE '%` + keyWord + `%'` + ` OR a.company_name LIKE '%` + keyWord + `%') `
+		}
+		total, err = cygx.GetCygxTagHistoryCountByCompanyId(companyId, condition)
+		if err != nil {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录失败"
+			return
+		}
+		list, err = cygx.GetCygxTagHistoryByCompanyId(companyId, startSize, pageSize, condition)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录列表失败"
+			return
+		}
 	}
 
 	page := paging.GetPaging(currentIndex, pageSize, total)
@@ -3238,6 +3286,26 @@ func (this *UserController) CompanyList() {
 			br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
 			return
 		}
+	} else if source == 10 { //标签点击记录
+		condition = ``
+		if adminId != "" {
+			condition += ` AND p.seller_id IN (` + adminId + `) `
+		}
+		if keyWord != "" {
+			condition += ` AND  (a.mobile LIKE '%` + keyWord + `%' OR a.email LIKE '%` + keyWord + `%' OR a.real_name LIKE '%` + keyWord + `%'` + ` OR a.company_name LIKE '%` + keyWord + `%') `
+		}
+		total, err = cygx.GetCygxTagHistoryCountByCompanyIds(companyIds, condition)
+		if err != nil {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录失败"
+			return
+		}
+		list, err = cygx.GetCygxTagHistoryByCompanyIds(companyIds, condition, startSize, pageSize)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录列表失败"
+			return
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 
@@ -4095,7 +4163,12 @@ func (this *UserController) TableCompanyList() {
 		br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
 		return
 	}
-
+	tagNum, err := cygx.GetCygxTagHistoryCountByCompanyIds(companyCondition,"")
+	if err != nil {
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		br.Msg = "获取搜索记录失败"
+		return
+	}
 	List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
 		{PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
 		{PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
@@ -4104,7 +4177,8 @@ func (this *UserController) TableCompanyList() {
 		{PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
 		{PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
 		{PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
-		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal}}
+		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum}}
 	resp := new(cygx.CygxUserTableListRep)
 	resp.List = List
 	br.Ret = 200

+ 3 - 0
models/company/company.go

@@ -90,6 +90,7 @@ type CompanySearchItem struct {
 	ShareSeller     string `description:"共享销售员"`
 	ShareSellerId   int    `description:"共享销售员id"`
 	IsShare         int    `description:"0:非共享用户,1:共享客户"`
+	IsScrounge      int    `description:"是否白嫖 0不是 1是"`
 }
 
 type CompanySearchListResp struct {
@@ -269,6 +270,7 @@ type CompanyListItem struct {
 	ServiceTimes     int                  `description:"服务次数"`
 	CloseReason      string               `description:"关闭客户原因"`
 	CloseTime        string               `description:"关闭客户时间"`
+	IsScrounge       int                  `description:"是否白嫖 0不是 1是"`
 }
 
 type TryStageSliceItem struct {
@@ -575,6 +577,7 @@ type CompanyDetail struct {
 	IsShare         int    `description:"0:非共享用户,1:共享客户"`
 	ShareSeller     string `description:"共享销售员"`
 	ShareSellerId   int    `description:"共享销售员id"`
+	IsScrounge      int    `description:"是否白嫖 0不是 1是"`
 }
 
 type CompanyDetailResp struct {

+ 23 - 0
models/company/scrounge_company.go

@@ -0,0 +1,23 @@
+package company
+
+import (
+"github.com/beego/beego/v2/client/orm"
+"time"
+)
+
+type ScroungeCompany struct {
+	Id          int `orm:"column(id);pk"`
+	CompanyId   int
+	CompanyName string // 公司名
+	ProductId   int
+	CreateTime  time.Time // 申请时间
+	ModifyTime  time.Time // 修改时间
+	Remark      string    // 备注
+}
+
+func GetScroungeCompany() (list []*ScroungeCompany, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM scrounge_company   `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 3 - 0
models/cygx/activity.go

@@ -77,6 +77,7 @@ type ActivityRep struct {
 	SiginupDeadline         string                    `description:"报名截止时间"`
 	IsResearchPoints        int                       `description:"是否为研选扣点  1是,0否"`
 	PointsSet               *CygxActivityPointsSetRsq `description:"研选扣点明细"`
+	IsAllCustomerType       int                       `description:"是否全选活动可见类型 0无 1全选"`
 	List                    []*ActivityGroupIndustrialRep
 	VoiceList               []*CygxActivityVoiceReq
 	VideoDetail             *CygxActivityVideoReq
@@ -227,6 +228,7 @@ type CygxActivity struct {
 	SiginupDeadline         string    `description:"报名截止时间"`
 	CancelDeadline          string    `description:"取消报名截止时间"`
 	IsResearchPoints        int       `description:"是否为研选扣点  1是,0否"`
+	IsAllCustomerType       int       `description:"是否全选活动可见类型 0无 1全选"`
 }
 
 type CygxActivityEditDetail struct {
@@ -392,6 +394,7 @@ func EditActivity(item *CygxActivity, oldPublishStatus int, industrialActivityIt
 	updateParams["SiginupDeadline"] = item.SiginupDeadline
 	updateParams["IsResearchPoints"] = item.IsResearchPoints
 	updateParams["CancelDeadline"] = item.CancelDeadline
+	updateParams["IsAllCustomerType"] = item.IsAllCustomerType
 	//修改活动信息
 	ptrStructOrTableName := "cygx_activity"
 	whereParam := map[string]interface{}{"activity_id": item.ActivityId}

+ 11 - 2
models/cygx/cygx_user.go

@@ -322,8 +322,15 @@ type UserInteraction struct {
 	CurrentIndex          int    `description:"当前页页码,配合前端分页添加的参数"`
 	RegisterPlatform      int    `description:"来源 1小程序,2:网页 ,3:策略平台"`
 	SourcePlatform        string `description:"来源 'MOBILE:移动端小程序','PC:PC端小程序','CELUE:上海策略平台','WEB:查研观向网页版'"`
+	TagId                 int
+	TagName               string `orm:"column(tag_name);NOT NULL"`       // 标签名
+	ArticleTypes          string `orm:"column(article_types);NOT NULL"`  // 报告系列
+	ActivityTypes         string `orm:"column(activity_types);NOT NULL"` // 活动类型
+	Industries            string `orm:"column(industries);NOT NULL"`     // 产业
+	SubjectNames          string `orm:"column(subject_names);NOT NULL"`  // 标的
 }
 
+
 // 查研观向图表
 type CygxChartResp struct {
 	Title       string `description:"标题"`
@@ -833,6 +840,7 @@ type GetUserInteractionTableCountResp struct {
 	RoadshowVideoNum    int `description:"产业视频播放量"`
 	ActivityVideoNum    int `description:"活动视频播放量"`
 	ActivityVoiceNum    int `description:"活动音频播放量"`
+	TagNum              int `description:"首页标签点击量"`
 }
 
 // 用户互动总数统计
@@ -852,8 +860,9 @@ func GetUserInteractionTableCount(uid int) (item *GetUserInteractionTableCountRe
 			( SELECT COUNT( 1 ) FROM cygx_activity_special_meeting_detail AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.mobile = u.mobile  AND a.publish_status = 1 AND a.activity_time_end < NOW()) AS trip_num,
 			( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h  INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE  h.mobile = u.mobile  ) AS roadshow_video_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS h  INNER JOIN cygx_activity_video as v ON v.video_id = h.video_id WHERE  h.mobile = u.mobile  ) AS activity_video_num,
-			( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h  INNER JOIN cygx_activity_voice as v ON v.activity_id = h.activity_id WHERE  h.mobile = u.mobile  ) AS activity_voice_num
-		FROM
+			( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h  INNER JOIN cygx_activity_voice as v ON v.activity_id = h.activity_id WHERE  h.mobile = u.mobile  ) AS activity_voice_num,
+			( SELECT COUNT(1) FROM cygx_tag_history as a INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id WHERE a.user_id=u.user_id  ) AS tag_num
+			FROM
 			wx_user  as u
 		WHERE
 			u.user_id = ?`

+ 4 - 0
models/cygx/report_selection_log.go

@@ -17,6 +17,8 @@ type CygxReportSelectionLog struct {
 	CompanyLabel           string    `description:"公司标签多个用{|}隔开"`
 	OverviewArticleId      int       `description:"关联的综述报告ID"`
 	IsNew                  int       `description:"是否为New标签"`
+	SubjectSort            int       `description:"标的排序"`
+	ChartPermissionSort    int       `description:"品种排序"`
 }
 
 type CygxReportSelectionLogRep struct {
@@ -56,6 +58,8 @@ type CygxReportSelectionLogResp struct {
 	OverviewArticleId        int      `description:"综述报告Id"`
 	OverviewArticleTitle     string   `description:"综述报告标题"`
 	IsNew                    int      `description:"是否为New标签"`
+	SubjectSort              int      `description:"标的排序"`
+	ChartPermissionSort      int      `description:"品种排序"`
 }
 
 type CygxReportSelectionChart struct {

+ 106 - 1
models/cygx/tag_history.go

@@ -7,7 +7,7 @@ import (
 
 type CygxTagHistory struct {
 	Id               int `orm:"column(id);pk"`
-	TimeLineId       int
+	TagId            int
 	UserId           int
 	CreateTime       time.Time
 	Mobile           string    `description:"手机号"`
@@ -61,3 +61,108 @@ func GetCygxTagHistoryCountPv(tagId int) (count int, err error) {
 	err = o.Raw(sqlCount, tagId).QueryRow(&count)
 	return
 }
+
+// 获取数量
+func GetCygxTagHistoryCountByUserId(userId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_tag_history as a 
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	WHERE a.user_id=? ORDER BY a.create_time  `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, userId).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryByUserId(userId, startSize, pageSize int) (list []*UserInteraction, err error) {
+	sqlCount := ` SELECT b.*,a.create_time FROM cygx_tag_history as a INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+WHERE a.user_id=? ORDER BY a.create_time DESC LIMIT ?,? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sqlCount, userId, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryCountByCompanyId(companyId int, condition string) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM (SELECT b.* FROM cygx_tag_history as a 
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id `
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += ` WHERE a.company_id=? ) AS t `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, companyId).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryByCompanyId(companyId, startSize, pageSize int, condition string) (list []*UserInteraction, err error) {
+	sqlCount := ` SELECT a.real_name,a.mobile,ui.tag_num, a.create_time AS create_time,
+b.tag_id,b.tag_name,b.article_types,b.activity_types,b.industries,b.subject_names   
+FROM cygx_tag_history as a 
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id  
+	LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id `
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += ` 
+	WHERE a.company_id=? ORDER BY tag_num DESC ,create_time DESC LIMIT ?,? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sqlCount, companyId, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryCountByCompanyIds(companyIds, condition string) (count int, err error) {
+	sqlCount := ` SELECT a.real_name,a.mobile,b.*,ci.tag_num,ui.tag_num AS ui_tag_num,a.company_name  FROM cygx_tag_history as a  
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	LEFT JOIN company_product AS p ON a.company_id=p.company_id 
+	LEFT JOIN cygx_company_interaction_num AS ci ON ci.company_id = a.company_id 
+	LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id WHERE p.product_id=2 `
+	if companyIds != "" {
+		sqlCount += `AND a.company_id IN ( ` + companyIds + `) `
+	}
+	if condition != "" {
+		sqlCount += condition
+	}
+	sql := `SELECT COUNT(1) AS count  FROM (` + sqlCount + `)  AS t`
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryByCompanyIds(companyIds, condition string, startSize, pageSize int) (list []*UserInteraction, err error) {
+	sqlCount := ` SELECT a.real_name,a.mobile,ci.tag_num,ui.tag_num AS ui_tag_num,a.company_name, a.create_time AS create_time,
+b.tag_id,b.tag_name,b.article_types,b.activity_types,b.industries,b.subject_names
+FROM cygx_tag_history as a 
+INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+LEFT JOIN company_product AS p ON a.company_id=p.company_id 
+LEFT JOIN cygx_company_interaction_num AS ci ON ci.company_id = a.company_id 
+LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id WHERE p.product_id=2 `
+	if companyIds != "" {
+		sqlCount += `AND a.company_id IN ( ` + companyIds + `) `
+	}
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += ` ORDER BY tag_num DESC ,ui_tag_num DESC , create_time DESC LIMIT ?,? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sqlCount, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryCountByCompanyIdCondition(condition string) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_tag_history as a  
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	INNER JOIN company_product AS p ON a.company_id=p.company_id WHERE p.product_id=2`
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += `GROUP BY a.user_id,a.tag_id   `
+	sql := `SELECT COUNT(1) AS count  FROM (` + sqlCount + `)  AS t`
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}