|
@@ -5,7 +5,6 @@ import (
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
- "sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -336,170 +335,170 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- for _, vUser := range listUser {
|
|
|
- labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetCygxCompanyUserListSplit Err", err)
|
|
|
- return err
|
|
|
- }
|
|
|
- mapLabels := make(map[string]string)
|
|
|
- var labelsListStr []*models.UserLabel
|
|
|
- mapActivityLabels := make(map[string]string)
|
|
|
- labelsList := strings.Split(labels, ",")
|
|
|
- for _, vL := range labelsList {
|
|
|
- if mapLabels[vL] == "" && vL != "" {
|
|
|
- mapLabels[vL] = vL
|
|
|
- item := new(models.UserLabel)
|
|
|
- item.Label = vL
|
|
|
- labelsListStr = append(labelsListStr, item)
|
|
|
- }
|
|
|
- }
|
|
|
- dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
|
|
|
- listArticlePv, err := models.GetArticlePvCount(vUser.Mobile, vUser.Email, dateTime)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- fmt.Println("GetArticlePvCount Err", err)
|
|
|
- return err
|
|
|
- }
|
|
|
- var articleIds string
|
|
|
- mapArticleIdLabelTotal := make(map[string]int)
|
|
|
- mapArticleIdPv := make(map[int]int)
|
|
|
- if len(listArticlePv) > 0 {
|
|
|
- for _, v := range listArticlePv {
|
|
|
- articleIds += strconv.Itoa(v.ArticleId) + ","
|
|
|
- mapArticleIdPv[v.ArticleId] = v.Pv
|
|
|
- }
|
|
|
- articleIds = strings.TrimRight(articleIds, ",")
|
|
|
-
|
|
|
- listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- fmt.Println("GetArticleGroupyIndustryName Err", err)
|
|
|
- return err
|
|
|
- }
|
|
|
- if len(listLabelName) > 0 {
|
|
|
- for _, v := range listLabelName {
|
|
|
- labelsIndustryList := strings.Split(v.IndustryName, "/")
|
|
|
- labelsSubjectList := strings.Split(v.SubjectName, "/")
|
|
|
-
|
|
|
- if len(labelsIndustryList) > 0 {
|
|
|
- for _, vIn := range labelsIndustryList {
|
|
|
- if mapActivityLabels[vIn] != "" {
|
|
|
- mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
|
|
|
- } else {
|
|
|
- mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
|
|
|
- mapActivityLabels[vIn] = vIn
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if len(labelsSubjectList) > 0 {
|
|
|
-
|
|
|
- for _, vIn := range labelsSubjectList {
|
|
|
- if mapActivityLabels[vIn] != "" {
|
|
|
- mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
|
|
|
- } else {
|
|
|
- mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
|
|
|
- mapActivityLabels[vIn] = vIn
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- articleIds, err = models.GetCygxArticleCollectId(vUser.UserId, dateTime)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- fmt.Println("GetCygxArticleCollectId Err", err)
|
|
|
- return err
|
|
|
- }
|
|
|
- if articleIds != "" {
|
|
|
-
|
|
|
- listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- fmt.Println("GetArticleGroupyIndustryName Err", err)
|
|
|
- return err
|
|
|
- }
|
|
|
- if len(listLabelName) > 0 {
|
|
|
- for _, v := range listLabelName {
|
|
|
- labelsIndustryList := strings.Split(v.IndustryName, "/")
|
|
|
- labelsSubjectList := strings.Split(v.SubjectName, "/")
|
|
|
-
|
|
|
- if len(labelsIndustryList) > 0 {
|
|
|
- for _, vIn := range labelsIndustryList {
|
|
|
- if mapActivityLabels[vIn] != "" {
|
|
|
- mapArticleIdLabelTotal[vIn] += 1
|
|
|
- } else {
|
|
|
- mapArticleIdLabelTotal[vIn] = 1
|
|
|
- mapActivityLabels[vIn] = vIn
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if len(labelsSubjectList) > 0 {
|
|
|
-
|
|
|
- for _, vIn := range labelsSubjectList {
|
|
|
- if mapActivityLabels[vIn] != "" {
|
|
|
- mapArticleIdLabelTotal[vIn] += 1
|
|
|
- } else {
|
|
|
- mapArticleIdLabelTotal[vIn] = 1
|
|
|
- mapActivityLabels[vIn] = vIn
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- listActivityPv, err := models.GetActivitySignCount(vUser.Mobile, dateTime)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- fmt.Println("GetActivitySignCount Err", err)
|
|
|
- return err
|
|
|
- }
|
|
|
- if len(listActivityPv) > 0 {
|
|
|
- for _, v := range listActivityPv {
|
|
|
- labelsList := strings.Split(v.Label, "-")
|
|
|
- for _, v2 := range labelsList {
|
|
|
- labelsListSon := strings.Split(v2, "/")
|
|
|
- for _, v3 := range labelsListSon {
|
|
|
- if mapActivityLabels[v3] != "" {
|
|
|
- mapArticleIdLabelTotal[v3] += 1
|
|
|
- } else {
|
|
|
- mapArticleIdLabelTotal[v3] = 1
|
|
|
- mapActivityLabels[v3] = v3
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- type KvPair struct {
|
|
|
- Key string
|
|
|
- Val int
|
|
|
- }
|
|
|
- tmpList := make([]KvPair, 0)
|
|
|
- for k, v := range mapArticleIdLabelTotal {
|
|
|
- tmpList = append(tmpList, KvPair{Key: k, Val: v})
|
|
|
- }
|
|
|
- sort.Slice(tmpList, func(i, j int) bool {
|
|
|
- return tmpList[i].Val > tmpList[j].Val
|
|
|
- })
|
|
|
- for _, v := range tmpList {
|
|
|
- if v.Key != "" {
|
|
|
- mapLabels[v.Key] = v.Key
|
|
|
- item := new(models.UserLabel)
|
|
|
- item.Label = v.Key
|
|
|
- labelsListStr = append(labelsListStr, item)
|
|
|
- }
|
|
|
- }
|
|
|
- var labelNew string
|
|
|
- for _, v := range labelsListStr {
|
|
|
- labelNew += v.Label + ","
|
|
|
- }
|
|
|
- labelNew = strings.TrimRight(labelNew, ",")
|
|
|
- if labelNew != "" {
|
|
|
- err = models.UpdateUserLabel(labelNew, vUser.UserId)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("UpdateUserLabel Err", err)
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
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