Browse Source

no message

xingzai 2 years ago
parent
commit
5e17fe3c34
2 changed files with 44 additions and 6 deletions
  1. 1 6
      controllers/article.go
  2. 43 0
      services/company_permission.go

+ 1 - 6
controllers/article.go

@@ -91,16 +91,12 @@ func (this *ArticleController) Detail() {
 		}
 		resp.IsSpecialArticle = true
 		if !havePower {
-			hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+			hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionArticle(user)
 			if err != nil {
 				br.Msg = "获取信息失败"
 				br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 				return
 			}
-			if hasPermission == 2 {
-				hasPermission = 3
-			}
-			popupMsg = "需要升级行业套餐权限才可查看此报告,请联系对口销售"
 			resp.PopupMsg = popupMsg
 			resp.HasPermission = hasPermission
 			resp.SellerName = sellerName
@@ -139,7 +135,6 @@ func (this *ArticleController) Detail() {
 			} else {
 				hasPermission = 2
 			}
-
 			goto Loop
 		} else {
 			var articlePermissionPermissionName string

+ 43 - 0
services/company_permission.go

@@ -73,3 +73,46 @@ func GetUserHasPermission(user *models.WxUserItem) (hasPermission int, sellerNam
 	popupMsg = "需要升级行业套餐权限才可参与此活动,请联系对口销售"
 	return
 }
+
+//获取用户对应的权限申请状态 文章详情
+func GetUserHasPermissionArticle(user *models.WxUserItem) (hasPermission int, sellerName, sellerMobile, popupMsg string, err error) {
+	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
+	uid := user.UserId
+	applyCount, e := models.GetApplyRecordCount(uid)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+		return
+	}
+	if user.CompanyId <= 1 {
+		if applyCount == 0 {
+			hasPermission = 4
+		} else {
+			hasPermission = 5
+		}
+	} else {
+		companyPermission, e := models.GetCompanyPermission(user.CompanyId)
+		if e != nil {
+			err = errors.New("GetCompanyPermission, Err: " + e.Error())
+			return
+		}
+		if companyPermission != "" {
+			if applyCount > 0 {
+				hasPermission = 2
+			} else {
+				hasPermission = 3
+				//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+				sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+				if e != nil && e.Error() != utils.ErrNoRow() {
+					err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+					return
+				}
+				if sellerItemQy != nil {
+					sellerName = sellerItemQy.Mobile
+					sellerMobile = sellerItemQy.RealName
+				}
+			}
+		}
+	}
+	popupMsg = "需要升级行业套餐权限才可查看此报告,请联系对口销售"
+	return
+}