浏览代码

no message

xingzai 9 月之前
父节点
当前提交
d10da47df9
共有 4 个文件被更改,包括 65 次插入25 次删除
  1. 1 1
      controllers/article.go
  2. 52 23
      controllers/yanxuan_special.go
  3. 11 0
      models/cygx_yanxuan_special.go
  4. 1 1
      services/article.go

+ 1 - 1
controllers/article.go

@@ -67,7 +67,7 @@ func (this *ArticleNoLoginController) Detail() {
 	}
 	resp.IsResearch = true
 
-	havePower, err := services.GetArticleDetailUserPower(user, detail)
+	havePower, err := services.GetArticleDetailUserPower(user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()

+ 52 - 23
controllers/yanxuan_special.go

@@ -163,8 +163,8 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -179,7 +179,7 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		return
 	}
 
-	item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
+	item, tmpErr := models.GetYanxuanSpecialById(specialId, user.UserId)
 	if tmpErr != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
@@ -188,15 +188,16 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 
 	//记录分享来源
 	if inviteShareCode != "" {
-		go services.AddCygxUserAdminShareHistory(sysUser, utils.CYGX_OBJ_YANXUANSPECIAL, item.Title, inviteShareCode, specialId)
+		go services.AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_YANXUANSPECIAL, item.Title, inviteShareCode, specialId)
 	}
 	if item.MyCollectNum > 0 {
 		item.IsCollect = 1
 	}
 
-	var resp models.CygxYanxuanSpecialResp
-	resp.HasPermission = 1
-	resp.CygxYanxuanSpecialItem = *item
+	var resp models.CygxYanxuanSpecialDetailResp
+	var yanxuanDetail *models.CygxYanxuanSpecialResp
+	yanxuanDetail.HasPermission = 1
+	yanxuanDetail.CygxYanxuanSpecialItem = *item
 	if item.DocUrl != "" {
 		var docs []models.Doc
 		err := json.Unmarshal([]byte(item.DocUrl), &docs)
@@ -205,31 +206,31 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 			br.ErrMsg = "参数解析失败,Err:" + err.Error()
 			return
 		}
-		resp.Docs = docs
+		yanxuanDetail.Docs = docs
 	}
 	if item.ImgUrl != "" {
 		imgList := strings.Split(item.ImgUrl, ",")
 		for _, s := range imgList {
-			resp.ImgUrlList = append(resp.ImgUrlList, s)
+			yanxuanDetail.ImgUrlList = append(yanxuanDetail.ImgUrlList, s)
 		}
 	} else {
-		resp.ImgUrlList = []string{}
+		yanxuanDetail.ImgUrlList = []string{}
 	}
 	if item.CompanyTags != "" {
 		cTagList := strings.Split(item.CompanyTags, ",")
 		for _, s := range cTagList {
-			resp.CompanyTags = append(resp.CompanyTags, s)
+			yanxuanDetail.CompanyTags = append(yanxuanDetail.CompanyTags, s)
 		}
 	} else {
-		resp.CompanyTags = []string{}
+		yanxuanDetail.CompanyTags = []string{}
 	}
 	if item.IndustryTags != "" {
 		iTagList := strings.Split(item.IndustryTags, ",")
 		for _, s := range iTagList {
-			resp.IndustryTags = append(resp.IndustryTags, s)
+			yanxuanDetail.IndustryTags = append(yanxuanDetail.IndustryTags, s)
 		}
 	} else {
-		resp.IndustryTags = []string{}
+		yanxuanDetail.IndustryTags = []string{}
 	}
 
 	var configCode string
@@ -241,9 +242,9 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		br.ErrMsg = "获取失败, Err:" + err.Error()
 		return
 	}
-	if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
-		resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
-		resp.CygxYanxuanSpecialItem.Status = item.Status
+	if item.UserId != user.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, user.Mobile) {
+		yanxuanDetail.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
+		yanxuanDetail.CygxYanxuanSpecialItem.Status = item.Status
 		//resp.HasPermission = 2
 	}
 
