2023-03-04 16:29:55 +08:00
|
|
|
|
package com.jsowell.quartz.task;
|
|
|
|
|
|
|
|
|
|
|
|
import com.jsowell.common.util.DateUtils;
|
2023-03-25 11:10:15 +08:00
|
|
|
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.pile.service.IOrderBasicInfoService;
|
2023-03-25 11:10:15 +08:00
|
|
|
|
import com.jsowell.service.OrderService;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
2023-03-25 11:10:15 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import java.util.Date;
|
2023-03-25 11:10:15 +08:00
|
|
|
|
import java.util.List;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
@Component("jsowellTask")
|
|
|
|
|
|
public class JsowellTask {
|
|
|
|
|
|
|
|
|
|
|
|
private final Logger log = LoggerFactory.getLogger(JsowellTask.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IOrderBasicInfoService orderBasicInfoService;
|
|
|
|
|
|
|
2023-03-25 11:10:15 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private OrderService orderService;
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 关闭15分钟未支付的订单
|
|
|
|
|
|
* close15MinutesOfUnpaidOrders
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void close15MinutesOfUnpaidOrders() {
|
|
|
|
|
|
// log.info("关闭15分钟未支付的订单");
|
|
|
|
|
|
orderBasicInfoService.close15MinutesOfUnpaidOrders();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 关闭启动失败的订单
|
|
|
|
|
|
* 订单支付成功,在15分钟内未启动,
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void closeStartFailedOrder() {
|
|
|
|
|
|
// 查询出最近2天支付成功,并且订单状态为未启动的订单
|
|
|
|
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addDays(new Date(), -2));
|
|
|
|
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
|
|
|
orderBasicInfoService.closeStartFailedOrder(startTime, endTime);
|
|
|
|
|
|
}
|
2023-03-25 11:10:15 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询预约充电的订单并启动
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void appointmentOrderStart() {
|
|
|
|
|
|
// 查询出 已支付 设置预约充电 未启动 的订单
|
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
List<OrderBasicInfo> list = orderBasicInfoService.getAppointmentOrder(now);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
for (OrderBasicInfo order : list) {
|
|
|
|
|
|
orderService.startCharging(order);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|