Browse Source

Merge branch 'cygx_4.0' of hongze/hongze_cygx into master

hongze 3 năm trước cách đây
mục cha
commit
c432bc92b1

+ 300 - 257
controllers/activity.go

@@ -3,8 +3,10 @@ package controllers
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/medivhzhan/weapp/v2"
 	"github.com/tealeg/xlsx"
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"os"
 	"path/filepath"
@@ -86,10 +88,10 @@ func (this *ActivityCoAntroller) ActivityList() {
 	activityTypeIds := this.GetString("ActivityTypeIds")
 	whichDay := this.GetString("WhichDay")
 	isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
-
 	keyWord := this.GetString("KeyWord")
 	activeState := this.GetString("ActiveState")
 	label := this.GetString("Label")
+
 	//入参为 undefined 时的处理
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
@@ -106,7 +108,7 @@ func (this *ActivityCoAntroller) ActivityList() {
 	if label == "undefined" {
 		label = ""
 	}
-
+	//更新用户的搜索信息
 	itemSearch := new(models.CygxActivityUserSearchContent)
 	itemSearch.UserId = uid
 	itemSearch.CreateTime = time.Now()
@@ -129,62 +131,7 @@ func (this *ActivityCoAntroller) ActivityList() {
 		return
 	}
 	utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*10)
-	var userType int
-	var permissionStr string
-	if user.CompanyId <= 1 {
-		userType = 0
-	} else {
-		total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		if total == 0 {
-			userType = 0
-		} else {
-			companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
-			if err != nil {
-				br.Msg = "获取信息失败!"
-				br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
-				return
-			}
-			if companyDetail == nil {
-				br.Msg = "获取信息失败!"
-				br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
-				return
-			}
-			permissionStr, err = models.GetCompanyPermission(user.CompanyId)
-			if err != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-				return
-			}
-			//1、永续客户
-			//2、大套餐客户(4个行业全开通的正式客户)
-			//3、分行业套餐客户(开通对应行业的正式客户)
-			//4、仅开通专家套餐的正式客户
-			//5、开通对应行业套餐或专家套餐的试用客户
-			if companyDetail.Status == "永续" {
-				userType = 1
-			} else if companyDetail.Status == "试用" {
-				userType = 5
-			} else if companyDetail.Status == "正式" {
-				if permissionStr == "专家" {
-					userType = 4
-				} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
-					userType = 2
-				} else {
-					userType = 3
-				}
-				if userType == 3 {
-					if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
-						userType = 4
-					}
-				}
-			}
-		}
-	}
+	userType, permissionStr, err := services.GetUserType(user.CompanyId)
 	if isShowJurisdiction == 1 && chartPermissionIds == "" && userType == 4 {
 		activityTypeIds = "1,3"
 	}
