|
|
@@ -118,6 +118,7 @@ public class UserService {
|
|
|
private ShowCollectionRepo showCollectionRepo;
|
|
|
private ShowroomService showroomService;
|
|
|
private NewsLikeRepo newsLikeRepo;
|
|
|
+ private UserPropertyRepo userPropertyRepo;
|
|
|
|
|
|
public User update(User user) {
|
|
|
if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
|
|
|
@@ -1169,4 +1170,55 @@ public class UserService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public void savePoint(User user) {
|
|
|
+ //给积分
|
|
|
+ Long invitor = user.getCollectionInvitor();
|
|
|
+ if (ObjectUtils.isEmpty(user.getCollectionId()) || ObjectUtils.isEmpty(invitor)) {
|
|
|
+ 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 && userProperty.getMaxCount() != point) {
|
|
|
+ userProperty.setMaxCount(point);
|
|
|
+ userPropertyRepo.save(userProperty);
|
|
|
+ log.info("邀请绑卡限购+1,{}", invitor);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|