This commit is contained in:
2026-08-18 11:44:39 +08:00
parent ec4b1e0fe5
commit cad9a81d21
3 changed files with 45 additions and 0 deletions
@@ -466,6 +466,10 @@ public class InboundMeasurementService {
}
return response.data();
} catch (FeignException exception) {
if (exception.status() == 400) {
throw new BizException(ResultCode.SERVICE_UNAVAILABLE,
"订单服务申报快照契约未就绪,请同步部署 order-service 与 firstleg-service");
}
throw new BizException(ResultCode.SERVICE_UNAVAILABLE, "订单服务暂不可用,无法读取客户申报数据");
}
}
@@ -29,6 +29,8 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import feign.FeignException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
@@ -147,6 +149,27 @@ class InboundMeasurementServiceTest {
verify(repository, never()).updateInbound(any());
}
@Test
void detailReportsOrderContractNotReadyInsteadOfExposingDownstreamBadRequest() {
InboundOrderEntity inbound = inbound("MEASURE_PENDING");
InboundMeasurementEntity measurement = new InboundMeasurementEntity();
measurement.setId(30L);
when(repository.findInbound(1L, 10L)).thenReturn(inbound);
when(repository.findLatestMeasurement(1L, 10L)).thenReturn(measurement);
FeignException downstreamBadRequest = mock(FeignException.class);
when(downstreamBadRequest.status()).thenReturn(400);
when(orderCargoClient.measurementDeclaration("internal-token", 1L, 80L))
.thenThrow(downstreamBadRequest);
assertThatThrownBy(() -> service.detail(1L, 10L))
.isInstanceOfSatisfying(BizException.class, exception -> {
assertThat(exception.getResultCode().code()).isEqualTo("S0503");
assertThat(exception).hasMessageContaining("申报快照契约未就绪")
.hasMessageContaining("order-service")
.hasMessageContaining("firstleg-service");
});
}
@Test
void detailKeepsDimensionAndWeightEvidenceOnTheirStableBusinessRecords() {
InboundOrderEntity inbound = inbound("MEASURE_PENDING");