ソースを参照

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_12.1

xingzai 1 年間 前
コミット
f242c816cb
82 ファイル変更3501 行追加627 行削除
  1. 1 1
      controllers/activity.go
  2. 4 1
      controllers/article.go
  3. 2 1
      controllers/banner.go
  4. 1 1
      controllers/htgj.go
  5. 32 1
      controllers/report.go
  6. 18 0
      controllers/report_selection.go
  7. 35 4
      controllers/research.go
  8. 3 0
      controllers/tactics.go
  9. 53 15
      controllers/user.go
  10. 1066 0
      controllers/yanxuan_special.go
  11. 3 0
      go.mod
  12. 4 2
      go.sum
  13. 18 28
      models/activity.go
  14. 1 1
      models/activity_attendance_detail.go
  15. 1 2
      models/activity_meet_detail_log.go
  16. 2 2
      models/activity_offline_meeting_detail.go
  17. 9 9
      models/activity_special_signup.go
  18. 1 1
      models/activity_special_trip.go
  19. 5 8
      models/activity_special_trip_bill.go
  20. 5 5
      models/admin.go
  21. 3 1
      models/apply_record.go
  22. 2 11
      models/article.go
  23. 2 3
      models/article_collect.go
  24. 18 16
      models/chart_permission.go
  25. 18 18
      models/company.go
  26. 1 1
      models/company/company_approval.go
  27. 1 1
      models/company/company_contract.go
  28. 11 12
      models/company_activity_trip.go
  29. 3 2
      models/company_product.go
  30. 2 2
      models/company_report_permission.go
  31. 29 27
      models/crm_company.go
  32. 267 0
      models/cygx_yanxuan_special.go
  33. 39 0
      models/cygx_yanxuan_special_collect.go
  34. 43 0
      models/cygx_yanxuan_special_company.go
  35. 57 0
      models/cygx_yanxuan_special_follow.go
  36. 32 0
      models/cygx_yanxuan_special_record.go
  37. 138 0
      models/cygx_yanxuan_special_user.go
  38. 14 2
      models/db.go
  39. 1 3
      models/industrial_article_group_management.go
  40. 0 2
      models/industry_fllow.go
  41. 2 4
      models/minutesSummary.go
  42. 1 1
      models/page_history_record.go
  43. 0 31
      models/product_interior.go
  44. 89 30
      models/report.go
  45. 2 4
      models/report_selection.go
  46. 1 2
      models/report_selection_chart_log.go
  47. 1 2
      models/researchSummary.go
  48. 9 0
      models/resource_data.go
  49. 5 5
      models/seller.go
  50. 22 22
      models/send_company_user.go
  51. 1 0
      models/tactics.go
  52. 100 36
      models/user.go
  53. 5 4
      models/user_invitee.go
  54. 2 1
      models/user_label.go
  55. 69 64
      models/user_record.go
  56. 2 2
      models/user_template_record.go
  57. 51 20
      models/wechat.go
  58. 45 17
      models/wx_template_msg.go
  59. 83 64
      models/wx_user.go
  60. 38 39
      models/wx_user_code.go
  61. 2 2
      models/wx_user_log.go
  62. 25 13
      models/wx_user_white.go
  63. 153 0
      routers/commentsRouter.go
  64. 5 0
      routers/router.go
  65. 63 27
      services/activity.go
  66. 54 3
      services/activity_special.go
  67. 55 20
      services/article.go
  68. 2 1
      services/article_history.go
  69. 29 0
      services/company_permission.go
  70. 304 0
      services/cygx_yanxuan_special.go
  71. 91 0
      services/cygx_yanxuan_special_company.go
  72. 61 1
      services/es_comprehensive.go
  73. 10 8
      services/keyword.go
  74. 35 0
      services/oss.go
  75. 27 3
      services/resource_data.go
  76. 2 0
      services/task.go
  77. 30 9
      services/user.go
  78. 1 1
      services/user_label.go
  79. 61 0
      utils/common.go
  80. 2 0
      utils/config.go
  81. 8 0
      utils/constants.go
  82. 8 8
      utils/email.go

+ 1 - 1
controllers/activity.go

@@ -691,7 +691,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 			return
 		}
 		if popupMsg != "" {
-			br.Msg = "报名失败!"
+			br.Msg = popupMsg
 			br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
 			return
 		}

+ 4 - 1
controllers/article.go

@@ -432,6 +432,9 @@ Loop:
 			detail.ReportLink += "?token=" + chartUserTokenByMobile
 		}
 	}
+	if articleId < utils.SummaryArticleId {
+		detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
+	}
 	if detail.ArticleTypeId == 14 {
 		detail.IsApplyAppointmentExpert = true //判断文章类型是否属于专家访谈  查研观向11.0
 	}
@@ -1570,7 +1573,7 @@ func (this *ArticleCommonController) AddStopTimePublic() {
 						recordRedis.Email = user.Email
 						recordRedis.RealName = user.RealName
 						recordRedis.CompanyName = companyName
-						recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
+						//recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
 						go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
 					} else {
 						go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)

+ 2 - 1
controllers/banner.go

@@ -121,10 +121,11 @@ func (this *BannerController) ListYx() {
 	listA = []*models.BannerUrlYxResp{
 		&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/1.png", Path: "pages-purchaser/leaflet/leaflet?leafletImage=https%3A%2F%2Fhzstatic.hzinsights.com%2Fcygx%2Fconfig%2Fresearch_11_0.png"},
 		&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/2.png", Path: "pages-purchaser/survey/surveySubmit"},
+		&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/4.png", Path: "pages-purchaser/specialColumn/specialColumn"},
 	}
 
 	listB = []*models.BannerUrlYxResp{
-		&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/3.png", Path: "/index/"},
+		&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/3.png", Path: "pages-purchaser/researchList/researchList"},
 	}
 	resp.ListA = listA
 	resp.ListB = listB

+ 1 - 1
controllers/htgj.go

@@ -787,7 +787,7 @@ func (this *BaseHtgjController) AddStopTimePublic() {
 						recordRedis.Email = user.Email
 						recordRedis.RealName = user.RealName
 						recordRedis.CompanyName = companyName
-						recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
+						//recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
 						go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
 					} else {
 						go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)

+ 32 - 1
controllers/report.go

@@ -1765,6 +1765,19 @@ func (this *ReportController) ResearchDetail() {
 		return
 	}
 
+	PermissionNameMap, err := services.GetPermissionNameMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
+
+	PermissionIcoMap, err := services.GetPermissionNameIcoMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
 	//未设置全部可见的只能给弘则内部查看
 	if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
 		resp.IsShow = true
@@ -1799,6 +1812,8 @@ func (this *ReportController) ResearchDetail() {
 			return
 		}
 		for k2, v2 := range listSecond {
+			v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
+			v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
 			listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
 			if err != nil && err.Error() != utils.ErrNoRow() {
 				br.Msg = "获取信息失败"
@@ -1927,6 +1942,18 @@ func (this *ReportController) MinutesDetailV4() {
 		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
 		return
 	}
+	PermissionNameMap, err := services.GetPermissionNameMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
+	PermissionIcoMap, err := services.GetPermissionNameIcoMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
 	//未设置全部可见的只能给弘则内部查看
 	if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
 		resp.IsShow = true
@@ -1955,6 +1982,8 @@ func (this *ReportController) MinutesDetailV4() {
 			return
 		}
 		for k2, v2 := range listSecond {
+			v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
+			v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
 			listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
 			if err != nil && err.Error() != utils.ErrNoRow() {
 				br.Msg = "获取信息失败"
@@ -2061,6 +2090,7 @@ func (this *ReportController) MinutesDetail() {
 		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
 		return
 	}
+
 	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
 	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
 	listLog, err := models.GetMinutesSummarylogListAll(articleId)
@@ -2077,12 +2107,13 @@ func (this *ReportController) MinutesDetail() {
 			return
 		}
 		if len(listSonLog) > 0 {
-			listLog[k].List = listSonLog
 			for k2, v2 := range listSonLog {
 				if v2.ReportLink == "0" {
 					listSonLog[k2].ReportLink = ""
 				}
 			}
+			listLog[k].List = listSonLog
+
 		}
 	}
 	//historyRecord := new(models.CygxReportHistoryRecord)

+ 18 - 0
controllers/report_selection.go

@@ -63,6 +63,21 @@ func (this *ReportSelectionController) Detail() {
 		br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
 		return
 	}
+
+	PermissionNameMap, err := services.GetPermissionNameMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
+
+	PermissionIcoMap, err := services.GetPermissionNameIcoMap()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
+		return
+	}
+
 	resp := new(models.ReportSelectionLetailResp)
 	//判断用户权限
 	hasPermission, err := services.GetUserhasPermission(user)
@@ -117,6 +132,7 @@ func (this *ReportSelectionController) Detail() {
 		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
 	}
 	for _, v := range listLog {
+		v.PermissionName = PermissionNameMap[v.ChartPermissionId]
 		item := new(models.ReportSelectionChartPermission)
 		itemSubject := new(models.ReportSelectionChartLogPermission)
 		itemSubject.PermissionName = v.PermissionName
@@ -154,6 +170,8 @@ func (this *ReportSelectionController) Detail() {
 			}
 			item.BodyChartSummary = mapChartLog[v.PermissionName]
 			item.List = listSonLog
+			item.PermissionName = PermissionNameMap[v.ChartPermissionId]
+			item.IcoLink = PermissionIcoMap[v.ChartPermissionId]
 			items = append(items, item)
 			itemsSubject = append(itemsSubject, itemSubject)
 			//itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)

+ 35 - 4
controllers/research.go

@@ -727,7 +727,7 @@ func (this *ResearchController) ArticleNewList() {
 	var conditiontype string
 	var pars []interface{}
 	condition = `    AND publish_status = 1  `
-	if articleTypeIds == "" {
+	if articleTypeIds == "" || strings.Contains(articleTypeIds, "999") {
 		conditiontype = " AND is_show_yanx  = 1 "
 	} else {
 		conditiontype = ` AND   group_id IN  (` + articleTypeIds + `) `
@@ -738,19 +738,29 @@ func (this *ResearchController) ArticleNewList() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	needYanxuanSpecial := true
+	if articleTypeIds != "" && !strings.Contains(articleTypeIds, "999") {
+		needYanxuanSpecial = false
+	}
+
+	//只勾选了研选专栏时去掉文章的统计
+	if articleTypeIds == "999" {
+		condition += ` AND 1<0 `
+	}
 	articleTypeIds = ""
 	for _, v := range listType {
 		articleTypeIds += strconv.Itoa(v.ArticleTypeId) + ","
 	}
 	articleTypeIds = strings.TrimRight(articleTypeIds, ",")
 	condition += `   AND a.article_type_id IN (` + articleTypeIds + `) `
-	total, err := models.GetArticleResearchCount(condition, pars)
+
+	total, err := models.GetArticleResearchCount(condition, pars, needYanxuanSpecial)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
+	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId, needYanxuanSpecial)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -790,16 +800,37 @@ func (this *ResearchController) ArticleNewList() {
 		item := models.ArticleResearchResp{
 			ArticleId:       v.ArticleId,
 			Title:           v.Title,
-			PublishDate:     v.PublishDate,
+			PublishDate:     v.PublishTime.Format(utils.FormatDate),
 			DepartmentId:    v.DepartmentId,
 			NickName:        v.NickName,
 			IsCollect:       v.IsCollect,
 			Pv:              v.Pv,
 			CollectNum:      v.CollectNum,
+			IsSpecial:       v.IsSpecial,
 			ArticleTypeName: nameMap[v.ArticleTypeId],
 			ButtonStyle:     styleMap[v.ArticleTypeId],
+			SpecialTags:     v.SpecialTags,
+			UserId:          v.UserId,
 			List:            v.List,
 		}
+		if v.ArticleTypeId == -1 {
+			item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+		}
+		if v.SpecialType == 1 {
+			item.Title = "【笔记】" + item.Title
+		} else if v.SpecialType == 2 {
+			item.Title = "【观点】" + item.Title
+		}
+		if v.CompanyTags != "" {
+			v.SpecialTags += v.CompanyTags
+		}
+		if v.IndustryTags != "" {
+			if v.SpecialTags != "" {
+				v.SpecialTags += ","
+			}
+			v.SpecialTags += v.IndustryTags
+		}
+		item.SpecialTags = v.SpecialTags
 		resp.List = append(resp.List, &item)
 	}
 	resp.Paging = page

+ 3 - 0
controllers/tactics.go

@@ -107,6 +107,9 @@ func (this *TacticsController) List() {
 			return
 		}
 		resp.MatchTypeName = detail.MatchTypeName
+		if detail.MatchTypeName == "热点问答" {
+			resp.IsShowAbstract = true
+		}
 	}
 
 	for _, v := range list {

+ 53 - 15
controllers/user.go

@@ -244,6 +244,31 @@ func (this *UserController) Detail() {
 			return
 		}
 
+		totalCollect, err := models.GetArticleUserCollectCount(uid) // 文章收藏数量
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "GetArticleUserCollectCount,Err:" + err.Error()
+			return
+		}
+
+		totalHistory, err := models.GetArticleUserHistoryNum(uid) // 足迹数量
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "GetArticleUserHistoryNum,Err:" + err.Error()
+			return
+		}
+
+		totalSchedule, err := models.GetArticleUserScheduleNum(uid) // 我的日程数量
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "GetArticleUserScheduleNum,Err:" + err.Error()
+			return
+		}
+
+		detail.ConNum = totalCollect
+		detail.HistoryNum = totalHistory
+		detail.ScheduleNum = totalSchedule
+
 		userRecord, _ := models.GetUserRecordByUserId(uid, utils.WxPlatform)
 		if userRecord != nil {
 			detail.NickName = userRecord.NickName
@@ -564,23 +589,36 @@ func (this *UserController) CollectList() {
 	for i := 0; i < lenList; i++ {
 		item := list[i]
 		article := articleMap[item.ArticleId]
-		list[i].Title = article.Title
-		list[i].DepartmentId = article.DepartmentId
-		list[i].NickName = article.NickName
-		list[i].PublishDate = article.PublishDate
-		if article.ArticleTypeId == 0 {
-			list[i].Source = 1
-		} else {
-			list[i].Source = 2
-			list[i].IsResearch = true
+		if list[i].IsSpecial != 1 {
+			list[i].Title = article.Title
+			list[i].DepartmentId = article.DepartmentId
+			list[i].NickName = article.NickName
+			list[i].PublishDate = article.PublishDate
+			if article.ArticleTypeId == 0 {
+				list[i].Source = 1
+			} else {
+				list[i].Source = 2
+				list[i].IsResearch = true
+			}
+			if mapArticleCollectNum[article.ArticleId] != nil {
+				list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
+				list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
+				list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
+			}
+			if _, ok := lyjhTypeMap[item.CategoryId]; ok && list[i].ArticleId >= utils.SummaryArticleId {
+				list[i].IsRoadShow = true
+			}
+		}
+		if item.ArticleTypeId == -1 {
+			list[i].ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
 		}
-		if mapArticleCollectNum[article.ArticleId] != nil {
-			list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
-			list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
-			list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
+		if item.SpecialType == 1 {
+			list[i].Title = "【笔记】"+list[i].Title
+		} else if list[i].SpecialType == 2 {
+			list[i].Title = "【观点】"+list[i].Title
 		}
-		if _, ok := lyjhTypeMap[item.CategoryId]; ok && list[i].ArticleId >= utils.SummaryArticleId {
-			list[i].IsRoadShow = true
+		if item.MyCollectNum > 0 {
+			list[i].IsCollect = true
 		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)

+ 1066 - 0
controllers/yanxuan_special.go

@@ -0,0 +1,1066 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+type YanxuanSpecialController struct {
+	BaseAuthController
+}
+
+// @Title 专栏列表
+// @Description 专栏列表
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /list [get]
+func (this *YanxuanSpecialController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	userId, _ := this.GetInt("UserId", 0)
+	var condition string
+	var pars []interface{}
+
+	var specialUser *models.CygxYanxuanSpecialAuthorItem
+	var err error
+	if userId > 0 {
+		condition += ` AND a.user_id = ? `
+		pars = append(pars, userId)
+	}
+
+	cond := ``
+	cond += ` AND a.status = 1 `
+	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId, cond)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + err.Error()
+		return
+	}
+
+	condition += ` AND a.status = 3 `
+
+	list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+	for _, v := range list {
+		hasImg, err := utils.ArticleHasImgUrl(v.Content)
+		if err != nil {
+			return
+		}
+		if hasImg {
+			v.ContentHasImg = 1
+		}
+		v.Content = utils.ArticleRemoveImgUrl(v.Content)
+
+		v.Content, err = utils.ExtractText(v.Content)
+		if err != nil {
+			return
+		}
+		v.Content, _ = services.GetReportContentTextSubNew(v.Content)
+		if v.DocUrl != "" {
+			var docs []models.Doc
+			err := json.Unmarshal([]byte(v.DocUrl), &docs)
+			if err != nil {
+				br.Msg = "参数解析异常!"
+				br.ErrMsg = "参数解析失败,Err:" + err.Error()
+				return
+			}
+			v.Docs = docs
+		}
+		if v.MyCollectNum > 0 {
+			v.IsCollect = 1
+		}
+		if v.CompanyTags != "" {
+			v.Tags += v.CompanyTags
+		}
+		if v.IndustryTags != "" {
+			if v.Tags != "" {
+				v.Tags += ","
+			}
+			v.Tags += v.IndustryTags
+		}
+	}
+	resp := new(models.SpecialListResp)
+
+	if specialUser != nil {
+		resp.IsAuthor = true
+	}
+	resp.List = list
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏详情
+// @Description 专栏详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /detail [get]
+func (this *YanxuanSpecialController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	specialId, _ := this.GetInt("Id", 0)
+
+	if specialId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+
+	item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+	if item.MyCollectNum > 0 {
+		item.IsCollect = 1
+	}
+
+	var resp models.CygxYanxuanSpecialResp
+	resp.CygxYanxuanSpecialItem = *item
+	if item.DocUrl != "" {
+		var docs []models.Doc
+		err := json.Unmarshal([]byte(item.DocUrl), &docs)
+		if err != nil {
+			br.Msg = "参数解析异常!"
+			br.ErrMsg = "参数解析失败,Err:" + err.Error()
+			return
+		}
+		resp.Docs = docs
+	}
+	if item.CompanyTags != "" {
+		resp.Tags += item.CompanyTags
+		resp.CompanyTags = append(resp.CompanyTags, item.CompanyTags)
+	}
+	if item.IndustryTags != "" {
+		if resp.Tags != "" {
+			resp.Tags += ","
+		}
+		resp.Tags += item.IndustryTags
+		resp.IndustryTags = append(resp.IndustryTags, item.IndustryTags)
+	}
+
+	go services.AddSpecialRecord(this.User, specialId)
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 新增保存专栏作者详情
+// @Description 新增保存专栏作者详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/save [post]
+func (this *YanxuanSpecialController) AuthorSave() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.SaveCygxYanxuanSpecialAuthorReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "用户id有误"
+		return
+	}
+	if req.SpecialName == "" {
+		br.Msg = "请输入专栏名称"
+		return
+	}
+	if req.NickName == "" {
+		br.Msg = "请输入昵称"
+		return
+	}
+
+	item := models.CygxYanxuanSpecialAuthor{
+		UserId:       req.UserId,
+		SpecialName:  req.SpecialName,
+		Introduction: req.Introduction,
+		Label:        req.Label,
+		NickName:     req.NickName,
+		CreateTime:   time.Now(),
+		ModifyTime:   time.Now(),
+		BgImg:        "",
+		Status:       1,
+	}
+
+	//if req.Id == 0{
+	//	_, err = models.AddCygxYanxuanSpecialAuthor(&item)
+	//	if err != nil {
+	//		br.Msg = "新增失败"
+	//		br.ErrMsg = "新增失败,Err:" + err.Error()
+	//		return
+	//	}
+	//} else {
+	//	err = models.UpdateYanxuanSpecialAuthor(&item)
+	//	if err != nil {
+	//		br.Msg = "保存失败"
+	//		br.ErrMsg = "保存失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
+	err = models.UpdateYanxuanSpecialAuthor(&item)
+	if err != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "保存失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 新增保存专栏
+// @Description 新增保存专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /save [post]
+func (this *YanxuanSpecialController) Save() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.CygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Content == "" && req.DoType == 2 {
+		br.Msg = "请输入内容"
+		return
+	}
+	if req.CompanyTags == "" && req.IndustryTags == "" && req.DoType == 2 {
+		br.Msg = "请至少输入一个标签"
+		return
+	}
+
+	item := models.CygxYanxuanSpecial{
+		Id:           req.Id,
+		UserId:       sysUser.UserId,
+		CreateTime:   time.Now(),
+		ModifyTime:   time.Now(),
+		PublishTime:  time.Now(),
+		Content:      req.Content,
+		ImgUrl:       req.ImgUrl,
+		DocUrl:       req.DocUrl,
+		Title:        req.Title,
+		Type:         req.Type,
+		CompanyTags:  req.CompanyTags,
+		IndustryTags: req.IndustryTags,
+	}
+	if req.DoType == 1 {
+		item.Status = 1
+	} else {
+		item.Status = 2
+	}
+
+	specialId := 0
+
+	if req.Id == 0 {
+		id, err := models.AddCygxYanxuanSpecial(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+		specialId = int(id)
+	} else {
+		err = models.UpdateYanxuanSpecial(&item)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
+		specialId = req.Id
+	}
+
+	if req.DoType == 2 {
+		go services.SendReviewTemplateMsgAdmin(specialId)
+		go services.UpdateYanxuanSpecialResourceData(specialId) //  写入首页最新  cygx_resource_data 表
+		go services.EsAddYanxuanSpecial(specialId)              //  写入es 综合搜索
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 专栏作者详情
+// @Description 专栏作者详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/detail [get]
+func (this *YanxuanSpecialController) AuthorDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	userId, _ := this.GetInt("UserId", 0)
+	if userId == 0 {
+		userId = sysUser.UserId
+	}
+	item, tmpErr := models.GetYanxuanSpecialAuthor(userId, sysUser.UserId, "")
+	if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = item
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 审批研选专栏
+// @Description 审批研选专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /enable [post]
+func (this *YanxuanSpecialController) Enable() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.EnableCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	status := 0
+	if req.Status == 1 {
+		status = 3
+	} else {
+		status = 4
+	}
+	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason); tmpErr != nil {
+		br.Msg = "审批失败"
+		br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
+		return
+	}
+	if req.Status == 1 {
+		go services.SendWxMsgSpecialFollow(req.Id)
+	}
+	go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
+	go services.UpdateYanxuanSpecialResourceData(req.Id) //  写入首页最新  cygx_resource_data 表
+	go services.EsAddYanxuanSpecial(req.Id)              //  写入es 综合搜索
+	br.Msg = "审批成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 研选专栏收藏
+// @Description 研选专栏收藏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /collect [post]
+func (this *YanxuanSpecialController) Collect() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.CollectCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	if req.Status == 1 {
+		item := models.CygxYanxuanSpecialCollect{
+			UserId:           sysUser.UserId,
+			Mobile:           sysUser.Mobile,
+			Email:            sysUser.Email,
+			CompanyId:        sysUser.CompanyId,
+			CompanyName:      sysUser.CompanyName,
+			RealName:         sysUser.RealName,
+			SellerName:       sellerName,
+			CreateTime:       time.Now(),
+			ModifyTime:       time.Now(),
+			RegisterPlatform: utils.REGISTER_PLATFORM,
+			YanxuanSpecialId: req.Id,
+		}
+		_, err = models.AddCygxYanxuanSpecialCollect(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "收藏成功"
+	} else {
+		err = models.DelCygxYanxuanSpecialCollect(sysUser.UserId, req.Id)
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "取消收藏成功"
+	}
+
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 专栏内容中心
+// @Description 专栏内容中心
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /center [get]
+func (this *YanxuanSpecialController) Center() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	// 1:未发布,2:审核中 3:已发布 4:驳回
+	status, _ := this.GetInt("Status", 0)
+
+	if status <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND a.user_id = ? `
+	pars = append(pars, sysUser.UserId)
+
+	condition += ` AND a.status = ? `
+	pars = append(pars, status)
+
+	list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	for _, v := range list {
+		hasStyle, err := utils.ArticleHasStyle(v.Content)
+		if err != nil {
+			return
+		}
+		v.ContentHasStyle = hasStyle
+		hasImg, err := utils.ArticleHasImgUrl(v.Content)
+		if err != nil {
+			return
+		}
+		if hasImg {
+			v.ContentHasStyle = hasImg
+		}
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏点击记录
+// @Description 专栏点击记录
+// @Param	request	body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
+// @router /record [post]
+func (this *YanxuanSpecialController) Record() {
+	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
+	}
+	var req models.AddCygxYanxuanSpecialRecordReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.SpecialId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	item := models.CygxYanxuanSpecialRecord{
+		UserId:           user.UserId,
+		Mobile:           user.Mobile,
+		Email:            user.Email,
+		CompanyId:        user.CompanyId,
+		CompanyName:      user.CompanyName,
+		RealName:         user.RealName,
+		SellerName:       sellerName,
+		CreateTime:       time.Now(),
+		ModifyTime:       time.Now(),
+		RegisterPlatform: utils.REGISTER_PLATFORM,
+		YanxuanSpecialId: req.SpecialId,
+	}
+	_, err = models.AddCygxYanxuanSpecialRecord(&item)
+	if err != nil {
+		br.Msg = "记录失败"
+		br.ErrMsg = "记录失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "记录成功"
+}
+
+// @Title 研选专栏关注
+// @Description 研选专栏关注
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /follow [post]
+func (this *YanxuanSpecialController) Follow() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.FollowCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.FollowUserId <= 0 {
+		br.Msg = "被关注的用户id"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	if req.Status == 1 {
+		item := models.CygxYanxuanSpecialFollow{
+			UserId:           sysUser.UserId,
+			FollowUserId:     req.FollowUserId,
+			Mobile:           sysUser.Mobile,
+			Email:            sysUser.Email,
+			CompanyId:        sysUser.CompanyId,
+			CompanyName:      sysUser.CompanyName,
+			RealName:         sysUser.RealName,
+			SellerName:       sellerName,
+			CreateTime:       time.Now(),
+			ModifyTime:       time.Now(),
+			RegisterPlatform: utils.REGISTER_PLATFORM,
+			YanxuanSpecialId: req.SpecialId,
+		}
+		err = models.AddCygxYanxuanSpecialFollow(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "关注成功"
+	} else {
+		err = models.DelCygxYanxuanSpecialFollow(sysUser.UserId, req.FollowUserId)
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "取消关注成功"
+	}
+
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 行业标签搜索
+// @Description 行业标签搜索
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /industrySearch [get]
+func (this *YanxuanSpecialController) IndustrySearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	keyword := this.GetString("Keyword")
+
+	list, tmpErr := models.GetYanxuanSpecialIndustry(keyword)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 公司标签搜索
+// @Description 公司标签搜索
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /companySearch [get]
+func (this *YanxuanSpecialController) CompanySearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	keyword := this.GetString("Keyword")
+
+	if keyword == "" {
+		br.Ret = 200
+		return
+	}
+
+	list, tmpErr := models.GetYanxuanSpecialCompany(keyword)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏取消发布
+// @Description 专栏取消发布
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /cancel [post]
+func (this *YanxuanSpecialController) Cancel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.CancelPublishCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+
+	if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
+		br.Msg = "取消发布失败"
+		br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
+		return
+	}
+	go services.UpdateYanxuanSpecialResourceData(req.Id) //  写入首页最新  cygx_resource_data 表
+	go services.EsAddYanxuanSpecial(req.Id)              //  写入es 综合搜索
+	br.Msg = "取消发布成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 作者列表
+// @Description 作者列表
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/list [get]
+func (this *YanxuanSpecialController) AuthorList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var specialUser *models.CygxYanxuanSpecialAuthorItem
+	var err error
+
+	cond := ``
+	cond += ` AND a.status = 1 `
+	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId, cond)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + err.Error()
+		return
+	}
+
+	list, tmpErr := models.GetYanxuanSpecialAuthorList()
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	for _, v := range list {
+		v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
+	}
+	resp := new(models.SpecialAuthorListResp)
+
+	if specialUser != nil {
+		resp.IsAuthor = true
+	}
+	resp.List = list
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 更新作者头像
+// @Description 更新作者头像
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/head_img [post]
+func (this *YanxuanSpecialController) AuthorHeadImg() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.SaveCygxYanxuanSpecialAuthoHeadImgrReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "用户id有误"
+		return
+	}
+	if req.HeadImg == "" {
+		br.Msg = "头像图片错误"
+		return
+	}
+
+	item := models.CygxYanxuanSpecialAuthor{
+		UserId:  req.UserId,
+		HeadImg: req.HeadImg,
+	}
+
+	err = models.UpdateYanxuanSpecialAuthorHeadImg(&item)
+	if err != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "保存失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 删除专栏
+// @Description 删除专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /del [post]
+func (this *YanxuanSpecialController) Delete() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.EnableCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+
+	if tmpErr := models.DelYanxuanSpecial(req.Id); tmpErr != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Msg = "删除成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 专栏文章敏感词检测
+// @Description 专栏文章敏感词检测
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /check [post]
+func (this *YanxuanSpecialController) Check() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.CygxYanxuanSpecialCheckReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Content == "" {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "校验成功"
+	}
+	itemToken, err := services.WxGetToken()
+	if err != nil {
+		br.Msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if itemToken.AccessToken == "" {
+		br.Msg = "accessToken is empty"
+		return
+	}
+
+	suggest := models.WxCheckContent(itemToken.AccessToken, sysUser.OpenId, req.Content)
+	if suggest == "risky" {
+		br.Msg = "文章内容含有违法违规内容"
+		br.ErrMsg = "文章内容含有违法违规内容"
+		return
+	}
+	if len(req.ImgUrl) > 0 {
+		//for _, imgUrl := range req.ImgUrl {
+		//	imgBody, err := http.Get(imgUrl)
+		//	if err != nil {
+		//		br.Msg = "图片链接有误"
+		//		br.ErrMsg = "图片链接有误"
+		//		return
+		//	}
+		//	rnStr := utils.GetRandStringNoSpecialChar(5)
+		//	savePath := time.Now().Format(utils.FormatDateTimeUnSpace) + rnStr + ".jpg"
+		//	err = file.SaveFile(imgBody, savePath)
+		//	if err != nil {
+		//		br.Msg = "保存图片错误"
+		//		br.ErrMsg = "保存图片错误"
+		//		return
+		//	}
+		//	res, err := weapp.IMGSecCheck(itemToken.AccessToken, savePath)
+		//	if err != nil {
+		//		// 处理一般错误信息
+		//		br.Msg = "图片内容含有违法违规内容"
+		//		br.ErrMsg = "图片内容含有违法违规内容"
+		//		return
+		//	}
+		//	if err := res.GetResponseError(); err != nil {
+		//		// 处理微信返回错误信息
+		//		return
+		//	}
+		//	err = os.RemoveAll(savePath)
+		//	if err != nil {
+		//		return
+		//	}
+		//}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "校验成功"
+}

+ 3 - 0
go.mod

@@ -11,11 +11,14 @@ require (
 	github.com/elastic/go-elasticsearch/v7 v7.17.1
 	github.com/go-sql-driver/mysql v1.6.0
 	github.com/medivhzhan/weapp/v2 v2.5.0
+	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/olivere/elastic/v7 v7.0.32
 	github.com/pdfcpu/pdfcpu v0.3.13
 	github.com/rdlucklib/rdluck_tools v1.0.3
 	github.com/satori/go.uuid v1.2.0 // indirect
 	github.com/tealeg/xlsx v1.0.5
+	golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
+	golang.org/x/sys v0.6.0 // indirect
 	golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
 	gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
 )

+ 4 - 2
go.sum

@@ -265,8 +265,9 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4
 github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
 github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
-github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
 github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
+github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
@@ -525,8 +526,9 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
 golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

+ 18 - 28
models/activity.go

@@ -348,14 +348,13 @@ func GetActivityListAll(condition string, pars []interface{}, uid, startSize, pa
 		//sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
 	}
 	o := orm.NewOrm()
-	sql := `SELECT art.* ,t.activity_type,t.img_url_text,c.image_url as  img_url,
+	sql := `SELECT art.* ,t.activity_type,t.img_url_text,
 		( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ?   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS is_signup,
 		( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS signup_num,
 		( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.user_id = ?  AND m.is_cancel = 0  ) AS is_cancel_meeting_reminder,
 		( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
 		FROM cygx_activity as art
-		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id
-		INNER JOIN  chart_permission  AS c ON c.chart_permission_id = art.chart_permission_id ` + sqlJiontable + ` WHERE 1= 1 `
+		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id` + sqlJiontable + ` WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
@@ -429,7 +428,7 @@ func GetScheduleCount(condition string, uid int) (count int, err error) {
 // 我的日程列表
 func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ActivityDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT art.*,t.activity_type,t.img_url_text,c.image_url as  img_url,
+	sql := `SELECT art.*,t.activity_type,t.img_url_text,
 			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ? AND s.is_cancel = 0 AND s.do_fail_type = 0) AS is_signup,
             ( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND  s.is_cancel = 0  AND s.do_fail_type = 0) AS signup_num ,
 			( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment,
@@ -437,7 +436,6 @@ func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageS
             FROM cygx_activity AS art
 			INNER JOIN cygx_my_schedule as my ON my.activity_id = art.activity_id 
 			INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id
-			INNER JOIN  chart_permission  AS c ON c.chart_permission_id = art.chart_permission_id 
             WHERE 1=1 AND my.user_id = ? `
 	if condition != "" {
 		sql += condition
@@ -479,7 +477,6 @@ func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpe
 			cygx_activity AS art
 			INNER JOIN cygx_my_schedule AS my ON my.activity_id = art.activity_id
 			INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
-			INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id 
 		WHERE
 			1 = 1 `
 	if condition != `` {
@@ -627,14 +624,12 @@ func GetActivitySendMsgListAll(endDate string) (items []*WxMsgCygxActivityList,
 FROM
 	cygx_activity AS a
 	INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
-	INNER   JOIN user_record AS c ON c.bind_account = s.mobile 
-	INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id 
+	INNER JOIN cygx_user_record AS cr ON cr.cygx_bind_account = s.mobile 
 WHERE
 	1 = 1 
 	AND s.is_send_wx_msg = 0 
 	AND s.do_fail_type = 0 
-	AND a.publish_status = 1 
-	AND c.create_platform = 4
+	AND a.publish_status = 1
 	AND a.activity_time <= ? AND a.activity_time >= NOW() 
 	AND s.is_cancel = 0
 	AND( a.activity_type_id IN (4,5,6) OR (a.activity_type_id = 3 AND a.is_limit_people = 1 )) 	GROUP BY s.id`
@@ -735,6 +730,7 @@ func GetActivityIdToSendFile(endDate string) (items []*ActivityIdRep, err error)
 type SignupExportRep struct {
 	Mobile         string `description:"手机号"`
 	CompanyName    string `description:"公司名称"`
+	CompanyId      int    `description:"公司Id"`
 	RealName       string `description:"姓名"`
 	CountryCode    string `description:"区号"`
 	OutboundMobile string `description:"外呼手机号"`
@@ -753,17 +749,17 @@ type ActivityMsgExportRep struct {
 
 func GetSignupExport(activityId int) (item []*SignupExportRep, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT  s.outbound_mobile,
+	sql := `SELECT
+			s.outbound_mobile,
 			s.country_code,
 			a.is_limit_people,
-			u.real_name,
-			( SELECT p.seller_name FROM company_product AS p WHERE p.company_id = u.company_id AND p.product_id = 2 ) AS seller_name,
-			( SELECT c.company_name FROM company AS c WHERE c.company_id = u.company_id  ) AS company_name
-			FROM
+			s.real_name,
+			s.seller_name,
+			s.company_id,
+			s.company_name 
+		FROM
 			cygx_activity_signup AS s
-			LEFT JOIN wx_user AS u ON u.user_id = s.user_id
-			LEFT JOIN cygx_activity AS a ON a.activity_id = s.activity_id
-			LEFT JOIN company_product AS p ON p.company_id = u.company_id 
+			JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
 			WHERE a.activity_id = ?  AND s.do_fail_type = 0 AND s.signup_type = 1  GROUP BY s.id `
 	_, err = o.Raw(sql, activityId).QueryRows(&item)
 	return
@@ -953,7 +949,6 @@ func GetCygxActivitySpecialDetailList(condition string, pars []interface{}, uid,
 	o := orm.NewOrm()
 	sql := ` SELECT
 	art.*,
-	c.image_url AS img_url,
 	(
 	SELECT
 		COUNT( 1 ) 
@@ -965,7 +960,6 @@ func GetCygxActivitySpecialDetailList(condition string, pars []interface{}, uid,
 	) AS is_signup
 FROM
 	cygx_activity_special AS art
-	INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id 
 WHERE
 	1 = 1 `
 	if condition != "" {
@@ -1021,14 +1015,12 @@ func GetActivityWeekPermission() (permission string, err error) {
 func GetIndustrialActivityGroupManagementList(activityId int) (items []*IndustrialManagementRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-			p.permission_name,
-			p.chart_permission_id,
+			m.chart_permission_id,
 			m.industrial_management_id,
 			m.industry_name 
 			FROM
 			cygx_industrial_activity_group_management AS am
 			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
-			INNER JOIN chart_permission AS p ON p.chart_permission_id = m.chart_permission_id 
 			WHERE
 			am.activity_id = ? AND am.source = 1`
 	_, err = o.Raw(sql, activityId).QueryRows(&items)
@@ -1201,14 +1193,13 @@ func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pa
 	}
 
 	o := orm.NewOrm()
-	sql := `SELECT art.* ,t.activity_type,t.img_url_text,c.image_url as  img_url,t.img_url_bg_yx,
+	sql := `SELECT art.* ,t.activity_type,t.img_url_text,t.img_url_bg_yx,
 		( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ?   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS is_signup,
 		( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS signup_num,
 		( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.user_id = ?  AND m.is_cancel = 0  ) AS is_cancel_meeting_reminder,
 		( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
 		FROM cygx_activity as art
-		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id
-		INNER JOIN  chart_permission  AS c ON c.chart_permission_id = art.chart_permission_id ` + sqlJiontable + ` WHERE 1= 1 `
+		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id ` + sqlJiontable + ` WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
@@ -1238,8 +1229,7 @@ func GetActivityListHomeNew(condition string, startSize, pageSize int) (items []
 	o := orm.NewOrm()
 	sql := `SELECT activity_id
 		FROM cygx_activity as art
-		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id
-		INNER JOIN  chart_permission  AS c ON c.chart_permission_id = art.chart_permission_id  WHERE 1= 1 `
+		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}

+ 1 - 1
models/activity_attendance_detail.go

@@ -151,7 +151,7 @@ type WxUserOutboundMobile struct {
 }
 
 func GetWxUserOutboundMobile(mobileStr string) (item []*WxUserOutboundMobile, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT u.real_name,u.mobile,u.outbound_mobile,u.company_id,p.company_name ,GROUP_CONCAT( DISTINCT p.seller_name SEPARATOR '/' ) AS seller_name
 			FROM wx_user as u 
 			INNER JOIN company_product AS p ON p.company_id = u.company_id 

+ 1 - 2
models/activity_meet_detail_log.go

@@ -77,8 +77,7 @@ func GetActivityMeetDetailLog(mobileStr string) (item []*CygxActivityMeetDetailL
 	o := orm.NewOrm()
 	sql := `SELECT l.* 
 			FROM
-			cygx_activity_meet_detail_log  as l 
-			INNER JOIN wx_user as u ON u.outbound_mobile = l.mobile
+			cygx_activity_meet_detail_log  as l
 			WHERE l.mobile IN (` + mobileStr + `)  GROUP BY l.mobile `
 	_, err = o.Raw(sql).QueryRows(&item)
 	return

+ 2 - 2
models/activity_offline_meeting_detail.go

@@ -83,9 +83,9 @@ type CygxActivityOfflineMeetingDetailResp struct {
 // 预约外呼列表
 func GetOfflineMeetingListWithUser(condition string, pars []interface{}) (items []*CygxActivitySignupList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT s.* , u.real_name
+	sql := `SELECT s.* 
 			FROM cygx_activity_offline_meeting_detail  as s 
-			INNER JOIN wx_user as u ON u.user_id = s.user_id  WHERE 1 =1 ` + condition
+			  WHERE 1 =1 ` + condition
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 9 - 9
models/activity_special_signup.go

@@ -29,14 +29,14 @@ type SignupSpecialStatus struct {
 	SignupStatus  int    `description:"返回状态:1:成功 、2 :人数已满 、3:调研次数已用完、 4:超时"`
 }
 
-//添加
+// 添加
 func AddCygxActivitySpecialSignup(item *CygxActivitySpecialSignup) (err error) {
 	o := orm.NewOrm()
 	_, err = o.Insert(item)
 	return
 }
 
-//获取某一用户的报名的数量
+// 获取某一用户的报名的数量
 func GetUserCygxActivitySpecialSignup(uid, activityId int) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_signup  WHERE  user_id=?  AND   activity_id =? `
 	o := orm.NewOrm()
@@ -44,7 +44,7 @@ func GetUserCygxActivitySpecialSignup(uid, activityId int) (count int, err error
 	return
 }
 
-//删除
+// 删除
 func DeleteCygxActivitySpecialSignup(uid, activityId int) (err error) {
 	o := orm.NewOrm()
 	sql := `DELETE  FROM cygx_activity_special_signup   WHERE   user_id=?   AND  activity_id=?    `
@@ -52,7 +52,7 @@ func DeleteCygxActivitySpecialSignup(uid, activityId int) (err error) {
 	return
 }
 
-//列表
+// 列表
 func GetActivityListSpecialAll(activityId int) (items []*CygxActivitySpecialSignup, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT art.*  FROM cygx_activity_special_signup as art WHERE 1= 1 AND  activity_id = ?  GROUP BY company_id`
@@ -60,7 +60,7 @@ func GetActivityListSpecialAll(activityId int) (items []*CygxActivitySpecialSign
 	return
 }
 
-//列表
+// 列表
 func GetActivityListSpecialByActivityId(activityId int) (items []*CygxActivitySpecialSignup, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT art.*  FROM cygx_activity_special_signup as art WHERE 1= 1 AND  activity_id = ? `
@@ -82,20 +82,20 @@ type CygxActivitySpecialSignupResp struct {
 	Count       string    `description:"所属销售"`
 }
 
-//列表
+// 列表
 func GetActivityListSpecialGroupByMobile(condition string, pars []interface{}) (items []*CygxActivitySpecialSignupResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT s.*,	COUNT( 1 ) AS count   FROM cygx_activity_special_signup as s INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
-			INNER JOIN wx_user AS u ON u.user_id = s.user_id ` + condition + `  GROUP BY s.mobile`
+			` + condition + `  GROUP BY s.mobile`
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
 
-//列表
+// 列表
 func GetActivityListSpecialGroupByCompanyId(condition string, pars []interface{}) (items []*CygxActivitySpecialSignupResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT *,	COUNT( 1 ) AS count   FROM cygx_activity_special_signup   as s INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
-			INNER JOIN wx_user AS u ON u.user_id = s.user_id ` + condition + `  GROUP BY s.company_id`
+			 ` + condition + `  GROUP BY s.company_id`
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 1 - 1
models/activity_special_trip.go

@@ -71,7 +71,7 @@ func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error)
 
 // 获取某一活动的报名的数量
 func GetActivitySpecialTripCountByActivityId(condition string, pars []interface{}) (count int, err error) {
-	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip as t   INNER JOIN wx_user as  u on u.user_id = t.user_id WHERE    1 = 1 ` + condition
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip as t  WHERE    1 = 1 ` + condition
 	o := orm.NewOrm()
 	err = o.Raw(sqlCount, pars).QueryRow(&count)
 	return

+ 5 - 8
models/activity_special_trip_bill.go

@@ -70,11 +70,9 @@ type CygxActivitySpecialTripBillList struct {
 func GetCygxActivitySpecialTripBillList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripBillList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-			b.*,
-			c.chart_permission_name 
+			b.*
 		FROM
 			cygx_activity_special_trip_bill AS b
-			LEFT JOIN chart_permission AS c ON c.chart_permission_id = b.chart_permission_id 
 		WHERE
 			1 = 1` + condition
 	_, err = o.Raw(sql, pars).QueryRows(&item)
@@ -146,9 +144,9 @@ func AddCygxActivitySpecialTripBillMulti(items []*CygxActivitySpecialTripBill) (
 }
 
 type SpecialBillInitReduce struct {
-	CreateTime       time.Time
-	CompanyId          int
-	CompanyName        string
+	CreateTime  time.Time
+	CompanyId   int
+	CompanyName string
 }
 
 func GetActivitySecialTirpBillForReduce() (item []*SpecialBillInitReduce, err error) {
@@ -182,10 +180,9 @@ func GetCygxActivitySpecialTripBillByCompanyIdForInit(companyId int) (item []*Cy
 	return
 }
 
-
 func UpdateCygxActivitySpecialTripBillByCompanyIdForInit(total string, id int) (err error) {
 	o := orm.NewOrm()
 	sql := ` UPDATE cygx_activity_special_trip_bill SET total=? WHERE id = ?  `
-	_, err = o.Raw(sql,total, id).Exec()
+	_, err = o.Raw(sql, total, id).Exec()
 	return
 }

+ 5 - 5
models/admin.go

@@ -11,7 +11,7 @@ type AdminMobileResp struct {
 
 // 获取销售所能查看到的手机号
 func GetAdminByRole() (items []*AdminMobileResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT mobile  FROM admin  WHERE role = 'admin' `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
@@ -56,21 +56,21 @@ type Admin struct {
 
 func GetSysAdminById(adminId int) (item *Admin, err error) {
 	sql := `SELECT * FROM admin WHERE admin_id=? `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, adminId).QueryRow(&item)
 	return
 }
 
 func GetSysAdminByMobile(mobile string) (item *Admin, err error) {
 	sql := `SELECT * FROM admin WHERE mobile=? LIMIT 1 `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, mobile).QueryRow(&item)
 	return
 }
 
 // 获取权益内部人员手机号
 func GetRaiAdmin() (items []*AdminMobileResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 	mobile
 FROM
@@ -92,7 +92,7 @@ type GetSellerUserMobileResp struct {
 
 // 获取销售所能查看到的手机号
 func GetSellerUserMobile(adminId int) (items []*GetSellerUserMobileResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT mobile FROM user_seller_relation WHERE seller_id  = ? `
 	_, err = o.Raw(sql, adminId).QueryRows(&items)
 	return

+ 3 - 1
models/apply_record.go

@@ -88,6 +88,8 @@ func AddApplyRecord(item *CygxApplyRecord) (err error) {
 	if err != nil {
 		return
 	}
+
+	ow := orm.NewOrmUsingDB("weekly_report")
 	msql := `UPDATE  wx_user
 		SET
 		  note = ?,
@@ -96,7 +98,7 @@ func AddApplyRecord(item *CygxApplyRecord) (err error) {
           real_name=?,
 		  mobile=?
 		WHERE user_id = ? `
-	_, err = o.Raw(msql, item.CompanyName, item.ApplyMethod, item.RealName, item.Mobile, item.UserId).Exec()
+	_, err = ow.Raw(msql, item.CompanyName, item.ApplyMethod, item.RealName, item.Mobile, item.UserId).Exec()
 	return
 }
 

+ 2 - 11
models/article.go

@@ -426,15 +426,6 @@ type ReportArticle struct {
 	Resource         int    `description:"来源类型,1:文章、2:产品内测"`
 }
 
-func GetReportPermission(categoryName string) (item []*ChartPermission, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT b.* FROM cygx_report_mapping AS a
-			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
-			WHERE a.sub_category_name=? `
-	_, err = o.Raw(sql, categoryName).QueryRows(&item)
-	return
-}
-
 type ReportMappingCategoryRep struct {
 	CategoryId int `description:"文章分类id"`
 }
@@ -500,9 +491,9 @@ func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err
 	//d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
 	o := orm.NewOrm()
 	sql := ` SELECT
-	( SELECT count( 1 ) FROM cygx_article_department_follow AS af INNER JOIN wx_user as u ON  u.user_id = af.user_id  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 ) 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 INNER JOIN wx_user as u ON  u.user_id = ac.user_id  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  ) 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

+ 2 - 3
models/article_collect.go

@@ -114,7 +114,6 @@ func GetUserArticleCollectList() (items []*CygxArticleCollectCountRep, err error
 			f.article_id 
 		FROM
 			cygx_article_collect AS f
-			INNER JOIN wx_user AS u ON u.user_id = f.user_id
 			INNER JOIN cygx_article AS a ON a.article_id = f.article_id 
 		WHERE
 			1 = 1 
@@ -151,8 +150,8 @@ func GetArticleCollectNum(articleId []string, uid int) (items []*CygxArticleNum,
 	sql := `SELECT
 			a.article_id,
 			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
 			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS is_collect
 		FROM
 			cygx_article AS a WHERE  1 = 1  AND  article_id IN  (` + utils.GetOrmInReplace(lenarticleId) + `) `

+ 18 - 16
models/chart_permission.go

@@ -9,6 +9,7 @@ type ChartPermission struct {
 	ChartPermissionId int    `description:"权限id"`
 	PermissionName    string `description:"权限名称"`
 	IsShowSustainable bool   `description:"是否展示限免标签"`
+	ImageUrlM         string `description:"图片地址"`
 }
 
 type ActivityChartPermission struct {
@@ -22,12 +23,19 @@ type ChartPermissionResp struct {
 }
 
 func GetChartPermissionAll(condition string) (items []*ChartPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND show_type=1  AND permission_type!=2  ` + condition + ` ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
+func GetChartPermissionListRai() (items []*ChartPermission, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT * FROM chart_permission WHERE product_id=2  ORDER BY sort ASC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 func GetCategoryId(chartPermissionId int) (category_id string, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT GROUP_CONCAT(a.category_id) AS category_id 
@@ -39,21 +47,21 @@ func GetCategoryId(chartPermissionId int) (category_id string, err error) {
 }
 
 func GetChartPermissionReportAll(condition string) (items []*ChartPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 AND permission_type!=2 ` + condition + ` ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
 func GetChartPermissionById(chartPermissionId int) (item *ChartPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM chart_permission WHERE chart_permission_id = ? `
 	err = o.Raw(sql, chartPermissionId).QueryRow(&item)
 	return
 }
 
 func GetChartPermissionActivity() (items []*ActivityChartPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM chart_permission WHERE chart_permission_id IN (19,20,21,22,23,31) ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
@@ -86,7 +94,7 @@ func GetUserCompanyPermission(companyId int) (items []*ActivityChartPermission,
 			AND b.chart_permission_name IN (` + chartPermissionName + `)
 			GROUP BY b.chart_permission_name
 			ORDER BY b.sort ASC `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -106,45 +114,39 @@ func GetUserCompanyPermissionSandO(companyId int) (items []*ActivityChartPermiss
 			AND b.chart_permission_name != '专家'
 			GROUP BY b.chart_permission_name
 			ORDER BY b.sort ASC `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Raw(sql, companyId).QueryRows(&items)
 	return
 }
 
 // 获取策略下面的所有分类
 func GetCompanyReportPermissionAll() (items []*CompanyReportPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM company_report_permission WHERE chart_permission_id IN (19,20,21,22) AND status IN ('正式','试用','永续')  AND created_time <= '2021-12-28 15:05:43'`
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
-func AddChartPersion(item *CompanyReportPermission) (newId int64, err error) {
-	o := orm.NewOrm()
-	newId, err = o.Insert(item)
-	return
-}
-
 // 获取海通国际开通的默认权限
 func GetCompanyPermissionIdWithHtgj() (chartpermissionids string, err error) {
 	sql := ` SELECT GROUP_CONCAT(DISTINCT chart_permission_id  ORDER BY b.sort ASC  SEPARATOR ',') AS chartpermissionids
 			FROM chart_permission as  b 
 			WHERE chart_permission_name IN ('医药','消费','科技','智造','买方研选')`
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql).QueryRow(&chartpermissionids)
 	return
 }
 
 // GetChartPermissionById 主键获取权限
 func GetChartPermissionByRemark(remark string) (item *ChartPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM chart_permission WHERE remark = ? LIMIT 1`
 	err = o.Raw(sql, remark).QueryRow(&item)
 	return
 }
 
 func GetChartPermissionIdByName(condition string, pars []interface{}) (chartpermissionids string, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT GROUP_CONCAT(DISTINCT chart_permission_id   SEPARATOR ',') AS chartpermissionids FROM chart_permission  WHERE product_id=2  ` + condition
 	err = o.Raw(sql, pars).QueryRow(&chartpermissionids)
 	return

+ 18 - 18
models/company.go

@@ -28,7 +28,7 @@ func GetCompanyDetailById(companyId int) (item *CompanyDetail, err error) {
 			LEFT JOIN admin AS c ON b.seller_id=c.admin_id
 			WHERE a.company_id=? AND cp.cygx_auth=1
 			OR (a.company_id = ? AND  cp.permission_name = '策略' ) ORDER BY  b.product_id  DESC LIMIT 1` // 兼容永续状态
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId, companyId).QueryRow(&item)
 	return
 }
@@ -43,7 +43,7 @@ func GetCompanyDetailByIdGroup(companyId int) (item *CompanyDetail, err error) {
 			WHERE a.company_id=? AND b.product_id = 2 
 			OR (a.company_id = ? AND  cp.permission_name = '策略' ) 
 			ORDER BY b.product_id DESC  LIMIT 0,1 `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId, companyId).QueryRow(&item)
 	return
 }
@@ -56,7 +56,7 @@ func GetCountCompanyDetailByIdGroup(companyId int) (count int, err error) {
 			INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
 			LEFT JOIN admin AS c ON b.seller_id=c.admin_id
 			WHERE a.company_id=? AND b.product_id = 2    OR (a.company_id = ? AND  cp.permission_name = '策略' )   `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId, companyId).QueryRow(&count)
 	return
 }
@@ -86,7 +86,7 @@ func GetCompanyPermission(companyId int) (permission string, err error) {
             AND b.cygx_auth=1
 			AND c.status IN('正式','试用','永续')
 			AND a.status IN('正式','试用','永续') `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return
 }
@@ -101,7 +101,7 @@ func GetCompanyPermissionName(companyId int) (permission string, err error) {
             AND b.cygx_auth=1
 			AND c.status IN('正式','试用','永续')
 			AND a.status IN('正式','试用','永续') `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return
 }
@@ -116,7 +116,7 @@ func GetCompanyPermissionByUser(companyId int) (permission string, err error) {
             AND b.cygx_auth=1
 			AND c.status IN('正式','试用','永续')
 			AND a.status IN('正式','试用','永续') `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return
 }
@@ -138,7 +138,7 @@ func GetCompanyPermissionList(companyId int) (items []*PermissionItem, err error
             AND b.cygx_auth=1
 			AND c.status IN('正式','试用','永续')
 			AND a.status IN('正式','试用','永续')   ORDER BY b.sort ASC `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Raw(sql, companyId).QueryRows(&items)
 	return
 }
@@ -152,7 +152,7 @@ func GetCompanyPermissionByUserNoStatus(companyId int) (permission string, err e
 			WHERE  a.company_id=?
 			AND c.is_suspend=0
             AND b.cygx_auth=1`
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return
 }
@@ -167,7 +167,7 @@ func GetCompanyPermissionByUserZhengShi(companyId int) (permission string, err e
 			AND c.is_suspend=0
             AND b.cygx_auth=1
 			AND a.status IN('正式') `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return
 }
@@ -180,7 +180,7 @@ func GetCompanyPermissionByName(name string) (permission string, err error) {
 			INNER JOIN company AS cm ON cm.company_id=c.company_id 
 			WHERE  cm.company_name=?
 			AND b.product_id = 2 `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, name).QueryRow(&permission)
 	return
 }
@@ -195,7 +195,7 @@ func GetCompanyDetailAllById(companyId int) (item *CompanyDetail, err error) {
 			WHERE a.company_id=? AND cp.cygx_auth=1
 			OR (a.company_id = ? AND  cp.permission_name = '策略' )` // 兼容永续状态
 	//WHERE a.company_id=?  AND b.status IN('正式','试用','永续')`
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId, companyId).QueryRow(&item)
 	return
 }
@@ -210,7 +210,7 @@ func GetSellerDetailAllByCompanyId(companyId int) (item *CompanyDetail, err erro
 			WHERE
 			b.product_id = 2 
 			AND a.company_id = ? LIMIT 1`
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&item)
 	return
 }
@@ -222,7 +222,7 @@ func GetCompanySellerName(companyId int) (sellerName string, err error) {
 			company_product AS p
 		WHERE
 			p.company_id = ? `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&sellerName)
 	return
 }
@@ -239,14 +239,14 @@ type CompanyProductDetial struct {
 // 获取对应销售以及销售的手机号
 func GetCompanyProductDetail(companyId, productId int) (item *CompanyProductDetial, err error) {
 	sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId, productId).QueryRow(&item)
 	return
 }
 
 // 获取公司详情详情
 func GetCompanyByName(companyName string) (item *Company, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT *  FROM company WHERE company_name = ? LIMIT 1`
 	err = o.Raw(sql, companyName).QueryRow(&item)
 	return
@@ -254,7 +254,7 @@ func GetCompanyByName(companyName string) (item *Company, err error) {
 
 // 获取公司详情详情
 func GetCompanyById(companyId int) (item *Company, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT *  FROM company WHERE company_id = ? LIMIT 1`
 	err = o.Raw(sql, companyId).QueryRow(&item)
 	return
@@ -262,7 +262,7 @@ func GetCompanyById(companyId int) (item *Company, err error) {
 
 // 获取公司详情详情
 func GetCompanyByThirdName(tripartiteCompanyCode string) (item *Company, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT *  FROM company WHERE tripartite_company_code = ? LIMIT 1`
 	err = o.Raw(sql, tripartiteCompanyCode).QueryRow(&item)
 	return
@@ -270,7 +270,7 @@ func GetCompanyByThirdName(tripartiteCompanyCode string) (item *Company, err err
 
 // 更新机构互动量
 func UpdateComapanyInteractionNum(interactionNum, companyId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE company SET interaction_num = ? WHERE company_id=? `
 	_, err = o.Raw(sql, interactionNum, companyId).Exec()
 	return

+ 1 - 1
models/company/company_approval.go

@@ -27,7 +27,7 @@ type CompanyApproval struct {
 
 func GetCompanyApprovalById(companyId int) (item *CompanyApproval, err error) {
 	sql := `SELECT * FROM company_approval WHERE company_id=? AND product_id=2 AND approve_status='已审批' order by company_approval_id desc LIMIT 1 `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&item)
 	return
 }

+ 1 - 1
models/company/company_contract.go

@@ -19,7 +19,7 @@ type CompanyContractPermission struct {
 }
 
 func GetCompanyContractPermissionCheck(companyContractId, permissionId int) (count int, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT COUNT(1) AS count FROM company_contract_permission AS a WHERE a.company_contract_id=? AND a.chart_permission_id=? `
 	err = o.Raw(sql, companyContractId, permissionId).QueryRow(&count)
 	return

+ 11 - 12
models/company_activity_trip.go

@@ -3,7 +3,7 @@ package models
 import "github.com/beego/beego/v2/client/orm"
 
 func GetCountCompanyDetailByIdGroupTrip(companyId int) (count int, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 	COUNT( 1 ) AS count 
 FROM
@@ -26,7 +26,7 @@ WHERE
 }
 
 func GetCompanyDetailByIdGroupTrip(companyId int) (item *CompanyDetail, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT a.company_id,a.company_name,b.status,b.seller_id,b.seller_name,c.mobile ,b.is_suspend
             FROM company AS a
 			INNER JOIN company_product AS b ON a.company_id=b.company_id
@@ -40,7 +40,7 @@ func GetCompanyDetailByIdGroupTrip(companyId int) (item *CompanyDetail, err erro
 }
 
 func GetCompanyPermissionByUserTrip(companyId int) (permission string, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 			GROUP_CONCAT( DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',' ) AS permission 
 		FROM
@@ -70,14 +70,14 @@ func GetCompanyPermissionByUserZhengShiTrip(companyId int) (permission string, e
 			AND c.is_suspend=0
             AND b.cygx_auth=1
 			AND ( a.is_upgrade = 1 AND c.STATUS = '正式' OR c.STATUS = '永续' ) `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return
 }
 
 // GetCompanyReportPermissionUpgrade 获取升级的权限类型
 func GetCompanyReportPermissionUpgrade(companyId, productId int) (items []*CompanyReportPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 	re.*
 FROM
@@ -103,14 +103,14 @@ func GetChartPermissionByIds(permissionIds []string) (list []*ChartPermission, e
 	sql := qb.String()
 
 	// 执行 SQL 语句
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
 
 // GetCompanyPermissionNameCheck 通过名称判断客户是否开了某一类型的权限
 func GetCompanyPermissionNameCheck(companyId, productId int, permissionName string) (count int, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 			COUNT( 1 ) AS count 
 		FROM
@@ -125,10 +125,9 @@ func GetCompanyPermissionNameCheck(companyId, productId int, permissionName stri
 	return
 }
 
-
 // GetCompanyReportPermissionByCompanyIdAndProductId 获取权限类型
 func GetCompanyReportPermissionByCompanyIdAndProductId(companyId, productId int) (items []*CompanyReportPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 	re.*
 FROM
@@ -144,7 +143,7 @@ WHERE
 
 // GetCompanyReportPermissionByCompanyIdAndProductIdForInit 获取权限类型-初始化用,去掉正式的判断
 func GetCompanyReportPermissionByCompanyIdAndProductIdForInit(companyId, productId int) (items []*CompanyReportPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 	re.*
 FROM
@@ -160,7 +159,7 @@ WHERE
 
 // GetCompanyReportPermissionByCompanyIdAndProductIdForInit 获取权限类型-初始化total用,去掉权限的判断
 func GetCompanyReportPermissionByCompanyIdAndProductIdForInit2(companyId, productId int) (items []*CompanyReportPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 	re.*
 FROM
@@ -172,4 +171,4 @@ WHERE
 	 `
 	_, err = o.Raw(sql, companyId, productId).QueryRows(&items)
 	return
-}
+}

+ 3 - 2
models/company_product.go

@@ -6,14 +6,15 @@ import (
 
 // 获取是否属于权益客户
 func GetCountCompanyProductCompanyId(companyId, productId int) (count int, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT  COUNT(1) AS count FROM company_product WHERE company_id = ?  AND product_id = ?  `
-	err = orm.NewOrm().Raw(sql, companyId, productId).QueryRow(&count)
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
 	return
 }
 
 // 获取列表
 func GetCompanyProductList(condition string, pars []interface{}) (items []*CompanyProduct, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT *  FROM company_product WHERE 1= 1 `
 	if condition != "" {
 		sql += condition

+ 2 - 2
models/company_report_permission.go

@@ -28,7 +28,7 @@ func GetCompanyReportPermissionDetailByCondition(condition string, pars []interf
 	if condition == "" {
 		return
 	}
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM company_report_permission  WHERE 1 = 1  ` + condition
 	err = o.Raw(sql, pars).QueryRow(&item)
 	return
@@ -36,7 +36,7 @@ func GetCompanyReportPermissionDetailByCondition(condition string, pars []interf
 
 // 列表
 func GetCompanyReportPermissionList(condition string, pars []interface{}) (items []*CompanyReportPermission, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM company_report_permission  WHERE 1= 1 `
 	if condition != "" {
 		sql += condition

+ 29 - 27
models/crm_company.go

@@ -182,23 +182,25 @@ type CompanySource struct {
 	SourceName string `description:"来源名称"`
 }
 
-//判断公司名称是否存在
+// 判断公司名称是否存在
 func GetCompanyCountByName(companyName string) (count int, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT  COUNT(1) AS count FROM company WHERE company_name = ?`
-	err = orm.NewOrm().Raw(sql, companyName).QueryRow(&count)
+	err = o.Raw(sql, companyName).QueryRow(&count)
 	return
 }
 
-//判断三方公司公司名称是否存在
+// 判断三方公司公司名称是否存在
 func GetCompanyCountByThirdName(tripartiteCompanyCode string) (count int, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT  COUNT(1) AS count FROM company WHERE tripartite_company_code = ?`
-	err = orm.NewOrm().Raw(sql, tripartiteCompanyCode).QueryRow(&count)
+	err = o.Raw(sql, tripartiteCompanyCode).QueryRow(&count)
 	return
 }
 
-//获取来源详情
+// 获取来源详情
 func GetCompanySourceByName(companyName string) (item *CompanySource, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT *  FROM company_source WHERE source_name = ?`
 	err = o.Raw(sql, companyName).QueryRow(&item)
 	return
@@ -206,7 +208,7 @@ func GetCompanySourceByName(companyName string) (item *CompanySource, err error)
 
 func GetCompanyCode() (companyCode string, err error) {
 	var num int
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT COUNT(1) AS num FROM company WHERE created_time >=? `
 	err = o.Raw(sql, time.Now().Format(utils.FormatDate)).QueryRow(&num)
 	if err != nil {
@@ -216,74 +218,74 @@ func GetCompanyCode() (companyCode string, err error) {
 	return
 }
 
-//新增客户
+// 新增客户
 func AddCompany(item *Company) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	lastId, err = o.Insert(item)
 	return
 }
 
-//更新客户基础信息
+// 更新客户基础信息
 func (company *Company) Update(cols []string) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Update(company, cols...)
 	fmt.Println(company)
 	fmt.Println(err)
 	return
 }
 
-//新增客户产品
+// 新增客户产品
 func AddCompanyProduct(item *CompanyProduct) (newId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	newId, err = o.Insert(item)
 	return
 }
 
-//新增客户产品
+// 新增客户产品
 func AddCompanyProductLog(item *CompanyProductLog) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Insert(item)
 	return
 }
 
 func GetCompanyReportPermissionCount(companyId, productId int) (count int, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT COUNT(1) AS count FROM company_report_permission WHERE company_id=? AND product_id=? `
 	err = o.Raw(sql, companyId, productId).QueryRow(&count)
 	return
 }
 
 func DeleteCompanyReportPermission(companyId, productId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` DELETE FROM company_report_permission WHERE company_id=? AND product_id=? `
 	_, err = o.Raw(sql, companyId, productId).Exec()
 	return
 }
 
-//新增客户权限
+// 新增客户权限
 func AddCompanyReportPermission(item *CompanyReportPermission) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Insert(item)
 	return
 }
 
-//新增客户权限日志
+// 新增客户权限日志
 func AddCompanyPermissionLog(item *CompanyPermissionLog) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Insert(item)
 	return
 }
 
-//新增客户操作记录
+// 新增客户操作记录
 func AddCompanyOperationRecord(item *CompanyOperationRecord) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	lastId, err = o.Insert(item)
 	return
 }
 
-//新增客户产品
+// 新增客户产品
 func AddCompanyLog(item *CompanyLog) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Insert(item)
 	return
 }
@@ -301,9 +303,9 @@ type UserSellerRelation struct {
 	CreateTime time.Time `description:"创建时间"`
 }
 
-//添加销售员与员工的关系
+// 添加销售员与员工的关系
 func AddUserSellerRelation(userId int64, companyId, sellerId, productId int, seller, mobile, email string) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	relation := UserSellerRelation{
 		UserId:     int(userId),
 		SellerId:   sellerId,

+ 267 - 0
models/cygx_yanxuan_special.go

@@ -0,0 +1,267 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecial struct {
+	Id           int       `orm:"column(id);pk"`
+	UserId       int       // 用户ID
+	CreateTime   time.Time // 创建时间
+	ModifyTime   time.Time // 修改时间
+	PublishTime  time.Time // 提审过审或驳回时间
+	Content      string    // 内容
+	Tags         string    // 标签
+	Status       int       // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl       string    // 图片链接
+	DocUrl       string    // 文档链接
+	Reason       string    // 理由
+	Title        string    // 标题
+	Type         int       // 类型1:笔记,2:观点
+	CompanyTags  string    // 公司标签
+	IndustryTags string    // 行业标签
+}
+
+type CygxYanxuanSpecialItem struct {
+	Id            int    `orm:"column(id);pk"`
+	UserId        int    // 用户ID
+	CreateTime    string // 创建时间
+	ModifyTime    string // 修改时间
+	PublishTime   string // 提审过审或驳回时间
+	Content       string // 内容
+	Tags          string // 标签
+	Status        int    // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl        string // 图片链接
+	DocUrl        string // 文档链接
+	SpecialName   string // 专栏名称
+	Introduction  string // 介绍
+	Label         string // 标签
+	NickName      string // 昵称
+	RealName      string // 姓名
+	Mobile        string // 手机号
+	HeadImg       string // 头像
+	BgImg         string // 背景图
+	Reason        string // 理由
+	Title         string // 标题
+	Type          int    // 类型1:笔记,2:观点
+	CollectNum    int
+	MyCollectNum  int
+	IsCollect     int
+	CompanyTags   string
+	IndustryTags  string
+	ContentHasImg int //正文是否包含图片 1包含 0不包含
+	Docs          []Doc
+}
+
+type CygxYanxuanSpecialResp struct {
+	CygxYanxuanSpecialItem
+	Docs         []Doc
+	CompanyTags  []string
+	IndustryTags []string
+}
+
+type CygxYanxuanSpecialCenterResp struct {
+	Id              int    `orm:"column(id);pk"`
+	UserId          int    // 用户ID
+	CreateTime      string // 创建时间
+	ModifyTime      string // 修改时间
+	PublishTime     string // 提审过审或驳回时间
+	Content         string // 内容
+	Tags            string // 标签
+	Status          int    // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl          string // 图片链接
+	DocUrl          string // 文档链接
+	SpecialName     string // 专栏名称
+	Introduction    string // 介绍
+	Label           string // 标签
+	NickName        string // 昵称
+	RealName        string // 姓名
+	Mobile          string // 手机号
+	HeadImg         string // 头像
+	BgImg           string // 背景图
+	Reason          string // 理由
+	Title           string // 标题
+	Type            int    // 类型1:笔记,2:观点
+	CollectNum      int
+	MyCollectNum    int
+	IsCollect       int
+	CompanyTags     string
+	IndustryTags    string
+	ContentHasImg   int  //正文是否包含图片 1包含 0不包含
+	ContentHasStyle bool //正文是否包含格式
+	Docs            []Doc
+	Annotation      string `description:"核心观点"`
+	Source          string `description:"来源"`
+	PublishDate     string // 提审过审或驳回时间      string `description:"核心观点"`
+}
+
+type Doc struct {
+	DocName   string
+	DocSuffix string
+	DocUrl    string
+	DocIcon   string
+}
+
+func GetYanxuanSpecialList(userId int, condition string, pars []interface{}) (items []*CygxYanxuanSpecialCenterResp, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num 
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY a.publish_time DESC `
+	_, err = o.Raw(sql, userId, pars).QueryRows(&items)
+	return
+}
+
+type EnableCygxYanxuanSpecialReq struct {
+	Id     int    // 文章id
+	Status int    // 1通过2驳回
+	Reason string //理由
+}
+
+func EnableYanxuanSpecial(id, status int, reason string) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, status, reason, id).Exec()
+	return
+}
+
+type SpecialListResp struct {
+	List     []*CygxYanxuanSpecialCenterResp
+	IsAuthor bool
+}
+
+func GetYanxuanSpecialById(specialId, userId int) (item *CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
+b.nick_name,b.real_name,b.special_name,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE a.id=? `
+	err = o.Raw(sql, userId, specialId).QueryRow(&item)
+	return
+}
+
+func GetYanxuanSpecialBySpecialId(specialId int) (item *CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*
+FROM cygx_yanxuan_special AS a
+ WHERE a.id=? `
+	err = o.Raw(sql, specialId).QueryRow(&item)
+	return
+}
+
+type CygxYanxuanSpecialReq struct {
+	Id           int    `orm:"column(id);pk"`
+	Content      string // 内容
+	Tags         string // 标签
+	DoType       int    // 1保存 2发布
+	ImgUrl       string // 图片链接
+	DocUrl       string // 文档链接
+	Title        string // 标题
+	Type         int    // 类型1:笔记,2:观点
+	IndustryTags string // 行业标签
+	CompanyTags  string // 公司标签
+}
+
+func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,company_tags=?,industry_tags=?,img_url=?,doc_url=?,type=?,status=?,
+	modify_time=NOW(),publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, item.Title, item.Content, item.CompanyTags, item.IndustryTags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.Id).Exec()
+	return
+}
+
+func GetYanxuanSpecialIndustry(keyword string) (IndustryNames []string, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	if keyword == "" {
+		sql = `SELECT industry_name FROM cygx_yanxuan_special_industry `
+	} else {
+		sql = `SELECT industry_name FROM cygx_yanxuan_special_industry WHERE industry_name LIKE '%` + keyword + `%' `
+	}
+	_, err = o.Raw(sql).QueryRows(&IndustryNames)
+	return
+}
+
+type CancelPublishCygxYanxuanSpecialReq struct {
+	Id int // 文章id
+}
+
+func CancelPublishYanxuanSpecial(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET status=1,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+type DelCygxYanxuanSpecialReq struct {
+	Id int // 文章id
+}
+
+func DelYanxuanSpecial(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `DELETE FROM cygx_yanxuan_special WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+type CygxYanxuanSpecialCheckReq struct {
+	Content string   // 内容
+	ImgUrl  []string // 图片
+}
+
+func GetYanxuanSpecialFollowUserById(specialId int) (items []int, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT b.user_id
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_follow AS b ON a.user_id = b.follow_user_id
+ WHERE a.id=? `
+	_, err = o.Raw(sql, specialId).QueryRows(&items)
+	return
+}
+
+func GetYanxuanSpecialItemById(specialId int) (item *CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
+b.nick_name,b.real_name,b.special_name
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE a.id=? `
+	err = o.Raw(sql, specialId).QueryRow(&item)
+	return
+}
+
+// 获取数量
+func GetCygxYanxuanSpecialCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 39 - 0
models/cygx_yanxuan_special_collect.go

@@ -0,0 +1,39 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialCollect struct {
+	CygxYanxuanSpecialCollectId int       `orm:"column(cygx_yanxuan_special_collect_id);pk"`
+	UserId                      int        // 用户ID
+	Mobile                      string     // 手机号
+	Email                       string     // 邮箱
+	CompanyId                   int        // 公司ID
+	CompanyName                 string     // 公司名称
+	RealName                    string     // 用户实际名称
+	SellerName                  string     // 所属销售
+	CreateTime                  time.Time  // 创建时间
+	ModifyTime                  time.Time  // 修改时间
+	RegisterPlatform            int        // 来源 1小程序,2:网页
+	YanxuanSpecialId            int        // cygx_yanxuan_special 表主键ID
+}
+
+func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type CollectCygxYanxuanSpecialReq struct {
+	Id     int    // 文章id
+	Status int    // 1收藏2取消收藏
+}
+
+func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_yanxuan_special_collect WHERE user_id=? AND yanxuan_special_id=? `
+	_, err = o.Raw(sql, userId, articleId).Exec()
+	return
+}

+ 43 - 0
models/cygx_yanxuan_special_company.go

@@ -0,0 +1,43 @@
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+type CygxYanxuanSpecialCompany struct {
+	Id        int    `orm:"column(id);pk"`
+	TradeCode string `json:"trade_code"` // 交易代码
+	SecName   string `json:"sec_name"`   // 公司名
+	PyName    string `json:"py_name"`    // 拼音名
+	Region    string `json:"region"`     // 地区
+}
+
+type VmpStocks struct {
+	Code int
+	Msg  string
+	Data []CygxYanxuanSpecialCompany
+}
+
+// 批量添加
+func AddCygxYanxuanSpecialCompanyMulti(items []*CygxYanxuanSpecialCompany) (err error) {
+	o := orm.NewOrm()
+	if len(items) > 0 {
+		//批量添加
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
+func GetYanxuanSpecialCompany(keyword string) (IndustryNames []string, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT sec_name FROM cygx_yanxuan_special_company WHERE sec_name LIKE '%` + keyword + `%' `
+	_, err = o.Raw(sql).QueryRows(&IndustryNames)
+	return
+}
+
+func DelYanxuanSpecialCompany() (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `DELETE FROM cygx_yanxuan_special_company `
+	_, err = o.Raw(sql).Exec()
+	return
+}

+ 57 - 0
models/cygx_yanxuan_special_follow.go

@@ -0,0 +1,57 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialFollow struct {
+	CygxYanxuanSpecialFollowId int        `orm:"column(cygx_yanxuan_special_follow_id);pk"`
+	UserId                     int        // 用户ID
+	FollowUserId               int        // 被关注用户ID
+	Mobile                     string     // 手机号
+	Email                      string     // 邮箱
+	CompanyId                  int        // 公司ID
+	CompanyName                string     // 公司名称
+	RealName                   string     // 用户实际名称
+	SellerName                 string     // 所属销售
+	CreateTime                 time.Time  // 创建时间
+	ModifyTime                 time.Time  // 修改时间
+	RegisterPlatform           int        // 来源 1小程序,2:网页
+	YanxuanSpecialId           int        // cygx_yanxuan_special 表主键ID
+}
+
+type FollowCygxYanxuanSpecialReq struct {
+	FollowUserId int // 被关注的用户id
+	Status       int // 1关注2取消关注
+	SpecialId    int // 研选专栏Id
+}
+
+func AddCygxYanxuanSpecialFollow(item *CygxYanxuanSpecialFollow) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func DelCygxYanxuanSpecialFollow(userId, followUserId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_yanxuan_special_follow WHERE user_id=? AND follow_user_id=? `
+	_, err = o.Raw(sql, userId, followUserId).Exec()
+	return
+}
+
+func GetCygxYanxuanSpecialFollowOpenIdList(followUserId int) (items []*OpenIdList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	cr.*,
+	c.user_id 
+FROM
+	user_record AS c
+	INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
+	INNER JOIN cygx_yanxuan_special_follow AS cf ON cf.user_id = c.user_id 
+	AND cf.follow_user_id = ? 
+WHERE
+	create_platform = 4 `
+	_, err = o.Raw(sql, followUserId).QueryRows(&items)
+	return
+}

+ 32 - 0
models/cygx_yanxuan_special_record.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialRecord struct {
+	CygxYanxuanSpecialRecordId int       `orm:"column(cygx_yanxuan_special_record_id);pk"`
+	UserId                     int       // 用户ID
+	Mobile                     string    // 手机号
+	Email                      string    // 邮箱
+	CompanyId                  int       // 公司ID
+	CompanyName                string    // 公司名称
+	RealName                   string    // 用户实际名称
+	SellerName                 string    // 所属销售
+	CreateTime                 time.Time // 创建时间
+	ModifyTime                 time.Time // 修改时间
+	RegisterPlatform           int       // 来源 1小程序,2:网页
+	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
+	StopTime                   int       // 停留时间
+}
+
+func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type AddCygxYanxuanSpecialRecordReq struct {
+	SpecialId           int `description:"专栏文章id"`
+}

+ 138 - 0
models/cygx_yanxuan_special_user.go

@@ -0,0 +1,138 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialAuthor struct {
+	Id           int       `orm:"column(id);pk"`
+	UserId       int       // 用户ID
+	SpecialName  string    // 专栏名称
+	Introduction string    // 介绍
+	Label        string    // 标签
+	NickName     string    // 昵称
+	RealName     string    // 姓名
+	Mobile       string    // 手机号
+	CreateTime   time.Time // 创建时间
+	ModifyTime   time.Time // 修改时间
+	HeadImg      string    // 头像
+	BgImg        string    // 背景图上部分
+	BgImgDown    string    // 背景图下部分
+	Status       int       // 1启用2禁用
+}
+
+type CygxYanxuanSpecialAuthorItem struct {
+	Id                int       `orm:"column(id);pk"`
+	UserId            int       // 用户ID
+	SpecialName       string    // 专栏名称
+	Introduction      string    // 介绍
+	Label             string    // 标签
+	NickName          string    // 昵称
+	RealName          string    // 姓名
+	CompanyName       string    // 公司名
+	Mobile            string    // 手机号
+	CreateTime        string    // 创建时间
+	ModifyTime        time.Time // 修改时间
+	HeadImg           string    // 头像
+	BgImg             string    // 背景图
+	BgImgDown         string    // 背景图下半部分
+	Status            int       // 1启用2禁用
+	CollectNum        int       // 被收藏数
+	FollowNum         int       // 被关注数
+	SpecialArticleNum int       // 文章数
+	LatestPublishTime time.Time // 最近更新时间
+	LatestPublishDate string    // 最近更新时间
+	IsFollow          int       // 是否已关注 1已关注 0 未关注
+	HasChangeHeadImg  int       // 是否更换过默认头像 1是,0否
+}
+
+func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type EnableCygxYanxuanSpecialAuthorReq struct {
+	UserId int // 用户ID
+	Status int // 1启用2禁用
+}
+
+// 启用禁用作者
+func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET status=?,modify_time=NOW() WHERE user_id = ? `
+	_, err = o.Raw(sql, status, userId).Exec()
+	return
+}
+
+func GetYanxuanSpecialAuthor(reqUserId, sysUserId int, cond string) (item *CygxYanxuanSpecialAuthorItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT
+	a.*,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  INNER JOIN cygx_yanxuan_special as cs ON  ac.yanxuan_special_id = cs.id  WHERE cs.user_id = a.user_id  ) AS collect_num,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_follow AS cf  WHERE cf.follow_user_id = a.user_id  ) AS follow_num,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special AS ca  WHERE ca.user_id = a.user_id AND ca.status = 3 ) AS special_article_num,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_follow AS cf  WHERE cf.follow_user_id =? AND cf.user_id = ?  ) AS is_follow 
+FROM
+	cygx_yanxuan_special_author as a WHERE a.user_id=? `
+	if cond != "" {
+		sql += cond
+	}
+	err = o.Raw(sql, reqUserId, sysUserId, reqUserId).QueryRow(&item)
+	return
+}
+
+type SaveCygxYanxuanSpecialAuthorReq struct {
+	UserId       int    // 用户ID
+	SpecialName  string // 专栏名称
+	Introduction string // 介绍
+	Label        string // 标签
+	NickName     string // 昵称
+	BgImg        string // 背景图
+}
+
+func UpdateYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET special_name=?,introduction=?,label=?,nick_name=?
+	,modify_time=NOW() WHERE user_id = ? `
+	_, err = o.Raw(sql, item.SpecialName, item.Introduction, item.Label, item.NickName, item.UserId).Exec()
+	return
+}
+
+func GetYanxuanSpecialAuthorList() (items []*CygxYanxuanSpecialAuthorItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT
+	a.*,
+	IFNULL(( SELECT publish_time FROM cygx_yanxuan_special WHERE user_id = a.user_id AND STATUS = 3 ORDER BY publish_time DESC LIMIT 1 ), a.modify_time) AS latest_publish_time
+FROM
+	cygx_yanxuan_special_author AS a
+WHERE
+	a.nick_name <> ''
+ORDER BY
+	latest_publish_time DESC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+type SpecialAuthorListResp struct {
+	List     []*CygxYanxuanSpecialAuthorItem
+	IsAuthor bool
+}
+
+type SaveCygxYanxuanSpecialAuthoHeadImgrReq struct {
+	UserId  int    // 用户ID
+	HeadImg string // 头像
+}
+
+func UpdateYanxuanSpecialAuthorHeadImg(item *CygxYanxuanSpecialAuthor) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET head_img=?,modify_time=NOW(),has_change_head_img = 1  WHERE user_id = ? `
+	_, err = o.Raw(sql, item.HeadImg, item.UserId).Exec()
+	return
+}

+ 14 - 2
models/db.go

@@ -10,11 +10,18 @@ import (
 
 func init() {
 
-	_ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
+	_ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_CYGX)
 	orm.SetMaxIdleConns("default", 50)
 	orm.SetMaxOpenConns("default", 100)
 
-	db, _ := orm.GetDB("default")
+	cygx_db, _ := orm.GetDB("default")
+	cygx_db.SetConnMaxLifetime(10 * time.Minute)
+
+	_ = orm.RegisterDataBase("weekly_report", "mysql", utils.MYSQL_URL)
+	orm.SetMaxIdleConns("weekly_report", 50)
+	orm.SetMaxOpenConns("weekly_report", 100)
+
+	db, _ := orm.GetDB("weekly_report")
 	db.SetConnMaxLifetime(10 * time.Minute)
 
 	_ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
@@ -165,6 +172,11 @@ func init() {
 		new(CygxResourceDataIndustrialGroupManagement),
 		new(CygxResourceDataIndustrialGroupSubject),
 		new(CygxIndustryFllowLog),
+		new(CygxYanxuanSpecialRecord),
+		new(CygxYanxuanSpecialCollect),
+		new(CygxYanxuanSpecial),
+		new(CygxYanxuanSpecialFollow),
+		new(CygxYanxuanSpecialCompany),
 		new(CygxQuestionnaireVote),
 		new(CygxQuestionnaireVoteOtherTheme),
 	)

+ 1 - 3
models/industrial_article_group_management.go

@@ -83,14 +83,12 @@ func GetIndustrialArticleGroupManagementList(condition string, pars []interface{
 func GetIndustrialArticleGroupManagementListByArticleId(articleId int) (items []*CygxIndustrialArticleGroupManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-			p.permission_name,
-			p.chart_permission_id,
+			m.chart_permission_id,
 			m.industrial_management_id,
 			m.industry_name 
 			FROM
 			cygx_industrial_article_group_management AS am
 			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
-			INNER JOIN chart_permission AS p ON p.chart_permission_id = m.chart_permission_id 
 			WHERE
 			am.article_id = ?`
 	_, err = o.Raw(sql, articleId).QueryRows(&items)

+ 0 - 2
models/industry_fllow.go

@@ -123,7 +123,6 @@ func GetUserFllowIndustrialList(userId int) (items []*CygxIndustryFllow, err err
 			m.industrial_management_id 
 		FROM
 			cygx_industry_fllow AS f
-			INNER JOIN wx_user AS u ON f.user_id = u.user_id
 			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = f.industrial_management_id 
 		WHERE
 			1 = 1 
@@ -145,7 +144,6 @@ func GetUserFllowIndustrialCountList() (items []*CygxIndustryFllowCountRep, err
 			f.industrial_management_id 
 		FROM
 			cygx_industry_fllow AS f
-			INNER JOIN wx_user AS u ON u.user_id = f.user_id 
 			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = f.industrial_management_id 
 		WHERE
 			1 = 1 

+ 2 - 4
models/minutesSummary.go

@@ -82,10 +82,9 @@ func GetMinutesSummarylogListAllV4(articleId int) (items []*ResearchSummaryChart
 // 列表
 func GetMinutesSummarylogListAll(articleId int) (items []*MinutesSummaryChartPermission, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name ,c.image_url,l.*
+	sql := `SELECT l.*
 			FROM
 			cygx_minutes_summary_log AS l
-			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
 			WHERE l.article_id = ? 
 			GROUP BY l.chart_permission_id
 			ORDER BY l.chart_permission_sort ASC   `
@@ -108,10 +107,9 @@ func GetMinutesSummarylogSonListAll(articleId, chartPermissionId int) (items []*
 // 列表
 func GetMinutesSummarylogSonListSecond(articleId int, artType string) (items []*CygxResearchSummaryLogSecond, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name ,c.chart_permission_id ,c.image_url_m as image_url, l.* 
+	sql := `SELECT  l.* 
 			FROM
 			cygx_minutes_summary_log AS l
-			LEFT JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
 			WHERE l.article_id = ? AND l.type =?
 			GROUP BY l.chart_permission_id
 			ORDER  BY l.chart_permission_sort ASC`

+ 1 - 1
models/page_history_record.go

@@ -61,7 +61,7 @@ func GetTimeLineRecordCount(userId, industrialManagementId int) (count int, err
 
 func GetTimeLineRecordItem(userId, industrialManagementId int) (item *CygxPageHistoryRecord, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_page_history_record WHERE user_id=? AND router = '/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=` + strconv.Itoa(industrialManagementId) + `' ORDER BY create_time DESC LIMIT 1,1 `
+	sql := `SELECT * FROM cygx_page_history_record WHERE user_id=? AND router = '/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=` + strconv.Itoa(industrialManagementId) + `' ORDER BY create_time DESC LIMIT 0,1 `
 	err = o.Raw(sql, userId).QueryRow(&item)
 	return
 }

+ 0 - 31
models/product_interior.go

@@ -36,37 +36,6 @@ type ProductInteriorIdReq struct {
 	ProductInteriorId int `description:"ID"`
 }
 
-// 添加
-func AddProductInterior(item *CygxProductInterior) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Insert(item)
-	return
-}
-
-// 修改
-func UpdateProductInterior(item *CygxProductInterior) (err error) {
-	to := orm.NewOrm()
-	updateParams := make(map[string]interface{})
-	updateParams["PublishTime"] = item.PublishTime
-	updateParams["ModifyTime"] = item.ModifyTime
-	updateParams["ColumnName"] = item.ColumnName
-	updateParams["Title"] = item.Title
-	updateParams["Status"] = item.Status
-	updateParams["Body"] = item.Body
-	updateParams["IsCancel"] = item.IsCancel
-	updateParams["VisibleRange"] = item.VisibleRange
-	updateParams["Abstract"] = item.Abstract
-	updateParams["Department"] = item.Department
-	ptrStructOrTableName := "cygx_product_interior"
-	whereParam := map[string]interface{}{"product_interior_id": item.ProductInteriorId}
-	qs := to.QueryTable(ptrStructOrTableName)
-	for expr, exprV := range whereParam {
-		qs = qs.Filter(expr, exprV)
-	}
-	_, err = qs.Update(updateParams)
-	return
-}
-
 type GetCygxProductInteriorResp struct {
 	Paging *paging.PagingItem `description:"分页数据"`
 	List   []*CygxProductInteriorResp

+ 89 - 30
models/report.go

@@ -488,7 +488,8 @@ func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
 type ArticleCollectionResp struct {
 	ArticleId              int                         `description:"文章id"`
 	Title                  string                      `description:"标题"`
-	PublishDate            string                      `description:"发布时间"`
+	PublishDate            string                      `description:"发布日期"`
+	PublishTime            time.Time                   `description:"发布时间"`
 	IndustrialManagementId int                         `description:"产业Id"`
 	IndustryName           string                      `description:"产业名称"`
 	DepartmentId           int                         `description:"作者Id"`
@@ -500,6 +501,12 @@ type ArticleCollectionResp struct {
 	Source                 int                         `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
 	ArticleTypeId          int                         `description:"文章类型ID"`
 	List                   []*IndustrialManagementResp `description:"产业列表"`
+	IsSpecial              int                         `description:"是否为研选专栏"`
+	SpecialTags            string                      `description:"研选专栏标签"`
+	UserId                 int                         `description:"作者id"`
+	SpecialType            int                         `description:"专栏类型 1:笔记,2:观点"`
+	IndustryTags           string                      `description:"研选专栏行业标签"`
+	CompanyTags            string                      `description:"研选专栏公司标签"`
 }
 
 type IndustrialManagementResp struct {
@@ -528,8 +535,8 @@ func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition
 			d.nick_name,
 			d.department_id,
 			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collection_num
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collection_num
 		FROM
 			cygx_article AS a
 			INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id 
@@ -560,8 +567,8 @@ func GetArticleCollectionList(condition string, userId int) (items []*ArticleCol
 			d.nick_name,
 			d.department_id,
 			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
 			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num
 		FROM
 			cygx_article AS a
@@ -595,45 +602,90 @@ type ArticleResearchResp struct {
 	ArticleTypeId   int                         `description:"文章类型ID"`
 	ArticleTypeName string                      `description:"类型名称"`
 	ButtonStyle     string                      `description:"按钮展示样式"`
+	IsSpecial       int                         `description:"是否为研选专栏"`
+	SpecialTags     string                      `description:"研选专栏标签"`
+	UserId          int                         `description:"作者id"`
 	List            []*IndustrialManagementResp `description:"产业列表"`
 }
 
 // 获取我的日程数量
-func GetArticleResearchCount(condition string, pars []interface{}) (count int, err error) {
+func GetArticleResearchCount(condition string, pars []interface{}, needYanxuanSpecial bool) (count int, err error) {
 	o := orm.NewOrm()
 	sqlCount := `SELECT COUNT( 1 ) AS count FROM
 			cygx_article AS a
 		WHERE
 			1 = 1  AND a.publish_status = 1` + condition
+	if needYanxuanSpecial {
+		sqlCount = `SELECT SUM(count) AS count FROM (` + sqlCount + `
+		UNION ALL
+	SELECT COUNT( 1 ) AS count FROM
+		cygx_yanxuan_special AS a WHERE
+	1 = 1  AND a.status = 3) AS c`
+	}
 	err = o.Raw(sqlCount, pars).QueryRow(&count)
 	return
 }
 
-func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleCollectionResp, err error) {
+func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			a.article_id,
 			a.title,
-			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
+			a.publish_date AS publish_time,
 			a.article_type_id,
 			d.nick_name,
 			d.department_id,
 			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
-			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac    WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num,
+			0 AS is_special,
+			0 AS special_type,
+			0 AS user_id,
+			'' AS company_tags, 
+			'' AS industry_tags
 		FROM
 			cygx_article AS a
 			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
 			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
 		WHERE
-			1 = 1  AND a.publish_status = 1  `
+			1 = 1  AND a.publish_status = 1
+		  `
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` GROUP BY a.article_id ORDER  BY   a.publish_date DESC  LIMIT ?,? `
-	_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	sql += ` GROUP BY a.article_id  `
+	if needYanxuanSpecial {
+		sql += `UNION ALL
+	SELECT
+		a.id AS article_id,
+		a.title AS title,
+		a.publish_time AS publish_time,
+		-1 AS article_type_id,
+		b.nick_name AS nick_name,
+		a.user_id AS department_id,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+		0 AS collect_num_order,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
+		1 AS is_special,
+		a.type AS special_type,
+		a.user_id AS user_id,
+		a.company_tags AS company_tags, 
+		a.industry_tags AS industry_tags 
+	FROM
+	cygx_yanxuan_special AS a
+	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+	WHERE
+	1 = 1  AND a.status = 3 `
+		sql += ` ORDER  BY publish_time DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		sql += ` ORDER  BY publish_time DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	}
+
 	return
 }
 
@@ -926,9 +978,9 @@ func GetDepartmentDetail(userId, departmentId int, condition string) (item Depar
 			d.nick_name,
 			d.img_url,
 			( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.user_id = ? AND af.department_id = d.department_id AND af.type= 1 ) AS my_fllow_num,
-			( SELECT count( 1 ) FROM cygx_article_department_follow AS f INNER JOIN wx_user as u ON  u.user_id = f.user_id   WHERE f.department_id = d.department_id  AND f.type= 1 ) AS fllow_num,
+			( SELECT count( 1 ) FROM cygx_article_department_follow AS f    WHERE f.department_id = d.department_id  AND f.type= 1 ) AS fllow_num,
 			( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ` + condition + `  ) AS article_num,
-			( SELECT count( 1 ) FROM cygx_article_collect  AS c INNER JOIN wx_user as u ON  u.user_id = c.user_id   WHERE c.article_id IN (SELECT  article_id FROM cygx_article AS a WHERE a.department_id = d.department_id  ` + condition + ` )) AS collect_num
+			( SELECT count( 1 ) FROM cygx_article_collect  AS c    WHERE c.article_id IN (SELECT  article_id FROM cygx_article AS a WHERE a.department_id = d.department_id  ` + condition + ` )) AS collect_num
 		FROM
 			cygx_article_department AS d 
 		WHERE
@@ -1021,20 +1073,27 @@ type ReportBillboardTableListResp struct {
 
 // 报告榜单start
 type ArticleReportBillboardResp struct {
-	ArticleId      int    `description:"文章id"`
-	Title          string `description:"标题"`
-	PublishDate    string `description:"发布时间"`
-	PermissionName string `description:"行业名称"`
-	DepartmentId   int    `description:"作者Id"`
-	NickName       string `description:"作者昵称"`
-	IsCollect      bool   `description:"本人是否收藏"`
-	Pv             int    `description:"PV"`
-	CollectNum     int    `description:"收藏人数"`
-	Source         int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
-	IsRoadShow     bool   `description:"是否是路演精华"`
-	CategoryId     int    `description:"分类ID"`
-	IsResearch     bool   `description:"是否属于研选"`
-	List           []*IndustrialManagementIdInt
+	ArticleId       int    `description:"文章id"`
+	Title           string `description:"标题"`
+	PublishDate     string `description:"发布时间"`
+	PermissionName  string `description:"行业名称"`
+	DepartmentId    int    `description:"作者Id"`
+	NickName        string `description:"作者昵称"`
+	IsCollect       bool   `description:"本人是否收藏"`
+	Pv              int    `description:"PV"`
+	CollectNum      int    `description:"收藏人数"`
+	Source          int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	IsRoadShow      bool   `description:"是否是路演精华"`
+	CategoryId      int    `description:"分类ID"`
+	IsResearch      bool   `description:"是否属于研选"`
+	ArticleTypeId   int    `description:"文章类型ID"`
+	ArticleTypeName string `description:"文章类型名称"`
+	IsSpecial       int    `description:"是否为研选专栏"`
+	SpecialTags     string `description:"研选专栏标签"`
+	MyCollectNum    int    `description:"本人是否收藏"`
+	SpecialType     int    `description:"专栏类型 1:笔记,2:观点"`
+	UserId          int    `description:"作者id"`
+	List            []*IndustrialManagementIdInt
 }
 
 type ArticleReportBillboardLIstResp struct {

+ 2 - 4
models/report_selection.go

@@ -170,10 +170,9 @@ func GetReportSelectionListHome(condition, tbdb string, pars []interface{}, star
 // 列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.*  ,l.company_label as label
+	sql := `SELECT s.subject_name , l.*  ,l.company_label as label
 			FROM
 			cygx_report_selection_log AS l
-			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
 			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
 			WHERE l.article_id = ? `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
@@ -183,10 +182,9 @@ func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLo
 // 列表
 func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name , l.* ,l.company_label as label
+	sql := `SELECT  l.* ,l.company_label as label
 			FROM
 			cygx_report_selection_log AS l
-			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
 			LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
 			WHERE l.article_id = ? AND l.chart_permission_id =?`
 	_, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)

+ 1 - 2
models/report_selection_chart_log.go

@@ -27,9 +27,8 @@ type AddCygxReportSelectionChartLog struct {
 
 func GetCygxReportSelectionChartLogRepList(articleId int) (items []*CygxReportSelectionChartLogRep, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT l.*,c.chart_permission_name
+	sql := `SELECT l.*
 			FROM cygx_report_selection_chart_log AS l
-			LEFT JOIN chart_permission as c  ON c.chart_permission_id = l.chart_permission_id
 			WHERE  1= 1 AND article_id=?  `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return

+ 1 - 2
models/researchSummary.go

@@ -89,10 +89,9 @@ func GetResearchSummarylogListFirst(articleId int) (items []*ResearchSummaryChar
 // 列表
 func GetResearchSummarylogSonListSecond(articleId int, artType string) (items []*CygxResearchSummaryLogSecond, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name ,c.chart_permission_id ,c.image_url_m as image_url, l.* 
+	sql := `SELECT  l.* 
 			FROM
 			cygx_research_summary_log AS l
-			LEFT JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 
 			WHERE l.article_id = ? AND l.type =?
 			GROUP BY l.chart_permission_id
 			ORDER  BY l.chart_permission_sort ASC`

+ 9 - 0
models/resource_data.go

@@ -38,6 +38,7 @@ type CygxResourceDataResp struct {
 	ProductInterior    *CygxProductInteriorResp                `description:"产品内测"`
 	IndustrialResource *IndustrialManagementHotResp            `description:"产业资源包"`
 	ReportSelection    *CygxReportSelectionRep                 `description:"重点公司(原报告精选)"`
+	YanxuanSpecial     *CygxYanxuanSpecialCenterResp           `description:"研选专栏"`
 }
 
 // Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
@@ -134,3 +135,11 @@ func GetCygxResourceDataByIdAndSource(sourceId int, source string) (item *CygxRe
 	err = o.Raw(sql, sourceId, source).QueryRow(&item)
 	return
 }
+
+// 获取数量
+func GetCygxResourceDataBySourceAndIdCount(sourceId int, source string) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_resource_data  WHERE  source_id = ? AND source =?  `
+	err = o.Raw(sqlCount, sourceId, source).QueryRow(&count)
+	return
+}

+ 5 - 5
models/seller.go

@@ -21,7 +21,7 @@ type AdminItem struct {
 }
 
 func GetSellerByCompanyId(companyId int) (item *AdminItem, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT b.*,c.open_id,c.user_id,a.company_name FROM company_product AS a
 			INNER JOIN admin AS b ON a.seller_id=b.admin_id
 			LEFT JOIN wx_user AS c ON b.mobile=c.mobile
@@ -31,7 +31,7 @@ func GetSellerByCompanyId(companyId int) (item *AdminItem, err error) {
 }
 
 func GetSellerByCompanyIdCheckFicc(companyId, productId int) (item *AdminItem, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT b.*,c.open_id,c.user_id,a.company_name FROM company_product AS a
 			INNER JOIN admin AS b ON a.seller_id=b.admin_id
 			LEFT JOIN wx_user AS c ON b.mobile=c.mobile
@@ -41,7 +41,7 @@ func GetSellerByCompanyIdCheckFicc(companyId, productId int) (item *AdminItem, e
 }
 
 func GetSellerByName(userName string) (item *AdminItem, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT * FROM admin WHERE real_name=? `
 	err = o.Raw(sql, userName).QueryRow(&item)
 	return
@@ -54,9 +54,9 @@ func GetSellerByAdminId(adminId int) (item *AdminItem, err error) {
 	return
 }
 
-//获取本组的销售ID
+// 获取本组的销售ID
 func GetSelleridWhichGroup(companyId, productId int) (adminId string, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 			GROUP_CONCAT( DISTINCT admin_id SEPARATOR ',' ) AS adminId
 			FROM

+ 22 - 22
models/send_company_user.go

@@ -62,16 +62,16 @@ type CompanyUnJsonList struct {
 	SyncData []CompanyJson `json:"sync_data"`
 }
 
-//删除用户
+// 删除用户
 type ShangHaiCrmUserDeleteResp struct {
 	Social string `json:"social"`
 	Mobile string `json:"phone"`
 	Name   string `json:"name"`
 }
 
-//获取公司
+// 获取公司
 func GetSendCompanyList(condition string) (items []*CompanyJson, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 			c.company_name,
 			c.company_id as cid, 
@@ -122,7 +122,7 @@ type PermissionDataResp struct {
 }
 
 func GetSendCompanyPermissionDataList(condition string, pars []interface{}) (items []*PermissionDataResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 				company_id,
 				c.permission_name,
@@ -140,9 +140,9 @@ func GetSendCompanyPermissionDataList(condition string, pars []interface{}) (ite
 	return
 }
 
-//获取FICC公司
+// 获取FICC公司
 func GetSendCompanyFiccList(condition string) (items []*CompanyJson, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 			c.company_name,
 			c.company_id AS cid,
@@ -209,9 +209,9 @@ func GetSendCompanyFiccList(condition string) (items []*CompanyJson, err error)
 	return
 }
 
-//获取用户
+// 获取用户
 func GetSendUserList(condition string) (items []*UserJson, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 			c.credit_code,
 			u.real_name,
@@ -272,9 +272,9 @@ type WxUserOpLogDeleteResp struct {
 	RealName         string `description:"真实姓名"`
 }
 
-//获取指定时间内更新的用户
+// 获取指定时间内更新的用户
 func GetWxUserOpLog(createTime string) (items []*WxUserOpLogResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 			u.company_id 
 		FROM
@@ -286,9 +286,9 @@ func GetWxUserOpLog(createTime string) (items []*WxUserOpLogResp, err error) {
 	return
 }
 
-//获取指定时间内删除的用户
+// 获取指定时间内删除的用户
 func GetWxUserOpLogDelete(createTime string) (items []*WxUserOpLogDeleteResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 			l.*,
 			c.credit_code 
@@ -299,9 +299,9 @@ func GetWxUserOpLogDelete(createTime string) (items []*WxUserOpLogDeleteResp, er
 	return
 }
 
-//获取指定时间内被暂停的客户
+// 获取指定时间内被暂停的客户
 func GetWxUserOpLogSuspend(createTime string) (items []*WxUserOpLogDeleteResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 				* 
 			FROM
@@ -313,9 +313,9 @@ func GetWxUserOpLogSuspend(createTime string) (items []*WxUserOpLogDeleteResp, e
 	return
 }
 
-//获取指定时间内被移动的客户
+// 获取指定时间内被移动的客户
 func GetCompanyOperationRecord(createTime string) (items []*WxUserOpLogDeleteResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 				* 
 			FROM
@@ -327,25 +327,25 @@ func GetCompanyOperationRecord(createTime string) (items []*WxUserOpLogDeleteRes
 	return
 }
 
-//获取指定时间内试用转冻结,冻结转流失的客户
+// 获取指定时间内试用转冻结,冻结转流失的客户
 func GetCompanyFreezeAndLoss(createTime string) (items []*WxUserOpLogResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT * FROM  company_operation_record WHERE status IN ('冻结','流失') AND  create_time >  '` + createTime + `'  GROUP BY company_id `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
-//获取指定时间内被移动的用户
+// 获取指定时间内被移动的用户
 func GetWxUserOpLogList(startDate, endDate string) (items []*WxUserOpLogResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT company_id,user_id,mobile FROM wx_user_op_log WHERE  log_type IN ('move','add') AND create_time >=  '` + startDate + `' AND create_time <=  '` + endDate + `'    GROUP BY user_id `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
-//获取指定时间内被删除的用户
+// 获取指定时间内被删除的用户
 func GetWxUserOpLogDeleteList(startDate, endDate string) (items []*WxUserOpLogResp, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT company_id,user_id,mobile FROM wx_user_op_log WHERE  log_type IN ('delete') AND create_time >=  '` + startDate + `' AND create_time <=  '` + endDate + `'   GROUP BY user_id `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return

+ 1 - 0
models/tactics.go

@@ -120,6 +120,7 @@ type TacticsListResp struct {
 	MatchTypeName     string `description:"匹配类型"`
 	ChartPermissionId int    `description:"行业ID"`
 	CategoryImgUrlPc  string `description:"图片"`
+	IsShowAbstract    bool   `description:"是否展示摘要"`
 	List              []*ReportArticle
 }
 

+ 100 - 36
models/user.go

@@ -29,16 +29,25 @@ type UserDetail struct {
 }
 
 func GetUserDetailByUserId(userId int) (item *UserDetail, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT *,
-	( 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 = ? AND art.publish_status = 1 ) AS con_num,
-	(SELECT	COUNT( 1 ) AS count FROM
-		( SELECT count(*) FROM cygx_article_history_record AS a WHERE a.user_id = ?  GROUP BY a.article_id ) b ) AS history_num ,
-	( SELECT COUNT( 1 ) AS count FROM	cygx_my_schedule AS a INNER JOIN cygx_activity AS art ON art.activity_id = a.activity_id WHERE
-		a.user_id = ? AND art.publish_status = 1 AND art.active_state != 3 ) AS schedule_num
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT *
 	FROM wx_user WHERE user_id = ? `
-	err = o.Raw(sql, userId, userId, userId, userId).QueryRow(&item)
+	err = o.Raw(sql, userId).QueryRow(&item)
+	return
+}
+
+// 足迹数量
+func GetArticleUserHistoryNum(userId int) (count int, err error) {
+	sql := `SELECT	count(*) AS count FROM	( SELECT count(*) FROM cygx_article_history_record AS a WHERE a.user_id = ? GROUP BY a.article_id ) AS c  `
+	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	return
+}
+
+// 我的日程数量
+func GetArticleUserScheduleNum(userId int) (count int, err error) {
+	sql := `SELECT COUNT( 1 ) AS count FROM	cygx_my_schedule AS a INNER JOIN cygx_activity AS art ON art.activity_id = a.activity_id WHERE
+		a.user_id = ? AND art.publish_status = 1 AND art.active_state != 3  `
+	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
 	return
 }
 
@@ -58,6 +67,7 @@ type LoginReq struct {
 
 func PcBindMobile(unionId, mobile string, userId, loginType int) (wxUserId int, err error) {
 	//loginType  登录方式:1:手机,2:邮箱
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ``
 	if loginType == 1 {
 		sql = `SELECT * FROM wx_user WHERE mobile = ? `
@@ -65,7 +75,7 @@ func PcBindMobile(unionId, mobile string, userId, loginType int) (wxUserId int,
 		sql = "SELECT * FROM wx_user WHERE email = ? "
 	}
 	user := new(WxUser)
-	o := orm.NewOrm()
+
 	err = o.Raw(sql, mobile).QueryRow(&user)
 
 	if err != nil && err.Error() != utils.ErrNoRow() {
@@ -148,16 +158,65 @@ type CheckStatusResp struct {
 }
 
 func GetArticleUserCollectCount(userId int) (count int, err error) {
-	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=? AND art.publish_status = 1  `
-	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	sql := `SELECT SUM(count) AS count FROM (
+			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=? AND art.publish_status = 1  
+			UNION ALL
+			SELECT COUNT(1) AS count FROM cygx_yanxuan_special_collect AS a
+			INNER JOIN cygx_yanxuan_special as b ON b.id = a.yanxuan_special_id 
+			WHERE a.user_id=? AND b.status = 3) AS c 
+			 `
+	err = orm.NewOrm().Raw(sql, userId, userId).QueryRow(&count)
 	return
 }
 
 func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleReportBillboardResp, err error) {
-	sql := `SELECT a.*,art.category_id FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id
+	sql := `SELECT 
+		a.article_id,
+		art.category_id,
+		'' AS title,
+		'' AS publish_date,
+		'' AS nick_name,
+		0 AS article_type_id,
+		'' AS article_type_name,
+		0 AS is_special,
+		'' AS special_tags,
+		0 AS pv,
+		0 AS collect_num,
+		0 AS my_collect_num,
+		0 AS special_type,
+		a.user_id AS user_id,
+		a.create_time AS create_time 
+			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)
+			UNION ALL
+	SELECT
+		a.id AS article_id,
+		0 AS category_id,
+		a.title AS title,
+		date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
+		b.nick_name AS nick_name,
+		-1 AS article_type_id,
+		'' AS article_type_name,
+		1 AS is_special,
+		a.tags AS special_tags,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
+		a.type AS special_type,
+		a.user_id AS user_id,
+		c.create_time AS create_time 
+	FROM
+	cygx_yanxuan_special AS a
+	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+	JOIN cygx_yanxuan_special_collect AS c ON a.id = c.yanxuan_special_id
+	WHERE
+	1 = 1  AND a.status = 3	AND c.user_id=? 		
+	ORDER BY create_time DESC 
+LIMIT ?,? `
+	_, err = orm.NewOrm().Raw(sql, userId, userId, userId, startSize, pageSize).QueryRows(&items)
 	return
 }
 
@@ -228,7 +287,7 @@ type CountryCodeItem struct {
 }
 
 func AddCountryCode(CountryCode string, user *WxUserItem) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	if user.OutboundCountryCode == "" {
 		sql := `UPDATE wx_user SET country_code=?,outbound_mobile=?,outbound_country_code=?  WHERE user_id=? `
 		_, err = o.Raw(sql, CountryCode, user.OutboundMobile, user.OutboundCountryCode, user.UserId).Exec()
@@ -247,7 +306,7 @@ type OutboundMobileItem struct {
 }
 
 func AddOutboundMobile(item *OutboundMobileItem, userId int) (err error) {
-	o, err := orm.NewOrm().Begin()
+	o, err := orm.NewOrmUsingDB("weekly_report").Begin()
 	if err != nil {
 		return
 	}
@@ -273,7 +332,7 @@ func AddOutboundMobile(item *OutboundMobileItem, userId int) (err error) {
 
 // 用户绑定手机号时同时绑定外呼手机号
 func BindUserOutboundMobile(mobile, countryCode string, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ?, country_code= ? WHERE user_id=? `
 	_, err = o.Raw(sql, mobile, countryCode, countryCode, userId).Exec()
 	return
@@ -281,7 +340,7 @@ func BindUserOutboundMobile(mobile, countryCode string, userId int) (err error)
 
 // 已经绑定手机号,没有绑定外呼手机号的的用户,预约外呼的时候,将外呼手机号同步成手机号
 func BindUserOutboundMobileByMobile(mobile, countryCode string, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ? WHERE user_id=? `
 	_, err = o.Raw(sql, mobile, countryCode, userId).Exec()
 	return
@@ -289,21 +348,22 @@ func BindUserOutboundMobileByMobile(mobile, countryCode string, userId int) (err
 
 // 将手机号为11位的用户,区号默认设置为86
 func ChangeUserOutboundMobileByMobile(userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET country_code = 86 WHERE user_id=? `
 	_, err = o.Raw(sql, userId).Exec()
 	return
 }
 
 type UserWhiteList struct {
-	Mobile      string `description:"手机号码"`
-	RealName    string `description:"用户实际名称"`
-	CompanyName string `description:"公司名称"`
-	Permission  string `description:"拥有权限分类,多个用英文逗号分隔"`
-	CountryCode string `description:"区号"`
-	SellerName  string `description:"销售姓名"`
-	CreatedTime time.Time
-	Status      string `description:"客户状态'试用','永续','冻结','流失','正式','潜在'"`
+	Mobile         string `description:"手机号码"`
+	OutboundMobile string `description:"外呼手机号"`
+	RealName       string `description:"用户实际名称"`
+	CompanyName    string `description:"公司名称"`
+	Permission     string `description:"拥有权限分类,多个用英文逗号分隔"`
+	CountryCode    string `description:"区号"`
+	SellerName     string `description:"销售姓名"`
+	CreatedTime    time.Time
+	Status         string `description:"客户状态'试用','永续','冻结','流失','正式','潜在'"`
 }
 
 type UserWhiteListRep struct {
@@ -312,6 +372,7 @@ type UserWhiteListRep struct {
 
 // 获取正式试用用户白名单
 func GetFormalUserWhiteList(fieldStr, condition string) (items []*UserWhiteList, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT ` + fieldStr + `
 		(SELECT cp.seller_name FROM company_product  AS cp WHERE cp.company_id = u.company_id ORDER BY cp.product_id DESC  LIMIT 0,1 ) as seller_name,
 		GROUP_CONCAT( DISTINCT b.chart_permission_name SEPARATOR '/' ) AS permission
@@ -325,12 +386,13 @@ func GetFormalUserWhiteList(fieldStr, condition string) (items []*UserWhiteList,
 		AND b.product_id = 2
 		AND u.company_id >1 ` + condition + `
 		GROUP BY u.user_id`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
 // 获取永续用户白名单
 func GetSustainableUserWhiteList(fieldStr, condition string) (items []*UserWhiteList, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT ` + fieldStr + `
 			(SELECT cp.seller_name FROM company_product  AS cp WHERE cp.company_id = u.company_id ORDER BY cp.product_id DESC  LIMIT 0,1 ) as seller_name,
 			(SELECT
@@ -351,7 +413,7 @@ func GetSustainableUserWhiteList(fieldStr, condition string) (items []*UserWhite
 			WHERE 1 = 1
 			AND u.company_id > 1  ` + condition + `
 			GROUP BY u.user_id `
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
@@ -371,6 +433,7 @@ type GetSendEmailAllUserWithRAIRep struct {
 }
 
 func GetSendEmailAllUserWithRAI() (items []*GetSendEmailAllUserWithRAIRep, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 			c.company_name,
 			c.credit_code,
@@ -398,7 +461,7 @@ func GetSendEmailAllUserWithRAI() (items []*GetSendEmailAllUserWithRAIRep, err e
 			c.company_id 
 		ORDER BY
 			c.company_id DESC`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
@@ -414,6 +477,7 @@ type GetSendEmailAllUserWithCompanyRep struct {
 }
 
 func GetSendEmailAllUserWithCompany() (items []*GetSendEmailAllUserWithCompanyRep, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 			u.real_name,
 			u.mobile,
@@ -432,7 +496,7 @@ func GetSendEmailAllUserWithCompany() (items []*GetSendEmailAllUserWithCompanyRe
 			u.user_id 
 		ORDER BY
 			c.company_id ASC`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
@@ -445,7 +509,7 @@ type UserEmail struct {
 
 // 更改用户手机号
 func UpdateUserHeadimgurl(headimgurl string, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET headimgurl = ? WHERE user_id=? `
 	_, err = o.Raw(sql, headimgurl, userId).Exec()
 	return
@@ -453,7 +517,7 @@ func UpdateUserHeadimgurl(headimgurl string, userId int) (err error) {
 
 // 更改用户邮箱号
 func UpdateUserEmail(email string, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET email = ? WHERE user_id=? `
 	_, err = o.Raw(sql, email, userId).Exec()
 	return
@@ -461,7 +525,7 @@ func UpdateUserEmail(email string, userId int) (err error) {
 
 // 更新用户标签
 func UpdateUserLabel(userLabel string, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET user_label = ? WHERE user_id=? `
 	_, err = o.Raw(sql, userLabel, userId).Exec()
 	return
@@ -469,7 +533,7 @@ func UpdateUserLabel(userLabel string, userId int) (err error) {
 
 // 更新用户互动量
 func UpdateUserInteractionNum(interactionNum, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET interaction_num = ? WHERE user_id=? `
 	_, err = o.Raw(sql, interactionNum, userId).Exec()
 	return

+ 5 - 4
models/user_invitee.go

@@ -18,16 +18,17 @@ type UserInvitee struct {
 	InviteeEmail      string    `description:"邀请人邮箱"`
 }
 
-//添加收藏信息
+// 添加收藏信息
 func AddUserInvite(item *UserInvitee) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	lastId, err = o.Insert(item)
 	return
 }
 
-//获取数量
+// 获取数量
 func GetUserInviteeCount(userId int) (count int, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT COUNT(1) AS count FROM user_invitee WHERE inviteed_user_id=? `
-	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	err = o.Raw(sql, userId).QueryRow(&count)
 	return
 }

+ 2 - 1
models/user_label.go

@@ -31,7 +31,8 @@ type CygxUserLabel struct {
 
 // 获取数量
 func GetCygxUserLabelCount(condition string, pars []interface{}) (count int, err error) {
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_label as art WHERE 1= 1   AND modify_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)  `
+	//sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_label as art WHERE 1= 1   AND modify_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)  `
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_label as art WHERE 1= 1   `
 	if condition != "" {
 		sqlCount += condition
 	}

+ 69 - 64
models/user_record.go

@@ -27,14 +27,15 @@ type UserRecord struct {
 
 // 根据openid获取用户关系
 func GetUserRecordByOpenId(openId string) (item *UserRecord, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM user_record WHERE open_id=? `
-	err = orm.NewOrm().Raw(sql, openId).QueryRow(&item)
+	err = o.Raw(sql, openId).QueryRow(&item)
 	return
 }
 
 // 根据openid解除绑定用户关系
 func UnBindUserRecordByOpenid(openId string) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	msql := ` UPDATE user_record SET user_id = 0,bind_account="" WHERE open_id = ? `
 	_, err = o.Raw(msql, openId).Exec()
 	return
@@ -42,37 +43,22 @@ func UnBindUserRecordByOpenid(openId string) (err error) {
 
 // 根据用户id和平台id获取用户关系
 func GetUserRecordByUserId(userId, platform int) (item *UserRecord, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM user_record WHERE user_id=? AND create_platform = ?`
-	err = orm.NewOrm().Raw(sql, userId, platform).QueryRow(&item)
-	return
-}
-
-// 根据用户id和平台id获取用户关系
-func GetUserRecordByUserIdByXzs(mobile string, platform int) (item *OpenIdList, err error) {
-	sql := `SELECT
-			cr.open_id,
-			u.user_id
-		FROM
-			wx_user AS u
-			INNER JOIN user_record AS r ON r.user_id = u.user_id
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
-		WHERE
-			u.mobile = ? 
-			AND create_platform = ?`
-	err = orm.NewOrm().Raw(sql, mobile, platform).QueryRow(&item)
+	err = o.Raw(sql, userId, platform).QueryRow(&item)
 	return
 }
 
 // 添加用户关系
 func AddUserRecord(record *UserRecord) (recordId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	recordId, err = o.Insert(record)
 	return
 }
 
 // 根据openid绑定用户关系
 func BindUserRecordByOpenid(userId int, openId, bindAccount string) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	msql := " UPDATE user_record SET user_id = ?,bind_account=? WHERE open_id = ? "
 	_, err = o.Raw(msql, userId, bindAccount, openId).Exec()
 	return
@@ -80,7 +66,7 @@ func BindUserRecordByOpenid(userId int, openId, bindAccount string) (err error)
 
 // 修改用户微信信息
 func ModifyUserRecordInfo(openId, nickName, headimgUrl, city, province, country, sessionKey string, sex, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE user_record SET nick_name=?,headimgurl=?,sex=?,city=?,province=?,country=?,session_key=? WHERE user_id=? and open_id=? `
 	_, err = o.Raw(sql, nickName, headimgUrl, sex, city, province, country, sessionKey, userId, openId).Exec()
 	return
@@ -88,7 +74,7 @@ func ModifyUserRecordInfo(openId, nickName, headimgUrl, city, province, country,
 
 // 修改用户微信信息
 func ModifyUserRecordByDetail(openId, unionId, nickName, headimgUrl, city, province, country string, sex, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE user_record SET union_id=?, nick_name=?,headimgurl=?,sex=?,city=?,province=?,country=? WHERE user_id=? and open_id=? `
 	_, err = o.Raw(sql, unionId, nickName, headimgUrl, sex, city, province, country, userId, openId).Exec()
 	return
@@ -96,7 +82,7 @@ func ModifyUserRecordByDetail(openId, unionId, nickName, headimgUrl, city, provi
 
 // 修改用户微信信息
 func ModifyUserRecordSessionKey(openId, sessionKey string) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE user_record SET session_key=? WHERE open_id=? `
 	_, err = o.Raw(sql, sessionKey, openId).Exec()
 	return
@@ -104,25 +90,17 @@ func ModifyUserRecordSessionKey(openId, sessionKey string) (err error) {
 
 // 根据用户id和平台id获取用户关系
 func GetUserRecordByMobile(platform int, bindAccount string) (item *OpenIdList, err error) {
-
 	var sql string
-	if utils.RunMode == "release" {
-		sql = `SELECT cr.open_id,user_id FROM user_record  as u 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE create_platform=? AND bind_account = ?`
-	} else {
-		platform = 1
-		sql = `SELECT open_id,user_id FROM	user_record  WHERE create_platform =? AND bind_account = ?`
-	}
-
-	err = orm.NewOrm().Raw(sql, platform, bindAccount).QueryRow(&item)
+	sql = `SELECT open_id,cygx_user_id AS user_id  FROM	cygx_user_record  WHERE	1 = 1  AND cygx_bind_account = ?`
+	err = orm.NewOrm().Raw(sql, bindAccount).QueryRow(&item)
 	return
 }
 
 // 获取该用户第一个的 三方信息(微信头像信息)
 func GetUserThirdRecordByUserId(userId int) (item *UserRecord, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM user_record WHERE user_id = ? order by user_record_id asc`
-	err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
+	err = o.Raw(sql, userId).QueryRow(&item)
 	return
 }
 
@@ -137,50 +115,77 @@ func GetUserRecordListByMobile(platform int, bindAccount string) (items []*OpenI
 	//	platform = 1
 	//	sql = `SELECT open_id,user_id FROM	user_record  WHERE create_platform =? AND bind_account IN (` + bindAccount + `)`
 	//}
-	sql = `SELECT cr.open_id,user_id FROM user_record  as u 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE create_platform=? AND bind_account IN (` + bindAccount + `)`
-	_, err = orm.NewOrm().Raw(sql, platform).QueryRows(&items)
+	sql = `SELECT
+			cr.open_id,
+			cr.cygx_user_id as  user_id 
+		FROM
+		  cygx_user_record  as cr 
+		WHERE 1= 1	AND cygx_bind_account IN (` + bindAccount + `)`
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
 }
 
-// 获取单个用户openid
-func GetOpenIdDetailByMobile(platform int, bindAccount string) (item *OpenIdList, err error) {
-	o := orm.NewOrm()
-	var sql string
-	sql = `SELECT cr.open_id,wu.user_id FROM user_record  as u 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			INNER JOIN wx_user AS wu ON wu.mobile = u.bind_account 
-			WHERE create_platform=? AND u.bind_account = ?`
-	err = o.Raw(sql, platform, bindAccount).QueryRow(&item)
-	return
-}
+//// 获取单个用户openid
+//func GetOpenIdDetailByMobile(platform int, bindAccount string) (item *OpenIdList, err error) {
+//	o := orm.NewOrm()
+//	var sql string
+//	sql = `SELECT cr.open_id,wu.user_id FROM user_record  as u
+//			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
+//			INNER JOIN wx_user AS wu ON wu.mobile = u.bind_account
+//			WHERE create_platform=? AND u.bind_account = ?`
+//	err = o.Raw(sql, platform, bindAccount).QueryRow(&item)
+//	return
+//}
 
 func GetOpenIdByUserIds(ids string) (item []*OpenIdList, err error) {
 	o := orm.NewOrm()
 	var sql string
-	sql = `SELECT cr.open_id,wu.user_id FROM user_record  as u 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			INNER JOIN wx_user AS wu ON wu.mobile = u.bind_account 
-			WHERE create_platform=4 AND u.user_id IN (` + ids + `)`
+	sql = ` SELECT
+			cr.open_id,
+			cr.cygx_user_id as  user_id 
+		FROM
+		  cygx_user_record  as cr 
+		WHERE 1= 1	AND cygx_user_id IN (` + ids + `)`
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
 }
 
+//// 根据手机号获取用户的openid
+//func GetUserRecordListByMobileArr(bindAccount []string) (items []*OpenIdList, err error) {
+//	lenarr := len(bindAccount)
+//	if lenarr == 0 {
+//		return
+//	}
+//	var condition string
+//	var pars []interface{}
+//	condition = ` AND u.bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+//	pars = append(pars, bindAccount)
+//	sql := `SELECT cr.open_id,u.user_id
+//			FROM user_record  as u
+//			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
+//			WHERE u.create_platform=4 ` + condition
+//	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
+//	return
+//}
+
 // 根据手机号获取用户的openid
-func GetUserRecordListByMobileArr(bindAccount []string) (items []*OpenIdList, err error) {
-	lenarr := len(bindAccount)
+func GetUserRecordListByMobileArr(mobiles []string) (items []*OpenIdList, err error) {
+	o := orm.NewOrm()
+	lenarr := len(mobiles)
 	if lenarr == 0 {
 		return
 	}
 	var condition string
 	var pars []interface{}
-	condition = ` AND u.bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
-	pars = append(pars, bindAccount)
-	sql := `SELECT cr.open_id,u.user_id
-			FROM user_record  as u 
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
-			WHERE u.create_platform=4 ` + condition
-	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
+	condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+	pars = append(pars, mobiles)
+	sql := `SELECT
+			u.open_id,
+			u.cygx_user_id AS user_id 
+		FROM
+			cygx_user_record AS u 
+		WHERE
+			1 = 1  ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 2 - 2
models/user_template_record.go

@@ -15,9 +15,9 @@ type UserTemplateRecord struct {
 	SendType   int
 }
 
-//添加banner
+// 添加
 func AddUserTemplateRecord(item *UserTemplateRecord) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Insert(item)
 	return
 }

+ 51 - 20
models/wechat.go

@@ -6,6 +6,9 @@ import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/http"
 	"hongze/hongze_cygx/utils"
+	"io/ioutil"
+	netHttp "net/http"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -41,7 +44,7 @@ type ReturnBodyRule struct {
 }
 
 func GetWxAccessToken() (accessTokenStr string, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM wx_token LIMIT 1`
 	wxToken := new(WxToken)
 	err = o.Raw(sql).QueryRow(&wxToken)
@@ -130,7 +133,7 @@ func GetWxAccessTokenByXzs() (accessTokenStr string, err error) {
 	return
 }
 
-//获取小助手的微信Token
+// 获取小助手的微信Token
 func GetWxTokenByXzs() (item *WxAccessToken, err error) {
 	getUrl := "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + utils.WxPublicIdXzs + "&secret=" + utils.WxPublicSecretXzs
 	result, err := http.Get(getUrl)
@@ -194,36 +197,64 @@ func WxUsersGet() (openIdStr string) {
 }
 
 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"`
+	Detail  []WxCheckContentJsonDetail `json:"detail"`
+	Errcode int                        `json:"errcode"`
+	Errmsg  string                     `json:"errmsg"`
+	Result  WxCheckContentJsonResult   `json:"result"`
 }
 
-func WxCheckContent(content string) {
-	accessToken, err := GetWxAccessToken()
+type WxCheckContentJsonDetail struct {
+	Label    int
+	KeyWord  string
+	Prob     int
+	Strategy string
+	Errcode  int
+}
+type WxCheckContentJsonResult struct {
+	Suggest string
+	Label   int
+}
+
+func WxCheckContent(token, openId, content string) (suggest string) {
+	url := "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + token
+	fmt.Println(url)
+	//result, err := http.Post(url, content)
+	//if err != nil {
+	//	utils.FileLog.Info("GetUser Err:", err.Error())
+	//	return
+	//}
+	method := "POST"
+	payload := strings.NewReader(`{
+		"openid":"` + openId + `",
+		"scene":` + strconv.Itoa(2) + `,
+		"version":` + strconv.Itoa(2) + `,
+		"content":"` + content + `"
+				}`)
+	client := &netHttp.Client{}
+	req, err := netHttp.NewRequest(method, url, payload)
 	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)
+	req.Header.Add("Content-Type", "application/json")
+	postBody, err := client.Do(req)
 	if err != nil {
-		utils.FileLog.Info("GetUser Err:", err.Error())
 		return
 	}
-
+	defer postBody.Body.Close()
+	body, err := ioutil.ReadAll(postBody.Body)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
 	item := new(WxCheckContentJson)
-	err = json.Unmarshal(result, &item)
+	err = json.Unmarshal(body, &item)
 	if err != nil {
 		fmt.Println("Unmarshal Err:", err.Error())
 		return
 	}
-	fmt.Println(result)
+	fmt.Println(item.Result.Label)
+	fmt.Println(item.Result.Suggest)
+	suggest = item.Result.Suggest
 	return
 }

+ 45 - 17
models/wx_template_msg.go

@@ -14,9 +14,11 @@ type SendTemplateResponse struct {
 type OpenIdList struct {
 	OpenId string
 	UserId int
+	Mobile string `description:"手机号"`
 }
 
 func GetOpenIdList() (items []*OpenIdList, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	openIdstr := WxUsersGet()
 	sql := `SELECT open_id FROM wx_user AS wu 
           INNER JOIN company AS c ON c.company_id = wu.company_id 
@@ -24,15 +26,20 @@ func GetOpenIdList() (items []*OpenIdList, err error) {
 	if openIdstr != "" {
 		sql += ` AND open_id in (` + openIdstr + `) `
 	}
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).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 cr.*,user_id FROM user_record  as c
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
-			WHERE bind_account IN (` + mobile + `) AND create_platform = 4`
+	//sql := `SELECT cr.*,user_id FROM user_record  as c
+	//		INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
+	//		WHERE bind_account IN (` + mobile + `) AND create_platform = 4`
+
+	sql := ` SELECT
+				union_id,
+				cygx_user_id AS user_id
+				FROM cygx_user_record	WHERE	1 = 1	AND cygx_bind_account IN (` + mobile + `)`
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
 }
@@ -46,30 +53,51 @@ type AdminOpenIdList struct {
 
 // GetAdminOpendidByCompany 通过用户公司ID获取对应销售的openid
 func GetAdminOpendidByCompany(condition string, pars []interface{}) (list []*AdminOpenIdList, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
-			cr.open_id,a.mobile,p.company_id,cr.union_id
+			a.mobile,
+			p.company_id 
 		FROM
 			company_product AS p
 			INNER JOIN admin AS a ON a.admin_id = p.seller_id 
-			INNER JOIN user_record  as c ON c.bind_account = a.mobile
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
 		WHERE
 			1 = 1 
-			AND p.product_id = 2
-			AND create_platform = 4 ` + condition
-	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+			AND p.product_id = 2 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&list)
 	return
 }
 
+//func GetWxOpenIdByMobileSliceList(mobiles []string) (items []*OpenIdList, err error) {
+//	itemsLen := len(mobiles)
+//	if itemsLen == 0 {
+//		return
+//	}
+//	o := orm.NewOrm()
+//	sql := `SELECT cr.*,user_id FROM user_record  as c
+//			INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
+//			WHERE bind_account IN (` + utils.GetOrmInReplace(itemsLen) + `) AND create_platform = 4`
+//	_, err = o.Raw(sql, mobiles).QueryRows(&items)
+//	return
+//}
+
+// 根据手机号获取用户的openid
 func GetWxOpenIdByMobileSliceList(mobiles []string) (items []*OpenIdList, err error) {
-	itemsLen := len(mobiles)
-	if itemsLen == 0 {
+	o := orm.NewOrm()
+	lenarr := len(mobiles)
+	if lenarr == 0 {
 		return
 	}
-	o := orm.NewOrm()
-	sql := `SELECT cr.*,user_id FROM user_record  as c
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
-			WHERE bind_account IN (` + utils.GetOrmInReplace(itemsLen) + `) AND create_platform = 4`
-	_, err = o.Raw(sql, mobiles).QueryRows(&items)
+	var condition string
+	var pars []interface{}
+	condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)`
+	pars = append(pars, mobiles)
+	sql := `SELECT
+			u.open_id,
+			u.cygx_user_id AS user_id 
+		FROM
+			cygx_user_record AS u 
+		WHERE
+			1 = 1  ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 83 - 64
models/wx_user.go

@@ -54,7 +54,7 @@ type WxUser struct {
 
 // 添加用户信息
 func AddWxUser(item *WxUser) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	lastId, err = o.Insert(item)
 	return
 }
@@ -90,23 +90,19 @@ type WxUserItem struct {
 }
 
 func GetWxUserItemByUnionid(unionid string) (item *WxUserItem, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM wx_user WHERE union_id=? `
-	err = orm.NewOrm().Raw(sql, unionid).QueryRow(&item)
+	err = o.Raw(sql, unionid).QueryRow(&item)
 	return
 }
 
 // 根据用户ID获取相关信息
 func GetWxUserItemByUserId(userId int) (item *WxUserItem, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT a.*,b.company_name FROM wx_user AS a
 			LEFT JOIN company AS b on a.company_id=b.company_id
 			WHERE a.user_id=? `
-	err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
-	return
-}
-
-func GetWxUserItemByOpenId(openId string) (item *WxUserItem, err error) {
-	sql := `SELECT * FROM wx_user WHERE open_id=? `
-	err = orm.NewOrm().Raw(sql, openId).QueryRow(&item)
+	err = o.Raw(sql, userId).QueryRow(&item)
 	return
 }
 
@@ -132,7 +128,7 @@ type WxGetUserInfoReq struct {
 
 // 修改用户会话key
 func ModifyWxUserSessionKey(sessionKey string, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET session_key=? WHERE user_id=? `
 	_, err = o.Raw(sql, sessionKey, userId).Exec()
 	return
@@ -140,7 +136,7 @@ func ModifyWxUserSessionKey(sessionKey string, userId int) (err error) {
 
 // 添加用户信息
 func ModifyWxUserInfo(unionId, nickName, province, city, country, avatar string, gender, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET union_id=?,unionid=?,nick_name=?,sex=?,province=?,city=?,country=?,headimgurl=? WHERE user_id=? `
 	_, err = o.Raw(sql, unionId, unionId, nickName, gender, province, city, country, avatar, userId).Exec()
 	return
@@ -148,7 +144,7 @@ func ModifyWxUserInfo(unionId, nickName, province, city, country, avatar string,
 
 // 修改用户会话key
 func DeleteWxUserByUserId(userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `DELETE FROM wx_user WHERE user_id=? `
 	_, err = o.Raw(sql, userId).Exec()
 	return
@@ -177,7 +173,7 @@ type WxGetPhoneNumberReq struct {
 }
 
 func ModifyUsersMobile(usersId int, phoneNumber string) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET mobile=? WHERE user_id=? `
 	_, err = o.Raw(sql, phoneNumber, usersId).Exec()
 	return
@@ -191,48 +187,50 @@ type WxGetPhoneNumberResp struct {
 
 // 根据用户手机号获取相关信息
 func GetWxUserItemByMobile(mobile string) (item *WxUserItem, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT a.*,b.company_name FROM wx_user AS a
 			LEFT JOIN company AS b on a.company_id=b.company_id
 			WHERE a.mobile=  '` + mobile + `'  ORDER BY a.company_id DESC LIMIT 1 `
-	err = orm.NewOrm().Raw(sql).QueryRow(&item)
+	err = o.Raw(sql).QueryRow(&item)
 	return
 }
 
 // 根据用户手机号获取相关信息
 func GetWxUserAouthByMobile(mobile string) (item *WxUserItem, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 			a.*,
-			s.mobile,
 			b.company_name 
 		FROM
-			cygx_session_mobile AS s
-			LEFT JOIN wx_user AS a ON a.mobile = s.mobile
+		    wx_user AS a 
 			LEFT JOIN company AS b ON a.company_id = b.company_id 
 		WHERE
-			s.mobile = ?
+			a.mobile = ?
 		ORDER BY
 			a.company_id DESC 
 			LIMIT 1`
-	err = orm.NewOrm().Raw(sql, mobile).QueryRow(&item)
+	err = o.Raw(sql, mobile).QueryRow(&item)
 	return
 }
 
 func GetWxUserItemByEmail(email string) (item *WxUserItem, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM wx_user WHERE email=? `
-	err = orm.NewOrm().Raw(sql, email).QueryRow(&item)
+	err = o.Raw(sql, email).QueryRow(&item)
 	return
 }
 
 func ModifyReportLastViewTime(uid int) (err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` UPDATE wx_user SET report_last_view_time=NOW()
 			WHERE user_id=? `
-	_, err = orm.NewOrm().Raw(sql, uid).Exec()
+	_, err = o.Raw(sql, uid).Exec()
 	return
 }
 
 // 变更联系人是否已注册状态
 func ModifyWxUserRegisterStatus(userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET is_register=?,source=3,register_time=NOW() WHERE user_id = ? `
 	_, err = o.Raw(sql, 1, userId).Exec()
 	return
@@ -240,7 +238,7 @@ func ModifyWxUserRegisterStatus(userId int) (err error) {
 
 // 修改用户是否绑定外呼手机号弹窗
 func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET is_msg_outbound_mobile=1 WHERE user_id=? `
 	_, err = o.Raw(sql, userId).Exec()
 	return
@@ -248,7 +246,7 @@ func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
 
 // 列表
 func GetUserListAll() (items []*WxUserItem, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM wx_user  WHERE mobile <>'' AND outbound_mobile = ''`
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
@@ -256,7 +254,7 @@ func GetUserListAll() (items []*WxUserItem, err error) {
 
 // 修改手机号区号  8位号码+852,9位号码+886,10位号码+1,11位及以上号码+86
 func UPdateUserCountryCode(item *WxUserItem) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	if item.CountryCode == "" && len(item.Mobile) >= 11 {
 		sql := ` UPDATE wx_user SET  outbound_mobile= ? , outbound_country_code=86 , country_code=86  WHERE user_id = ?`
 		_, err = o.Raw(sql, item.Mobile, item.UserId).Exec()
@@ -279,42 +277,47 @@ func UPdateUserCountryCode(item *WxUserItem) (err error) {
 
 // 判断公司下用户名称是否存在
 func GetUserCountByName(companyId int, name string) (count int, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT  COUNT(1) AS count FROM wx_user WHERE company_id = ? AND real_name = ?`
-	err = orm.NewOrm().Raw(sql, companyId, name).QueryRow(&count)
+	err = o.Raw(sql, companyId, name).QueryRow(&count)
 	return
 }
 
 // 判断这个用户是否被设置消息提醒
 func GetUserRemind(uid int) (count int, err error) {
+	o := orm.NewOrm()
 	sql := `SELECT  COUNT(1) AS count FROM cygx_user_remind WHERE user_id = ? `
-	err = orm.NewOrm().Raw(sql, uid).QueryRow(&count)
+	err = o.Raw(sql, uid).QueryRow(&count)
 	return
 }
 
 // 判断公司下用户名称是否存在
 func GetUserCountByThirdName(companyId int, name string) (count int, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT  COUNT(1) AS count FROM wx_user WHERE company_id = ? AND tripartite_code = ?`
-	err = orm.NewOrm().Raw(sql, companyId, name).QueryRow(&count)
+	err = o.Raw(sql, companyId, name).QueryRow(&count)
 	return
 }
 
 // 获取公司下一共有多少用户
 func GetUserCountByCompanyId(companyId int) (count int, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT  COUNT(1) AS count FROM wx_user WHERE company_id = ? `
-	err = orm.NewOrm().Raw(sql, companyId).QueryRow(&count)
+	err = o.Raw(sql, companyId).QueryRow(&count)
 	return
 }
 
 func UpdateUserMobile(uid int, mobile string) (err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` UPDATE wx_user SET mobile=?
 			WHERE user_id=? `
-	_, err = orm.NewOrm().Raw(sql, mobile, uid).Exec()
+	_, err = o.Raw(sql, mobile, uid).Exec()
 	return
 }
 
 // 获取公司下用户详情详情详情
 func GetUserByName(companyId int, name string) (item *WxUser, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT *  FROM wx_user WHERE company_id = ? AND real_name = ? `
 	err = o.Raw(sql, companyId, name).QueryRow(&item)
 	return
@@ -322,45 +325,61 @@ func GetUserByName(companyId int, name string) (item *WxUser, err error) {
 
 // 获取公司下用户详情详情详情
 func GetUserByThirdName(companyId int, name string) (item *WxUser, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT *  FROM wx_user WHERE company_id = ? AND tripartite_code = ? `
 	err = o.Raw(sql, companyId, name).QueryRow(&item)
 	return
 }
 
+// 获取所有注册的权益用户
+//func GetUserRegisterList() (items []*WxUser, err error) {
+//	o := orm.NewOrmUsingDB("weekly_report")
+//	sql := `SELECT
+//			u.user_id,
+//			u.company_id,
+//			u.mobile,
+//			u.email,
+//			u.real_name,
+//			u.is_register,
+//			u.is_maker,
+//			u.register_time
+//		FROM
+//			wx_user AS u
+//			INNER JOIN company AS c ON c.company_id = u.company_id
+//			INNER JOIN company_product AS cp ON cp.company_id = c.company_id
+//		WHERE
+//			u.company_id IN (
+//			SELECT
+//				a.company_id
+//			FROM
+//				company AS a
+//				INNER JOIN company_product AS b ON a.company_id = b.company_id
+//			WHERE
+//				a.enabled = 1
+//				AND b.STATUS IN ( '正式', '试用', '冻结' )
+//				AND cp.product_id = 2
+//			)
+//			AND cp.product_id = 2
+//		GROUP BY
+//			u.user_id `
+//	_, err = o.Raw(sql).QueryRows(&items)
+//	//AND u.register_time IS NOT NULL OR u.report_last_view_time <>'' 统计阅读时间与注册时间不为空的用户
+//	return
+//}
+
 // 获取所有注册的权益用户
 func GetUserRegisterList() (items []*WxUser, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-			u.user_id,
-			u.company_id,
-			u.mobile,
-			u.email,
-			u.real_name,
-			u.is_register,
-			u.is_maker,
-			u.register_time 
-		FROM
-			wx_user AS u
-			INNER JOIN company AS c ON c.company_id = u.company_id
-			INNER JOIN company_product AS cp ON cp.company_id = c.company_id 
-		WHERE
-			u.company_id IN (
-			SELECT
-				a.company_id 
+				* 
 			FROM
-				company AS a
-				INNER JOIN company_product AS b ON a.company_id = b.company_id 
+				cygx_page_history_record 
 			WHERE
-				a.enabled = 1 
-				AND b.STATUS IN ( '正式', '试用', '冻结' ) 
-				AND cp.product_id = 2 
-			)
-			AND cp.product_id = 2
-		GROUP BY
-			u.user_id `
+				user_id > 0 
+				AND company_id > 0 
+				AND create_time > DATE_SUB( DATE( NOW()), INTERVAL 1 DAY ) 
+			GROUP BY user_id `
 	_, err = o.Raw(sql).QueryRows(&items)
-	//AND u.register_time IS NOT NULL OR u.report_last_view_time <>'' 统计阅读时间与注册时间不为空的用户
 	return
 }
 
@@ -560,14 +579,14 @@ func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInterac
 				man.activity_id IN ( SELECT activity_id FROM cygx_activity_signup AS f WHERE f.user_id = u.user_id  AND label != '') 
 			) AS activity_label
 		FROM
-			wx_user AS u WHERE  u.user_id IN( ` + userIds + `) `
+			cygx_user_label AS u WHERE  u.user_id IN( ` + userIds + `)  	GROUP BY u.user_id  `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
 // GetWxUserListByUserIds 根据用户ID集合获取用户
 func GetWxUserListByUserIds(userIds string) (list []*WxUserItem, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT u.*, c.company_name FROM wx_user AS u
 			INNER JOIN company AS c ON c.company_id = u.company_id 
 			WHERE user_id IN (` + userIds + `) `
@@ -582,7 +601,7 @@ func GetWxUserByMobiles(mobiles []string) (items []*WxUser, err error) {
 		return
 	}
 	sql := `SELECT* FROM wx_user  WHERE mobile in (` + utils.GetOrmInReplace(lenmobiles) + `)  `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Raw(sql, mobiles).QueryRows(&items)
 	return
 }
@@ -594,13 +613,13 @@ func GetWxUserByOutboundMobiles(mobiles []string) (items []*WxUser, err error) {
 		return
 	}
 	sql := `SELECT* FROM wx_user  WHERE outbound_mobile in (` + utils.GetOrmInReplace(lenmobiles) + `)  `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Raw(sql, mobiles).QueryRows(&items)
 	return
 }
 
 func UserSubscribe(subscribeTime string, userId int) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET cygx_subscribe=1,cygx_subscribe_time=? WHERE user_id = ? `
 	_, err = o.Raw(sql, subscribeTime, userId).Exec()
 	return
@@ -611,7 +630,7 @@ func GetWxUserOutboundMobiles(mobiles []string) (item []*WxUserOutboundMobile, e
 	if lenmobiles == 0 {
 		return
 	}
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT u.real_name,u.mobile,u.outbound_mobile,u.company_id,p.company_name ,GROUP_CONCAT( DISTINCT p.seller_name SEPARATOR '/' ) AS seller_name
 			FROM wx_user as u 
 			INNER JOIN company_product AS p ON p.company_id = u.company_id 

+ 38 - 39
models/wx_user_code.go

@@ -16,25 +16,24 @@ type WxUserCode struct {
 	CreateTime     time.Time
 }
 
-//添加联系人日志信息
+// 添加联系人日志信息
 func AddWxUserCode(item *WxUserCode) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	lastId, err = o.Insert(item)
 	return
 }
 
 func GetWxUserCode(wxCode string) (item *WxUserCode, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM wx_user_code WHERE wx_code=? `
 	err = o.Raw(sql, wxCode).QueryRow(&item)
 	return
 }
 
-//获取所有有权限的用户的opid
+// 获取所有有权限的用户的手机号
 func GetCygxUserRecordPower(condition string, pars []interface{}) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
-			cr.open_id,
 			u.user_id,
 			u.company_id,
 			u.real_name,
@@ -43,75 +42,75 @@ func GetCygxUserRecordPower(condition string, pars []interface{}) (items []*Open
 			company_report_permission AS p
 			INNER JOIN wx_user AS u ON u.company_id = p.company_id
 			INNER JOIN user_record AS r ON r.user_id = u.user_id
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
 		WHERE
-			 r.create_platform = 4 ` + condition + ` AND p.STATUS IN ('正式','试用','永续')  GROUP BY cr.open_id`
+			r.create_platform = 4 ` + condition + `
+			AND p.STATUS IN ( '正式', '试用', '永续' ) 
+			GROUP BY u.mobile `
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
 
-//获取关注这个文章对应产业的用户的 openid
+// 获取关注这个文章对应产业的用户的 openid
 func GetCygxUserFllowOpenid(articleId int) (items []*OpenIdList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-			cr.open_id,
+			f.mobile,
 			f.user_id 
 		FROM
 			cygx_xzs_choose_send AS s
 			INNER JOIN cygx_industry_fllow AS f ON f.user_id = s.user_id
-			INNER JOIN user_record AS r ON r.user_id = f.user_id
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
-			INNER JOIN cygx_industrial_article_group_management as mg  ON mg.industrial_management_id = f.industrial_management_id
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = f.industrial_management_id 
 		WHERE
-			r.create_platform = 4 
-			AND mg.article_id  = ?`
+			1 = 1 
+			AND mg.article_id = ? 
+			GROUP BY f.user_id `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return
 }
 
-//获取拒绝接收推送的的用户的 openid
+// 获取拒绝接收推送的的用户的 openid
 func GetCygxUserRefusetOpenid() (items []*OpenIdList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			cr.open_id,
-			s.user_id
-			FROM
+			cr.cygx_user_id AS user_id 
+		FROM
 			cygx_xzs_choose_send AS s
-			INNER JOIN user_record AS r ON r.user_id = s.user_id
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id
-			WHERE
-			r.create_platform = 4
+			INNER JOIN cygx_user_record AS cr ON cr.cygx_user_id = s.user_id 
+		WHERE
+			1 = 1 
 			AND s.is_refuse = 1`
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
-//获取选择策略推送的用户的openid openid
+// 获取选择策略推送的用户的openid openid
 func GetCygxUserFllowCeLueOpenid(categoryId int) (items []*OpenIdList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			cr.open_id,
-			f.user_id 
+			cr.cygx_user_id AS user_id 
 		FROM
 			cygx_xzs_choose_send AS s
 			INNER JOIN cygx_xzs_choose_category AS f ON f.user_id = s.user_id
-			INNER JOIN user_record AS r ON r.user_id = f.user_id
-			INNER JOIN cygx_user_record AS cr ON cr.union_id = r.union_id 
+			INNER JOIN cygx_user_record AS cr ON cr.cygx_user_id = s.user_id 
 		WHERE
-			r.create_platform = 4
-			AND s.is_refuse = 0
-			AND (s.is_subjective = 1 OR s.is_objective = 1)
-			AND f.category_id = ?`
+			1 = 1 
+			AND s.is_refuse = 0 
+			AND ( s.is_subjective = 1 OR s.is_objective = 1 ) 
+			AND f.category_id = ?
+		GROUP BY
+			s.user_id `
 	_, err = o.Raw(sql, categoryId).QueryRows(&items)
 	return
 }
 
-//获取提交过推送规则用户的userId
-func GetCygxXzsChooseSendOpenIdByUserIds(idStr string) (items []*OpenIdList, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT ur.user_id, cr.open_id FROM user_record AS ur
-INNER JOIN cygx_user_record AS cr
-WHERE ur.user_id IN (` + idStr + `) AND create_platform=4 AND ur.union_id=cr.union_id `
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
+// 获取提交过推送规则用户的userId
+//func GetCygxXzsChooseSendOpenIdByUserIds(idStr string) (items []*OpenIdList, err error) {
+//	o := orm.NewOrm()
+//	sql := `SELECT ur.user_id, cr.open_id FROM user_record AS ur
+//INNER JOIN cygx_user_record AS cr
+//WHERE ur.user_id IN (` + idStr + `) AND create_platform=4 AND ur.union_id=cr.union_id `
+//	_, err = o.Raw(sql).QueryRows(&items)
+//	return
+//}

+ 2 - 2
models/wx_user_log.go

@@ -17,9 +17,9 @@ type WxUserLog struct {
 	CreateTime time.Time
 }
 
-//添加联系人日志信息
+// 添加联系人日志信息
 func AddWxUserLog(item *WxUserLog) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	lastId, err = o.Insert(item)
 	return
 }

+ 25 - 13
models/wx_user_white.go

@@ -20,14 +20,24 @@ type WxUserWhite struct {
 	SellerName          string `description:"销售"`
 }
 
-//添加
+// 添加
 func AddWxUserWhite(item *WxUserWhite) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	lastId, err = o.Insert(item)
 	return
 }
 
-//获取用户手机号白名单
+// 批量添加
+func AddAddWxUserWhiteMulti(items []*WxUserWhite) (err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	if len(items) > 0 {
+		//批量添加新的关注记录
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
+// 获取用户手机号白名单
 func GetWxUserWhiteMobile() (mobileStr string, err error) {
 	sql := ` SELECT
 			GROUP_CONCAT( DISTINCT u.mobile SEPARATOR ',' ) AS mobileStr 
@@ -43,12 +53,12 @@ func GetWxUserWhiteMobile() (mobileStr string, err error) {
 				AND u.mobile NOT IN ( SELECT mobile FROM wx_user_white ) 
 				AND u.mobile != ''
 				AND cp.status IN ( '正式', '试用' ) `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql).QueryRow(&mobileStr)
 	return
 }
 
-//获取用户外呼手机号白名单
+// 获取用户外呼手机号白名单
 func GetWxUserWhiteOutboundMobile() (mobileStr string, err error) {
 	sql := ` SELECT
 			GROUP_CONCAT( DISTINCT u.outbound_mobile SEPARATOR ',' ) AS outboundmobileStr 
@@ -66,13 +76,14 @@ func GetWxUserWhiteOutboundMobile() (mobileStr string, err error) {
 				AND cp.status IN ( '正式', '试用' )
 				AND u.mobile != ''
 				AND u.mobile !=  u.outbound_mobile `
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql).QueryRow(&mobileStr)
 	return
 }
 
-//获取冻结用户白名单
+// 获取冻结用户白名单
 func GetFrozenUserWhiteList() (items []*WxUserWhite, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 				* 
 			FROM
@@ -94,12 +105,13 @@ func GetFrozenUserWhiteList() (items []*WxUserWhite, err error) {
 					AND mobile != '' 
 				) 
 				AND w.outbound_mobile = '' ` //OR w.outbound_mobile NOT IN ( SELECT outbound_mobile FROM wx_user )`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
-//获取冻结用户白名单外呼号
+// 获取冻结用户白名单外呼号
 func GetFrozenUserWhiteListOutbound() (items []*WxUserWhite, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT
 				* 
 			FROM
@@ -120,17 +132,17 @@ func GetFrozenUserWhiteListOutbound() (items []*WxUserWhite, err error) {
 					AND cp.STATUS IN ( '正式', '试用' ) 
 					AND outbound_mobile != '') 
             AND w.mobile = ''`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
-//删除数据
+// 删除数据
 func DeleteWxUserWhite(item *WxUserWhite) (err error) {
-	o := orm.NewOrm()
+	o := orm.NewOrmUsingDB("weekly_report")
 	if item.Mobile != "" {
 		sql := ` DELETE FROM wx_user_white WHERE mobile = ?`
 		_, err = o.Raw(sql, item.Mobile).Exec()
-	} else {
+	} else if item.OutboundMobile != "" {
 		sql := ` DELETE FROM wx_user_white WHERE outbound_mobile = ?`
 		_, err = o.Raw(sql, item.OutboundMobile).Exec()
 	}

+ 153 - 0
routers/commentsRouter.go

@@ -1708,4 +1708,157 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorDetail",
+            Router: `/author/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorHeadImg",
+            Router: `/author/head_img`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorList",
+            Router: `/author/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorSave",
+            Router: `/author/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Cancel",
+            Router: `/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Center",
+            Router: `/center`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Check",
+            Router: `/check`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Collect",
+            Router: `/collect`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "CompanySearch",
+            Router: `/companySearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Delete",
+            Router: `/del`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Enable",
+            Router: `/enable`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Follow",
+            Router: `/follow`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "IndustrySearch",
+            Router: `/industrySearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Record",
+            Router: `/record`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Save",
+            Router: `/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
 }

+ 5 - 0
routers/router.go

@@ -165,6 +165,11 @@ func init() {
 				&controllers.TagController{},
 			),
 		),
+		web.NSNamespace("/yanxuan_special",
+			web.NSInclude(
+				&controllers.YanxuanSpecialController{},
+			),
+		),
 		web.NSNamespace("/collection",
 			web.NSInclude(
 				&controllers.CollectionController{},

+ 63 - 27
services/activity.go

@@ -32,7 +32,7 @@ func SendActivityBeginMsg(cont context.Context) (err error) {
 	//func SendActivityBeginMsg() (err error) {
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg("60分钟会议消息提醒失败", 2)
+			go utils.SendAlarmMsg("60分钟会议消息提醒失败"+err.Error(), 2)
 			fmt.Println("发送失败,Err:", err.Error())
 		}
 	}()
@@ -172,23 +172,26 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
 			fmt.Println("err:", err)
-			go utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组失败"+msg, 2)
+			go utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组失败"+err.Error()+msg, 2)
 		}
 	}()
 	endDate := time.Now().Add(+time.Minute * 60).Format(utils.FormatDateTime)
-	total, err := models.GetCountActivityIdToSendFile(endDate)
-
+	total, e := models.GetCountActivityIdToSendFile(endDate)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCountActivityIdToSendFile" + e.Error())
+		return
+	}
 	if total == 0 {
 		fmt.Println("发送附件完成0")
 		return nil
 	}
-	if err != nil {
-		msg = "发送附件模版消息失败 Err:" + err.Error()
+
+	listActivity, e := models.GetActivityIdToSendFile(endDate)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetActivityIdToSendFile" + e.Error())
 		return
 	}
-	listActivity, err := models.GetActivityIdToSendFile(endDate)
-	if err != nil {
-		msg = "发送附件模版消息失败 Err:" + err.Error()
+	if len(listActivity) == 0 {
 		return
 	}
 	var activityIds []int
@@ -196,22 +199,23 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 		activityIds = append(activityIds, v.ActivityId)
 	}
 
-	//{
-	//	utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组 监控日志,监控使用无需处理,活动ID:"+fmt.Sprint(activityIds), 2)
-	//}
-
 	for _, v := range listActivity {
 		//time.Sleep(30 * time.Second) //延时30秒,避免邮件发送不成功
-		activityInfo, _ := models.GetAddActivityInfoById(v.ActivityId)
-		if activityInfo == nil {
-			msg = "活动不存在,Err:activityId:" + strconv.Itoa(v.ActivityId)
+		activityInfo, e := models.GetAddActivityInfoById(v.ActivityId)
+		if e != nil {
+			err = errors.New("GetAddActivityInfoById" + e.Error())
 			return
 		}
-		list, errFile := models.GetSignupExport(v.ActivityId)
-		if errFile != nil {
-			msg = "获取失败,Err:" + errFile.Error()
+		list, e := models.GetSignupExport(v.ActivityId)
+		if e != nil {
+			err = errors.New("GetSignupExport" + e.Error())
 			return
 		}
+		var companyIds []int
+		for _, vSin := range list {
+			companyIds = append(companyIds, vSin.CompanyId)
+		}
+		sellNameMap := GetSellNameMapByCompanyIds(companyIds)
 		//创建excel
 		dir, errFile := os.Executable()
 		exPath := filepath.Dir(dir)
@@ -265,8 +269,9 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 			cellD := row.AddCell()
 			cellD.Value = item.CompanyName
 			cellE := row.AddCell()
-			cellE.Value = item.SellerName
+			cellE.Value = sellNameMap[item.CompanyId]
 		}
+
 		errFile = xlsxFile.Save(downLoadnFilePath)
 		if errFile != nil {
 			msg = "保存文件失败Err:" + errFile.Error()
@@ -297,9 +302,9 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 			}
 		}
 		os.Remove(downLoadnFilePath)
-		err = models.UPdateActivityIdToSendFile(v.ActivityId)
-		if err != nil {
-			go utils.SendAlarmMsg("UPdateActivityIdToSendFile err"+msg, 2)
+		e = models.UPdateActivityIdToSendFile(v.ActivityId)
+		if e != nil {
+			go utils.SendAlarmMsg("UPdateActivityIdToSendFile err"+e.Error(), 2)
 		}
 
 		//sendResult := utils.SendEmailByHongze(title, content, touser, fileName, title+".xlsx")
@@ -557,7 +562,8 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 		isResearchSpecial = true
 	}
 	//如果是弘则的用户或者宏观的权限不做校验
-	if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
+	//if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
+	if GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID {
 		havePower = true
 		return
 	}
@@ -567,6 +573,16 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
 		return
 	}
+	//如果一个权限都没有就返回无权限
+	if permissionStr == "" {
+		return
+	}
+	permissionStr += "," + utils.HONG_GUAN_NAME // 添加一个宏观权限
+	if permissionStrZhengShi == "" {
+		permissionStrZhengShi = utils.HONG_GUAN_NAME // 添加一个宏观权限
+	} else {
+		permissionStrZhengShi += "," + utils.HONG_GUAN_NAME // 添加一个宏观权限
+	}
 
 	//如果是易董的活动,主、副权限有一个满足即可
 	if activityInfo.YidongActivityId != "" {
@@ -703,10 +719,20 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 			companyDetailStatus = companyDetail.Status
 		}
 	}
+
+	//宏观满足用户可见身份验证权限既满足  2023-9-18
 	if activityInfo.ChartPermissionId == 1 {
-		havePower = true
-		return
+		if activityInfo.LimitPeopleNum > 0 {
+			if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
+				havePower = true
+				return
+			}
+		} else {
+			havePower = true
+			return
+		}
 	}
+
 	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") {
@@ -2298,10 +2324,20 @@ func DoActivityOnenIdWxTemplateMsg(cont context.Context) (err error) {
 	}()
 	var condition string
 	var pars []interface{}
-	openidPowerList, err := models.GetCygxUserRecordPower(condition, pars)
+	openidPowerListMobile, err := models.GetCygxUserRecordPower(condition, pars)
 	if err != nil {
 		return err
 	}
+
+	var mobileArr []string
+	for _, v := range openidPowerListMobile {
+		mobileArr = append(mobileArr, v.Mobile)
+	}
+	openidPowerList, err := models.GetWxOpenIdByMobileSliceList(mobileArr)
+	if err != nil {
+		return err
+	}
+
 	first := "近期所有行业活动预告,欢迎参与"
 	keyword1 := "下周活动预告"
 	keyword2 := "已发布"

+ 54 - 3
services/activity_special.go

@@ -1108,6 +1108,7 @@ func SendWxMsgActivitySpecialTwoDays(cont context.Context) (err error) {
 			condition = ` AND p.company_id IN (` + utils.GetOrmInReplace(companyIdsLen) + `)  GROUP BY  p.company_id  `
 			pars = append(pars, companyIds)
 
+			//获取销售的手机号
 			listSeller, e := models.GetAdminOpendidByCompany(condition, pars)
 			if e != nil && e.Error() != utils.ErrNoRow() {
 				err = errors.New("GetAdminOpendidByCompany, Err: " + e.Error())
@@ -1116,13 +1117,34 @@ func SendWxMsgActivitySpecialTwoDays(cont context.Context) (err error) {
 			if len(listSeller) == 0 {
 				continue
 			}
+			var mobileArr []string
+			for _, v := range listSeller {
+				if v.Mobile != "" {
+					mobileArr = append(mobileArr, v.Mobile)
+				}
+			}
+			mobileLen := len(mobileArr)
+			if mobileLen == 0 {
+				return
+			}
+			//获取手机号对应的Openid
+			listSellerOpenid, e := models.GetWxOpenIdByMobileSliceList(mobileArr)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("GetWxOpenIdByMobileSliceList, Err: " + e.Error())
+				return
+			}
+			mapMobileOpenid := make(map[string]string)
+			for _, v := range listSellerOpenid {
+				mapMobileOpenid[v.Mobile] = v.OpenId
+			}
+
 			mapSller := make(map[string]string)
 			mapSllerOpenid := make(map[string]string)
 			for _, vS := range listSeller {
 				for _, vT := range listSpecialTrip {
 					if vT.CompanyId == vS.CompanyId {
 						mapSller[vS.Mobile] += "【" + vT.RealName + "--" + vT.CompanyName + "】"
-						mapSllerOpenid[vS.Mobile] = vS.OpenId
+						mapSllerOpenid[vS.Mobile] = mapMobileOpenid[vS.Mobile]
 					}
 				}
 			}
@@ -1234,8 +1256,28 @@ func SendWxMsgActivitySpecialCancel(cont context.Context) (err error) {
 				err = errors.New("GetAdminOpendidByCompany, Err: " + e.Error())
 				return
 			}
-			if len(listSeller) > 0 {
-				for _, vOpenid := range listSeller {
+
+			if len(listSeller) == 0 {
+				continue
+			}
+			var mobileArr []string
+			for _, v := range listSeller {
+				if v.Mobile != "" {
+					mobileArr = append(mobileArr, v.Mobile)
+				}
+			}
+			mobileLen := len(mobileArr)
+			if mobileLen == 0 {
+				return
+			}
+			//获取手机号对应的Openid
+			listSellerOpenid, e := models.GetWxOpenIdByMobileSliceList(mobileArr)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("GetWxOpenIdByMobileSliceList, Err: " + e.Error())
+				return
+			}
+			if len(listSellerOpenid) > 0 {
+				for _, vOpenid := range listSellerOpenid {
 					openIdArr = append(openIdArr, vOpenid.OpenId)
 				}
 			}
@@ -1295,6 +1337,15 @@ func GetChartPermissionSpecialSurplusByCompany(companyId int) (userType int, tri
 			err = errors.New("GetActivitySpecialTripCountByActivitySpecial, Err: " + e.Error())
 			return
 		}
+
+		PermissionNameMap, e := GetPermissionNameMap()
+		if e != nil {
+			err = errors.New("GetPermissionNameMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range listTripBill {
+			listTripBill[k].ChartPermissionName = PermissionNameMap[v.ChartPermissionId]
+		}
 		// 获取继承点数
 		inheritList, e := models.GetCygxActivitySpecialInheritPointsByCompanyId(companyId)
 		if e != nil && e.Error() != utils.ErrNoRow() {

+ 55 - 20
services/article.go

@@ -519,27 +519,40 @@ type UserViewRedisData struct {
 }
 
 type ReportViewRecord struct {
-	Id              int       `orm:"column(id);pk"`
-	UserId          int       `description:"用户id"`
-	ReportId        int       `description:"报告id"`
-	Mobile          string    `description:"手机号"`
-	Email           string    `description:"邮箱"`
-	RealName        string    `description:"用户实际姓名"`
-	CompanyName     string    `description:"公司名称"`
-	CreateTime      time.Time `description:"创建时间"`
-	StopTime        int       `json:"stop_time" description:"停留时间"`
-	ReportChapterId int       `json:"report_chapter_id" description:"章节ID"`
-	OutId           int       `json:"out_id" description:"记录ID"`
+	Id int `orm:"column(id);pk"`
+	//UserId          int       `json:"user_id" description:"用户ID"`
+	//ReportId        int       `description:"报告id"`
+	//Mobile          string    `description:"手机号"`
+	//Email           string    `description:"邮箱"`
+	//RealName        string    `description:"用户实际姓名"`
+	//CompanyName     string    `description:"公司名称"`
+	//CreateTime      time.Time `description:"创建时间"`
+	//StopTime        int       `json:"stop_time" description:"停留时间"`
+	//ReportChapterId int       `json:"report_chapter_id" description:"章节ID"`
+	//OutId           int       `json:"out_id" description:"记录ID"`
+	Mobile          string `json:"mobile"`
+	Email           string `json:"email"`
+	RealName        string `json:"real_name"`
+	CompanyName     string `json:"company_name"`
+	ViewTime        string `json:"view_time" description:"阅读时间,格式:2022-02-17 13:06:13"`
+	ProductId       int    `json:"product_id" description:"报告所属产品,ficc:1,权益:2"`
+	CompanyId       int    `json:"company_id" description:"客户id"`
+	UserId          int    `json:"user_id" description:"用户id"`
+	ReportId        int    `json:"report_id" description:"报告id"`
+	StopTime        int    `json:"stop_time" description:"停留时间"`
+	ReportChapterId int    `json:"report_chapter_id" description:"章节ID"`
+	OutId           int    `json:"out_id" description:"章节ID"`
 }
 
 // PushViewRecordNewRedisData 阅读数据加入到redis
 func PushViewRecordNewRedisData(reportViewRecord *ReportViewRecord, companyId int) bool {
 	data := &UserViewRedisData{
 		Mobile:          reportViewRecord.Mobile,
+		UserId:          reportViewRecord.UserId,
 		Email:           reportViewRecord.Email,
 		RealName:        reportViewRecord.RealName,
 		CompanyName:     reportViewRecord.CompanyName,
-		ViewTime:        reportViewRecord.CreateTime.Format(utils.FormatDateTime),
+		ViewTime:        reportViewRecord.ViewTime,
 		ProductId:       2,
 		CompanyId:       companyId,
 		ReportId:        reportViewRecord.ReportId,
@@ -547,6 +560,7 @@ func PushViewRecordNewRedisData(reportViewRecord *ReportViewRecord, companyId in
 		ReportChapterId: reportViewRecord.ReportChapterId,
 		OutId:           reportViewRecord.OutId,
 	}
+
 	if utils.Re == nil {
 		err := utils.Rc.LPush(utils.CACHE_KEY_USER_VIEW, data)
 		if err != nil {
@@ -725,12 +739,12 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		fmt.Println("Getres.PublicGetDate Err:", err.Error())
 		return err
 	}
-	//item := new(models.CygxShanghaiCompanyLog)
-	//item.CreateTime = time.Now()
-	//item.Url = clueApiUrl
-	//item.Body = ""
-	//item.Result = string(body)
-	//go models.AddCygxShanghaiCompanyLog(item)
+	item := new(models.CygxShanghaiCompanyLog)
+	item.CreateTime = time.Now()
+	item.Url = clueApiUrl
+	item.Body = ""
+	item.Result = string(body)
+	go models.AddCygxShanghaiCompanyLog(item)
 	go models.UpdateCygxArticleCeluePush(artcleId)
 	articleResult := articleResultDate.Data
 
@@ -1350,7 +1364,16 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 		condition += ` AND p.chart_permission_id  IN (` + utils.GetOrmInReplace(len(slicepermissionId)) + ` )  `
 		pars = append(pars, permissionIdList)
 	}
-	openidPowerList, err := models.GetCygxUserRecordPower(condition, pars)
+	openidPowerListMobile, err := models.GetCygxUserRecordPower(condition, pars)
+	if err != nil {
+		return err
+	}
+
+	var mobileArr []string
+	for _, v := range openidPowerListMobile {
+		mobileArr = append(mobileArr, v.Mobile)
+	}
+	openidPowerList, err := models.GetWxOpenIdByMobileSliceList(mobileArr)
 	if err != nil {
 		return err
 	}
@@ -1373,13 +1396,25 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 	//获取关注这个文章对应产业的用户的 openid
 	mapOpenidFllow := make(map[int]string)
 	if chartPermissionId != utils.CE_LUE_ID && chartPermissionId != utils.GU_SHOU_ID {
-		openidFllowList, err := models.GetCygxUserFllowOpenid(articleId)
+		openidFllowListMobile, err := models.GetCygxUserFllowOpenid(articleId)
+		if err != nil {
+			return err
+		}
+
+		var mobileArrFllow []string
+		for _, v := range openidFllowListMobile {
+			mobileArrFllow = append(mobileArrFllow, v.Mobile)
+		}
+
+		openidFllowList, err := models.GetWxOpenIdByMobileSliceList(mobileArrFllow)
 		if err != nil {
 			return err
 		}
+
 		for _, v := range openidFllowList {
 			mapOpenidFllow[v.UserId] = v.OpenId
 		}
+
 	}
 
 	//获取拒绝接收推送的的用户的 openid

+ 2 - 1
services/article_history.go

@@ -112,8 +112,9 @@ func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUse
 		recordRedis.RealName = user.RealName
 		recordRedis.CompanyName = user.CompanyName
 		recordRedis.StopTime = stopTime
+		recordRedis.ViewTime = record.CreateTime.Format(utils.FormatDateTime)
 		recordRedis.OutId = int(newId)
-		recordRedis.CreateTime = time.Now()
+		//recordRedis.CreateTime = time.Now()
 		go PushViewRecordNewRedisData(recordRedis, user.CompanyId)
 		utils.Rc.Put(key, 1, 2*time.Second)
 	}

+ 29 - 0
services/company_permission.go

@@ -286,3 +286,32 @@ func GetUserHasPermissionSimple(user *models.WxUserItem) (hasPermission int, err
 	}
 	return
 }
+
+// GetPermissionNameMap 权限名称与权限ID的map
+func GetPermissionNameMap() (mapItem map[int]string, err error) {
+	list, e := models.GetChartPermissionListRai()
+	if e != nil {
+		err = e
+		return
+	}
+	mapPermissionName := make(map[int]string)
+	for _, v := range list {
+		mapPermissionName[v.ChartPermissionId] = v.PermissionName
+	}
+	mapItem = mapPermissionName
+	return
+}
+
+func GetPermissionNameIcoMap() (mapItem map[int]string, err error) {
+	list, e := models.GetChartPermissionListRai()
+	if e != nil {
+		err = e
+		return
+	}
+	mapPermissionName := make(map[int]string)
+	for _, v := range list {
+		mapPermissionName[v.ChartPermissionId] = v.ImageUrlM
+	}
+	mapItem = mapPermissionName
+	return
+}

+ 304 - 0
services/cygx_yanxuan_special.go

@@ -0,0 +1,304 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+// 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+func SendWxMsgSpecialFollow(specialId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息失败", specialId, ", specialId", err.Error()), 2)
+		}
+	}()
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+
+	followers, e := models.GetYanxuanSpecialFollowUserById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	if len(followers) == 0 {
+		return
+	}
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	var allInUserId string
+	for _, v := range followers {
+		allInUserId += strconv.Itoa(v) + ","
+	}
+
+	allInUserId = strings.TrimRight(allInUserId, ",")
+
+	userList, err := models.GetWxUserListByUserIds(allInUserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	mobile := ``
+
+	for _, v := range userList {
+		mobile += v.Mobile + ","
+	}
+
+	mobile = strings.TrimRight(mobile, ",")
+
+	openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+	if e != nil {
+		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+		return
+	}
+	if len(openIdList) == 0 {
+		return
+	}
+
+	//first =
+	keyword1 = "研选专栏:" + specialItem.SpecialName
+	keyword2 = "发布了新内容,点击查看详情"
+	keyword3 = "-"
+	//keyword4 = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := ""
+	redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(specialId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// SendReviewTemplateMsgAdmin 提交审核时给王芳,汪洋发消息
+func SendReviewTemplateMsgAdmin(specialId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("处理试用申请给王芳,汪洋发消息失败, specialId:", specialId, "ErrMsg", err.Error()), 2)
+		}
+	}()
+	var configCode string
+	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
+	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	cnf, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
+		return
+	}
+	openIdList, e := models.GetUserRecordListByMobile(4, cnf.ConfigValue)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
+		return err
+	}
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	user, e := models.GetWxUserItemByUserId(specialItem.UserId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+		return err
+	}
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	keyword1 = specialItem.RealName + "【" + user.CompanyName + "】"
+	keyword2 = user.Mobile
+	keyword3 = time.Now().Format(utils.FormatDateTime)
+	keyword4 = "研选专栏提交了内容待审核"
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := ""
+	redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_ENABLE_DETAIL + strconv.Itoa(specialId)
+	sendInfo := new(SendWxTemplate)
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(specialId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// 研选专栏审核完成时,给提交人发送模板消息
+func SendWxMsgSpecialAuthor(specialId, status int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("研选专栏审核完成时,给提交人发送模板消息", specialId, ", specialId", err.Error()), 2)
+		}
+	}()
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	var redirectUrl string
+
+	specialItem, e := models.GetYanxuanSpecialItemById(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
+		return
+	}
+	user, e := models.GetWxUserItemByUserId(specialItem.UserId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
+		return err
+	}
+
+	openIdList, err := models.GetUserRecordListByMobile(4, user.Mobile)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	keyword1 = "研选专栏内容审核"
+	if status == 1 {
+		keyword2 = "已通过审核,点击查看详情"
+		redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
+	} else {
+		keyword2 = "未通过审核,点击查看驳回原因"
+		redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_CENTER
+	}
+	keyword3 = "-"
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(specialId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+//func init() {
+//
+//	var condition string
+//	var pars []interface{}
+//
+//	condition = " AND   a.user_id = 103354  "
+//	list, tmpErr := models.GetYanxuanSpecialList(0, condition, pars)
+//
+//	fmt.Println(len(list))
+//	fmt.Println(tmpErr)
+//
+//	for _, v := range list {
+//		fmt.Println(v.Id)
+//		EsAddYanxuanSpecial(v.Id)
+//	}
+//}
+
+// 更新研选专栏  写入首页最新  cygx_resource_data 表
+func UpdateYanxuanSpecialResourceData(sourceId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败sourceId: ", sourceId, "ErrMsg", err.Error()), 2)
+		}
+	}()
+	var source = utils.CYGX_OBJ_YANXUANSPECIAL
+	var condition string
+	var pars []interface{}
+	condition = ` AND status = 3  AND  id = ?  `
+	pars = append(pars, sourceId)
+	total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
+		return
+	}
+	//如果取消发布了就做删除处理
+	if total == 0 {
+		e = models.DeleteResourceData(sourceId, source)
+		if e != nil {
+			err = errors.New("DeleteResourceData, Err: " + e.Error())
+			return
+		}
+	} else {
+		//判断是否存在,如果不存在就新增,存在就更新
+		totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
+		if e != nil {
+			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
+			return
+		}
+
+		detail, e := models.GetYanxuanSpecialBySpecialId(sourceId)
+		if e != nil {
+			err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
+			return
+		}
+		publishDate := detail.PublishTime
+		item := new(models.CygxResourceData)
+		item.SourceId = sourceId
+		item.Source = source
+		item.PublishDate = publishDate
+		item.CreateTime = time.Now()
+		if totalData == 0 {
+			_, e := models.AddCygxResourceData(item)
+			if e != nil {
+				err = errors.New("AddCygxResourceData, Err: " + e.Error())
+				return
+			}
+		} else {
+			e = models.UpdateResourceDataByItem(item)
+			if e != nil {
+				err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
+				return
+			}
+		}
+	}
+	return
+}

+ 91 - 0
services/cygx_yanxuan_special_company.go

@@ -0,0 +1,91 @@
+package services
+
+import (
+	"context"
+	"encoding/json"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"io/ioutil"
+	"net/http"
+	"time"
+)
+
+func GetStocksFromVmp(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("更新上市公司表失败"+err.Error(), 2)
+		}
+	}()
+	err = models.DelYanxuanSpecialCompany()
+	if err != nil {
+		fmt.Println("获取上市公司信息失败 Err:%s", err.Error())
+		return
+	}
+	getUrl := "https://vmp.hzinsights.com/v2api/articles/stock"
+	result, err := http.Get(getUrl)
+	if err != nil {
+		return
+	}
+	defer result.Body.Close()
+	body, err := ioutil.ReadAll(result.Body)
+	if err != nil {
+		fmt.Println("err:" + err.Error())
+		return
+	}
+	fmt.Println(body)
+	var resp models.VmpStocks
+	err = json.Unmarshal(body, &resp)
+	if err != nil {
+		fmt.Println("获取上市公司信息失败 Err:%s", err.Error())
+		return
+	}
+
+	items := make([]*models.CygxYanxuanSpecialCompany, 0)
+
+
+	for i, _ := range resp.Data {
+		items = append(items, &resp.Data[i])
+		if len(items) > 5000 {
+			err  = models.AddCygxYanxuanSpecialCompanyMulti(items)
+			if err != nil {
+				fmt.Println("AddCygxYanxuanSpecialCompanyMulti Err:%s", err.Error())
+				return
+			}
+			items = []*models.CygxYanxuanSpecialCompany{}
+		}
+	}
+
+	err  = models.AddCygxYanxuanSpecialCompanyMulti(items)
+	if err != nil {
+		fmt.Println("AddCygxYanxuanSpecialCompanyMulti Err:%s", err.Error())
+		return
+	}
+	return
+}
+
+func AddSpecialRecord(user *models.WxUserItem, specialId int) {
+	var sellerName string
+	sellerName, err := models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		return
+	}
+	item := models.CygxYanxuanSpecialRecord{
+		UserId:           user.UserId,
+		Mobile:           user.Mobile,
+		Email:            user.Email,
+		CompanyId:        user.CompanyId,
+		CompanyName:      user.CompanyName,
+		RealName:         user.RealName,
+		SellerName:       sellerName,
+		CreateTime:       time.Now(),
+		ModifyTime:       time.Now(),
+		RegisterPlatform: utils.REGISTER_PLATFORM,
+		YanxuanSpecialId: specialId,
+	}
+	_, err = models.AddCygxYanxuanSpecialRecord(&item)
+	if err != nil {
+		return
+	}
+}

+ 61 - 1
services/es_comprehensive.go

@@ -584,6 +584,41 @@ func AddComprehensiveRoadshow() {
 	}
 }
 
+// Es研选专栏
+func EsAddYanxuanSpecial(sourceId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败sourceId: ", sourceId), 2)
+		}
+	}()
+	detail, e := models.GetYanxuanSpecialItemById(sourceId)
+	if e != nil {
+		err = errors.New("GetArticleInfoOtherByArticleId" + e.Error())
+		return
+	}
+	content := html.UnescapeString(detail.Content)
+	doc, e := goquery.NewDocumentFromReader(strings.NewReader(content))
+	if e != nil {
+		err = errors.New("goquery.NewDocumentFromReader" + e.Error())
+		return
+	}
+	bodyText := doc.Text()
+	item := new(ElasticComprehensiveDetail)
+	item.SourceId = detail.Id
+	item.Source = utils.CYGX_OBJ_YANXUANSPECIAL
+	item.Title = detail.Title
+	item.PublishDate = detail.PublishTime
+	item.BodyText = bodyText
+	if detail.Status == 3 {
+		EsAddOrEditComprehensiveData(item) //如果发布了就新增
+	} else {
+		EsDeleteComprehensiveData(item) // 没有发布就删除
+	}
+	return
+}
+
 // 新增和修改数据
 func EsAddOrEditComprehensiveData(item *ElasticComprehensiveDetail) (err error) {
 	indexName := utils.IndexNameComprehensive
@@ -962,6 +997,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	var productinteriorIds []int
 	var industrialResourceIdsHz []int // 弘则产业资源包
 	var industrialResourceIdsYx []int // 研选产业资源包
+	var yanxuanSpecialIds []int       // 研选专栏
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -990,6 +1026,8 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			industrialResourceIdsHz = append(industrialResourceIdsHz, v.SourceId)
 		} else if v.Source == "industrialsourceYx" {
 			industrialResourceIdsYx = append(industrialResourceIdsYx, v.SourceId)
+		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
+			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
 		}
 	}
 	//处理文章
@@ -1420,10 +1458,32 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 	}
 
+	//处理研选专栏
+	lenyanxuanSpecialIds := len(yanxuanSpecialIds)
+	if lenyanxuanSpecialIds > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.id IN (` + utils.GetOrmInReplace(lenyanxuanSpecialIds) + `) `
+		pars = append(pars, yanxuanSpecialIds)
+		listyanxuanSpecial, e := models.GetYanxuanSpecialList(user.UserId, condition, pars)
+		if e != nil {
+			err = errors.New("GetYanxuanSpecialList, Err: " + e.Error())
+			return
+		}
+
+		for _, v := range listyanxuanSpecial {
+			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
+			v.Annotation, _ = GetReportContentTextSubNew(v.Content)
+			// Source  PublishDate 字段兼容前端样式
+			v.Source = utils.CYGX_OBJ_YANXUANSPECIAL
+			v.PublishDate = v.PublishTime
+			mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL, v.Id)].YanxuanSpecial = v
+		}
+	}
+
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil {
+			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil {
 				continue
 			}
 			if v.Article != nil && v.SourceId == vList.SourceId {

+ 10 - 8
services/keyword.go

@@ -69,15 +69,16 @@ func SearchKeywordUserRmind(user *models.WxUserItem, keyWord string) (err error)
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
-			go utils.SendAlarmMsg("用户搜索操作操作行为,模板消息推送失败"+err.Error(), 2)
+			go utils.SendAlarmMsg(fmt.Sprint("用户搜索操作操作行为,模板消息推送失败"+err.Error(), "UserId:", user.UserId, "keyWord:", keyWord), 2)
 		}
 	}()
-	countUser, err := models.GetUserRemind(user.UserId)
-	if err != nil {
-		return err
+	countUser, e := models.GetUserRemind(user.UserId)
+	if e != nil {
+		err = errors.New("GetUserRemind, Err: " + e.Error())
+		return
 	}
 	if countUser == 0 {
-		return err
+		return
 	}
 	var first string
 	var keyword1 string
@@ -86,9 +87,10 @@ func SearchKeywordUserRmind(user *models.WxUserItem, keyWord string) (err error)
 	var keyword4 string
 	var remark string
 	//获取销售手机号
-	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		return err
+	sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+		return
 	}
 	if sellerItemQy != nil {
 		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)

+ 35 - 0
services/oss.go

@@ -138,3 +138,38 @@ func UploadFileToAliyun(filename, filepath, savePath string) error {
 	//return path,err
 	return err
 }
+
+// GetCloudDiskResourceFileTypeExtMap 常见文件类型图标
+func GetCloudDiskResourceFileTypeExtMap() map[string]string {
+	return map[string]string{
+		".doc":  "https://hzstatic.hzinsights.com/static/icon/file_type_docx.png",
+		".docx": "https://hzstatic.hzinsights.com/static/icon/file_type_docx.png",
+
+		".pdf": "https://hzstatic.hzinsights.com/static/icon/file_type_pdf.png",
+
+		".ppt":  "https://hzstatic.hzinsights.com/static/icon/file_type_ppt.png",
+		".pptx": "https://hzstatic.hzinsights.com/static/icon/file_type_ppt.png",
+
+		".xls":  "https://hzstatic.hzinsights.com/static/icon/file_type_xlsx.png",
+		".xlsx": "https://hzstatic.hzinsights.com/static/icon/file_type_xlsx.png",
+
+		".jpg":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".jpeg": "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".png":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".bmp":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".svg":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".gif":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+
+		".mp4":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".wmv":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".mov":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".mpeg": "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".avi":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".flv":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".rm":   "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".rmvb": "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+
+		".mp3": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
+		".wma": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
+	}
+}

+ 27 - 3
services/resource_data.go

@@ -41,6 +41,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 	var meetingreviewchaptIds []int
 	var productinteriorIds []int
 	var reportselectionIds []int // 报告精选
+	var yanxuanSpecialIds []int  // 研选专栏
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -67,8 +68,9 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			productinteriorIds = append(productinteriorIds, v.SourceId)
 		} else if v.Source == "reportselection" {
 			reportselectionIds = append(reportselectionIds, v.SourceId)
+		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
+			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
 		}
-
 	}
 	//处理文章
 	if len(articleIds) > 0 {
@@ -440,10 +442,32 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
+	//处理研选专栏
+	lenyanxuanSpecialIds := len(yanxuanSpecialIds)
+	if lenyanxuanSpecialIds > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.id IN (` + utils.GetOrmInReplace(lenyanxuanSpecialIds) + `) `
+		pars = append(pars, yanxuanSpecialIds)
+		listyanxuanSpecial, e := models.GetYanxuanSpecialList(user.UserId, condition, pars)
+		if e != nil {
+			err = errors.New("GetYanxuanSpecialList, Err: " + e.Error())
+			return
+		}
+
+		for _, v := range listyanxuanSpecial {
+			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
+			v.Annotation, _ = GetReportContentTextSubNew(v.Content)
+			// Source  PublishDate 字段兼容前端样式
+			v.Source = utils.CYGX_OBJ_YANXUANSPECIAL
+			v.PublishDate = v.PublishTime
+			mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL, v.Id)].YanxuanSpecial = v
+		}
+	}
+
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil {
+			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil && v.YanxuanSpecial == nil {
 				continue
 			}
 			if v.SourceId == vList.SourceId {
@@ -534,7 +558,7 @@ func UpdateArticleResourceData(sourceId int) {
 		}
 	} else {
 		//判断是否存在,如果不存在就新增,存在就更新
-		totalData, e := models.GetCygxReportSelectionBySourceAndId(sourceId, source)
+		totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
 		if e != nil {
 			err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
 			return

+ 2 - 0
services/task.go

@@ -120,6 +120,8 @@ func Task() {
 		cygxActivityRestrictSignupByTask := task.NewTask("cygxActivityRestrictSignupByTask", "0 */10 6-23 * * *", CygxActivityRestrictSignupByTask)
 		task.AddTask("cygxActivityRestrictSignupByTask", cygxActivityRestrictSignupByTask) //定时任务处理为到会人员的爽约
 
+		getStocksFromVmp := task.NewTask("getStocksFromVmp", "0 40 3 * * *", GetStocksFromVmp)
+		task.AddTask("getStocksFromVmp", getStocksFromVmp) //定时任务更新上市公司表
 	}
 	if utils.RunMode != "release" {
 		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章

+ 30 - 9
services/user.go

@@ -437,6 +437,7 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	//手机号新增
 	fieldStr = ` u.mobile,u.country_code,u.real_name,c.company_name,u.company_id,cp.seller_name,cp.status,`
 	condition = `  AND cp.status IN ( '正式', '试用' ) AND u.mobile IN (` + mobileStr + `) `
+	condition += ` AND  u.mobile !=''  AND DATE_SUB(CURDATE(), INTERVAL 2 DAY) <= DATE(u.created_time )`
 	listMobile, err := models.GetFormalUserWhiteList(fieldStr, condition)
 	if err != nil {
 		msg = "获取失败,Err:" + err.Error()
@@ -450,11 +451,13 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	outboundMobileStr = strings.Replace(outboundMobileStr, " ", "", -1)
 	fieldStr = ` u.outbound_mobile as mobile,u.outbound_country_code as country_code,u.real_name,c.company_name,u.company_id,cp.status,`
 	condition = `  AND cp.status IN ( '正式', '试用' ) AND u.outbound_mobile IN (` + outboundMobileStr + `) `
+	condition += `  AND DATE_SUB(CURDATE(), INTERVAL 2 DAY) <= DATE(u.created_time )`
 	listOutboundMobile, err := models.GetFormalUserWhiteList(fieldStr, condition)
 	if err != nil {
 		msg = "获取失败,Err:" + err.Error()
 		return
 	}
+
 	var rep models.UserWhiteListRep
 	var repList []*models.UserWhiteList
 	repList = listMobile
@@ -463,7 +466,16 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 			repList = append(listMobile, v)
 		}
 	}
-	rep.List = repList
+
+	//新增用户,过滤手机号为空的
+	for _, v := range repList {
+		if v.Mobile == "" {
+			continue
+		}
+		rep.List = append(rep.List, v)
+	}
+
+	//rep.List = repList
 	//创建excel
 	dir, errFile := os.Executable()
 	exPath := filepath.Dir(dir)
@@ -640,17 +652,26 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	//手机号冻结
 	listFrozen, err := models.GetFrozenUserWhiteList()                 //手机号用户修改
 	listFrozenOutbound, err := models.GetFrozenUserWhiteListOutbound() //外呼手机号用户修改
+	if err != nil {
+		msg = "获取失败,Err:" + err.Error()
+		return
+	}
 	if len(listFrozenOutbound) > 0 {
 		for _, v := range listFrozenOutbound {
 			listFrozen = append(listFrozen, v)
 		}
 	}
-	if err != nil {
-		msg = "获取失败,Err:" + err.Error()
-		return
+
+	var listFrozenUser []*models.WxUserWhite
+	for _, v := range listFrozen {
+		if v.Mobile == "" {
+			continue
+		}
+		listFrozenUser = append(listFrozenUser, v)
 	}
-	if len(listFrozen) > 0 {
-		for _, item := range listFrozen {
+
+	if len(listFrozenUser) > 0 {
+		for _, item := range listFrozenUser {
 			row := sheet.AddRow()
 			cellA := row.AddCell()
 			cellA.Value = item.RealName
@@ -696,11 +717,10 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	content = time.Now().Format("2006-01-02") + "删除白名单用户"
 	fileName = downLoadnFilePaths
 	var sendResult2 bool
-	if len(listFrozen) > 0 {
+	if len(listFrozenOutbound) > 0 {
 		sendResult2 = utils.SendEmailByHongze(title, content, utils.EmaiWhiteUserList, fileName, title+".xlsx")
 	}
-	fmt.Println(sendResult2)
-	fmt.Println(sendResult)
+
 	os.Remove(downLoadnFilePaths)
 	//更新名单表
 	if sendResult {
@@ -726,6 +746,7 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 		if len(listOutboundMobile) > 0 {
 			for _, v := range listOutboundMobile {
 				item := new(models.WxUserWhite)
+				item.Mobile = v.Mobile
 				item.OutboundMobile = v.Mobile
 				item.OutboundCountryCode = v.CountryCode
 				item.CreatedTime = time.Now()

+ 1 - 1
services/user_label.go

@@ -739,7 +739,7 @@ func updateUserLabelByUserId(userId int) (err error) {
 	time.Sleep(200 * time.Millisecond)
 	var condition string
 	var pars []interface{}
-	condition = ` AND is_follow=1  AND  user_id = ?  `
+	condition = ` AND is_follow=1  AND  user_id = ?  AND modify_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)  `
 	pars = append(pars, userId)
 	totalSource1, e := models.GetCygxUserLabelCount(condition+" AND source = 1 ", pars)
 	if e != nil {

+ 61 - 0
utils/common.go

@@ -7,6 +7,7 @@ import (
 	"encoding/hex"
 	"encoding/json"
 	"fmt"
+	"github.com/PuerkitoBio/goquery"
 	"image"
 	"image/png"
 	"math"
@@ -868,3 +869,63 @@ func GetTimeDateRemoveYearAndSecond(strTime string) (dataStr string) {
 	dataStr = dataStr[:len(dataStr)-3]
 	return
 }
+
+func ArticleHasImgUrl(body string) (hasImg bool, err error) {
+	r := strings.NewReader(string(body))
+	doc, err := goquery.NewDocumentFromReader(r)
+	if err != nil {
+		fmt.Println(err)
+	}
+	doc.Find("img").Each(func(i int, s *goquery.Selection) {
+		hasImg = true
+	})
+	return
+}
+
+func ArticleHasStyle(body string) (hasStyle bool, err error) {
+	r := strings.NewReader(string(body))
+	doc, err := goquery.NewDocumentFromReader(r)
+	if err != nil {
+		fmt.Println(err)
+	}
+	doc.Find("p style").Each(func(i int, s *goquery.Selection) {
+		hasStyle = true
+	})
+	doc.Find("class").Each(func(i int, s *goquery.Selection) {
+		hasStyle = true
+	})
+	return
+}
+
+func ArticleRemoveImgUrl(body string) (result string){
+	// 使用正则表达式去除img标签
+	re := regexp.MustCompile(`<img[^>]*>`)
+	result = re.ReplaceAllString(body, "")
+
+	return
+}
+
+func FindArticleImgUrls(body string) (imgUrls []string, err error) {
+	r := strings.NewReader(string(body))
+	doc, err := goquery.NewDocumentFromReader(r)
+	if err != nil {
+		fmt.Println(err)
+	}
+	doc.Find("img").Each(func(i int, s *goquery.Selection) {
+		src, _ := s.Attr("src")
+		imgUrls = append(imgUrls, src)
+	})
+	return
+}
+
+// 去除部分style
+func ExtractText(body string) (result string, err error) {
+	// 使用正则表达式去除img标签
+	re := regexp.MustCompile(`<section style[\s\S]*?>`)
+	result = re.ReplaceAllString(body, "")
+
+	re = regexp.MustCompile(`<span style[\s\S]*?>`)
+	result = re.ReplaceAllString(result, "")
+
+	return
+}

+ 2 - 0
utils/config.go

@@ -9,6 +9,7 @@ import (
 var (
 	RunMode               string //运行模式
 	MYSQL_URL             string //数据库连接
+	MYSQL_URL_CYGX        string //查研观向数据库连接
 	MYSQL_URL_RDDP        string //数据库连接
 	MYSQL_URL_TACTICS     string
 	MYSQL_URL_COMEIN_DATA string // 路演记录数据库
@@ -122,6 +123,7 @@ func init() {
 	}
 	//beego.Info(RunMode + " 模式")
 	MYSQL_URL = config["mysql_url"]
+	MYSQL_URL_CYGX = config["mysql_url_cygx"]
 	MYSQL_URL_RDDP = config["mysql_url_rddp"]
 	MYSQL_URL_TACTICS = config["mysql_url_tactics"]
 	MYSQL_URL_COMEIN_DATA = config["mysql_url_comein_data"]

+ 8 - 0
utils/constants.go

@@ -183,6 +183,9 @@ const (
 	WX_MSG_PATH_APPLY_DETAIL             = "pages-message/applyFor/applyFor?id="                          //潜在用户试用权限申请
 	WX_MSG_PATH_YX_SURVEY_DETAIL         = "pages-purchaser/survey/surveyDetail?surveyId="                //用户提交研选调研需求
 	WX_MSG_PATH_APPLY_COLLECTION_DETAIL  = "reportPages/bulletinDetail/bulletinDetail?id="                //精选看板申请详情页
+	WX_MSG_PATH_YX_SPECIAL_DETAIL        = "pages-purchaser/noteAndViewpoint/noteAndViewpoint?id="        //研选专栏详情
+	WX_MSG_PATH_YX_SPECIAL_ENABLE_DETAIL = "pages-purchaser/toExamine/toExamine?isMessage=模板&id="         //研选专栏审核详情页面
+	WX_MSG_PATH_YX_SPECIAL_CENTER        = "pages-purchaser/contentAllPage/contentAllPage?Status=4"       //研选专栏内容中心
 )
 
 //2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=
@@ -238,4 +241,9 @@ const (
 	CYGX_OBJ_PRODUCTINTERIOR    string = "productinterior"    // 对象类型:产品内测
 	CYGX_OBJ_RESEARCHSUMMARY    string = "researchsummary"    // 对象类型:本周研究汇总
 	CYGX_OBJ_MINUTESSUMMARY     string = "minutessummary"     // 对象类型:本周研究汇总
+	CYGX_OBJ_YANXUANSPECIAL     string = "yanxuanspecial"     // 对象类型:研选专栏
+)
+
+const (
+	CYGX_YANXUAN_SPECIAL = "研选专栏" //用户阅读数据
 )

+ 8 - 8
utils/email.go

@@ -13,7 +13,7 @@ var (
 	AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send"
 )
 
-//发送邮件
+// 发送邮件
 func SendEmail(title, content string, touser string) bool {
 	if RunMode == "debug" {
 		return false
@@ -40,10 +40,10 @@ func SendEmail(title, content string, touser string) bool {
 	return true
 }
 
-//projectName-项目名称
-//runMode-运行模式
-//msgBody-消息内容
-//level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
+// projectName-项目名称
+// runMode-运行模式
+// msgBody-消息内容
+// level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
 func SendAlarmMsg(msgBody string, level int) {
 	params := make(map[string]interface{})
 	params["ProjectName"] = APPNAME
@@ -58,7 +58,7 @@ func SendAlarmMsg(msgBody string, level int) {
 	http.Post(AlarmMsgUrl, string(param))
 }
 
-//发送邮件
+// 发送邮件
 func SendEmailByHz(title, content string, touser string) (result bool, err error) {
 	//if RunMode == "debug" {
 	//	result = false
@@ -88,7 +88,7 @@ func SendEmailByHz(title, content string, touser string) (result bool, err error
 	return
 }
 
-//发送带有文件的邮件
+// 发送带有文件的邮件
 func SendEmailHaveFile(title, content string, fileName, touser string) bool {
 	var arr []string
 	sub := strings.Index(touser, ";")
@@ -113,7 +113,7 @@ func SendEmailHaveFile(title, content string, fileName, touser string) bool {
 	return true
 }
 
-//发送邮件
+// 发送邮件
 func SendEmailByHongze(title, content string, touser, attachPath, attachName string) bool {
 	var arr []string
 	sub := strings.Index(touser, ";")