Browse Source

6.3纪要关注模块

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

+ 340 - 2
controllers/activity.go

@@ -575,7 +575,7 @@ func (this *ActivityCoAntroller) Detail() {
 	activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
 		return
 	}
 	if activityInfo == nil {
@@ -3530,7 +3530,7 @@ func (this *ActivityCoAntroller) SpecialList() {
 		conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
 	}
 	if userType == 1 {
-		conditionOr += ` OR (` + condition + permissionSqlStr + `) `
+		conditionOr += ` OR ( 1=1` + condition + permissionSqlStr + `) `
 	}
 	if companyProduct != nil {
 		if companyProduct.Scale != "" {
@@ -4411,3 +4411,341 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 预约纪要
+// @Description 预约纪要接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.AppointmentResp
+// @router /appointment/add [post]
+func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	signupStatus := "Success"
+	var req models.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	//判断是否已经预约过
+	totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if totalAppointment > 0 {
+		br.Msg = "您已预约!"
+		return
+	}
+
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+
+	//获取销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "申请失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+
+	//SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
+	item := new(models.CygxActivityAppointment)
+	resp := new(models.SignupStatus)
+	hasPermission := 0
+	var companyDetailStatus string
+	if user.CompanyId <= 1 {
+		companyDetailStatus = ""
+	} else {
+		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 4
+			} else {
+				if sellerItem != nil {
+					hasPermission = 5
+				} else {
+					//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+					sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+						return
+					}
+					if sellerItemQy != nil {
+						hasPermission = 2
+						resp.SellerMobile = sellerItemQy.Mobile
+						resp.SellerName = sellerItemQy.RealName
+					} else {
+						hasPermission = 3
+					}
+				}
+			}
+			resp.ActivityId = activityId
+			resp.HasPermission = hasPermission
+			resp.OperationMode = "Apply"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+		companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		if companyDetail == nil {
+			br.Msg = "获取信息失败!"
+			br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
+			return
+		}
+		companyDetailStatus = companyDetail.Status
+	}
+	var userType int
+	var permissionStr string
+	userType, permissionStr, err = services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if userType == 1 && activityInfo.ChartPermissionName == "研选" {
+		br.Msg = "您暂无查看该活动权限"
+		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		return
+	}
+	if user.CompanyId > 1 {
+		companyItem, err := models.GetCompanyDetailById(user.CompanyId)
+		//冻结客户
+		if err != nil {
+			if err.Error() == utils.ErrNoRow() {
+				//如果是FICC的客户类型,则默认他申请过
+				if applyCount > 0 {
+					hasPermission = 4
+				} else {
+					if sellerItem != nil {
+						hasPermission = 5
+					} else {
+						hasPermission = 3
+					}
+				}
+				resp.ActivityId = activityId
+				resp.HasPermission = hasPermission
+				resp.OperationMode = "Apply"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+				br.Ret = 200
+				br.Success = true
+				br.Msg = "获取成功"
+				br.Data = resp
+				return
+			} else {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
+				return
+			}
+		}
+
+		havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
+		if err != nil {
+			br.Msg = "获取信息失败!"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		if havePower {
+			hasPermission = 1
+			signupStatus = "Success"
+			totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
+			if errMeeting != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
+				return
+			}
+			if totalMeeting > 0 {
+				br.Msg = "您已预约,请勿重复预约"
+				return
+			}
+			var sellerName string
+			sellerName, err = models.GetCompanySellerName(user.CompanyId)
+			if err != nil {
+				br.Msg = "报名失败!"
+				br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+				return
+			}
+			item.UserId = uid
+			item.ActivityId = activityId
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.SellerName = sellerName
+			item.RealName = user.RealName
+			err = models.AddCygxActivityAppointment(item)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			resp.HaqveJurisdiction = true
+		} else {
+			if companyItem.ProductId == 2 {
+				hasPermission = 2
+				resp.SellerMobile = companyItem.Mobile
+				resp.SellerName = companyItem.SellerName
+				resp.MsgType = "Type"
+				resp.OperationMode = "Call"
+				if permissionStr == "专家" {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Type"
+				} else {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Industry"
+				}
+			} else {
+				hasPermission = 5
+			}
+		}
+	} else { //潜在客户
+		if applyCount > 0 {
+			hasPermission = 4
+		} else {
+			if sellerItem != nil {
+				hasPermission = 5
+			} else {
+				hasPermission = 3
+			}
+		}
+		resp.OperationMode = "Apply"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+	}
+	resp.HasPermission = hasPermission
+	resp.SignupStatus = signupStatus
+	resp.ActivityId = activityId
+	var total int
+	total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
+		return
+	}
+	if total <= 1 {
+		resp.GoFollow = true
+	}
+	br.Ret = 200
+	br.Success = true
+	if hasPermission == 1 {
+		br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
+	}
+	br.Data = resp
+}
+
+// @Title 取消预约纪要
+// @Description 取消预约纪要接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupStatus
+// @router /appointment/cancel [post]
+func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	signupStatus := "Success"
+	item := new(models.CygxActivityAppointment)
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if total == 0 {
+		br.Msg = "您暂未预约该纪要"
+		return
+	}
+
+	item.UserId = uid
+	item.ActivityId = activityId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	_, errSignup := models.CancelcygxActivityAppointment(item)
+	if errSignup != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+		return
+	}
+	resp := new(models.SignupStatus)
+	resp.SignupStatus = signupStatus
+	resp.ActivityId = activityId
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "已取消"
+	br.Data = resp
+}

