1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package services
- import (
- "errors"
- "fmt"
- "hongze/hongze_cygx/models"
- )
- func GetScheduleAndSpecilList(user *models.WxUserItem, condition string, startSize, pageSize int) (items []*models.ActivityDetail, err error) {
- var conditionSpecil string
- var pars, parsSpecil []interface{}
- condition += ` AND my.user_id = ?`
- pars = append(pars, user.UserId)
- conditionSpecil += ` AND my.user_id = ?`
- parsSpecil = append(parsSpecil, user.UserId)
- list, e := models.GetScheduleAndSpecilList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
- if e != nil {
- fmt.Println(e)
- err = errors.New("GetScheduleAndSpecilList, Err: " + e.Error())
- return
- }
- var activityIds []int
- var activitySpecilalIds []int
- for _, v := range list {
- if v.SignupType == 2 {
- activitySpecilalIds = append(activitySpecilalIds, v.ActivityId)
- } else {
- activityIds = append(activityIds, v.ActivityId)
- }
- }
- if len(activityIds) > 0 {
- //处理用户是否报名
- mapSignUp, e := GetActivitySignUpUserMap(activityIds, user)
- if e != nil {
- err = errors.New("GetActivitySignUpUserMap, Err: " + e.Error())
- return
- }
- for k, v := range list {
- if v.SignupType != 2 {
- if _, ok := mapSignUp[v.ActivityId]; ok {
- list[k].IsSignup = 1
- }
- }
- }
- //处理用户是否预约纪要
- mapAppointment, e := GetActivityAppointmentUserMap(activityIds, user)
- if e != nil {
- err = errors.New("GetActivityAppointmentUserMap, Err: " + e.Error())
- return
- }
- for k, v := range list {
- if v.SignupType != 2 {
- if _, ok := mapAppointment[v.ActivityId]; ok {
- list[k].IsAppointment = 1
- }
- }
- }
- }
- items = list
- return
- }
|