Преглед изворни кода

官方购买-任务白名单

licailing пре 3 година
родитељ
комит
8457b4a660

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

@@ -175,4 +175,6 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     long countAllByCreatedAtAfterAndAuthoritiesContainsAndDelFalse(LocalDateTime createdAt, Authority authority);
 
     List<User> findAllByCollectionIdAndCollectionInvitor(Long collectionId, Long collectionInvitor);
+
+    long countAllByCollectionIdAndCollectionInvitor(Long collectionId, Long collectionInvitor);
 }

+ 10 - 1
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -155,6 +155,15 @@ public class OrderService {
                 }
             }
 
+            //查询是否有拉新任务,只算官方购买
+            if (collection.getSource() != CollectionSource.TRANSFER && collection.getAssignment() > 0) {
+                long count = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, userId);
+                int sub = collection.getAssignment() - (int) count;
+                if (sub > 0) {
+                    throw new BusinessException("再拉新" + sub + "人即可购买");
+                }
+            }
+
             UserAddress userAddress = null;
             if (addressId != null) {
                 userAddress = userAddressRepo.findById(addressId).orElseThrow(new BusinessException("地址信息不存在"));
@@ -185,7 +194,7 @@ public class OrderService {
                     .contactName(Optional.ofNullable(userAddress).map(UserAddress::getName).orElse(null))
                     .contactPhone(Optional.ofNullable(userAddress).map(UserAddress::getPhone).orElse(null))
                     .address(Optional.ofNullable(userAddress).map(u ->
-                                    u.getProvinceId() + " " + u.getCityId() + " " + u.getDistrictId() + " " + u.getAddress())
+                                    u.getProvinceName() + " " + u.getCityName() + " " + u.getDistrictName() + " " + u.getAddress())
                             .orElse(null))
                     .status(OrderStatus.NOT_PAID)
                     .assetId(collection.getAssetId())