|
|
@@ -49,19 +49,20 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class MintOrderService {
|
|
|
|
|
|
- private MintOrderRepo mintOrderRepo;
|
|
|
- private UserRepo userRepo;
|
|
|
- private AssetService assetService;
|
|
|
- private AssetRepo assetRepo;
|
|
|
- private MintActivityRepo mintActivityRepo;
|
|
|
- private UserAddressRepo userAddressRepo;
|
|
|
- private GeneralProperties generalProperties;
|
|
|
- private Environment env;
|
|
|
- private AdapayProperties adapayProperties;
|
|
|
- private SnowflakeIdWorker snowflakeIdWorker;
|
|
|
- private WxPayProperties wxPayProperties;
|
|
|
- private WxPayService wxPayService;
|
|
|
- private MintMaterialRepo mintMaterialRepo;
|
|
|
+ private MintOrderRepo mintOrderRepo;
|
|
|
+ private UserRepo userRepo;
|
|
|
+ private AssetService assetService;
|
|
|
+ private AssetRepo assetRepo;
|
|
|
+ private MintActivityRepo mintActivityRepo;
|
|
|
+ private UserAddressRepo userAddressRepo;
|
|
|
+ private GeneralProperties generalProperties;
|
|
|
+ private Environment env;
|
|
|
+ private AdapayProperties adapayProperties;
|
|
|
+ private SnowflakeIdWorker snowflakeIdWorker;
|
|
|
+ private WxPayProperties wxPayProperties;
|
|
|
+ private WxPayService wxPayService;
|
|
|
+ private MintMaterialRepo mintMaterialRepo;
|
|
|
+ private MintActivityService mintActivityService;
|
|
|
|
|
|
public Page<MintOrder> all(PageQuery pageQuery) {
|
|
|
return mintOrderRepo.findAll(JpaUtils.toSpecification(pageQuery, MintOrder.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -148,7 +149,10 @@ public class MintOrderService {
|
|
|
MintActivity mintActivity = mintActivityRepo.findByIdAndDelFalse(mintActivityId)
|
|
|
.orElseThrow(new BusinessException("无此铸造活动"));
|
|
|
|
|
|
- if (mintActivity.getStock() <= 0) {
|
|
|
+ int stock = Optional.ofNullable(mintActivityService.decreaseStock(mintActivityId, 1))
|
|
|
+ .map(Math::toIntExact)
|
|
|
+ .orElseThrow(new BusinessException("很遗憾,藏品已售罄"));
|
|
|
+ if (stock < 0) {
|
|
|
throw new BusinessException("铸造活动已无库存");
|
|
|
}
|
|
|
|
|
|
@@ -255,8 +259,10 @@ public class MintOrderService {
|
|
|
mintMaterialRepo.saveAll(materials);
|
|
|
|
|
|
//库存
|
|
|
- mintActivity.setStock(mintActivity.getStock() - 1);
|
|
|
- mintActivityRepo.save(mintActivity);
|
|
|
+
|
|
|
+// mintActivity.setStock(mintActivity.getStock() - 1);
|
|
|
+// mintActivityRepo.save(mintActivity);
|
|
|
+ mintActivityService.increaseSale(mintActivityId, 1);
|
|
|
return mintOrder;
|
|
|
}
|
|
|
|
|
|
@@ -438,6 +444,7 @@ public class MintOrderService {
|
|
|
mintOrderRepo.save(order);
|
|
|
|
|
|
// 加库存
|
|
|
- mintActivityRepo.addStock(order.getMintActivityId());
|
|
|
+// mintActivityRepo.addStock(order.getMintActivityId());
|
|
|
+ mintActivityService.increaseStock(order.getMintActivityId(), 1);
|
|
|
}
|
|
|
}
|