diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeDishesService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeDishesService.java index aadded6..4f15d51 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeDishesService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeDishesService.java @@ -1,5 +1,6 @@ package com.bonus.canteen.core.cook.service; +import java.time.LocalDate; import java.util.Date; import java.util.List; @@ -68,7 +69,7 @@ public interface ICookRecipeDishesService { * @return 结果 */ public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail, - Integer quantity, Long userId, Date orderTime); + Integer quantity, Long userId, LocalDate orderDate); public int addMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, Integer quantity); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeDishesServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeDishesServiceImpl.java index 183c0c1..45aac68 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeDishesServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeDishesServiceImpl.java @@ -1,5 +1,6 @@ package com.bonus.canteen.core.cook.service.impl; +import java.time.LocalDate; import java.util.Date; import java.util.List; import java.util.Objects; @@ -116,7 +117,7 @@ public class CookRecipeDishesServiceImpl implements ICookRecipeDishesService { @Override public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail, - Integer quantity, Long userId, Date orderTime) { + Integer quantity, Long userId, LocalDate orderDate) { log.info("扣减库存入参:{},数量:{}", JacksonUtil.writeValueAsString(cookRecipeDishes), quantity); if(cookRecipeDishes == null || cookRecipeDishes.getRecipeDetailId() == null || cookRecipeDishes.getDishesId() == null) { throw new ServiceException("参数错误"); @@ -135,7 +136,7 @@ public class CookRecipeDishesServiceImpl implements ICookRecipeDishesService { if(cookRecipeDishes.getRemanentNum() < quantity) { throw new ServiceException("菜品供应量不足"); } - Long sellNumCount = orderInfoMapper.goodsSellNumCount(menuRecipeDetail, userId, orderTime, cookRecipeDishes.getDishesId()); + Long sellNumCount = orderInfoMapper.goodsSellNumCount(menuRecipeDetail, userId, orderDate, cookRecipeDishes.getDishesId()); log.info("菜品销售数量:{}", sellNumCount); if(Objects.nonNull(cookRecipeDishes.getLimitNum()) && (sellNumCount > cookRecipeDishes.getLimitNum())) { throw new ServiceException("菜品超过个人限购数量"); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java index 810dbf9..7caa3a9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java @@ -48,6 +48,7 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; @@ -84,13 +85,13 @@ public class OrderBusiness { List orderDetailList = orderInfo.getOrderDetailList(); orderDetailList.forEach(orderDetail -> orderDetail.setOrderId(orderInfo.getOrderId())); orderDetailService.batchInsertOrderDetail(orderDetailList); - reduceMenuDishSupplyNum(orderDetailList, orderInfo.getUserId(), orderInfo.getOrderTime()); + reduceMenuDishSupplyNum(orderDetailList, orderInfo.getUserId(), orderInfo.getOrderDate()); }); } return orderInfoList; } - public void reduceMenuDishSupplyNum(List orderDetailList, Long userId, Date orderTime) { + public void reduceMenuDishSupplyNum(List orderDetailList, Long userId, LocalDate orderDate) { log.info("订单扣减库存入参:{}", JacksonUtil.writeValueAsString(orderDetailList)); for(OrderDetail orderDetail : orderDetailList) { if(OrderDetailTypeEnum.KEYAMOUNT.getKey().equals(orderDetail.getDetailType())) { @@ -111,7 +112,7 @@ public class OrderBusiness { menuRecipeDishes.setRecipeDetailId(cookRecipeDetails.get(0).getRecipeDetailId()); menuRecipeDishes.setDishesId(orderDetail.getGoodsId()); cookRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, menuRecipeDetail, - orderDetail.getQuantity(), userId , orderTime); + orderDetail.getQuantity(), userId , orderDate); } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java index 9a171bb..d1dce79 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/mapper/OrderInfoMapper.java @@ -10,6 +10,7 @@ import com.bonus.canteen.core.order.domain.param.OrderSellNumCountParam; import com.bonus.canteen.core.order.domain.param.OrderWriteOffParam; import org.apache.ibatis.annotations.Param; +import java.time.LocalDate; import java.util.Date; import java.util.List; @@ -78,7 +79,7 @@ public interface OrderInfoMapper public Long goodsSellNumCount(@Param("param") CookRecipeDetail param, @Param("userId")Long userId, - @Param("orderTime")Date orderTime, + @Param("orderDate")LocalDate orderDate, @Param("dishesId")Long dishesId); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml index bcbca56..79ea935 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/order/OrderInfoMapper.xml @@ -478,7 +478,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and od.order_date = #{param.applyDate} and oi.mealtime_type = #{param.mealtimeType} and od.goods_id = #{dishesId} - and oi.order_time >= #{orderTime ,jdbcType=TIMESTAMP} - 7 + and oi.order_state != 3 + and oi.order_time = ]]> DATE_SUB(#{orderDate}, INTERVAL 7 DAY) \ No newline at end of file