1.库存排序
This commit is contained in:
parent
a90c441988
commit
fcfe0a2f53
|
|
@ -1,5 +1,6 @@
|
|||
package cn.ysk.cashier.dto.product;
|
||||
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
|
@ -11,6 +12,7 @@ public class StockQueryDto {
|
|||
private Double num;
|
||||
private Integer isStock;
|
||||
private String categoryId;
|
||||
private boolean sort;
|
||||
|
||||
public void setName(String name) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
|
|
|
|||
|
|
@ -80,6 +80,26 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
|
|||
Page<StockV2Vo> searchProStockV2(@Param("shopId") String shopId, @Param("proName") String proName, @Param("isStock")Integer isStock,
|
||||
@Param("categoryId") String categoryId, Pageable pageable);
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
|
||||
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " +
|
||||
"CASE WHEN pro.isDistribute = 1 THEN IFNULL(pro.stockNumber, 0) ELSE SUM(sku.stockNumber) END as number" +
|
||||
", pro.isDistribute, pro.isPauseSale, true, sku.warnLine, pro.lowPrice, CASE WHEN sum(sku.isGrounding) > 0 THEN true ELSE false END as isGrounding) " +
|
||||
"from " +
|
||||
"TbProduct pro " +
|
||||
"LEFT JOIN TbProductSku sku on pro.id = sku.productId " +
|
||||
"LEFT JOIN TbShopUnit unit ON pro.unitId = unit.id " +
|
||||
"WHERE " +
|
||||
"pro.shopId = :shopId " +
|
||||
"AND pro.status = 1 " +
|
||||
"AND sku.isDel = 0 " +
|
||||
"AND (:categoryId IS NULL OR pro.categoryId = :categoryId) " +
|
||||
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
|
||||
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
|
||||
"group by pro.id " +
|
||||
"order by number desc ")
|
||||
Page<StockV2Vo> searchProStockV2ByDesc(@Param("shopId") String shopId, @Param("proName") String proName, @Param("isStock")Integer isStock,
|
||||
@Param("categoryId") String categoryId, Pageable pageable);
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
|
||||
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " +
|
||||
"CASE " +
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ public class StockServiceImpl implements StockService {
|
|||
@Override
|
||||
public Page queryAllV2(StockQueryDto criteria, Integer page, Integer size) {
|
||||
Pageable pageable = PageRequest.of(page, size);
|
||||
if (criteria.isSort()) {
|
||||
return tbProductSkuRepository.searchProStockV2ByDesc(criteria.getShopId(), criteria.getName(), criteria.getIsStock(), criteria.getCategoryId(), pageable);
|
||||
}
|
||||
return tbProductSkuRepository.searchProStockV2(criteria.getShopId(), criteria.getName(), criteria.getIsStock(), criteria.getCategoryId(), pageable);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue