优化
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)));
|
||||
}
|
||||
|
||||
@@ -65,6 +65,13 @@ CREATE TABLE IF NOT EXISTS fin_subject (
|
||||
UNIQUE KEY uk_fin_subject_code (subject_code)
|
||||
) ENGINE=InnoDB COMMENT='平台财务主体;首期仅一个有效主体';
|
||||
|
||||
INSERT INTO fin_subject
|
||||
(subject_code, subject_name, status, version, created_by, updated_by)
|
||||
VALUES
|
||||
('PLATFORM_DEFAULT', '平台', 'ACTIVE', 0, 0, 0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
subject_name = VALUES(subject_name), status = 'ACTIVE', updated_by = 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fin_customer_settlement_profile (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
tenant_id BIGINT UNSIGNED NOT NULL COMMENT '客户ID和数据隔离键',
|
||||
|
||||
Reference in New Issue
Block a user