licailing hace 3 años
padre
commit
6801a82deb

+ 4 - 4
src/main/java/com/izouma/nineth/repo/UserRepo.java

@@ -181,10 +181,10 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
 
     List<User> findBySettleAccountIdIsNotNull();
 
-//    @Transactional
-//    @Modifying
-//    @Query("update User set vipPoint = vipPoint + ?2 where id = ?1")
-//    void updateVipPoint(Long id, int num);
+    @Transactional
+    @Modifying
+    @Query("update User set vipPoint = vipPoint + ?2 where id = ?1")
+    void addVipPoint(Long id, int num);
 
     @Transactional
     @Modifying

+ 2 - 7
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -208,11 +208,6 @@ public class OrderService {
                         collectionService.decreaseQuota(collectionId, 1);
                     }
                 } else {
-//                    long count = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, userId);
-//                    int sub = collection.getAssignment() - (int) count;
-//                    if (sub > 0) {
-//                        throw new BusinessException("再拉新" + sub + "人即可购买");
-//                    }
                     if (user.getVipPoint() < 1) {
                         throw new BusinessException("没有购买名额");
                     }
@@ -284,7 +279,7 @@ public class OrderService {
 
             if (usePoint > 0) {
                 // 扣除积分
-                userRepo.updateVipPoint(userId, -usePoint);
+                userRepo.addVipPoint(userId, -usePoint);
             }
             rocketMQTemplate.syncSend(generalProperties.getUpdateStockTopic(), collectionId, 10000);
             log.info("订单创建完成, id={}, {}ms", order.getId(), System.currentTimeMillis() - t);
@@ -293,7 +288,7 @@ public class OrderService {
             collectionService.increaseStock(collectionId, qty);
             if (usePoint > 0) {
                 // 扣除积分
-                userRepo.updateVipPoint(userId, usePoint);
+                userRepo.addVipPoint(userId, usePoint);
                 log.info("取消加积分用户ID:{}, 积分:{}", userId, usePoint);
             }
             throw e;