This commit is contained in:
张良(004796)
2024-04-25 11:00:23 +08:00
parent 6aad29a3b2
commit ad7017ab5c
2 changed files with 14 additions and 6 deletions

View File

@@ -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()));
}
}