Compare commits
No commits in common. "de96c9a9c82dbbaccf37e677895fed69eb422469" and "87def2c183f9608e57b3ddf525eee362a8dc7a8e" have entirely different histories.
de96c9a9c8
...
87def2c183
|
|
@ -1,6 +1,5 @@
|
||||||
package com.bonus.canteen.core.cook.service;
|
package com.bonus.canteen.core.cook.service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -69,7 +68,7 @@ public interface ICookRecipeDishesService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail,
|
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail,
|
||||||
Integer quantity, Long userId, LocalDate orderDate);
|
Integer quantity, Long userId, Date orderTime);
|
||||||
|
|
||||||
public int addMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, Integer quantity);
|
public int addMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, Integer quantity);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.bonus.canteen.core.cook.service.impl;
|
package com.bonus.canteen.core.cook.service.impl;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -117,7 +116,7 @@ public class CookRecipeDishesServiceImpl implements ICookRecipeDishesService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail,
|
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail,
|
||||||
Integer quantity, Long userId, LocalDate orderDate) {
|
Integer quantity, Long userId, Date orderTime) {
|
||||||
log.info("扣减库存入参:{},数量:{}", JacksonUtil.writeValueAsString(cookRecipeDishes), quantity);
|
log.info("扣减库存入参:{},数量:{}", JacksonUtil.writeValueAsString(cookRecipeDishes), quantity);
|
||||||
if(cookRecipeDishes == null || cookRecipeDishes.getRecipeDetailId() == null || cookRecipeDishes.getDishesId() == null) {
|
if(cookRecipeDishes == null || cookRecipeDishes.getRecipeDetailId() == null || cookRecipeDishes.getDishesId() == null) {
|
||||||
throw new ServiceException("参数错误");
|
throw new ServiceException("参数错误");
|
||||||
|
|
@ -136,7 +135,7 @@ public class CookRecipeDishesServiceImpl implements ICookRecipeDishesService {
|
||||||
if(cookRecipeDishes.getRemanentNum() < quantity) {
|
if(cookRecipeDishes.getRemanentNum() < quantity) {
|
||||||
throw new ServiceException("菜品供应量不足");
|
throw new ServiceException("菜品供应量不足");
|
||||||
}
|
}
|
||||||
Long sellNumCount = orderInfoMapper.goodsSellNumCount(menuRecipeDetail, userId, orderDate, cookRecipeDishes.getDishesId());
|
Long sellNumCount = orderInfoMapper.goodsSellNumCount(menuRecipeDetail, userId, orderTime, cookRecipeDishes.getDishesId());
|
||||||
log.info("菜品销售数量:{}", sellNumCount);
|
log.info("菜品销售数量:{}", sellNumCount);
|
||||||
if(Objects.nonNull(cookRecipeDishes.getLimitNum()) && (sellNumCount > cookRecipeDishes.getLimitNum())) {
|
if(Objects.nonNull(cookRecipeDishes.getLimitNum()) && (sellNumCount > cookRecipeDishes.getLimitNum())) {
|
||||||
throw new ServiceException("菜品超过个人限购数量");
|
throw new ServiceException("菜品超过个人限购数量");
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -85,13 +84,13 @@ public class OrderBusiness {
|
||||||
List<OrderDetail> orderDetailList = orderInfo.getOrderDetailList();
|
List<OrderDetail> orderDetailList = orderInfo.getOrderDetailList();
|
||||||
orderDetailList.forEach(orderDetail -> orderDetail.setOrderId(orderInfo.getOrderId()));
|
orderDetailList.forEach(orderDetail -> orderDetail.setOrderId(orderInfo.getOrderId()));
|
||||||
orderDetailService.batchInsertOrderDetail(orderDetailList);
|
orderDetailService.batchInsertOrderDetail(orderDetailList);
|
||||||
reduceMenuDishSupplyNum(orderDetailList, orderInfo.getUserId(), orderInfo.getOrderDate());
|
reduceMenuDishSupplyNum(orderDetailList, orderInfo.getUserId(), orderInfo.getOrderTime());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return orderInfoList;
|
return orderInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reduceMenuDishSupplyNum(List<OrderDetail> orderDetailList, Long userId, LocalDate orderDate) {
|
public void reduceMenuDishSupplyNum(List<OrderDetail> orderDetailList, Long userId, Date orderTime) {
|
||||||
log.info("订单扣减库存入参:{}", JacksonUtil.writeValueAsString(orderDetailList));
|
log.info("订单扣减库存入参:{}", JacksonUtil.writeValueAsString(orderDetailList));
|
||||||
for(OrderDetail orderDetail : orderDetailList) {
|
for(OrderDetail orderDetail : orderDetailList) {
|
||||||
if(OrderDetailTypeEnum.KEYAMOUNT.getKey().equals(orderDetail.getDetailType())) {
|
if(OrderDetailTypeEnum.KEYAMOUNT.getKey().equals(orderDetail.getDetailType())) {
|
||||||
|
|
@ -112,7 +111,7 @@ public class OrderBusiness {
|
||||||
menuRecipeDishes.setRecipeDetailId(cookRecipeDetails.get(0).getRecipeDetailId());
|
menuRecipeDishes.setRecipeDetailId(cookRecipeDetails.get(0).getRecipeDetailId());
|
||||||
menuRecipeDishes.setDishesId(orderDetail.getGoodsId());
|
menuRecipeDishes.setDishesId(orderDetail.getGoodsId());
|
||||||
cookRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, menuRecipeDetail,
|
cookRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, menuRecipeDetail,
|
||||||
orderDetail.getQuantity(), userId , orderDate);
|
orderDetail.getQuantity(), userId , orderTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import com.bonus.canteen.core.order.domain.param.OrderSellNumCountParam;
|
||||||
import com.bonus.canteen.core.order.domain.param.OrderWriteOffParam;
|
import com.bonus.canteen.core.order.domain.param.OrderWriteOffParam;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -79,7 +78,7 @@ public interface OrderInfoMapper
|
||||||
|
|
||||||
public Long goodsSellNumCount(@Param("param") CookRecipeDetail param,
|
public Long goodsSellNumCount(@Param("param") CookRecipeDetail param,
|
||||||
@Param("userId")Long userId,
|
@Param("userId")Long userId,
|
||||||
@Param("orderDate")LocalDate orderDate,
|
@Param("orderTime")Date orderTime,
|
||||||
@Param("dishesId")Long dishesId);
|
@Param("dishesId")Long dishesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -478,8 +478,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
and od.order_date = #{param.applyDate}
|
and od.order_date = #{param.applyDate}
|
||||||
and oi.mealtime_type = #{param.mealtimeType}
|
and oi.mealtime_type = #{param.mealtimeType}
|
||||||
and od.goods_id = #{dishesId}
|
and od.goods_id = #{dishesId}
|
||||||
and oi.order_state != 3
|
and oi.order_time >= #{orderTime ,jdbcType=TIMESTAMP} - 7
|
||||||
and oi.order_time <![CDATA[ >= ]]> DATE_SUB(#{orderDate}, INTERVAL 7 DAY)
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue