|
|
@@ -111,15 +111,14 @@ public class OrderService {
|
|
|
|
|
|
Long id = snowflakeIdWorker.nextId();
|
|
|
SendResult result = rocketMQTemplate.syncSend(generalProperties.getCreateOrderTopic(),
|
|
|
- new CreateOrderEvent(id, userId, collectionId, qty, addressId, userCouponId, invitor, vip, vipPurchase,
|
|
|
- vipPoint), 100000);
|
|
|
+ new CreateOrderEvent(id, userId, collectionId, qty, addressId, userCouponId, invitor, vip), 100000);
|
|
|
|
|
|
log.info("发送订单到队列: {}, userId={}, result={}", id, userId, result);
|
|
|
return String.valueOf(id);
|
|
|
}
|
|
|
|
|
|
public Order create(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor,
|
|
|
- Long id, boolean vip, int vipPurchase, int vipPoint) {
|
|
|
+ Long id, boolean vip) {
|
|
|
long t = System.currentTimeMillis();
|
|
|
qty = 1;
|
|
|
int stock = Optional.ofNullable(collectionService.decreaseStock(collectionId, qty))
|
|
|
@@ -191,10 +190,10 @@ public class OrderService {
|
|
|
throw new BusinessException("当前还未开售");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
if (vip) {
|
|
|
int purchase = orderRepo.countByUserIdAndCollectionIdAndVipTrueAndStatusIn(userId, collectionId, Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
- if (vipPurchase - purchase <= 0) {
|
|
|
+ if (user.getVipPurchase() - purchase <= 0) {
|
|
|
throw new BusinessException("vip名额已使用完毕!");
|
|
|
}
|
|
|
} else {
|
|
|
@@ -203,7 +202,7 @@ public class OrderService {
|
|
|
// if (sub > 0) {
|
|
|
// throw new BusinessException("再拉新" + sub + "人即可购买");
|
|
|
// }
|
|
|
- if (vipPoint < 1) {
|
|
|
+ if (user.getVipPoint() < 1) {
|
|
|
throw new BusinessException("没有购买名额");
|
|
|
}
|
|
|
usePoint = 1;
|