| | |
| | | throw new RuntimeException("发货信息不存在"); |
| | | } |
| | | for (ShippingProductDetail shippingProductDetail : shippingProductDetails) { |
| | | stockUtils.substractStock(shippingProductDetail.getProductModelId(), shippingProductDetail.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(), shippingProductDetail.getBatchNo()); |
| | | deductOrRecordStock(shippingProductDetail, req.getId()); |
| | | } |
| | | } |
| | | byId.setExpressNumber(req.getExpressNumber()); |
| | |
| | | @Override |
| | | public boolean add(ShippingInfoDto req) { |
| | | this.save(req); |
| | | req.getBatchNoDetailList().forEach(item -> item.setShippingInfoId(req.getId())); |
| | | shippingProductDetailMapper.insert(req.getBatchNoDetailList()); |
| | | for (ShippingProductDetail shippingProductDetail : req.getBatchNoDetailList()) { |
| | | stockUtils.substractStock(shippingProductDetail.getProductModelId(), shippingProductDetail.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(), shippingProductDetail.getBatchNo()); |
| | | List<ShippingProductDetail> detailList = req.getBatchNoDetailList(); |
| | | if (CollectionUtils.isNotEmpty(detailList)) { |
| | | detailList.forEach(item -> item.setShippingInfoId(req.getId())); |
| | | shippingProductDetailMapper.insert(detailList); |
| | | for (ShippingProductDetail shippingProductDetail : detailList) { |
| | | deductOrRecordStock(shippingProductDetail, req.getId()); |
| | | } |
| | | } |
| | | // 保存文件 |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.IMAGE, RecordTypeEnum.SHIPPING_INFO, req.getId(), req.getStorageBlobDTOs()); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 有库存批号的发货扣减库存;没有库存批号(未启用仓储模块)的发货只登记出库流水。 |
| | | */ |
| | | private void deductOrRecordStock(ShippingProductDetail detail, Long shippingInfoId) { |
| | | String recordType = StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(); |
| | | if (detail.getStockInventoryId() == null) { |
| | | stockUtils.recordStockOutWithoutInventory(detail.getProductModelId(), detail.getQuantity(), recordType, shippingInfoId, detail.getBatchNo()); |
| | | } else { |
| | | stockUtils.substractStock(detail.getProductModelId(), detail.getQuantity(), recordType, shippingInfoId, detail.getBatchNo()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<ShippingProductDetailDto> getDetail(Long id) { |
| | | return shippingProductDetailMapper.getDetail(id); |