industrial_management.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package cygx
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models/cygx"
  6. "hongze/hz_crm_api/services/alarm_msg"
  7. "hongze/hz_crm_api/utils"
  8. )
  9. //func init() {
  10. // GetIndustrialManagementArticleNewPublishData(607)
  11. //}
  12. // 批量修改获取产业关联文章的最新发布时间
  13. func GetIndustrialManagementArticleNewPublishData(industrialManagementId int) (err error) {
  14. defer func() {
  15. if err != nil {
  16. fmt.Println(err)
  17. go alarm_msg.SendAlarmMsg("批量修改获取产业关联文章的最新发布时间GetIndustrialManagementArticleNewPublishData ErrMsg:"+err.Error(), 2)
  18. }
  19. }()
  20. articleNewPublishDataList, e := cygx.GetIndustrialManagementArticleNewPublishData()
  21. if e != nil {
  22. err = errors.New("获取客户剩余报名次数失败 GetIndustrialManagementArticleNewPublishData, Err: " + e.Error())
  23. return
  24. }
  25. mapUPdateTime := make(map[int]string)
  26. var industrialManagementIds []int
  27. for _, v := range articleNewPublishDataList {
  28. if v.IndustrialManagementId != industrialManagementId {
  29. continue
  30. }
  31. if v.IndustrialManagementId > 0 {
  32. industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
  33. }
  34. mapUPdateTime[v.IndustrialManagementId] = v.UpdateTime
  35. }
  36. if len(industrialManagementIds) == 0 {
  37. return
  38. }
  39. //时间线的更新时间
  40. listtimelinePublishdate, err := cygx.GetTimeLineReportIndustrialPublishdateList(industrialManagementIds)
  41. if err != nil && err.Error() != utils.ErrNoRow() {
  42. return
  43. }
  44. for _, v := range listtimelinePublishdate {
  45. if v.IndustrialManagementId == industrialManagementId {
  46. if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  47. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  48. }
  49. }
  50. }
  51. err = cygx.UpdateIndustrialManagementArticleNewPublishData(mapUPdateTime)
  52. return
  53. }
  54. // AddUserIndustryFllowByNewId 出现了新的产业,给选择推送方式的用户自动添加关注
  55. //func AddUserIndustryFllowByNewId(industrialManagementId int) (err error) {
  56. // defer func() {
  57. // if err != nil {
  58. // fmt.Println(err)
  59. // go alarm_msg.SendAlarmMsg("出现了新的产业,给选择推送方式的用户自动添加关注。失败 ErrMsg:"+err.Error()+"industrialManagementId"+strconv.Itoa(industrialManagementId), 2)
  60. // }
  61. // }()
  62. // //获取小助手提交过勾选项的用户
  63. // //var condition string
  64. // //condition = " AND is_refuse = 0 "
  65. // //chooseSendtList, e := cygx.GetCygxXzsChooseSend(condition)
  66. // //if e != nil {
  67. // // err = errors.New("GetCygxXzsChooseSend , Err: " + e.Error())
  68. // // return
  69. // //}
  70. // //var mobiles []string
  71. // //for _, v := range chooseSendtList {
  72. // // if v.Mobile != "" {
  73. // // mobiles = append(mobiles, v.Mobile)
  74. // // }
  75. // //}
  76. //
  77. // //userList, e := models.GetWxUserListByUserMobileHaveCompany(mobiles)
  78. // userList, e := cygx.GetCygxCompanyUserListByNoLoss() //需求池859 2023-08-29 目前数量大概在 16000条
  79. // if e != nil {
  80. // err = errors.New("GetWxUserListByUserMobileHaveCompany" + e.Error())
  81. // return
  82. // }
  83. // var numk int
  84. // var industryFllowItems []*cygx.CygxIndustryFllow
  85. // for _, vUser := range userList {
  86. // numk++
  87. // item := new(cygx.CygxIndustryFllow)
  88. // item.IndustrialManagementId = industrialManagementId
  89. // item.UserId = vUser.UserId
  90. // item.Email = vUser.Email
  91. // item.Mobile = vUser.Mobile
  92. // item.RealName = vUser.RealName
  93. // item.CompanyId = vUser.CompanyId
  94. // item.CompanyName = vUser.CompanyName
  95. // item.Source = 3 // 通过程序或者管理员手动添加的关注
  96. // item.Type = 1
  97. // item.CreateTime = time.Now()
  98. // item.ModifyTime = time.Now()
  99. // industryFllowItems = append(industryFllowItems, item)
  100. // //一次插入五千条
  101. // if numk%5000 == 0 {
  102. // e = cygx.AddCygxIndustryFllowMulti(industryFllowItems)
  103. // if e != nil {
  104. // err = errors.New("AddCygxIndustryFllowMulti , Err: " + e.Error())
  105. // return
  106. // }
  107. // industryFllowItems = make([]*cygx.CygxIndustryFllow, 0)
  108. // numk = 0
  109. // }
  110. // }
  111. // if len(industryFllowItems) > 0 {
  112. // e = cygx.AddCygxIndustryFllowMulti(industryFllowItems)
  113. // if e != nil {
  114. // err = errors.New("AddCygxIndustryFllowMulti , Err: " + e.Error())
  115. // return
  116. // }
  117. // }
  118. //
  119. // ////更新用户关注产业的标签
  120. // //for _, v := range industryFllowItems {
  121. // // IndustryFllowUserLabelLogAdd(v.IndustrialManagementId, 0, v.UserId)
  122. // //}
  123. // return
  124. //}
  125. // 处理产业管理时间线相关内容的数据
  126. func UpdateIndustrialManagementTimeLineDateList3ByRedis(industrialManagementId int) (err error) {
  127. defer func() {
  128. if err != nil {
  129. fmt.Println(err)
  130. msg := fmt.Sprint("industrialManagementId:", industrialManagementId)
  131. go alarm_msg.SendAlarmMsg("处理产业管理时间线相关内容的数据,写入Redis队列消息失败: UpdateIndustrialManagementTimeLineDateList3ByRedis"+err.Error()+msg, 2)
  132. }
  133. }()
  134. //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
  135. log := &cygx.IndustrialManagementDelte{IndustrialManagementId: industrialManagementId}
  136. if utils.Re == nil {
  137. err := utils.Rc.LPush(utils.CYGX_ARTICLE_TIME_LINE_KEY, log)
  138. if err != nil {
  139. fmt.Println("UpdateIndustrialManagementTimeLineDateList3ByRedis LPush Err:" + err.Error())
  140. }
  141. }
  142. return
  143. }