|
|
@@ -1169,70 +1169,6 @@ public class UserService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void savePoint(User user) {
|
|
|
-
|
|
|
- //给积分
|
|
|
- Long invitor = user.getCollectionInvitor();
|
|
|
- if (ObjectUtils.isEmpty(user.getCollectionId()) || ObjectUtils.isEmpty(invitor)) {
|
|
|
- this.noCollectionId(user);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (8573130L != user.getCollectionId()) return;
|
|
|
-
|
|
|
- Collection collection = collectionRepo.findById(user.getCollectionId()).orElse(null);
|
|
|
- if (collection == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (user.getVipPoint() < 1) {
|
|
|
- //有效新用户1个限购
|
|
|
- user.setVipPoint(100);
|
|
|
- userRepo.save(user);
|
|
|
- cacheService.clearUserMy(user.getId());
|
|
|
- cacheService.clearUser(user.getId());
|
|
|
- }
|
|
|
-
|
|
|
- //指标数量
|
|
|
- int assignment = collection.getAssignment();
|
|
|
- if (assignment < 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
- int inviteNum = userRepo.countAllByCollectionIdAndCollectionInvitorAndSettleAccountIdIsNotNull(
|
|
|
- user.getCollectionId(), invitor);
|
|
|
-
|
|
|
- int point = inviteNum / assignment;
|
|
|
- log.info("邀请数量,{}-{}", invitor, inviteNum);
|
|
|
- if (point < 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
- User parent = userRepo.findById(invitor).orElse(null);
|
|
|
- if (parent == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (parent.getVipPoint() < 1) {
|
|
|
- //老用户可有一个限购
|
|
|
- parent.setVipPoint(100);
|
|
|
- userRepo.save(parent);
|
|
|
- cacheService.clearUserMy(user.getId());
|
|
|
- cacheService.clearUser(user.getId());
|
|
|
- }
|
|
|
- log.info("修改限购{}", invitor);
|
|
|
- UserProperty userProperty = userPropertyRepo.findById(invitor).orElse(new UserProperty(invitor, 0));
|
|
|
- if (userProperty.getMaxCount() < 10) {
|
|
|
- if (parent.getVipPurchase() > 0 || parent.getCreatedAt().isAfter(LocalDateTime.of(2022, 7, 5, 0, 0, 0))) {
|
|
|
- if (userProperty.getMaxCount() != point + 1) {
|
|
|
- userProperty.setMaxCount(Math.min(point + 1, 10));
|
|
|
- userPropertyRepo.save(userProperty);
|
|
|
- log.info("邀请绑卡限购+1,{}", invitor);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- userProperty.setMaxCount(Math.min(point, 10));
|
|
|
- userPropertyRepo.save(userProperty);
|
|
|
- log.info("邀请绑卡限购+1,{}", invitor);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public void noCollectionId(User user) {
|
|
|
if (user.getCreatedAt().isBefore(LocalDateTime.of(2022, 7, 5, 0, 0, 0))) {
|
|
|
return;
|