优化
This commit is contained in:
@@ -9,9 +9,11 @@ import java.util.List;
|
||||
|
||||
@FeignClient(name="firstleg-service", contextId="financeFirstlegCostSnapshotClient", url="${baiyue.clients.firstleg.url:}", path="/internal/firstleg/v1/finance-cost-snapshots")
|
||||
public interface FirstlegCostSnapshotClient {
|
||||
@GetMapping("/customers/{customerId}/containers/{containerId}")
|
||||
ApiResponse<ContainerSnapshot> container(@RequestHeader("X-Internal-Service-Token") String token,
|
||||
@PathVariable long customerId, @PathVariable long containerId);
|
||||
record ContainerSnapshot(long containerId, long customerId, List<OrderVolume> orders) {}
|
||||
@GetMapping("/customers/{customerId}/loading-plans/{loadingPlanId}")
|
||||
ApiResponse<ContainerSnapshot> loadingPlan(@RequestHeader("X-Internal-Service-Token") String token,
|
||||
@PathVariable long customerId,
|
||||
@PathVariable long loadingPlanId);
|
||||
record ContainerSnapshot(long loadingPlanId, long containerBookingId, long customerId,
|
||||
List<OrderVolume> orders) {}
|
||||
record OrderVolume(long orderId, Long inboundId, BigDecimal volumeCbm) {}
|
||||
}
|
||||
|
||||
@@ -175,12 +175,20 @@ public class PlatformFinanceController {
|
||||
java.util.List<FinanceService.ContainerOrderVolume> volumes = java.util.List.of();
|
||||
if ("CONTAINER_SHARED".equals(request.costType())) {
|
||||
if (request.containerId() == null) throw new IllegalArgumentException("整柜成本必须指定柜次");
|
||||
var response = costSnapshotClient.container(fileToken, request.customerId(), request.containerId());
|
||||
var response = costSnapshotClient.loadingPlan(fileToken, request.customerId(), request.containerId());
|
||||
var snapshot = response == null ? null : response.data();
|
||||
if (snapshot == null || snapshot.customerId() != request.customerId() || snapshot.containerId() != request.containerId() || snapshot.orders() == null || snapshot.orders().isEmpty()) {
|
||||
if (response == null || !response.successful()) {
|
||||
throw new IllegalArgumentException(response == null || response.message() == null
|
||||
? "Firstleg柜内订单体积快照不可用" : response.message());
|
||||
}
|
||||
if (snapshot == null || snapshot.customerId() != request.customerId()
|
||||
|| snapshot.loadingPlanId() != request.containerId()
|
||||
|| snapshot.containerBookingId() <= 0
|
||||
|| snapshot.orders() == null || snapshot.orders().isEmpty()) {
|
||||
throw new IllegalArgumentException("Firstleg未返回有效柜内订单体积快照");
|
||||
}
|
||||
volumes = snapshot.orders().stream().map(v -> new FinanceService.ContainerOrderVolume(v.orderId(), v.inboundId(), snapshot.containerId(), snapshot.customerId(), v.volumeCbm())).toList();
|
||||
volumes = snapshot.orders().stream().map(v -> new FinanceService.ContainerOrderVolume(v.orderId(),
|
||||
v.inboundId(), snapshot.loadingPlanId(), snapshot.customerId(), v.volumeCbm())).toList();
|
||||
}
|
||||
return FinanceResponses.success(resourceView(service.createCost(request.customerId(), user.userId(), internal, volumes, key)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user