fix: expose phase2 terminal inbound billing

This commit is contained in:
2026-08-08 11:46:20 +08:00
parent ef4e1d6015
commit 0113d19274
8 changed files with 52 additions and 11 deletions
@@ -53,7 +53,8 @@ class InboundOrderControllerContractTest {
.contains("tenantId: {type: string, pattern: '^[1-9][0-9]*$', description:")
.contains("[WAIT_MEASURE, WAIT_REVIEW, WAIT_FEE_SEND, INBOUNDED]")
.contains("platform:firstleg:inbound:list")
.doesNotContain("WAIT_CUSTOMER_CONFIRM");
.doesNotContain("WAIT_CUSTOMER_CONFIRM")
.contains("WAIT_SPLIT");
assertThat(inboundList).contains("#/components/schemas/InboundOrderPageEnvelope");
assertThat(taskList).doesNotContain("InboundOrderPageEnvelope");
}
@@ -8,7 +8,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.core.io.ClassPathResource;
import java.nio.charset.StandardCharsets;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,6 +34,11 @@ class MerchantInboundBillingControllerContractTest {
.isEqualTo("hasAuthority('merchant:order:view')");
assertThat(MerchantInboundBillingController.class.getDeclaredMethods())
.noneMatch(candidate -> candidate.getName().toLowerCase().contains("confirm"));
String openapi = new ClassPathResource("openapi/firstleg-v1.yaml")
.getContentAsString(StandardCharsets.UTF_8);
assertThat(openapi).contains("/api/merchant/v1/first-leg/orders/{orderId}/inbound-billing:")
.contains("仅 WAIT_SPLIT + APPROVED + CONFIRMED 的二期终态可见");
}
@Test
@@ -40,6 +40,18 @@ class InboundOrderQueryServiceTest {
verify(repository).page(null, query);
}
@Test
void shouldAcceptCurrentPhase2TerminalStatusFilters() {
InboundOrderQuery query = new InboundOrderQuery(null, null, "WAIT_SPLIT", null,
"APPROVED", "CONFIRMED", null, null, null, null, null, null, null,
null, null, null, null, 1, 200);
PageResult<InboundOrderSummary> expected = new PageResult<>(List.of(), 1, 200, 0, 0);
when(repository.page(10001L, query)).thenReturn(expected);
assertThat(service.page(10001L, query)).isSameAs(expected);
verify(repository).page(10001L, query);
}
@Test
void shouldKeepV2TabMappingWithoutCustomerConfirmation() {
assertThat(InboundListTab.WAIT_MEASURE.processStatuses())
@@ -36,7 +36,7 @@ class MerchantInboundBillingServiceTest {
@Test
void shouldHandleCase01() {
InboundOrderEntity inbound = inbound("INBOUNDED", "SENT");
InboundOrderEntity inbound = inbound("WAIT_SPLIT", "APPROVED", "CONFIRMED");
InboundOrderDetail detail = new InboundOrderDetail(mock(com.baiyue.firstleg.dto.InboundOrderSummary.class),
"客户备注", List.of(), List.of(
new InboundOrderDetail.FileSummary(1L, "RELATED", "public.pdf", "PUBLIC", 1, 1L, null),
@@ -83,7 +83,7 @@ class MerchantInboundBillingServiceTest {
@Test
void shouldHandleCase02() {
InboundOrderEntity inbound = inbound("FEE_CONFIRMING", "CONFIRMED");
InboundOrderEntity inbound = inbound("WAIT_SPLIT", "PENDING", "CONFIRMED");
when(orders.findByOrderId(10001L, 77L)).thenReturn(inbound);
assertThatThrownBy(() -> service.find(10001L, 77L))
@@ -104,7 +104,7 @@ class MerchantInboundBillingServiceTest {
@Test
void shouldHandleCase04() {
InboundOrderEntity inbound = inbound("INBOUNDED", "SENT");
InboundOrderEntity inbound = inbound("WAIT_SPLIT", "APPROVED", "CONFIRMED");
InboundMeasurementResponses.Detail measurement = mock(InboundMeasurementResponses.Detail.class);
InboundMeasurementResponses.Item item = mock(InboundMeasurementResponses.Item.class);
when(item.intelligentImageFileId()).thenReturn(41L);
@@ -127,7 +127,7 @@ class MerchantInboundBillingServiceTest {
@Test
void shouldHandleCase05() {
InboundOrderEntity inbound = inbound("INBOUNDED", "SENT");
InboundOrderEntity inbound = inbound("WAIT_SPLIT", "APPROVED", "CONFIRMED");
InboundMeasurementResponses.Detail measurement = mock(InboundMeasurementResponses.Detail.class);
when(measurement.items()).thenReturn(List.of());
when(measurement.weightResults()).thenReturn(List.of());
@@ -140,10 +140,22 @@ class MerchantInboundBillingServiceTest {
verify(imageClient, never()).download("internal-token", 10001L, 88L, 99L);
}
private static InboundOrderEntity inbound(String process, String feeStatus) {
@Test
void shouldRejectHistoricalPublishedStatusCombination() {
InboundOrderEntity inbound = inbound("INBOUNDED", "APPROVED", "SENT");
when(orders.findByOrderId(10001L, 77L)).thenReturn(inbound);
assertThatThrownBy(() -> service.find(10001L, 77L))
.isInstanceOf(BizException.class)
.hasMessageContaining("尚未由客服审核并发布");
verify(pricing, never()).latest(10001L, 88L);
}
private static InboundOrderEntity inbound(String process, String reviewStatus, String feeStatus) {
InboundOrderEntity inbound = new InboundOrderEntity();
inbound.setId(88L);
inbound.setProcessStatus(process);
inbound.setMeasureReviewStatus(reviewStatus);
inbound.setFeeStatus(feeStatus);
return inbound;
}