| | |
| | | @Autowired |
| | | private CodeDecorator codeDecorator; |
| | | |
| | | @Autowired |
| | | private OrderItemCheckMapper orderItemCheckMapper; |
| | | |
| | | public String createSales(OrderItemSalesCreateDTO dto){ |
| | | Integer num = dto.getNum(); |
| | | if(num == null || num == 0){ |
| | |
| | | throw new ValidationException("订单商品不存在"); |
| | | } |
| | | |
| | | if(num > oi.getNum()){ |
| | | OrderItemCheck c = orderItemCheckMapper.selectOne(new QueryWrapper<OrderItemCheck>() |
| | | .eq("order_item_id", oi.getId()) |
| | | .eq("type", Constants.CHECK_TYPE.lack.name()) |
| | | .eq("audit_status", Constants.CHECK_AUDIT_STATUS.AGREED.name()) |
| | | ); |
| | | int totalNum = oi.getNum(); |
| | | if(c != null){//需要减去缺货的数量 |
| | | totalNum -= c.getNum(); |
| | | } |
| | | if(num > totalNum){ |
| | | throw new ValidationException("申请数量不能超过总数"); |
| | | } |
| | | |