init
This commit is contained in:
@@ -38,6 +38,15 @@ public class User implements Serializable {
|
||||
* 用户类型: 0普通用户 1 内部用户
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 是否为VIP
|
||||
*/
|
||||
private Boolean openVip;
|
||||
/**
|
||||
* @see com.ruoyi.xq.enums.vip.VipTypeEnum
|
||||
*/
|
||||
@Schema(description = "开通的VIP类型")
|
||||
private Integer vipType;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
|
||||
@@ -75,11 +75,11 @@ public class CurrentUserInfoVo {
|
||||
|
||||
@Schema(description = "是否开通VIP")
|
||||
private Boolean openVip = false;
|
||||
@Schema(description = "vip等级")
|
||||
/**
|
||||
* 还没有实现 TODO
|
||||
*/
|
||||
@Schema(description = "vip等级",hidden = true)
|
||||
private Integer vipType;
|
||||
@Schema(description = "vip到期时间")
|
||||
private LocalDateTime vipTimeout;
|
||||
|
||||
/**
|
||||
* 收益的余额
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,6 @@ public enum VipStatusEnum {
|
||||
NORMAL(1,"正常"),
|
||||
TIMEOUT(2,"已过期"),
|
||||
CLOSE(3,"已取消"),
|
||||
|
||||
;
|
||||
private final Integer code;
|
||||
private final String text;
|
||||
|
||||
@@ -116,11 +116,9 @@ public class CurrentUserManager {
|
||||
vo.setAlreadyAuthNum(userAuth.getAlreadyAuthNum());
|
||||
List<UserPictures> userPictures = userPicturesService.listByUserIdAuditingAndSuccess(user.getId());
|
||||
vo.setUserPicturesList(BeanConvertUtil.convertListTo(userPictures, UserPicturesDTO::new));
|
||||
UserVip userVip = userVipService.getByUserVipMaster(userId);
|
||||
if(userVip != null){
|
||||
vo.setOpenVip(true);
|
||||
vo.setVipType(userVip.getVipType());
|
||||
vo.setVipTimeout(userVip.getVipTimeout());
|
||||
if(user.getOpenVip() != null){
|
||||
vo.setOpenVip(user.getOpenVip());
|
||||
// vo.setVipType();
|
||||
}
|
||||
UserExtend userExtend = userExtendService.getByUserId(userId);
|
||||
vo.setIncomeCoin(userExtend.getIncomeCoin());
|
||||
|
||||
@@ -75,8 +75,7 @@ public class ImManager {
|
||||
throw new ServiceException("不能给自己发送哦!");
|
||||
}
|
||||
// 判断VIP 只有VIP才可以发送消息
|
||||
UserVip userVip = userVipService.getByUserVipMaster(fromUserId);
|
||||
if(userVip == null){
|
||||
if(!fromUser.getOpenVip()){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
||||
}
|
||||
// 检查拉黑
|
||||
|
||||
@@ -33,4 +33,6 @@ public interface UserVipService extends IService<UserVip> {
|
||||
Page<UserVipAdminVo> pageAdmin(PageQuery pageQuery, UserVipAdminVo bo);
|
||||
|
||||
void removeVip(Long id);
|
||||
|
||||
void checkUserVip(Long userId);
|
||||
}
|
||||
|
||||
@@ -119,11 +119,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
BeanConvertUtil.copyProperties(user,result);
|
||||
List<UserPictures> userPicturesList = userPicturesService.listByUserIdSuccess(userId);
|
||||
result.setUserPictureList(userPicturesList.stream().map(UserPictures::getPicture).collect(Collectors.toList()));
|
||||
UserVip userVip = userVipService.getByUserVipMaster(user.getId());
|
||||
if(userVip != null){
|
||||
result.setOpenVip(true);
|
||||
result.setVipType(userVip.getVipType());
|
||||
}
|
||||
result.setOpenVip(user.getOpenVip());
|
||||
result.setVipType(user.getVipType());
|
||||
Long currentUserId = LoginHelper.getUserId();
|
||||
if(userId.equals(currentUserId)){
|
||||
return result;
|
||||
@@ -218,8 +215,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
return ShowAvatarUtil.showAvatar(false,false,avatar);
|
||||
}
|
||||
UserAuth userAuth = userAuthService.getByUserId(userId);
|
||||
UserVip userVip = userVipService.getByUserVipMaster(userId);
|
||||
return ShowAvatarUtil.showAvatar(userAuth.getCarAuth()==1,userVip!=null, avatar);
|
||||
User user = this.getById(userId);
|
||||
return ShowAvatarUtil.showAvatar(user.getOpenVip(),userAuth.getCarAuth()==1, avatar);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,12 +225,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
boolean vip = false; // 是否为VIP
|
||||
boolean card = false; // 是否实名认证
|
||||
Long userId = LoginHelper.getUserId();
|
||||
UserVip userVip = null;
|
||||
if(userId != null){
|
||||
UserAuth userAuth = userAuthService.getByUserId(userId);
|
||||
card = userAuth != null && userAuth.getCarAuth() == 1;
|
||||
userVip = userVipService.getByUserVipMaster(userId);
|
||||
vip = userVip != null;
|
||||
User user = this.getById(userId);
|
||||
vip = user.getOpenVip();
|
||||
}
|
||||
if(vipQuery != null){
|
||||
if(StringUtils.isNotEmpty(vipQuery.getProfession()) ||
|
||||
@@ -243,16 +239,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
if(userId == null){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
||||
}
|
||||
if(userVip == null){
|
||||
if(!vip){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
Page<HomeUserListVo> page = baseMapper.homePageApp(params.build(), params);
|
||||
List<HomeUserListVo> records = page.getRecords();
|
||||
List<Long> userIdArray = new ArrayList<>();
|
||||
for (HomeUserListVo record : records) {
|
||||
userIdArray.add(record.getUserId());
|
||||
record.setBirthdayStr(BirthdayUtil.getMinBirthday(record.getBirthday()));
|
||||
record.setAge(BirthdayUtil.getAge(record.getBirthday()));
|
||||
boolean showAvatarBool = ShowAvatarUtil.showAvatar(vip, card, record.getShowAvatar());
|
||||
@@ -261,15 +255,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements Use
|
||||
record.setAvatar(null);
|
||||
}
|
||||
}
|
||||
List<UserVip> vips = userVipService.listUserVipMaster(userIdArray);
|
||||
Map<Long, UserVip> userVipMap = vips.stream().collect(Collectors.toMap(UserVip::getUserId, Function.identity()));
|
||||
for (HomeUserListVo record : records) {
|
||||
UserVip userVipNode = userVipMap.get(record.getUserId());
|
||||
if(userVip != null){
|
||||
record.setOpenVip(true);
|
||||
record.setVipType(userVipNode.getVipType());
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.xq.domain.User;
|
||||
import com.ruoyi.xq.domain.UserStatus;
|
||||
import com.ruoyi.xq.domain.UserVip;
|
||||
import com.ruoyi.xq.dto.admin.userstatus.UserStatusAdminVo;
|
||||
@@ -14,6 +15,7 @@ import com.ruoyi.xq.enums.ErrorEnum;
|
||||
import com.ruoyi.xq.enums.userstatus.PersonalsStatusEnum;
|
||||
import com.ruoyi.xq.enums.userstatus.ShowAvatarEnum;
|
||||
import com.ruoyi.xq.mapper.UserStatusMapper;
|
||||
import com.ruoyi.xq.service.UserService;
|
||||
import com.ruoyi.xq.service.UserStatusService;
|
||||
import com.ruoyi.xq.service.UserVipService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -31,6 +33,8 @@ import java.time.LocalDateTime;
|
||||
public class UserStatusServiceImpl extends ServiceImpl<UserStatusMapper,UserStatus> implements UserStatusService {
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public UserStatus getByUserId(Long userId) {
|
||||
@@ -41,8 +45,8 @@ public class UserStatusServiceImpl extends ServiceImpl<UserStatusMapper,UserStat
|
||||
public void updateStatus(UserStatusUpdateAppReq req) {
|
||||
UserStatus userStatus = this.getByUserId(req.getUserId());
|
||||
if(req.getShowAvatar() != null && !req.getShowAvatar().equals(ShowAvatarEnum.ALL.getCode())){
|
||||
UserVip userVip = userVipService.getByUserVipMaster(req.getUserId());
|
||||
if(userVip == null){
|
||||
User user = userService.getById(req.getUserId());
|
||||
if(!user.getOpenVip()){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH.getText());
|
||||
}
|
||||
}
|
||||
@@ -51,8 +55,8 @@ public class UserStatusServiceImpl extends ServiceImpl<UserStatusMapper,UserStat
|
||||
update.setAllowTransMobile(req.getAllowTransMobile());
|
||||
update.setAllowTransWx(req.getAllowTransWx());
|
||||
if(req.getPushVip() != null && req.getPushVip() == 1){
|
||||
UserVip userVip = userVipService.getByUserVipMaster(req.getUserId());
|
||||
if(userVip == null){
|
||||
User user = userService.getById(req.getUserId());
|
||||
if(!user.getOpenVip()){
|
||||
throw new ServiceException(ErrorEnum.VIP_AUTH.getText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.xq.domain.User;
|
||||
import com.ruoyi.xq.domain.UserStatus;
|
||||
import com.ruoyi.xq.domain.UserVip;
|
||||
import com.ruoyi.xq.domain.VipOrder;
|
||||
import com.ruoyi.xq.dto.admin.user.UserVipAdminVo;
|
||||
@@ -20,6 +21,8 @@ import com.ruoyi.xq.enums.vip.VipStatusEnum;
|
||||
import com.ruoyi.xq.enums.vip.VipTypeEnum;
|
||||
import com.ruoyi.xq.manager.OrderNoUtil;
|
||||
import com.ruoyi.xq.mapper.UserVipMapper;
|
||||
import com.ruoyi.xq.service.UserService;
|
||||
import com.ruoyi.xq.service.UserStatusService;
|
||||
import com.ruoyi.xq.service.UserVipService;
|
||||
import com.ruoyi.xq.service.VipOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -44,6 +47,10 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> imple
|
||||
|
||||
@Autowired
|
||||
private VipOrderService vipOrderService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserStatusService userStatusService;
|
||||
|
||||
@Override
|
||||
public UserVip getUserVip(Long userId, Integer vipType){
|
||||
@@ -132,6 +139,9 @@ 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));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,10 +150,27 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeVip(Long id) {
|
||||
this.update(Wrappers.lambdaUpdate(UserVip.class)
|
||||
.eq(UserVip::getId,id)
|
||||
.set(UserVip::getVipStatus, VipStatusEnum.CLOSE.getCode()));
|
||||
UserVip userVip = this.getById(id);
|
||||
UserVipService service = SpringUtil.getBean(UserVipService.class);
|
||||
service.checkUserVip(userVip.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user