|
@@ -57,6 +57,7 @@ public class OrderService {
|
|
|
if (qty <= 0) throw new BusinessException("数量必须大于0");
|
|
if (qty <= 0) throw new BusinessException("数量必须大于0");
|
|
|
User user = userRepo.findByIdAndDelFalse(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
User user = userRepo.findByIdAndDelFalse(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("藏品不存在"));
|
|
Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("藏品不存在"));
|
|
|
|
|
+ User minter = userRepo.findById(collection.getMinterId()).orElseThrow(new BusinessException("铸造者不存在"));
|
|
|
|
|
|
|
|
if (!collection.isOnShelf()) {
|
|
if (!collection.isOnShelf()) {
|
|
|
throw new BusinessException("藏品已下架");
|
|
throw new BusinessException("藏品已下架");
|
|
@@ -73,14 +74,15 @@ public class OrderService {
|
|
|
collection.setSale(collection.getSale() + qty);
|
|
collection.setSale(collection.getSale() + qty);
|
|
|
collectionRepo.save(collection);
|
|
collectionRepo.save(collection);
|
|
|
|
|
|
|
|
- User minter = userRepo.findById(collection.getMinterId()).orElse(null);
|
|
|
|
|
|
|
+ minter.setSales(minter.getSales() + 1);
|
|
|
|
|
+
|
|
|
Order order = Order.builder()
|
|
Order order = Order.builder()
|
|
|
.userId(userId)
|
|
.userId(userId)
|
|
|
.collectionId(collectionId)
|
|
.collectionId(collectionId)
|
|
|
.name(collection.getName())
|
|
.name(collection.getName())
|
|
|
.pic(collection.getPics())
|
|
.pic(collection.getPics())
|
|
|
- .minter(Optional.ofNullable(minter).map(User::getNickname).orElse(collection.getMinter()))
|
|
|
|
|
- .minterAvatar(Optional.ofNullable(minter).map(User::getAvatar).orElse(collection.getMinterAvatar()))
|
|
|
|
|
|
|
+ .minter(minter.getNickname())
|
|
|
|
|
+ .minterAvatar(minter.getAvatar())
|
|
|
.qty(qty)
|
|
.qty(qty)
|
|
|
.price(collection.getPrice())
|
|
.price(collection.getPrice())
|
|
|
.gasPrice(BigDecimal.valueOf(1))
|
|
.gasPrice(BigDecimal.valueOf(1))
|