package com.stylefeng.guns.modular.system.util;
|
|
|
import com.stylefeng.guns.modular.account.controller.AppOrderController;
|
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
|
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
|
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
|
import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
|
import lombok.extern.slf4j.Slf4j;
|
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.net.InetAddress;
|
import java.net.UnknownHostException;
|
|
|
/**
|
* 定时任务工具类
|
*/
|
@Slf4j
|
@Component
|
public class TaskUtil implements ApplicationListener<WebServerInitializedEvent> {
|
|
@Autowired
|
private IUserCouponRecordService userCouponRecordService;
|
|
@Autowired
|
private IUserMerchantCouponService userMerchantCouponService;
|
|
@Autowired
|
private AppOrderController appOrderController;
|
|
@Autowired
|
private IOrderPrivateCarService orderPrivateCarService;
|
@Autowired
|
private IPaymentRecordService paymentRecordService;
|
@Autowired
|
private IIncomeService incomeService;
|
|
|
@Autowired
|
private IOrderCrossCityService orderCrossCityService;
|
|
@Autowired
|
private IOrderLogisticsService orderLogisticsService;
|
|
@Autowired
|
private IOrderTaxiService orderTaxiService;
|
|
@Autowired
|
private ChinaMobileUtil chinaMobileUtil;
|
|
@Autowired
|
private IUserInfoService userInfoService;
|
|
@Autowired
|
private IDriverService driverService;
|
@Autowired
|
private ICompanyService companyService;
|
|
private String ip = null;
|
|
|
/**
|
* 每隔一分钟去处理的定时任务
|
*/
|
@Scheduled(fixedRate = 1000 * 60)
|
public void taskMinute() {
|
if(null != ip && "10.31.182.11".equals(ip)){
|
try {
|
//处理超时未支付的订单
|
// timoutNoPayment();
|
//修改过期的优惠券
|
userCouponRecordService.updateTimeOut();
|
//修改过期的商家优惠券
|
userMerchantCouponService.updateExpired();
|
} 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);
|
InetAddress inetAddress = null;
|
try {
|
inetAddress = InetAddress.getLocalHost();
|
} catch (UnknownHostException e) {
|
throw new RuntimeException(e);
|
}
|
System.out.println("本机 IP 地址: " + inetAddress.getHostAddress());
|
this.ip = inetAddress.getHostAddress();
|
}
|
}
|