| | |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.procurementrecord.bean.vo.ShippingProductVo; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.sales.dto.SalesLedgerProductDto; |
| | | import com.ruoyi.sales.dto.ShippingApproveDto; |
| | | import com.ruoyi.sales.dto.ShippingInfoDto; |
| | | import com.ruoyi.sales.dto.ShippingProductDetailDto; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.mapper.ShippingProductDetailMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.pojo.ShippingProductDetail; |
| | | import com.ruoyi.sales.service.ShippingInfoService; |
| | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | if (CollectionUtils.isEmpty(shippingInfos)) return false; |
| | | // 删除附件 |
| | | commonFileService.deleteByBusinessIds(ids, FileNameType.SHIP.getValue()); |
| | | // 扣已发货库存 |
| | | for (ShippingInfo shippingInfo : shippingInfos) { |
| | | if ("已发货".equals(shippingInfo.getStatus())) { |
| | | stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode()); |
| | | } |
| | | } |
| | | // 删除发货审批 |
| | | if (CollectionUtils.isNotEmpty(shippingInfos)) { |
| | | for (ShippingInfo shippingInfo : shippingInfos) { |
| | |
| | | List<Long> list = one.stream().map(ApproveProcess::getId).toList(); |
| | | approveProcessService.delByIds(list); |
| | | } |
| | | // 扣已发货库存 |
| | | stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode()); |
| | | } |
| | | } |
| | | //删除发货明细 |
| | |
| | | |
| | | @Override |
| | | public boolean add(ShippingInfoDto req) { |
| | | if (CollectionUtils.isEmpty(req.getBatchNoDetailList())) { |
| | | throw new RuntimeException("发货明细不能为空"); |
| | | } |
| | | // normalizeShippingQuantity(req.getBatchNoDetailList(), req.getSalesLedgerProductId()); |
| | | this.save(req); |
| | | req.getBatchNoDetailList().forEach(item -> item.setShippingInfoId(req.getId())); |
| | | shippingProductDetailMapper.insert(req.getBatchNoDetailList()); |
| | |
| | | shippingApproveDto.setShippingProductDetailDtoList(dateilByShippingNo); |
| | | return shippingApproveDto; |
| | | } |
| | | |
| | | /** |
| | | * 正常化发货数量 |
| | | * @param shippingProductDetails |
| | | * @param salesLedgerProductId |
| | | */ |
| | | private void normalizeShippingQuantity(List<ShippingProductDetail> shippingProductDetails, Long salesLedgerProductId) { |
| | | if (CollectionUtils.isEmpty(shippingProductDetails)) { |
| | | return; |
| | | } |
| | | BigDecimal singleQuantity = BigDecimal.ONE; |
| | | if (salesLedgerProductId != null) { |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(salesLedgerProductId); |
| | | if (salesLedgerProduct != null && salesLedgerProduct.getSingleQuantity() != null |
| | | && salesLedgerProduct.getSingleQuantity().compareTo(BigDecimal.ZERO) > 0) { |
| | | singleQuantity = salesLedgerProduct.getSingleQuantity(); |
| | | } |
| | | } |
| | | if (singleQuantity.compareTo(BigDecimal.ONE) == 0) { |
| | | return; |
| | | } |
| | | for (ShippingProductDetail shippingProductDetail : shippingProductDetails) { |
| | | if (shippingProductDetail.getQuantity() != null) { |
| | | shippingProductDetail.setQuantity(shippingProductDetail.getQuantity().multiply(singleQuantity)); |
| | | } |
| | | } |
| | | } |
| | | } |