|
@@ -5,13 +5,16 @@ import (
|
|
|
"eta/eta_mini_ht_api/common/exception"
|
|
|
permissionService "eta/eta_mini_ht_api/domian/config"
|
|
|
merchantService "eta/eta_mini_ht_api/domian/merchant"
|
|
|
- reportService "eta/eta_mini_ht_api/domian/report"
|
|
|
+ reportDomain "eta/eta_mini_ht_api/domian/report"
|
|
|
"eta/eta_mini_ht_api/models/config"
|
|
|
"eta/eta_mini_ht_api/models/media"
|
|
|
configService "eta/eta_mini_ht_api/service/config"
|
|
|
+ mediaService "eta/eta_mini_ht_api/service/media"
|
|
|
"eta/eta_mini_ht_api/service/order"
|
|
|
+ reportService "eta/eta_mini_ht_api/service/report"
|
|
|
"fmt"
|
|
|
"github.com/shopspring/decimal"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -27,16 +30,22 @@ type ProductDTO struct {
|
|
|
SourceId int
|
|
|
}
|
|
|
|
|
|
-func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel string, err error) {
|
|
|
+func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel, sourceTitle, sourceAbsract, sourceSrc, permissionNames string, err error) {
|
|
|
switch product.Type {
|
|
|
case "package":
|
|
|
permissionRisk, permissionErr := config.PermissionsByPermissionId(product.SourceId)
|
|
|
+ permissionNames = permissionRisk.Name
|
|
|
if permissionErr != nil {
|
|
|
logger.Error("获取权限信息失败[permissionId:%d]", product.SourceId)
|
|
|
} else {
|
|
|
riskLevel = permissionRisk.RiskLevel
|
|
|
}
|
|
|
case "audio", "video":
|
|
|
+ mediaInfo, mediaErr := media.GetMediaById(product.Type, product.SourceId)
|
|
|
+ sourceTitle, sourceSrc = mediaInfo.MediaName, mediaInfo.Src
|
|
|
+ if mediaErr != nil {
|
|
|
+ logger.Error("获取媒体信息失败[mediaType:%s,mediaId:%d]", product.Type, product.SourceId)
|
|
|
+ }
|
|
|
permissionIds, mediaErr := media.GetMediaPermissionMappingByMedia(product.Type, product.SourceId)
|
|
|
if mediaErr != nil {
|
|
|
logger.Error("获取媒体权限失败[mediaType:%s,mediaId:%d]", product.Type, product.SourceId)
|
|
@@ -45,23 +54,26 @@ func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel
|
|
|
if permissionErr != nil {
|
|
|
logger.Error("获取权限信息失败[permissionIds:%v]", permissionIds)
|
|
|
}
|
|
|
+ permissionNamesList := mediaService.GetMediaPermissionNames(permissionIds)
|
|
|
+ permissionNames = strings.Join(permissionNamesList, ",")
|
|
|
riskNum := configService.GetHighestRiskLevel(permissions)
|
|
|
riskLevel = fmt.Sprintf("R%d", riskNum)
|
|
|
}
|
|
|
case "report":
|
|
|
- report, reportErr := reportService.GetReportById(product.SourceId)
|
|
|
+ report, reportErr := reportDomain.GetReportById(product.SourceId)
|
|
|
+ sourceAbsract, sourceTitle = report.Abstract, report.Title
|
|
|
if reportErr != nil {
|
|
|
logger.Error("获取研报信息失败[reportId:%d]", product.SourceId)
|
|
|
} else {
|
|
|
switch report.Source {
|
|
|
- case reportService.SourceHT:
|
|
|
+ case reportDomain.SourceHT:
|
|
|
permission, permissionErr := configService.GetPermissionByName(report.PlateName)
|
|
|
if permissionErr != nil {
|
|
|
logger.Error("获取板块权限失败[plateName:%s]", report.PlateName)
|
|
|
} else {
|
|
|
riskLevel = permission.RiskLevel
|
|
|
}
|
|
|
- case reportService.SourceETA:
|
|
|
+ case reportDomain.SourceETA:
|
|
|
permissions, permissionErr := configService.GetSecondPermissionsByClassifyId(report.ClassifyId)
|
|
|
if permissionErr != nil {
|
|
|
logger.Error("获取板块权限失败[plateName:%s]", report.PlateName)
|
|
@@ -70,6 +82,9 @@ func GetProductRiskLevel(product merchantService.MerchantProductDTO) (riskLevel
|
|
|
riskLevel = fmt.Sprintf("R%d", riskNum)
|
|
|
}
|
|
|
}
|
|
|
+ var permissionNamesList []string
|
|
|
+ _, permissionNamesList = reportService.GetReportPermissionNames(report.OrgId, report.Source)
|
|
|
+ permissionNames = strings.Join(permissionNamesList, ",")
|
|
|
}
|
|
|
default:
|
|
|
logger.Warn("不支持的产品类型[%s]", product.Type)
|
|
@@ -83,7 +98,7 @@ func GetProductInfoById(productId int) (product ProductDTO, err error) {
|
|
|
return
|
|
|
}
|
|
|
product = convertToProductDTO(merchantProduct)
|
|
|
- product.RiskLevel, err = GetProductRiskLevel(merchantProduct)
|
|
|
+ product.RiskLevel, _, _, _, _, err = GetProductRiskLevel(merchantProduct)
|
|
|
if err != nil {
|
|
|
logger.Error("获取风险等级失败[productId:%d]", productId)
|
|
|
}
|
|
@@ -149,12 +164,12 @@ func GetRelatePackage(info ProductDTO) (prodList []merchantService.MerchantProdu
|
|
|
}
|
|
|
return merchantService.GetProductListBySourceIds(permissionIds, "package")
|
|
|
case "report":
|
|
|
- reportInfo, reportErr := reportService.GetReportById(info.SourceId)
|
|
|
+ reportInfo, reportErr := reportDomain.GetReportById(info.SourceId)
|
|
|
if reportErr != nil {
|
|
|
logger.Error("获取报告信息失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- permissions := reportService.GetReportSecondPermissionsById(reportInfo.OrgId, reportInfo.Source)
|
|
|
+ permissions := reportDomain.GetReportSecondPermissionsById(reportInfo.OrgId, reportInfo.Source)
|
|
|
var permissionIds []int
|
|
|
if len(permissions) > 0 {
|
|
|
for _, permission := range permissions {
|