|
|
@@ -46,7 +46,6 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.regex.Pattern;
|
|
|
@@ -73,8 +72,6 @@ public class UserService {
|
|
|
private TokenHistoryRepo tokenHistoryRepo;
|
|
|
private CollectionRepo collectionRepo;
|
|
|
private AdapayMerchantService adapayMerchantService;
|
|
|
- private PointRecordRepo pointRecordRepo;
|
|
|
- private CollectionService collectionService;
|
|
|
|
|
|
public User update(User user) {
|
|
|
if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
|
|
|
@@ -171,15 +168,19 @@ public class UserService {
|
|
|
invite = inviteRepo.findFirstByCode(inviteCode).orElse(null);
|
|
|
}
|
|
|
smsService.verify(phone, code);
|
|
|
- Collection collection = null;
|
|
|
+ Collection collection;
|
|
|
if (collectionId != null) {
|
|
|
collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("无藏品"));
|
|
|
- if (!collection.isOnShelf() || !collection.isSalable()) {
|
|
|
+// if (!collection.isOnShelf() || !collection.isSalable()) {
|
|
|
+// collectionId = null;
|
|
|
+// } else if (collection.isScheduleSale()) {
|
|
|
+// if (collection.getStartTime().isAfter(LocalDateTime.now())) {
|
|
|
+// collectionId = null;
|
|
|
+// }
|
|
|
+// }
|
|
|
+ // 只看是否开去分享
|
|
|
+ if (ObjectUtils.isEmpty(collection.getOpenQuota()) || !collection.getOpenQuota()) {
|
|
|
collectionId = null;
|
|
|
- } else if (collection.isScheduleSale()) {
|
|
|
- if (collection.getStartTime().isAfter(LocalDateTime.now())) {
|
|
|
- collectionId = null;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
User user = create(UserRegister.builder()
|
|
|
@@ -200,34 +201,34 @@ public class UserService {
|
|
|
}
|
|
|
|
|
|
// 加积分
|
|
|
- if (collectionId != null && invitor != null) {
|
|
|
- // 额度或者额度为空, 库存不为空
|
|
|
- if (collection.getStock() > 0 && (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota()))) {
|
|
|
- int countUser = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
|
|
|
- // 邀请人数
|
|
|
- if (countUser >= collection.getAssignment()) {
|
|
|
- int point = pointRecordRepo.countByUserIdAndCollectionId(invitor, collectionId);
|
|
|
- // 是否已有积分
|
|
|
- if (point <= 0) {
|
|
|
- long count = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
|
|
|
- if (count >= collection.getAssignment()) {
|
|
|
- // 扣除藏品额度
|
|
|
- if (ObjectUtils.isNotEmpty(collection.getVipQuota())) {
|
|
|
- collectionService.decreaseQuota(collectionId, 1);
|
|
|
- }
|
|
|
- userRepo.updateVipPoint(invitor, 1);
|
|
|
- pointRecordRepo.save(PointRecord.builder()
|
|
|
- .collectionId(collectionId)
|
|
|
- .userId(invitor)
|
|
|
- .type("VIP_POINT")
|
|
|
- .point(1)
|
|
|
- .build());
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// if (collectionId != null && invitor != null) {
|
|
|
+// // 额度或者额度为空, 库存不为空
|
|
|
+// if (collection.getStock() > 0 && (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota()))) {
|
|
|
+// int countUser = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
|
|
|
+// // 邀请人数
|
|
|
+// if (countUser >= collection.getAssignment()) {
|
|
|
+// int point = pointRecordRepo.countByUserIdAndCollectionId(invitor, collectionId);
|
|
|
+// // 是否已有积分
|
|
|
+// if (point <= 0) {
|
|
|
+// long count = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
|
|
|
+// if (count >= collection.getAssignment()) {
|
|
|
+// // 扣除藏品额度
|
|
|
+// if (ObjectUtils.isNotEmpty(collection.getVipQuota())) {
|
|
|
+// collectionService.decreaseQuota(collectionId, 1);
|
|
|
+// }
|
|
|
+// userRepo.updateVipPoint(invitor, 1);
|
|
|
+// pointRecordRepo.save(PointRecord.builder()
|
|
|
+// .collectionId(collectionId)
|
|
|
+// .userId(invitor)
|
|
|
+// .type("VIP_POINT")
|
|
|
+// .point(1)
|
|
|
+// .build());
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
@@ -672,4 +673,5 @@ public class UserService {
|
|
|
public User my(Long id) {
|
|
|
return userRepo.findById(id).orElseThrow(new BusinessException("用户不存在"));
|
|
|
}
|
|
|
+
|
|
|
}
|