fix(firstleg): keep published billing visible after loading
This commit is contained in:
+5
-1
@@ -9,6 +9,7 @@ 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 io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
@@ -32,13 +33,16 @@ class MerchantInboundBillingControllerContractTest {
|
||||
"find", AuthenticatedUser.class, long.class);
|
||||
assertThat(method.getAnnotation(PreAuthorize.class).value())
|
||||
.isEqualTo("hasAuthority('merchant:order:view')");
|
||||
assertThat(method.getAnnotation(Operation.class).description())
|
||||
.contains("WAIT_SPLIT", "LOADING", "LOADED", "DELIVERED", "APPROVED + CONFIRMED", "已发布入库运费明细");
|
||||
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");
|
||||
.contains("WAIT_SPLIT", "LOADING、LOADED、DELIVERED", "measureReviewStatus=APPROVED",
|
||||
"feeStatus=CONFIRMED", "PUBLISHED 入库运费明细");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+33
-3
@@ -10,6 +10,8 @@ import com.baiyue.firstleg.entity.InboundFeeDetailEntity;
|
||||
import com.baiyue.firstleg.repository.InboundOrderRepository;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
@@ -34,9 +36,10 @@ class MerchantInboundBillingServiceTest {
|
||||
@MockBean private InboundFeeDetailService feeDetails;
|
||||
@Resource private MerchantInboundBillingService service;
|
||||
|
||||
@Test
|
||||
void shouldHandleCase01() {
|
||||
InboundOrderEntity inbound = inbound("WAIT_SPLIT", "APPROVED", "CONFIRMED");
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"WAIT_SPLIT", "LOADING", "LOADED", "DELIVERED"})
|
||||
void shouldKeepPublishedBillingVisibleAfterFulfillmentProgresses(String processStatus) {
|
||||
InboundOrderEntity inbound = inbound(processStatus, "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),
|
||||
@@ -151,6 +154,33 @@ class MerchantInboundBillingServiceTest {
|
||||
verify(pricing, never()).latest(10001L, 88L);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"FEE_CONFIRMING", "VOIDED"})
|
||||
void shouldRejectProcessStatusesOutsidePublishedFulfillmentLifecycle(String processStatus) {
|
||||
InboundOrderEntity inbound = inbound(processStatus, "APPROVED", "CONFIRMED");
|
||||
when(orders.findByOrderId(10001L, 77L)).thenReturn(inbound);
|
||||
|
||||
assertThatThrownBy(() -> service.find(10001L, 77L))
|
||||
.isInstanceOf(BizException.class)
|
||||
.hasMessageContaining("尚未由客服审核并发布");
|
||||
verify(feeDetails, never()).publishedFreight(10001L, 88L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRequirePublishedFreightDetailAfterLoadingCompletes() {
|
||||
InboundOrderEntity inbound = inbound("LOADED", "APPROVED", "CONFIRMED");
|
||||
when(orders.findByOrderId(10001L, 77L)).thenReturn(inbound);
|
||||
when(feeDetails.publishedFreight(10001L, 88L))
|
||||
.thenThrow(new BizException(com.baiyue.common.core.api.ResultCode.NOT_FOUND,
|
||||
"入库运费明细尚未发布"));
|
||||
|
||||
assertThatThrownBy(() -> service.find(10001L, 77L))
|
||||
.isInstanceOf(BizException.class)
|
||||
.hasMessageContaining("运费明细尚未发布");
|
||||
verify(orders, never()).detail(10001L, inbound);
|
||||
verify(pricing, never()).latest(10001L, 88L);
|
||||
}
|
||||
|
||||
private static InboundOrderEntity inbound(String process, String reviewStatus, String feeStatus) {
|
||||
InboundOrderEntity inbound = new InboundOrderEntity();
|
||||
inbound.setId(88L);
|
||||
|
||||
Reference in New Issue
Block a user