Browse Source

no message

xingzai 2 years ago
parent
commit
8f3702bce4
2 changed files with 24 additions and 147 deletions
  1. 19 144
      controllers/activity_special.go
  2. 5 3
      services/activity_special.go

+ 19 - 144
controllers/activity_special.go

@@ -7,7 +7,6 @@ import (
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -192,22 +191,6 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 		return
 	}
 	activityId := req.ActivityId
-	hasPermission := 0
-	//判断是否已经申请过
-	applyCount, err := models.GetApplyRecordCount(uid)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
-		return
-	}
-	//获取FICC销售信息
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "申请失败"
-		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		return
-	}
-
 	activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
 	if activityInfo == nil {
 		br.Msg = "操作失败"
@@ -219,137 +202,17 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 		return
 	}
-	//HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
-	//var companyDetailStatus string
-	if user.CompanyId > 1 {
-		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.HasPermission = hasPermission
-			resp.ActivityId = activityId
-			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
-		}
-	}
-	var userType int
-	var permissionStr string
-	userType, permissionStr, err = services.GetUserType(user.CompanyId)
+
+	havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
 	if err != nil {
-		br.Msg = "获取信息失败!"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
-		br.Msg = "您暂无查看该活动权限"
-		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 	}
 
-	if user.CompanyId > 1 {
-		companyItem, err := models.GetCompanyDetailById(user.CompanyId)
-		//冻结客户
-		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
-				if applyCount > 0 {
-					hasPermission = 4
-				} else {
-					if sellerItem != nil {
-						hasPermission = 5
-					} else {
-						hasPermission = 3
-					}
-				}
-				resp.ActivityId = activityId
-				resp.HasPermission = hasPermission
-				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
-				br.Ret = 200
-				br.Success = true
-				br.Msg = "获取成功"
-				br.Data = resp
-				return
-			} else {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
-				return
-			}
-		}
-		//判断是否有权限
-		var havePower bool
-		if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
-			havePower = true
-		}
-		if havePower {
-			hasPermission = 1
-		} else {
-			if companyItem.ProductId == 2 {
-				hasPermission = 2
-				resp.SellerMobile = companyItem.Mobile
-				resp.SellerName = companyItem.SellerName
-				if permissionStr == "专家" {
-					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
-				} else {
-					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
-				}
-			} else {
-				hasPermission = 5
-			}
-		}
-	} else { //潜在客户
-		if applyCount > 0 {
-			hasPermission = 4
-		} else {
-			if sellerItem != nil {
-				hasPermission = 5
-			} else {
-				hasPermission = 3
-			}
-		}
-		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
-	}
-	resp.HasPermission = hasPermission
-	resp.ActivityId = activityId
-	if hasPermission == 1 {
+	//判断有没有对应的权限,如果没有则给出对应的状态码
+	if havePower {
+		resp.HasPermission = 1
 		signupStatus, popupMsg, popupMsg2, err := services.SpecialTripPopupMsg(activityInfo, user)
 		if err != nil {
 			br.Msg = "获取信息失败"
@@ -424,7 +287,19 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 				//go services.SpecialActivityUserRemind(user, activityInfo, 1)
 			}
 		}
+	} else {
+		hasPermission, sellerName, sellerMobile, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
 	}
+	resp.ActivityId = activityId
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 5 - 3
services/activity_special.go

@@ -357,7 +357,7 @@ func GetSpecialTripUserMap(activityIds []int, userId int) (mapUserId map[int]int
 
 //GetActivitySpecialList 获取专项调研列表
 func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int, keywords string) (list []*models.CygxActivitySpecialDetail, total int, err error) {
-	listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, 1, keywords)
+	listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, 0, keywords)
 	if e != nil {
 		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
 		return
@@ -608,7 +608,9 @@ func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.Cyg
 		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
 		return
 	}
-	if permissionStr == "" {
+	fmt.Println(permissionStr)
+	//如果没有对应的升级权限,则返回
+	if !strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
 		return
 	}
 	userType, e := GetSpecialUserType(user)
@@ -639,7 +641,7 @@ func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.Cyg
 		havePower = true
 	}
 	fmt.Println(havePower)
-	fmt.Println(permissionStr)
+
 	fmt.Println(userType)
 	return
 }