|  | @@ -161,6 +161,41 @@ public class SaleDeliveryServiceImpl extends ServiceImpl<SaleDeliveryMapper, Sal
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public void delMain(String id) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<SaleDeliveryDetails> detailsList = saleDeliveryDetailsMapper.selectByMainId(id);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (detailsList != null && detailsList.size() > 0) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (SaleDeliveryDetails entity : detailsList) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                String sourceId = entity.getSourceId();
 | 
	
		
			
				|  |  | +                if (StringUtils.isNotBlank(sourceId)) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    BigDecimal deliveryQuantity = entity.getDeliveryQuantity() == null ? BigDecimal.ZERO : entity.getDeliveryQuantity();//入库数量
 | 
	
		
			
				|  |  | +                    SaleOrderProduct arrival = saleOrderProductMapper.selectById(sourceId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    if (arrival != null) {
 | 
	
		
			
				|  |  | +                        BigDecimal arrivalQuantity = arrival.getDeliveryQuantity() == null ? BigDecimal.ZERO : arrival.getDeliveryQuantity();//到货数量
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        arrivalQuantity = arrivalQuantity.subtract(deliveryQuantity);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        if (arrivalQuantity.compareTo(BigDecimal.ZERO) < 1) {
 | 
	
		
			
				|  |  | +                            arrival.setDeliveryQuantity(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            arrival.setDeliveryQuantity(arrivalQuantity);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        saleOrderProductMapper.updateById(arrival);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          saleDeliveryShipMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  |          saleDeliveryDetailsMapper.deleteByMainId(id);
 | 
	
		
			
				|  |  |          saleDeliveryMapper.deleteById(id);
 | 
	
	
		
			
				|  | @@ -170,6 +205,40 @@ public class SaleDeliveryServiceImpl extends ServiceImpl<SaleDeliveryMapper, Sal
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public void delBatchMain(Collection<? extends Serializable> idList) {
 | 
	
		
			
				|  |  |          for (Serializable id : idList) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<SaleDeliveryDetails> detailsList = saleDeliveryDetailsMapper.selectByMainId(id.toString());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (detailsList != null && detailsList.size() > 0) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                for (SaleDeliveryDetails entity : detailsList) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    String sourceId = entity.getSourceId();
 | 
	
		
			
				|  |  | +                    if (StringUtils.isNotBlank(sourceId)) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        BigDecimal deliveryQuantity = entity.getDeliveryQuantity() == null ? BigDecimal.ZERO : entity.getDeliveryQuantity();//入库数量
 | 
	
		
			
				|  |  | +                        SaleOrderProduct arrival = saleOrderProductMapper.selectById(sourceId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        if (arrival != null) {
 | 
	
		
			
				|  |  | +                            BigDecimal arrivalQuantity = arrival.getDeliveryQuantity() == null ? BigDecimal.ZERO : arrival.getDeliveryQuantity();//到货数量
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            arrivalQuantity = arrivalQuantity.subtract(deliveryQuantity);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            if (arrivalQuantity.compareTo(BigDecimal.ZERO) < 1) {
 | 
	
		
			
				|  |  | +                                arrival.setDeliveryQuantity(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +                            } else {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                                arrival.setDeliveryQuantity(arrivalQuantity);
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            saleOrderProductMapper.updateById(arrival);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              saleDeliveryShipMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  |              saleDeliveryDetailsMapper.deleteByMainId(id.toString());
 | 
	
		
			
				|  |  |              saleDeliveryMapper.deleteById(id);
 |