|
|
@@ -163,9 +163,18 @@ public class MintOrderService {
|
|
|
MintActivity mintActivity = mintActivityRepo.findByIdAndDelFalse(mintActivityId)
|
|
|
.orElseThrow(new BusinessException("无此铸造活动"));
|
|
|
|
|
|
+ if (mintActivity.isScheduleSale()) {
|
|
|
+ if (mintActivity.getStartTime().isAfter(LocalDateTime.now())) {
|
|
|
+ throw new BusinessException("当前还未开售");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!mintActivity.isOnShelf()) {
|
|
|
+ throw new BusinessException("活动已下架");
|
|
|
+ }
|
|
|
+
|
|
|
int stock = Optional.ofNullable(mintActivityService.decreaseStock(mintActivityId, 1))
|
|
|
.map(Math::toIntExact)
|
|
|
- .orElseThrow(new BusinessException("很遗憾,藏品已售罄"));
|
|
|
+ .orElseThrow(new BusinessException("很遗憾,铸造活动已无库存"));
|
|
|
if (stock < 0) {
|
|
|
throw new BusinessException("铸造活动已无库存");
|
|
|
}
|