Browse Source

no message

xingzai 2 years ago
parent
commit
589ccaa5d5
4 changed files with 115 additions and 0 deletions
  1. 42 0
      controllers/article.go
  2. 4 0
      models/article.go
  3. 26 0
      services/article.go
  4. 43 0
      services/company_permission.go

+ 42 - 0
controllers/article.go

@@ -56,6 +56,48 @@ func (this *ArticleController) Detail() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 	}
+
+	//resp := new(models.ArticleDetailResp)
+	detail, err = models.GetArticleDetailById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	//是否属于专项调研报告
+	if detail.SubCategoryName == "专项调研" {
+		detail.IsSpecialArticle = true
+		havePower, err := services.GetSpecialArticleDetailUserPower(user, detail)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.IsSpecialArticle = true
+		if !havePower {
+			hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionArticle(user)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+				return
+			}
+			resp.PopupMsg = popupMsg
+			resp.HasPermission = hasPermission
+			resp.SellerName = sellerName
+			resp.SellerMobile = sellerMobile
+			detail.Body = ""
+			detail.Abstract = ""
+			detail.Seller.SellerName = sellerName
+			detail.Seller.SellerMobile = sellerMobile
+			resp.Detail = detail
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
+
 	//HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
 	if user.CompanyId > 1 {
 		companyPermission, err := models.GetCompanyPermission(user.CompanyId)

+ 4 - 0
models/article.go

@@ -40,6 +40,10 @@ type SellerResp struct {
 }
 
 type ArticleDetailResp struct {
+	Mobile           string `description:"用户手机号"`
+	PopupMsg         string `description:"权限弹窗信息"`
+	SellerMobile     string `description:"销售电话"`
+	SellerName       string `description:"销售姓名"`
 	Detail           *ArticleDetail
 	IsSpecialArticle bool `description:"是否属于专项调研报告"`
 	HasPermission    int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`

+ 26 - 0
services/article.go

@@ -244,3 +244,29 @@ func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	}
 	return
 }
+
+//GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
+func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *models.ArticleDetail) (havePower bool, err error) {
+	permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+		return
+	}
+	reportMapDetail, e := models.GetdetailByCategoryIdPush(articleInfo.CategoryId)
+	if e != nil {
+		err = errors.New("GetdetailByCategoryIdPush, Err: " + e.Error())
+		return
+	}
+	if reportMapDetail == nil {
+		err = errors.New("GetdetailByCategoryIdP,获取详情失败, Err: ")
+		return
+	}
+	fmt.Println(permissionStr)
+	//如果没有对应的升级权限,则返回
+	if !strings.Contains(permissionStr, reportMapDetail.ChartPermissionName) {
+		return
+	} else {
+		havePower = true
+	}
+	return
+}

+ 43 - 0
services/company_permission.go

@@ -75,3 +75,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
+}