| | |
| | | /** |
| | | * 定时计算用户过期积分 |
| | | */ |
| | | @Scheduled(cron = "0 20 9 * * ?") |
| | | @Scheduled(cron = "0 10 1 * * ?") |
| | | public void calculatingExpiredPoint() { |
| | | log.info("过期积分计算开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); |
| | | LocalDate now = LocalDate.now().minusDays(1);//前一天 |
| | | LocalDate lastYear = now.minus(1, ChronoUnit.YEARS); // 日期减去一年 |
| | | List<ExpiredPointDTO> pointDTOS = customerPointDetailMapper.tongjiExpiredPoint(lastYear); |
| | | List<ExpiredPointDTO> pointDTOS = customerPointDetailMapper.tongjiExpiredPoint(lastYear,null); |
| | | if(pointDTOS != null && pointDTOS.size() > 0){ |
| | | for (ExpiredPointDTO pointDTO : pointDTOS) { |
| | | if(pointDTO.getAddPoint().intValue()> pointDTO.getReducePoint().intValue()){ //积分增加大于减少 |
| | |
| | | customerPointDetail.setChangeType(Constants.POINT_CHANGE_TYPE.reduce.name()); |
| | | customerPointDetail.setType(Constants.POINT_TYPE.expired.name()); |
| | | customerPointDetail.setPoint(expiredPoint); |
| | | customerPointDetail.setRecordDate(now); |
| | | customerPointDetail.setRecordDate(lastYear); |
| | | customerPointDetail.create("sys"); |
| | | customerPointDetail.setRemarks(DateUtils.toString(now,"yyyy-MM-dd")+"过期积分结算"); |
| | | customerPointDetailMapper.insert(customerPointDetail); |
| | |
| | | .eq(CustomerPoint::getCustomerId, pointDTO.getCustomerId()) |
| | | .eq(CustomerPoint::getUserId, pointDTO.getUserId())); |
| | | if(customerPoint == null ){ |
| | | customerPoint = new CustomerPoint(); |
| | | customerPoint.setCustomerId(pointDTO.getCustomerId()); |
| | | customerPoint.setUserId(pointDTO.getUserId()); |
| | | customerPoint.setTotalPoint(0); |
| | | customerPoint.setUsedPoint(0); |
| | | customerPoint.setExpiredPoint(0); |
| | | customerPoint.create("sys"); |
| | | customerPointMapper.insert(customerPoint); |
| | | log.error("用户积分记录不存在,userId={},customerId={}",pointDTO.getUserId(),pointDTO.getCustomerId()); |
| | | }else { |
| | | customerPoint.setExpiredPoint(expiredPoint); |
| | | customerPointMapper.updateById(customerPoint); |