fix: prevent duplicate delivery assignments

This commit is contained in:
王鹏
2026-07-07 17:52:54 +08:00
parent c4b32da54d
commit 060051cb44
2 changed files with 23 additions and 0 deletions

View File

@@ -69,6 +69,18 @@ class DeliveryAssignmentServiceTests {
.hasMessageContaining("自提订单无需派单");
}
@Test
void cannotAssignSameGoodsOrderTwice() {
TestFixture fixture = new TestFixture();
GoodsOrderResponse order = fixture.preparedDeliveryOrder();
DeliveryUserResponse rider = fixture.rider();
fixture.assignmentService.assignGoodsOrder(order.getId(), rider.getId());
assertThatThrownBy(() -> fixture.assignmentService.assignGoodsOrder(order.getId(), rider.getId()))
.hasMessageContaining("订单已派单");
}
private static class TestFixture {
private final ProductService productService = new ProductService();
private final GoodsOrderService goodsOrderService = new GoodsOrderService(productService);