Parcourir la source

Merge branch 'cygx_13.8' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai il y a 6 mois
Parent
commit
90d1c8ee0a

+ 3 - 0
controllers/tactics.go

@@ -127,6 +127,9 @@ func (this *TacticsController) List() {
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
 			v.Pv = productInteriorMapPv[v.ArticleId]
 		}
+		if v.ReportId > 0 {
+			v.Resource = 3
+		}
 	}
 	resp.List = list
 	resp.Paging = page

+ 1 - 1
services/cygx_yanxuan_special_company.go

@@ -88,7 +88,7 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	}
 	var sellerName string
 	//获取销售信息
-	sellerName, _ = GetSellerName(user)
+	sellerName, _, _ = GetSellerName(user)
 	if stopTime >= 3 {
 
 		//判断一个用户是否阅读过 某一篇研选专栏

+ 13 - 41
services/ficc_report.go

@@ -96,65 +96,37 @@ func GetReportDetail(userinfo *models.WxUserItem, reportId int) (reportDetail fi
 			return
 		}
 	}
-	//判断是否已经申请过
-	applyCount, e := models.GetApplyRecordCount(userinfo.UserId)
-	if e != nil {
-		err = errors.New("判断是否已申请过试用失败")
-		return
-	}
 	var hasPermission int
+	var hasPower bool
 	if userinfo.CompanyId > 1 {
 		companyPermission, e := models.GetCompanyPermission(userinfo.CompanyId)
 		if e != nil {
-			err = errors.New("获取用户权限信息失败")
+			err = errors.New("GetCompanyPermission")
 			return
 		}
-		if companyPermission == "" {
-			if applyCount > 0 {
-				hasPermission = 5
-			} else {
-				hasPermission = 2
-			}
-		} else {
-			var hasPersion bool
+		if companyPermission != "" {
 			slice := strings.Split(companyPermission, ",")
 			if utils.InArrayByStr(slice, "周期") {
-				hasPersion = true
-			}
-			if hasPersion {
-				hasPermission = 1
-			} else { //无该行业权限
-				companyDetail, e := models.GetCompanyDetailById(userinfo.CompanyId)
-				if e == nil && companyDetail.ProductId == 1 {
-					hasPermission = 2
-				} else {
-					hasPermission = 3
-				}
+				hasPower = true
 			}
 		}
-		//获取销售手机号
-		sellerItem, e := models.GetSellerByCompanyId(userinfo.CompanyId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("获取销售数据失败")
+	}
+
+	if hasPower {
+		hasPermission = 1
+	} else {
+		hasPermission, e = GetUserPermissionCode(userinfo.UserId, userinfo.CompanyId)
+		if e != nil {
+			err = errors.New("GetUserPermissionCode")
 			return
 		}
-		if sellerItem != nil {
-			reportDetail.SellerMobile = sellerItem.Mobile
-			reportDetail.SellerName = sellerItem.RealName
-		}
-	} else { //潜在客户
-		if applyCount > 0 {
-			hasPermission = 5
-		} else {
-			hasPermission = 4
-		}
+		reportDetail.SellerName, reportDetail.SellerMobile, _ = GetSellerName(userinfo)
 	}
 	reportDetail.HasPermission = hasPermission
 
 	//判断权限
 
 	var authOk bool
-
 	var reportChapterIdList []int
 	if reportInfo.HasChapter == 1 {
 		if reportInfo.ClassifyNameFirst == "晨报" {

+ 50 - 1
services/user_permission.go

@@ -119,7 +119,7 @@ func GetUserRaiPermissionYanXuanInfo(user *models.WxUserItem) (hasPermission int
 }
 
 // 获取权益销售姓名
-func GetSellerName(user *models.WxUserItem) (sellerName string, sellerId int) {
+func GetSellerName(user *models.WxUserItem) (sellerName, mobile string, sellerId int) {
 	var err error
 	defer func() {
 		if err != nil {
@@ -149,6 +149,7 @@ func GetSellerName(user *models.WxUserItem) (sellerName string, sellerId int) {
 	}
 	sellerName = sealldetail.RealName
 	sellerId = sealldetail.AdminId
+	mobile = sealldetail.Mobile
 	return
 }
 
@@ -190,3 +191,51 @@ func GetUserDetailPermissionCode(userId, companyId int) (permission int, err err
 	}
 	return
 }
+
+// 获取用户权限状态  https://hzstatic.hzinsights.com/static/images/202402/20240205/LpE6dspJCLzfQoCoE8SFMDiLuxXk.png(状态码说明)
+func GetUserPermissionCode(userId, companyId int) (permission int, err error) {
+	// 用户申请记录
+	applyCount, e := models.GetApplyRecordCount(userId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+		return
+	}
+
+	if companyId == 1 {
+		// 潜在用户
+		if applyCount > 0 {
+			permission = 6
+		} else {
+			permission = 7
+		}
+	} else {
+		//权益客户
+		raiCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+		if e != nil {
+			err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+			return
+		}
+		if raiCount == 1 {
+			if applyCount > 0 {
+				permission = 2
+			} else {
+				permission = 3
+			}
+		} else {
+			//ficc 客户
+			ficcCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_FICC_ID)
+			if e != nil {
+				err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+				return
+			}
+			if ficcCount == 1 {
+				if applyCount > 0 {
+					permission = 4
+				} else {
+					permission = 5
+				}
+			}
+		}
+	}
+	return
+}