|
@@ -5,6 +5,7 @@ import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/models/roadshow"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
"strconv"
|
|
|
"time"
|
|
@@ -171,10 +172,10 @@ func KeyWordsWxUserRaiLabelRedisAddReduce(log models.WxUserRaiLabelRedis) (err e
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func init() {
|
|
|
- log := models.WxUserRaiLabelRedis{UserId: 53840, SourceId: 1753, SourceType: 3, TableName: "", Label: "", CreateTime: time.Now(), RegisterPlatform: utils.REGISTER_PLATFORM}
|
|
|
- ActivityWxUserRaiLabelRedisAddReduce(log)
|
|
|
-}
|
|
|
+//func init() {
|
|
|
+// log := models.WxUserRaiLabelRedis{UserId: 53840, SourceId: 1753, SourceType: 3, TableName: "", Label: "", CreateTime: time.Now(), RegisterPlatform: utils.REGISTER_PLATFORM}
|
|
|
+// RoadshowWxUserRaiLabelRedisAddReduce(log)
|
|
|
+//}
|
|
|
|
|
|
// 2:产业/个股标签(线下活动)、 4:产业/个股标签(线上活动)
|
|
|
// 用户参加活动,相关标签
|
|
@@ -305,46 +306,100 @@ func RoadshowWxUserRaiLabelRedisAddReduce(log models.WxUserRaiLabelRedis) (err e
|
|
|
err = errors.New("GetWxUserItemByUserId" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- activityDetail, e := models.GetAddActivityDetailByActivityId(sourceId)
|
|
|
+
|
|
|
+ rsCalendar, e := roadshow.GetRsCalendarById(sourceId)
|
|
|
if e != nil {
|
|
|
- err = errors.New("GetArticleDetailTestById" + e.Error())
|
|
|
+ err = errors.New("GetRsCalendarById" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
|
|
|
var sourceType int
|
|
|
- if activityDetail.ActivityType == 1 {
|
|
|
- sourceType = 4
|
|
|
+ if rsCalendar.RoadshowType == "线下" {
|
|
|
+ sourceType = 3
|
|
|
} else {
|
|
|
- sourceType = 2
|
|
|
+ sourceType = 5
|
|
|
}
|
|
|
|
|
|
- //正常的有产业报告
|
|
|
- var labelArr []string
|
|
|
- //建立首页资源表,与产业的关系
|
|
|
- industrialList, e := models.GetIndustrialActivityGroupManagementListByArticleId(sourceId)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
|
|
|
+ totalGroup, e := roadshow.GetRsCalendarMeetingLabelGroupByRsCalendarId(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetRsCalendarMeetingLabelGroupByRsCalendarId" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ //var lebelDetail []*cygx.RaiServeTagResp
|
|
|
+ var label string
|
|
|
+ var labelArr []string
|
|
|
var items []*models.WxUserRaiLabel
|
|
|
- for _, v := range industrialList {
|
|
|
- item := new(models.WxUserRaiLabel)
|
|
|
- item.UserId = wxUser.UserId
|
|
|
- item.RealName = wxUser.RealName
|
|
|
- item.Mobile = wxUser.Mobile
|
|
|
- item.Email = wxUser.Email
|
|
|
- item.CompanyId = wxUser.CompanyId
|
|
|
- item.CompanyName = wxUser.CompanyName
|
|
|
- item.Label = v.IndustryName
|
|
|
- item.SourceType = sourceType
|
|
|
- item.SourceId = sourceId
|
|
|
- item.CreateTime = log.CreateTime
|
|
|
- item.ModifyTime = time.Now()
|
|
|
- item.RegisterPlatform = log.RegisterPlatform
|
|
|
- item.TableName = ""
|
|
|
- items = append(items, item)
|
|
|
- labelArr = append(labelArr, v.IndustryName)
|
|
|
+ if totalGroup > 0 {
|
|
|
+ listGroup, e := roadshow.GetRsCalendarMeetingLabelGroupListByRsCalendarId(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetRsCalendarMeetingLabelGroupByRsCalendarId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var industrialManagementIds []int
|
|
|
+ var industrialSubjectIds []int
|
|
|
+
|
|
|
+ mapindustrialManagementName := make(map[int]string)
|
|
|
+ mapindustrialSubjectName := make(map[int]string)
|
|
|
+ mapCelueName := make(map[int]string)
|
|
|
+ for _, v := range listGroup {
|
|
|
+ switch v.TagType {
|
|
|
+ case 1:
|
|
|
+ industrialManagementIds = append(industrialManagementIds, v.TagId)
|
|
|
+ case 2:
|
|
|
+ industrialSubjectIds = append(industrialSubjectIds, v.TagId)
|
|
|
+ case 3:
|
|
|
+ mapCelueName[v.TagId] = "策略"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(industrialManagementIds) > 0 {
|
|
|
+ IndustryList, e := models.GetIndustryListByConditionByIds(industrialManagementIds)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetRsCalendarMeetingLabelGroupByRsCalendarId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range IndustryList {
|
|
|
+ mapindustrialManagementName[v.IndustrialManagementId] = v.IndustryName
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(industrialSubjectIds) > 0 {
|
|
|
+ SubjectList, e := models.GetIndustrialSubjectDetailByIds(industrialSubjectIds)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetIndustrialSubjectDetailByIds" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range SubjectList {
|
|
|
+ mapindustrialSubjectName[v.IndustrialSubjectId] = v.SubjectName
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listGroup {
|
|
|
+ switch v.TagType {
|
|
|
+ case 1:
|
|
|
+ label = mapindustrialManagementName[v.TagId]
|
|
|
+ case 2:
|
|
|
+ label = mapindustrialSubjectName[v.TagId]
|
|
|
+ case 3:
|
|
|
+ label = mapCelueName[v.TagId]
|
|
|
+ }
|
|
|
+ item := new(models.WxUserRaiLabel)
|
|
|
+ item.UserId = wxUser.UserId
|
|
|
+ item.RealName = wxUser.RealName
|
|
|
+ item.Mobile = wxUser.Mobile
|
|
|
+ item.Email = wxUser.Email
|
|
|
+ item.CompanyId = wxUser.CompanyId
|
|
|
+ item.CompanyName = wxUser.CompanyName
|
|
|
+ item.Label = label
|
|
|
+ item.SourceType = sourceType
|
|
|
+ item.SourceId = sourceId
|
|
|
+ item.CreateTime = log.CreateTime
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ item.RegisterPlatform = log.RegisterPlatform
|
|
|
+ item.TableName = ""
|
|
|
+ items = append(items, item)
|
|
|
+ labelArr = append(labelArr, label)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
e = models.AddWxUserRaiLabelMulti(items, labelArr, userId)
|
|
@@ -352,7 +407,6 @@ func RoadshowWxUserRaiLabelRedisAddReduce(log models.WxUserRaiLabelRedis) (err e
|
|
|
err = errors.New("AddWxUserRaiLabelMulti" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -540,6 +594,234 @@ func ReportSelectionWxUserRaiLabelRedisAddReduce(log models.WxUserRaiLabelRedis)
|
|
|
err = errors.New("AddWxUserRaiLabel" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// initCrm16_5Activity()
|
|
|
+//}
|
|
|
+
|
|
|
+func initCrm16_5keyWord() {
|
|
|
+
|
|
|
+ listKeyWords, err := models.GetSearchKeyWordinitCrm16_5()
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var mobiles []string
|
|
|
+ mapMobile := make(map[string]bool)
|
|
|
+ for _, v := range listKeyWords {
|
|
|
+ if mapMobile[v.Mobile] || v.Mobile == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapMobile[v.Mobile] = true
|
|
|
+ mobiles = append(mobiles, v.Mobile)
|
|
|
+ }
|
|
|
+
|
|
|
+ listUser, err := models.GetWxUserListByMobileArr(mobiles)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ mapUser := make(map[string]*models.WxUserItem)
|
|
|
+
|
|
|
+ for _, v := range listUser {
|
|
|
+ mapUser[v.Mobile] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ var items []*models.WxUserRaiLabelLog
|
|
|
+ for _, v := range listKeyWords {
|
|
|
+ if mapUser[v.Mobile] == nil || v.Mobile == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ wxUser := mapUser[v.Mobile]
|
|
|
+ item := new(models.WxUserRaiLabelLog)
|
|
|
+ item.UserId = wxUser.UserId
|
|
|
+ item.RealName = wxUser.RealName
|
|
|
+ item.Mobile = wxUser.Mobile
|
|
|
+ item.Email = wxUser.Email
|
|
|
+ item.CompanyId = wxUser.CompanyId
|
|
|
+ item.CompanyName = wxUser.CompanyName
|
|
|
+ item.Label = v.KeyWord
|
|
|
+ item.SourceType = 1
|
|
|
+ item.CreateTime = v.CreateTime
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ item.RegisterPlatform = v.RegisterPlatform
|
|
|
+ items = append(items, item)
|
|
|
+ }
|
|
|
+ fmt.Println(len(items))
|
|
|
+
|
|
|
+ var itemsAdd []*models.WxUserRaiLabelLog
|
|
|
+ if len(items) > 0 {
|
|
|
+ for _, v := range items {
|
|
|
+ itemsAdd = append(itemsAdd, v)
|
|
|
+ if len(items)%2000 == 0 {
|
|
|
+ err = models.AddWxUserRaiLabelLogMultiInit(items)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ itemsAdd = make([]*models.WxUserRaiLabelLog, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(itemsAdd) > 0 {
|
|
|
+ err = models.AddWxUserRaiLabelLogMultiInit(itemsAdd)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fmt.Println("endAddWxUserRaiLabelLogMultiInit")
|
|
|
+}
|
|
|
+
|
|
|
+func initCrm16_5Activity() {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND create_time > '2024-09-01' AND (is_meeting =1 OR duration != '') `
|
|
|
+ pars = append(pars)
|
|
|
+ //获取提交到会的人员信息
|
|
|
+ signUpDetailList, err := models.GetSignupDetailList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var mobiles []string
|
|
|
+
|
|
|
+ mapMobile := make(map[string]bool)
|
|
|
+
|
|
|
+ for _, v := range signUpDetailList {
|
|
|
+ if mapMobile[v.Mobile] || v.Mobile == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapMobile[v.Mobile] = true
|
|
|
+ mobiles = append(mobiles, v.Mobile)
|
|
|
+ }
|
|
|
+
|
|
|
+ var activityIds []int
|
|
|
+ mapactivityId := make(map[int]bool)
|
|
|
+ for _, v := range signUpDetailList {
|
|
|
+ if mapactivityId[v.ActivityId] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mapactivityId[v.ActivityId] = true
|
|
|
+ activityIds = append(activityIds, v.ActivityId)
|
|
|
+ }
|
|
|
+
|
|
|
+ listUser, err := models.GetWxUserListByMobileArr(mobiles)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapUser := make(map[string]*models.WxUserItem)
|
|
|
+ for _, v := range listUser {
|
|
|
+ mapUser[v.Mobile] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ activityDetailList, e := models.GetAddActivityDetailByActivityIdinitCrm16_5(activityIds)
|
|
|
+ if e != nil {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sourceTypemap := make(map[int]int)
|
|
|
+
|
|
|
+ for _, v := range activityDetailList {
|
|
|
+ if v.ActivityType == 1 {
|
|
|
+ sourceTypemap[v.ActivityId] = 4
|
|
|
+ } else {
|
|
|
+ sourceTypemap[v.ActivityId] = 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //正常的有产业报告
|
|
|
+
|
|
|
+ //建立首页资源表,与产业的关系
|
|
|
+ industrialList, e := models.GetIndustrialActivityGroupManagementListByArticleIds(activityIds)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //建立首页资源表,与标的 的关系
|
|
|
+ subjectList, e := models.GetSubjectActivityGroupManagementListByActivityIds(activityIds)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ fmt.Println(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var items []*models.WxUserRaiLabelLog
|
|
|
+ for _, v := range signUpDetailList {
|
|
|
+ if mapUser[v.Mobile] == nil || v.Mobile == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ wxUser := mapUser[v.Mobile]
|
|
|
+ for _, vI := range industrialList {
|
|
|
+ if vI.ActivityId != v.ActivityId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ item := new(models.WxUserRaiLabelLog)
|
|
|
+ item.UserId = wxUser.UserId
|
|
|
+ item.RealName = wxUser.RealName
|
|
|
+ item.Mobile = wxUser.Mobile
|
|
|
+ item.Email = wxUser.Email
|
|
|
+ item.CompanyId = wxUser.CompanyId
|
|
|
+ item.CompanyName = wxUser.CompanyName
|
|
|
+ item.Label = vI.IndustryName
|
|
|
+ item.SourceType = sourceTypemap[v.ActivityId]
|
|
|
+ item.SourceId = v.ActivityId
|
|
|
+ item.CreateTime = v.CreateTime
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ item.TableName = ""
|
|
|
+ //item.RegisterPlatform = v.RegisterPlatform
|
|
|
+ items = append(items, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, vs := range subjectList {
|
|
|
+ if vs.ActivityId != v.ActivityId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ item := new(models.WxUserRaiLabelLog)
|
|
|
+ item.UserId = wxUser.UserId
|
|
|
+ item.RealName = wxUser.RealName
|
|
|
+ item.Mobile = wxUser.Mobile
|
|
|
+ item.Email = wxUser.Email
|
|
|
+ item.CompanyId = wxUser.CompanyId
|
|
|
+ item.CompanyName = wxUser.CompanyName
|
|
|
+ item.Label = vs.SubjectName
|
|
|
+ item.SourceType = sourceTypemap[v.ActivityId]
|
|
|
+ item.SourceId = v.ActivityId
|
|
|
+ item.CreateTime = v.CreateTime
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ //item.RegisterPlatform = v.RegisterPlatform
|
|
|
+ items = append(items, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ fmt.Println(len(items))
|
|
|
+
|
|
|
+ var itemsAdd []*models.WxUserRaiLabelLog
|
|
|
+ if len(items) > 0 {
|
|
|
+ for _, v := range items {
|
|
|
+ itemsAdd = append(itemsAdd, v)
|
|
|
+ if len(items)%2000 == 0 {
|
|
|
+ err = models.AddWxUserRaiLabelLogMultiInit(items)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ itemsAdd = make([]*models.WxUserRaiLabelLog, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(itemsAdd) > 0 {
|
|
|
+ err = models.AddWxUserRaiLabelLogMultiInit(itemsAdd)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fmt.Println("endAddWxUserRaiLabelLogMultiInit")
|
|
|
+}
|