Explorar o código

Merge branch 'cygx_8.2.1' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai %!s(int64=2) %!d(string=hai) anos
pai
achega
2f806a8470
Modificáronse 4 ficheiros con 73 adicións e 21 borrados
  1. 42 20
      controllers/article.go
  2. 3 0
      models/article.go
  3. 1 1
      models/industrial_management.go
  4. 27 0
      services/article.go

+ 42 - 20
controllers/article.go

@@ -74,24 +74,55 @@ func (this *ArticleController) Detail() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 	}
-	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
-	if user.CompanyId > 1 {
-		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
+	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:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 			return
 		}
-		detail, err = models.GetArticleDetailById(articleId)
+		if !havePower {
+			hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(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.BodyText = ""
+			detail.SellerName = sellerName
+			detail.SellerMobile = sellerMobile
+			resp.Detail = detail
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
+	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
+	if user.CompanyId > 1 {
+		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
 		if err != nil {
 			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
 			return
 		}
-		//是否属于专项调研报告
-		if detail.SubCategoryName == "专项调研" {
-			detail.IsSpecialArticle = true
-		}
+
 		detail.PublishDate = utils.TimeRemoveHms(detail.PublishDate)
 		detail.Body = html.UnescapeString(detail.Body)
 		detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
@@ -363,22 +394,13 @@ Loop:
 
 	// 处理研选下面的路演精华 的报告链接是否跳转
 	if hasPermission == 1 && detail.ArticleId > utils.SummaryArticleId && detail.ArticleTypeId > 0 {
-		//articleTYpeDetail, err := models.GetArticleTypeInfo(detail.ArticleTypeId)
-		//if err != nil && err.Error() != utils.ErrNoRow() {
-		//	br.Msg = "获取信息失败"
-		//	br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		//	return
-		//}
-		//if articleTYpeDetail != nil {
-		//	detail.IsShowLinkButton = articleTYpeDetail.IsShowLinkButton
-		//}
 		detail.PublishDate = utils.TimeRemoveHms2(detail.PublishDate)
 		if detail.ReportLink != "" {
 			chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
 			detail.ReportLink += "?token=" + chartUserTokenByMobile
 		}
 	}
-	resp := new(models.ArticleDetailResp)
+
 	resp.HasPermission = hasPermission
 	resp.HaveResearch = haveResearch
 	resp.HasFree = hasFree

+ 3 - 0
models/article.go

@@ -221,6 +221,9 @@ type ArticleDetailResp struct {
 	HasFree       int    `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
 	HaveResearch  bool   `description:"是否有研选权限"`
 	Mobile        string `description:"用户手机号"`
+	PopupMsg      string `description:"权限弹窗信息"`
+	SellerMobile  string `description:"销售电话"`
+	SellerName    string `description:"销售姓名"`
 }
 
 type ArticleDetailHtgjResp struct {

+ 1 - 1
models/industrial_management.go

@@ -643,7 +643,7 @@ func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []
 			0,
 			mmc.industry_id AS industrial_management_id,			
 			mmc.content AS title,
-			mm.meeting_time AS publish_date
+			MAX( mm.meeting_time ) AS publish_date 
 		FROM
 			cygx_morning_meeting_review_chapter AS mmc
 			INNER JOIN cygx_morning_meeting_reviews AS mm 

+ 27 - 0
services/article.go

@@ -3,6 +3,7 @@ package services
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"github.com/PuerkitoBio/goquery"
 	"github.com/beego/beego/v2/client/orm"
@@ -1567,3 +1568,29 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 	utils.Rc.Put(cacheKey, articleId, time.Hour*12)
 	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: " + e.Error())
+		return
+	}
+	fmt.Println(permissionStr)
+	//如果没有对应的升级权限,则返回
+	if !strings.Contains(permissionStr, reportMapDetail.ChartPermissionName) {
+		return
+	} else {
+		havePower = true
+	}
+	return
+}