Kaynağa Gözat

权益研报的申请不过滤

xiexiaoyuan 3 yıl önce
ebeveyn
işleme
cfd7c99a3f

+ 1 - 7
controllers/report.go

@@ -8,7 +8,6 @@ import (
 	"hongze/hongze_api/utils"
 	"html"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -69,13 +68,8 @@ func (this *ReportController) Detail() {
 	report.ContentSub = html.UnescapeString(report.ContentSub)
 	report.Content = html.UnescapeString(report.Content)
 
-	productId := 0
+	productId := 1
 	maxPermissionCount := 0
-	if strings.Contains(report.ClassifyNameFirst, "权益研报") {
-		productId = 2
-	} else {
-		productId = 1
-	}
 
 	maxPermissionCount, err = models.GetDefaultChartPermissionCountByCache(productId)
 	if err != nil {

+ 10 - 0
models/company_product.go

@@ -86,6 +86,16 @@ func GetCompanyProductsByUserId(userId int) (items []*CompanyProductDetail, err
 	return
 }
 
+// GetTacticsPermissionIdByCompanyId 获取客户的策略权限
+func GetTacticsPermissionIdByCompanyId(companyId, productId int) (count int, err error) {
+	sql := `SELECT COUNT(DISTINCT crp.chart_permission_id) AS COUNT from chart_permission  cp 
+INNER JOIN company_report_permission AS crp ON cp.chart_permission_id = crp.chart_permission_id
+WHERE  crp.company_id=? AND crp.product_id=? AND cp.permission_name="策略"`
+	o := orm.NewOrm()
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}
+
 // UpdateCompanyProductViewData 更新客户产品的阅读记录(阅读时间、总阅读次数)
 func UpdateCompanyProductViewData(companyId, productId int, lastViewTime string) (err error) {
 	sql := ` update company_product set view_total=view_total+1,last_view_time=? WHERE company_id=? and product_id =? `

+ 26 - 0
services/user_permission.go

@@ -188,6 +188,32 @@ func CheckUserReportPermission(user *models.WxUserItem, productId int, report *m
 					checkInfo.Type = ""
 				}
 			}
+			// 判断用户是否有权益研报,权益产品中的策略权限
+			if strings.Contains(report.ClassifyNameFirst, "权益研报") {
+				productId = 2
+				qyCompany, tmpErr := models.GetCompanyProductById(user.CompanyId, 2)
+				if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+					brMsg = "获取客户产品信息失败"
+					brErrMsg = "获取客户产品信息失败,Err:" + tmpErr.Error()
+					return
+				}
+				if qyCompany != nil {
+					if strings.Contains("正式,永续",qyCompany.Status) || (qyCompany.Status == "试用" && qyCompany.IsSuspend != 1) {
+						tacticsCount, tmpErr2 := models.GetTacticsPermissionIdByCompanyId(qyCompany.CompanyId, 2)
+						if tmpErr2 != nil && tmpErr2.Error() != utils.ErrNoRow()  {
+							brMsg = "获取信息失败"
+							brErrMsg = "获取权限信息失败,Err:" + tmpErr2.Error()
+							return
+						}
+						if tacticsCount > 0 {
+							status = 0
+							msg = ""
+							checkInfo.Type = ""
+							company = qyCompany
+						}
+					}
+				}
+			}
 		}
 	}
 

+ 7 - 35
services/yb_apply.go

@@ -12,37 +12,16 @@ func AddYbApply(userId int, companyId int, mobile, email string, applyInfo model
 	sellerName := ``
 	status := `潜在用户`
 	companyName := applyInfo.CompanyName
-	reportId := applyInfo.ReportId
-
-	//查询从哪些报告页面进入申请
-	productId := 0
-	if reportId > 0 {
-		report, tErr := models.GetReportById(reportId)
-		if tErr != nil {
-			brMsg = "该报告已删除"
-			brErrMsg = "获取报告详情失败,Err:" + tErr.Error()
-			return
-		}
-		if report != nil {
-			if strings.Contains(report.ClassifyNameFirst, "权益研报") {
-				productId = 2
-			} else {
-				productId = 1
-			}
-		}
-	}
 
 	ybApplyRecord := new(models.YbApplyRecord)
-	if productId != 2 {
-		tmpmYbApplyRecord, tErr := models.GetLastApplyRecordNotOpRecordByUserId(userId)
-		if tErr == nil {
-			ybApplyRecord = tmpmYbApplyRecord	// 申请来源每一种只存在一条数据
+	tmpmYbApplyRecord, tErr := models.GetLastApplyRecordNotOpRecordByUserId(userId)
+	if tErr == nil {
+		ybApplyRecord = tmpmYbApplyRecord	// 申请来源每一种只存在一条数据
+		return
+	} else {
+		if tErr.Error() != utils.ErrNoRow() {
+			err = tErr
 			return
-		} else {
-			if tErr.Error() != utils.ErrNoRow() {
-				err = tErr
-				return
-			}
 		}
 	}
 	// 联系人信息
@@ -90,10 +69,6 @@ func AddYbApply(userId int, companyId int, mobile, email string, applyInfo model
 		applyMethod = 1
 	}
 
-	if productId == 2 {
-		 err, brMsg, brMsg = AddUserApply(applyInfo, applyMethod, wxUserInfo)
-		 return
-	}
 	ybApplyRecord = &models.YbApplyRecord{
 		UserID:          userId,
 		//BusinessCardURL: applyInfo.BusinessCardUrl,
@@ -122,9 +97,6 @@ func AddYbApply(userId int, companyId int, mobile, email string, applyInfo model
 	wxUserInfo.ApplyMethod = applyMethod
 
 	err = models.ModifyWxUserNameApplyMethod(wxUserInfo.UserId, wxUserInfo.RealName, wxUserInfo.Note, wxUserInfo.IsNote, wxUserInfo.ApplyMethod)
-	if err != nil {
-		
-	}
 	return
 }