@@ -200,12 +147,18 @@ func (this *ActivityCoAntroller) ActivityList() {
 	var pars []interface{}
 	//活动可见限制
 	var sqlExport string
-
 	slicePer := strings.Split(permissionStr, ",")
 	var permissionSqlStr string
 	for _, v := range slicePer {
-		permissionSqlStr += "'" + v + "',"
+		if userType == 1 {
+			if v != "研选" {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
 	}
+
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
@@ -216,7 +169,6 @@ func (this *ActivityCoAntroller) ActivityList() {
 		sqlExport += ` OR  art.customer_type_ids LIKE '%4%' `
 	}
 	sqlExport += `) `
-
 	if keyWord != "" {
 		var mirrorword string
 		var mirrorwordSql string
@@ -263,7 +215,6 @@ func (this *ActivityCoAntroller) ActivityList() {
 		labelSqlStr = strings.TrimRight(labelSqlStr, ",")
 		condition = ` AND art.label  IN (` + labelSqlStr + `)`
 	}
-
 	//行业名称
 	if len(chartPermissionIds) > 0 {
 		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
@@ -293,10 +244,6 @@ func (this *ActivityCoAntroller) ActivityList() {
 	}
 	condition += ` AND art.publish_status = 1 `
 	var conditionOr string
-	//if strings.Contains(permissionStr, "专家") && (userType == 2 || userType == 3 || userType == 4) {
-	//conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + permissionSqlStr + condition + `) `
-	//conditionOr += ` OR (  art.is_limit_people = 1 AND art.activity_type_id = 3  AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
-	//}
 	// 有专家权限的这几种用户,不做行业权限校验
 	if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
 		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
@@ -304,7 +251,11 @@ func (this *ActivityCoAntroller) ActivityList() {
 	if (userType == 5) && strings.Contains(permissionStr, "专家") {
 		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
 	}
-	conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
+	if userType == 1 {
+		conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + permissionSqlStr + `) `
+	} else {
+		conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
+	}
 	condition += ` AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
 	total, err := models.GetActivityCount(condition, pars)
 	if err != nil {
@@ -312,7 +263,12 @@ func (this *ActivityCoAntroller) ActivityList() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	condition += ` ORDER BY art.active_state ASC, art.activity_time ASC  `
+	if activeState == "2" || activeState == "3" {
+		condition += ` ORDER BY art.activity_time DESC  `
+	} else {
+		condition += ` ORDER BY art.active_state ASC, art.activity_time ASC  `
+	}
+
 	list, errList := models.GetActivityListAll(condition, pars, uid, startSize, pageSize)
 	if errList != nil {
 		br.Msg = "获取失败"
@@ -326,6 +282,9 @@ func (this *ActivityCoAntroller) ActivityList() {
 		if v.SignupNum > v.LimitPeopleNum {
 			list[k].SignupNum = v.LimitPeopleNum
 		}
+		if services.GetShowSustainable() && v.ChartPermissionName == "研选" {
+			list[k].IsShowSustainable = true
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(models.GetCygxActivityListRep)
@@ -335,6 +294,7 @@ func (this *ActivityCoAntroller) ActivityList() {
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = resp
+
 }
 
 // @Title 我的日程
@@ -367,21 +327,70 @@ func (this *ActivityCoAntroller) ScheduleList() {
 	}
 	startSize = utils.StartIndex(currentIndex, pageSize)
 	var condition string
+	var conditionCount string
 	var pars []interface{}
-	//condition += ` AND art.publish_status = 1  AND art.active_state IN(1,2)	 AND s.is_cancel = 0  AND s.fail_type = 0  `
-	condition += ` AND art.publish_status = 1  AND art.active_state IN(1,2)	  `
-	total, err := models.GetScheduleCount(uid)
+	condition += ` AND art.publish_status = 1    `
+	total, err := models.GetScheduleCount(conditionCount, uid)
+	page := paging.GetPaging(currentIndex, pageSize, total)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	list, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
-	if errList != nil {
+	conditionCount = ` 	AND art.active_state = 2 `
+	totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
+	if err != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + errList.Error()
+		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	var list []*models.CygxActivityList
+	fmt.Println(totalCount)
+	//全部都是进行中的活动
+	if totalCount > currentIndex*pageSize {
+		condition += ` AND art.active_state IN(2) `
+		listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		list = listHave
+		if errList != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errList.Error()
+			return
+		}
+		fmt.Println("22222")
+	} else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
+		condition = `  AND art.publish_status = 1 AND art.active_state IN(2) `
+		listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		list = listHave
+		if errList != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errList.Error()
+			return
+		}
+		fmt.Println("33333")
+		pageSize = pageSize - len(listHave)
+		condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
+		listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		if errList != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errList.Error()
+			return
+		}
+		fmt.Println("长度", len(listOther))
+		if len(listOther) > 0 {
+			for _, v := range listOther {
+				list = append(list, v)
+			}
+		}
+	} else {
+		condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
+		listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		list = listOther
+		if errList != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errList.Error()
+			return
+		}
+	}
 	for k, v := range list {
 		if strings.Contains(v.ActivityName, "【") {
 			list[k].IsBrackets = 1
@@ -389,8 +398,11 @@ func (this *ActivityCoAntroller) ScheduleList() {
 		if v.SignupNum > v.LimitPeopleNum {
 			list[k].SignupNum = v.LimitPeopleNum
 		}
+		//是否展示限免标签
+		if services.GetShowSustainable() && v.ChartPermissionName == "研选" {
+			list[k].IsShowSustainable = true
+		}
 	}
-	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(models.GetCygxActivityListRep)
 	resp.List = list
 	resp.Paging = page
@@ -481,74 +493,32 @@ func (this *ActivityCoAntroller) Detail() {
 		}
 		companyDetailStatus = companyDetail.Status
 	}
-
-	var userType int
-	var permissionStr string
-	if user.CompanyId <= 1 {
-		userType = 0
-	} else {
-
-		companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
-			return
-		}
-		if companyDetail == nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
-			return
-		}
-		//1、永续客户
-		//2、大套餐客户(4个行业全开通的正式客户)
-		//3、分行业套餐客户(开通对应行业的正式客户)
-		//4、仅开通专家套餐的正式客户
-		//5、开通对应行业套餐或专家套餐的试用客户
-		if companyDetail.Status == "永续" {
-			userType = 1
-		} else if companyDetail.Status == "试用" {
-			userType = 5
-		} else if companyDetail.Status == "正式" {
-			permissionStr, err = models.GetCompanyPermission(user.CompanyId)
-			if err != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-				return
-			}
-			if permissionStr == "专家" {
-				userType = 4
-			} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
-				userType = 2
-			} else {
-				userType = 3
-			}
-		}
+	userType, permissionStr, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
 	}
 	if activityInfo.IsLimitPeople > 0 {
-		var noPower bool
-		if (userType == 1 || userType == 4 || userType == 5) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
-			noPower = true
-		}
-		//带有专家权限的 2、大套餐客户(4个行业全开通的正式客户)  3、分行业套餐客户(开通对应行业的正式客户)
-		if userType == 2 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
-			noPower = true
-		}
-		if userType == 2 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
-			noPower = true
-		}
-		if userType == 3 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
-			noPower = true
-		}
-		if userType == 3 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
-			noPower = true
+		noPower, err := services.GetShareNoPowe(activityInfo, permissionStr, userType)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+			return
 		}
 		if noPower {
 			br.Msg = "您暂无查看该活动权限"
-			br.ErrMsg = "被分享客户不可见,获取信息失败,Err:"
+			br.ErrMsg = "被分享客户不可见,获取信息失败"
 			return
 		}
 	}
-	fmt.Println("权限可见校验")
+
+	if userType == 1 && activityInfo.ChartPermissionName == "研选" {
+		br.Msg = "您暂无查看该活动权限"
+		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		return
+	}
+
 	detail, errDetail := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
 	if errDetail != nil {
 		br.Msg = "获取信息失败"
@@ -593,20 +563,7 @@ func (this *ActivityCoAntroller) Detail() {
 				return
 			}
 		}
-		//1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
-		//OperationMode     string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
-		var havePower bool
-		if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 {
-			havePower = true
-		} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") {
-			havePower = true
-		} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
-			havePower = true
-		} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
-			havePower = true
-		} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
-			havePower = true
-		}
+		havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
 		if havePower {
 			hasPermission = 1
 			resp.HaqveJurisdiction = true
@@ -633,6 +590,18 @@ func (this *ActivityCoAntroller) Detail() {
 		resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
 	}
 	if hasPermission == 1 {
+		//是否展示限免标签
+		if services.GetShowSustainable() && activityInfo.ChartPermissionName == "研选" {
+			activityInfo.IsShowSustainable = true
+		}
+		configCode := "description_of_research"
+		detail, err := models.GetConfigByCode(configCode)
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		activityInfo.Description = detail.ConfigValue
 		if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
 			activityInfo.SignupNum = activityInfo.LimitPeopleNum
 		}
@@ -743,48 +712,20 @@ func (this *ActivityCoAntroller) SignupAdd() {
 	}
 	var userType int
 	var permissionStr string
-	if user.CompanyId <= 1 {
-		userType = 0
-	} else {
-		companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
-			return
-		}
-		if companyDetail == nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
-			return
-		}
-		if companyDetail.Status == "永续" {
-			userType = 1
-		} else if companyDetail.Status == "试用" {
-			userType = 5
-		} else if companyDetail.Status == "正式" {
-			permissionStr, err = models.GetCompanyPermission(user.CompanyId)
-			if err != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-				return
-			}
-			if permissionStr == "专家" {
-				userType = 4
-			} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
-				userType = 2
-			} else {
-				userType = 3
-			}
-		}
+	userType, permissionStr, err = services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
 	}
+	if userType == 1 && activityInfo.ChartPermissionName == "研选" {
+		br.Msg = "您暂无查看该活动权限"
+		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		return
+	}
+
 	item := new(models.CygxActivitySignup)
 	if user.CompanyId > 1 {
-		permissionStr, err := models.GetCompanyPermission(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-			return
-		}
 		companyItem, err := models.GetCompanyDetailById(user.CompanyId)
 		//冻结客户
 		if err != nil {
@@ -805,17 +746,11 @@ func (this *ActivityCoAntroller) SignupAdd() {
 		}
 		//1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
 		//OperationMode     string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
-		var havePower bool
-		if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 {
-			havePower = true
-		} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") {
-			havePower = true
-		} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
-			havePower = true
-		} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
-			havePower = true
-		} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
-			havePower = true
+		havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
+		if err != nil {
+			br.Msg = "获取信息失败!"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
 		}
 		if havePower {
 			hasPermission = 1
@@ -1216,8 +1151,6 @@ func (this *ActivityCoAntroller) GetUserSearchContent() {
 	if detail.IsShowJurisdiction == 1 {
 		resp.IsShowJurisdiction = true
 	}
-	fmt.Println(isShowJurisdiction)
-
 	if isShowJurisdiction == 1 || detail.IsShowJurisdiction == 1 {
 		resp.IsShowJurisdiction = true
 		for k, _ := range listChartPermissionid {
@@ -1234,12 +1167,40 @@ func (this *ActivityCoAntroller) GetUserSearchContent() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	resp.ListChartPermission2 = list2
+
 	if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
 		activeStateList[0].IsChoose = true
 	}
+	var userType int
+	userType, _, err = services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	var listChartPermissionidNew2 []*models.ActivityChartPermission
+	for _, v := range list2 {
+		if userType == 1 {
+			if v.PermissionName != "研选" {
+				listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
+			}
+		} else {
+			listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
+		}
+	}
+	resp.ListChartPermission2 = listChartPermissionidNew2
+	var listChartPermissionidNew []*models.ActivityChartPermission
+	for _, v := range listChartPermissionid {
+		if userType == 1 {
+			if v.PermissionName != "研选" {
+				listChartPermissionidNew = append(listChartPermissionidNew, v)
+			}
+		} else {
+			listChartPermissionidNew = append(listChartPermissionidNew, v)
+		}
+	}
 	resp.ListActivityType = listActivityType
-	resp.ListChartPermission = listChartPermissionid
+	resp.ListChartPermission = listChartPermissionidNew
 	resp.ListActivityStaus = activeStateList
 	br.Ret = 200
 	br.Success = true
@@ -1338,53 +1299,23 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 	}
 	var userType int
 	var permissionStr string
-	if user.CompanyId <= 1 {
-		userType = 0
-	} else {
-		companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
-			return
-		}
-		if companyDetail == nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
-			return
-		}
-		if companyDetail.Status == "永续" {
-			userType = 1
-		} else if companyDetail.Status == "试用" {
-			userType = 5
-		} else if companyDetail.Status == "正式" {
-			permissionStr, err = models.GetCompanyPermission(user.CompanyId)
-			if err != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-				return
-			}
-			if permissionStr == "专家" {
-				userType = 4
-			} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
-				userType = 2
-			} else {
-				userType = 3
-			}
-		}
+	userType, permissionStr, err = services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if userType == 1 && activityInfo.ChartPermissionName == "研选" {
+		br.Msg = "您暂无查看该活动权限"
+		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		return
 	}
-
 	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
 	if time.Now().After(resultTime.Add(-time.Minute * 15)) {
 		br.Msg = "活动开始前15分钟无法设置会议提醒"
 		return
 	}
 	if user.CompanyId > 1 {
-		permissionStr, err := models.GetCompanyPermission(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-			return
-		}
 		companyItem, err := models.GetCompanyDetailById(user.CompanyId)
 		//冻结客户
 		if err != nil {
@@ -1404,17 +1335,11 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 			}
 		}
 
-		var havePower bool
-		if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 {
-			havePower = true
-		} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") {
-			havePower = true
-		} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
-			havePower = true
-		} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
-			havePower = true
-		} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
-			havePower = true
+		havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
+		if err != nil {
+			br.Msg = "获取信息失败!"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
 		}
 		if havePower {
 			hasPermission = 1
@@ -1712,8 +1637,17 @@ func (this *ActivityCoAntroller) LabelList() {
 	var sqlExport string
 	slicePer := strings.Split(permissionStr, ",")
 	var permissionSqlStr string
+	//for _, v := range slicePer {
+	//	permissionSqlStr += "'" + v + "',"
+	//}
 	for _, v := range slicePer {
-		permissionSqlStr += "'" + v + "',"
+		if userType == 1 {
+			if v != "研选" {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
 	}
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
@@ -1734,7 +1668,12 @@ func (this *ActivityCoAntroller) LabelList() {
 	if (userType == 5) && strings.Contains(permissionStr, "专家") {
 		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
 	}
-	conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
+	if userType == 1 {
+		conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + permissionSqlStr + `) `
+	} else {
+		conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
+	}
+	//conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
 	condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
 	resp := new(models.GetCygxActivityLabelListRep)
 	//conditionLaable := condition
@@ -1809,7 +1748,11 @@ func (this *ActivityCoAntroller) LabelList() {
 		if (userType == 5) && strings.Contains(permissionStr, "专家") {
 			conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
 		}
-		conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
+		if userType == 1 {
+			conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + permissionSqlStr + `) `
+		} else {
+			conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
+		}
 		condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
 	}
 	sortTime = ` mintimesort ASC `
@@ -1980,3 +1923,103 @@ func (this *ActivityCoAntroller) Import() {
 	br.Ret = 200
 	br.Success = true
 }
+
+// @Title 活动带问
+// @Description 新增活动带问接口
+// @Param	request	body models.AddCygxActivityHelpAsk true "type json string"
+// @Success Ret=200 新增成功
+// @router /askAdd [post]
+func (this *ActivityCoAntroller) AskAdd() {
+	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"
+		br.Ret = 408
+		return
+	}
+	var req models.CygxActivityHelpAsk
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.Content == "" {
+		br.Msg = "建议内容不可为空"
+		return
+	}
+
+	content := req.Content
+	itemToken, err := services.WxGetToken()
+	if err != nil {
+		br.Msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if itemToken.AccessToken == "" {
+		br.Msg = "accessToken is empty"
+		return
+	}
+	commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
+	if err != nil {
+		br.Msg = "内容校验失败!"
+		br.ErrMsg = "内容校验失败,Err:" + err.Error()
+
+		return
+	}
+	if commerr.ErrCode != 0 {
+		br.Msg = "内容违规,请重新提交!"
+		br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
+	if time.Now().After(resultTime.Add(-time.Minute * 60)) {
+		br.Msg = "活动开始前1小时内无法提交问题"
+		return
+	}
+	companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
+	if err != nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if companyDetail == nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
+		return
+	}
+	item := new(models.CygxActivityHelpAsk)
+	item.UserId = user.UserId
+	item.ActivityId = req.ActivityId
+	item.CompanyId = user.CompanyId
+	item.CompanyName = companyDetail.CompanyName
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.Content = content
+	_, err = models.AddActivityHelpAsk(item)
+	if err != nil {
+		br.Msg = "提交失败"
+		br.ErrMsg = "提交带问失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "提交成功"
+}

+ 291 - 47
controllers/article.go

@@ -3,10 +3,13 @@ package controllers
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/medivhzhan/weapp/v2"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"html"
+	"os"
+	"rdluck_tools/http"
 	"regexp"
 	"strconv"
 	"strings"
@@ -49,7 +52,7 @@ func (this *ArticleController) Detail() {
 	detail := new(models.ArticleDetail)
 	hasPermission := 0
 	hasFree := 0
-
+	var haveResearch bool
 	//判断是否已经申请过
 	applyCount, err := models.GetApplyRecordCount(uid)
 	if err != nil && err.Error() != utils.ErrNoRow() {
@@ -84,37 +87,6 @@ func (this *ArticleController) Detail() {
 			goto Loop
 		} else {
 			hasFree = 1
-			// 原有的权限校验 更改于 2021-05-18
-			//articlePermission, err := models.GetArticlePermission(detail.SubCategoryName)
-			//fmt.Println(articlePermission)
-			//fmt.Println(detail.SubCategoryName)
-			//if err != nil {
-			//	br.Msg = "获取信息失败"
-			//	br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
-			//	return
-			//}
-			//if articlePermission == nil {
-			//	br.Msg = "获取信息失败"
-			//	br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
-			//	return
-			//}
-			//for _, p := range articlePermission {
-			//	if strings.Contains(companyPermission, p.PermissionName) {
-			//		hasPermission = 1
-			//		historyRecord := new(models.CygxArticleHistoryRecord)
-			//		historyRecord.UserId = uid
-			//		historyRecord.ArticleId = articleId
-			//		historyRecord.CreateTime = time.Now()
-			//		historyRecord.Mobile = user.Mobile
-			//		historyRecord.Email = user.Email
-			//		historyRecord.CompanyId = user.CompanyId
-			//		historyRecord.CompanyName = user.CompanyName
-			//		go models.AddCygxArticleHistoryRecord(historyRecord)
-			//		break
-			//	} else { //无该行业权限
-			//		hasPermission = 3
-			//	}
-			//}
 			var articlePermissionPermissionName string
 			if detail.CategoryId > 0 {
 				articlePermission, err := models.GetArticlePermission(detail.CategoryId)
@@ -133,7 +105,26 @@ func (this *ArticleController) Detail() {
 				articlePermissionPermissionName = detail.CategoryName
 			}
 
-			if strings.Contains(companyPermission, articlePermissionPermissionName) {
+			var hasPersion bool
+			slice := strings.Split(articlePermissionPermissionName, ",")
+			for _, v := range slice {
+				if strings.Contains(companyPermission, v) {
+					hasPersion = true
+				}
+			}
+			if strings.Contains(detail.CategoryName, "研选") {
+				detail.IsResearch = true
+			}
+			userType, _, err := services.GetUserType(user.CompanyId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+				return
+			}
+			if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
+				hasPersion = false
+			}
+			if hasPersion {
 				hasPermission = 1
 				historyRecord := new(models.CygxArticleHistoryRecord)
 				historyRecord.UserId = uid
@@ -160,7 +151,6 @@ func (this *ArticleController) Detail() {
 			} else { //无该行业权限
 				hasPermission = 3
 			}
-
 			if hasPermission == 1 {
 				key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
 				if !utils.Rc.IsExist(key) {
@@ -179,6 +169,7 @@ func (this *ArticleController) Detail() {
 				}
 			}
 		}
+
 		collectCount, err := models.GetArticleCollectCount(uid, articleId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
@@ -210,23 +201,21 @@ func (this *ArticleController) Detail() {
 			detail.SellerName = sellerItem.RealName
 		}
 		sellerList, err := models.GetSellerList(articleId)
-		fmt.Println(err)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
 			return
 		}
-		if detail.ArticleId >= utils.SummaryArticleId {
-			var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
-			match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
-			if match != nil {
-				for _, v := range match {
-					sellerAndMobile := &models.SellerRep{
-						SellerMobile: v,
-						SellerName:   strings.Replace(detail.SellerAndMobile, v, "", -1),
-					}
-					sellerList = append(sellerList, sellerAndMobile)
+		if detail.ArticleId >= utils.SummaryArticleId && strings.Contains(detail.SellerAndMobile, "-") {
+			strnum := strings.Index(detail.SellerAndMobile, "-")
+			detail.SellerAndMobile = detail.SellerAndMobile[0:strnum]
+			if strnum > 0 {
+				nickName := detail.SellerAndMobile[0:strnum]
+				sellerAndMobile := &models.SellerRep{
+					SellerMobile: "",
+					SellerName:   nickName,
 				}
+				sellerList = append(sellerList, sellerAndMobile)
 			}
 		}
 		detail.SellerList = sellerList
@@ -241,9 +230,29 @@ Loop:
 	if hasPermission != 1 {
 		detail.Body = ""
 		detail.BodyText = ""
+	} else {
+		articleFollowdetail, err := models.GetArticleFollowDetail(articleId, uid)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取关注信息失败,Err:" + err.Error()
+			return
+		}
+		detail.FollowNum = articleFollowdetail.DNum
+		detail.CollectionNum = articleFollowdetail.AcNum
+		if articleFollowdetail.MdNum > 0 {
+			detail.IsFollow = true
+		}
+		if detail.IsSummary == 1 {
+			detail.IsBelongSummary = true
+		}
+		if detail.IsReport == 1 {
+			detail.IsBelongReport = true
+		}
+		haveResearch = true
 	}
 	resp := new(models.ArticleDetailResp)
 	resp.HasPermission = hasPermission
+	resp.HaveResearch = haveResearch
 	resp.HasFree = hasFree
 	resp.Detail = detail
 	br.Ret = 200
@@ -574,8 +583,14 @@ func (this *ArticleController) AddStopTime() {
 			} else {
 				articlePermissionPermissionName = detail.CategoryName
 			}
-
-			if strings.Contains(companyPermission, articlePermissionPermissionName) {
+			var hasPersion bool
+			slice := strings.Split(articlePermissionPermissionName, ",")
+			for _, v := range slice {
+				if strings.Contains(companyPermission, v) {
+					hasPersion = true
+				}
+			}
+			if hasPersion {
 				detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
 				if err == nil {
 					//br.Msg = "获取信息失败"
@@ -608,3 +623,232 @@ Loop:
 	br.Msg = "操作成功"
 	br.Data = resp
 }
+
+// @Title 文章带问
+// @Description 新增文章带问接口
+// @Param	request	body models.AddArticleAskRep true "type json string"
+// @Success Ret=200 新增成功
+// @router /askAdd [post]
+func (this *ArticleController) AskAdd() {
+	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"
+		br.Ret = 408
+		return
+	}
+	var req models.AddArticleAskRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.Content == "" {
+		br.Msg = "建议内容不可为空"
+		return
+	}
+
+	content := req.Content
+	itemToken, err := services.WxGetToken()
+	if err != nil {
+		br.Msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if itemToken.AccessToken == "" {
+		br.Msg = "accessToken is empty"
+		return
+	}
+	commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
+	if err != nil {
+		br.Msg = "内容校验失败!"
+		br.ErrMsg = "内容校验失败,Err:" + err.Error()
+
+		return
+	}
+	if commerr.ErrCode != 0 {
+		br.Msg = "内容违规,请重新提交!"
+		br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
+		return
+	}
+
+	articleId := req.ArticleId
+	count, _ := models.GetArticleCountById(articleId)
+	if count == 0 {
+		br.Msg = "操作失败"
+		br.ErrMsg = "文章ID错误,不存在 articleId:" + strconv.Itoa(articleId)
+		return
+	}
+	companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
+	if err != nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if companyDetail == nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
+		return
+	}
+	item := new(models.CygxArticleAsk)
+	item.UserId = user.UserId
+	item.ArticleId = req.ArticleId
+	item.CompanyId = user.CompanyId
+	item.CompanyName = companyDetail.CompanyName
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.Content = content
+	_, err = models.AddArticleAsk(item)
+	if err != nil {
+		br.Msg = "提交失败"
+		br.ErrMsg = "提交失败,Err:" + err.Error()
+		return
+	}
+	companyItem, err := models.GetCompanyDetailById(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取所属销售信息失败,Err:" + err.Error()
+		return
+	}
+	var mobile string
+	companyItem.Mobile = "123"
+	if utils.WxMsgTemplateIdAskMsgMobile == "" {
+		mobile = utils.WxMsgTemplateIdAskMsgMobileAll + "," + companyItem.Mobile
+	} else {
+		mobile = utils.WxMsgTemplateIdAskMsgMobile
+	}
+	openIdList, err := models.GetWxOpenIdByMobileList(mobile)
+	if err != nil {
+		br.Msg = "提交失败"
+		br.ErrMsg = "提交失败,Err:" + err.Error()
+		return
+	}
+	detail, err := models.GetArticleDetailById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	companyName := user.CompanyName + "-" + user.RealName + "(" + companyItem.SellerName + ")"
+	go services.SendWxMsgWithAsk(companyName, time.Now().Format(utils.FormatDateTime), content, detail.Title, openIdList, req.ArticleId)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "提交成功"
+}
+
+// @Title 下载PDF打水印
+// @Description 下载PDF打水印接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Success 200 {object} models.ArticleDetailFileLink
+// @router /pdfwatermark [get]
+func (this *ArticleController) Pdfwatermark() {
+	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
+	}
+
+	articleId, err := this.GetInt("ArticleId")
+	if articleId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	detail := new(models.ArticleDetail)
+	detail, err = models.GetArticleDetailById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	fileLink := detail.FileLink
+	if fileLink == "" {
+		br.Msg = "下载失败"
+		br.ErrMsg = "下载失败,报告链接不存在"
+		return
+	}
+	mobile := user.Mobile
+	if mobile == "" {
+		mobile = user.Email
+	}
+	dataMap := make(map[string]interface{})
+	dataMap["Mobile"] = mobile
+	//dataMap["Name"] = user.RealName
+	dataMap["Name"] = ""
+	dataMap["FileLink"] = fileLink
+	postUrl := "http://127.0.0.1:5007/pdfwatermark/" //
+	fmt.Println("postUrl:", postUrl)
+	postData, err := json.Marshal(dataMap)
+	if err != nil {
+		br.Msg = "获取postData数据失败"
+		br.ErrMsg = "解析,Marshal,Err:" + err.Error()
+		return
+	}
+	fmt.Println("publish ppt param:", string(postData))
+	result, err := http.Post(postUrl, string(postData))
+	if err != nil {
+		br.Msg = "发布失败"
+		br.ErrMsg = "Marshal,Err:" + err.Error()
+		return
+	}
+	fmt.Println("publish pdf result:", string(result))
+	var pdfResult PublishPdfResult
+	err = json.Unmarshal(result, &pdfResult)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "Unmarshal,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ArticleDetailFileLink)
+	filePathName := strings.TrimLeft(pdfResult.FilePath, ".")
+	filePathOldName := strings.TrimLeft(pdfResult.FileOldPath, ".")
+	filePath := pdfResult.Pdfpath + filePathName
+	filePathOld := pdfResult.Pdfpath + filePathOldName
+	fmt.Println(filePath)
+	fmt.Println(filePathOld)
+	randStr := utils.GetRandStringNoSpecialChar(28)
+	fileName := randStr + ".pdf"
+	hzUploadDir := "static/pdf/"
+	savePath := hzUploadDir + time.Now().Format("200601/20060102/")
+	savePath += fileName
+	//上传到阿里云
+	err = services.UploadFileToAliyun(fileName, filePath, savePath)
+	if err != nil {
+		br.Msg = "文件上传失败"
+		br.ErrMsg = "文件上传失败,Err:" + err.Error()
+		return
+	}
+	utils.FileLog.Info("%s:", time.Now().Format(utils.FormatDateTime))
+	utils.FileLog.Info("end update oss ")
+	fileHost := "https://hzstatic.hzinsights.com/"
+	resourceUrl := fileHost + savePath
+	defer func() {
+		os.Remove(filePath)
+		os.Remove(filePathOld)
+	}()
+	resp.FileLink = resourceUrl
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+type PublishPdfResult struct {
+	Result      string `json:"result"`
+	FilePath    string `json:"file_path"`
+	FileOldPath string `json:"file_old_path"`
+	Pdfpath     string `json:"pdfpath"`
+}

+ 93 - 5
controllers/chart_permission.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 )
 
@@ -18,19 +19,63 @@ type ChartPermissionAuthController struct {
 // @Description 获取用户详情接口
 // @Success 200 {object} models.ChartPermissionResp
 // @router /all [get]
-func (this *ChartPermissionController) Detail() {
+func (this *ChartPermissionAuthController) Detail() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	list, err := models.GetChartPermissionAll()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var condition string
+	var userType int
+	if user.CompanyId > 1 {
+		total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		if total == 0 {
+			userType = 0
+		} else {
+			companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
+			if err != nil {
+				br.Msg = "获取信息失败!"
+				br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+				return
+			}
+			if companyDetail.Status == "永续" {
+				userType = 1
+			}
+		}
+	}
+	if userType == 1 {
+		condition += ` AND permission_name  != '研选'`
+	}
+	list, err := models.GetChartPermissionAll(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
 	resp := new(models.ChartPermissionResp)
+	for k, v := range list {
+		if userType == 1 {
+			if v.PermissionName != "研选" {
+				resp.List = append(resp.List, v)
+			}
+		} else {
+			resp.List = append(resp.List, v)
+		}
+		if services.GetShowSustainable() && v.PermissionName == "研选" {
+			resp.List[k].IsShowSustainable = true
+		}
+	}
 	resp.List = list
 	br.Ret = 200
 	br.Success = true
@@ -42,20 +87,63 @@ func (this *ChartPermissionController) Detail() {
 // @Description 获取报告所有品种接口
 // @Success 200 {object} models.ChartPermissionResp
 // @router /reportall [get]
-func (this *ChartPermissionController) ReportDetail() {
+func (this *ChartPermissionAuthController) ReportDetail() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	list, err := models.GetChartPermissionReportAll()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var condition string
+	var userType int
+	if user.CompanyId > 1 {
+		total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		if total == 0 {
+			userType = 0
+		} else {
+			companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
+			if err != nil {
+				br.Msg = "获取信息失败!"
+				br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+				return
+			}
+			if companyDetail.Status == "永续" {
+				userType = 1
+			}
+		}
+	}
+	if userType == 1 {
+		condition += ` AND permission_name  != '研选'`
+	}
+	list, err := models.GetChartPermissionReportAll(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
 	resp := new(models.ChartPermissionResp)
-	resp.List = list
+	for k, v := range list {
+		if userType == 1 {
+			if v.PermissionName != "研选" {
+				resp.List = append(resp.List, v)
+			}
+		} else {
+			resp.List = append(resp.List, v)
+		}
+		if services.GetShowSustainable() && v.PermissionName == "研选" {
+			resp.List[k].IsShowSustainable = true
+		}
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 87 - 2
controllers/config.go

@@ -1,7 +1,9 @@
 package controllers
 
 import (
+	"encoding/json"
 	"hongze/hongze_cygx/models"
+	"time"
 )
 
 type ConfigController struct {
@@ -18,7 +20,7 @@ func (this *ConfigController) BrowseHistoryList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	configCode:="hot_search"
+	configCode := "hot_search"
 	detail, err := models.GetConfigByCode(configCode)
 	if err != nil {
 		br.Msg = "获取数据失败"
@@ -26,11 +28,94 @@ func (this *ConfigController) BrowseHistoryList() {
 		return
 	}
 	resp := new(models.ConfigResp)
-	resp.Item=detail
+	resp.Item = detail
 	br.Msg = "获取成功!"
 	br.Ret = 200
 	br.Success = true
 	br.Data = resp
 }
 
+// @Title 页面访问统计
+// @Description 上传页面访问统计
+// @Param	request	body models.CygxPageHistoryRecordRep true "type json string"
+// @Success Ret=200 新增成功
+// @router /pageHistory [post]
+func (this *ConfigController) PageHistory() {
+	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"
+		br.Ret = 408
+		return
+	}
+	var req models.CygxPageHistoryRecordRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	pageType := req.PageType
+	var havePageType bool
+	PageType := []string{"Summary", "SummarySearch", "Report", "ReportSearch", "IndustryList", "Activit", "ActivitSearch", "ActivitParticulars", "ReportParticulars"}
+	for _, v := range PageType {
+		if pageType == v {
+			havePageType = true
+		}
+	}
+	if !havePageType {
+		br.Msg = "新增失败"
+		br.ErrMsg = "PageType参数类型错误:" + pageType
+		return
+	}
+	item := new(models.CygxPageHistoryRecord)
+	item.UserId = user.UserId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.DetailId = req.DetailId
+	item.ChartPermissionId = req.ChartPermissionId
+	item.IndustrialManagementId = req.IndustrialManagementId
+	item.PageType = req.PageType
+	_, err = models.AddCygxPageHistoryRecord(item)
+	if err != nil {
+		br.Msg = "新增访问记录失败"
+		br.ErrMsg = "新增访问记录失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "新增成功"
+}
 
+// @Title 获取研选说明
+// @Description 获取研选说明接口
+// @Success 200 {object} models.ConfigResp
+// @router /descriptionOfResearch [get]
+func (this *ConfigController) DescriptionOfResearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	configCode := "description_of_research"
+	detail, err := models.GetConfigByCode(configCode)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ConfigResp)
+	resp.Item = detail
+	br.Msg = "获取成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 39 - 19
controllers/home.go

@@ -1,15 +1,15 @@
 package controllers
 
 import (
-	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"rdluck_tools/paging"
+	"strings"
 )
 
 type HomeController struct {
-	BaseCommonController
+	BaseAuthController
 }
 
 // @Title 首页列表接口
@@ -25,6 +25,13 @@ func (this *HomeController) ListHome() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	chartPermissionId, _ := this.GetInt("ChartPermissionId")
@@ -43,6 +50,13 @@ func (this *HomeController) ListHome() {
 	var total int
 	resp := new(models.HomeListResp)
 	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.HaveResearch = true
+	userType, _, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+		return
+	}
 	condition += ` AND is_summary = 1  `
 	if chartPermissionId > 0 {
 		categoryId, err := models.GetCategoryId(chartPermissionId)
@@ -57,30 +71,29 @@ func (this *HomeController) ListHome() {
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
+		if userType == 1 && categoryinfo.PermissionName == "研选" {
+			resp.HaveResearch = false
+			resp.Paging = page
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
 		page = paging.GetPaging(currentIndex, pageSize, total)
-		//if categoryId == "" {
-		//	list := make([]*models.HomeArticle, 0)
-		//	resp.List = list
-		//	resp.Paging = page
-		//	br.Ret = 200
-		//	br.Success = true
-		//	br.Msg = "获取成功"
-		//	br.Data = resp
-		//	return
-		//}
-
 		if categoryId != "" {
 			condition += ` AND category_id IN(` + categoryId + `)`
-			condition += ` OR ( category_name = '` + categoryinfo.PermissionName + `' AND publish_status = 1 AND is_summary = 1 )`
+			condition += ` OR ( category_name  LIKE '%` + categoryinfo.PermissionName + `%' AND publish_status = 1 AND is_summary = 1 )`
 		} else {
-			condition += ` AND  category_name = '` + categoryinfo.PermissionName + `'`
+			condition += ` AND  category_name   LIKE '%` + categoryinfo.PermissionName + `%'`
 		}
-
 	}
-
+	//永续客户无法查看研选分类的内容
+	if userType == 1 {
+		condition += ` AND  category_name  NOT LIKE '%研选` + `%'`
+	}
 	//condition = ` AND a.category_id NOT IN (85,71) `
-	fmt.Println(condition)
-	total, err := models.GetHomeCount(condition, pars)
+	total, err = models.GetHomeCount(condition, pars)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取帖子总数失败,Err:" + err.Error()
@@ -97,6 +110,13 @@ func (this *HomeController) ListHome() {
 	for i := 0; i < lenList; i++ {
 		item := list[i]
 		list[i].Body, _ = services.GetReportContentTextSub(item.Body)
+		list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDateTimeNoSecond) //时间字符串格式转时间格式
+		if strings.Contains(item.CategoryName, "研选") {
+			list[i].IsResearch = true
+		}
+		if item.Pv > 999 {
+			list[i].Pv = 999
+		}
 	}
 	resp.List = list
 	resp.Paging = page

+ 511 - 56
controllers/report.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_cygx/utils"
 	"rdluck_tools/paging"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -94,6 +95,7 @@ func (this *ReportController) IndustryList() {
 	}
 	uid := user.UserId
 
+	fmt.Println(uid)
 	ChartPermissionId, _ := this.GetInt("ChartPermissionId")
 	orderColumn := this.GetString("OrderColumn")
 	isNewLabel := this.GetString("IsNewLabel")
@@ -111,6 +113,7 @@ func (this *ReportController) IndustryList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
+
 	startSize = paging.StartIndex(currentIndex, pageSize)
 	if isNewLabel == "1" {
 		condition += ` AND is_new_label = ` + isNewLabel
@@ -157,74 +160,91 @@ func (this *ReportController) IndustryList() {
 		condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
 	}
 
-	var total int
+	//var total int
 	var list []*models.IndustrialManagement
-	totalTopList, errTop := models.GetIndustrialManagemenCountTop(sqlChartPermissionId, uid, condition)
-	totalTop := len(totalTopList)
-	if errTop != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + errTop.Error()
-		return
-	}
-	totalNoTopList, errNoTop := models.GetIndustrialManagemenCountNoTop(sqlChartPermissionId, uid, condition)
-	totalNoTop := len(totalNoTopList)
-	if errNoTop != nil {
+	//totalTopList, errTop := models.GetIndustrialManagemenCountTop(sqlChartPermissionId, uid, condition)
+	//totalTop := len(totalTopList)
+	//if errTop != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取品种信息失败,Err:" + errTop.Error()
+	//	return
+	//}
+	//totalNoTopList, errNoTop := models.GetIndustrialManagemenCountNoTop(sqlChartPermissionId, uid, condition)
+	//totalNoTop := len(totalNoTopList)
+	//if errNoTop != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取品种信息失败,Err:" + errNoTop.Error()
+	//	return
+	//}
+	total, err := models.GetIndustrialManagementAllCount(condition)
+	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + errNoTop.Error()
+		br.ErrMsg = "获取数量失败,Err:" + err.Error()
 		return
 	}
-	total = totalTop + totalNoTop
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	if orderColumn == "" {
 		orderColumn = "NewTime"
 	}
-	//if ChartPermissionId < 1 {
-	//	br.Msg = "请输入分类ID"
-	//	return
-	//}
 	if orderColumn == "NewTime" {
 		orderSrt = "update_time DESC"
 	} else {
 		orderSrt = "man.recommended_index DESC,update_time DESC"
 	}
-	fmt.Println(orderSrt)
 	//全部都是置顶
-	if totalTop >= currentIndex*pageSize {
-		listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
-		for k, _ := range listTop {
-			listTop[k].IsTop = true
-		}
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-		list = listTop
-	} else if totalTop < (currentIndex-1)*pageSize { //全部都是不置顶
-		listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize-totalTop, pageSize)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-		list = listNoTop
-	} else { //部分置顶,部分不置顶
-		listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-		for k, _ := range listTop {
-			listTop[k].IsTop = true
-		}
-		listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, pageSize-len(listTop))
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-		list = append(listTop, listNoTop...)
+	//if totalTop >= currentIndex*pageSize {
+	//	listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
+	//	for k, _ := range listTop {
+	//		listTop[k].IsTop = true
+	//	}
+	//	if err != nil {
+	//		br.Msg = "获取信息失败"
+	//		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	list = listTop
+	//} else if totalTop < (currentIndex-1)*pageSize { //全部都是不置顶
+	//	listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize-totalTop, pageSize)
+	//	if err != nil {
+	//		br.Msg = "获取信息失败"
+	//		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	list = listNoTop
+	//} else { //部分置顶,部分不置顶
+	//	listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
+	//	if err != nil {
+	//		br.Msg = "获取信息失败"
+	//		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	for k, _ := range listTop {
+	//		listTop[k].IsTop = true
+	//	}
+	//	listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, pageSize-len(listTop))
+	//	if err != nil {
+	//		br.Msg = "获取信息失败"
+	//		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	list = append(listTop, listNoTop...)
+	//}
+
+	if ChartPermissionId == 0 {
+		ChartPermissionId = 20
+	}
+	detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+
+	list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
 	}
 	for k, v := range list {
 		//var analystStr string
@@ -262,10 +282,12 @@ func (this *ReportController) IndustryList() {
 			br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
 			return
 		}
-		//
 		if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
 			list[k].IsRed = true
 		}
+		if v.ArticleReadNum >= detailHot3.ArticleReadNum {
+			list[k].IsHot = true
+		}
 	}
 	resp.List = list
 	resp.Paging = page
@@ -447,7 +469,6 @@ func (this *ReportController) ArticleCollect() {
 		return
 	}
 	industrialManagementId := req.IndustrialManagementId
-	fmt.Println(industrialManagementId)
 	countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
 	if err != nil {
 		br.Msg = "获取数据失败!"
@@ -493,3 +514,437 @@ func (this *ReportController) ArticleCollect() {
 	br.Success = true
 	br.Data = resp
 }
+
+// @Title 关注/取消关注产业
+// @Description 关注/取消关注 接口
+// @Param	request	body models.CygxIndustryFllowRep true "type json string"
+// @Success 200
+// @router /fllow [post]
+func (this *ReportController) Fllow() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.CygxIndustryFllowRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	industrialManagementId := req.IndustrialManagementId
+	var condition string
+	countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	if countIndustrial == 0 {
+		br.Msg = "产业不存在!"
+		br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
+		return
+	}
+	count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.CygxIndustryFllowResp)
+	countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
+	if countUser == 0 {
+		resp.GoFollow = true
+	}
+	if count == 0 {
+		item := new(models.CygxIndustryFllow)
+		item.IndustrialManagementId = industrialManagementId
+		item.UserId = uid
+		item.Email = user.Email
+		item.Mobile = user.Mobile
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.Type = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		_, err = models.AddCygxIndustryFllow(item)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 1
+	} else {
+		var doType int
+		condition = ` AND type = 1`
+		count, err = models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		if count == 1 {
+			resp.Status = 2
+			doType = 2
+		} else {
+			resp.Status = 1
+			doType = 1
+		}
+		err = models.RemoveCygxIndustryFllow(uid, industrialManagementId, doType)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "取消关注失败,Err:" + err.Error()
+			return
+		}
+	}
+	br.Msg = "操作成功"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 产业报告分类关联作者列表接口
+// @Description 获取产业报告分类关联作者列表接口
+// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.CygxArticleDepartmentList
+// @router /industryListByDepartment [get]
+func (this *ReportController) IndustryListByDepartment() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	var startSize int
+	var condition string
+	condition = `	AND a.is_report = 1  AND a.publish_status=1  AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	total, err := models.GetArticleDepartmentCount(condition)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.CygxArticleDepartmentList)
+	userType, _, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+		return
+	}
+	if userType == 1 {
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	resp.HaveResearch = true
+	//获取作者信息,并排序
+	list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
+			return
+		}
+		for k2, v2 := range artList {
+			subjectNames, err := models.GetSubjectNames(v2.ArticleId)
+			if err != nil {
+				br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			var subjectNamesNew string
+			if len(subjectNames) > 0 {
+				slice := strings.Split(subjectNames, "/")
+				for k3, v3 := range slice {
+					if k3 < 4 {
+						subjectNamesNew += v3 + "/"
+					}
+				}
+			}
+			industryName, err := models.GetIndustrialNames(v2.ArticleId)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
+			artList[k2].SubjectName = subjectNamesNew
+			artList[k2].DepartmentId = v.DepartmentId
+			artList[k2].IndustryName = industryName + "-" + subjectNamesNew
+		}
+		list[k].List = artList
+		if v.FollowNum > 0 {
+			list[k].IsMyFollow = true
+		}
+	}
+	resp.ListnNew, err = models.GetIndustrialSubjectByDepartmentNew(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 关注作者/取消关注作者
+// @Description 关注作者/取消关注作者 接口
+// @Param	request	body models.CygxArticleDepartmentId true "type json string"
+// @Success 200
+// @router /fllowDepartment [post]
+func (this *ReportController) FllowDepartment() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.CygxArticleDepartmentId
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	departmentId := req.DepartmentId
+	var condition string
+	countDepartment, err := models.GetDepartmentCount(departmentId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	if countDepartment == 0 {
+		br.Msg = "作者不存在!"
+		br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
+		return
+	}
+	countUser, err := models.GetArticleDepartmentFollowByUid(uid)
+	count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.CygxArticleDepartmentFollowResp)
+	if countUser == 0 {
+		resp.GoFollow = true
+	}
+	if count == 0 {
+		item := new(models.CygxArticleDepartmentFollow)
+		item.DepartmentId = departmentId
+		item.UserId = uid
+		item.Email = user.Email
+		item.Mobile = user.Mobile
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.Type = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		_, err = models.AddArticleDepartmentFollow(item)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 1
+	} else {
+		var doType int
+		condition = ` AND type = 1`
+		count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		if count == 1 {
+			resp.Status = 2
+			doType = 2
+		} else {
+			resp.Status = 1
+			doType = 1
+		}
+		err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "取消关注失败,Err:" + err.Error()
+			return
+		}
+	}
+	br.Msg = "操作成功"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 研选文章列表接口
+// @Description 获取研选文章列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ArticleId      query   int  true       "文章id"
+// @Param   DepartmentId   query   int  true       "作者ID"
+// @Param   IndustrialManagementId   query   int  true       "产业ID"
+// @Success 200 {object} models.ReportArticleWhichIndustrialRepList
+// @router /industry/reportList [get]
+func (this *ReportController) ReportList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	departmentId, _ := this.GetInt("DepartmentId")
+	industrialManagementId, _ := this.GetInt("IndustrialManagementId")
+	articleId, _ := this.GetInt("ArticleId")
+	var condition string
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	var pars []interface{}
+	var total int
+	resp := new(models.ReportArticleWhichIndustrialRepList)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	userType, _, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+		return
+	}
+	if userType == 1 {
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	resp.HaveResearch = true
+	if departmentId > 0 {
+		condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
+		detail, err := models.GetArticleDepartmentDateilById(departmentId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		resp.NickName = detail.NickName
+	}
+	if industrialManagementId > 0 {
+		condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
+	}
+	if articleId > 0 {
+		detail, err := models.GetArticleDetailById(articleId)
+
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
+	}
+	total, err = models.GetWhichDepartmentCount(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+		return
+	}
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	condition += ` AND art.is_report =1 	GROUP BY art.article_id ORDER BY art.publish_date DESC`
+	list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		if v.Readnum == 0 {
+			list[k].IsRed = true
+		}
+		list[k].IsResearch = true
+		subjectNames, err := models.GetSubjectNames(v.ArticleId)
+		if err != nil {
+			br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		var subjectNamesNew string
+		if len(subjectNames) > 0 {
+			slice := strings.Split(subjectNames, "/")
+			for k3, v3 := range slice {
+				if k3 < 4 {
+					subjectNamesNew += v3 + "/"
+				}
+			}
+		}
+		industryName, err := models.GetIndustrialNames(v.ArticleId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
+		list[k].SubjectName = subjectNamesNew
+		list[k].IndustryName = industryName + "-" + subjectNamesNew
+		resp.IndustryName = industryName
+	}
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 13 - 8
models/activity.go

@@ -90,6 +90,8 @@ type ActivityDetail struct {
 	IsCancelMeetingReminder int    `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
 	ArticleId               int    `description:"报告id(报告链接跳转使用)"`
 	CustomerTypeIds         string `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	IsShowSustainable       bool   `description:"是否展示限免标签"`
+	Description             string `description:"研选内容说明"`
 }
 
 type CygxActivityResp struct {
@@ -146,6 +148,7 @@ type CygxActivityList struct {
 	IsCancelMeetingReminder int    `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
 	IsBrackets              int    `description:"是否有方括号 1是 ,0 否"`
 	Label                   string `description:"主题标签"`
+	IsShowSustainable       bool   `description:"是否展示限免标签"`
 }
 
 type GetCygxActivityListRep struct {
@@ -181,14 +184,16 @@ func GetActivityCount(condition string, pars []interface{}) (count int, err erro
 }
 
 //获取我的日程数量
-func GetScheduleCount(uid int) (count int, err error) {
+func GetScheduleCount(condition string, uid int) (count int, err error) {
 	o := orm.NewOrm()
-	//sqlCount := ` SELECT COUNT( 1 ) AS count  FROM cygx_activity AS art  INNER JOIN cygx_activity_signup as s ON s.activity_id = art.activity_id
-	//				WHERE  	s.user_id = ?  AND s.is_cancel = 0 `
-	//if condition != "" {
-	//	sqlCount += condition
-	//}
-	sqlCount := ` SELECT COUNT( 1 ) AS count  FROM cygx_my_schedule WHERE user_id = ?`
+	sqlCount := `SELECT COUNT( 1 ) AS count 
+				FROM cygx_my_schedule AS m
+				INNER JOIN cygx_activity AS art ON art.activity_id = m.activity_id 
+				WHERE
+				user_id = ?`
+	if condition != "" {
+		sqlCount += condition
+	}
 	err = o.Raw(sqlCount, uid).QueryRow(&count)
 	return
 }
@@ -205,7 +210,7 @@ func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageS
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` ORDER BY art.active_state DESC,art.activity_time ASC  LIMIT ?,?`
+	sql += ` ORDER BY art.active_state ASC,art.activity_time ASC  LIMIT ?,?`
 	_, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 30 - 0
models/activity_help_ask.go

@@ -0,0 +1,30 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type CygxActivityHelpAsk struct {
+	AskId       int       `orm:"column(ask_id);pk" description:"带问id"`
+	UserId      int       `description:"用户id"`
+	ActivityId  int       `description:"活动id"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	Content     string    `description:"内容"`
+}
+
+//添加优化建议
+func AddActivityHelpAsk(item *CygxActivityHelpAsk) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type AddCygxActivityHelpAsk struct {
+	ActivityId int    `description:"活动id"`
+	Content    string `description:"内容"`
+}

+ 1 - 1
models/activity_user_search_content.go

@@ -21,7 +21,7 @@ type CygxActivityUserSearchContent struct {
 	IsShowJurisdiction int       `description:"是否仅展示有权限的,1是,0否"`
 }
 
-//添加报名信息
+//更新搜索信息
 func AddUserSearchContent(item *CygxActivityUserSearchContent, ttlTime time.Duration) (lastId int64, err error) {
 	o := orm.NewOrm()
 	o.Begin()

+ 43 - 2
models/article.go

@@ -79,6 +79,8 @@ type HomeArticle struct {
 	CategoryName     string `description:"一级分类"`
 	SubCategoryName  string `description:"二级分类"`
 	ExpertBackground string `description:"专家背景"`
+	IsResearch       bool   `description:"是否属于研选"`
+	Pv               int    `description:"PV"`
 }
 
 type ArticleDetail struct {
@@ -107,11 +109,22 @@ type ArticleDetail struct {
 	CategoryId           int    `description:"分类ID"`
 	IsSummary            int    `description:"是否是纪要库,1是,0否"`
 	IsReport             int    `description:"是否属于报告,1是,0否"`
+	IsResearch           bool   `description:"是否属于研选"`
 	FileLink             string `description:"下载预览链接"`
 	SellerAndMobile      string `description:"销售和手机号"`
+	IsFollow             bool   `description:"是否关注,1是,0否"`
+	IsBelongSummary      bool   `description:"是否属于纪要库"`
+	IsBelongReport       bool   `description:"是否属于报告"`
+	FollowNum            int    `description:"关注数量"`
+	CollectionNum        int    `description:"收藏数量"`
+	DepartmentId         int    `description:"作者ID"`
+	SubjectIds           string `description:"文章关联标的的ID字符串"`
 	SellerList           []*SellerRep
 }
 
+type ArticleDetailFileLink struct {
+	FileLink string `description:"下载预览链接"`
+}
 type SellerRep struct {
 	SellerMobile string `description:"销售手机号"`
 	SellerName   string `description:"销售名称"`
@@ -177,8 +190,9 @@ func GetArticlePermission(companyId int) (item *ChartPermission, err error) {
 
 type ArticleDetailResp struct {
 	Detail        *ArticleDetail
-	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
-	HasFree       int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
+	HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	HasFree       int  `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
+	HaveResearch  bool `description:"是否有研选权限"`
 }
 
 func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {
@@ -376,3 +390,30 @@ func GetCustomArticleId() (item []*ArticleId, err error) {
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
 }
+
+type ArticleFollowDetail struct {
+	DNum   int `description:"作者被关注的数量"`
+	MdNum  int `description:"本人是否关注这个作者"`
+	AcNum  int `description:"文章被收藏的数量"`
+	MacNum int `description:"本人是否收藏这个文章"`
+}
+
+//获取文章被关注被收藏的详情
+func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err error) {
+	//d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
+	o := orm.NewOrm()
+	sql := ` SELECT
+	( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.department_id = art.department_id AND af.type = 1 ) AS d_num,
+	( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.department_id = art.department_id AND af.type = 1 AND af.user_id = ? ) AS md_num,
+	( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id  ) AS ac_num,
+	( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id  AND ac.user_id = ? ) AS mac_num
+FROM
+	cygx_article AS art
+	LEFT JOIN cygx_article_department_follow AS af ON af.department_id = art.department_id
+	LEFT JOIN cygx_article_collect AS ac ON ac.article_id = art.article_id 
+WHERE
+	art.article_id = ?
+	GROUP BY art.article_id `
+	err = o.Raw(sql, uid, uid, articleId).QueryRow(&item)
+	return
+}

+ 30 - 0
models/article_ask.go

@@ -0,0 +1,30 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type CygxArticleAsk struct {
+	AskId       int       `orm:"column(ask_id);pk" description:"带问id"`
+	UserId      int       `description:"用户id"`
+	ArticleId   int       `description:"文章id"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	Content     string    `description:"内容"`
+}
+
+//添加优化建议
+func AddArticleAsk(item *CygxArticleAsk) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type AddArticleAskRep struct {
+	ArticleId int    `description:"文章id"`
+	Content   string `description:"内容"`
+}

+ 219 - 0
models/article_department.go

@@ -0,0 +1,219 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"rdluck_tools/paging"
+	"time"
+)
+
+type CygxArticleDepartment struct {
+	DepartmentId int       `orm:"column(department_id);pk;主键ID"`
+	CreateTime   time.Time `description:"创建时间"`
+	NickName     string    `description:"昵称"`
+	Remark       string    `description:"备注"`
+	Remarks      string    `description:"备注辅助字段"`
+	Content      string    `description:"初始内容"`
+}
+
+type CygxArticleDepartmentRep struct {
+	DepartmentId int    `description:"作者ID"`
+	CreateTime   string `description:"创建时间"`
+	NickName     string `description:"昵称"`
+	ImgUrl       string `description:"头像链接"`
+	FollowNum    int    `description:"是否关注 1是 ,0 否"`
+	IsMyFollow   bool   `description:"是否关注"`
+	List         []*IndustrialManagementIdName
+}
+
+type CygxArticleDepartmentId struct {
+	DepartmentId int `description:"作者ID"`
+}
+
+type CygxArticleDepartmentList struct {
+	HaveResearch bool               `description:"是否有研选权限"`
+	Paging       *paging.PagingItem `description:"分页数据"`
+	ListnNew     []*IndustrialManagementIdInt
+	List         []*CygxArticleDepartmentRep
+}
+
+//详情
+func GetArticleDepartmentDateil(nickName, remarks string) (item *CygxArticleDepartmentRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_department WHERE nick_name = ? AND  remarks = ? LIMIT 1 `
+	err = o.Raw(sql, nickName, remarks).QueryRow(&item)
+	return
+}
+
+func GetArticleDepartmentDateilById(departmentId int) (item *CygxArticleDepartmentRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_department WHERE department_id = ? `
+	err = o.Raw(sql, departmentId).QueryRow(&item)
+	return
+}
+
+//数量
+func GetArticleDepartmentCount(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT COUNT(*) count
+		FROM
+		( SELECT COUNT(1)  FROM cygx_article_department AS d
+		INNER JOIN cygx_article AS a ON a.department_id = d.department_id
+		INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+		INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY d.department_id ) AS num `
+
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
+//列表
+func GetCygxArticleDepartmentList(startSize, pageSize int, condition string, uid int) (items []*CygxArticleDepartmentRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT d.*,
+		( SELECT COUNT( 1 ) FROM cygx_article AS a INNER JOIN cygx_article_history_record as h ON h.article_id = a.article_id WHERE  a.department_id = d.department_id  AND a.publish_status = 1  AND a.is_report = 1  ) AS art_num,
+		( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS f  WHERE f.department_id = d.department_id AND f.user_id = ? AND f.type = 1 ) AS follow_num
+		FROM
+		cygx_article_department AS d
+		INNER JOIN cygx_article AS a ON a.department_id = d.department_id
+		INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+		INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY
+		d.department_id
+		ORDER BY  art_num DESC  LIMIT ?,?`
+	_, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//产业列表
+func GetIndustrialSubjectByDepartment(departmentId int) (items []*IndustrialManagementIdInt, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.*,
+			( SELECT GROUP_CONCAT(DISTINCT s.subject_name ORDER BY s.create_time DESC SEPARATOR '/' ) FROM cygx_industrial_subject AS s WHERE s.industrial_management_id = m.industrial_management_id) AS subject_name,
+			( SELECT publish_date FROM cygx_article AS a INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = a.article_id  ORDER BY publish_date DESC LIMIT 1  ) AS art_time
+		FROM
+			cygx_article_department AS d
+			INNER JOIN cygx_article AS a ON a.department_id = d.department_id
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id 
+			WHERE 1= 1
+			AND d.department_id = ?
+			AND a.publish_status = 1
+			GROUP BY a.article_id
+			ORDER BY art_time DESC
+			LIMIT 4 `
+	_, err = o.Raw(sql, departmentId).QueryRows(&items)
+	return
+}
+
+//最新产业列表
+func GetIndustrialSubjectByDepartmentNew(industrialManagementId int) (items []*IndustrialManagementIdInt, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT m.*, MAX( a.publish_date ) art_time
+			FROM
+			cygx_article_department AS d
+			INNER JOIN cygx_article AS a ON a.department_id = d.department_id
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id 
+			WHERE 1 = 1 
+			AND m.chart_permission_id = ?
+			AND a.publish_status=1 
+			AND a.subject_ids != ''
+			AND a.is_report=1 
+			GROUP BY
+			m.industrial_management_id 
+			ORDER BY art_time DESC LIMIT 6 `
+	_, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
+	return
+}
+
+//获取作者数量
+func GetDepartmentCount(departmentId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_department WHERE department_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, departmentId).QueryRow(&count)
+	return
+}
+
+type IndustrialSubjectList struct {
+	SubjectName string `description:"标的名称"`
+}
+
+//最新标的列表
+func GetIndustrialSubjectNewList(condition string) (items []*IndustrialSubjectList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT s.*
+			FROM
+				cygx_industrial_subject AS s
+				INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.industrial_subject_id = s.industrial_subject_id
+				INNER JOIN cygx_article AS art ON art.article_id = sg.article_id
+				INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = art.article_id
+			WHERE
+				1 = 1 
+				AND art.publish_status = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY s.industrial_subject_id ORDER BY s.create_time DESC LIMIT 4`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//最新标的列表
+func GetIndustrialSubjectNewListByDepartmentId(departmentId, industrialManagementId int) (items []*IndustrialManagementIdName, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT art.article_id,
+			( SELECT GROUP_CONCAT( DISTINCT s.subject_name ORDER BY s.industrial_subject_id DESC SEPARATOR '/' )  ) AS subject_name
+			FROM
+				cygx_article AS art
+				INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
+				INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id 
+			WHERE
+				department_id = ?
+				AND s.industrial_management_id = ?
+				GROUP BY art.article_id
+				ORDER BY s.create_time DESC  LIMIT 4`
+	_, err = o.Raw(sql, departmentId, industrialManagementId).QueryRows(&items)
+	return
+}
+
+//最新标的列表
+func GetArticleByDepartmentId(departmentId int) (items []*IndustrialManagementIdName, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT article_id,	MAX( publish_date ) art_time  FROM cygx_article WHERE department_id = ? AND  publish_status = 1 AND subject_ids != '' GROUP  BY subject_ids  ORDER BY art_time DESC  LIMIT 4 `
+	_, err = o.Raw(sql, departmentId).QueryRows(&items)
+	return
+}
+
+func GetSubjectNames(articleId int) (subjects string, err error) {
+	sql := ` SELECT GROUP_CONCAT( DISTINCT s.subject_name ORDER BY id ASC SEPARATOR '/' ) AS subject_name 
+				FROM
+				cygx_industrial_article_group_subject as sg 
+				INNER JOIN cygx_industrial_subject as  s ON s.industrial_subject_id = sg.industrial_subject_id 
+				WHERE article_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sql, articleId).QueryRow(&subjects)
+	return
+}
+
+func GetIndustrialNames(articleId int) (Industrial string, err error) {
+	sql := ` SELECT
+	m.industry_name
+FROM
+	cygx_industrial_article_group_management as mg 
+	INNER JOIN cygx_industrial_management as  m ON m.industrial_management_id = mg.industrial_management_id 
+WHERE
+	mg.article_id = ?
+	ORDER BY  m.industrial_management_id DESC
+	LIMIT 1
+`
+	o := orm.NewOrm()
+	err = o.Raw(sql, articleId).QueryRow(&Industrial)
+	return
+}

+ 56 - 0
models/article_department_follow.go

@@ -0,0 +1,56 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type CygxArticleDepartmentFollow struct {
+	Id           int       `orm:"column(id);pk"`
+	DepartmentId int       `description:"作者ID"`
+	UserId       int       `description:"用户ID"`
+	Mobile       string    `description:"手机号"`
+	Email        string    `description:"邮箱"`
+	CompanyId    int       `description:"公司id"`
+	CompanyName  string    `description:"公司名称"`
+	Type         int       `description:"操作方式,1报名,2取消报名"`
+	CreateTime   time.Time `description:"创建时间"`
+	ModifyTime   time.Time `description:"更新时间"`
+}
+
+type ArticleDepartmentIdRep struct {
+	DepartmentId int `description:"作者ID"`
+}
+
+//添加
+func AddArticleDepartmentFollow(item *CygxArticleDepartmentFollow) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type CygxArticleDepartmentFollowResp struct {
+	Status   int  `description:"1:关注,2:取消关注"`
+	GoFollow bool `description:"是否去关注"`
+}
+
+func RemoveArticleDepartmentFollow(userId, industrialManagementId, doType int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_article_department_follow SET type = ? ,modify_time=? WHERE user_id=? AND department_id=? `
+	_, err = o.Raw(sql, doType, time.Now(), userId, industrialManagementId).Exec()
+	return
+}
+
+//获取数量
+func GetArticleDepartmentFollow(userId, departmentId int, condition string) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_department_follow WHERE user_id=? AND department_id=? ` + condition
+	err = orm.NewOrm().Raw(sql, userId, departmentId).QueryRow(&count)
+	return
+}
+
+//获取数量
+func GetArticleDepartmentFollowByUid(userId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_department_follow WHERE user_id=? `
+	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	return
+}

+ 5 - 4
models/chart_permission.go

@@ -5,6 +5,7 @@ import "rdluck_tools/orm"
 type ChartPermission struct {
 	ChartPermissionId int    `description:"权限id"`
 	PermissionName    string `description:"权限名称"`
+	IsShowSustainable bool   `description:"是否展示限免标签"`
 }
 
 type ActivityChartPermission struct {
@@ -17,9 +18,9 @@ type ChartPermissionResp struct {
 	List []*ChartPermission
 }
 
-func GetChartPermissionAll() (items []*ChartPermission, err error) {
+func GetChartPermissionAll(condition string) (items []*ChartPermission, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND show_type=1 ORDER BY sort ASC `
+	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND show_type=1 ` + condition + ` ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -34,9 +35,9 @@ func GetCategoryId(chartPermissionId int) (category_id string, err error) {
 	return
 }
 
-func GetChartPermissionReportAll() (items []*ChartPermission, err error) {
+func GetChartPermissionReportAll(condition string) (items []*ChartPermission, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 ORDER BY sort ASC `
+	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 ` + condition + ` ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 10 - 2
models/config.go

@@ -20,5 +20,13 @@ func GetConfigByCode(configCode string) (item *CygxConfig, err error) {
 }
 
 type ConfigResp struct {
-	Item   *CygxConfig
-}
+	Item *CygxConfig
+}
+
+//获取是否展示限免标签
+func GetShowSustainable() (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) FROM cygx_config WHERE config_code= 'is_show_sustainable' AND config_value = 1 `
+	err = o.Raw(sqlCount).QueryRow(&count)
+	return
+}

+ 5 - 0
models/db.go

@@ -56,5 +56,10 @@ func init() {
 		new(CygxActivityMeetingReminderLog),
 		new(CygxMySchedule),
 		new(WxUserWhite),
+		new(CygxActivityHelpAsk),
+		new(CygxIndustryFllow),
+		new(CygxArticleDepartmentFollow),
+		new(CygxArticleAsk),
+		new(CygxPageHistoryRecord),
 	)
 }

+ 4 - 5
models/home.go

@@ -1,7 +1,6 @@
 package models
 
 import (
-	"fmt"
 	"rdluck_tools/orm"
 	"rdluck_tools/paging"
 )
@@ -20,19 +19,19 @@ func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
 
 func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT *
+	sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record as h WHERE h.article_id = a.article_id ) as pv
                  FROM cygx_article AS a
                 WHERE a.publish_status=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
-	fmt.Println(sql)
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
 
 type HomeListResp struct {
-	Paging *paging.PagingItem
-	List   []*HomeArticle
+	HaveResearch bool `description:"是否有研选权限"`
+	Paging       *paging.PagingItem
+	List         []*HomeArticle
 }

+ 69 - 7
models/industrial_management.go

@@ -12,6 +12,7 @@ type IndustrialManagementRep struct {
 	ChartPermissionId int    `description:"权限id"`
 	RecommendedIndex  int    `description:"推荐指数"`
 	LayoutTime        string `description:"布局时间"`
+	ArticleReadNum    int    `description:"文章阅读数量"`
 }
 
 type IndustrialManagementCount struct {
@@ -50,33 +51,53 @@ func GetIndustrialManagemenCountNoTop(sqlChartPermissionId string, uid int, cond
 	return
 }
 
-//产业列表 不置顶
+//产业列表
 func GetIndustrialManagementAll(uid int, condition, orderSrt string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			man.*,
             MAX( art.publish_date ) AS update_time ,(
-			SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(uid) + ` AND rec.article_id = art.article_id ) AS readnum 
+			SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(uid) + ` AND rec.article_id = art.article_id ) AS readnum ,
+		    (SELECT COUNT( 1 )  FROM cygx_industry_fllow AS f WHERE f.user_id = ` + strconv.Itoa(uid) + ` AND f.industrial_management_id = man.industrial_management_id AND f.type = 1) AS is_follow
 			FROM
 			cygx_industrial_management AS man
 			INNER JOIN cygx_report_mapping AS re ON re.chart_permission_id = man.chart_permission_id
 			INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.industrial_management_id = man.industrial_management_id
 			INNER JOIN cygx_article AS art ON art.article_id = man_g.article_id 
-			WHERE 1= 1 
-			AND man.industrial_management_id NOT IN ( SELECT industrial_management_id FROM cygx_industry_top WHERE user_id = ` + strconv.Itoa(uid) + ` ) 
+			WHERE 1= 1
 			AND re.report_type = 2 
 			AND art.is_report = 1
 			AND art.is_class = 1 ` + condition + `
 			GROUP BY
 			man.industry_name 
 			ORDER BY ` + orderSrt + ` LIMIT ?,?`
-	//fmt.Println(sql)
-	//fmt.Println(startSize)
-	//fmt.Println(pageSize)
+	//AND man.industrial_management_id NOT IN ( SELECT industrial_management_id FROM cygx_industry_top WHERE user_id = ` + strconv.Itoa(uid) + ` )
 	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
 	return
 }
 
+//产业列表
+func GetIndustrialManagementAllCount(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT(*) as count 
+		FROM
+			(SELECT
+			COUNT(*) 
+		FROM
+			cygx_industrial_management AS man
+			INNER JOIN cygx_report_mapping AS re ON re.chart_permission_id = man.chart_permission_id
+			INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.industrial_management_id = man.industrial_management_id
+			INNER JOIN cygx_article AS art ON art.article_id = man_g.article_id 
+		WHERE
+			1 = 1 
+			AND re.report_type = 2 
+			AND art.is_report = 1 
+			AND art.is_class = 1 ` + condition + ` GROUP BY man.industrial_management_id) AS num `
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
 //产业列表 -置顶
 func GetIndustrialManagementTopAll(uid int, condition string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
@@ -200,6 +221,14 @@ func UpdateIndustrialIsDeepLabel(idStr string) (err error) {
 type IndustrialManagementIdInt struct {
 	IndustrialManagementId int    `description:"产业Id"`
 	IndustryName           string `description:"产业名称"`
+	SubjectName            string `description:"标的名称"`
+}
+
+type IndustrialManagementIdName struct {
+	DepartmentId int    `description:"作者ID"`
+	ArticleId    int    `description:"文章id"`
+	IndustryName string `description:"产业名称"`
+	SubjectName  string `description:"标的名称"`
 }
 
 //获取归类产业报告数量大于10的
@@ -229,3 +258,36 @@ func UpdateIndustrialManagementSubjectNames(nameStr string, industrialManagement
 	_, err = o.Raw(sql, nameStr, industrialManagementId).Exec()
 	return
 }
+
+// 处理每个产业下所关联的文章的阅读量  start
+func IndustrialManagementAll() (items []*IndustrialManagement, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industrial_management `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetIndustrialManagementArtCount(industrialManagementId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  
+	 			FROM  cygx_article_history_record AS h
+				INNER JOIN cygx_industrial_article_group_management as mg ON  mg.article_id = h.article_id
+				WHERE mg.industrial_management_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, industrialManagementId).QueryRow(&count)
+	return
+}
+
+func UpdateIndustrialManagementArtReadNum(num, industrialManagementId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industrial_management SET article_read_num = ? WHERE industrial_management_id = ?`
+	_, err = o.Raw(sql, num, industrialManagementId).Exec()
+	return
+}
+
+//获取产业下阅读数量第三的产业详情
+func GetIndustrialManagementHot3(chartPermissionId int) (item *IndustrialManagementRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industrial_management WHERE chart_permission_id = ? ORDER BY article_read_num DESC LIMIT 2,1`
+	err = o.Raw(sql, chartPermissionId).QueryRow(&item)
+	return
+}

+ 56 - 0
models/industry_fllow.go

@@ -0,0 +1,56 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type CygxIndustryFllow struct {
+	Id                     int       `orm:"column(id);pk"`
+	IndustrialManagementId int       `description:"产业D"`
+	UserId                 int       `description:"用户ID"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	CompanyId              int       `description:"公司id"`
+	CompanyName            string    `description:"公司名称"`
+	Type                   int       `description:"操作方式,1报名,2取消报名"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"更新时间"`
+}
+
+type CygxIndustryFllowRep struct {
+	IndustrialManagementId int `description:"产业D"`
+}
+
+//添加
+func AddCygxIndustryFllow(item *CygxIndustryFllow) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type CygxIndustryFllowResp struct {
+	Status   int  `description:"1:关注,2:取消关注"`
+	GoFollow bool `description:"是否去关注"`
+}
+
+func RemoveCygxIndustryFllow(userId, industrialManagementId, doType int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industry_fllow SET type = ? ,modify_time=? WHERE user_id=? AND industrial_management_id=? `
+	_, err = o.Raw(sql, doType, time.Now(), userId, industrialManagementId).Exec()
+	return
+}
+
+//获取数量
+func GetCountCygxIndustryFllow(userId, industrialManagementId int, condition string) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? ` + condition
+	err = orm.NewOrm().Raw(sql, userId, industrialManagementId).QueryRow(&count)
+	return
+}
+
+//获取数量
+func GetCountCygxIndustryFllowByUid(userId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? `
+	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	return
+}

+ 34 - 0
models/page_history_record.go

@@ -0,0 +1,34 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type CygxPageHistoryRecord struct {
+	Id                     int       `orm:"column(id);pk"`
+	UserId                 int       `description:"用户ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	CompanyId              int       `description:"公司id"`
+	CompanyName            string    `description:"公司名称"`
+	DetailId               string    `description:"详情ID"`
+	ChartPermissionId      int       `description:"行业ID"`
+	IndustrialManagementId string    `description:"产业ID"`
+	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars"`
+}
+
+type CygxPageHistoryRecordRep struct {
+	DetailId               string `description:"详情ID"`
+	ChartPermissionId      int    `description:"行业ID"`
+	IndustrialManagementId string `description:"产业ID"`
+	PageType               string `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars"`
+}
+
+//添加
+func AddCygxPageHistoryRecord(item *CygxPageHistoryRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}

+ 78 - 1
models/report.go

@@ -21,8 +21,11 @@ type IndustrialManagement struct {
 	UpdateTime             string               `description:"更新时间"`
 	IsRed                  bool                 `description:"是否标记红点"`
 	IsTop                  bool                 `description:"是否置顶"`
-	AnalystList            []*IndustrialAnalyst `description:"分析师列表"`
+	IsHot                  bool                 `description:"是否是热门"`
+	IsFollow               int                  `description:"是否关注"`
 	Analyst                string               `description:"分析师"`
+	ArticleReadNum         int                  `description:"文章阅读数量"`
+	AnalystList            []*IndustrialAnalyst `description:"分析师列表"`
 	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
 }
 
@@ -133,3 +136,77 @@ func GetIndustrialManagementIdsBykeyWord(condition string) (industrialManagement
 	err = o.Raw(sql).QueryRow(&industrialManagementIds)
 	return
 }
+
+type ReportArticleWhichIndustrial struct {
+	ArticleId    int    `description:"文章id"`
+	Title        string `description:"标题"`
+	PublishDate  string `description:"发布时间"`
+	IndustryName string `description:"产业名称"`
+	SubjectName  string `description:"标的名称"`
+	NickName     string `description:"作者昵称"`
+	IsRed        bool   `description:"是否标记红点"`
+	Readnum      int    `description:"阅读数量"`
+	IsResearch   bool   `description:"是否属于研选"`
+}
+
+type ReportArticleWhichIndustrialRepList struct {
+	HaveResearch bool               `description:"是否有研选权限"`
+	Paging       *paging.PagingItem `description:"分页数据"`
+	NickName     string             `description:"作者昵称"`
+	IndustryName string             `description:"产业名称"`
+	List         []*ReportArticleWhichIndustrial
+}
+
+//列表
+func IndustrialToArticleWhichDepartment(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ReportArticleWhichIndustrial, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	art.* ,m.industry_name,d.nick_name,
+	(SELECT  GROUP_CONCAT(DISTINCT s.subject_name   SEPARATOR '/')  FROM cygx_industrial_subject as s  WHERE s.industrial_management_id = m.industrial_management_id  LIMIT 0,4) AS subject_name ,
+	( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id =  ` + strconv.Itoa(uid) + ` AND rec.article_id = art.article_id ) AS readnum 
+FROM
+	cygx_article AS art
+	INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id 
+	INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
+	INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
+	WHERE 1 = 1 
+	AND art.publish_status = 1`
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+func GetWhichDepartmentCount(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	//sql := `SELECT COUNT(*) count
+	//		FROM(
+	//		SELECT COUNT(1) count
+	//		FROM
+	//		cygx_article AS art
+	//		INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
+	//		INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
+	//		INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
+	//		WHERE 1 = 1
+	//		AND art.publish_status = 1`
+	//if condition != "" {
+	//	sql += condition
+	//}
+	//sql += ` ) AS num`
+
+	sql := `SELECT COUNT(1) count 
+			FROM
+			cygx_article AS art
+			INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id 
+			INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
+			INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
+			WHERE 1 = 1 
+			AND art.publish_status = 1`
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}

+ 2 - 2
models/user.go

@@ -136,13 +136,13 @@ type CheckStatusResp struct {
 }
 
 func GetArticleUserCollectCount(userId int) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect AS a WHERE a.user_id=? `
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id WHERE a.user_id=?  `
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
 	return
 }
 
 func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleCollectList, err error) {
-	sql := `SELECT a.* FROM cygx_article_collect AS a
+	sql := `SELECT a.* FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id
 			WHERE a.user_id=? 
            ORDER BY a.create_time DESC LIMIT ?,? `
 	_, err = orm.NewOrm().Raw(sql, userId, startSize, pageSize).QueryRows(&items)

+ 35 - 0
models/wechat.go

@@ -124,3 +124,38 @@ func WxUsersGet() (openIdStr string) {
 	utils.FileLog.Info("openIdStr:%s", openIdStr)
 	return
 }
+
+type WxCheckContentJson struct {
+	AccessToken  string `json:"access_token"`
+	ExpiresIn    int    `json:"expires_in"`
+	RefreshToken string `json:"refresh_token"`
+	Openid       string `json:"openid"`
+	Unionid      string `json:"unionid"`
+	Scope        string `json:"scope"`
+	Errcode      int    `json:"errcode"`
+	Errmsg       string `json:"errmsg"`
+}
+
+func WxCheckContent(content string) {
+	accessToken, err := GetWxAccessToken()
+	if err != nil {
+		utils.FileLog.Info("GetWxAccessToken Err:%s", err.Error())
+		return
+	}
+	url := "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + accessToken
+	fmt.Println(url)
+	result, err := http.Post(url, content)
+	if err != nil {
+		utils.FileLog.Info("GetUser Err:", err.Error())
+		return
+	}
+
+	item := new(WxCheckContentJson)
+	err = json.Unmarshal(result, &item)
+	if err != nil {
+		fmt.Println("Unmarshal Err:", err.Error())
+		return
+	}
+	fmt.Println(result)
+	return
+}

+ 10 - 1
models/wx_template_msg.go

@@ -1,6 +1,8 @@
 package models
 
-import "rdluck_tools/orm"
+import (
+	"rdluck_tools/orm"
+)
 
 type SendTemplateResponse struct {
 	Errcode int    `json:"errcode"`
@@ -32,3 +34,10 @@ func GetWxOpenIdList() (items []*OpenIdList, err error) {
 	_, err = orm.NewOrm().Raw(sql, openId).QueryRows(&items)
 	return
 }
+
+func GetWxOpenIdByMobileList(mobile string) (items []*OpenIdList, err error) {
+	//sql := `SELECT * FROM user_record WHERE bind_account IN (` + utils.WxMsgTemplateIdAskMsgMobile + `) AND create_platform = 1`
+	sql := `SELECT * FROM user_record WHERE bind_account IN (` + mobile + `) AND create_platform = 1`
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	return
+}

+ 90 - 0
services/activity.go

@@ -303,3 +303,93 @@ func EditUserOutboundMobile(cont context.Context) (err error) {
 	fmt.Println("修改完成")
 	return
 }
+
+//获取 用户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
+func GetUserType(companyId int) (userType int, permissionStrnew string, err error) {
+
+	var permissionStr string
+	if companyId <= 1 {
+		userType = 0
+	} else {
+		total, errs := models.GetCountCompanyDetailByIdGroup(companyId)
+		if errs != nil {
+			err = errs
+			return
+		}
+		if total == 0 {
+			userType = 0
+		} else {
+			companyDetail, errs := models.GetCompanyDetailByIdGroup(companyId)
+			if errs != nil {
+				err = errs
+				return
+			}
+			permissionStr, errs = models.GetCompanyPermission(companyId)
+			if errs != nil {
+				err = errs
+				return
+			}
+			//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
+			if companyDetail.Status == "永续" {
+				userType = 1
+			} else if companyDetail.Status == "试用" {
+				userType = 5
+			} else if companyDetail.Status == "正式" {
+				if permissionStr == "专家" {
+					userType = 4
+				} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
+					userType = 2
+				} else {
+					userType = 3
+				}
+				if userType == 3 {
+					if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
+						userType = 4
+					}
+				}
+			}
+		}
+	}
+	permissionStrnew = permissionStr
+	return
+}
+
+// 校验被分享的用户是否有查看详情的权限
+func GetShareNoPowe(activityInfo *models.ActivityDetail, permissionStr string, userType int) (noPower bool, err error) {
+	//var noPower bool
+	if (userType == 1 || userType == 4 || userType == 5) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
+		noPower = true
+	}
+	//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
+	if userType == 2 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
+		noPower = true
+	}
+	if userType == 2 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
+		noPower = true
+	}
+	if userType == 3 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
+		noPower = true
+	}
+	if userType == 3 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
+		noPower = true
+	}
+	return
+}
+
+// 校验用户报名的权限
+func GetHavePower(activityInfo *models.ActivityDetail, permissionStr, companyDetailStatus string, userType int) (havePower bool, err error) {
+	if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 {
+		havePower = true
+	} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") {
+		havePower = true
+	} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
+		havePower = true
+	} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
+		havePower = true
+	} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
+		havePower = true
+	} else if activityInfo.ActivityTypeId == 5 && strings.Contains(permissionStr, "专家") {
+		havePower = true
+	}
+	return
+}

+ 19 - 0
services/config.go

@@ -0,0 +1,19 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+)
+
+//是否展示限免标签
+func GetShowSustainable() (isShowSustainable bool) {
+	total, err := models.GetShowSustainable()
+	if err != nil {
+		fmt.Println("GetShowSustainable Err:", err.Error())
+		return
+	}
+	if total > 0 {
+		isShowSustainable = true
+	}
+	return
+}

+ 24 - 0
services/industrial_management.go

@@ -71,3 +71,27 @@ func UpdateIndustrialManagementSubjectNnames() (err error) {
 	fmt.Println("修改状态完成")
 	return
 }
+
+func ChageIndustrialArticleNum(cont context.Context) (err error) {
+	fmt.Println("666")
+	allList, err := models.IndustrialManagementAll()
+	if err != nil {
+		fmt.Println("GetArticleAll Err:", err.Error())
+		return
+	}
+	for _, v := range allList {
+		total, errTop := models.GetIndustrialManagementArtCount(v.IndustrialManagementId)
+		if errTop != nil {
+			fmt.Println("Top Err:", errTop.Error())
+			return
+		}
+		if total > 0 {
+			err = models.UpdateIndustrialManagementArtReadNum(total, v.IndustrialManagementId)
+			if err != nil {
+				fmt.Println("Update Err:", err.Error())
+				return
+			}
+		}
+	}
+	return
+}

+ 61 - 13
services/oss.go

@@ -27,48 +27,47 @@ func init() {
 */
 
 //图片上传到阿里云
-func UploadAliyun(filename, filepath string) (string,error) {
+func UploadAliyun(filename, filepath string) (string, error) {
 	client, err := oss.New(utils.Endpoint, utils.AccessKeyId, utils.AccessKeySecret)
 	if err != nil {
-		return "1",err
+		return "1", err
 	}
 	bucket, err := client.Bucket(utils.Bucketname)
 	if err != nil {
-		return "2",err
+		return "2", err
 	}
 	path := utils.Upload_dir + time.Now().Format("200601/20060102/")
 	path += filename
 	err = bucket.PutObjectFromFile(path, filepath)
 	if err != nil {
-		return "3",err
+		return "3", err
 	}
 	path = utils.Imghost + path
-	return path,err
+	return path, err
 }
 
-
 //音频上传到阿里云
-func UploadAudioAliyun(filename, filepath string) (string,error) {
+func UploadAudioAliyun(filename, filepath string) (string, error) {
 	client, err := oss.New(utils.Endpoint, utils.AccessKeyId, utils.AccessKeySecret)
 	if err != nil {
-		return "1",err
+		return "1", err
 	}
 	bucket, err := client.Bucket(utils.Bucketname)
 	if err != nil {
-		return "2",err
+		return "2", err
 	}
 	path := utils.Upload_Audio_Dir + time.Now().Format("200601/20060102/")
 	path += filename
 	err = bucket.PutObjectFromFile(path, filepath)
 	if err != nil {
-		return "3",err
+		return "3", err
 	}
 	path = utils.Imghost + path
-	return path,err
+	return path, err
 }
 
 //视频上传到阿里云
-func UploadVideoAliyun(filename, filepath,savePath string) (error) {
+func UploadVideoAliyun(filename, filepath, savePath string) error {
 	defer func() {
 		os.Remove(filepath)
 	}()
@@ -89,4 +88,53 @@ func UploadVideoAliyun(filename, filepath,savePath string) (error) {
 	//path = utils.Imghost + path
 	//return path,err
 	return err
-}
+}
+
+//PDF上传到阿里云
+func UploadPdfAliyun(filename, filepath string) (string, error) {
+	client, err := oss.New(utils.Endpoint, utils.AccessKeyId, utils.AccessKeySecret)
+	if err != nil {
+		return "1", err
+	}
+	bucket, err := client.Bucket(utils.Bucketname)
+	if err != nil {
+		return "2", err
+	}
+	path := utils.Upload_Pdf_Dir + time.Now().Format("200601/20060102/")
+	path += filename
+	err = bucket.PutObjectFromFile(path, filepath)
+	if err != nil {
+		return "3", err
+	}
+	path = utils.Imghost + path
+	return path, err
+}
+
+const (
+	HzEndpoint          = "oss-cn-shanghai.aliyuncs.com"
+	HzBucketName string = "hzchart"
+)
+
+//上传文件到阿里云
+func UploadFileToAliyun(filename, filepath, savePath string) error {
+	defer func() {
+		os.Remove(filepath)
+	}()
+	client, err := oss.New(HzEndpoint, utils.AccessKeyId, utils.AccessKeySecret)
+	if err != nil {
+		return err
+	}
+	bucket, err := client.Bucket(HzBucketName)
+	if err != nil {
+		return err
+	}
+	//path := utils.Upload_Audio_Dir + time.Now().Format("200601/20060102/")
+	//path += filename
+	err = bucket.PutObjectFromFile(savePath, filepath)
+	if err != nil {
+		return err
+	}
+	//path = utils.Imghost + path
+	//return path,err
+	return err
+}

+ 8 - 14
services/task.go

@@ -3,7 +3,6 @@ package services
 import (
 	"fmt"
 	"github.com/PuerkitoBio/goquery"
-	//"github.com/beego/beego/v2/adapter/toolbox"
 	"github.com/beego/beego/v2/task"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
@@ -11,29 +10,18 @@ import (
 	"strconv"
 	"strings"
 	"time"
-	//"github.com/beego/beego/v2/adapter/cache"
 )
 
 func Task() {
 	fmt.Println("start")
 	//同步数据
 	if utils.RunMode == "release" {
-		//syncTacticsList := toolbox.NewTask("syncTacticsList", "0 */5 * * * *", SyncTacticsList)
-		//toolbox.AddTask("syncTacticsList", syncTacticsList)
-		//toolbox.StartTask()
-		syncTacticsListAddreport := task.NewTask("syncTacticsListAddreport", "0 */5 * * * *", SyncTacticsListAddreport)
+		syncTacticsListAddreport := task.NewTask("syncTacticsListAddreport", "0 */5 * * * *", SyncTacticsListAddreport) //同步文章
 		task.AddTask("syncTacticsListAddreport", syncTacticsListAddreport)
-
 		//同步纪要库中的Es
-		//syncTacticsListToEs := toolbox.NewTask("syncTacticsListToEs", "0 */30 * * * *", SyncTacticsListToEs)
-		//toolbox.AddTask("syncTacticsListToEs", syncTacticsListToEs)
 		getSummarytoEs := task.NewTask("getSummarytoEs", "0 */30 * * * *", GetSummarytoEs) //同步纪要库内容到Es
 		task.AddTask("getSummarytoEs", getSummarytoEs)
-
-		//toolbox.StartTask()
 	}
-
-	//UpdateActivitySattus()
 	//修改任务状态
 	updateActivitySattus := task.NewTask("syncTacticsListAddreport", "0 */1 8-22 * * *", UpdateActivitySattus)
 	task.AddTask("updateActivitySattus", updateActivitySattus)
@@ -52,17 +40,23 @@ func Task() {
 	task.AddTask("sendEmailFileToExpert", sendEmailFileToExpert)
 
 	////白名单发送
-	//sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 27 17 * * *", SendEmailUserWhiteList) //预约外呼名单,会前1小时自动发送邮件给专家组
+	//sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 27 17 * * *", SendEmailUserWhiteList) //白名单发送
 	//task.AddTask("sendEmailUserWhiteList", sendEmailUserWhiteList)
 
 	//白名单发送2
 	sendEmailUserWhiteListChange := task.NewTask("sendEmailUserWhiteListChange", "0 00 17 * * *", SendEmailUserWhiteListChange) //新增 和冻结的客户白名单
 	task.AddTask("sendEmailUserWhiteListChange", sendEmailUserWhiteListChange)
 
+	//更改对应产业的文章阅读数量
+	chageIndustrialArticleNum := task.NewTask("chageIndustrialArticleNum", "0 01 00 * * *", ChageIndustrialArticleNum) //更改对应产业的文章阅读数量
+	task.AddTask("chageIndustrialArticleNum", chageIndustrialArticleNum)
+
 	//editOutboundMobile := task.NewTask("editOutboundMobile", "0 */1 8-22 * * *", EditOutboundMobile) //同步外呼号码与手机号
 	//task.AddTask("sendEmailFileToExpert", editOutboundMobile)
 	//editUserOutboundMobile := task.NewTask("editUserOutboundMobile", "0 27 14 * * *   ", EditUserOutboundMobile) //同步外呼号码与手机号
 	//task.AddTask("editUserOutboundMobile", editUserOutboundMobile)
+
+	//IndustrialArticleNum()
 	task.StartTask()
 	fmt.Println("end")
 }

+ 1 - 1
services/wechat.go

@@ -104,4 +104,4 @@ type WxUserDetail struct {
 	Unionid    string
 	Headimgurl string
 	Nickname   string
-}
+}

+ 47 - 0
services/wx_template_msg.go

@@ -46,7 +46,54 @@ func SendWxMsgWithFrequency(first, activityName, reserveResults, activityTime, a
 	sendData["activity_address"] = map[string]interface{}{"value": activityAddress, "color": "#173177"}
 	sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
 	sendMap["data"] = sendData
+	WxSendTemplateMsg(sendUrl, sendMap, openIdList)
+	return
+}
 
+//发送报告提问消息提醒
+func SendWxMsgWithAsk(name, askTime, askMsg, title string, openIdList []*models.OpenIdList, articleId int) (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+		fmt.Println("line 21", err, msg)
+	}()
+	utils.FileLog.Info("%s", "services SendMsg")
+	accessToken, err := models.GetWxAccessToken()
+	if err != nil {
+		msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if accessToken == "" {
+		msg = "accessToken is empty"
+		return
+	}
+	var first string
+	var keyword1 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	first = "研选报告有新的提问,请及时处理"
+	keyword1 = name
+	keyword3 = askTime
+	keyword4 = askMsg
+	remark = title
+	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
+	templateId := utils.WxMsgTemplateIdAskMsg
+	sendMap := make(map[string]interface{})
+	sendData := make(map[string]interface{})
+	sendMap["template_id"] = templateId
+	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "pages/reportDetail/reportDetail?id=" + strconv.Itoa(articleId)}
+	//sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "path": "article/detail?ArticleId=1000001"}
+	sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
+	sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
+	sendData["keyword2"] = map[string]interface{}{"value": "", "color": "#173177"}
+	sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
+	sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": "#173177"}
+	sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
+	sendMap["data"] = sendData
 	WxSendTemplateMsg(sendUrl, sendMap, openIdList)
 	return
 }

+ 8 - 5
utils/config.go

@@ -28,6 +28,9 @@ var (
 	WxMsgTemplateIdPermissionApply string //预约取消提醒
 	WxMsgTemplateIdActivityApply   string //活动预约消息提醒
 	WxMsgTemplateIdActivityChange  string //活动预约变更提醒
+	WxMsgTemplateIdAskMsg          string //手机号用户【XXX】发送模板消息模板ID
+	WxMsgTemplateIdAskMsgMobile    string //手机号用户【XXX】发送模板消息
+	WxMsgTemplateIdAskMsgMobileAll string //手机号用户【XXX】发送模板消息
 )
 
 //微信公众号配置信息
@@ -72,6 +75,7 @@ func init() {
 	}
 	OnlineTime = "2021-06-01 00:00:01" //上线时间
 	SummaryArticleId = 1000000         //手动添加的纪要库开始ID
+	WxMsgTemplateIdAskMsgMobileAll = "15557270714"
 	if RunMode == "release" {
 		WxAppId = "wxcc32b61f96720d2f"
 		WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
@@ -93,12 +97,9 @@ func init() {
 		EmailZhizao = "xfma@hzinsights.com;agne@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com"                         //智造行业专家邮箱
 		EmailStrategy = "xfma@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com"                                           //策略行业专家邮箱
 		EmaiWhiteUserList = "tshen@hzinsights.com;cxzhang@hzinsights.com;yyli@hzinsights.com"                                                             //白名单邮箱
+		WxMsgTemplateIdAskMsg = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"
+		WxMsgTemplateIdAskMsgMobile = ""
 
-		//EmailTechnology = "jhwang@hzinsights.com;cxzhang@hzinsights.com" //科技行业专家邮箱
-		//EmailMedicine = "jhwang@hzinsights.com"                          //医药行业专家邮箱
-		//EmailConsumption = "jhwang104@163.com;cxzhang@hzinsights.com"    //消费行业专家邮箱
-		//EmailZhizao = "jhwang104@163.com"                                //智造行业专家邮箱
-		//EmailStrategy = "jhwang104@163.com;cxzhang@hzinsights.com"       //策略行业专家邮箱
 	} else {
 		WxAppId = "wxcc32b61f96720d2f"
 		WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
@@ -122,6 +123,8 @@ func init() {
 		EmailZhizao = "jhwang@hzinsights.com;cxzhang@hzinsights.com"      //智造行业专家邮箱
 		EmailStrategy = "jhwang@hzinsights.com;cxzhang@hzinsights.com"    //策略行业专家邮箱
 		EmaiWhiteUserList = "cxzhang@hzinsights.com"
+		WxMsgTemplateIdAskMsg = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo"
+		WxMsgTemplateIdAskMsgMobile = "15557270714,17634786714,18767183922"
 	}
 }
 

+ 12 - 10
utils/constants.go

@@ -6,16 +6,17 @@ const (
 
 //常量定义
 const (
-	FormatTime            = "15:04:05"                //时间格式
-	FormatDate            = "2006-01-02"              //日期格式
-	FormatDateTime        = "2006-01-02 15:04:05"     //完整时间格式
-	HlbFormatDateTime     = "2006-01-02_15:04:05.999" //完整时间格式
-	FormatDateTimeUnSpace = "20060102150405"          //完整时间格式
-	PageSize15            = 15                        //列表页每页数据量
-	PageSize5             = 5
-	PageSize10            = 10
-	PageSize20            = 20
-	PageSize30            = 30
+	FormatTime             = "15:04:05"                //时间格式
+	FormatDate             = "2006-01-02"              //日期格式
+	FormatDateTime         = "2006-01-02 15:04:05"     //完整时间格式
+	HlbFormatDateTime      = "2006-01-02_15:04:05.999" //完整时间格式
+	FormatDateTimeNoSecond = "2006-01-02 15:04"        //完整时间格式
+	FormatDateTimeUnSpace  = "20060102150405"          //完整时间格式
+	PageSize15             = 15                        //列表页每页数据量
+	PageSize5              = 5
+	PageSize10             = 10
+	PageSize20             = 20
+	PageSize30             = 30
 )
 
 const (
@@ -48,6 +49,7 @@ var (
 	Imghost          string = "https://hongze.oss-cn-shanghai.aliyuncs.com/"
 	Upload_dir       string = "static/images/"
 	Upload_Audio_Dir string = "static/audio/"
+	Upload_Pdf_Dir   string = "static/pdf/"
 
 	AccessKeyId     string = "LTAIFMZYQhS2BTvW"
 	AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"