morning_meeting.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/utils"
  7. "strconv"
  8. "strings"
  9. "time"
  10. )
  11. // 添加晨会点评点击记录
  12. func AddCygxMorningMeetingReviewChapterHistory(user *models.WxUserItem, articleId int, sourcePage string) (err error) {
  13. defer func() {
  14. if err != nil {
  15. go utils.SendAlarmMsg(fmt.Sprint("添加晨会点评点击记录失败 ,AddCygxMorningMeetingReviewChapterHistory err"+err.Error(), "id:", articleId, "sourcePage:", sourcePage, "userid:", user.UserId), 2)
  16. }
  17. }()
  18. detail, e := models.GetCygxMorningMeetingReviewChapterDetail(articleId)
  19. if e != nil {
  20. err = errors.New("GetCygxMorningMeetingReviewChapterDetail, Err: " + e.Error())
  21. return
  22. }
  23. historyRecord := new(models.CygxMorningMeetingReviewChapterHistory)
  24. historyRecord.UserId = user.UserId
  25. historyRecord.ArticleId = articleId
  26. historyRecord.SourcePage = sourcePage
  27. historyRecord.CreateTime = time.Now()
  28. historyRecord.Mobile = user.Mobile
  29. historyRecord.Email = user.Email
  30. historyRecord.CompanyId = user.CompanyId
  31. historyRecord.CompanyName = user.CompanyName
  32. historyRecord.MeetingId = int(detail.MeetingId)
  33. historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
  34. sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  35. if e != nil && e.Error() != utils.ErrNoRow() {
  36. err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
  37. return
  38. }
  39. historyRecord.RealName = user.RealName
  40. if sellerItem != nil {
  41. historyRecord.SellerName = sellerItem.RealName
  42. }
  43. _, e = models.AddCygxMorningMeetingReviewChapterHistory(historyRecord)
  44. if e != nil {
  45. err = errors.New("AddCygxMorningMeetingReviewChapterHistorymodels, Err: " + e.Error())
  46. return
  47. }
  48. return
  49. }
  50. // 通过晨会精华子ID,获取出参列表详情
  51. func GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds []int) (items []*models.CygxMorningMeetingGatherDetailListResp, err error) {
  52. lenArr := len(meetingreviewchaptIds)
  53. if lenArr == 0 {
  54. return
  55. }
  56. defer func() {
  57. if err != nil {
  58. go utils.SendAlarmMsg(fmt.Sprint("通过晨会精华子ID,获取出参列表详情失败 ,GetCygxMorningMeetingReviewChapterListByIds err"+err.Error(), "meetingreviewchaptIds:", meetingreviewchaptIds), 2)
  59. }
  60. }()
  61. var condition string
  62. var pars []interface{}
  63. pars = make([]interface{}, 0)
  64. condition = ` AND c.id IN (` + utils.GetOrmInReplace(lenArr) + `)`
  65. pars = append(pars, meetingreviewchaptIds)
  66. //查询晨会
  67. listrMeet, e := models.GetCygxMorningMeetingReviewChapterList(condition, pars)
  68. if e != nil {
  69. err = errors.New("GetCygxMorningMeetingReviewChapterList, Err: " + e.Error())
  70. return
  71. }
  72. //获取晨会相关的标的
  73. var subjectIds []string
  74. for _, v := range listrMeet {
  75. if v.IndustrialSubjectIds != "" {
  76. slice := strings.Split(v.IndustrialSubjectIds, ",")
  77. for _, vS := range slice {
  78. subjectIds = append(subjectIds, vS)
  79. }
  80. }
  81. }
  82. lensubjectIds := len(subjectIds)
  83. if lensubjectIds > 0 {
  84. //获取标的信息
  85. pars = make([]interface{}, 0)
  86. condition = ` AND industrial_subject_id IN (` + utils.GetOrmInReplace(lensubjectIds) + `)`
  87. pars = append(pars, subjectIds)
  88. listsubject, e := models.GetCygxIndustrialSubjectListCondition(condition, pars)
  89. if e != nil {
  90. err = errors.New("GetCygxIndustrialSubjectListCondition, Err: " + e.Error())
  91. return
  92. }
  93. var meetSubjectItems = make(map[string]*models.CygxIndustrialSubject)
  94. for _, v := range listsubject {
  95. meetSubjectItems[strconv.Itoa(v.IndustrialSubjectId)] = v
  96. }
  97. //建立标的与晨会的映射关系
  98. for _, v := range listrMeet {
  99. if v.IndustrialSubjectIds != "" {
  100. slice := strings.Split(v.IndustrialSubjectIds, ",")
  101. for _, vS := range slice {
  102. if meetSubjectItems[vS] != nil {
  103. v.ListSubject = append(v.ListSubject, meetSubjectItems[vS])
  104. }
  105. }
  106. }
  107. }
  108. }
  109. items = listrMeet
  110. return
  111. }