parent
55247ab60d
commit
24f6a46c8b
@ -0,0 +1,127 @@ |
||||
package com.hai.schedule; |
||||
|
||||
import com.hai.entity.OutRechargeChildOrder; |
||||
import com.hai.entity.OutRechargeOrder; |
||||
import com.hai.service.OutRechargeChildOrderService; |
||||
import com.hai.service.OutRechargeOrderService; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* @serviceName HighRechargeOrderSchedule.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 充值订单定时任务
|
||||
* @createTime 09:57 2023/1/13 |
||||
**/ |
||||
@Configuration |
||||
public class HighRechargeOrderSchedule { |
||||
|
||||
Logger log = LoggerFactory.getLogger(HighRechargeOrderSchedule.class); |
||||
|
||||
@Resource |
||||
private OutRechargeOrderService outRechargeOrderService; |
||||
|
||||
@Resource |
||||
private OutRechargeChildOrderService rechargeChildOrderService; |
||||
|
||||
/** |
||||
* @return void |
||||
* @Author Sum1Dream |
||||
* @name cancelMobileOrder.java |
||||
* @Description // 取消话费订单
|
||||
* @Date 3:33 下午 2021/12/10 |
||||
* @Param [] |
||||
*/ |
||||
@Scheduled(cron = "0 0/1 * * * ?") //每15分钟执行一次
|
||||
public void cancelMobileOrder() { |
||||
List<OutRechargeOrder> orderList = outRechargeOrderService.getOutRechargeOrderList(); |
||||
if (orderList != null && orderList.size() > 0) { |
||||
for (OutRechargeOrder order : orderList) { |
||||
try { |
||||
outRechargeOrderService.cancelOrder(order.getId()); |
||||
} catch (Exception e) { |
||||
log.error("HighCouponSchedule --> expiredCoupon() error!", e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @return void |
||||
* @Author Sum1Dream |
||||
* @name cancelOrder.java |
||||
* @Description // 定时发起
|
||||
* @Date 14:18 2022/5/31 |
||||
* @Param [] |
||||
*/ |
||||
@Scheduled(cron = "0 0/1 * * * ?") //每5分钟执行一次
|
||||
public void initRechargeOrder() { |
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("payStatus", String.valueOf(102)); |
||||
map.put("rechargeStatus", String.valueOf(205)); |
||||
List<OutRechargeOrder> orderList = outRechargeOrderService.getListRechargeOrder(map); |
||||
if (orderList.size() > 0) { |
||||
for (OutRechargeOrder order : orderList) { |
||||
try { |
||||
// 查询充值子订单
|
||||
Map<String, Object> childOrderMap = new HashMap<>(); |
||||
childOrderMap.put("parent_order_id", order.getId()); |
||||
childOrderMap.put("status", 102); |
||||
|
||||
List<OutRechargeChildOrder> childOrderList = rechargeChildOrderService.getListRechargeChildOrder(childOrderMap); |
||||
|
||||
System.out.println("话费定时任务 -> 判断是否存在已支付订单:订单id:" + order.getId()); |
||||
if (childOrderList.size() == 0) { |
||||
Date rechargeTime = order.getCreateTimed(); |
||||
Date currentTime = new Date(); |
||||
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); |
||||
|
||||
// 充值时间小于72
|
||||
if (hours < 72) { |
||||
System.out.println("话费定时任务 -> 请求慢充:订单id:" + order.getId()); |
||||
outRechargeOrderService.pollRequest(order); |
||||
continue; |
||||
} |
||||
System.out.println("话费定时任务 -> 退款任务" + order.getId()); |
||||
outRechargeOrderService.rechargeOrderToRefund(order.getId()); |
||||
|
||||
} |
||||
} catch (Exception e) { |
||||
log.error("HighCouponSchedule --> expiredCoupon() error!", e); |
||||
} |
||||
} |
||||
} |
||||
System.out.println("话费定时任务 -> 结束任务"); |
||||
} |
||||
|
||||
@Scheduled(cron = "0 0/1 * * * ?") //每分钟执行一次
|
||||
public void failRechargeOrder() { |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
|
||||
map.put("payStatus" , 102); |
||||
map.put("rechargeStatus" , 203); |
||||
|
||||
List<OutRechargeOrder> orderList = outRechargeOrderService.getListRechargeOrder(map); |
||||
if (orderList != null && orderList.size() > 0) { |
||||
for (OutRechargeOrder order : orderList) { |
||||
try { |
||||
outRechargeOrderService.rechargeOrderToRefund(order.getId()); |
||||
} catch (Exception e) { |
||||
log.error("HighCouponSchedule --> expiredCoupon() error!", e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue