| | |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.mapper.UserPointMapper; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.vo.UserPointDetailVO; |
| | | import com.ruoyi.account.vo.UserPointStatistics; |
| | | import com.ruoyi.account.vo.UserPointVO; |
| | | import com.ruoyi.account.vo.*; |
| | | import com.ruoyi.common.core.annotation.Excel; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.PhoneNumberValidator; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.enums.PointChangeType; |
| | | import com.ruoyi.system.api.domain.SysConfig; |
| | | import com.ruoyi.system.api.feignClient.SysConfigClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private UserPointService userPointService; |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private SysConfigClient sysConfigClient; |
| | | @Autowired |
| | | private UserPointMapper userPointMapper; |
| | | |
| | | |
| | | @Override |
| | | public UserPointVO getUserPoint(Long userId) { |
| | | AppUser appUser = appUserService.getById(userId); |
| | | UserPointVO userPointVO = new UserPointVO(); |
| | | userPointVO.setTotalPoint(appUser.getUserTotalPoint() ); |
| | | userPointVO.setTotalPoint(appUser.getTotalPoint() ); |
| | | userPointVO.setConsumePoint(appUser.getAvailablePoint()); |
| | | userPointVO.setRechargePoint(appUser.getRechargePoint()); |
| | | userPointVO.setCancelPoint(appUser.getCancelPoint()); |
| | | userPointVO.setExpendPoint(appUser.getExchangePoint()); |
| | | userPointVO.setTransferableInPoint(appUser.getTransferableInPoint()); |
| | | userPointVO.setTransferableOutPoint(appUser.getTransferableOutPoint()); |
| | | R<SysConfig> info = sysConfigClient.getInfo(9L); |
| | | if (info == null || info.getData() == null) { |
| | | throw new RuntimeException("获取积分兑换比例配置失败"); |
| | | } |
| | | String configValue = info.getData().getConfigValue(); |
| | | if (StringUtils.isBlank(configValue)) { |
| | | throw new RuntimeException("积分兑换比例配置值为空"); |
| | | } |
| | | Boolean isTransferable = Boolean.valueOf(configValue.trim()); |
| | | userPointVO.setIsTransferable(isTransferable); |
| | | return userPointVO; |
| | | } |
| | | |
| | |
| | | return R.fail("不能转增给自己"); |
| | | } |
| | | |
| | | if (null==appUserForPhoe.getTotalPoint()){ |
| | | appUserForPhoe.setTotalPoint(0); |
| | | } |
| | | if (null==appUserForPhoe.getTransferableInPoint()){ |
| | | appUserForPhoe.setTransferableInPoint(0); |
| | | } |
| | | if(null==appUserForPhoe.getAvailablePoint()){ |
| | | appUserForPhoe.setAvailablePoint(0); |
| | | } |
| | | |
| | | Integer historicalPoint = appUserForPhoe.getAvailablePoint();//历史积分 |
| | | Integer balance = historicalPoint +point;//变动后积分 |
| | | |
| | | appUserForPhoe.setAvailablePoint(balance);//可用积分增加 |
| | | |
| | | appUserForPhoe.setTotalPoint(appUserForPhoe.getTotalPoint() + point);//总积分增加 |
| | | appUserForPhoe.setTransferableInPoint(appUserForPhoe.getTransferableInPoint() + point);//转入积分增加 |
| | | |
| | |
| | | userPointService.save(userPoint); |
| | | } |
| | | |
| | | if (null==appUser.getTotalPoint()){ |
| | | appUser.setTotalPoint(0); |
| | | } |
| | | if (null==appUser.getTransferableOutPoint()){ |
| | | appUser.setTransferableOutPoint(0); |
| | | } |
| | | if (null==appUser.getAvailablePoint()){ |
| | | appUser.setAvailablePoint(0); |
| | | } |
| | | Integer historicalPoint2 = appUser.getAvailablePoint();//历史积分 |
| | | Integer balance2 = historicalPoint2 - point;//变动后积分 |
| | | |
| | | |
| | | appUser.setAvailablePoint(balance2);//可用积分减少 |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + point);//总积分增加 |
| | |
| | | }); |
| | | return userPointIPage; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<UserPointDetailVO> getUserPontDetailPageList(Collection<Integer> types, Long id, Integer pageCurr, Integer pageSize) { |
| | | PageInfo<UserPointDetailVO> pageInfo = new PageInfo<>(pageCurr, pageSize); |
| | | List<UserPointDetailVO> list =baseMapper.getUserPontDetailPageList(pageInfo,id,types); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectRechargeAndUse(String name, String phone, LocalDateTime beginTime, LocalDateTime endTime,Integer type) { |
| | | |
| | | return baseMapper.selectRechargeAndUse(name,phone,beginTime,endTime,type); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<UserPointStatisticsPageVO> getUserPointStatisticsPageList(Collection<Integer> types, String name, String phone, LocalDateTime beginTime, LocalDateTime endTime, Integer pageCurr, Integer pageSize) { |
| | | PageInfo<UserPointStatisticsPageVO> pageInfo = new PageInfo<>(pageCurr, pageSize); |
| | | List<UserPointStatisticsPageVO>list=baseMapper.getUserPointStatisticsPageList(pageInfo,types,name,phone,beginTime,endTime); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | |
| | | } |