|
@@ -305,21 +305,48 @@ func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (r
|
|
|
} else {
|
|
|
report.CoverUrl = src
|
|
|
}
|
|
|
- //下查询产品信息
|
|
|
+ //查询产品信息
|
|
|
product, pdErr := productService.GetProductBySourceId(report.ReportID, productDao.Report)
|
|
|
if pdErr != nil {
|
|
|
if errors.Is(pdErr, gorm.ErrRecordNotFound) {
|
|
|
- report.Price = defaultProductPrice
|
|
|
- report.IsFree = true
|
|
|
- report.IsSubscribe = false
|
|
|
+ permissions = reportService.GetReportSecondPermissionsById(report.OrgId, report.Source)
|
|
|
+ var permissionIds []int
|
|
|
+ if len(permissions) > 0 {
|
|
|
+ for _, permission := range permissions {
|
|
|
+ permissionIds = append(permissionIds, permission.PermissionId)
|
|
|
+ }
|
|
|
+ //单品不存在的话查套餐
|
|
|
+ productList, prodErr := productService.GetProductListBySourceIds(permissionIds, "package")
|
|
|
+ if prodErr != nil || len(productList) == 0 {
|
|
|
+ logger.Error("获取套餐列表失败:%v", pdErr)
|
|
|
+ report.Price = defaultProductPrice
|
|
|
+ report.IsFree = true
|
|
|
+ report.IsSubscribe = false
|
|
|
+ report.IsPackage = false
|
|
|
+ } else {
|
|
|
+ report.Price = defaultProductPrice
|
|
|
+ report.IsFree = true
|
|
|
+ report.IsSubscribe = false
|
|
|
+ report.IsPackage = true
|
|
|
+ report.ProductId = productList[0].Id
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ report.Price = defaultProductPrice
|
|
|
+ report.IsFree = true
|
|
|
+ report.IsSubscribe = false
|
|
|
+ report.IsPackage = false
|
|
|
+ }
|
|
|
} else {
|
|
|
report.Price = defaultProductPrice
|
|
|
report.IsFree = false
|
|
|
report.IsSubscribe = false
|
|
|
+ report.IsPackage = false
|
|
|
}
|
|
|
} else {
|
|
|
report.Price = product.Price.String()
|
|
|
report.IsFree = false
|
|
|
+ report.ProductId = product.Id
|
|
|
+ report.IsPackage = false
|
|
|
if isLogin {
|
|
|
subscribe, subscribeErr := userService.GetUserSubscribe(product.Id, userId)
|
|
|
if subscribeErr != nil {
|
|
@@ -328,17 +355,6 @@ func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (r
|
|
|
report.IsSubscribe = subscribe.Status == productDao.SubscribeValid
|
|
|
}
|
|
|
}
|
|
|
- pdRiskNum, parseErr := config.ParseRiskLevel(product.RiskLevel)
|
|
|
- if parseErr != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- rpRiskNum, parseErr := config.ParseRiskLevel(report.RiskLevel)
|
|
|
- if parseErr != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- if rpRiskNum <= pdRiskNum {
|
|
|
- report.RiskLevel = product.RiskLevel
|
|
|
- }
|
|
|
}
|
|
|
}(&list[i])
|
|
|
}
|