| | |
| | | @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("申请数量不能超过总数"); |
| | | } |
| | | |
| | |
| | | s.setReason(dto.getReason()); |
| | | s.setStatus(Constants.ORDER_SALES_STATUS.PENDING.name()); |
| | | s.create(userId); |
| | | s.setSalesType(dto.getSalesType()); |
| | | orderItemSalesMapper.insert(s); |
| | | |
| | | return s.getId(); |
| | |
| | | orderItemSalesMapper.updateById(sl); |
| | | |
| | | return oi; |
| | | } |
| | | |
| | | private BigDecimal getAmount(BigDecimal amount){ |
| | | return amount == null ? new BigDecimal(0) : amount; |
| | | } |
| | | } |