fix(lastleg): bind merged return inventory to reusable target pallet
This commit is contained in:
+9
@@ -58,6 +58,7 @@ public class ReturnInventoryService {
|
||||
@Resource private com.baiyue.lastleg.returnreceipt.mapper.ReturnReceiptMapper receiptMapper;
|
||||
@Resource private LastlegOrderMapper lastlegOrders;
|
||||
@Resource private LastlegOrderDetailMapper lastlegOrderDetails;
|
||||
@Resource private com.baiyue.lastleg.palletops.gateway.PalletPhysicalGateway physicalPallets;
|
||||
|
||||
@Transactional
|
||||
public ReturnInventoryCarton createReceiptCarton(ReturnOrder order, ReturnReceipt receipt,
|
||||
@@ -300,6 +301,14 @@ public class ReturnInventoryService {
|
||||
if (total <= 0) throw badRequest("至少填写一个大于 0 的 SKU 合箱数量");
|
||||
long targetId = IdWorker.getId();
|
||||
ReturnInventoryCarton target = new ReturnInventoryCarton();
|
||||
// Stable across transaction rollback/retry; a generated target ID would leak a new resource on every retry.
|
||||
String palletBusinessKey = "RETURN-MERGE:" + hash(List.of(identity.operatorKey(), key, requestHash));
|
||||
var pallet = physicalPallets.ensureRelabelPallet(identity.overseasWarehouseId(), palletBusinessKey);
|
||||
if (pallet == null || pallet.warehouseId() != identity.overseasWarehouseId()
|
||||
|| pallet.palletId() <= 0 || text(pallet.palletCode()) == null) {
|
||||
throw conflict("合箱目标托盘资源无效,请核对后重试");
|
||||
}
|
||||
target.setPalletCode(pallet.palletCode());
|
||||
target.setId(targetId); target.setCustomerId(customerId); target.setOverseasWarehouseId(sources.get(0).getOverseasWarehouseId());
|
||||
target.setCartonMark(numbers.next("RETURN_CARTON", target.getOverseasWarehouseId(), targetId)); target.setSourceBatchNo(String.join(",", consumedBatchNos)); target.setSourceReturnNo(String.join(",", consumedReturnNos)); target.setStatus(AVAILABLE);
|
||||
target.setSkuTypes(requested.size()); target.setTotalQuantity(total); target.setLength(request.length()); target.setWidth(request.width()); target.setHeight(request.height()); target.setWeight(request.weight()); target.setCreatedAt(now); target.setUpdatedAt(now); cartons.insert(target);
|
||||
|
||||
Reference in New Issue
Block a user