1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498 |
- package services
- import (
- "context"
- "errors"
- "fmt"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- "strconv"
- "strings"
- "time"
- )
- func UpdateWxUserLabelOLd(cont context.Context) (err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("更新用户标签失败;Err:"+err.Error(), 2)
- }
- }()
- //获取需要处理的权益客户
- listUser, err := models.GetUserRegisterList()
- if err != nil {
- fmt.Println("GetUserRegisterList Err", err)
- return err
- }
- mapChartCollect := make(map[string]int)
- //获取已经处理记录的用户并记录切片
- listChartCollectL, err := models.GetCygxChartCollectList()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetCygxUserInteractionNumList Err", err)
- return err
- }
- for _, v := range listChartCollectL {
- mapChartCollect[fmt.Sprint("m:", v.Mobile, "u:", v.ChartId)] = v.UserId
- }
- var interactionNum int // 互动量
- mapComapnyInteractionNum := make(map[int]int)
- //拉取策略平台用户同步的图表信息
- {
- var chartMobile string
- var chartItems []*models.CygxChartCollect
- if utils.RunMode == "release" {
- for k, vUser := range listUser {
- if vUser.Mobile != "" {
- mobile := vUser.Mobile
- fmt.Println(vUser.Mobile, "_", k)
- chartMobile += mobile + ","
- listChart, _, _ := GetChartCollectionByApi(mobile, 9999, 0)
- if len(listChart) > 0 {
- for _, vChart := range listChart {
- if mapChartCollect[fmt.Sprint("m:", mobile, "u:", vChart.ChartId)] == 0 {
- item := new(models.CygxChartCollect)
- item.ChartId = vChart.ChartId
- t1, _ := time.Parse("2006-01-02T15:04:05Z", vChart.CreateDate)
- item.CreateTime = t1
- item.Mobile = mobile
- chartItems = append(chartItems, item)
- }
- }
- }
- }
- }
- }
- //如果有数据就添加
- if len(chartItems) > 0 {
- _, err = models.AddCygxChartCollectList(chartItems)
- if err != nil {
- fmt.Println(" RemoveChartCollectByMobile Err", err)
- }
- }
- //处理图表关注后的用户
- {
- if utils.RunMode == "release" {
- listChartCollect, err := models.GetCygxChartCollectByMobileList()
- if err != nil {
- fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
- }
- for k, v := range listChartCollect {
- if v.Mobile != "" {
- user, err := models.GetWxUserItemByMobile(v.Mobile)
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- }
- if user != nil {
- fmt.Println(user.RealName, k)
- err = models.UpdateCygxChartCollect(user)
- if err != nil {
- fmt.Println("UpdateCygxChartCollect ,Err" + err.Error())
- }
- }
- }
- }
- }
- }
- }
- //处理 前一天移动之后的用户的公司记录信息
- //{
- // startDate := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
- // endDate := time.Now().Format(utils.FormatDate)
- // listUpdateUser, err := models.GetWxUserOpLogList(startDate, endDate)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // return err
- // }
- // var userIds string
- // var mobiles string
- // if len(listUpdateUser) > 0 {
- // for _, v := range listUpdateUser {
- // userIds += strconv.Itoa(v.UserId) + ","
- // mobiles += "'" + v.Mobile + "',"
- // }
- // }
- // userIds = strings.TrimRight(userIds, ",")
- // mobiles = strings.TrimRight(mobiles, ",")
- //
- // //如果用户ID不为空那么就处理这些用户的记录信息
- // if userIds != "" {
- // var condition string
- // //condition = ` AND user_id IN (` + userIds + `)`
- // condition = ` AND mobile IN (` + mobiles + `)`
- // //处理用户的文章收藏
- // listCollect, err := models.GetCygxArticleCollectList(condition)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetAddCygxArticleCollectList ,Err" + err.Error())
- // }
- // if len(listCollect) > 0 {
- // for _, v := range listCollect {
- // user, err := models.GetWxUserItemByUserId(v.UserId)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName)
- // err = models.UpdateCygxArticleCollect(user)
- // if err != nil {
- // fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
- // }
- // }
- // }
- // }
- // //处理用户的文章收藏 end
- //
- // //修改用户关注的产业
- // listIndustryFllow, err := models.GetCygxIndustryFllowList(condition)
- // if err != nil {
- // fmt.Println("GetCygxIndustryFllowList ,Err" + err.Error())
- // }
- // for k, v := range listIndustryFllow {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByUserId(v.UserId)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName, k)
- // err = models.UpdateCygxIndustryFllow(user)
- // if err != nil {
- // fmt.Println("UpdateCygxIndustryFllow ,Err" + err.Error())
- // }
- // }
- // }
- // }
- //
- // //修改用户产业关注的产业end
- //
- // //修改用户的阅读记录
- // listArticlePv, err := models.GetArticleHistoryRecordAllByMobileList(condition)
- // if err != nil {
- // fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
- // }
- // for k, v := range listArticlePv {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByMobile(v.Mobile)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName, k)
- // err = models.UpdateCygxArticleHistoryRecordAll(user)
- // if err != nil {
- // fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
- // }
- // }
- // }
- // }
- // //修改用户的阅读记录end
- //
- // //处理用户的搜索记录
- // listSearch, err := models.GetCygxSearchKeyWordList(condition)
- // if err != nil {
- // fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
- // }
- //
- // for k, v := range listSearch {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByUserId(v.UserId)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName, k)
- // err = models.UpdateCygxSearchKeyWord(user)
- // if err != nil {
- // fmt.Println("UpdateCygxSearchKeyWord ,Err" + err.Error())
- // }
- // }
- // }
- // }
- //
- // // 处理用户的作者关注
- // lisDepartmentF, err := models.GetArticleDepartmentFollowByMobileList(condition)
- // if err != nil {
- // fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
- // return err
- // }
- // for k, v := range lisDepartmentF {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByUserId(v.UserId)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName, k)
- // err = models.UpdateCygxArticleDepartmentFollow(user)
- // if err != nil {
- // fmt.Println("UpdateCygxArticleDepartmentFollow ,Err" + err.Error())
- // }
- // }
- // }
- // }
- // // 处理用户的作者关注end
- //
- // // 处理用户的活动视频播放
- // listActivityVideo, err := models.GetActivityVideoHistoryByMobileList(condition)
- // if err != nil {
- // fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
- // return err
- // }
- // for k, v := range listActivityVideo {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByUserId(v.UserId)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName, k)
- // err = models.UpdateCygxActivityVideoHistory(user)
- // if err != nil {
- // fmt.Println("UpdateCygxActivityVideoHistory ,Err" + err.Error())
- // }
- // }
- // }
- // }
- // // 处理用户的活动视频播放end
- //
- // // 处理用户的活动音频播放
- // listActivityVoice, err := models.GetActivityVoiceHistoryByMobileList(condition)
- // if err != nil {
- // fmt.Println("GetActivityVoiceHistoryByMobileList ,Err" + err.Error())
- // return err
- // }
- // for k, v := range listActivityVoice {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByUserId(v.UserId)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName, k)
- // err = models.UpdateCygxActivityVoiceHistory(user)
- // if err != nil {
- // fmt.Println("UpdateCygxActivityVoiceHistory ,Err" + err.Error())
- // }
- // }
- // }
- // }
- // // 处理用户的活动音频播放end
- //
- // // 处理用户产业视频的播放记录
- // listMicroRoadshow, err := models.GetMicroRoadshowVideoHistoryByMobileList(condition)
- // if err != nil {
- // fmt.Println("GetMicroRoadshowVideoHistoryByMobileList ,Err" + err.Error())
- // return err
- // }
- // for k, v := range listMicroRoadshow {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByUserId(v.UserId)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // fmt.Println(user.RealName, k)
- // err = models.UpdateCygxMicroRoadshowVideoHistory(user)
- // if err != nil {
- // fmt.Println("UpdateCygxMicroRoadshowVideoHistory ,Err" + err.Error())
- // }
- // }
- // }
- // }
- // // 处理用户产业视频的播放记录 end
- //
- // //如果手机号不为空,则更新用户的报名信息
- // if mobiles != "" {
- // condition = ` AND mobile IN (` + mobiles + `)`
- // listSingUp, err := models.GetCygxActivitySignupByMobileList(condition)
- // if err != nil {
- // fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
- // }
- // //fmt.Println("更新用户的报名信息长度", len(listSingUp))
- // for _, v := range listSingUp {
- // if v.Mobile != "" {
- // user, err := models.GetWxUserItemByMobile(v.Mobile)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
- // }
- // if user != nil {
- // err = models.UpdateCygxActivitySignup(user)
- // if err != nil {
- // fmt.Println("UpdateCygxActivitySignup ,Err" + err.Error())
- // //return err
- // }
- // }
- // }
- // }
- // }
- //
- // }
- //}
- //处理用户标签
- //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
- // }
- // }
- //}
- //处理用户、机构互动量数据
- {
- var userIds string
- var itemsInteraction []*models.CygxUserInteractionNum
- mapUserInteraction := make(map[int]int)
- mapCompanyInteraction := make(map[int]int)
- mapCompanyInteractionItem := make(map[int]*models.CygxCompanyInteractionNum)
- mapComapnyInteractionSeller := make(map[int]int)
- mapComapnyInteractionNumSeller := make(map[int]int) // 销售可查看的互动量
- //获取已经处理记录的用户并记录切片
- listUserInteractionNum, err := models.GetCygxUserInteractionNumList()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetCygxUserInteractionNumList Err", err)
- return err
- }
- for _, v := range listUserInteractionNum {
- mapUserInteraction[v.UserId] = v.UserId
- }
- //获取跟销售建立绑定关系的用户并记录切片
- listUserSeller, err := models.GetUserSellerRelationUserList()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetUserSellerRelationUserList Err", err)
- return err
- }
- for _, v := range listUserSeller {
- mapComapnyInteractionSeller[v.UserId] = v.UserId
- }
- listCompanyInteractionNum, err := models.GetCygxCompanyInteractionNumList()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetCygxUserInteractionNumList Err", err)
- return err
- }
- for _, v := range listCompanyInteractionNum {
- mapCompanyInteraction[v.CompanyId] = v.CompanyId
- }
- //处理用户互动量数据
- for kUser, vUser := range listUser {
- userIds += strconv.Itoa(vUser.UserId) + ","
- //一次查询一百个避免用户过多
- if kUser%100 == 0 {
- userIds = strings.TrimRight(userIds, ",")
- userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
- if err != nil {
- fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
- return err
- }
- //处理用户的互动量
- if len(userUserInteractionList) > 0 {
- for _, vsplit := range userUserInteractionList {
- interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum + vsplit.TripNum + vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum + vsplit.TagNum
- if interactionNum > 0 {
- //更改用户的互动量
- err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
- if err != nil {
- fmt.Println("UpdateUserInteractionNum Err", err)
- return err
- }
- mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
- itemInteraction := new(models.CygxUserInteractionNum)
- itemInteraction.UserId = int(vsplit.UserId)
- itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemInteraction.ArticleCountNum = vsplit.CountNum
- itemInteraction.ChartCountNum = vsplit.ChartCountNum
- itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemInteraction.KeyWordNum = vsplit.KeyWordNum
- itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemInteraction.TripNum = vsplit.TripNum
- itemInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemInteraction.TagNum = vsplit.TagNum
- itemInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- itemInteraction.CreateTime = time.Now()
- itemInteraction.ModifyTime = time.Now()
- //如果这个切片下的结构体没有值就给他初始值,如果有就跟后面的相加
- if mapCompanyInteractionItem[vsplit.CompanyId] == nil {
- itemCompanyInteraction := new(models.CygxCompanyInteractionNum)
- itemCompanyInteraction.CompanyId = vsplit.CompanyId
- itemCompanyInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemCompanyInteraction.ArticleCountNum = vsplit.CountNum
- itemCompanyInteraction.ChartCountNum = vsplit.ChartCountNum
- itemCompanyInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemCompanyInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemCompanyInteraction.KeyWordNum = vsplit.KeyWordNum
- itemCompanyInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemCompanyInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemCompanyInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemCompanyInteraction.TripNum = vsplit.TripNum
- itemCompanyInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemCompanyInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemCompanyInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemCompanyInteraction.TagNum = vsplit.TagNum
- itemCompanyInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId] = itemCompanyInteraction
- mapCompanyInteractionItem[vsplit.CompanyId].CreateTime = time.Now()
- mapCompanyInteractionItem[vsplit.CompanyId].ModifyTime = time.Now()
- } else {
- fmt.Println("公司ID", vsplit.CompanyId)
- mapCompanyInteractionItem[vsplit.CompanyId].CompanyId = vsplit.CompanyId
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleHistoryNum += vsplit.HistoryNum
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleCountNum += vsplit.CountNum
- mapCompanyInteractionItem[vsplit.CompanyId].ChartCountNum += vsplit.ChartCountNum
- mapCompanyInteractionItem[vsplit.CompanyId].IndustryFllowNum += vsplit.IndustryFllowNum
- mapCompanyInteractionItem[vsplit.CompanyId].DepartmentFollowNum += vsplit.DepartmentFollowNum
- mapCompanyInteractionItem[vsplit.CompanyId].KeyWordNum += vsplit.KeyWordNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOnLineNum += vsplit.OnLineNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOfficeNum += vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityNum += vsplit.OnLineNum + vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].TripNum += vsplit.TripNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowVideoNum += vsplit.RoadshowVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVideoNum += vsplit.ActivityVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVoiceNum += vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId].TagNum += vsplit.TagNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowNum += vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- }
- //如果存在就修改不存在就新增
- if mapUserInteraction[int(vsplit.UserId)] == 0 {
- itemsInteraction = append(itemsInteraction, itemInteraction)
- } else {
- err = models.UpdateCygxUserInteractionNum(itemInteraction)
- if err != nil {
- fmt.Println("UpdateCygxUserInteractionNum Err", err)
- return err
- }
- }
- }
- }
- }
- userIds = ""
- }
- }
- userIds = strings.TrimRight(userIds, ",")
- if userIds != "" {
- userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
- if err != nil {
- fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
- return err
- }
- //fmt.Println("处理用户剩余的")
- //处理用户的互动量
- if len(userUserInteractionList) > 0 {
- for _, vsplit := range userUserInteractionList {
- interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum + vsplit.TripNum + vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum + vsplit.TagNum
- if interactionNum > 0 {
- err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
- if err != nil {
- fmt.Println("UpdateUserInteractionNum Err", err)
- return err
- }
- mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
- if mapComapnyInteractionSeller[int(vsplit.UserId)] > 0 {
- mapComapnyInteractionNumSeller[vsplit.CompanyId] += interactionNum //如果销售可以看到这个人,那么就对销售可见的数量进行添加
- }
- itemInteraction := new(models.CygxUserInteractionNum)
- itemInteraction.UserId = int(vsplit.UserId)
- itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemInteraction.ArticleCountNum = vsplit.CountNum
- itemInteraction.ChartCountNum = vsplit.ChartCountNum
- itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemInteraction.KeyWordNum = vsplit.KeyWordNum
- itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemInteraction.TripNum = vsplit.TripNum
- itemInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemInteraction.TagNum = vsplit.TagNum
- itemInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- //如果这个切片下的结构体没有值就给他初始值,如果有就跟后面的相加
- if mapCompanyInteractionItem[vsplit.CompanyId] == nil {
- itemCompanyInteraction := new(models.CygxCompanyInteractionNum)
- itemCompanyInteraction.CompanyId = vsplit.CompanyId
- itemCompanyInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemCompanyInteraction.ArticleCountNum = vsplit.CountNum
- itemCompanyInteraction.ChartCountNum = vsplit.ChartCountNum
- itemCompanyInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemCompanyInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemCompanyInteraction.KeyWordNum = vsplit.KeyWordNum
- itemCompanyInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemCompanyInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemCompanyInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemCompanyInteraction.TripNum = vsplit.TripNum
- itemCompanyInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemCompanyInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemCompanyInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemCompanyInteraction.TagNum = vsplit.TagNum
- itemCompanyInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId] = itemCompanyInteraction
- mapCompanyInteractionItem[vsplit.CompanyId].CreateTime = time.Now()
- mapCompanyInteractionItem[vsplit.CompanyId].ModifyTime = time.Now()
- } else {
- mapCompanyInteractionItem[vsplit.CompanyId].CompanyId = vsplit.CompanyId
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleHistoryNum += vsplit.HistoryNum
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleCountNum += vsplit.CountNum
- mapCompanyInteractionItem[vsplit.CompanyId].ChartCountNum += vsplit.ChartCountNum
- mapCompanyInteractionItem[vsplit.CompanyId].IndustryFllowNum += vsplit.IndustryFllowNum
- mapCompanyInteractionItem[vsplit.CompanyId].DepartmentFollowNum += vsplit.DepartmentFollowNum
- mapCompanyInteractionItem[vsplit.CompanyId].KeyWordNum += vsplit.KeyWordNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOnLineNum += vsplit.OnLineNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOfficeNum += vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityNum += vsplit.OnLineNum + vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].TripNum += vsplit.TripNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowVideoNum += vsplit.RoadshowVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVideoNum += vsplit.ActivityVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVoiceNum += vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId].TagNum += vsplit.TagNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowNum += vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- }
- //如果存在就修改不存在就新增
- if mapUserInteraction[int(vsplit.UserId)] == 0 {
- itemsInteraction = append(itemsInteraction, itemInteraction)
- } else {
- err = models.UpdateCygxUserInteractionNum(itemInteraction)
- if err != nil {
- fmt.Println("UpdateCygxUserInteractionNum Err", err)
- return err
- }
- //fmt.Println(itemInteraction.UserId)
- //err = models.UpdateCygxUserInteractionNum(itemInteraction)
- }
- }
- }
- }
- }
- fmt.Println("修改机构互动量信息")
- ////修改机构互动量信息
- if len(mapComapnyInteractionNum) > 0 {
- for k, v := range mapComapnyInteractionNum {
- companyId := k
- err = models.UpdateComapanyInteractionNum(v, mapComapnyInteractionNumSeller[companyId], companyId)
- if err != nil {
- fmt.Println(" AddCygxUserInteractionNumList Err", err)
- }
- }
- }
- // 批量添加用户互动量信息
- if len(itemsInteraction) > 0 {
- _, err = models.AddCygxUserInteractionNumList(itemsInteraction)
- if err != nil {
- fmt.Println(" AddCygxUserInteractionNumList Err", err)
- }
- }
- // 批量添加用户互动量信息
- if len(mapCompanyInteractionItem) > 0 {
- fmt.Println("添加机构互动信息")
- for _, v := range mapCompanyInteractionItem {
- fmt.Println(v.CompanyId)
- if mapCompanyInteraction[v.CompanyId] > 0 {
- err = models.UpdateCygxCompanyInteractionNum(v)
- if err != nil {
- fmt.Println(" UpdateCygxCompanyInteractionNum Err", err)
- }
- } else {
- _, err = models.AddCygxCompanyInteractionNum(v)
- if err != nil {
- fmt.Println(" AddCygxCompanyInteractionNum Err", err)
- }
- }
- }
- }
- }
- //更新用户标签以及权重
- //go UpdateUserLabelWeight()
- return
- }
- func init123123() {
- var err error
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("更新用户标签失败;Err:"+err.Error(), 2)
- }
- }()
- var interactionNum int
- mapComapnyInteractionNum := make(map[int]int)
- listUser, err := models.GetUserRegisterListinit()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetUserSellerRelationUserList Err", err)
- return
- }
- fmt.Println(len(listUser))
- //return
- //处理用户、机构互动量数据
- {
- var userIds string
- var itemsInteraction []*models.CygxUserInteractionNum
- mapUserInteraction := make(map[int]int)
- mapCompanyInteraction := make(map[int]int)
- mapCompanyInteractionItem := make(map[int]*models.CygxCompanyInteractionNum)
- mapComapnyInteractionSeller := make(map[int]int)
- mapComapnyInteractionNumSeller := make(map[int]int) // 销售可查看的互动量
- //获取已经处理记录的用户并记录切片
- listUserInteractionNum, err := models.GetCygxUserInteractionNumList()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetCygxUserInteractionNumList Err", err)
- return
- }
- for _, v := range listUserInteractionNum {
- mapUserInteraction[v.UserId] = v.UserId
- }
- //获取跟销售建立绑定关系的用户并记录切片
- listUserSeller, err := models.GetUserSellerRelationUserList()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetUserSellerRelationUserList Err", err)
- return
- }
- for _, v := range listUserSeller {
- mapComapnyInteractionSeller[v.UserId] = v.UserId
- }
- listCompanyInteractionNum, err := models.GetCygxCompanyInteractionNumList()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetCygxUserInteractionNumList Err", err)
- return
- }
- for _, v := range listCompanyInteractionNum {
- mapCompanyInteraction[v.CompanyId] = v.CompanyId
- }
- //处理用户互动量数据
- for kUser, vUser := range listUser {
- userIds += strconv.Itoa(vUser.UserId) + ","
- //一次查询一百个避免用户过多
- if kUser%100 == 0 {
- userIds = strings.TrimRight(userIds, ",")
- userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
- if err != nil {
- fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
- return
- }
- //处理用户的互动量
- if len(userUserInteractionList) > 0 {
- for _, vsplit := range userUserInteractionList {
- interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum + vsplit.TripNum + vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum + vsplit.TagNum
- if interactionNum > 0 {
- //更改用户的互动量
- err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
- if err != nil {
- fmt.Println("UpdateUserInteractionNum Err", err)
- return
- }
- mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
- itemInteraction := new(models.CygxUserInteractionNum)
- itemInteraction.UserId = int(vsplit.UserId)
- itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemInteraction.ArticleCountNum = vsplit.CountNum
- itemInteraction.ChartCountNum = vsplit.ChartCountNum
- itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemInteraction.KeyWordNum = vsplit.KeyWordNum
- itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemInteraction.TripNum = vsplit.TripNum
- itemInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemInteraction.TagNum = vsplit.TagNum
- itemInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- itemInteraction.CreateTime = time.Now()
- itemInteraction.ModifyTime = time.Now()
- //如果这个切片下的结构体没有值就给他初始值,如果有就跟后面的相加
- if mapCompanyInteractionItem[vsplit.CompanyId] == nil {
- itemCompanyInteraction := new(models.CygxCompanyInteractionNum)
- itemCompanyInteraction.CompanyId = vsplit.CompanyId
- itemCompanyInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemCompanyInteraction.ArticleCountNum = vsplit.CountNum
- itemCompanyInteraction.ChartCountNum = vsplit.ChartCountNum
- itemCompanyInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemCompanyInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemCompanyInteraction.KeyWordNum = vsplit.KeyWordNum
- itemCompanyInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemCompanyInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemCompanyInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemCompanyInteraction.TripNum = vsplit.TripNum
- itemCompanyInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemCompanyInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemCompanyInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemCompanyInteraction.TagNum = vsplit.TagNum
- itemCompanyInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId] = itemCompanyInteraction
- mapCompanyInteractionItem[vsplit.CompanyId].CreateTime = time.Now()
- mapCompanyInteractionItem[vsplit.CompanyId].ModifyTime = time.Now()
- } else {
- fmt.Println("公司ID", vsplit.CompanyId)
- mapCompanyInteractionItem[vsplit.CompanyId].CompanyId = vsplit.CompanyId
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleHistoryNum += vsplit.HistoryNum
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleCountNum += vsplit.CountNum
- mapCompanyInteractionItem[vsplit.CompanyId].ChartCountNum += vsplit.ChartCountNum
- mapCompanyInteractionItem[vsplit.CompanyId].IndustryFllowNum += vsplit.IndustryFllowNum
- mapCompanyInteractionItem[vsplit.CompanyId].DepartmentFollowNum += vsplit.DepartmentFollowNum
- mapCompanyInteractionItem[vsplit.CompanyId].KeyWordNum += vsplit.KeyWordNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOnLineNum += vsplit.OnLineNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOfficeNum += vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityNum += vsplit.OnLineNum + vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].TripNum += vsplit.TripNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowVideoNum += vsplit.RoadshowVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVideoNum += vsplit.ActivityVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVoiceNum += vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId].TagNum += vsplit.TagNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowNum += vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- }
- //如果存在就修改不存在就新增
- if mapUserInteraction[int(vsplit.UserId)] == 0 {
- itemsInteraction = append(itemsInteraction, itemInteraction)
- } else {
- err = models.UpdateCygxUserInteractionNum(itemInteraction)
- if err != nil {
- fmt.Println("UpdateCygxUserInteractionNum Err", err)
- return
- }
- fmt.Println(itemInteraction.UserId)
- }
- }
- }
- }
- userIds = ""
- }
- }
- userIds = strings.TrimRight(userIds, ",")
- if userIds != "" {
- userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
- if err != nil {
- fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
- return
- }
- //fmt.Println("处理用户剩余的")
- //处理用户的互动量
- if len(userUserInteractionList) > 0 {
- for _, vsplit := range userUserInteractionList {
- interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum + vsplit.TripNum + vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum + vsplit.TagNum
- if interactionNum > 0 {
- err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
- if err != nil {
- fmt.Println("UpdateUserInteractionNum Err", err)
- return
- }
- mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
- if mapComapnyInteractionSeller[int(vsplit.UserId)] > 0 {
- mapComapnyInteractionNumSeller[vsplit.CompanyId] += interactionNum //如果销售可以看到这个人,那么就对销售可见的数量进行添加
- }
- itemInteraction := new(models.CygxUserInteractionNum)
- itemInteraction.UserId = int(vsplit.UserId)
- itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemInteraction.ArticleCountNum = vsplit.CountNum
- itemInteraction.ChartCountNum = vsplit.ChartCountNum
- itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemInteraction.KeyWordNum = vsplit.KeyWordNum
- itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemInteraction.TripNum = vsplit.TripNum
- itemInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemInteraction.TagNum = vsplit.TagNum
- itemInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- //如果这个切片下的结构体没有值就给他初始值,如果有就跟后面的相加
- if mapCompanyInteractionItem[vsplit.CompanyId] == nil {
- itemCompanyInteraction := new(models.CygxCompanyInteractionNum)
- itemCompanyInteraction.CompanyId = vsplit.CompanyId
- itemCompanyInteraction.ArticleHistoryNum = vsplit.HistoryNum
- itemCompanyInteraction.ArticleCountNum = vsplit.CountNum
- itemCompanyInteraction.ChartCountNum = vsplit.ChartCountNum
- itemCompanyInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
- itemCompanyInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
- itemCompanyInteraction.KeyWordNum = vsplit.KeyWordNum
- itemCompanyInteraction.ActivityOnLineNum = vsplit.OnLineNum
- itemCompanyInteraction.ActivityOfficeNum = vsplit.OfficeNum
- itemCompanyInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
- itemCompanyInteraction.TripNum = vsplit.TripNum
- itemCompanyInteraction.RoadshowVideoNum = vsplit.RoadshowVideoNum
- itemCompanyInteraction.ActivityVideoNum = vsplit.ActivityVideoNum
- itemCompanyInteraction.ActivityVoiceNum = vsplit.ActivityVoiceNum
- itemCompanyInteraction.TagNum = vsplit.TagNum
- itemCompanyInteraction.RoadshowNum = vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId] = itemCompanyInteraction
- mapCompanyInteractionItem[vsplit.CompanyId].CreateTime = time.Now()
- mapCompanyInteractionItem[vsplit.CompanyId].ModifyTime = time.Now()
- } else {
- mapCompanyInteractionItem[vsplit.CompanyId].CompanyId = vsplit.CompanyId
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleHistoryNum += vsplit.HistoryNum
- mapCompanyInteractionItem[vsplit.CompanyId].ArticleCountNum += vsplit.CountNum
- mapCompanyInteractionItem[vsplit.CompanyId].ChartCountNum += vsplit.ChartCountNum
- mapCompanyInteractionItem[vsplit.CompanyId].IndustryFllowNum += vsplit.IndustryFllowNum
- mapCompanyInteractionItem[vsplit.CompanyId].DepartmentFollowNum += vsplit.DepartmentFollowNum
- mapCompanyInteractionItem[vsplit.CompanyId].KeyWordNum += vsplit.KeyWordNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOnLineNum += vsplit.OnLineNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityOfficeNum += vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityNum += vsplit.OnLineNum + vsplit.OfficeNum
- mapCompanyInteractionItem[vsplit.CompanyId].TripNum += vsplit.TripNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowVideoNum += vsplit.RoadshowVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVideoNum += vsplit.ActivityVideoNum
- mapCompanyInteractionItem[vsplit.CompanyId].ActivityVoiceNum += vsplit.ActivityVoiceNum
- mapCompanyInteractionItem[vsplit.CompanyId].TagNum += vsplit.TagNum
- mapCompanyInteractionItem[vsplit.CompanyId].RoadshowNum += vsplit.RoadshowVideoNum + vsplit.ActivityVideoNum + vsplit.ActivityVoiceNum
- }
- ////如果存在就修改不存在就新增
- //if mapUserInteraction[int(vsplit.UserId)] == 0 {
- // itemsInteraction = append(itemsInteraction, itemInteraction)
- //} else {
- // err = models.UpdateCygxUserInteractionNum(itemInteraction)
- // if err != nil {
- // fmt.Println("UpdateCygxUserInteractionNum Err", err)
- // return
- // }
- // fmt.Println(itemInteraction.UserId)
- // err = models.UpdateCygxUserInteractionNum(itemInteraction)
- //}
- }
- }
- }
- }
- fmt.Println("修改机构互动量信息")
- ////修改机构互动量信息
- if len(mapComapnyInteractionNum) > 0 {
- for k, v := range mapComapnyInteractionNum {
- companyId := k
- err = models.UpdateComapanyInteractionNum(v, mapComapnyInteractionNumSeller[companyId], companyId)
- if err != nil {
- fmt.Println(" AddCygxUserInteractionNumList Err", err)
- }
- }
- }
- }
- }
- //func init() {
- // UpdateWxUserLabelNew()
- //}
- func UpdateWxUserLabel(cont context.Context) (err error) {
- //func UpdateWxUserLabel() (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg(fmt.Sprint("更新用户标签失败UpdateWxUserLabel, err:", err.Error()), 2)
- }
- }()
- mapComapnyInteractionNum := make(map[int]int) // 机构互动数量
- mapComapnyInteractionNumSeller := make(map[int]int) // 销售可查看的机构互动数量
- mapComapnyInteractionSeller := make(map[int]bool) // 跟销售建立绑定关系的用户
- mapComapnyInteractionNumItem := make(map[int]*models.CygxCompanyInteractionNum) // 公司互动详情结构体
- var comapnyInteractionNumItemAdd []*models.CygxCompanyInteractionNum // 公司互动详情结构体新增
- var comapnyInteractionNumItemUpdate []*models.CygxCompanyInteractionNum // 公司互动详情结构体修改
- //获取跟销售建立绑定关系的用户并记录切片
- listUserSeller, e := models.GetUserSellerRelationUserList()
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetUserSellerRelationUserList, Err: " + e.Error())
- return
- }
- for _, v := range listUserSeller {
- mapComapnyInteractionSeller[v.UserId] = true
- }
- var condition string
- //condition = ` AND h.create_time < '%s' AND h.company_id IN ( 398,17773) `
- condition = ` AND h.create_time < '%s' `
- condition = fmt.Sprintf(condition, time.Now().Format(utils.FormatDate)) // 截止昨天的所有数据
- //fmt.Println(condition)
- //报告阅读记录1
- {
- listArticleHistoryRecord, e := models.GetCygxArticleHistoryRecordInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxArticleHistoryRecordInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listArticleHistoryRecord {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].ArticleHistoryNum += v.InteractionNum
- }
- }
- //报告收藏记录2
- {
- listArticleCollect, e := models.GetCygxArticleCollectInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxArticleCollectInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listArticleCollect {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].ArticleCountNum += v.InteractionNum
- }
- }
- //图表收藏记录3
- {
- listChartCollect, e := models.GetCygxChartCollectInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxChartCollectInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listChartCollect {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].ChartCountNum += v.InteractionNum
- }
- }
- //用户关注产业数量4
- {
- listIndustryFllow, e := models.GetCygxIndustryFllowInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxIndustryFllowInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listIndustryFllow {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].IndustryFllowNum += v.InteractionNum
- }
- }
- //用户搜索关键词数量5
- {
- listSearchKeyWord, e := models.GetCygxSearchKeyWordInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxSearchKeyWordInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listSearchKeyWord {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].KeyWordNum += v.InteractionNum
- }
- }
- //用户活动报名参会数量6
- {
- listActivitySignup, e := models.GetCygxActivitySignupInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxActivitySignupInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listActivitySignup {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].ActivityNum += v.InteractionNum
- }
- }
- //用户专项调研活动报名参会数量7
- {
- listActivitySpecialSignup, e := models.GetCygxActivitySpecialSignupInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxActivitySpecialSignupInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listActivitySpecialSignup {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].TripNum += v.InteractionNum
- }
- }
- //用户路演精华播放数量8
- {
- listMicroRoadshowVideoHistory, e := models.GetCygxMicroRoadshowVideoHistoryInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxMicroRoadshowVideoHistoryInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listMicroRoadshowVideoHistory {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].RoadshowNum += v.InteractionNum
- }
- }
- //用户活动视频播放数量9
- {
- listActivityVideoHistory, e := models.GetCygxActivityVideoHistoryInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxActivityVideoHistoryInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listActivityVideoHistory {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].ActivityVideoNum += v.InteractionNum
- }
- }
- //用户活动音频播放数量10
- {
- listActivityVoiceHistory, e := models.GetCygxActivityVoiceHistoryInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxActivityVoiceHistoryInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listActivityVoiceHistory {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].ActivityVoiceNum += v.InteractionNum
- }
- }
- //用户首页标签点击量数量11
- {
- listTagHistory, e := models.GetCygxTagHistoryInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxTagHistoryInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listTagHistory {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].TagNum += v.InteractionNum
- }
- }
- //用户关注文章作者数量12
- {
- listArticleDepartmentFollow, e := models.GetCygxArticleDepartmentFollowInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxArticleDepartmentFollowInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listArticleDepartmentFollow {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].DepartmentFollowNum += v.InteractionNum
- }
- }
- //用户收藏研选专栏数量13
- //{
- // listYanxuanSpecialCollect, e := models.GetCygxYanxuanSpecialCollectInteractionNum(condition)
- // if e != nil {
- // err = errors.New("GetCygxYanxuanSpecialCollectInteractionNum, Err: " + e.Error())
- // return
- // }
- // for _, v := range listYanxuanSpecialCollect {
- // mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- // if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- // mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- // }
- //
- // if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- // mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- // }
- // mapComapnyInteractionNumItem[v.CompanyId].YanxuanSpecialCollectNum += v.InteractionNum
- // }
- //}
- //用户关注研选专栏作者数量统计14
- //{
- // listYanxuanSpecialFollow, e := models.GetCygxYanxuanSpecialFollowInteractionNum(condition)
- // if e != nil {
- // err = errors.New("GetCygxYanxuanSpecialFollowInteractionNum, Err: " + e.Error())
- // return
- // }
- // for _, v := range listYanxuanSpecialFollow {
- // mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- // if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- // mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- // }
- // if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- // mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- // }
- // mapComapnyInteractionNumItem[v.CompanyId].YanxuanSpecialFollowNum += v.InteractionNum
- // }
- //}
- //用户研选专栏阅读数量数量15
- {
- listYanxuanSpecialFollow, e := models.GetCygxYanxuanSpecialRecordInteractionNum(condition)
- if e != nil {
- err = errors.New("GetCygxYanxuanSpecialRecordInteractionNum, Err: " + e.Error())
- return
- }
- for _, v := range listYanxuanSpecialFollow {
- mapComapnyInteractionNum[v.CompanyId] += v.InteractionNum
- if mapComapnyInteractionSeller[v.UserId] { //如果用户跟销售建立绑定关系,就对互动量进行累加
- mapComapnyInteractionNumSeller[v.CompanyId] += v.InteractionNum
- }
- if mapComapnyInteractionNumItem[v.CompanyId] == nil {
- mapComapnyInteractionNumItem[v.CompanyId] = new(models.CygxCompanyInteractionNum)
- }
- mapComapnyInteractionNumItem[v.CompanyId].YanxuanSpecialNum += v.InteractionNum
- }
- }
- mapCompanyInteraction := make(map[int]bool)
- mapCompanyInteractionItem := make(map[int]*models.CygxCompanyInteractionNum)
- listCompanyInteractionNum, e := models.GetCygxCompanyInteractionNumList() // 有过互动记录的公司
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetCygxCompanyInteractionNumList, Err: " + e.Error())
- return
- }
- for _, v := range listCompanyInteractionNum {
- mapCompanyInteraction[v.CompanyId] = true
- mapCompanyInteractionItem[v.CompanyId] = v
- }
- var itemsCompanyInteractionNums []*models.CompanyInteractionNumReq // 公司总的互动量结构体
- companyInteractionNumList, e := models.GetCompanyInteractionNumList() // 获取有机构互动的公司
- mapInteractionNumOld := make(map[int]int) //历史公司总的互动量
- mapInteractionNumSellerOld := make(map[int]int) //历史公司关联销售所能查看的互动量
- for _, v := range companyInteractionNumList {
- mapInteractionNumOld[v.CompanyId] = v.InteractionNum
- mapInteractionNumSellerOld[v.CompanyId] = v.InteractionNumSeller
- }
- for k, v := range mapComapnyInteractionNumItem {
- v.CompanyId = k
- if mapCompanyInteraction[k] {
- itemOld := mapCompanyInteractionItem[v.CompanyId]
- //ArticleHistoryNum int `description:"文章浏览数量"`
- //ArticleCountNum int `description:"文章收藏数量"`
- //ChartCountNum int `description:"图表收藏"`
- //IndustryFllowNum int `description:"产业关注数量"`
- //DepartmentFollowNum int `description:"作者关注数量"`
- //KeyWordNum int `description:"关键词搜索次数"`
- //ActivityOnLineNum int `description:"线上活动报名次数"`
- //ActivityOfficeNum int `description:"线下活动报名次数"`
- //ActivityNum int `description:"活动报名次数"`
- //TripNum int `description:"专项产业调研数量"`
- //RoadshowVideoNum int `description:"产业视频播放量"`
- //ActivityVideoNum int `description:"活动视频播放量"`
- //ActivityVoiceNum int `description:"活动音频播放量"`
- //RoadshowNum int `description:"路演播放总数量"`
- //TagNum int `description:"标签点击次数"`
- //YanxuanSpecialNum int `description:"研选专栏阅读数量"`
- //YanxuanSpecialCollectNum int `description:"研选专栏收藏数量"`
- //YanxuanSpecialFollowNum int `description:"研选专栏作者关注数量"`
- //如果这些数据对比不一样,那么就对这条数据进行更新
- //if itemOld != nil && (itemOld.ArticleHistoryNum != v.ArticleHistoryNum || itemOld.ArticleCountNum != v.ArticleCountNum || itemOld.ChartCountNum != v.ChartCountNum || itemOld.IndustryFllowNum != v.IndustryFllowNum || itemOld.DepartmentFollowNum != v.DepartmentFollowNum || itemOld.KeyWordNum != v.KeyWordNum || itemOld.ActivityNum != v.ActivityNum || itemOld.TripNum != v.TripNum || itemOld.RoadshowVideoNum != v.RoadshowVideoNum || itemOld.ActivityVideoNum != v.ActivityVideoNum || itemOld.ActivityVoiceNum != v.ActivityVoiceNum || itemOld.RoadshowNum != v.RoadshowNum || itemOld.TagNum != v.TagNum || itemOld.YanxuanSpecialNum != v.YanxuanSpecialNum || itemOld.YanxuanSpecialCollectNum != v.YanxuanSpecialCollectNum || itemOld.YanxuanSpecialFollowNum != v.YanxuanSpecialFollowNum) {
- if itemOld != nil && (itemOld.ArticleHistoryNum != v.ArticleHistoryNum || itemOld.ArticleCountNum != v.ArticleCountNum || itemOld.ChartCountNum != v.ChartCountNum || itemOld.IndustryFllowNum != v.IndustryFllowNum || itemOld.DepartmentFollowNum != v.DepartmentFollowNum || itemOld.KeyWordNum != v.KeyWordNum || itemOld.ActivityNum != v.ActivityNum || itemOld.TripNum != v.TripNum || itemOld.RoadshowVideoNum != v.RoadshowVideoNum || itemOld.ActivityVideoNum != v.ActivityVideoNum || itemOld.ActivityVoiceNum != v.ActivityVoiceNum || itemOld.RoadshowNum != v.RoadshowNum || itemOld.TagNum != v.TagNum) {
- comapnyInteractionNumItemUpdate = append(comapnyInteractionNumItemUpdate, v)
- }
- } else {
- v.CreateTime = time.Now()
- v.ModifyTime = time.Now()
- comapnyInteractionNumItemAdd = append(comapnyInteractionNumItemAdd, v)
- }
- //对比历史数据如果不一样就进行修改
- if mapInteractionNumOld[v.CompanyId] != mapComapnyInteractionNum[v.CompanyId] || mapInteractionNumSellerOld[v.CompanyId] != mapComapnyInteractionNumSeller[v.CompanyId] {
- itemCompanyInteractionNums := new(models.CompanyInteractionNumReq)
- itemCompanyInteractionNums.CompanyId = k
- itemCompanyInteractionNums.InteractionNum = mapComapnyInteractionNum[v.CompanyId]
- itemCompanyInteractionNums.InteractionNumSeller = mapComapnyInteractionNumSeller[v.CompanyId]
- itemsCompanyInteractionNums = append(itemsCompanyInteractionNums, itemCompanyInteractionNums)
- }
- }
- //for _, v := range comapnyInteractionNumItemUpdate {
- // fmt.Println(v)
- //}
- //return
- //批量插入公司互动详情
- if len(comapnyInteractionNumItemAdd) > 0 {
- _, e = models.AddCygxCompanyInteractionNumList(comapnyInteractionNumItemAdd)
- if e != nil {
- err = errors.New("AddCygxCompanyInteractionNumList, Err: " + e.Error())
- return
- }
- }
- // 批量修改公司互动详情
- if len(comapnyInteractionNumItemUpdate) > 0 {
- e = models.UpdateCygxCompanyInteractionNumMulti(comapnyInteractionNumItemUpdate)
- if e != nil {
- err = errors.New("UpdateCygxCompanyInteractionNumMulti, Err: " + e.Error())
- return
- }
- }
- // 批量修改公司互动总量
- if len(itemsCompanyInteractionNums) > 0 {
- e = models.UpdateCompanyInteractionNumMulti(itemsCompanyInteractionNums)
- if e != nil {
- err = errors.New("UpdateCompanyInteractionNumMulti, Err: " + e.Error())
- return
- }
- }
- //CompanyInteractionNumReq
- fmt.Println("add", len(comapnyInteractionNumItemAdd))
- fmt.Println("edit", len(comapnyInteractionNumItemUpdate))
- fmt.Println("Update", len(itemsCompanyInteractionNums))
- //fmt.Println(mapComapnyInteractionNum)
- return
- }
|