Browse Source

过滤下架产品

kobe6258 4 months ago
parent
commit
13650b698f
2 changed files with 18 additions and 4 deletions
  1. 1 0
      domian/report/report_service.go
  2. 17 4
      service/report/report_service.go

+ 1 - 0
domian/report/report_service.go

@@ -92,6 +92,7 @@ type ReportDTO struct {
 	ProductId       int             `json:"productId"`
 	IsPackage       bool            `json:"isPackage"`
 	Score           float64         `json:"score"`
+	Show            bool            `json:"-"`
 }
 
 type Detail struct {

+ 17 - 4
service/report/report_service.go

@@ -264,18 +264,23 @@ func DealReportInfo(report *reportService.ReportDTO, isLogin bool, userId int) (
 			report.IsFree = true
 			report.IsSubscribe = false
 			report.IsPackage = false
+			//最热最新的时候使用
+			report.Show = true
 		} else {
 			report.Price = packageList[0].Price
 			report.IsFree = false
 			report.IsSubscribe = false
 			report.IsPackage = true
 			report.ProductId = packageList[0].Id
+			//最热最新的时候使用
+			report.Show = packageList[0].SaleStatus == "on_sale"
 		}
 	} else {
 		report.Price = product.Price
 		report.IsFree = false
 		report.ProductId = product.Id
 		report.IsPackage = false
+		report.Show = product.SaleStatus == "on_sale"
 	}
 	if isLogin {
 		var productIds []int
@@ -379,12 +384,16 @@ func GetRandedReportByWeeklyHot(limit int, isLogin bool, userId int, pdRiskLevel
 					continue
 				}
 
-				if pdRiskNum <= reRiskNum {
+				if pdRiskNum <= reRiskNum && report.Show {
 					filterList = append(filterList, report)
 				}
 			}
 		} else {
-			filterList = dtoList
+			for _, report := range dtoList {
+				if report.Show {
+					filterList = append(filterList, report)
+				}
+			}
 		}
 		reports = make([]HotRankedReport, len(ids))
 		for i := 0; i < len(filterList); i++ {
@@ -429,12 +438,16 @@ func GetRandedReportByPublishTimeWeekly(limit int, week bool, isLogin bool, user
 				logger.Error("解析风险等级失败:%v", err)
 				continue
 			}
-			if pdRiskNum <= reRiskNum {
+			if pdRiskNum <= reRiskNum && report.Show {
 				filterList = append(filterList, report)
 			}
 		}
 	} else {
-		filterList = dtoList
+		for _, report := range dtoList {
+			if report.Show {
+				filterList = append(filterList, report)
+			}
+		}
 	}
 	reports = convertToPublishRankedReportList(filterList)
 	return