| | |
| | | package com.ruoyi.account.task; |
| | | |
| | | |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | @Resource |
| | | private TAppUserVipDetailService tAppUserVipDetailService; |
| | | |
| | | @Resource |
| | | private TAppUserService appUserService; |
| | | |
| | | |
| | | /** |
| | |
| | | .orderByDesc(TAppUserVipDetail::getStartTime).list(); |
| | | //判断sendNum是否包括当前月份 |
| | | for (TAppUserVipDetail recentDetail : recentDetails) { |
| | | if (recentDetail.getSendMonth()!=null&&recentDetail.getSendMonth().contains(monthNum+"")){ |
| | | //如果包含,则不执行操作 |
| | | continue; |
| | | }else { |
| | | //如果不包含,则更新sendNum,并且赠送优惠卷 |
| | | TAppUserVipDetail byId = tAppUserVipDetailService.getById(recentDetail.getId()); |
| | | if (byId==null){ |
| | | byId.setSendMonth(byId.getSendMonth()+monthNum); |
| | | }else{ |
| | | byId.setSendMonth(","+byId.getSendMonth()+monthNum); |
| | | } |
| | | |
| | | |
| | | tAppUserVipDetailService.updateById(byId); |
| | | //赠送优惠卷 |
| | | tAppUserVipDetailService.giveVipCoupun(recentDetail.getAppUserId(), recentDetail.getVipId()); |
| | | } |
| | | tAppUserVipDetailService.giveVipCoupun(recentDetail.getAppUserId(), recentDetail.getVipId(),recentDetail.getId(),monthNum); |
| | | |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | @Scheduled(fixedRate = 1000 * 60) |
| | | public void changeVipId(){ |
| | | LocalDateTime currentDate = LocalDateTime.now(); |
| | | List<TAppUserVipDetail> recentDetails = tAppUserVipDetailService.lambdaQuery() |
| | | .le(TAppUserVipDetail::getStartTime, currentDate) |
| | | .ge(TAppUserVipDetail::getEndTime, currentDate) |
| | | .orderByDesc(TAppUserVipDetail::getStartTime).list(); |
| | | for (TAppUserVipDetail recentDetail : recentDetails) { |
| | | TAppUser byId = appUserService.getById(recentDetail.getAppUserId()); |
| | | if (byId!=null) { |
| | | byId.setVipId(recentDetail.getVipId()); |
| | | appUserService.updateById(byId); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |