Bladeren bron

no message

zhangchuanxing 4 dagen geleden
bovenliggende
commit
fcad772c43
3 gewijzigde bestanden met toevoegingen van 122 en 50 verwijderingen
  1. 8 48
      controllers/cygx/user.go
  2. 2 2
      models/cygx/article_and_yanxuan_record.go
  3. 112 0
      services/cygx/article.go

+ 8 - 48
controllers/cygx/user.go

@@ -2519,7 +2519,7 @@ func (this *UserController) CompanyTableDetail() {
 			condition += " AND art.article_type_id > 0  "
 		}
 		condition += "  ORDER BY r.create_time DESC "
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			total, err = cygx.GetCygxArticleAndYanxuanRecordCount(condition, pars)
 			if err != nil {
@@ -2548,7 +2548,7 @@ func (this *UserController) CompanyTableDetail() {
 			}
 		}
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
@@ -3174,7 +3174,7 @@ func (this *UserController) CompanyExportInteraction() {
 		}
 		condition += ` ORDER BY r.create_time DESC  `
 		var pars []interface{}
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -3191,7 +3191,7 @@ func (this *UserController) CompanyExportInteraction() {
 			}
 		}
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
@@ -3826,7 +3826,7 @@ func (this *UserController) CompanyList() {
 
 		var pars []interface{}
 		condition += "  ORDER BY r.create_time DESC "
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, startSize, pageSize)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -3856,7 +3856,7 @@ func (this *UserController) CompanyList() {
 		}
 
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
@@ -4767,7 +4767,7 @@ func (this *UserController) CompanyExportInteractionList() {
 		}
 		condition += ` ORDER BY r.create_time DESC  `
 		var pars []interface{}
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -4784,52 +4784,12 @@ func (this *UserController) CompanyExportInteractionList() {
 			}
 		}
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
 			return
 		}
