activity_my_schedule.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package services
  2. import (
  3. "errors"
  4. "hongze/hongze_web_mfyx/models"
  5. )
  6. // 我的日程 GetScheduleAndSpecilList
  7. func GetScheduleAndSpecilList(user *models.WxUserItem, condition string, startSize, pageSize int) (items []*models.ActivityDetail, err error) {
  8. //var conditionSpecil string
  9. var pars []interface{}
  10. condition += ` AND my.user_id = ?`
  11. pars = append(pars, user.UserId)
  12. //conditionSpecil += ` AND my.user_id = ? AND my.is_cancel = 0 `
  13. //parsSpecil = append(parsSpecil, user.UserId)
  14. list, e := models.GetScheduleAndSpecilList(condition, pars, startSize, pageSize)
  15. if e != nil {
  16. err = errors.New("GetScheduleAndSpecilList, Err: " + e.Error())
  17. return
  18. }
  19. var activityIds []int
  20. var activitySpecilalIds []int
  21. for k, v := range list {
  22. if v.SourceType == 2 {
  23. activitySpecilalIds = append(activitySpecilalIds, v.ActivityId)
  24. //把专项调研的线下改为活动的线下类型
  25. if v.ActivityType == 2 {
  26. list[k].ActivityType = 0
  27. }
  28. list[k].IsShowSignup = true
  29. } else {
  30. activityIds = append(activityIds, v.ActivityId)
  31. }
  32. }
  33. //处理活动
  34. if len(activityIds) > 0 {
  35. //处理用户是否报名
  36. mapSignUp, e := GetActivitySignUpUserMap(activityIds, user)
  37. if e != nil {
  38. err = errors.New("GetActivitySignUpUserMap, Err: " + e.Error())
  39. return
  40. }
  41. for k, v := range list {
  42. if v.SourceType != 2 {
  43. if _, ok := mapSignUp[v.ActivityId]; ok {
  44. list[k].IsSignup = 1
  45. }
  46. }
  47. }
  48. //处理用户是否预约纪要
  49. mapAppointment, e := GetActivityAppointmentUserMap(activityIds, user)
  50. if e != nil {
  51. err = errors.New("GetActivityAppointmentUserMap, Err: " + e.Error())
  52. return
  53. }
  54. for k, v := range list {
  55. if v.SourceType != 2 {
  56. if _, ok := mapAppointment[v.ActivityId]; ok {
  57. list[k].IsAppointment = 1
  58. }
  59. }
  60. }
  61. //处理用户是否预约会议提醒
  62. mapReminder, e := GetActivityReminderUserMasp(activityIds, user)
  63. if e != nil {
  64. err = errors.New("GetActivityReminderUserMasp, Err: " + e.Error())
  65. return
  66. }
  67. for k, v := range list {
  68. if v.SourceType != 2 {
  69. if _, ok := mapReminder[v.ActivityId]; ok {
  70. list[k].IsCancelMeetingReminder = 1
  71. }
  72. }
  73. }
  74. }
  75. items = list
  76. return
  77. }