|
|
@@ -661,6 +661,11 @@ public class AssetService {
|
|
|
return assetRepo.saveAndFlush(asset);
|
|
|
}
|
|
|
|
|
|
+ public void batchCancelConsignment(String search) {
|
|
|
+ List<Asset> onShelf = assetRepo.findOnShelfByNameLike("%" + search + "%");
|
|
|
+ onShelf.forEach(this::cancelConsignmentBySystem);
|
|
|
+ }
|
|
|
+
|
|
|
public void cancelConsignment(Long id) {
|
|
|
Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
if (!asset.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())) {
|
|
|
@@ -1012,10 +1017,13 @@ public class AssetService {
|
|
|
assetIds.forEach(this::cancelConsignmentBySystem);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public void cancelConsignmentBySystem(Long id) {
|
|
|
+ Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
+ cancelConsignmentBySystem(asset);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void cancelConsignmentBySystem(Asset asset) {
|
|
|
try {
|
|
|
- Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
if (asset.getPublicCollectionId() != null) {
|
|
|
List<Order> orders = orderRepo.findByCollectionId(asset.getPublicCollectionId());
|
|
|
if (orders.stream().anyMatch(o -> o.getStatus() != OrderStatus.CANCELLED)) {
|
|
|
@@ -1032,7 +1040,7 @@ public class AssetService {
|
|
|
asset.setPublicShow(false);
|
|
|
assetRepo.saveAndFlush(asset);
|
|
|
} catch (Exception e) {
|
|
|
- log.info("自动下架报错,assetId:" + id);
|
|
|
+ log.info("自动下架报错,assetId:" + asset.getId());
|
|
|
}
|
|
|
}
|
|
|
|