fix(order): align FBA submit and fee confirmation

This commit is contained in:
2026-09-14 17:19:06 +08:00
parent e0af45db02
commit 8a1e587ee4
13 changed files with 103 additions and 12 deletions
@@ -10,6 +10,7 @@ import com.baiyue.firstleg.entity.CustomerChargeRuleEntity;
import com.baiyue.firstleg.entity.CarrierFbaRateEntity;
import com.baiyue.firstleg.entity.InboundPricingIdempotencyEntity;
import com.baiyue.firstleg.entity.InboundPricingEntity;
import com.baiyue.firstleg.entity.InboundFeeEntity;
import com.baiyue.firstleg.mapper.CarrierFbaRateMapper;
import com.baiyue.firstleg.mapper.CustomerChargeRuleMapper;
import com.baiyue.firstleg.mapper.ContainerTierPricingMapper;
@@ -30,6 +31,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -58,6 +60,8 @@ class FbaPricingRepositoryRuleListTest {
CarrierFbaRateEntity.class);
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new Configuration(), "test"),
InboundPricingEntity.class);
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new Configuration(), "test"),
InboundFeeEntity.class);
}
@Test
@@ -204,6 +208,29 @@ class FbaPricingRepositoryRuleListTest {
.contains("List.of(\"FEE_CONFIRMING\", \"WAIT_PALLET\", \"WAIT_SPLIT\", \"LOADING\", \"LOADED\", \"DELIVERED\")");
}
@Test
void customerFeeConfirmationIsRequiredOnlyForLatestUnconfirmedSentFee() {
InboundFeeEntity waiting = new InboundFeeEntity();
waiting.setId(12L);
waiting.setTenantId(10001L);
waiting.setInboundId(88L);
waiting.setFeeVersion(2);
waiting.setFeeStatus("SENT");
InboundFeeEntity confirmed = new InboundFeeEntity();
confirmed.setId(22L);
confirmed.setTenantId(10001L);
confirmed.setInboundId(99L);
confirmed.setFeeVersion(1);
confirmed.setFeeStatus("SENT");
confirmed.setCustomerConfirmedAt(java.time.LocalDateTime.now());
when(fees.selectList(org.mockito.ArgumentMatchers.any())).thenReturn(List.of(waiting, confirmed));
assertThat(repository.customerFeeConfirmationRequiredMap(
10001L, Map.of(88L, 10001L, 99L, 10001L)))
.containsEntry(88L, true)
.containsEntry(99L, false);
}
@Test
void dropshipInitialPricingPreservesWaitingForPalletization() {
when(pricing.update(org.mockito.ArgumentMatchers.isNull(), org.mockito.ArgumentMatchers.any()))
@@ -5,6 +5,7 @@ import com.baiyue.firstleg.dto.InboundOrderDetail;
import com.baiyue.firstleg.dto.UnifiedInboundDetail;
import com.baiyue.firstleg.dto.UnifiedInboundQuery;
import com.baiyue.firstleg.entity.InboundOrderEntity;
import com.baiyue.firstleg.repository.FbaPricingRepository;
import com.baiyue.firstleg.repository.InboundOrderRepository;
import com.baiyue.firstleg.repository.UnifiedInboundReadRepository;
import org.junit.jupiter.api.Test;
@@ -91,9 +92,11 @@ class UnifiedInboundQueryServiceTest {
void phaseTwoDetailDoesNotQueryPhaseThreeTables(String processStatus) {
InboundOrderRepository inbounds = mock(InboundOrderRepository.class);
UnifiedInboundReadRepository operations = mock(UnifiedInboundReadRepository.class);
FbaPricingRepository pricing = mock(FbaPricingRepository.class);
UnifiedInboundQueryService service = new UnifiedInboundQueryService();
ReflectionTestUtils.setField(service, "inbounds", inbounds);
ReflectionTestUtils.setField(service, "operations", operations);
ReflectionTestUtils.setField(service, "pricing", pricing);
InboundOrderEntity inbound = new InboundOrderEntity();
inbound.setId(88L);
@@ -103,10 +106,13 @@ class UnifiedInboundQueryServiceTest {
InboundOrderDetail detail = new InboundOrderDetail(null, null, null, null, null, List.of());
when(inbounds.findByOrderId(10001L, 99L)).thenReturn(inbound);
when(inbounds.detail(10001L, inbound)).thenReturn(detail);
when(pricing.customerFeeConfirmationRequiredMap(10001L, Map.of(88L, 10001L)))
.thenReturn(Map.of(88L, true));
UnifiedInboundDetail result = service.detail(10001L, 99L);
assertThat(result).isNotNull();
assertThat(result.summary().customerFeeConfirmationRequired()).isTrue();
verifyNoInteractions(operations);
}