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())
- }
- }
- }
- }
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- 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
- }
-
-
- 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("修改机构互动量信息")
-
- 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)
- }
- }
- }
- }
- }
-
-
- 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))
-
-
- {
- 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
- }
-
-
- 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
- }
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
- }
- }
- 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 UpdateWxUserLabel(cont context.Context) (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' `
- condition = fmt.Sprintf(condition, time.Now().Format(utils.FormatDate))
-
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
- {
- 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
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- 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]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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)
- }
- }
-
-
-
-
-
- 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
- }
- }
-
- fmt.Println("add", len(comapnyInteractionNumItemAdd))
- fmt.Println("edit", len(comapnyInteractionNumItemUpdate))
- fmt.Println("Update", len(itemsCompanyInteractionNums))
-
- return
- }
|