Browse Source

处理冻结流失客户弹窗提示

xingzai 2 years ago
parent
commit
25e3436683
3 changed files with 152 additions and 1 deletions
  1. 97 0
      controllers/activity.go
  2. 22 1
      controllers/article.go
  3. 33 0
      services/user_activity_permission.go

+ 97 - 0
controllers/activity.go

@@ -663,6 +663,25 @@ func (this *ActivityCoAntroller) Detail() {
 	if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
 		activityInfo.IsCClassMeeting = true
 	}
+	//处理冻结客户,流失客户的弹窗提示
+	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
+		}
+	}
 	applyCount, err := models.GetApplyRecordCount(uid)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
@@ -1041,6 +1060,25 @@ func (this *ActivityCoAntroller) SignupAdd() {
 	if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
 		resp.GoBindEmail = true
 	}
+	//处理冻结客户,流失客户的弹窗提示
+	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
+		}
+	}
 	//判断是否已经申请过
 	applyCount, err := models.GetApplyRecordCount(uid)
 	if err != nil && err.Error() != utils.ErrNoRow() {
@@ -1724,6 +1762,26 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 	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
+		}
+	}
 	var companyDetailStatus string
 	if user.CompanyId <= 1 {
 		companyDetailStatus = ""
@@ -3284,6 +3342,26 @@ func (this *ActivityCoAntroller) CheckAsk() {
 		return
 	}
 	resp := new(models.SignupStatus)
+
+	//处理冻结客户,流失客户的弹窗提示
+	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
+		}
+	}
 	hasPermission := 0
 	var companyDetailStatus string
 	if user.CompanyId <= 1 {
@@ -4747,6 +4825,25 @@ func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
 	//SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
 	item := new(models.CygxActivityAppointment)
 	resp := new(models.SignupStatus)
+	//处理冻结客户,流失客户的弹窗提示
+	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
+		}
+	}
 	hasPermission := 0
 	var companyDetailStatus string
 	if user.CompanyId <= 1 {

+ 22 - 1
controllers/article.go

@@ -312,6 +312,27 @@ Loop:
 		}
 		haveResearch = true
 	}
+	if hasPermission == 5 {
+		companyPermissionNoStatus, err := models.GetCompanyPermissionByUserNoStatus(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		if companyPermissionNoStatus != "" {
+			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 = 3
+				detail.SellerMobile = sellerItemQy.Mobile
+				detail.SellerName = sellerItemQy.RealName
+			}
+		}
+	}
 
 	if hasPermission == 2 || hasPermission == 4 {
 		//获取销售手机号
@@ -327,6 +348,7 @@ Loop:
 			detail.SellerName = sellerItemQy.RealName
 		}
 	}
+
 	if detail.ArticleId < utils.SummaryArticleId {
 		if user.Mobile != "" {
 			chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
@@ -353,7 +375,6 @@ Loop:
 			chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
 			detail.ReportLink += "?token=" + chartUserTokenByMobile
 		}
-
 	}
 	resp := new(models.ArticleDetailResp)
 	resp.HasPermission = hasPermission

+ 33 - 0
services/user_activity_permission.go

@@ -0,0 +1,33 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+func CheckActivityUserPermission(user *models.WxUserItem) (sellerMobile, sellerRealName string, err error) {
+	companyPermission, e := models.GetCompanyPermission(user.CompanyId)
+	if e != nil {
+		err = e
+		return
+	}
+	if companyPermission == "" {
+		companyPermissionNoStatus, e := models.GetCompanyPermissionByUserNoStatus(user.CompanyId)
+		if e != nil {
+			err = e
+			return
+		}
+		if companyPermissionNoStatus != "" {
+			sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = e
+				return
+			}
+			if sellerItemQy != nil {
+				sellerMobile = sellerItemQy.Mobile
+				sellerRealName = sellerItemQy.RealName
+			}
+		}
+	}
+	return
+}