@@ -263,26 +264,54 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 	//判断是否属于审核人员
 	mobileSlice := strings.Split(cnf.ConfigValue, ",")
 	for _, v := range mobileSlice {
-		if v == sysUser.Mobile {
-			resp.IsApprovalAdmin = true
+		if v == user.Mobile {
+			yanxuanDetail.IsApprovalAdmin = true
 		}
 	}
 
-	fllowNum, err := models.GetCygxYanxuanSpecialFollowCountByUserId(sysUser.UserId, item.UserId)
+	fllowNum, err := models.GetCygxYanxuanSpecialFollowCountByUserId(user.UserId, item.UserId)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取是否关注作者失败, Err:" + err.Error()
 		return
 	}
 	if fllowNum == 1 {
-		resp.IsFollowAuthor = true
+		yanxuanDetail.IsFollowAuthor = true
+	}
+
+	havePower, err := services.GetArticleDetailUserPower(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
 	}
-	//
+	var hasPermission int
+	if havePower {
+		hasPermission = 1
+	} else {
+		hasPermission, err = services.GetUserDetailPermissionCode(user.UserId, user.CompanyId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,GetUserDetailPermissionCode Err:" + err.Error()
+			return
+		}
+	}
+	yanxuanDetail.HasPermission = hasPermission
+	resp.HasPermission = hasPermission
+
 	//if resp.HasPermission != 1 || sysUser.UserId == 0 {
 	//	resp.Content = utils.InterceptHtmlLength(resp.Content, 240)
 	//}
 	//resp.ShareImg = utils.YANXUAN_SPECIAL_SHARE_IMG
-	resp.ShareImg = resp.HeadImg
+	yanxuanDetail.ShareImg = yanxuanDetail.HeadImg
+	resp.IsShowWxPay = utils.IS_SHOW_WX_PAY                                                      //是否展示微信支付按钮
+	resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId)         //获取客户是否有过历史申请记录
+	resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
+	resp.GoodsList = services.GetUserGoodsCardList()                                             //日卡月卡商品信息
+	for _, v := range resp.GoodsList {
+		resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
+	}
+	resp.Detail = yanxuanDetail
 	br.Data = resp
 	br.Ret = 200
 	br.Success = true

+ 11 - 0
models/cygx_yanxuan_special.go

@@ -3,6 +3,7 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_web_mfyx/models/order"
 	"time"
 )
 
@@ -64,6 +65,16 @@ type CygxYanxuanSpecialItem struct {
 	LabelKeywordImgLink string   `description:"标签关键词ico"`
 }
 
+type CygxYanxuanSpecialDetailResp struct {
+	Detail             *CygxYanxuanSpecialResp
+	HasPermission      int                    `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	PopupPriceMsg      string                 `description:"价格弹窗信息"`
+	IsShowWxPay        bool                   `description:"是否展示微信支付"`
+	IsCompanyApply     bool                   `description:"机构是否申请过试用"`
+	IsNeedBusinessCard bool                   `description:"是否需要上传名片"`
+	GoodsList          []*order.CygxGoodsResp `description:"商品信息"`
+}
+
 type CygxYanxuanSpecialResp struct {
 	CygxYanxuanSpecialItem
 	Docs            []Doc

+ 1 - 1
services/article.go

@@ -658,7 +658,7 @@ func GetArticleShareImg(articleId int) (shareImg string) {
 }
 
 // GetArticleDetailUserPower 处理用户查看报告详情的权限
-func GetArticleDetailUserPower(user *models.WxUserItem, articleInfo *models.ArticleDetail) (havePower bool, err error) {
+func GetArticleDetailUserPower(user *models.WxUserItem) (havePower bool, err error) {
 	userId := user.UserId
 	companyId := user.CompanyId
 	//判断用户是否开通了个人研选权限