fix(lastleg): scope inventory holds by cycle and align pick lock ordering
This commit is contained in:
+10
-8
@@ -144,23 +144,25 @@ public class InventoryCommandService {
|
||||
|
||||
@Transactional
|
||||
public void holdInboundOrderInventory(String customerId, String operatorId, long inboundOrderId,
|
||||
String businessOrderNo, String remark) {
|
||||
String businessOrderNo, String remark, String holdCycle) {
|
||||
for (InventoryPosition position : commands.lockInboundAvailablePositions(customerId, inboundOrderId)) {
|
||||
long packages = value(position.getAvailablePackages());
|
||||
if (packages == 0) continue;
|
||||
hold(customerId, operatorId, new InventoryCommandRequests.Move(position.getId(), packages,
|
||||
businessOrderNo, null, null, "ORDER_HOLD:" + inboundOrderId + ":" + position.getId(), remark));
|
||||
businessOrderNo, null, holdCycle, holdCycle + ":" + position.getId(), remark));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void releaseInboundOrderHold(String customerId, String operatorId, long inboundOrderId,
|
||||
String businessOrderNo, String remark) {
|
||||
for (InventoryPosition position : commands.lockInboundHeldPositions(customerId, inboundOrderId)) {
|
||||
long packages = value(position.getHoldPackages());
|
||||
if (packages == 0) continue;
|
||||
release(customerId, operatorId, new InventoryCommandRequests.Move(position.getId(), packages,
|
||||
businessOrderNo, null, null, "ORDER_HOLD_RELEASE:" + inboundOrderId + ":" + position.getId(), remark));
|
||||
String businessOrderNo, String remark, String holdCycle) {
|
||||
// HOLD is shared by several business flows. Only release facts owned by this order hold cycle.
|
||||
for (InventoryLedger held : ledgers.orderHoldCycle(customerId, inboundOrderId, holdCycle)) {
|
||||
if (held.getPositionId() == null || value(held.getDeltaPackages()) <= 0) {
|
||||
throw conflict("Order hold inventory fact is invalid");
|
||||
}
|
||||
release(customerId, operatorId, new InventoryCommandRequests.Move(held.getPositionId(), held.getDeltaPackages(),
|
||||
businessOrderNo, null, holdCycle, holdCycle + ":RELEASE:" + held.getPositionId(), remark));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -12,6 +12,11 @@ import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface InventoryLedgerMapper extends BaseMapper<InventoryLedger> {
|
||||
@Select("SELECT * FROM ll_inventory_ledger WHERE customer_id=#{customerId} AND inbound_order_id=#{inboundOrderId} " +
|
||||
"AND business_type='HOLD' AND source_event_id=#{holdCycle} ORDER BY position_id,id")
|
||||
List<InventoryLedger> orderHoldCycle(@Param("customerId") String customerId,
|
||||
@Param("inboundOrderId") long inboundOrderId, @Param("holdCycle") String holdCycle);
|
||||
|
||||
@Select("SELECT * FROM ll_inventory_ledger WHERE customer_id=#{customerId} AND idempotency_key=#{idempotencyKey} LIMIT 1")
|
||||
InventoryLedger findIdempotency(@Param("customerId") String customerId,
|
||||
@Param("idempotencyKey") String idempotencyKey);
|
||||
|
||||
Reference in New Issue
Block a user