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");
@@ -18,8 +18,11 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import java.math.BigDecimal;
import java.lang.reflect.Method;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
@SpringJUnitConfig(InternalOrderCargoController.class)
@TestPropertySource(properties = "baiyue.security.internal-service-token=internal-token")
class InternalOrderCargoControllerTest {
@@ -149,6 +152,21 @@ class InternalOrderCargoControllerTest {
assertThat(result.defaultActualGoodsName()).isEqualTo("品名A、品名B");
}
@Test
void measurementDeclarationHasAnExplicitStaticRouteBesideNumericCargoDetail() throws Exception {
Method declaration = InternalOrderCargoController.class.getMethod(
"measurementDeclaration", String.class, long.class, long.class);
Method cargoDetail = InternalOrderCargoController.class.getMethod(
"detail", String.class, long.class, long.class, long.class);
assertThat(declaration.getAnnotation(GetMapping.class).value())
.containsExactly("/{tenantId}/{orderId}/measurement-declaration");
assertThat(cargoDetail.getAnnotation(GetMapping.class).value())
.containsExactly("/{tenantId}/{orderId}/{cargoId}");
assertThat(declaration.getParameterCount()).isEqualTo(3);
assertThat(cargoDetail.getParameterCount()).isEqualTo(4);
}
@Test
void splitChildWithoutDirectCargoDoesNotCopyRootDeclarationTotals() {
OrderEntity child = new OrderEntity();