diff --git a/server/internal/logic/sys/product.go b/server/internal/logic/sys/product.go index f71fff2..0909e75 100644 --- a/server/internal/logic/sys/product.go +++ b/server/internal/logic/sys/product.go @@ -55,6 +55,24 @@ func (s *sSysProduct) List(ctx context.Context, in *sysin.ProductListInp) (list if in.CategoryId > 0 { mod = mod.Where(col("p", pc.CategoryId), in.CategoryId) } + var minAmount, maxAmount int64 + if in.PriceMin != "" { + minAmount, err = parseCents(in.PriceMin) + if err != nil { + return nil, 0, gerror.New("最低价格格式不正确") + } + mod = mod.WhereGTE(col("p", pc.PriceAmount), minAmount) + } + if in.PriceMax != "" { + maxAmount, err = parseCents(in.PriceMax) + if err != nil { + return nil, 0, gerror.New("最高价格格式不正确") + } + mod = mod.WhereLTE(col("p", pc.PriceAmount), maxAmount) + } + if in.PriceMin != "" && in.PriceMax != "" && minAmount > maxAmount { + return nil, 0, gerror.New("最低价格不能高于最高价格") + } if in.PublishStatus > 0 { mod = mod.Where(col("p", pc.PublishStatus), in.PublishStatus) } diff --git a/server/internal/model/input/sysin/product_task.go b/server/internal/model/input/sysin/product_task.go index 7193439..1de8372 100644 --- a/server/internal/model/input/sysin/product_task.go +++ b/server/internal/model/input/sysin/product_task.go @@ -45,6 +45,8 @@ type ProductListInp struct { Name string `json:"name"` PaymentType string `json:"paymentType"` CategoryId uint64 `json:"categoryId"` + PriceMin string `json:"priceMin" dc:"最低价格"` + PriceMax string `json:"priceMax" dc:"最高价格"` PublishStatus int `json:"publishStatus"` } diff --git a/web/src/views/product-task/product/index.vue b/web/src/views/product-task/product/index.vue index 94a8b99..5c4f93a 100644 --- a/web/src/views/product-task/product/index.vue +++ b/web/src/views/product-task/product/index.vue @@ -1,7 +1,29 @@