init
This commit is contained in:
@@ -117,6 +117,7 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void incsVip(User user, Integer vipType, Integer vipMonth){
|
||||
// TODO 加锁
|
||||
UserVip userVip = this.getUserVip(user.getId(),vipType);
|
||||
@@ -139,9 +140,8 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> imple
|
||||
userVip.setVipTimeout(userVip.getVipTimeout().plusMonths(vipMonth));
|
||||
this.saveOrUpdate(userVip);
|
||||
}
|
||||
userService.update(Wrappers.lambdaUpdate(User.class)
|
||||
.eq(User::getId, user.getId())
|
||||
.set(User::getOpenVip, true));
|
||||
UserVipService service = SpringUtil.getBean(UserVipService.class);
|
||||
service.checkUserVip(userVip.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,15 +161,22 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void checkUserVip(Long userId){
|
||||
UserVip vip = this.getByUserVipMaster(userId);
|
||||
userService.update(Wrappers.lambdaUpdate(User.class)
|
||||
.eq(User::getId, userId)
|
||||
.set(User::getOpenVip, vip!=null));
|
||||
if(vip == null){
|
||||
userStatusService.update(Wrappers.lambdaUpdate(UserStatus.class)
|
||||
.eq(UserStatus::getUserId, userId)
|
||||
.set(UserStatus::getPushVip, 0));
|
||||
userService.update(Wrappers.lambdaUpdate(User.class)
|
||||
.eq(User::getId, userId)
|
||||
.set(User::getOpenVip, false));
|
||||
}else{
|
||||
userService.update(Wrappers.lambdaUpdate(User.class)
|
||||
.eq(User::getId, userId)
|
||||
.set(User::getOpenVip, true)
|
||||
.set(User::getVipType, vip.getVipType())
|
||||
.set(User::getVipTimeout, vip.getVipTimeout()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user