|
|
|
|
@ -104,20 +104,25 @@ public final class WarehouseOperations {
@@ -104,20 +104,25 @@ public final class WarehouseOperations {
|
|
|
|
|
throw new IllegalStateException("WarehouseSdk requires an idempotencyStore for write operations"); |
|
|
|
|
} |
|
|
|
|
final TransferCapable capable = (TransferCapable) adapter; |
|
|
|
|
common.ecommerce.shared.idempotency.WriteResult<TransferOrder> result = |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
cmd.transferRequestNo(), "create"), |
|
|
|
|
() -> capable.create(ctx, cmd), |
|
|
|
|
order -> order.providerTransferNo()); |
|
|
|
|
if (result.alreadyCompleted()) { |
|
|
|
|
// 回放:本次没有调仓,只有上次记录的仓单号
|
|
|
|
|
return TransferOrder.builder() |
|
|
|
|
.transferRequestNo(cmd.transferRequestNo()) |
|
|
|
|
.providerTransferNo(result.resultRef()) |
|
|
|
|
.build(); |
|
|
|
|
} |
|
|
|
|
return result.value(); |
|
|
|
|
return CallSupport.observe(observer, ctx, "warehouse.transfer.create", |
|
|
|
|
CallSupport.params("transferRequestNo", cmd.transferRequestNo()), |
|
|
|
|
r -> CallSupport.NO_COUNT, |
|
|
|
|
() -> { |
|
|
|
|
common.ecommerce.shared.idempotency.WriteResult<TransferOrder> result = |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
cmd.transferRequestNo(), "create"), |
|
|
|
|
() -> capable.create(ctx, cmd), |
|
|
|
|
order -> order.providerTransferNo()); |
|
|
|
|
if (result.alreadyCompleted()) { |
|
|
|
|
// 回放:本次没有调仓,只有上次记录的仓单号
|
|
|
|
|
return TransferOrder.builder() |
|
|
|
|
.transferRequestNo(cmd.transferRequestNo()) |
|
|
|
|
.providerTransferNo(result.resultRef()) |
|
|
|
|
.build(); |
|
|
|
|
} |
|
|
|
|
return result.value(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -132,14 +137,17 @@ public final class WarehouseOperations {
@@ -132,14 +137,17 @@ public final class WarehouseOperations {
|
|
|
|
|
throw new IllegalStateException("WarehouseSdk requires an idempotencyStore for write operations"); |
|
|
|
|
} |
|
|
|
|
final TransferCapable capable = (TransferCapable) adapter; |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
transferRequestNo, "approve"), |
|
|
|
|
() -> { |
|
|
|
|
capable.approve(ctx, transferRequestNo); |
|
|
|
|
return transferRequestNo; |
|
|
|
|
}, |
|
|
|
|
ref -> ref); |
|
|
|
|
CallSupport.observe(observer, ctx, "warehouse.transfer.approve", |
|
|
|
|
CallSupport.params("providerTransferNo", transferRequestNo), |
|
|
|
|
r -> CallSupport.NO_COUNT, |
|
|
|
|
() -> guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
transferRequestNo, "approve"), |
|
|
|
|
() -> { |
|
|
|
|
capable.approve(ctx, transferRequestNo); |
|
|
|
|
return transferRequestNo; |
|
|
|
|
}, |
|
|
|
|
ref -> ref)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -168,14 +176,17 @@ public final class WarehouseOperations {
@@ -168,14 +176,17 @@ public final class WarehouseOperations {
|
|
|
|
|
throw new IllegalStateException("WarehouseSdk requires an idempotencyStore for write operations"); |
|
|
|
|
} |
|
|
|
|
final TransferCapable capable = (TransferCapable) adapter; |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
providerTransferNo, "delete"), |
|
|
|
|
() -> { |
|
|
|
|
capable.deleteTransfer(ctx, providerTransferNo); |
|
|
|
|
return providerTransferNo; |
|
|
|
|
}, |
|
|
|
|
ref -> ref); |
|
|
|
|
CallSupport.observe(observer, ctx, "warehouse.transfer.delete", |
|
|
|
|
CallSupport.params("providerTransferNo", providerTransferNo), |
|
|
|
|
r -> CallSupport.NO_COUNT, |
|
|
|
|
() -> guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
providerTransferNo, "delete"), |
|
|
|
|
() -> { |
|
|
|
|
capable.deleteTransfer(ctx, providerTransferNo); |
|
|
|
|
return providerTransferNo; |
|
|
|
|
}, |
|
|
|
|
ref -> ref)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 库存视图。 */ |
|
|
|
|
@ -245,6 +256,19 @@ public final class WarehouseOperations {
@@ -245,6 +256,19 @@ public final class WarehouseOperations {
|
|
|
|
|
() -> ((WarehouseDirectoryCapable) adapter).carriers(ctx)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查物流产品(承运商渠道)清单。只读主数据,不走幂等。 |
|
|
|
|
* |
|
|
|
|
* @param warehouseCode 仓 code;null 时用账户配置的仓 |
|
|
|
|
*/ |
|
|
|
|
public List<LogisticsProduct> logisticsProducts(String warehouseCode) { |
|
|
|
|
require(WarehouseCapability.LOGISTICS_PRODUCT, LogisticsProductCapable.class); |
|
|
|
|
return CallSupport.observe(observer, ctx, "warehouse.logistics.products", |
|
|
|
|
CallSupport.params("warehouseCode", warehouseCode), |
|
|
|
|
List::size, |
|
|
|
|
() -> ((LogisticsProductCapable) adapter).products(ctx, warehouseCode)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 费用视图。 */ |
|
|
|
|
public FeeView fees() { |
|
|
|
|
return new FeeView(); |
|
|
|
|
@ -262,22 +286,27 @@ public final class WarehouseOperations {
@@ -262,22 +286,27 @@ public final class WarehouseOperations {
|
|
|
|
|
throw new IllegalStateException("WarehouseSdk requires an idempotencyStore for write operations"); |
|
|
|
|
} |
|
|
|
|
final DestructionCapable capable = (DestructionCapable) adapter; |
|
|
|
|
common.ecommerce.shared.idempotency.WriteResult<DestructionOrder> result = |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
cmd.destructionNo(), "create"), |
|
|
|
|
() -> capable.create(ctx, cmd), |
|
|
|
|
order -> order.providerDestructionId()); |
|
|
|
|
if (result.alreadyCompleted()) { |
|
|
|
|
// 回放:本次没有提交销毁,只有上次记录的仓单号
|
|
|
|
|
return DestructionOrder.builder() |
|
|
|
|
.destructionNo(cmd.destructionNo()) |
|
|
|
|
.providerDestructionId(result.resultRef()) |
|
|
|
|
.warehouseCode(account.warehouseCode()) |
|
|
|
|
.sourceProvider(provider) |
|
|
|
|
.build(); |
|
|
|
|
} |
|
|
|
|
return result.value(); |
|
|
|
|
return CallSupport.observe(observer, ctx, "warehouse.destruction.create", |
|
|
|
|
CallSupport.params("destructionNo", cmd.destructionNo()), |
|
|
|
|
r -> CallSupport.NO_COUNT, |
|
|
|
|
() -> { |
|
|
|
|
common.ecommerce.shared.idempotency.WriteResult<DestructionOrder> result = |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
cmd.destructionNo(), "create"), |
|
|
|
|
() -> capable.create(ctx, cmd), |
|
|
|
|
order -> order.providerDestructionId()); |
|
|
|
|
if (result.alreadyCompleted()) { |
|
|
|
|
// 回放:本次没有提交销毁,只有上次记录的仓单号
|
|
|
|
|
return DestructionOrder.builder() |
|
|
|
|
.destructionNo(cmd.destructionNo()) |
|
|
|
|
.providerDestructionId(result.resultRef()) |
|
|
|
|
.warehouseCode(account.warehouseCode()) |
|
|
|
|
.sourceProvider(provider) |
|
|
|
|
.build(); |
|
|
|
|
} |
|
|
|
|
return result.value(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 查询销毁计划。 */ |
|
|
|
|
@ -389,13 +418,17 @@ public final class WarehouseOperations {
@@ -389,13 +418,17 @@ public final class WarehouseOperations {
|
|
|
|
|
throw new IllegalStateException("WarehouseSdk requires an idempotencyStore for write operations"); |
|
|
|
|
} |
|
|
|
|
final InboundCapable capable = (InboundCapable) adapter; |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), inboundRef, "improve"), |
|
|
|
|
() -> { |
|
|
|
|
capable.improve(ctx, inboundRef, cmd); |
|
|
|
|
return inboundRef; |
|
|
|
|
}, |
|
|
|
|
ref -> ref); |
|
|
|
|
CallSupport.observe(observer, ctx, "warehouse.inbound.improve", |
|
|
|
|
CallSupport.params("inboundRef", inboundRef), |
|
|
|
|
r -> CallSupport.NO_COUNT, |
|
|
|
|
() -> guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
inboundRef, "improve"), |
|
|
|
|
() -> { |
|
|
|
|
capable.improve(ctx, inboundRef, cmd); |
|
|
|
|
return inboundRef; |
|
|
|
|
}, |
|
|
|
|
ref -> ref)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -408,13 +441,17 @@ public final class WarehouseOperations {
@@ -408,13 +441,17 @@ public final class WarehouseOperations {
|
|
|
|
|
throw new IllegalStateException("WarehouseSdk requires an idempotencyStore for write operations"); |
|
|
|
|
} |
|
|
|
|
final InboundCapable capable = (InboundCapable) adapter; |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), inboundRef, "submit"), |
|
|
|
|
() -> { |
|
|
|
|
capable.submit(ctx, inboundRef); |
|
|
|
|
return inboundRef; |
|
|
|
|
}, |
|
|
|
|
ref -> ref); |
|
|
|
|
CallSupport.observe(observer, ctx, "warehouse.inbound.submit", |
|
|
|
|
CallSupport.params("inboundRef", inboundRef), |
|
|
|
|
r -> CallSupport.NO_COUNT, |
|
|
|
|
() -> guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
inboundRef, "submit"), |
|
|
|
|
() -> { |
|
|
|
|
capable.submit(ctx, inboundRef); |
|
|
|
|
return inboundRef; |
|
|
|
|
}, |
|
|
|
|
ref -> ref)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** BOL 文档。 */ |
|
|
|
|
@ -517,14 +554,18 @@ public final class WarehouseOperations {
@@ -517,14 +554,18 @@ public final class WarehouseOperations {
|
|
|
|
|
throw new IllegalStateException("WarehouseSdk requires an idempotencyStore for write operations"); |
|
|
|
|
} |
|
|
|
|
final WarehouseReturnCapable capable = (WarehouseReturnCapable) adapter; |
|
|
|
|
guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
cmd.providerReturnNo() + ':' + cmd.lineId(), "process"), |
|
|
|
|
() -> { |
|
|
|
|
capable.process(ctx, cmd); |
|
|
|
|
return cmd; |
|
|
|
|
}, |
|
|
|
|
c -> null); |
|
|
|
|
CallSupport.observe(observer, ctx, "warehouse.return.process", |
|
|
|
|
CallSupport.params("providerReturnNo", cmd.providerReturnNo(), |
|
|
|
|
"lineId", cmd.lineId()), |
|
|
|
|
r -> CallSupport.NO_COUNT, |
|
|
|
|
() -> guard.execute( |
|
|
|
|
WarehouseWriteScope.of(provider.name(), account.warehouseCode(), |
|
|
|
|
cmd.providerReturnNo() + ':' + cmd.lineId(), "process"), |
|
|
|
|
() -> { |
|
|
|
|
capable.process(ctx, cmd); |
|
|
|
|
return cmd; |
|
|
|
|
}, |
|
|
|
|
c -> null)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|