修改话费定时任务问题

dev-discount
袁野 2 years ago
parent a860b4d79c
commit 3cd01161b4
  1. 15
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  2. 12
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.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<String, Object> map = new HashMap<>();
map.put("payStatus" , String.valueOf(102));
map.put("rechargeStatus" , String.valueOf(204));
List<OutRechargeOrder> 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<OutRechargeChildOrder> 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("话费定时任务 -> 结束任务");
}
/**

@ -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<String, Object> 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

Loading…
Cancel
Save