|
|
@@ -129,20 +129,23 @@ public class MintOrderService {
|
|
|
throw new BusinessException("铸造活动已无库存");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (assetId.size() != mintActivity.getNum()) {
|
|
|
- throw new BusinessException("数量不正确,请重新选择");
|
|
|
+ if (mintActivity.getNum() > 0) {
|
|
|
+ if (assetId.size() != mintActivity.getNum()) {
|
|
|
+ throw new BusinessException("数量不正确,请重新选择");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
List<Asset> assets = assetRepo.findAllByIdInAndUserId(assetId, user.getId());
|
|
|
// 资产产品是否符合铸造活动的名称
|
|
|
assets = assets.stream()
|
|
|
.filter(asset -> asset.getName()
|
|
|
.contains(mintActivity.getCollectionName()) && AssetStatus.NORMAL.equals(asset.getStatus()))
|
|
|
.collect(Collectors.toList());
|
|
|
- if (assets.size() != mintActivity.getNum()) {
|
|
|
+ if (mintActivity.getNum() > 0 && (assets.size() != mintActivity.getNum())) {
|
|
|
throw new BusinessException("有藏品不符合,请重新选择");
|
|
|
}
|
|
|
+
|
|
|
Map<Long, Long> privilegeIds = new HashMap<>();
|
|
|
// 铸造特权
|
|
|
if (!mintActivity.isConsume()) {
|
|
|
@@ -375,16 +378,19 @@ public class MintOrderService {
|
|
|
}
|
|
|
List<MintMaterial> materials = order.getMaterial();
|
|
|
|
|
|
- Map<Long, Long> privilegeIds = materials.stream()
|
|
|
- .collect(Collectors.toMap(MintMaterial::getAssetId, MintMaterial::getPrivilegeId));
|
|
|
-
|
|
|
- List<Asset> assets = assetRepo.findAllById(privilegeIds.keySet());
|
|
|
+ List<Asset> assets = assetRepo.findAllById(materials.stream()
|
|
|
+ .map(MintMaterial::getAssetId)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
|
|
- assets.forEach(asset -> {
|
|
|
- if (order.isConsume()) {
|
|
|
+ if (order.isConsume()) {
|
|
|
+ assets.forEach(asset -> {
|
|
|
asset.setStatus(AssetStatus.NORMAL);
|
|
|
-
|
|
|
- } else {
|
|
|
+ assetRepo.save(asset);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ Map<Long, Long> privilegeIds = materials.stream()
|
|
|
+ .collect(Collectors.toMap(MintMaterial::getAssetId, MintMaterial::getPrivilegeId));
|
|
|
+ assets.forEach(asset -> {
|
|
|
asset.getPrivileges()
|
|
|
.stream()
|
|
|
.filter(p -> p.getId().equals(privilegeIds.get(asset.getId())))
|
|
|
@@ -393,10 +399,9 @@ public class MintOrderService {
|
|
|
p.setOpenTime(null);
|
|
|
p.setOpenedBy(null);
|
|
|
});
|
|
|
- }
|
|
|
- assetRepo.save(asset);
|
|
|
-
|
|
|
- });
|
|
|
+ assetRepo.save(asset);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
log.info("set normal mintOrder {}", order.getId());
|
|
|
|