소스 검색

no message

xingzai 11 달 전
부모
커밋
0a4ac852ae
4개의 변경된 파일229개의 추가작업 그리고 138개의 파일을 삭제
  1. 111 8
      controllers/cygx/user.go
  2. 4 2
      models/cygx/article_and_yanxuan_record.go
  3. 114 0
      models/cygx/cygx_user.go
  4. 0 128
      models/cygx/cygx_user_company.go

+ 111 - 8
controllers/cygx/user.go

@@ -2065,12 +2065,12 @@ func (this *UserController) CompanyTableList() {
 	conditionIndustryFllow := condition //产业关注搜索条件
 	conditionKeyWord := condition       //关键词记录搜索条件
 	if classType == 1 {
-		conditionArtcile += " AND art.article_type_id > 0  "
+		conditionArtcile += " AND art.article_type_id = 0  "
 		conditionActivityMeet += " AND a.chart_permission_id  != 31  "
 		conditionIndustryFllow += " AND m.chart_permission_id  != 31  "
 		conditionKeyWord += " AND r.register_platform IN (1,2)  "
 	} else {
-		conditionArtcile += " AND art.article_type_id = 0  "
+		conditionArtcile += " AND art.article_type_id > 0  "
 		conditionActivityMeet += " AND a.chart_permission_id  = 31  "
 		conditionIndustryFllow += " AND m.chart_permission_id  = 31  "
 		conditionKeyWord += " AND r.register_platform IN (5,6)  "
@@ -2219,7 +2219,7 @@ func (this *UserController) CompanyTableList() {
 			return
 		}
 		//获取关注作者总数
-		departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(conditionIndustryFllow)
+		departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
@@ -2324,6 +2324,7 @@ func (this *UserController) CompanyTableList() {
 // @Param   EndDate   query   string  false       "结束时间"
 // @Param   KeyWord   query   string  false       "搜索关键词"
 // @Param   ActivityName    query   string  false       "活动名称"
+// @Param  ClassType   query   int  true       "列表类型,1:权益,2:研选,默认1"
 // @Success 200 {object} cygx.UserInteractionListResp
 // @router /user/company/interaction/detail [get]
 func (this *UserController) CompanyTableDetail() {
@@ -2357,6 +2358,7 @@ func (this *UserController) CompanyTableDetail() {
 	keyWord := this.GetString("KeyWord")
 	activityName := this.GetString("ActivityName")
 	source, _ := this.GetInt("Source")
+	classType, _ := this.GetInt("ClassType", 1)
 	if companyId < 1 {
 		br.Msg = "用户不存在"
 		return
@@ -2376,6 +2378,22 @@ func (this *UserController) CompanyTableDetail() {
 		condition += ` AND ( r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%')`
 	}
 
+	conditionArtcile := condition       //文章搜索条件
+	conditionActivityMeet := condition  //活动到会搜索条件
+	conditionIndustryFllow := condition //产业关注搜索条件
+	conditionKeyWord := condition       //关键词记录搜索条件
+	if classType == 1 {
+		conditionArtcile += " AND art.article_type_id = 0  "
+		conditionActivityMeet += " AND a.chart_permission_id  != 31  "
+		conditionIndustryFllow += " AND m.chart_permission_id  != 31  "
+		conditionKeyWord += " AND r.register_platform IN (1,2)  "
+	} else {
+		conditionArtcile += " AND art.article_type_id > 0  "
+		conditionActivityMeet += " AND a.chart_permission_id  = 31  "
+		conditionIndustryFllow += " AND m.chart_permission_id  = 31  "
+		conditionKeyWord += " AND r.register_platform IN (5,6)  "
+	}
+
 	var isAdminRole bool
 	//如果不是管理员身份或者研究员身份则需要添加可见范围处理
 	if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
@@ -2391,6 +2409,11 @@ func (this *UserController) CompanyTableDetail() {
 			endDate += " 23:59:59"
 			condition += ` AND r.create_time <= '` + endDate + `' `
 		}
+		if classType == 1 {
+			condition += " AND art.article_type_id = 0  "
+		} else {
+			condition += " AND art.article_type_id > 0  "
+		}
 		condition += "  ORDER BY r.create_time DESC "
 		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
 		if isAdminRole {
@@ -2455,6 +2478,13 @@ func (this *UserController) CompanyTableDetail() {
 		if activityName != "" {
 			condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
 		}
+
+		if classType == 1 {
+			condition += "  AND a.chart_permission_id  != 31  "
+		} else {
+			condition += "  AND a.chart_permission_id  = 31  "
+		}
+
 		if isAdminRole {
 			total, err = cygx.GetActivityMeetByCompanyCount(condition)
 			if err != nil {
@@ -2505,6 +2535,11 @@ func (this *UserController) CompanyTableDetail() {
 			}
 		}
 	} else if source == 3 {
+		if classType == 1 {
+			condition += " AND art.article_type_id = 0  "
+		} else {
+			condition += " AND art.article_type_id > 0  "
+		}
 		if isAdminRole {
 			total, err = cygx.GetCygxArticleCollectCountByCompany(condition)
 			if err != nil {
@@ -2598,6 +2633,11 @@ func (this *UserController) CompanyTableDetail() {
 		}
 
 	} else if source == 5 {
+		if classType == 1 {
+			condition += " AND m.chart_permission_id  != 31 "
+		} else {
+			condition += " AND m.chart_permission_id  = 31 "
+		}
 		if isAdminRole {
 			total, err = cygx.GetCygxIndustryFllowCountByCompany(condition)
 			if err != nil {
@@ -2669,6 +2709,11 @@ func (this *UserController) CompanyTableDetail() {
 			}
 		}
 	} else if source == 7 {
+		if classType == 1 {
+			condition += " AND r.register_platform IN (1,2) "
+		} else {
+			condition += " AND r.register_platform IN (5,6) "
+		}
 		if isAdminRole {
 			total, err = cygx.GetCygxSearchKeyWordCountBuCompany(condition)
 			if err != nil {
@@ -2753,11 +2798,6 @@ func (this *UserController) CompanyTableDetail() {
 			}
 		}
 	} else if source == 10 { //标签点击记录
-		//condition = ``
-		//condition += `  AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' `
-		//if keyWord != "" {
-		//	condition += ` AND  (r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%'` + ` OR r.company_name LIKE '%` + keyWord + `%') `
-		//}
 		if isAdminRole {
 			total, err = cygx.GetCygxTagHistoryCount(condition)
 			if err != nil {
@@ -2785,6 +2825,69 @@ func (this *UserController) CompanyTableDetail() {
 				return
 			}
 		}
+	} else if source == 11 { //专栏文章阅读记录
+		if isAdminRole {
+			total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, startSize, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
+				return
+			}
+		} else {
+			total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, startSize, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
+				return
+			}
+		}
+		if len(list) > 0 {
+			for k, v := range list {
+				list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
+			}
+		}
+	} else if source == 12 { //收藏的专栏文章
+		if isAdminRole {
+			total, list, err = cygx.GetCygxYanxuanSpecialCollectByUser(condition, startSize, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
+				return
+			}
+		} else {
+			total, list, err = cygx.GetCygxYanxuanSpecialCollectByUserWeekly(condition, startSize, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
+				return
+			}
+		}
+		if len(list) > 0 {
+			for k, v := range list {
+				list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
+			}
+		}
+	} else if source == 13 { //关注的专栏作者
+		if isAdminRole {
+			total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUser(condition, startSize, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
+				return
+			}
+		} else {
+			total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUserWeekly(condition, startSize, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
+				return
+			}
+		}
+		if len(list) > 0 {
+			for k, v := range list {
+				list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
+			}
+		}
 	}
 
 	page := paging.GetPaging(currentIndex, pageSize, total)

+ 4 - 2
models/cygx/article_and_yanxuan_record.go

@@ -41,7 +41,7 @@ func GetCygxArticleAndYanxuanRecordCountWeekly(condition string, pars []interfac
 	o := orm.NewOrmUsingDB("hz_cygx")
 	databaseName := utils.GetWeeklyDatabase()
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_and_yanxuan_record as r 
-                             INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id
+                             INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id
 				  INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
 		WHERE 1= 1  `
 	sqlCount = fmt.Sprintf(sqlCount, databaseName)
@@ -55,7 +55,8 @@ func GetCygxArticleAndYanxuanRecordCountWeekly(condition string, pars []interfac
 // 列表
 func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleAndYanxuanRecordResp, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT * FROM cygx_article_and_yanxuan_record as r WHERE 1= 1 `
+	sql := `SELECT * FROM cygx_article_and_yanxuan_record as r 
+          INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id  WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
@@ -69,6 +70,7 @@ func GetCygxArticleAndYanxuanRecordRespListWeekly(condition string, pars []inter
 	o := orm.NewOrmUsingDB("hz_cygx")
 	databaseName := utils.GetWeeklyDatabase()
 	sql := `SELECT r.* FROM cygx_article_and_yanxuan_record as r 
+     		INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id 
 			INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
 		WHERE 1= 1   `
 	sql = fmt.Sprintf(sql, databaseName)

+ 114 - 0
models/cygx/cygx_user.go

@@ -1,6 +1,7 @@
 package cygx
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hz_crm_api/models/company"
@@ -498,6 +499,11 @@ func GetCygxYanxuaSspecialHistoryRecordByUser(condition string, startSize, pageS
 			art.publish_time AS publish_date,
 			r.create_time,
 			r.stop_time,
+			r.user_id,
+			r.mobile,
+			r.company_id,
+			r.company_name,
+			r.real_name,
 			r.register_platform AS source_platform,
 			art.type AS special_type,
 			art.industry_tags as  industry_name
@@ -520,6 +526,45 @@ func GetCygxYanxuaSspecialHistoryRecordByUser(condition string, startSize, pageS
 	return
 }
 
+// 用户阅读记录列表
+func GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.title,
+			art.id AS article_id,
+			art.publish_time AS publish_date,
+			r.create_time,
+			r.stop_time,
+			r.user_id,
+			r.mobile,
+			r.company_id,
+			r.company_name,
+			r.real_name,
+			r.register_platform AS source_platform,
+			art.type AS special_type,
+			art.industry_tags as  industry_name
+		FROM
+			cygx_yanxuan_special_record AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+	    	INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2
+		WHERE 1 = 1 ` + condition
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql += ` ORDER BY create_time DESC, article_id DESC   `
+	if startSize > 0 || pageSize > 0 {
+		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
+	}
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 用户阅读记录列表
 func GetCygxYanxuanSpecialCollectByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
@@ -551,6 +596,39 @@ func GetCygxYanxuanSpecialCollectByUser(condition string, startSize, pageSize in
 	return
 }
 
+// 用户阅读记录列表
+func GetCygxYanxuanSpecialCollectByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.title,
+			art.id AS article_id,
+			art.publish_time AS publish_date,
+			r.create_time,
+			r.register_platform AS source_platform,
+			art.type AS special_type,
+			art.industry_tags as  industry_name
+		FROM
+			cygx_yanxuan_special_collect AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+		    INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2
+		WHERE 1 = 1 ` + condition
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql += ` ORDER BY create_time DESC, article_id DESC   `
+	if startSize > 0 || pageSize > 0 {
+		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
+	}
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 用户阅读记录列表
 func GetCygxYanxuanSpecialAuthorByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
@@ -585,6 +663,42 @@ func GetCygxYanxuanSpecialAuthorByUser(condition string, startSize, pageSize int
 	return
 }
 
+// 用户阅读记录列表
+func GetCygxYanxuanSpecialAuthorByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.special_name as  title,
+			art.id AS department_id,
+			art.nick_name,
+			art.article_num,
+			art.fans_num,
+			art.company_id,
+			art.company_name,
+			art.mobile_init as  mobile,
+			r.create_time,
+			r.register_platform AS source_platform
+		FROM
+			cygx_yanxuan_special_follow AS r
+			INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
+		   INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2
+		WHERE 1 = 1 ` + condition
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql += ` ORDER BY create_time DESC, department_id DESC   `
+	if startSize > 0 || pageSize > 0 {
+		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
+	}
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 收藏列表数量
 func GetCygxArticleCollectCount(uid int, condition string) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")

+ 0 - 128
models/cygx/cygx_user_company.go

@@ -1105,134 +1105,6 @@ func GetCygxActivitySpecialTripByCompanyList(condition string, startSize, pageSi
 	return
 }
 
-// 通过纪要ID获取活动详情
-func GetTableCompanyList() (item *GetUserInteractionTableCountResp, err error) {
-	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT
-	SUM( article_history_num ) AS history_num,
-	SUM( article_count_num ) AS count_num,
-	SUM( industry_fllow_num ) AS industry_fllow_num,
-	SUM( department_follow_num ) AS department_follow_num,
-	SUM( key_word_num ) AS key_word_num,
-	SUM( activity_num ) AS activity_num,
-	SUM( chart_count_num ) AS chart_num 
-FROM
-	cygx_company_interaction_num 
-	LIMIT 1`
-	err = o.Raw(sql).QueryRow(&item)
-	return
-}
-
-// 获取用户参会记录根据销售分组
-func GetActivityMeetBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	return
-	o := orm.NewOrm()
-	sqlCount := `				SELECT
-				p.seller_id as admin_id,count(DISTINCT(r.company_id)) num,GROUP_CONCAT(DISTINCT r.company_id SEPARATOR ',') AS company_ids
-			FROM
-				cygx_activity_signup AS r
-				INNER JOIN cygx_activity AS a ON a.activity_id = r.activity_id
-				INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
-				INNER JOIN wx_user AS u ON u.user_id = r.user_id 
-				INNER JOIN company_product AS p ON p.company_id=r.company_id
-			WHERE
-				1 = 1 
-				AND r.do_fail_type = 0
-				AND p.product_id = 2
-				`
-	if condition != "" {
-		sqlCount += condition
-	}
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 收藏列表数量根据销售分组
-func GetCygxArticleCollectCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	return // 没有使用了
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id as admin_id,count(DISTINCT(r.company_id)) num,GROUP_CONCAT(DISTINCT r.company_id SEPARATOR ',') AS company_ids
-FROM
-	cygx_article_collect AS r
-	INNER JOIN cygx_article AS art ON art.article_id = r.article_id
-	INNER JOIN wx_user AS u ON u.user_id = r.user_id 
-	INNER JOIN company_product AS p ON p.company_id=r.company_id
-WHERE
-	1 = 1
-	AND p.product_id=2  ` + condition
-
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 关注产业数量根据销售分组
-func GetCygxIndustryFllowCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id AS admin_id,
-	count(
-	DISTINCT ( r.company_id )) num,
-	GROUP_CONCAT( DISTINCT r.company_id SEPARATOR ',' ) AS company_ids 
-FROM
-	cygx_industry_fllow AS r
-	INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = r.industrial_management_id
-	INNER JOIN wx_user AS u ON u.user_id = r.user_id
-	INNER JOIN company_product AS p ON p.company_id = r.company_id 
-WHERE
-	type = 1 
-	AND p.product_id = 2 
-  ` + condition
-
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 关注作者数量根据销售分组
-func GetCygArticleDepartmentFollowCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	return // 没有使用了
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id AS admin_id,
-	count(
-	DISTINCT ( r.company_id )) num,
-	GROUP_CONCAT( DISTINCT r.company_id SEPARATOR ',' ) AS company_ids 
-FROM
-	cygx_article_department_follow AS r
-	INNER JOIN cygx_article_department AS m ON m.department_id = r.department_id
-	INNER JOIN wx_user AS u ON u.user_id = r.user_id
-	INNER JOIN company_product AS p ON p.company_id = r.company_id 
-WHERE
-	type = 1 
-	AND p.product_id = 2  ` + condition
-
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 用户搜索关键词统计根据销售分组
-func GetCygxSearchKeyWordCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id AS admin_id,
-	count(
-	DISTINCT ( r.company_id )) num,
-	GROUP_CONCAT( DISTINCT r.company_id SEPARATOR ',' ) AS company_ids 
-FROM
-	cygx_search_key_word AS r 
-	INNER JOIN company_product AS p ON p.company_id = r.company_id 
-WHERE
-	1 = 1
-	AND p.product_id = 2  ` + condition
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
 type CompanyAndCount struct {
 	CompanyId int
 	Count     int