fix(phase4): enforce customer and pallet versions

This commit is contained in:
2026-08-24 15:14:18 +08:00
parent e773816c98
commit 95b72afdcc
12 changed files with 82 additions and 31 deletions
@@ -152,6 +152,9 @@ public class WarehouseResourceService {
@Transactional
public void updatePallet(long customerId, long warehouseId, long id, PalletRequests.SaveRequest request) {
WarehousePalletEntity existing = requirePallet(customerId, warehouseId, id);
if (request.version() == null || !request.version().equals(existing.getVersion())) {
throw new BizException(ResultCode.CONFLICT, "托盘版本已变化,请刷新后重试");
}
if ("SCRAPPED".equals(existing.getStatus()) && !"SCRAPPED".equals(request.status())) {
throw new BizException(ResultCode.CONFLICT, "SCRAPPED pallet cannot be reused");
}
@@ -161,7 +164,10 @@ public class WarehouseResourceService {
validatePallet(request, palletCode, locationId, customerId, warehouseId, id);
WarehousePalletEntity entity = palletEntity(customerId, warehouseId, request, palletCode, locationId);
entity.setId(existing.getId());
repository.updatePallet(entity);
entity.setVersion(request.version());
if (repository.updatePallet(entity) != 1) {
throw new BizException(ResultCode.CONFLICT, "托盘版本已变化,请刷新后重试");
}
}
public WarehousePalletEntity pallet(long customerId, long warehouseId, long id) {