查询商品库存 增加分类功能

This commit is contained in:
GYJ 2024-07-08 14:02:28 +08:00
parent cfee6f4b43
commit 83075a34b7
3 changed files with 7 additions and 4 deletions

View File

@ -10,6 +10,7 @@ public class StockQueryDto {
private String shopId;
private Double num;
private Integer isStock;
private Integer categoryId;
public void setName(String name) {
if (StringUtils.isNotBlank(name)) {

View File

@ -65,11 +65,13 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " +
"pro.shopId = :shopId " +
"AND pro.status = 1 " +
"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 asc ")
Page<StockV2Vo> searchProStockV2(@Param("shopId") String shopId, @Param("proName") String proName, @Param("isStock")Integer isStock, Pageable pageable);
Page<StockV2Vo> searchProStockV2(@Param("shopId") String shopId, @Param("proName") String proName, @Param("isStock")Integer isStock,
@Param("categoryId") Integer 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, " +

View File

@ -73,7 +73,7 @@ public class StockServiceImpl implements StockService {
@Override
public Page queryAllV2(StockQueryDto criteria, Integer page, Integer size) {
Pageable pageable = PageRequest.of(page, size);
return tbProductSkuRepository.searchProStockV2(criteria.getShopId(), criteria.getName(), criteria.getIsStock(), pageable);
return tbProductSkuRepository.searchProStockV2(criteria.getShopId(), criteria.getName(), criteria.getIsStock(), criteria.getCategoryId(), pageable);
}
@Override
@ -304,8 +304,8 @@ public class StockServiceImpl implements StockService {
@Transactional
public void inHouseV2(String shopId, List<StockV2Vo> list) {
Set<Integer> proIds=new HashSet<>();
Set<Integer> skuIds=new HashSet<>();
Set<Integer> proIds = new HashSet<>();
Set<Integer> skuIds = new HashSet<>();
for (StockV2Vo stockVo : list) {
if (stockVo.getProId() == 0) {
tbProductSkuRepository.updateStockNumber2(stockVo.getSkuId(), shopId, Double.parseDouble(stockVo.getNumber().toString()));