activity_my_schedule.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. )
  7. func GetScheduleAndSpecilList(user *models.WxUserItem, condition string, startSize, pageSize int) (items []*models.ActivityDetail, err error) {
  8. var conditionSpecil string
  9. var pars, parsSpecil []interface{}
  10. condition += ` AND my.user_id = ?`
  11. pars = append(pars, user.UserId)
  12. conditionSpecil += ` AND my.user_id = ?`
  13. parsSpecil = append(parsSpecil, user.UserId)
  14. list, e := models.GetScheduleAndSpecilList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
  15. if e != nil {
  16. fmt.Println(e)
  17. err = errors.New("GetScheduleAndSpecilList, Err: " + e.Error())
  18. return
  19. }
  20. var activityIds []int
  21. var activitySpecilalIds []int
  22. for _, v := range list {
  23. if v.SignupType == 2 {
  24. activitySpecilalIds = append(activitySpecilalIds, v.ActivityId)
  25. } else {
  26. activityIds = append(activityIds, v.ActivityId)
  27. }
  28. }
  29. if len(activityIds) > 0 {
  30. //处理用户是否报名
  31. mapSignUp, e := GetActivitySignUpUserMap(activityIds, user)
  32. if e != nil {
  33. err = errors.New("GetActivitySignUpUserMap, Err: " + e.Error())
  34. return
  35. }
  36. for k, v := range list {
  37. if v.SignupType != 2 {
  38. if _, ok := mapSignUp[v.ActivityId]; ok {
  39. list[k].IsSignup = 1
  40. }
  41. }
  42. }
  43. //处理用户是否预约纪要
  44. mapAppointment, e := GetActivityAppointmentUserMap(activityIds, user)
  45. if e != nil {
  46. err = errors.New("GetActivityAppointmentUserMap, Err: " + e.Error())
  47. return
  48. }
  49. for k, v := range list {
  50. if v.SignupType != 2 {
  51. if _, ok := mapAppointment[v.ActivityId]; ok {
  52. list[k].IsAppointment = 1
  53. }
  54. }
  55. }
  56. }
  57. items = list
  58. return
  59. }