Merge branch 'ww' into test

This commit is contained in:
wangw 2024-10-09 09:35:51 +08:00
commit bd21ba9ae8
2 changed files with 17 additions and 34 deletions

View File

@ -1,18 +1,3 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.repository.product;
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
@ -26,23 +11,18 @@ import java.util.List;
public interface TbProductStockDetailRepository extends JpaRepository<TbProductStockDetail, Long>, JpaSpecificationExecutor<TbProductStockDetail> {
@Query(value =
"SELECT detail.* " +
" FROM " +
"tb_product_stock_detail detail" +
" INNER JOIN TbProduct pro ON detail.product_id = pro.id " +
"AND pro.shop_id = :shopId " +
"AND ( :categoryId IS NULL OR pro.category_id = :categoryId ) " +
"AND ( :productName IS NULL OR pro.name LIKE %:productName % ) " +
"AND ( :type IS NULL OR pro.type = :type ) " +
" WHERE" +
" detail.shop_id = :shopId " +
"AND detail.created_at > :startTime " +
"AND detail.created_at < :endTime " +
"AND (:types IS NULL OR detail.type IN (:types)) " +
"ORDER BY " +
" detail.id DESC", nativeQuery = true)
@Query("SELECT detail FROM TbProductStockDetail detail " +
"INNER JOIN TbProduct pro ON detail.productId = pro.id " +
"AND pro.shopId = :shopId " +
"AND (:categoryId IS NULL OR pro.categoryId = :categoryId) " +
"AND (:productName IS NULL OR pro.name LIKE %:productName%) " +
"AND (:type IS NULL OR pro.typeEnum = :type) " +
"where detail.shopId = :shopId " +
"AND detail.createdAt > :startTime " +
"AND detail.createdAt < :endTime " +
"AND detail.type IN :types " +
"ORDER BY detail.id DESC")
Page<TbProductStockDetail> findByProductParam(String shopId, String productName, String categoryId, String type,
List<String> types,
long startTime, long endTime,Pageable pageable);
long startTime, long endTime, Pageable pageable);
}

View File

@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.dto.product.*;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.pojo.shop.TbShopUnit;
@ -88,6 +87,9 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
case "lossNumber":
criteria.setTypes(Collections.singletonList("报损"));
break;
default:
criteria.setTypes(Arrays.asList("供应商入库", "盘点入库", "其他入库", "退单","供应商出库","其他出库","盘点出库","售出记录","报损"));
break;
}
}
@ -96,7 +98,8 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
Page<TbProductStockDetail> page = tbProductStockDetailRepository.findByProductParam(
criteria.getShopId().toString(), criteria.getProductName(),
criteria.getCategoryId(),criteria.getType(),criteria.getTypes(),
criteria.getCategoryId(),criteria.getType(),
criteria.getTypes() ,
criteria.getStartTime().getTime(), criteria.getEndTime().getTime(), pageable);
Page<TbProductStockDetailDto> map = page.map(tbProductStockDetailMapper::toDto);