report_selection.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/utils"
  7. "time"
  8. )
  9. // 重点公司路演申请,给吴昂迪、对口销售
  10. func SendCygxReportSelectionLogApplyTemplateMsg(user *models.WxUserItem, content string) (err error) {
  11. var msg string
  12. msg = fmt.Sprint(user, content)
  13. defer func() {
  14. if err != nil {
  15. go utils.SendAlarmMsg("SendCygxReportSelectionLogApplyTemplateMsg Err"+msg+err.Error(), 2)
  16. }
  17. }()
  18. var mobiles []string
  19. //获取权益销售
  20. sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  21. if e != nil {
  22. err = errors.New("GetAdminByRoleName, Err: " + e.Error())
  23. return
  24. }
  25. mobiles = append(mobiles, sellerItem.Mobile)
  26. mobiles = append(mobiles, "")
  27. mobiles = append(mobiles, utils.MobileShenTao, utils.MobileZhangChuanXin, utils.MobileWuAngDi) // 添加沈涛、张传星、吴昂迪手机号
  28. openIdList, e := models.GetWxOpenIdByMobileSliceList(mobiles)
  29. if e != nil {
  30. err = errors.New("GetWxOpenIdByMobileSliceList, Err: " + e.Error())
  31. return
  32. }
  33. if len(openIdList) == 0 {
  34. return
  35. }
  36. openIdArr := make([]string, 0)
  37. for _, v := range openIdList {
  38. openIdArr = append(openIdArr, v.OpenId)
  39. }
  40. fmt.Println(openIdArr)
  41. var keyword1 string
  42. var keyword2 string
  43. var keyword3 string
  44. var keyword4 string
  45. keyword1 = fmt.Sprint(user.RealName, "--", user.CompanyName, "(", sellerItem.RealName, ")")
  46. if user.Mobile == "" {
  47. user.Mobile = user.Email
  48. }
  49. keyword2 = user.Mobile
  50. keyword3 = time.Now().Format(utils.FormatDateTime)
  51. keyword4 = fmt.Sprint(content, "(申请路演)")
  52. var redirectUrl string
  53. sendInfo := new(SendWxTemplate)
  54. sendInfo.Keyword1 = keyword1
  55. sendInfo.Keyword2 = keyword2
  56. sendInfo.Keyword3 = keyword3
  57. sendInfo.Keyword4 = keyword4
  58. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_ADD
  59. sendInfo.TemplateId = utils.WxMsgTemplateIdApplyXzs
  60. sendInfo.RedirectUrl = redirectUrl
  61. sendInfo.RedirectTarget = 3
  62. sendInfo.OpenIdArr = openIdArr
  63. err = PublicSendTemplateMsg(sendInfo)
  64. return
  65. }
  66. // 记录用户在重点公司单独点了某一个标签
  67. func GetReportSelectionLabelName(req models.AddCygxReportSelectionSubjectHistoryReq, userId int) {
  68. var err error
  69. defer func() {
  70. if err != nil {
  71. go utils.SendAlarmMsg("SendCygxReportSelectionLogApplyTemplateMsg Err"+err.Error(), 2)
  72. }
  73. }()
  74. var condition string
  75. var pars []interface{}
  76. condition = ` AND article_id = ? AND industrial_subject_id = ? AND industrial_management_id = ? AND third_id = ? `
  77. pars = append(pars, req.ArticleId, req.IndustrialSubjectId, req.IndustrialManagementId, req.ThirdId)
  78. listLog, e := models.GetCygxReportSelectionLog(condition, pars, 0, 9999)
  79. if e != nil {
  80. err = errors.New("GetCygxReportSelectionLog, Err: " + e.Error())
  81. return
  82. }
  83. var labelName string
  84. for _, v2 := range listLog {
  85. if v2.ThirdId > 0 {
  86. labelName = v2.ThirdName
  87. } else if v2.IndustrialSubjectId == 0 && v2.IndustrialManagementId != "" {
  88. labelName = v2.IndustrialManagementNames
  89. } else {
  90. labelName = v2.SubjectName
  91. }
  92. }
  93. if labelName == "" {
  94. return
  95. }
  96. ReportSelectionWxUserRaiLabelRedisAdd(req.ArticleId, userId, time.Now(), "cygx_report_selection", labelName)
  97. return
  98. }