| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.BalanceChangeRecordCopy; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.account.api.model.UserPointCopy; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.mapper.UserPointCopyMapper; |
| | | import com.ruoyi.account.mapper.UserPointMapper; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.PointSettingService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.account.service.VipSettingService; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.vo.UserPointDetailVO; |
| | | import com.ruoyi.account.vo.UserPointStatistics; |
| | | import com.ruoyi.account.vo.UserPointVO; |
| | |
| | | private UserPointCopyMapper userPointCopyMapper; |
| | | @Resource |
| | | private UserPointService userPointService; |
| | | @Resource |
| | | private IAppUserGiveawayTemporaryService appUserGiveawayTemporaryService; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | public UserPointVO getUserPoint(Long userId) { |
| | | AppUser appUser = appUserService.getById(userId); |
| | | VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userId); |
| | | |
| | | List<UserPointCopy> userPointCopies = userPointCopyMapper.selectList(new LambdaQueryWrapper<UserPointCopy>() |
| | | .eq(UserPointCopy::getAppUserId, userId) |
| | | .eq(UserPointCopy::getType, 2)); |
| | | |
| | | Integer totalPoint = userPointCopies.stream() |
| | | .mapToInt(UserPointCopy::getVariablePoint) |
| | | .sum(); |
| | | |
| | | List<AppUserGiveawayTemporary> list = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>().eq(AppUserGiveawayTemporary::getAppUserId, userId)); |
| | | int totalPoint = 0; |
| | | int sharePoint = 0; |
| | | int shopAchievementPoint = 0; |
| | | int shopSharePoint = 0; |
| | | if(list.size() > 0){ |
| | | totalPoint = list.stream().mapToInt(AppUserGiveawayTemporary::getTotalPoint).sum(); |
| | | sharePoint = list.stream().mapToInt(AppUserGiveawayTemporary::getSharePoint).sum(); |
| | | shopAchievementPoint = list.stream().mapToInt(AppUserGiveawayTemporary::getShopAchievementPoint).sum(); |
| | | shopSharePoint = list.stream().mapToInt(AppUserGiveawayTemporary::getShopSharePoint).sum(); |
| | | } |
| | | UserPointVO userPointVO = new UserPointVO(); |
| | | userPointVO.setTotalPoint(totalPoint); |
| | | userPointVO.setTotalPoint(appUser.getTotalPoint() + totalPoint); |
| | | userPointVO.setConsumePoint(appUser.getAvailablePoint()); |
| | | userPointVO.setShopPoint(appUser.getShopPoint()); |
| | | userPointVO.setSharePoint(appUser.getSharePoint()); |
| | | userPointVO.setSharePoint(appUser.getSharePoint() + sharePoint); |
| | | userPointVO.setPullNewPoint(appUser.getTotalInvitePoint()); |
| | | userPointVO.setShopAchievementPoint(appUser.getShopAchievementPoint()); |
| | | userPointVO.setShopSharePoint(appUser.getShopSharePoint()); |
| | | userPointVO.setShopAchievementPoint(appUser.getShopAchievementPoint() + shopAchievementPoint); |
| | | userPointVO.setShopSharePoint(appUser.getShopSharePoint() + shopSharePoint); |
| | | userPointVO.setGiftPoint(vipSetting.getVipGiftRole() == 1 ? 1 : 0); |
| | | return userPointVO; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public PageInfo<UserPointDetailVO> getUserPointDetail(Long userId, LocalDateTime startTime, LocalDateTime endTime, Integer type, Integer pageCurr, Integer pageSize) { |
| | | PageInfo<UserPointCopy> pageInfo = new PageInfo<>(pageCurr, pageSize); |
| | | PageInfo<UserPointCopy> page = userPointCopyMapper.selectPage(pageInfo, new QueryWrapper<UserPointCopy>() |
| | | .between(startTime != null, "create_time", startTime, endTime) |
| | | .eq(type != null, "type", type) |
| | | .eq("app_user_id", userId).orderByDesc("create_time")); |
| | | if (CollectionUtil.isNotEmpty(page.getRecords())) { |
| | | List<UserPointDetailVO> collect = page.getRecords().stream().map(p -> { |
| | | UserPointDetailVO userPointDetailVO = new UserPointDetailVO(); |
| | | if (p.getType() != null && (p.getType().equals(12) || p.getType().equals(13))){ |
| | | Long appUserId = p.getObjectId(); |
| | | AppUser appUser = appUserService.getById(appUserId); |
| | | userPointDetailVO.setName(appUser.getName()); |
| | | } |
| | | userPointDetailVO.setType(p.getType()); |
| | | userPointDetailVO.setVariablePoint(p.getVariablePoint()); |
| | | String format = p.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | userPointDetailVO.setCreateTime(format); |
| | | Integer historicalPoint = p.getHistoricalPoint(); |
| | | Integer balance = p.getBalance(); |
| | | if (historicalPoint != null && balance != null) { |
| | | userPointDetailVO.setFlag(historicalPoint > balance ? 2 : 1); |
| | | } |
| | | return userPointDetailVO; |
| | | }).collect(Collectors.toList()); |
| | | PageInfo<UserPointDetailVO> pageInfo1 = new PageInfo<>(pageCurr, pageSize); |
| | | pageInfo1.setRecords(collect); |
| | | pageInfo1.setTotal(page.getTotal()); |
| | | pageInfo1.setCurrent(page.getCurrent()); |
| | | pageInfo1.setSize(page.getSize()); |
| | | return pageInfo1; |
| | | PageInfo<UserPointDetailVO> pageInfo = new PageInfo<>(pageCurr, pageSize); |
| | | List<UserPointDetailVO> userPointDetail = this.baseMapper.getUserPointDetail(pageInfo, userId, startTime, endTime, type); |
| | | for (UserPointDetailVO userPointDetailVO : userPointDetail) { |
| | | Integer type1 = userPointDetailVO.getType(); |
| | | if (type1 != null && type1.equals(12)){ |
| | | AppUser appUser = appUserService.getById(userPointDetailVO.getReceiveUserId()); |
| | | userPointDetailVO.setName(appUser.getName()); |
| | | } |
| | | if (type1 != null && type1.equals(13)){ |
| | | AppUser appUser = appUserService.getById(userPointDetailVO.getTransferUserId()); |
| | | userPointDetailVO.setName(appUser.getName()); |
| | | } |
| | | Integer historicalPoint = userPointDetailVO.getHistoricalPoint(); |
| | | Integer balance = userPointDetailVO.getBalance(); |
| | | if (historicalPoint != null && balance != null) { |
| | | userPointDetailVO.setFlag(historicalPoint > balance ? 2 : 1); |
| | | } |
| | | } |
| | | return null; |
| | | |
| | | pageInfo.setRecords(userPointDetail); |
| | | return pageInfo; |
| | | } |
| | | |
| | | |