| | |
| | | package com.zy.asrs.wms.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.Order; |
| | | import com.zy.asrs.wms.asrs.entity.OrderDetl; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OrderUtils { |
| | |
| | | |
| | | @Transactional |
| | | public void updateWorkQty(Long orderDetlId, Double qty) { |
| | | updateWorkQty(orderDetlId, qty, true); |
| | | } |
| | | |
| | | @Transactional |
| | | public void updateWorkQty(Long orderDetlId, Double qty, boolean increase) { |
| | | OrderDetl orderDetl = orderDetlService.getById(orderDetlId); |
| | | if(orderDetl == null) { |
| | | if (orderDetl == null) { |
| | | throw new CoolException("订单明细不存在"); |
| | | } |
| | | |
| | | Order order = orderService.getById(orderDetl.getOrderId()); |
| | | if(order == null) { |
| | | if (order == null) { |
| | | throw new CoolException("订单不存在"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | Double workQty = orderDetl.getWorkQty(); |
| | | orderDetl.setWorkQty(workQty + qty); |
| | | if (increase) { |
| | | orderDetl.setWorkQty(workQty + qty); |
| | | }else { |
| | | orderDetl.setWorkQty(workQty - qty); |
| | | } |
| | | orderDetl.setUpdateTime(new Date()); |
| | | if (!orderDetlService.updateById(orderDetl)) { |
| | | throw new CoolException("订单明细更新失败"); |
| | | } |
| | | |
| | | List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId())); |
| | | boolean flag = false; |
| | | for (OrderDetl detl : orderDetls) { |
| | | if ((detl.getQty() + detl.getWorkQty()) > 0) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | order.setOrderSettle(OrderSettleType.WORKING.val()); |
| | | if (flag) { |
| | | order.setOrderSettle(OrderSettleType.WORKING.val()); |
| | | } else { |
| | | order.setOrderSettle(OrderSettleType.WAIT.val()); |
| | | } |
| | | order.setUpdateTime(new Date()); |
| | | if(!orderService.updateById(order)) { |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("订单更新失败"); |
| | | } |
| | | } |