tag.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package services
  2. import (
  3. "errors"
  4. "hongze/hongze_web_mfyx/models"
  5. "hongze/hongze_web_mfyx/utils"
  6. "strconv"
  7. "time"
  8. )
  9. func AddCygxTagHistory(user *models.WxUserItem, tagId int) (err error) {
  10. if user.UserId == 0 {
  11. return
  12. }
  13. defer func() {
  14. if err != nil {
  15. go utils.SendAlarmMsg("tag点击信息记录失败"+err.Error()+"tagId"+strconv.Itoa(tagId)+"userId:"+strconv.Itoa(user.UserId), 2)
  16. }
  17. }()
  18. historyRecord := new(models.CygxTagHistory)
  19. historyRecord.UserId = user.UserId
  20. historyRecord.TagId = tagId
  21. historyRecord.CreateTime = time.Now()
  22. historyRecord.Mobile = user.Mobile
  23. historyRecord.Email = user.Email
  24. historyRecord.CompanyId = user.CompanyId
  25. historyRecord.CompanyName = user.CompanyName
  26. historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
  27. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  28. if err != nil && err.Error() != utils.ErrNoRow() {
  29. return
  30. }
  31. historyRecord.RealName = user.RealName
  32. if sellerItem != nil {
  33. historyRecord.SellerName = sellerItem.RealName
  34. }
  35. _, err = models.AddCygxTagHistory(historyRecord)
  36. return
  37. }
  38. //func init() {
  39. // conditionInit, err := GetConditionInitByTagIds("43")
  40. // fmt.Println(err)
  41. // fmt.Println()
  42. // fmt.Println(conditionInit)
  43. //}
  44. func GetConditionInitByTagIds(user *models.WxUserItem, labelKeyword string) (yanxuanActivityIdsResp, yanxuanArticleIdsResp []int, conditionresp string, err error) {
  45. var yanxuanActivityIds []int
  46. var yanxuanArticleIds []int
  47. var condition string
  48. var pars []interface{}
  49. switch labelKeyword {
  50. case utils.LABEL_L1_1: // 全部活动
  51. yanxuanActivityIds = GetYanxuanActivityIds(user, "1,2") // 获取所有的研选活动ID
  52. case "买方交流": // 买方交流 ->买方线下交流
  53. condition = ` AND chart_permission_id = ? AND yidong_activity_id = '' AND activity_type_id = 8 AND active_state IN (1,2) `
  54. pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN)
  55. list, e := models.GetCygxActivityIdList(condition, pars)
  56. if e != nil {
  57. err = errors.New("GetCygxActivityIdList, Err: " + e.Error())
  58. return
  59. }
  60. for _, v := range list {
  61. yanxuanActivityIds = append(yanxuanActivityIds, v.ActivityId)
  62. }
  63. case "专家调研": // 专家调研->专家电话会+专家线下沙龙
  64. condition = ` AND chart_permission_id = ? AND yidong_activity_id = '' AND activity_type_id IN (1,5) AND active_state IN (1,2) `
  65. pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN)
  66. list, e := models.GetCygxActivityIdList(condition, pars)
  67. if e != nil {
  68. err = errors.New("GetCygxActivityIdList, Err: " + e.Error())
  69. return
  70. }
  71. for _, v := range list {
  72. yanxuanActivityIds = append(yanxuanActivityIds, v.ActivityId)
  73. }
  74. case "上市公司小范围": // 上市公司小范围->公司调研电话会
  75. condition = ` AND chart_permission_id = ? AND yidong_activity_id = '' AND activity_type_id = 3 AND active_state IN (1,2) `
  76. pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN)
  77. list, e := models.GetCygxActivityIdList(condition, pars)
  78. if e != nil {
  79. err = errors.New("GetCygxActivityIdList, Err: " + e.Error())
  80. return
  81. }
  82. for _, v := range list {
  83. yanxuanActivityIds = append(yanxuanActivityIds, v.ActivityId)
  84. }
  85. case "全部报告": // 全部报告
  86. yanxuanArticleIds = GetYanxuanArticleIds() //获取所有研选文章ID
  87. conditionresp = ` AND source IN ('article','yanxuanspecial') `
  88. case "专栏": //专栏
  89. conditionresp = ` AND source IN ('yanxuanspecial') `
  90. case "纪要": //纪要
  91. conditionresp = ` AND source IN ('article') `
  92. //condition = ` AND article_type_id > 0 AND article_type_id != 12 `
  93. condition = ` AND article_type_id > 0 `
  94. list, e := models.GetCygxCygxArticleIdList(condition, pars)
  95. if e != nil {
  96. err = errors.New("GetCygxCygxArticleIdList, Err: " + e.Error())
  97. return
  98. }
  99. for _, v := range list {
  100. yanxuanArticleIds = append(yanxuanArticleIds, v.ArticleId)
  101. }
  102. //case "买方沙龙": // 买方沙龙
  103. // condition = ` AND article_type_id = 12 `
  104. // list, e := models.GetCygxCygxArticleIdList(condition, pars)
  105. // if e != nil {
  106. // err = errors.New("GetCygxCygxArticleIdList, Err: " + e.Error())
  107. // return
  108. // }
  109. // for _, v := range list {
  110. // yanxuanArticleIds = append(yanxuanArticleIds, v.ArticleId)
  111. // }
  112. }
  113. yanxuanActivityIdsResp = yanxuanActivityIds
  114. yanxuanArticleIdsResp = yanxuanArticleIds
  115. return
  116. }