| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.modular.account.service.UserWithdrawalService; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.CusApplicationExample; |
| | | import com.stylefeng.guns.modular.system.model.UserWithdrawal; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IOrderService; |
| | | import com.stylefeng.guns.modular.system.service.IUserMerchantCouponService; |
| | | import com.unionpay.upyzt.resp.CusApplicationResp; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.web.context.WebServerInitializedEvent; |
| | | import org.springframework.boot.web.server.WebServer; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * 定时任务工具类 |
| | | */ |
| | | @Component |
| | | public class TaskUtil { |
| | | |
| | | public class TaskUtil implements ApplicationListener<WebServerInitializedEvent> { |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderService orderService; |
| | | |
| | | |
| | | @Autowired |
| | | private JGPushUtil jgPushUtil; |
| | | |
| | | |
| | | @Autowired |
| | | private IUserMerchantCouponService userMerchantCouponService; |
| | | @Autowired |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 每隔一分钟去处理的定时任务 |
| | | */ |
| | | // @Scheduled(fixedRate = 1000 * 60) |
| | | // public void userWith(){ |
| | | // try { |
| | | // List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>()); |
| | | // List<UserWithdrawal> collect = userWithdrawals.stream().filter(e -> "succeeded".equals(e.getApplicationStatus())).collect(Collectors.toList()); |
| | | // for (UserWithdrawal userWithdrawal : collect) { |
| | | // CusApplicationResp cusApplicationResp = CusApplicationExample.retrieveByOutRequestNo(userWithdrawal.getOutRequestNo()); |
| | | // System.out.println("请求订单号:"+userWithdrawal.getApplicationStatus()+"================="+cusApplicationResp); |
| | | // |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 每天的凌晨执行的任务 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | public void taskDay(){ |
| | | public void taskDay() { |
| | | try { |
| | | //生成当天的司机活动 |
| | | driverService.addTodayActivity(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | // |
| | | // /** |
| | | // * 每月第一天的1点执行的任务 |
| | | // */ |
| | | // @Scheduled(cron = "0 0 1 1 * *") |
| | | // public void taskMonth(){ |
| | | // try { |
| | | // |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | @Override |
| | | public void onApplicationEvent(WebServerInitializedEvent event) { |
| | | // 获取环境对象 |
| | | WebServer webServer = event.getWebServer(); |
| | | // 获取端口号 |
| | | int port = webServer.getPort(); |
| | | // 打印端口号 |
| | | System.out.println("Spring Boot应用已启动,访问端口:" + port); |
| | | } |
| | | } |