@author Exrickx
| 21 | * @author Exrickx |
| 22 | */ |
| 23 | @Component |
| 24 | public class Jobs { |
| 25 | |
| 26 | final static Logger log= LoggerFactory.getLogger(Jobs.class); |
| 27 | |
| 28 | @Autowired |
| 29 | private PayService payService; |
| 30 | |
| 31 | @Autowired |
| 32 | private PayDao payDao; |
| 33 | |
| 34 | @Autowired |
| 35 | private EmailUtils emailUtils; |
| 36 | |
| 37 | @Autowired |
| 38 | private StringRedisTemplate redisTemplate; |
| 39 | |
| 40 | @Value("${email.sender}") |
| 41 | private String EMAIL_SENDER; |
| 42 | |
| 43 | private static final String CLOSE_KEY="XPAY_CLOSE_KEY"; |
| 44 | |
| 45 | /** |
| 46 | * 每日凌晨清空除捐赠和审核中以外的数据 |
| 47 | */ |
| 48 | @Scheduled(cron="0 0 0 * * ?") |
| 49 | public void cronJob(){ |
| 50 | |
| 51 | List<Pay> list=payDao.getByStateIs(2); |
| 52 | list.addAll(payDao.getByStateIs(3)); |
| 53 | for(Pay p:list){ |
| 54 | try { |
| 55 | payService.delPay(p.getId()); |
| 56 | }catch (Exception e){ |
| 57 | log.error("定时删除数据"+p.getId()+"失败"); |
| 58 | e.printStackTrace(); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | log.info("定时执行清空驳回和通过不展示的数据完毕"); |
| 63 | |
| 64 | //设置未审核或已扫码数据为支付失败 |
| 65 | List<Pay> list1=payDao.getByStateIs(0); |
| 66 | list1.addAll(payDao.getByStateIs(4)); |
| 67 | for(Pay p:list1){ |
| 68 | p.setState(2); |
| 69 | p.setUpdateTime(new Date()); |
| 70 | try { |
| 71 | payService.updatePay(p); |
| 72 | }catch (Exception e){ |
| 73 | log.error("设置未审核数据"+p.getId()+"为支付失败出错"); |
| 74 | e.printStackTrace(); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | log.info("定时执行设置未审核数据为支付失败完毕"); |
| 79 | } |
| 80 |
nothing calls this directly
no outgoing calls
no test coverage detected