|
@@ -74,7 +74,7 @@ func GetTotalPageCountByAnalystId(mediaType string, analystId int) (total int64,
|
|
|
return mediaService.GetTotalPageCountByAnalystId(mediaType, analystId)
|
|
|
}
|
|
|
|
|
|
-func RangeSearchByAnalyst(mediaType string, analystId int, userId int) (total int64, latestId int64, ids []int) {
|
|
|
+func RangeSearchByAnalyst(mediaType string, analystId int, userId int) (total int64, latestId int64, ids []int, mappingRiskLevel string) {
|
|
|
var err error
|
|
|
//登录了需要校验风险等级,如果风险等级没做或者过期直接返回空,做了就筛选风险等级
|
|
|
userProfile, userErr := user.GetUserProfile(userId)
|
|
@@ -101,6 +101,7 @@ func RangeSearchByAnalyst(mediaType string, analystId int, userId int) (total in
|
|
|
logger.Error("查询产品风险等级映射失败:%v", mappingErr)
|
|
|
return
|
|
|
}
|
|
|
+ mappingRiskLevel = mapping.ProductRiskLevel
|
|
|
var permissionList []permissionService.PermissionDTO
|
|
|
//获取所有设置风险等级的品种
|
|
|
permissionList, err = permissionService.GetPermissionListWithRisk()
|
|
@@ -112,7 +113,7 @@ func RangeSearchByAnalyst(mediaType string, analystId int, userId int) (total in
|
|
|
for _, permission := range permissionList {
|
|
|
filterPermissionIds = append(filterPermissionIds, permission.PermissionId)
|
|
|
}
|
|
|
- return mediaService.GetAnalystMediaPermissionMappingByPermissionIds(mediaType, filterPermissionIds, analystId)
|
|
|
+ return mediaService.GetAnalystMediaPermissionMappingByPermissionIds(mediaType, filterPermissionIds, analystId, mappingRiskLevel)
|
|
|
}
|
|
|
|
|
|
func getCount(mediaType string, permissionIds []int, isLogin bool, userId int) (total int64, latestId int64, orgIds []int, mappingPdRisk string) {
|
|
@@ -300,7 +301,7 @@ func getLowestRiskLevel(permissions []permissionService.PermissionDTO) (riskLeve
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func GetMediaPageByAnalystId(mediaType string, pageInfo page.PageInfo, analystId int, mediaIds []int) (list []mediaService.MediaDTO, err error) {
|
|
|
+func GetMediaPageByAnalystId(mediaType string, pageInfo page.PageInfo, analystId int, mediaIds []int, userId int, mappingRiskLevel string) (list []mediaService.MediaDTO, err error) {
|
|
|
list, err = mediaService.GetMediaPageByAnalystId(mediaType, pageInfo, analystId, mediaIds)
|
|
|
if err != nil {
|
|
|
err = exception.New(exception.GetAnalystMediaListFailed)
|
|
@@ -314,15 +315,88 @@ func GetMediaPageByAnalystId(mediaType string, pageInfo page.PageInfo, analystId
|
|
|
var wg sync.WaitGroup
|
|
|
wg.Add(len(list))
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
+ //go func(media *mediaService.MediaDTO) {
|
|
|
+ // defer wg.Done()
|
|
|
+ // idStr := strings.Split(media.PermissionIDs, ",")
|
|
|
+ // var ids []int
|
|
|
+ // ids, err = stringUtils.StringToIntSlice(idStr)
|
|
|
+ // if err != nil {
|
|
|
+ // logger.Error("品种名称列表转换失败:%v", err)
|
|
|
+ // }
|
|
|
+ // media.PermissionNames = getMediaPermissionNames(ids)
|
|
|
go func(media *mediaService.MediaDTO) {
|
|
|
defer wg.Done()
|
|
|
idStr := strings.Split(media.PermissionIDs, ",")
|
|
|
var ids []int
|
|
|
ids, err = stringUtils.StringToIntSlice(idStr)
|
|
|
if err != nil {
|
|
|
- logger.Error("品种名称列表转换失败:%v", err)
|
|
|
+ logger.Error("获取品种列表失败:%v", err)
|
|
|
}
|
|
|
media.PermissionNames = getMediaPermissionNames(ids)
|
|
|
+ permissions, permissionErr := getMediaSecondPermissions(ids)
|
|
|
+ if permissionErr != nil {
|
|
|
+ logger.Error("获取媒体品种信息失败:%v,无法设置媒体风险等级", err)
|
|
|
+ }
|
|
|
+ riskNum := getHighestRiskLevel(permissions)
|
|
|
+ media.RiskLevel = strings.Join([]string{"R", strconv.Itoa(riskNum)}, "")
|
|
|
+ media.Login = true
|
|
|
+ var productType productDao.MerchantProductType
|
|
|
+ switch media.MediaType {
|
|
|
+ case string(mediaDao.Audio):
|
|
|
+ productType = productDao.Audio
|
|
|
+ case string(mediaDao.Video):
|
|
|
+ productType = productDao.Video
|
|
|
+ default:
|
|
|
+ logger.Error("未知媒体类型:%s", media.MediaType)
|
|
|
+ productType = ""
|
|
|
+ }
|
|
|
+ product, pdErr := productService.GetProductBySourceId(media.MediaId, productType)
|
|
|
+ if pdErr != nil {
|
|
|
+ if errors.Is(pdErr, gorm.ErrRecordNotFound) {
|
|
|
+ media.Price = defaultProductPrice
|
|
|
+ media.IsFree = true
|
|
|
+ media.IsSubscribe = false
|
|
|
+ } else {
|
|
|
+ media.Price = defaultProductPrice
|
|
|
+ media.IsFree = false
|
|
|
+ media.IsSubscribe = false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ media.Price = product.Price.String()
|
|
|
+ media.IsFree = false
|
|
|
+ }
|
|
|
+ subscribe, subscribeErr := userService.GetUserSubscribe(product.Id, userId)
|
|
|
+ if subscribeErr != nil {
|
|
|
+ media.IsSubscribe = false
|
|
|
+ } else {
|
|
|
+ media.IsSubscribe = subscribe.Status == userDao.SubscribeValid
|
|
|
+ }
|
|
|
+ media.RiskLevelStatus = RiskLevelMatch
|
|
|
+ pdRiskNum, parseErr := parseRiskLevel(product.RiskLevel)
|
|
|
+ if parseErr != nil {
|
|
|
+ media.RiskLevelStatus = RiskLevelUnMatch
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rpRiskNum, parseErr := parseRiskLevel(media.RiskLevel)
|
|
|
+ if parseErr != nil {
|
|
|
+ media.RiskLevelStatus = RiskLevelUnMatch
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mappingRiskNum, parseErr := parseRiskLevel(mappingRiskLevel)
|
|
|
+ if parseErr != nil {
|
|
|
+ media.RiskLevelStatus = RiskLevelUnMatch
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if rpRiskNum <= pdRiskNum {
|
|
|
+ media.RiskLevel = product.RiskLevel
|
|
|
+ if mappingRiskNum < pdRiskNum {
|
|
|
+ media.RiskLevelStatus = RiskLevelUnMatch
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if mappingRiskNum < rpRiskNum {
|
|
|
+ media.RiskLevelStatus = RiskLevelUnMatch
|
|
|
+ }
|
|
|
+ }
|
|
|
}(&list[i])
|
|
|
}
|
|
|
wg.Wait()
|