fix: resolve frontend build error and order refund bug, add member price filter
This commit is contained in:
@@ -38,6 +38,37 @@ func (s *content) List(ctx context.Context, filter *content_dto.ContentListFilte
|
||||
q = q.Where(tbl.IsPinned.Is(*filter.IsPinned))
|
||||
}
|
||||
|
||||
if filter.PriceType != nil && *filter.PriceType != "all" {
|
||||
if *filter.PriceType == "member" {
|
||||
q = q.Where(tbl.Visibility.Eq(consts.ContentVisibilityTenantOnly))
|
||||
} else {
|
||||
pTbl, pQ := models.ContentPriceQuery.QueryContext(ctx)
|
||||
|
||||
var shouldFilter bool
|
||||
var prices []*models.ContentPrice
|
||||
|
||||
if *filter.PriceType == "free" {
|
||||
shouldFilter = true
|
||||
prices, _ = pQ.Where(pTbl.PriceAmount.Eq(0)).Select(pTbl.ContentID).Find()
|
||||
} else if *filter.PriceType == "paid" {
|
||||
shouldFilter = true
|
||||
prices, _ = pQ.Where(pTbl.PriceAmount.Gt(0)).Select(pTbl.ContentID).Find()
|
||||
}
|
||||
|
||||
if shouldFilter {
|
||||
ids := make([]int64, len(prices))
|
||||
for i, p := range prices {
|
||||
ids[i] = p.ContentID
|
||||
}
|
||||
if len(ids) > 0 {
|
||||
q = q.Where(tbl.ID.In(ids...))
|
||||
} else {
|
||||
q = q.Where(tbl.ID.Eq(-1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort
|
||||
sort := "latest"
|
||||
if filter.Sort != nil && *filter.Sort != "" {
|
||||
|
||||
Reference in New Issue
Block a user