Browse Source

修改报告详情风险等级配置

kobe6258 7 months ago
parent
commit
e32a154161
2 changed files with 12 additions and 3 deletions
  1. 2 0
      common/exception/exc_enums.go
  2. 10 3
      service/report/report_service.go

+ 2 - 0
common/exception/exc_enums.go

@@ -91,6 +91,7 @@ const (
 	GetReportFailed
 	GetReportSearchRangeFailed
 	SearchKeyEmptyError
+	ReportRiskLevelUnSet
 )
 
 const (
@@ -161,6 +162,7 @@ var ErrorMap = map[int]string{
 	GetReportFailed:              "获取研报详情失败",
 	GetReportSearchRangeFailed:   "设置报告搜索范围失败",
 	SearchKeyEmptyError:          "搜索关键字不能为空",
+	ReportRiskLevelUnSet:         "报告未设置风险等级",
 	//媒体
 	MediaFoundFailed:          "查询媒体信息失败",
 	GetMediaListFailed:        "查询媒体列表失败",

+ 10 - 3
service/report/report_service.go

@@ -24,6 +24,8 @@ const (
 	SourceETA        = "ETA"
 	SourceHT         = "HT"
 	RiskLevelUnMatch = "unMatch"
+	RiskLevelUnTest  = "unTest"
+	RiskLevelExpired = "expired"
 	RiskLevelMatch   = "match"
 )
 
@@ -85,12 +87,12 @@ func matchRiskLevel(userId int, report reportService.ReportDTO) (riskLevelMatch
 	//比较风险等级
 	if userProfile.RiskLevelStatus == user.RiskUnTest {
 		logger.Info("客户风险等级未测试,mobile:%d", userProfile.Mobile)
-		riskLevelMatch = RiskLevelUnMatch
+		riskLevelMatch = RiskLevelUnTest
 		return
 	}
 	if userProfile.RiskLevelStatus == user.RiskExpired {
 		logger.Info("客户风险等级已过期,mobile:%d", userProfile.Mobile)
-		riskLevelMatch = RiskLevelUnMatch
+		riskLevelMatch = RiskLevelExpired
 		return
 	}
 	level, err := permissionService.GetRiskMappingByCustomerRiskLevel(userProfile.RiskLevel)
@@ -119,6 +121,11 @@ func matchRiskLevel(userId int, report reportService.ReportDTO) (riskLevelMatch
 		logger.Error("解析风险等级失败:%v", err)
 		return
 	}
+	if len(permissionDTOs) == 0 {
+		logger.Error("当前报告对应品种未设置风险等级")
+		err = exception.New(exception.ReportRiskLevelUnSet)
+		return
+	}
 	//能够查看需要的最小等级
 	num := getLowestRiskLevel(permissionDTOs)
 	if num > matchNum {
@@ -158,7 +165,7 @@ func GetReportById(reportId int, login bool, userId int) (report reportService.R
 	status, err = matchRiskLevel(userId, report)
 	if err != nil {
 		logger.Error("匹配风险等级失败:%v", err)
-		err = exception.New(exception.GetReportFailed)
+		err = exception.New(exception.ReportRiskLevelUnSet)
 		return
 	}
 	var pdfUrl string