|
@@ -64,6 +64,7 @@ import jakarta.annotation.Resource;
|
|
|
import jakarta.validation.Valid;
|
|
import jakarta.validation.Valid;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -2902,6 +2903,7 @@ public class KwtLogisticsConsignmentService {
|
|
|
throw new BusinessException("未找到该物流订单信息");
|
|
throw new BusinessException("未找到该物流订单信息");
|
|
|
}
|
|
}
|
|
|
List<KwtLogisticsOrder> logisticsOrders = Lists.newArrayList();
|
|
List<KwtLogisticsOrder> logisticsOrders = Lists.newArrayList();
|
|
|
|
|
+ Set<Long> tradeIds = Sets.newHashSet();
|
|
|
logisticsOrder.forEach(x->{
|
|
logisticsOrder.forEach(x->{
|
|
|
KwtLogisticsOrder updateLogisticsOrder = new KwtLogisticsOrder();
|
|
KwtLogisticsOrder updateLogisticsOrder = new KwtLogisticsOrder();
|
|
|
updateLogisticsOrder.setId(x.getId());
|
|
updateLogisticsOrder.setId(x.getId());
|
|
@@ -2912,6 +2914,7 @@ public class KwtLogisticsConsignmentService {
|
|
|
if (Objects.equals(x.getStatus(), LogisticsOrderV1Enum.WAIT_DELIVERY.getCode())){
|
|
if (Objects.equals(x.getStatus(), LogisticsOrderV1Enum.WAIT_DELIVERY.getCode())){
|
|
|
updateLogisticsOrder.setStatus(LogisticsOrderV1Enum.HAVE_RECONCILED.getCode());
|
|
updateLogisticsOrder.setStatus(LogisticsOrderV1Enum.HAVE_RECONCILED.getCode());
|
|
|
logisticsOrders.add(updateLogisticsOrder);
|
|
logisticsOrders.add(updateLogisticsOrder);
|
|
|
|
|
+ tradeIds.add(x.getTOrderId());
|
|
|
return;
|
|
return;
|
|
|
// return logisticsOrderRepository.updateLogisticsOrder(updateLogisticsOrder);
|
|
// return logisticsOrderRepository.updateLogisticsOrder(updateLogisticsOrder);
|
|
|
}
|
|
}
|
|
@@ -2928,17 +2931,62 @@ public class KwtLogisticsConsignmentService {
|
|
|
}else {
|
|
}else {
|
|
|
updateLogisticsOrder.setStatus(LogisticsOrderV1Enum.HAVE_RECONCILED.getCode());
|
|
updateLogisticsOrder.setStatus(LogisticsOrderV1Enum.HAVE_RECONCILED.getCode());
|
|
|
logisticsOrders.add(updateLogisticsOrder);
|
|
logisticsOrders.add(updateLogisticsOrder);
|
|
|
|
|
+ tradeIds.add(x.getTOrderId());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- Map<Long, List<KwtLogisticsOrder>> tradeOrderIdAndLogisticsOrdersMap = logisticsOrders.stream()
|
|
|
|
|
- .filter(x -> Objects.equals(x.getStatus(), LogisticsOrderV1Enum.HAVE_RECONCILED.getCode()))
|
|
|
|
|
|
|
+ //更新物流订单
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(logisticsOrders)){
|
|
|
|
|
+ log.info("没有需要更新的物流订单");
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ logisticsOrderRepository.updateBatchById(logisticsOrders);
|
|
|
|
|
+
|
|
|
|
|
+ //更新贸易订单数据
|
|
|
|
|
+ updateTradeOrder(tradeIds);
|
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void updateTradeOrder(Set<Long> tradeIds) {
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(tradeIds)){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<KwtLogisticsOrder> tradeOrderInfos = logisticsOrderRepository.queryByTradeOrderIds(tradeIds);
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(tradeOrderInfos)){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<Long, List<KwtLogisticsOrder>> tradeOrderIdAndLogisticsOrdersMap = tradeOrderInfos.stream()
|
|
|
.collect(Collectors.groupingBy(KwtLogisticsOrder::getTOrderId));
|
|
.collect(Collectors.groupingBy(KwtLogisticsOrder::getTOrderId));
|
|
|
- tradeOrderIdAndLogisticsOrdersMap.forEach((tradeOrderId,orders)->{
|
|
|
|
|
- //todo cxf 通知贸易订单完成
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ //通知订贸易订单完结订单
|
|
|
|
|
+ if (MapUtils.isNotEmpty(tradeOrderIdAndLogisticsOrdersMap)){
|
|
|
|
|
|
|
|
- return logisticsOrderRepository.updateBatchById(logisticsOrders);
|
|
|
|
|
|
|
+ tradeOrderIdAndLogisticsOrdersMap
|
|
|
|
|
+ .forEach((tradeOrderId,orders)->noticeTrader(tradeOrderId, orders));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void noticeTrader(Long tradeOrderId, List<KwtLogisticsOrder> orders) {
|
|
|
|
|
+ boolean b = orders.stream()
|
|
|
|
|
+ .allMatch(x -> Arrays.asList(LogisticsOrderV1Enum.HAVE_RECONCILED.getCode(), LogisticsOrderV1Enum.REJECT_ORDER.getCode())
|
|
|
|
|
+ .contains(x.getStatus()));
|
|
|
|
|
+ if (!b){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ TradeOrderSettlePara tradeOrderSettlePara = new TradeOrderSettlePara();
|
|
|
|
|
+
|
|
|
|
|
+ tradeOrderSettlePara.setTOrderId(tradeOrderId);
|
|
|
|
|
+ BigDecimal loadAmount = orders.stream()
|
|
|
|
|
+ .filter(x -> Objects.nonNull(x.getLoadAmount()))
|
|
|
|
|
+ .map(KwtLogisticsOrder::getLoadAmount)
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ BigDecimal unloadAmount = orders.stream()
|
|
|
|
|
+ .filter(x -> Objects.nonNull(x.getUnloadAmount()))
|
|
|
|
|
+ .map(KwtLogisticsOrder::getUnloadAmount)
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ tradeOrderSettlePara.setLoadAmount(loadAmount);
|
|
|
|
|
+ tradeOrderSettlePara.setUnloadAmount(unloadAmount);
|
|
|
|
|
+ log.info("物流订单-完结修改贸易订单参数信息:{}", JSONObject.toJSONString(tradeOrderSettlePara));
|
|
|
|
|
+ tradeOrderInfoService.orderSettle(tradeOrderSettlePara);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|