From 9543878cd117f5866a7675536f8d85ed94ceea73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 16 Dec 2024 09:32:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B4=AD=E7=89=A9=E8=BD=A6=E8=A7=92?= =?UTF-8?q?=E6=A0=87=E6=95=B0=E7=9B=AE=E4=B8=8D=E5=87=86=E7=A1=AE=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/dao/TbProductMapper.java | 4 +++- .../system/cashierservice/service/ProductService.java | 9 +++++++-- src/main/resources/mapper/TbProductMapper.xml | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java index 29711bd..21e7c51 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java @@ -20,7 +20,9 @@ public interface TbProductMapper { List selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName); List selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName); - Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day, @Param("tableId") String tableId); + Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, + @Param("masterId") String masterId,@Param("day") String day, + @Param("tableId") String tableId, @Param("useType") String useType); @Update("update tb_product set stock_number = stock_number - #{num,jdbcType=INTEGER} where id = #{productId}") void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 42a4ae2..2eba271 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -7,6 +7,7 @@ import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO; import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO; +import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO; import com.chaozhanggui.system.cashierservice.entity.vo.ProductGroupVo; import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; @@ -55,6 +56,9 @@ public class ProductService { private TbShopUnitMapper tbShopUnitMapper; @Autowired private MpShopUnitMapper mpShopUnitMapper; + private MpCashierCartService cashierCartService; + @Autowired + private OrderService orderService; public ProductService(RabbitProducer producer) { this.producer = producer; @@ -87,7 +91,7 @@ public class ProductService { String day = DateUtils.getDay(); if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){ tbProductWithBLOBs.parallelStream().forEach(it->{ - Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, ""); + Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "", null); it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount); TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId()); if(ObjectUtil.isEmpty(tbProductSpec)){ @@ -139,10 +143,11 @@ public class ProductService { )); } String day = DateUtils.getDay(); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = orderService.checkEatModel(shopId, tableId); if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){ Map finalShopUnitsMap = shopUnitsMap; tbProductWithBLOBs.parallelStream().forEach(it->{ - Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId); + Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId, shopEatTypeInfoDTO.getUseType()); it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount); TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId()); if(ObjectUtil.isEmpty(tbProductSpec)){ diff --git a/src/main/resources/mapper/TbProductMapper.xml b/src/main/resources/mapper/TbProductMapper.xml index be823f4..0b03211 100644 --- a/src/main/resources/mapper/TbProductMapper.xml +++ b/src/main/resources/mapper/TbProductMapper.xml @@ -537,9 +537,10 @@ shop_id = #{shopId} AND product_id = #{productId} AND `status` = 'create' - and master_id = #{masterId} + AND created_at > DATE_SUB(NOW(), INTERVAL 1 DAY) + AND (master_id = #{masterId} OR master_id IS NULL) and table_id = #{tableId} - and trade_day = #{day} + AND use_type = #{useType} group by shop_id,product_id