This commit is contained in:
2026-10-28 14:44:59 +08:00
parent f3d57869f2
commit 71a1026e21
9 changed files with 92 additions and 3 deletions
@@ -17,7 +17,8 @@ class OverseasProcurementOpenApiContractTest {
}
String platform = "/api/platform/v1/last-leg/overseas-procurements/{orderNo}";
for (String suffix : new String[]{"/workflow:", "/receipts:", "/request-confirmation:",
"/outbounds:", "/outbounds/{batchId}/dispatch:", "/outbounds/{batchId}/complete:"}) {
"/outbounds:", "/outbounds/{batchId}:", "/outbounds/{batchId}/cancel:",
"/outbounds/{batchId}/dispatch:", "/outbounds/{batchId}/complete:"}) {
assertTrue(yaml.contains(platform + suffix), suffix);
}
String merchant = "/api/merchant/v1/last-leg/overseas-procurements/{orderNo}";
@@ -35,6 +35,8 @@ class ProcurementWorkflowAuthorizationTest {
controller.read(user,"9","CG-1");verify(service).read("9","CG-1");
assertThatThrownBy(()->controller.receive(user,"9","CG-1",new Receipt(0,"r",1,List.of(1L)))).isInstanceOf(AccessDeniedException.class);
assertThatThrownBy(()->controller.outbound(user,"9","CG-1",new Outbound(0,"o",1,"TN"))).isInstanceOf(AccessDeniedException.class);
assertThatThrownBy(()->controller.editOutbound(user,"9","CG-1",1,new OutboundEdit(0,"edit",1,"TN"))).isInstanceOf(AccessDeniedException.class);
assertThatThrownBy(()->controller.cancelOutbound(user,"9","CG-1",1,new Command(0,"cancel"))).isInstanceOf(AccessDeniedException.class);
}
@Test void receiverCanSubmitConfirmationButCannotShip() {
var controller=context.getBean(ProcurementWorkflowController.class);
@@ -126,7 +126,7 @@ class ProcurementWorkflowPersistenceTest {
assertThat(service.read("9","CG-1").stockQuantity()).isEqualTo(10);
}
@Test void outboundDoesNotRequireFeeDetailsOrApproval() {
@Test void outboundCanBeEditedOrCancelledBeforeDispatchButNotAfter() {
tx.execute(s->service.receive("9","CG-1","7",new Receipt(0,"r",10,List.of(101L))));
tx.execute(s->service.requestConfirmation("9","CG-1","7",new Command(1,"ask")));
tx.execute(s->service.confirm("9","CG-1","8",new Command(2,"ok")));
@@ -134,6 +134,21 @@ class ProcurementWorkflowPersistenceTest {
var result=tx.execute(s->service.outbound("9","CG-1","7",request));
assertThat(result.reservedQuantity()).isEqualTo(3);
assertThat(result.outbounds()).hasSize(1);
long batch=result.outbounds().get(0).id();
var edited=tx.execute(s->service.editOutbound("9","CG-1",batch,"7",new OutboundEdit(4,"edit",4,"TRACK-EDIT")));
assertThat(edited.outbounds().get(0).quantity()).isEqualTo(4);
assertThat(edited.outbounds().get(0).trackingNo()).isEqualTo("TRACK-EDIT");
var cancelled=tx.execute(s->service.cancelOutbound("9","CG-1",batch,"7",new Command(5,"cancel")));
assertThat(cancelled.outbounds().get(0).status()).isEqualTo("CANCELLED");
assertThat(cancelled.reservedQuantity()).isZero();
assertThat(cancelled.availableQuantity()).isEqualTo(10);
var next=tx.execute(s->service.outbound("9","CG-1","7",new Outbound(6,"out2",3,"TRACK-2")));
long activeBatch=next.outbounds().stream().filter(row->"IN_TRANSIT".equals(row.status())).findFirst().orElseThrow().id();
tx.execute(s->service.dispatch("9","CG-1",activeBatch,"7",new Command(7,"dispatch")));
assertThatThrownBy(()->tx.execute(s->service.editOutbound("9","CG-1",activeBatch,"7",new OutboundEdit(8,"edit-late",2,"TRACK-LATE"))))
.hasMessageContaining("开始派送后");
assertThatThrownBy(()->tx.execute(s->service.cancelOutbound("9","CG-1",activeBatch,"7",new Command(8,"cancel-late"))))
.hasMessageContaining("开始派送后");
}
private void file(long id,long orderId,String customer,String type) {