优化
This commit is contained in:
@@ -141,11 +141,21 @@ public class OrderFulfillmentSplitService {
|
||||
child.setDestinationWarehouseName(root.getDestinationWarehouseName()); child.setReceivingWarehouseId(root.getReceivingWarehouseId());
|
||||
child.setReceivingWarehouseName(root.getReceivingWarehouseName()); child.setChannelCode(root.getChannelCode());
|
||||
child.setChannelName(root.getChannelName()); child.setDestinationType(root.getDestinationType());
|
||||
child.setInboundCode(remainderInboundCode(root, sequence));
|
||||
child.setCreatedBy(operatorId); child.setUpdatedBy(operatorId);
|
||||
if (orders.insert(child) != 1) throw new BizException(ResultCode.CONFLICT, "余量子订单创建失败");
|
||||
return child;
|
||||
}
|
||||
|
||||
private String remainderInboundCode(OrderEntity root, int sequence) {
|
||||
String rootInboundCode = Optional.ofNullable(root.getInboundCode()).orElse("").trim();
|
||||
String childInboundCode = rootInboundCode + "-" + sequence;
|
||||
if (rootInboundCode.isEmpty() || sequence < 1 || childInboundCode.length() > 40) {
|
||||
throw new BizException(ResultCode.CONFLICT, "根订单入仓码格式无效,无法创建余量子订单");
|
||||
}
|
||||
return childInboundCode;
|
||||
}
|
||||
|
||||
private OrderFulfillmentSplitEntity ledger(OrderSplitDtos.CreateRequest r, OrderEntity root, OrderEntity source,
|
||||
long childId, String role, String hash, long operatorId) {
|
||||
OrderFulfillmentSplitEntity row = new OrderFulfillmentSplitEntity();
|
||||
|
||||
@@ -621,7 +621,7 @@ components:
|
||||
success: {type: boolean}
|
||||
orderId: {type: string, pattern: '^[1-9][0-9]*$'}
|
||||
orderNo: {type: string}
|
||||
inboundCode: {type: string, pattern: '^[A-Z]{4,6}[0-9]{10,}$', example: ZBYHK2608140001}
|
||||
inboundCode: {type: string, pattern: '^[A-Z]{4,6}[0-9]{10,}(?:-[1-9][0-9]*)?$', example: ZBYHK2608140001, description: 根订单使用渠道前缀+业务日期+全局票序;履约拆分产生的余量子订单追加根范围 splitSequence 后缀,如 ZBYHK2608140001-1}
|
||||
errorCode: {type: string}
|
||||
errorMessage: {type: string}
|
||||
FirstLegOrderCargo:
|
||||
|
||||
@@ -53,6 +53,11 @@ class OrderFulfillmentSplitServiceTest {
|
||||
assertThat(response.loadedChild().sourceOrderId()).isEqualTo(100L);
|
||||
assertThat(response.loadedChild().loadingPlanId()).isEqualTo(701L);
|
||||
assertThat(response.remainderChild().containerBookingId()).isEqualTo(801L);
|
||||
ArgumentCaptor<OrderEntity> childOrder = ArgumentCaptor.forClass(OrderEntity.class);
|
||||
verify(orders).insert(childOrder.capture());
|
||||
assertThat(childOrder.getValue().getInboundCode())
|
||||
.isEqualTo("ZBYHK2608170001-1")
|
||||
.isNotEqualTo(parent.getInboundCode());
|
||||
ArgumentCaptor<OrderFulfillmentSplitEntity> rows = ArgumentCaptor.forClass(OrderFulfillmentSplitEntity.class);
|
||||
verify(splits, times(2)).insert(rows.capture());
|
||||
assertThat(rows.getAllValues()).allSatisfy(row -> {
|
||||
@@ -174,6 +179,7 @@ class OrderFulfillmentSplitServiceTest {
|
||||
OrderEntity child = invocation.getArgument(0);
|
||||
assertThat(child.getOrderNo()).isEqualTo("ORDER-001-2");
|
||||
assertThat(child.getParentOrderId()).isEqualTo(100L);
|
||||
assertThat(child.getInboundCode()).isEqualTo("ZBYHK2608170001-2");
|
||||
return 1;
|
||||
});
|
||||
when(splits.insert(any(OrderFulfillmentSplitEntity.class))).thenReturn(1);
|
||||
@@ -209,6 +215,7 @@ class OrderFulfillmentSplitServiceTest {
|
||||
private static OrderEntity parent() {
|
||||
OrderEntity parent = new OrderEntity();
|
||||
parent.setId(100L); parent.setTenantId(10L); parent.setOrderNo("ORDER-001");
|
||||
parent.setInboundCode("ZBYHK2608170001");
|
||||
parent.setOrderRole("MASTER"); parent.setVersion(3); parent.setStatus(OrderStatus.PROCESSING);
|
||||
return parent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user