From 3cd01161b40e59ebd5c4959b493f1ecce2f45f07 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Wed, 6 Jul 2022 16:55:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=9D=E8=B4=B9=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hai/schedule/HighOrderSchedule.java | 15 +++++++++++---- .../service/impl/OutRechargeOrderServiceImpl.java | 12 ++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 19f9dfec..2f3e9b28 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -23,6 +23,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; /** * @Auther: 胡锐 @@ -92,14 +93,15 @@ public class HighOrderSchedule { * @Param [] * @return void */ - @Scheduled(cron="0 0/5 * * * ?") //每10分钟执行一次 + @Scheduled(cron="0 0/1 * * * ?") //每10分钟执行一次 public void initRechargeOrder() { Map map = new HashMap<>(); map.put("payStatus" , String.valueOf(102)); map.put("rechargeStatus" , String.valueOf(204)); List orderList = outRechargeOrderService.getListRechargeOrder(map); - System.out.println("订单数量------------------------------------------------------------------------------" + orderList.size()); + System.out.println("话费定时任务 -> 开始循环数据:开始 需要操作的订单数量:" + orderList.size()); + if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { try { @@ -110,6 +112,7 @@ public class HighOrderSchedule { List childOrderList = rechargeChildOrderService.getListRechargeChildOrder(childOrderMap); + System.out.println("话费定时任务 -> 判断是否存在已支付订单:订单id:" + order.getId()); if (childOrderList.size() == 0) { Date rechargeTime = order.getCreateTimed(); Date currentTime = new Date(); @@ -117,14 +120,17 @@ public class HighOrderSchedule { // 判断快充 并且 充值时间小于6 if (order.getRechargeType() == 1 && hours < 6) { + System.out.println("话费定时任务 -> 请求快充:订单id:" + order.getId()); outRechargeOrderService.pollRequest(order); - return; + continue; } // 判断慢充 并且 充值时间小于72 if (order.getRechargeType() == 2 && hours < 72) { + System.out.println("话费定时任务 -> 请求慢充:订单id:" + order.getId()); outRechargeOrderService.pollRequest(order); - return; + continue; } + System.out.println("话费定时任务 -> 退款任务" + order.getId()); outRechargeOrderService.rechargeOrderToRefund(order.getId()); } @@ -133,6 +139,7 @@ public class HighOrderSchedule { } } } + System.out.println("话费定时任务 -> 结束任务"); } /** diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index da66bed6..bc215ca5 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -30,6 +30,8 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -46,6 +48,8 @@ import java.util.concurrent.TimeUnit; @Service("outRechargeOrderService") public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { + private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); + @Resource private OutRechargeOrderMapper outRechargeOrderMapper; @@ -730,7 +734,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { // 查询充值产品 OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null); - + System.out.println("话费定时任务 -> 需要重新充值:开始"); // 查询充值子订单 Map childOrderMap = new HashMap<>(); @@ -785,9 +789,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } for (String s : rechargePlatform) { - TimeUnit.SECONDS.sleep(1); - System.out.println("-----------------------------------------------------------------------------------------------------------------------------------------------------" + new Date()); // 尖椒充值 + System.out.println("话费定时任务 -> 需要重新充值:尖椒开始"); if (s.equals("1") && type == 1) { object.put("out_order_id", orderNo); object.put("amount", outRechargePrice.getRechargePrice()); @@ -808,12 +811,12 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } // 龙阅充值 if (s.equals("2") && type == 2) { + System.out.println("话费定时任务 -> 需要重新充值:龙阅开始"); object.put("out_trade_num", orderNo); object.put("product_id", outRechargePrice.getGoodsId()); object.put("mobile", outRechargeOrder.getRechargeContent()); object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl()); JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); - System.out.println("龙阅请求回调地址---------------------" + CommonSysConst.getSysConfig().getLyNotifyUrl()); object.put("return_content", returnObject); if (returnObject != null && returnObject.getLong("errno") == 0) { childOrder.setStatus(102); @@ -854,6 +857,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { outRechargeOrder.setRechargeStatus(204); } outRechargeOrderService.updateOrder(outRechargeOrder); + System.out.println("话费定时任务 -> 需要重新充值:结束"); } @Override