Merge remote-tracking branch 'origin/test' into dev
This commit is contained in:
+2
-2
@@ -40,9 +40,9 @@ public class ContainerFeeDetailRepository {
|
||||
.eq(ContainerFeeDetailEntity::getId, feeId));
|
||||
}
|
||||
|
||||
public ContainerFeeDetailEntity find(long loadingPlanId, long feeId) {
|
||||
public ContainerFeeDetailEntity findByContainerBookingId(long containerBookingId, long feeId) {
|
||||
return mapper.selectOne(new LambdaQueryWrapper<ContainerFeeDetailEntity>()
|
||||
.eq(ContainerFeeDetailEntity::getLoadingPlanId, loadingPlanId)
|
||||
.eq(ContainerFeeDetailEntity::getContainerBookingId, containerBookingId)
|
||||
.eq(ContainerFeeDetailEntity::getId, feeId));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -49,10 +49,10 @@ public class ContainerFeeSourceSnapshotRepository {
|
||||
mapper.insert(value);
|
||||
}
|
||||
|
||||
public ContainerFeeSourceSnapshotEntity find(long loadingPlanId, long sourceFeeId,
|
||||
int sourceVersion) {
|
||||
public ContainerFeeSourceSnapshotEntity findByContainerBookingId(long containerBookingId, long sourceFeeId,
|
||||
int sourceVersion) {
|
||||
return mapper.selectOne(new LambdaQueryWrapper<ContainerFeeSourceSnapshotEntity>()
|
||||
.eq(ContainerFeeSourceSnapshotEntity::getLoadingPlanId, loadingPlanId)
|
||||
.eq(ContainerFeeSourceSnapshotEntity::getContainerBookingId, containerBookingId)
|
||||
.eq(ContainerFeeSourceSnapshotEntity::getSourceFeeId, sourceFeeId)
|
||||
.eq(ContainerFeeSourceSnapshotEntity::getSourceVersion, sourceVersion));
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class ContainerFeeDetailService {
|
||||
sourceSnapshots.saveApproved(approved);
|
||||
String eventType = approved.getSourceVersion() > 1
|
||||
? FinanceFeeSourceOutboxService.ADJUSTED : FinanceFeeSourceOutboxService.PUBLISHED;
|
||||
financeOutbox.publishContainer(eventType, tenantId, loadingPlanId, feeId,
|
||||
financeOutbox.publishContainer(eventType, tenantId, containerBookingId(approved), feeId,
|
||||
approved.getSourceVersion(), LocalDateTime.now());
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public class ContainerFeeDetailService {
|
||||
throw conflict("只有当前版本的已审核柜次费用可以作废");
|
||||
}
|
||||
financeOutbox.publishContainer(FinanceFeeSourceOutboxService.VOIDED, tenantId,
|
||||
loadingPlanId, feeId, expectedVersion, LocalDateTime.now());
|
||||
containerBookingId(current), feeId, expectedVersion, LocalDateTime.now());
|
||||
}
|
||||
|
||||
private PlanContext requireOwnedPlan(long tenantId, long loadingPlanId) {
|
||||
@@ -372,6 +372,13 @@ public class ContainerFeeDetailService {
|
||||
return new BizException(ResultCode.CONFLICT, message);
|
||||
}
|
||||
|
||||
private static long containerBookingId(ContainerFeeDetailEntity value) {
|
||||
if (value.getContainerBookingId() == null || value.getContainerBookingId() <= 0) {
|
||||
throw conflict("柜次费用缺少真实货柜关联");
|
||||
}
|
||||
return value.getContainerBookingId();
|
||||
}
|
||||
|
||||
private record PlanContext(LoadingPlanEntity plan, ContainerBookingEntity booking) {
|
||||
}
|
||||
private static String text(String value) { return value == null || value.isBlank() ? null : value.trim(); }
|
||||
|
||||
+4
-3
@@ -123,9 +123,10 @@ public class FinanceFeeSourceCommandService {
|
||||
}
|
||||
|
||||
private void voidContainer(VoidRequest request) {
|
||||
long containerId = positive(request.containerId(), "柜次ID");
|
||||
long containerBookingId = positive(request.containerId(), "柜次ID");
|
||||
if (request.inboundId() != null) throw bad("柜次费用不能携带入库单ID");
|
||||
ContainerFeeDetailEntity detail = containerFees.find(containerId, request.sourceFeeId());
|
||||
ContainerFeeDetailEntity detail = containerFees.findByContainerBookingId(
|
||||
containerBookingId, request.sourceFeeId());
|
||||
if (detail == null || !Long.valueOf(request.customerId()).equals(detail.getTenantId())) {
|
||||
throw new BizException(ResultCode.NOT_FOUND, "指定客户的柜次费用来源版本不存在");
|
||||
}
|
||||
@@ -133,7 +134,7 @@ public class FinanceFeeSourceCommandService {
|
||||
throw conflict("柜次费用来源版本已变化");
|
||||
}
|
||||
if ("VOIDED".equals(detail.getSourceStatus())) return;
|
||||
containerFeeService.voidApproved(request.customerId(), containerId,
|
||||
containerFeeService.voidApproved(request.customerId(), detail.getLoadingPlanId(),
|
||||
request.sourceFeeId(), request.sourceVersion(), request.operatorId());
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -36,11 +36,11 @@ public class FinanceFeeSourceOutboxService {
|
||||
payload, occurredAt));
|
||||
}
|
||||
|
||||
public void publishContainer(String eventType, long tenantId, long containerId,
|
||||
public void publishContainer(String eventType, long tenantId, long containerBookingId,
|
||||
long feeId, int feeVersion, LocalDateTime occurredAt) {
|
||||
FinanceFeeSourceEvent.Payload payload = new FinanceFeeSourceEvent.Payload(
|
||||
null, String.valueOf(containerId), String.valueOf(feeId), feeVersion);
|
||||
publish(event(eventType, tenantId, "CONTAINER", containerId, feeId, feeVersion,
|
||||
null, String.valueOf(containerBookingId), String.valueOf(feeId), feeVersion);
|
||||
publish(event(eventType, tenantId, "CONTAINER", containerBookingId, feeId, feeVersion,
|
||||
payload, occurredAt));
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -58,12 +58,13 @@ public class FinanceFeeSourceSnapshotService {
|
||||
detail.getActualGrossWeightKg(), detail.getActualVolumeCbm(), sha256(canonical), 1);
|
||||
}
|
||||
|
||||
public FinanceFeeSourceSnapshot container(long containerId, long feeId, int sourceVersion) {
|
||||
ContainerFeeSourceSnapshotEntity detail = containerSnapshots.find(containerId, feeId, sourceVersion);
|
||||
public FinanceFeeSourceSnapshot container(long containerBookingId, long feeId, int sourceVersion) {
|
||||
ContainerFeeSourceSnapshotEntity detail = containerSnapshots.findByContainerBookingId(
|
||||
containerBookingId, feeId, sourceVersion);
|
||||
if (detail == null) throw new BizException(ResultCode.NOT_FOUND, "柜次费用来源不存在");
|
||||
int version = detail.getSourceVersion();
|
||||
String canonical = String.join("|", "CONTAINER_FEE", String.valueOf(feeId),
|
||||
String.valueOf(version), String.valueOf(detail.getTenantId()), String.valueOf(containerId),
|
||||
String.valueOf(version), String.valueOf(detail.getTenantId()), String.valueOf(containerBookingId),
|
||||
nullSafe(detail.getFeeItemCode()), nullSafe(detail.getDirection()),
|
||||
nullSafe(detail.getSupplierId()), nullSafe(detail.getSupplierName()),
|
||||
nullSafe(detail.getSupplierCategory()),
|
||||
@@ -76,7 +77,8 @@ public class FinanceFeeSourceSnapshotService {
|
||||
detail.getAmount().toPlainString(), nullSafe(detail.getCurrency()),
|
||||
nullSafe(detail.getReviewStatus()));
|
||||
return new FinanceFeeSourceSnapshot(detail.getTenantId(), "CONTAINER_FEE", feeId,
|
||||
version, detail.getAllocationInboundId(), detail.getAllocationInboundCode(), detail.getAllocationOrderId(), containerId, detail.getContainerBookingId(),
|
||||
version, detail.getAllocationInboundId(), detail.getAllocationInboundCode(), detail.getAllocationOrderId(),
|
||||
containerBookingId, containerBookingId,
|
||||
detail.getContainerNo(), detail.getTenantId(), null, detail.getSupplierId(),
|
||||
detail.getSupplierName(), detail.getSupplierCategory(), detail.getSettlementMode(),
|
||||
detail.getPaidAt(), detail.getPaymentMethod(), detail.getPaymentReferenceNo(),
|
||||
|
||||
Reference in New Issue
Block a user