-		if len(list) > 0 {
-			var articleIds string
-			mapAricleId := make(map[int]int)
-			mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
-			for k, v := range list {
-				if v.ArticleId >= utils.SummaryArticleId {
-					list[k].ArticleType = 1
-				} else {
-					list[k].ArticleType = 2
-				}
-				if list[k].PermissionName == "" {
-					list[k].PermissionName = v.CategoryName
-				}
-				if mapAricleId[v.ArticleId] == 0 {
-					articleIds += strconv.Itoa(v.ArticleId) + ","
-					mapAricleId[v.ArticleId] = v.ArticleId
-				}
-			}
-			articleIds = strings.TrimRight(articleIds, ",")
-			if articleIds != "" {
-				listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
-				if err != nil && err.Error() != utils.ErrNoRow() {
-					br.Msg = "获取信息失败"
-					br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
-					return
-				}
-				if len(listArticleIndustrialSubjectList) > 0 {
-					for _, v := range listArticleIndustrialSubjectList {
-						mapAricleIndustrialSubjectName[v.ArticleId] = v
-					}
-					for k, v := range list {
-						if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
-							fmt.Println(mapAricleIndustrialSubjectName[v.ArticleId].IndustryName)
-							list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName
-							list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr
-						}
-					}
-				}
-			}
-		}
 	} else if source == 2 {
 		if classType == 1 {
 			condition += "  AND  a.chart_permission_id  != 31 "

+ 2 - 2
models/cygx/article_and_yanxuan_record.go

@@ -53,7 +53,7 @@ func GetCygxArticleAndYanxuanRecordCountWeekly(condition string, pars []interfac
 }
 
 // 列表
-func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleAndYanxuanRecordResp, err error) {
+func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT r.* ,art.title  FROM cygx_article_history_record_all as r 
           INNER JOIN cygx_article  as art  ON  art.article_id = r.article_id  WHERE 1= 1 `
@@ -66,7 +66,7 @@ func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}
 }
 
 // 列表(关联用户跟销售的绑定关系跨库查询)
-func GetCygxArticleAndYanxuanRecordRespListWeekly(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleAndYanxuanRecordResp, err error) {
+func GetCygxArticleAndYanxuanRecordRespListWeekly(condition string, pars []interface{}, startSize, pageSize int) (items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	databaseName := utils.GetWeeklyDatabase()
 	sql := `SELECT r.* FROM cygx_article_history_record_all as r 

+ 112 - 0
services/cygx/article.go

@@ -340,6 +340,118 @@ func HandleArticleAndYanxuanRecordList(items []*cygx.CygxArticleAndYanxuanRecord
 	return
 }
 
+// 处理文章、研选专栏的查询信息回显
+func HandleArticleAndYanxuanRecordList2(items []*cygx.UserInteraction) (itemsResp []*cygx.UserInteraction, err error) {
+	itemsResp = make([]*cygx.UserInteraction, 0)
+	if len(items) > 0 {
+
+		var articleIds []int        // 文章ID
+		var yanxuanSpecialIds []int // 研选专栏ID
+		var sellerCompanyIds []int  // 公司ID
+		var mobiles []string        // 手机号
+		for _, v := range items {
+			articleIds = append(articleIds, v.ArticleId)
+			sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+			mobiles = append(mobiles, v.Mobile)
+		}
+
+		sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
+
+		mapIndustrialLabel := GetArticleIndustrialLabelByArticleId(articleIds) // 关联产业
+		mapSubjectLabel := GetArticleSubjectLabelByArticleId(articleIds)       // 关联标的
+
+		//根据手机号获取这些用户的信息
+		listUser, e := models.GetWxUserByOutboundMobiles(mobiles)
+		if e != nil {
+			err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
+			return
+		}
+		mapUserRealname := make(map[string]string)
+		for _, v := range listUser {
+			mapUserRealname[v.Mobile] = v.RealName
+		}
+
+		var condition string
+		var pars []interface{}
+
+		//获取文章map
+		mapArticle := make(map[int]*cygx.CygxReportArticle)
+		lenarticleIds := len(articleIds)
+		if lenarticleIds > 0 {
+			condition = " AND art.article_id IN  (" + utils.GetOrmInReplace(lenarticleIds) + ")  GROUP  BY art.article_id "
+			pars = append(pars, articleIds)
+			list, e := cygx.GetReportArticleList(condition, pars, 0, lenarticleIds, 1)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = e
+				return
+			}
+
+			if len(list) > 0 {
+				for _, v := range list {
+					mapArticle[v.ArticleId] = v
+				}
+			}
+		}
+
+		//获取研选专栏map
+		mapYanxuanSpecial := make(map[int]*cygx.CygxYanxuanSpeciaResplItem)
+		lenyanxuanSpecialIds := len(yanxuanSpecialIds)
+		if lenyanxuanSpecialIds > 0 {
+			pars = make([]interface{}, 0)
+			condition = " AND a.id IN  (" + utils.GetOrmInReplace(lenyanxuanSpecialIds) + ")"
+			pars = append(pars, yanxuanSpecialIds)
+			list, e := cygx.GetYanxuanSpecialListByCondition(condition, pars, 0, lenyanxuanSpecialIds)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = e
+				return
+			}
+			if len(list) > 0 {
+				for _, v := range list {
+					mapYanxuanSpecial[v.Id] = v
+				}
+			}
+		}
+
+		for _, v := range items {
+			item := new(cygx.UserInteraction)
+
+			item.IndustryName = strings.Join(mapIndustrialLabel[v.ArticleId], ",")
+			item.SubjectNameStr = strings.Join(mapSubjectLabel[v.ArticleId], ",")
+			if v.ArticleId >= utils.SummaryArticleId {
+				item.ArticleType = 1
+			} else {
+				item.ArticleType = 2
+			}
+			//如果对应的map不为空,就赋值
+			if mapArticle[v.ArticleId] != nil {
+				item.Title = mapArticle[v.ArticleId].Title
+				item.PublishDate = mapArticle[v.ArticleId].PublishDate
+				item.PermissionName = mapArticle[v.ArticleId].PermissionName
+				item.ArticleIdMd5 = mapArticle[v.ArticleId].ArticleIdMd5
+				item.ReportId = mapArticle[v.ArticleId].ReportId
+			}
+
+			item.ArticleId = v.ArticleId
+			item.CreateTime = v.CreateTime
+			item.UserId = v.UserId
+			item.RealName = v.RealName
+			if item.RealName == "" {
+				item.RealName = mapUserRealname[v.Mobile]
+			}
+			item.Mobile = v.Mobile
+			item.CompanyId = v.CompanyId
+			item.CompanyName = v.CompanyName
+			item.SellerName = sellNameMap[v.CompanyId]
+			item.RegisterPlatform = v.RegisterPlatform
+			item.RegisterPlatformText = GetArticleSourcePlatformText(v.RegisterPlatform)
+			item.StopTime = v.StopTime
+			itemsResp = append(itemsResp, item)
+		}
+
+	}
+	return
+}
+
 //
 //func init() {
 //	SendWxMsgWithroadshowEssence(1000546)