+ 10 - 5
models/activity.go

@@ -85,6 +85,7 @@ type ActivityDetail struct {
 	Remarks                 string `description:"备注"`
 	ShowType                string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
 	IsSignup                int    `description:"是否已报名 1是 ,0 否"`
+	IsAppointment           int    `description:"是否已预约纪要 1是 ,0 否"`
 	SignupNum               int    `description:"已报名人数"`
 	SignupType              int    `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
 	ActiveState             string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
@@ -132,9 +133,10 @@ func GetAddActivityInfoByIdShow(uid, ActivityId int) (item *ActivityDetail, err
 	o := orm.NewOrm()
 	sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = a.activity_id AND s.user_id = ?   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS is_signup,
 			( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = a.activity_id  AND s.is_cancel = 0 AND s.do_fail_type = 0) AS signup_num,
-			( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = a.activity_id AND m.user_id = ?  AND m.is_cancel = 0 ) AS is_cancel_meeting_reminder
+			( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = a.activity_id AND m.user_id = ?  AND m.is_cancel = 0 ) AS is_cancel_meeting_reminder,
+			( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = a.activity_id AND ap.user_id = ? ) AS is_appointment
 			FROM cygx_activity AS a  WHERE activity_id=? AND publish_status = 1 `
-	err = o.Raw(sql, uid, uid, ActivityId).QueryRow(&item)
+	err = o.Raw(sql, uid, uid, uid, ActivityId).QueryRow(&item)
 	return
 }
 
