Browse Source

no message

xingzai 2 years ago
parent
commit
5bef813900
2 changed files with 45 additions and 165 deletions
  1. 44 165
      controllers/activity.go
  2. 1 0
      services/company_permission.go

+ 44 - 165
controllers/activity.go

@@ -1156,83 +1156,11 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 		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.CygxActivityMeetingReminder)
 	resp := new(models.SignupStatus)
 	hasPermission := 0
-	//处理冻结客户,流失客户的弹窗提示
-	if user.CompanyId > 1 {
-		sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-			return
-		}
-		if sellerMobile != "" {
-			resp.HasPermission = 2
-			resp.SellerMobile = sellerMobile
-			resp.SellerName = sellerRealName
-			br.Ret = 200
-			br.Success = true
-			br.Msg = "获取成功"
-			br.Data = resp
-			return
-		}
-	}
-	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 = "获取信息失败!"
@@ -1245,8 +1173,7 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 		return
 	}
 	var userType int
-	var permissionStr string
-	userType, permissionStr, err = services.GetUserType(user.CompanyId)
+	userType, _, err = services.GetUserType(user.CompanyId)
 	if err != nil {
 		br.Msg = "获取信息失败!"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
@@ -1262,103 +1189,55 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 		br.Msg = "活动开始前15分钟无法设置会议提醒"
 		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.GetActivityDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
+	}
 
-		havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+	if havePower {
+		hasPermission = 1
+		signupStatus = "Success"
+		totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
+		if errMeeting != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errMeeting.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
-			}
-			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.AddActivityMeetingReminder(item)
-			if errSignup != nil {
-				br.Msg = "操作失败"
-				br.ErrMsg = "操作失败,Err:" + errSignup.Error()
-				return
-			}
-			resp.HaqveJurisdiction = true
-			//1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
-			go services.ActivityUserRemind(user, activityInfo, 2)
-		} 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
-			}
+		if totalMeeting > 0 {
+			br.Msg = "您已预约,请勿重复预约"
+			return
 		}
-	} else { //潜在客户
-		if applyCount > 0 {
-			hasPermission = 4
-		} else {
-			if sellerItem != nil {
-				hasPermission = 5
-			} else {
-				hasPermission = 3
-			}
+		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.AddActivityMeetingReminder(item)
+		if errSignup != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+			return
 		}
-		resp.OperationMode = "Apply"
-		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+		resp.HaqveJurisdiction = true
+		//1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
+		go services.ActivityUserRemind(user, activityInfo, 2)
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.PopupMsg = popupMsg
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
 	}
+
 	resp.HasPermission = hasPermission
 	resp.SignupStatus = signupStatus
 	resp.ActivityId = activityId

+ 1 - 0
services/company_permission.go

@@ -149,6 +149,7 @@ func GetUserHasPermissionActivity(user *models.WxUserItem, activityInfo *models.
 		err = errors.New("GetApplyRecordCount, Err: " + e.Error())
 		return
 	}
+	popupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	companyItem, err := models.GetCompanyDetailById(user.CompanyId)
 	if err != nil {
 		if err.Error() == utils.ErrNoRow() {