Browse Source

no message

xingzai 2 năm trước cách đây
mục cha
commit
fd6765a020

+ 6 - 0
models/activity.go

@@ -377,6 +377,9 @@ func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpe
 			art.active_state,
 			t.activity_type,
 			art.chart_permission_name,
+			art.distinguished_guest,
+			art.expert,
+			art.speaker,
 			1 AS source_type,
 			art.activity_time 
 		FROM
@@ -398,6 +401,9 @@ func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpe
 			"",
 			art.special_type AS activity_type,
 			art.chart_permission_name,
+			"",
+			"",
+			"",
 			2 AS source_type,
 			art.activity_time 
 		FROM

+ 13 - 2
models/activity_appointment.go

@@ -198,7 +198,7 @@ func GetCygxAppointmentSummaryListBySubjectId(subjectIds string) (item []*CygxAp
 
 type CygxAppointment struct {
 	Mobile         string `description:"手机号"`
-	UserId         int `description:"userId"`
+	UserId         int    `description:"userId"`
 	ActivityName   string `description:"所属销售"`
 	ActivityTypeId int    `description:"活动类型"`
 }
@@ -223,4 +223,15 @@ func GetCygxAppointmentSummaryBySubjectId(subjectIds string) (item []*CygxAppoin
 			ap.activity_id `
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
-}
+}
+
+//GetCygxAppointmentListByUser 获取预约纪要的人
+func GetCygxAppointmentListByUser(condition string, pars []interface{}) (item []*CygxActivityAppointment, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_appointment  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}

+ 10 - 0
models/activity_signup.go

@@ -349,6 +349,16 @@ func GetActivitySignupDetail(activityId, uid int) (item *CygxActivitySignup, err
 	return
 }
 
+func GetActivitySignuListByUser(condition string, pars []interface{}) (item []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_signup  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}
+
 //解除报名限制之后二次报名
 func AddActivitySignupByRestrict(item *CygxActivitySignup) (lastId int64, err error) {
 	o, err := orm.NewOrm().Begin()

+ 57 - 0
services/activity_button.go

@@ -0,0 +1,57 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+//获取用户已经报名的活动
+func GetActivitySignUpUserMap(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
+	userId := user.UserId
+	var condition string
+	var pars []interface{}
+	activityIdsLen := len(activityIds)
+	if activityIdsLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
+		pars = append(pars, activityIds)
+	}
+	condition += ` AND user_id = ?  AND do_fail_type = 0 `
+	pars = append(pars, userId)
+	list, e := models.GetActivitySignuListByUser(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+		return
+	}
+	mapUid := make(map[int]int)
+	for _, v := range list {
+		mapUid[v.ActivityId] = v.UserId
+	}
+	mapUserId = mapUid
+	return
+}
+
+//获取用户已经预约纪要的活动
+func GetActivityAppointmentUserMap(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
+	userId := user.UserId
+	var condition string
+	var pars []interface{}
+	activityIdsLen := len(activityIds)
+	if activityIdsLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
+		pars = append(pars, activityIds)
+	}
+	condition += ` AND user_id = ?  `
+	pars = append(pars, userId)
+	list, e := models.GetCygxAppointmentListByUser(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+		return
+	}
+	mapUid := make(map[int]int)
+	for _, v := range list {
+		mapUid[v.ActivityId] = v.UserId
+	}
+	mapUserId = mapUid
+	return
+}

+ 42 - 4
services/activity_my_schedule.go

@@ -7,21 +7,59 @@ import (
 )
 
 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("获取微路演音视频列表失败, Err: " + e.Error())
+		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
 }