xingzai 11 miesięcy temu
rodzic
commit
113838ea12

+ 27 - 26
controllers/yanxuan_special.go

@@ -244,32 +244,33 @@ func (this *BaseAuthMobileController) Detail() {
 		resp.ContentHasStyle = true
 		resp.ContentHasStyle = true
 	}
 	}
 
 
-	//var hasPermission int
-	//if userId > 0 {
-	//	hasPermission, err = services.GetUserYxHasPermissionCode(user)
-	//	if err != nil {
-	//		br.Msg = "获取失败"
-	//		br.ErrMsg = "获取失败, Err:" + err.Error()
-	//	}
-	//}
-
-	//resp.HasPermission = hasPermission
-	if user.UserId == 0 {
-		resp.HasPermission = 1
+	//校验研选专栏权限,以及无权限的时候的对应状态码
+	havePower, err := services.GetYanxuanSpecialDetailUserPower(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
+		}
+	}
+	resp.HasPermission = hasPermission
+	//支付信息
+	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 //价格弹窗信息
 	}
 	}
-
-	//如果是用户本人写的专栏,那么就不做校验
-	//if item.UserId == user.UserId || user.UserId == 0 {
-	//	resp.HasPermission = 1
-	//} else {
-	//	hasPermission, err = services.GetUserRaiPermissionYanXuanInfo(user)
-	//	if err != nil {
-	//		br.Msg = "获取失败"
-	//		br.ErrMsg = "获取失败, Err:" + err.Error()
-	//		return
-	//	}
-	//	resp.HasPermission = hasPermission
-	//}
 
 
 	br.Data = resp
 	br.Data = resp
 	br.Ret = 200
 	br.Ret = 200
@@ -457,7 +458,7 @@ func (this *YanxuanSpecialController) Save() {
 		go services.UpdateYanxuanSpecialResourceData(specialId)        //  写入首页最新  cygx_resource_data 表
 		go services.UpdateYanxuanSpecialResourceData(specialId)        //  写入首页最新  cygx_resource_data 表
 		go services.EsAddYanxuanSpecial(specialId)                     //  写入es 综合搜索
 		go services.EsAddYanxuanSpecial(specialId)                     //  写入es 综合搜索
 		go services.SendWxMsgSpecialFollow(req.Id)                     //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
 		go services.SendWxMsgSpecialFollow(req.Id)                     //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
-		go services.SendWxCategoryMsgSpecialFollow(req.Id)                     //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+		go services.SendWxCategoryMsgSpecialFollow(req.Id)             //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
 		go services.SendWxMsgSpecialAuthor(req.Id, 1)                  //研选专栏审核完成时,给提交人发送模板消息
 		go services.SendWxMsgSpecialAuthor(req.Id, 1)                  //研选专栏审核完成时,给提交人发送模板消息
 		go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1)          //研选专栏审核完成时,给提交人发送类目模板消息
 		go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1)          //研选专栏审核完成时,给提交人发送类目模板消息
 		go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) //  更新作者发布文章的数量
 		go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) //  更新作者发布文章的数量

+ 7 - 0
models/cygx_yanxuan_special.go

@@ -3,6 +3,7 @@ package models
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_mfyx/models/order"
 	"time"
 	"time"
 )
 )
 
 
@@ -68,6 +69,12 @@ type CygxYanxuanSpecialResp struct {
 	HasPermission int  `description:"1:正常展示,2:不展示"`
 	HasPermission int  `description:"1:正常展示,2:不展示"`
 	ExamineStatus int  `description:"1:未发布,2:审核中 3:已发布 4:驳回"`
 	ExamineStatus int  `description:"1:未发布,2:审核中 3:已发布 4:驳回"`
 	IsShowExamine bool `description:"是否展示审核状态按钮"`
 	IsShowExamine bool `description:"是否展示审核状态按钮"`
+
+	PopupPriceMsg      string                 `description:"价格弹窗信息"`
+	IsShowWxPay        bool                   `description:"是否展示微信支付"`
+	IsCompanyApply     bool                   `description:"机构是否申请过试用"`
+	IsNeedBusinessCard bool                   `description:"是否需要上传名片"`
+	GoodsList          []*order.CygxGoodsResp `description:"商品信息"`
 }
 }
 
 
 type CygxYanxuanSpecialCenterResp struct {
 type CygxYanxuanSpecialCenterResp struct {

+ 60 - 0
services/cygx_yanxuan_special.go

@@ -529,3 +529,63 @@ func GetSpecialAuthorListMomentsImg() (imgUrl string) {
 //func init() {
 //func init() {
 //	GetSpecialAuthorListMomentsImg()
 //	GetSpecialAuthorListMomentsImg()
 //}
 //}
+
+// GetYanxuanSpecialDetailUserPower 处理用户查看研选专栏详情的权限
+func GetYanxuanSpecialDetailUserPower(user *models.WxUserItem) (havePower bool, err error) {
+	if user.UserId == 0 {
+		havePower = true
+		return
+	}
+	//研选专栏是否需要校验权限
+	detailChart, e := models.GetConfigByCode("yanxuan_special_power_check")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	//如果没有开启校验,直接返回true
+	if detailChart.ConfigValue == "0" {
+		havePower = true
+		return
+	}
+	//判断用户是否开通了个人研选权限
+
+	userId := user.UserId
+	companyId := user.CompanyId
+	//判断用户是否开通了个人研选权限
+	mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId)
+
+	if mfyxUserPermissionTotal == 1 {
+		havePower = true
+		return
+	}
+
+	//是否是权益客户
+	raiCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if e != nil {
+		err = errors.New("GetCompanyProductCount, Err: " + e.Error())
+		return
+	}
+	if raiCount == 0 {
+		return
+	}
+
+	productDetail, e := models.GetCompanyProductDetailByCompanyId(companyId, 2)
+	if e != nil {
+		err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
+		return
+	}
+	// 永续客户无法查看研选权限
+	if productDetail.Status == utils.COMPANY_STATUS_FOREVER {
+		return
+	}
+	permissionStr, e := models.GetCompanyPermission(companyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermission, Err: " + e.Error())
+		return
+	}
+	if strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
+		havePower = true
+		return
+	}
+	return
+}