@@ -157,6 +159,7 @@ type CygxActivityList struct {
 	DistinguishedGuest      string `description:"嘉宾"`
 	Expert                  string `description:"专家"`
 	IsSignup                int    `description:"是否已报名 1是 ,0 否"`
+	IsAppointment           int    `description:"是否已预约纪要 1是 ,0 否"`
 	SignupNum               int    `description:"已报名人数"`
 	ActiveState             string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
 	IsCancelMeetingReminder int    `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
@@ -182,7 +185,8 @@ func GetActivityListAll(condition string, pars []interface{}, uid, startSize, pa
 	sql := `SELECT art.* ,t.activity_type,t.img_url_text,c.image_url as  img_url,
 		( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ?   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS is_signup,
 		( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS signup_num,
-		( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.user_id = ?  AND m.is_cancel = 0  ) AS is_cancel_meeting_reminder
+		( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.user_id = ?  AND m.is_cancel = 0  ) AS is_cancel_meeting_reminder,
+		( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
 		FROM cygx_activity as art
 		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id
 		INNER JOIN  chart_permission  AS c ON c.chart_permission_id = art.chart_permission_id 
@@ -191,7 +195,7 @@ func GetActivityListAll(condition string, pars []interface{}, uid, startSize, pa
 		sql += condition
 	}
 	sql += ` LIMIT ?,?`
-	_, err = o.Raw(sql, pars, uid, uid, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
 	return
 }
 
@@ -240,6 +244,7 @@ func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageS
 	sql := `SELECT art.*,t.activity_type,t.img_url_text,c.image_url as  img_url,
 			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ? AND s.is_cancel = 0 AND s.do_fail_type = 0) AS is_signup,
             ( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND  s.is_cancel = 0  AND s.do_fail_type = 0) AS signup_num ,
+			( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment,
 			( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.is_cancel = 0 AND m.user_id = ? ) AS is_cancel_meeting_reminder
             FROM cygx_activity AS art
 			INNER JOIN cygx_my_schedule as my ON my.activity_id = art.activity_id 
@@ -250,7 +255,7 @@ func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageS
 		sql += condition
 	}
 	sql += ` ORDER BY art.active_state ASC,art.activity_time ASC  LIMIT ?,?`
-	_, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, pars, uid, uid, uid, uid, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 131 - 0
models/activity_appointment.go

@@ -0,0 +1,131 @@
+package models
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityAppointment struct {
+	Id          int       `orm:"column(id);pk"`
+	ActivityId  int       `description:"活动ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
+
+type AppointmentResp struct {
+	ActivityId    int    `description:"活动ID"`
+	HasPermission int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
+	PopupMsg      string `description:"权限弹窗信息"`
+	SellerMobile  string `description:"销售电话"`
+	SellerName    string `description:"销售姓名"`
+	GoFollow      bool   `description:"是否去关注"`
+}
+
+//添加
+func AddCygxActivityAppointment(item *CygxActivityAppointment) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	var countMySchedule int
+	sql := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countMySchedule)
+	if err != nil {
+		return
+	}
+	if countMySchedule == 0 {
+		itemMy := new(CygxMySchedule)
+		itemMy.UserId = item.UserId
+		itemMy.ActivityId = item.ActivityId
+		itemMy.CreateTime = time.Now()
+		itemMy.Mobile = item.Mobile
+		itemMy.Email = item.Email
+		itemMy.CompanyId = item.CompanyId
+		itemMy.CompanyName = item.CompanyName
+		_, err = o.Insert(itemMy)
+		if err != nil {
+			return
+		}
+	}
+	_, err = o.Insert(item)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserCygxActivityAppointmentCount(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_appointment  WHERE  user_id=?  AND   activity_id =? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserCygxActivityAppointmentCountByUid(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_appointment  WHERE  user_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxActivityAppointment(uid, activityId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_activity_special_signup   WHERE   user_id=?   AND  activity_id=?    `
+	_, err = o.Raw(sql, uid, activityId).Exec()
+	return
+}
+
+//取消纪要预约
+func CancelcygxActivityAppointment(item *CygxActivityAppointment) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	//判断是否删除我的日程
+	var countSingup int
+	var countReminder int
+	sql := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE  is_cancel = 0  AND user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countSingup)
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE   user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countReminder)
+	if err != nil {
+		return
+	}
+	if countSingup == 0 && countReminder == 0 {
+		sql = `DELETE  FROM cygx_my_schedule   WHERE user_id=?  AND activity_id=? `
+		_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+		if err != nil {
+			return
+		}
+	}
+	//删除预约的纪要
+	sql = `DELETE  FROM cygx_activity_appointment   WHERE user_id=?  AND activity_id=? `
+	_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+	if err != nil {
+		return
+	}
+	return
+}

+ 7 - 3
models/activity_meeting_reminder.go

@@ -112,13 +112,17 @@ func CancelActivityMeetingReminder(item *CygxActivityMeetingReminder) (lastId in
 		}
 	}()
 	//判断是否删除我的日程
-	var count int
+	var countSignup int
+	var countAppointment int
 	sql := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE  is_cancel = 0  AND user_id=? AND activity_id=? `
-	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&count)
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countSignup)
+
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_appointment WHERE  user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countAppointment)
 	if err != nil {
 		return
 	}
-	if count == 0 {
+	if countSignup == 0 && countAppointment == 0 {
 		sql = `DELETE  FROM cygx_my_schedule   WHERE user_id=?  AND activity_id=? `
 		_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
 		if err != nil {

+ 7 - 3
models/activity_signup.go

@@ -306,13 +306,17 @@ func CancelActivitySignup(item *CygxActivitySignup) (lastId int64, err error) {
 		}
 	}()
 	//判断是否删除我的日程
-	var count int
+	var countReminder int
+	var countAppointment int
 	sql := `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE is_cancel = 0  AND  user_id=? AND activity_id=? `
-	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&count)
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countReminder)
+
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_appointment WHERE  user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countAppointment)
 	if err != nil {
 		return
 	}
-	if count == 0 {
+	if countReminder == 0 && countAppointment == 0 {
 		sql = `DELETE  FROM cygx_my_schedule   WHERE user_id=?  AND activity_id=? `
 		_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
 		if err != nil {

+ 1 - 0
models/db.go

@@ -104,6 +104,7 @@ func init() {
 		new(CygxChartTop),
 		new(CygxCelueArticleHistoryRecord),
 		new(CygxArticleHistoryRecordAll),
+		new(CygxActivityAppointment),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 18 - 0
routers/commentsRouter_controllers.go

@@ -25,6 +25,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "ActivityAppointmentAdd",
+            Router: "/appointment/add",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "ActivityAppointmentCancel",
+            Router: "/appointment/cancel",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
             Method: "AskAdd",