优化话费定时任务代码

dev-discount
袁野 2 years ago
parent 7f634f1f0d
commit 2d13835ab0
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 6
      hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java
  3. 2
      hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java
  4. 174
      hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java
  5. 151
      hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java
  6. 57
      hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java
  7. 2
      hai-service/src/main/java/com/hai/common/utils/WxUtils.java
  8. 18
      hai-service/src/main/java/com/hai/config/RechargeConfig.java
  9. 26
      hai-service/src/main/java/com/hai/dao/OutRechargeChildOrderMapperExt.java
  10. 2
      hai-service/src/main/java/com/hai/entity/BsRechargeCode.java
  11. 2
      hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java
  12. 4
      hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java
  13. 54
      hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java
  14. 10
      hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java
  15. 6
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  16. 5
      hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java
  17. 96
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  18. 1
      hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java

File diff suppressed because one or more lines are too long

@ -262,7 +262,7 @@ public class OutRechargePriceController {
if ((outRechargePrice.getRechargePlatform().contains("-2-") || outRechargePrice.getRechargePlatform().contains("-3-") || outRechargePrice.getRechargePlatform().contains("-4-") ) && rechargeCodes.size() == 0) { if ((outRechargePrice.getRechargePlatform().contains("-2-") || outRechargePrice.getRechargePlatform().contains("-3-") || outRechargePrice.getRechargePlatform().contains("-4-") ) && rechargeCodes.size() == 0) {
log.error("OutRechargePriceController -> editPriceStatus() error!"); log.error("OutRechargePriceController -> editPriceStatus() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!");
} }
for (BsRechargeCode rechargeCode : rechargeCodes) { for (BsRechargeCode rechargeCode : rechargeCodes) {
@ -270,11 +270,11 @@ public class OutRechargePriceController {
if ((rechargeCode.getRechargePlatform() == 2 || rechargeCode.getRechargePlatform() == 3 || rechargeCode.getRechargePlatform() == 4) ){ if ((rechargeCode.getRechargePlatform() == 2 || rechargeCode.getRechargePlatform() == 3 || rechargeCode.getRechargePlatform() == 4) ){
if (rechargeCode.getGoodsId() == null) { if (rechargeCode.getGoodsId() == null) {
log.error("OutRechargePriceController -> editPriceStatus() error!"); log.error("OutRechargePriceController -> editPriceStatus() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!");
} }
if (rechargeCode.getGoodsId().length() == 0) { if (rechargeCode.getGoodsId().length() == 0) {
log.error("OutRechargePriceController -> editPriceStatus() error!"); log.error("OutRechargePriceController -> editPriceStatus() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!");
} }
} }

@ -18,6 +18,7 @@ import com.hai.model.UserInfoModel;
import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.model.OrderThirdPartyModel;
import com.hai.order.service.OrderService; import com.hai.order.service.OrderService;
import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderPayType;
import com.hai.order.type.RechargePlatformType;
import com.hai.service.OutRechargeChildOrderService; import com.hai.service.OutRechargeChildOrderService;
import com.hai.service.OutRechargeOrderService; import com.hai.service.OutRechargeOrderService;
import com.hai.service.impl.OutRechargeOrderServiceImpl; import com.hai.service.impl.OutRechargeOrderServiceImpl;
@ -174,6 +175,7 @@ public class OrderMobileRechargeController {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(thirdPartyModel.getOrderNo()); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(thirdPartyModel.getOrderNo());
if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) {
model.setRegOrderNo(outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo()); model.setRegOrderNo(outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo());
model.setRechargePlatform(RechargePlatformType.getDataByType(outRechargeOrder.getOutRechargeChildOrders().get(0).getRechargePlatform()).getName());
} }
model.setMemPhone(thirdPartyModel.getMemPhone()); model.setMemPhone(thirdPartyModel.getMemPhone());
model.setTitle(thirdPartyModel.getTitle()); model.setTitle(thirdPartyModel.getTitle());

@ -30,12 +30,14 @@ import java.io.PrintWriter;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Controller @Controller
@RequestMapping(value = "telChargeCallback") @RequestMapping(value = "telChargeCallback")
@Api(value = "话费充值回调业务") @Api(value = "话费充值回调业务")
public class OrderTelChargeCallbackController { public class OrderTelChargeCallbackController {
private static Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); private static Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class);
@Resource @Resource
@ -44,18 +46,6 @@ public class OrderTelChargeCallbackController {
@Resource @Resource
private OutRechargeChildOrderService outRechargeChildOrderService; private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private HighUserService highUserService;
@Resource
private ApiOrderRecordService apiOrderRecordService;
@Resource
private HighOrderService highOrderService;
@Resource
private OrderService orderService;
@RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST)
@ApiOperation(value = "尖椒充值回调") @ApiOperation(value = "尖椒充值回调")
@ -69,40 +59,13 @@ public class OrderTelChargeCallbackController {
log.info("尖椒订单充值-回调参数: " + dataObject); log.info("尖椒订单充值-回调参数: " + dataObject);
log.info("============回调任务End============="); log.info("============回调任务End=============");
// 1 尖椒 2 龙阅 // 判断是否充值成功
dataObject.put("orderNo" , dataObject.getString("out_order_id"));
// 查询充值记录订单
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id"));
// 查询充值订单
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// 判断是否充值成功 并发送微信小程序服务通知
if (dataObject.getInteger("status") == 3) { if (dataObject.getInteger("status") == 3) {
if (rechargeOrder.getRechargeStatus() ==201) { // 充值成功操作
new Thread(() -> { outRechargeOrderService.completeOrder(dataObject.getString("out_order_id"));
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedSuccess(
rechargeOrder.getRechargeContent() + "充值成功",
String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getOrderNo(),
rechargeOrder.getFinishTime(),
RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
outRechargeOrderService.completeOrder(rechargeOrder , childOrder);
// api商户订单
if (rechargeOrder.getPayType() == 6) {
apiOrderRecord(rechargeOrder);
}
} else { } else {
// 充值失败操作 // 充值失败操作
callbackResult(childOrder , rechargeOrder); callbackResult(dataObject.getString("out_order_id"));
} }
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
@ -132,31 +95,11 @@ public class OrderTelChargeCallbackController {
log.info("龙阅订单充值-回调参数: " + reqBodyStr); log.info("龙阅订单充值-回调参数: " + reqBodyStr);
log.info("============回调任务End============="); log.info("============回调任务End=============");
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(out_trade_num); // 判断是否充值成功
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// 判断是否充值成功 并发送微信小程序服务通知
if (state == 1) { if (state == 1) {
if (rechargeOrder.getRechargeStatus() ==201) { outRechargeOrderService.completeOrder(out_trade_num);
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedSuccess(
rechargeOrder.getRechargeContent() + "充值成功",
String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getOrderNo(),
rechargeOrder.getFinishTime(),
RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
outRechargeOrderService.completeOrder(rechargeOrder , childOrder);
// todo 代理商话费回调
// if (rechargeOrder.getPayType() == 6) {
// apiOrderRecord(rechargeOrder);
// }
} else { } else {
callbackResult(childOrder , rechargeOrder); callbackResult(out_trade_num);
} }
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
@ -170,55 +113,76 @@ public class OrderTelChargeCallbackController {
} }
} }
// 充值回调结果处理 @RequestMapping(value = "/rechargeCallbackByHg", method = RequestMethod.POST)
private void callbackResult(OutRechargeChildOrder childOrder , OutRechargeOrder rechargeOrder) throws Exception { @ApiOperation(value = "畅停充值回调")
@ResponseBody
// 101:充值成功 102: 充值中 103:充值失败 104 未充值 public void rechargeCallbackByHg(
// 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 @RequestParam(name = "mchid", required = false) String mchid,
if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) { @RequestParam(name = "out_order_id", required = false) String out_order_id,
@RequestParam(name = "orderid", required = true) String orderid,
Date rechargeTime = rechargeOrder.getCreateTimed(); @RequestParam(name = "return_time", required = false) String return_time,
Date currentTime = new Date(); @RequestParam(name = "return_price", required = false) String return_price,
// 当前时间减去充值时间 @RequestParam(name = "recharge_price", required = false) String recharge_price,
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); @RequestParam(name = "price", required = false) String price,
@RequestParam(name = "status", required = true) String status,
// // 判断快充 并且 充值时间小于6 @RequestParam(name = "phone", required = false) String phone,
// if (rechargeOrder.getRechargeType() == 1 && hours < 6) { @RequestParam(name = "secret_key", required = false) String secret_key,
// outRechargeOrderService.pollRequest(rechargeOrder); HttpServletResponse response) {
// return; try {
// }
// 判断慢充 并且 充值时间小于72
if (hours < 72) {
outRechargeOrderService.pollRequest(rechargeOrder); JSONObject dataObject = new JSONObject();
return;
dataObject.put("mchid" , mchid);
dataObject.put("out_order_id" , out_order_id);
dataObject.put("orderid" , orderid);
dataObject.put("return_time" , return_time);
dataObject.put("return_price" , return_price);
dataObject.put("recharge_price" , recharge_price);
dataObject.put("price" , price);
dataObject.put("status" , status);
dataObject.put("phone" , phone);
dataObject.put("secret_key" , secret_key);
log.info("============回调任务Start=============");
log.info("畅停订单充值-回调参数: " + dataObject);
log.info("============回调任务End=============");
// 判断是否充值成功 并发送微信小程序服务通知
if (Objects.equals(status, "1")) {
outRechargeOrderService.completeOrder(orderid);
} else {
// 充值失败操作
callbackResult(orderid);
} }
outRechargeOrderService.refundOrder(rechargeOrder.getId() , childOrder); response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer= response.getWriter();
writer.write("success");
// 发送充值失败 微信小程序服务通知
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedFail(
rechargeOrder.getRechargeContent() + "充值失败",
String.valueOf(rechargeOrder.getPayRealPrice()),
highUser.getOpenId());
}).start();
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
} }
} }
private void apiOrderRecord(OutRechargeOrder rechargeOrder) { // 充值回调结果处理
Map<String, Object> orderMap = new HashMap<>(); private void callbackResult(String orderNo) {
orderMap.put("orderId" , rechargeOrder.getId());
// 查询是否用重复订单 // 查询充值订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(orderNo);
OutRechargeChildOrder childOrder = rechargeOrder.getOutRechargeChildOrders().get(0);
apiOrderRecord.setStatus(100); childOrder.setStatus(103);
apiOrderRecord.setRequestTime(new Date()); childOrder.setUpdateTime(new Date());
apiOrderRecordService.updateOrderRecord(apiOrderRecord); outRechargeChildOrderService.updateOrder(childOrder);
rechargeOrder.setRechargeStatus(205);
outRechargeOrderService.updateOrder(rechargeOrder);
} }

@ -38,17 +38,6 @@ public class MobileRechargeNotifyController {
@Resource @Resource
private OutRechargeChildOrderService outRechargeChildOrderService; private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private HighUserService highUserService;
@Resource
private ApiOrderRecordService apiOrderRecordService;
@Resource
private HighOrderService highOrderService;
@Resource
private OrderService orderService;
@RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST)
@ApiOperation(value = "尖椒充值回调") @ApiOperation(value = "尖椒充值回调")
@ -62,35 +51,13 @@ public class MobileRechargeNotifyController {
log.info("尖椒订单充值-回调参数: " + dataObject); log.info("尖椒订单充值-回调参数: " + dataObject);
log.info("============回调任务End============="); log.info("============回调任务End=============");
// 1 尖椒 2 龙阅 // 判断是否充值成功
dataObject.put("orderNo" , dataObject.getString("out_order_id"));
// 查询充值记录订单
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id"));
// 查询充值订单
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// 判断是否充值成功 并发送微信小程序服务通知
if (dataObject.getInteger("status") == 3) { if (dataObject.getInteger("status") == 3) {
if (rechargeOrder.getRechargeStatus() ==201) { // 充值成功操作
new Thread(() -> { outRechargeOrderService.completeOrder(dataObject.getString("out_order_id"));
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedSuccess(
rechargeOrder.getRechargeContent() + "充值成功",
String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getOrderNo(),
rechargeOrder.getFinishTime(),
RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
outRechargeOrderService.completeOrder(rechargeOrder , childOrder);
} else { } else {
// 充值失败操作 // 充值失败操作
callbackResult(childOrder , rechargeOrder); callbackResult(dataObject.getString("out_order_id"));
} }
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
@ -120,27 +87,11 @@ public class MobileRechargeNotifyController {
log.info("龙阅订单充值-回调参数: " + reqBodyStr); log.info("龙阅订单充值-回调参数: " + reqBodyStr);
log.info("============回调任务End============="); log.info("============回调任务End=============");
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(out_trade_num); // 判断是否充值成功
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// 判断是否充值成功 并发送微信小程序服务通知
if (state == 1) { if (state == 1) {
if (rechargeOrder.getRechargeStatus() ==201) { outRechargeOrderService.completeOrder(out_trade_num);
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedSuccess(
rechargeOrder.getRechargeContent() + "充值成功",
String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getOrderNo(),
rechargeOrder.getFinishTime(),
RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
outRechargeOrderService.completeOrder(rechargeOrder , childOrder);
} else { } else {
callbackResult(childOrder , rechargeOrder); callbackResult(out_trade_num);
} }
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
@ -155,7 +106,7 @@ public class MobileRechargeNotifyController {
} }
@RequestMapping(value = "/rechargeCallbackByHg", method = RequestMethod.POST) @RequestMapping(value = "/rechargeCallbackByHg", method = RequestMethod.POST)
@ApiOperation(value = "嗨购充值回调") @ApiOperation(value = "畅停充值回调")
@ResponseBody @ResponseBody
public void rechargeCallbackByHg( public void rechargeCallbackByHg(
@RequestParam(name = "mchid", required = false) String mchid, @RequestParam(name = "mchid", required = false) String mchid,
@ -187,42 +138,17 @@ public class MobileRechargeNotifyController {
dataObject.put("secret_key" , secret_key); dataObject.put("secret_key" , secret_key);
log.info("============回调任务Start============="); log.info("============回调任务Start=============");
log.info("嗨购订单充值-回调参数: " + dataObject); log.info("畅停订单充值-回调参数: " + dataObject);
log.info("============回调任务End============="); log.info("============回调任务End=============");
// 1 尖椒 2 龙阅
// 查询充值记录订单
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(orderid);
// 查询充值订单
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// 判断是否充值成功 并发送微信小程序服务通知 // 判断是否充值成功 并发送微信小程序服务通知
if (Objects.equals(status, "1")) { if (Objects.equals(status, "1")) {
if (rechargeOrder.getRechargeStatus() ==201) {
new Thread(() -> { outRechargeOrderService.completeOrder(orderid);
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedSuccess(
rechargeOrder.getRechargeContent() + "充值成功",
String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getOrderNo(),
rechargeOrder.getFinishTime(),
RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
outRechargeOrderService.completeOrder(rechargeOrder , childOrder);
// api商户订单
// if (rechargeOrder.getPayType() == 6) {
// apiOrderRecord(rechargeOrder);
// }
} else { } else {
// 充值失败操作 // 充值失败操作
callbackResult(childOrder , rechargeOrder); callbackResult(orderid);
} }
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
@ -238,54 +164,19 @@ public class MobileRechargeNotifyController {
// 充值回调结果处理 // 充值回调结果处理
private void callbackResult(OutRechargeChildOrder childOrder , OutRechargeOrder rechargeOrder) throws Exception { private void callbackResult(String orderNo) {
// 101:充值成功 102: 充值中 103:充值失败 104 未充值
// 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) {
Date rechargeTime = rechargeOrder.getCreateTimed();
Date currentTime = new Date();
// 当前时间减去充值时间
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60));
// // 判断快充 并且 充值时间小于6
// if (rechargeOrder.getRechargeType() == 1 && hours < 6) {
// outRechargeOrderService.pollRequest(rechargeOrder);
// return;
// }
// 判断慢充 并且 充值时间小于72
if (hours < 72) {
outRechargeOrderService.pollRequest(rechargeOrder);
return;
}
outRechargeOrderService.refundOrder(rechargeOrder.getId() , childOrder); // 查询充值订单
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(orderNo);
OutRechargeChildOrder childOrder = rechargeOrder.getOutRechargeChildOrders().get(0);
// 发送充值失败 微信小程序服务通知 childOrder.setStatus(103);
new Thread(() -> { childOrder.setUpdateTime(new Date());
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); outRechargeChildOrderService.updateOrder(childOrder);
WxMsgConfig.rechargedFail( rechargeOrder.setRechargeStatus(205);
rechargeOrder.getRechargeContent() + "充值失败", outRechargeOrderService.updateOrder(rechargeOrder);
String.valueOf(rechargeOrder.getPayRealPrice()),
highUser.getOpenId());
}).start();
}
} }
private void apiOrderRecord(OutRechargeOrder rechargeOrder) {
Map<String, Object> orderMap = new HashMap<>();
orderMap.put("orderId" , rechargeOrder.getId());
// 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap);
apiOrderRecord.setStatus(100);
apiOrderRecord.setRequestTime(new Date());
apiOrderRecordService.updateOrderRecord(apiOrderRecord);
}
} }

@ -53,7 +53,7 @@ public class HighRechargeOrderSchedule {
* @Date 14:18 2022/5/31 * @Date 14:18 2022/5/31
* @Param [] * @Param []
*/ */
@Scheduled(cron = "0 0/1 * * * ?") //每5分钟执行一次 @Scheduled(cron = "0 0/5 * * * ?") //每5分钟执行一次
public void initRechargeOrder() { public void initRechargeOrder() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("payStatus", String.valueOf(102)); map.put("payStatus", String.valueOf(102));
@ -62,27 +62,20 @@ public class HighRechargeOrderSchedule {
if (orderList.size() > 0) { if (orderList.size() > 0) {
for (OutRechargeOrder order : orderList) { for (OutRechargeOrder order : orderList) {
try { try {
// 查询充值子订单
Map<String, Object> childOrderMap = new HashMap<>();
childOrderMap.put("parent_order_id", order.getId());
childOrderMap.put("status", 102);
List<OutRechargeChildOrder> childOrderList = rechargeChildOrderService.getListRechargeChildOrder(childOrderMap);
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) {
outRechargeOrderService.pollRequest(order);
continue;
}
outRechargeOrderService.rechargeOrderHandle(order , childOrderList.get(0));
// 定义小时数
Date rechargeTime = order.getCreateTimed();
Date currentTime = new Date();
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60));
// 查询当前订单是否超时 如果超过72小时则处理退款
if (hours < 72) {
outRechargeOrderService.pollRequest(order);
} else {
// 话费订单处理
outRechargeOrderService.rechargeOrderHandle(order.getOrderNo());
} }
} catch (Exception e) { } catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e); log.error("HighCouponSchedule --> expiredCoupon() error!", e);
} }
@ -91,29 +84,5 @@ public class HighRechargeOrderSchedule {
System.out.println("话费定时任务 -> 结束任务"); System.out.println("话费定时任务 -> 结束任务");
} }
@Scheduled(cron = "0 0/30 * * * ?") //每30分钟执行一次
public void failRechargeOrder() {
List<HighOrder> highOrders = orderService.phoneErrorOrder();
for (HighOrder order: highOrders) {
try {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo());
OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) {
childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0);
}
outRechargeOrderService.rechargeOrderHandle(outRechargeOrder , childOrder);
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
}
}
} }

@ -468,7 +468,7 @@ public class WxUtils {
} }
/** /**
* 生成嗨购签名. 注意若含有sign_type字段必须和signType参数保持一致 * 生成畅停签名. 注意若含有sign_type字段必须和signType参数保持一致
* *
* @param data 待签名数据 * @param data 待签名数据
* @param key API密钥 * @param key API密钥

@ -214,7 +214,7 @@ public class RechargeConfig {
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Name checkOrderByHg * @Name checkOrderByHg
* @Description // 查询嗨购订单下单 * @Description // 查询畅停订单下单
* @Date 14:50 2023/2/8 * @Date 14:50 2023/2/8
* @Param [object] * @Param [object]
* @Return com.alibaba.fastjson.JSONObject * @Return com.alibaba.fastjson.JSONObject
@ -231,12 +231,12 @@ public class RechargeConfig {
paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("============请求任务Start=============");
log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
System.out.println("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); System.out.println("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
JSONObject repsObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/telPay", paramSort(paramMap), new HashMap<>()); JSONObject repsObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/telPay", paramSort(paramMap), new HashMap<>());
log.info("嗨购话费查询订单-响应参数: " + repsObject.toJSONString()); log.info("畅停话费查询订单-响应参数: " + repsObject.toJSONString());
log.info("============请求任务End=============="); log.info("============请求任务End==============");
return repsObject; return repsObject;
} }
@ -244,7 +244,7 @@ public class RechargeConfig {
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Name searchOrder * @Name searchOrder
* @Description // 嗨购话费查询订单详情 * @Description // 畅停话费查询订单详情
* @Date 11:39 2023/2/7 * @Date 11:39 2023/2/7
* @Param [object] * @Param [object]
* @Return com.alibaba.fastjson.JSONObject * @Return com.alibaba.fastjson.JSONObject
@ -257,11 +257,11 @@ public class RechargeConfig {
paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("============请求任务Start=============");
log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/searchOrder", paramSort(paramMap) , new HashMap<>()); JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/searchOrder", paramSort(paramMap) , new HashMap<>());
log.info("嗨购话费查询订单-响应参数: " + jsonObject.toJSONString()); log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End=============="); log.info("============请求任务End==============");
return jsonObject; return jsonObject;
} }
@ -273,11 +273,11 @@ public class RechargeConfig {
paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("============请求任务Start=============");
log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "/external/api/searchProduct", paramSort(paramMap) , new HashMap<>()); JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "/external/api/searchProduct", paramSort(paramMap) , new HashMap<>());
log.info("嗨购话费查询订单-响应参数: " + jsonObject.toJSONString()); log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End=============="); log.info("============请求任务End==============");
return jsonObject; return jsonObject;
} }

@ -1,7 +1,31 @@
package com.hai.dao; package com.hai.dao;
import com.hai.entity.OutRechargeChildOrder;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
/** /**
* mapper扩展类 * mapper扩展类
*/ */
public interface OutRechargeChildOrderMapperExt { public interface OutRechargeChildOrderMapperExt {
}
@Select({
"select * from out_recharge_child_order order by id desc limit 1;"
})
@Results({
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
@Result(column="parent_order_id", property="parentOrderId", jdbcType=JdbcType.BIGINT),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="recharge_platform", property="rechargePlatform", jdbcType=JdbcType.INTEGER),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
OutRechargeChildOrder findOutRechargeChildOrderByDesc();
}

@ -29,7 +29,7 @@ public class BsRechargeCode implements Serializable {
private String sourceId; private String sourceId;
/** /**
* 充值平台充值平台 1尖椒 2龙阅 3:城宇 4.嗨购 * 充值平台充值平台 1尖椒 2龙阅 3:城宇 4.畅停
*/ */
private Integer rechargePlatform; private Integer rechargePlatform;

@ -126,7 +126,7 @@ public class OutRechargeOrder implements Serializable {
private Integer payStatus; private Integer payStatus;
/** /**
* 充值状态201:充值中 202充值成功 203充值失败 204未充值 * 充值状态201:充值中 202充值成功 203充值失败 204未充值 205: 待充值
*/ */
private Integer rechargeStatus; private Integer rechargeStatus;

@ -24,6 +24,10 @@ public class OrderThirdPartyModel {
@ExcelProperty(value = "充值订单号") @ExcelProperty(value = "充值订单号")
private String regOrderNo; private String regOrderNo;
@ColumnWidth(25)
@ExcelProperty(value = "充值平台")
private String rechargePlatform;
@ColumnWidth(15) @ColumnWidth(15)
@ExcelProperty(value = "客户电话") @ExcelProperty(value = "客户电话")
private String memPhone; private String memPhone;

@ -0,0 +1,54 @@
package com.hai.order.type;
import java.util.Objects;
/**
* 子订单状态
* @className: OrderChildGoodsType
* @author: HuRui
* @date: 2022/8/24
**/
public enum RechargePlatformType {
STATUS1(1, "尖椒"),
STATUS2(2, "龙阅"),
STATUS3(3, "城宇"),
STATUS4(4, "畅停"),
;
private Integer number;
private String name;
RechargePlatformType(int number, String name) {
this.number = number;
this.name = name;
}
/**
* 根据类型查询数据
* @param type
* @return
*/
public static RechargePlatformType getDataByType(Integer type) {
for (RechargePlatformType ele : values()) {
if(Objects.equals(type,ele.getNumber())) return ele;
}
return null;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -77,4 +77,14 @@ public interface OutRechargeChildOrderService {
**/ **/
void updateOrder(OutRechargeChildOrder rechargeChildOrder); void updateOrder(OutRechargeChildOrder rechargeChildOrder);
/**
* @Author Sum1Dream
* @Name findOutRechargeChildOrderByDesc
* @Description //根据id 查询最后一条充值记录
* @Date 15:29 2023/2/27
* @Param []
* @Return com.hai.entity.OutRechargeChildOrder
*/
OutRechargeChildOrder findOutRechargeChildOrderByDesc();
} }

@ -42,7 +42,7 @@ public interface OutRechargeOrderService {
**/ **/
OutRechargeOrder findByOrderNo(String orderNo); OutRechargeOrder findByOrderNo(String orderNo);
/*** /*** todo 当前接口已经废弃
* @Author Sum1Dream * @Author Sum1Dream
* @Description // 新增订单 * @Description // 新增订单
* @Date 15:25 2021/6/11 * @Date 15:25 2021/6/11
@ -152,7 +152,7 @@ public interface OutRechargeOrderService {
* @Param [order, childOrder] * @Param [order, childOrder]
* @Return void * @Return void
*/ */
void completeOrder(OutRechargeOrder order , OutRechargeChildOrder childOrder); void completeOrder(String orderNo);
/** /**
@ -184,7 +184,7 @@ public interface OutRechargeOrderService {
* @Param [outRechargeOrder, childOrder] * @Param [outRechargeOrder, childOrder]
* @Return void * @Return void
*/ */
void rechargeOrderHandle(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception; void rechargeOrderHandle(String orderNo) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream

@ -96,4 +96,9 @@ public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderSe
public void updateOrder(OutRechargeChildOrder rechargeChildOrder) { public void updateOrder(OutRechargeChildOrder rechargeChildOrder) {
rechargeChildOrderMapper.updateByPrimaryKey(rechargeChildOrder); rechargeChildOrderMapper.updateByPrimaryKey(rechargeChildOrder);
} }
@Override
public OutRechargeChildOrder findOutRechargeChildOrderByDesc() {
return rechargeChildOrderMapper.findOutRechargeChildOrderByDesc();
}
} }

@ -1,20 +1,16 @@
package com.hai.service.impl; package com.hai.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.security.AESEncodeUtil; import com.hai.common.security.AESEncodeUtil;
import com.hai.common.utils.*; import com.hai.common.utils.*;
import com.hai.config.*; import com.hai.config.*;
import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighGasOrderPushMapper;
import com.hai.dao.HighOrderMapper;
import com.hai.dao.OutRechargeOrderMapper; import com.hai.dao.OutRechargeOrderMapper;
import com.hai.dao.OutRechargeOrderMapperExt; import com.hai.dao.OutRechargeOrderMapperExt;
import com.hai.entity.*; import com.hai.entity.*;
@ -22,33 +18,26 @@ import com.hai.enum_type.*;
import com.hai.model.*; import com.hai.model.*;
import com.hai.order.service.OrderService; import com.hai.order.service.OrderService;
import com.hai.order.type.OrderChildStatus; import com.hai.order.type.OrderChildStatus;
import com.hai.order.type.OrderPayType;
import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.type.OrderRefundOpUserType;
import com.hai.service.*; import com.hai.service.*;
import com.hai.service.pay.impl.GoodsOrderServiceImpl; import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import io.swagger.models.auth.In;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@Service("outRechargeOrderService") @Service("outRechargeOrderService")
public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@ -213,6 +202,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrder; return outRechargeOrder;
} }
// todo 接口已经废弃
@Override @Override
@Transactional( @Transactional(
isolation = Isolation.SERIALIZABLE, isolation = Isolation.SERIALIZABLE,
@ -592,16 +582,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款z"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款z");
} }
// 订单处理
HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo());
orderService.refundOrder(highOrder, "话费自动退款",OrderRefundOpUserType.TYPE1, orderService.refundOrder(highOrder, "话费自动退款",OrderRefundOpUserType.TYPE1,
null, null,
"系统自动退款"); "系统自动退款");
// 话费充值业务订单处理
outRechargeOrder.setPayStatus(105); outRechargeOrder.setPayStatus(105);
outRechargeOrder.setRechargeStatus(203); outRechargeOrder.setRechargeStatus(203);
outRechargeOrder.setRefundTime(new Date()); outRechargeOrder.setRefundTime(new Date());
outRechargeOrderService.updateOrder(outRechargeOrder); outRechargeOrderService.updateOrder(outRechargeOrder);
// 子订单修改状态 // 充值订单记录修改状态
childOrder.setStatus(103); childOrder.setStatus(103);
outRechargeChildOrderService.updateOrder(childOrder); outRechargeChildOrderService.updateOrder(childOrder);
} }
@ -625,7 +618,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
// 定义新的子订单对象 // 定义新的子订单对象
OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 初始化充值平台 1:尖椒 2:龙阅 3:畅停 4.嗨购 // 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停
int platformType = 0; int platformType = 0;
// 判断子订单是否存在充值中订单 // 判断子订单是否存在充值中订单
@ -638,19 +631,22 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (status == 0 || status == 3 || status == 99) { if (status == 0 || status == 3 || status == 99) {
return; return;
} else if (status == 1) { } else if (status == 1) {
completeOrder(outRechargeOrder , childOrder); completeOrder(outRechargeOrder.getOrderNo());
} }
// 修改充值记录状态
childOrder.setStatus(103); childOrder.setStatus(103);
childOrder.setUpdateTime(new Date()); childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder); outRechargeChildOrderService.updateOrder(childOrder);
platformType = childOrder.getRechargePlatform();
} }
// 获取充值平台
platformType = getRechargePlatformType();
// 定义下单请求数据对象
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
// 定义充值订单号 // 定义充值订单号
String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5);
// 查询平台 // 查询平台
@ -661,9 +657,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (string.length() == 1) { if (string.length() == 1) {
platformType = Integer.parseInt(string); platformType = Integer.parseInt(string);
} else { } else {
// 如果平台充值记录暂无 则充值第一个
if (platformType == 0) { if (platformType == 0) {
platformType = Integer.parseInt(rechargePlatform[0]); platformType = Integer.parseInt(rechargePlatform[0]);
} else { } else {
// 获取上一条充值平台的下一个平台内容
platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]); platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]);
} }
@ -729,7 +727,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
childOrder.setRechargePlatform(3); childOrder.setRechargePlatform(3);
break; break;
} }
// 嗨购充值 // 畅停充值
if (s.equals("4") && platformType == 4) { if (s.equals("4") && platformType == 4) {
map.put("sourceId" , outRechargePrice.getId()); map.put("sourceId" , outRechargePrice.getId());
@ -771,12 +769,20 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
@Override @Override
public void completeOrder(OutRechargeOrder order, OutRechargeChildOrder childOrder) { public void completeOrder(String orderNo) {
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo);
OutRechargeChildOrder childOrder = order.getOutRechargeChildOrders().get(0);
// 修改话费充值业务订单状态
childOrder.setStatus(101); childOrder.setStatus(101);
order.setRechargeStatus(202); order.setRechargeStatus(202);
order.setPayStatus(100); order.setPayStatus(100);
order.setFinishTime(new Date()); order.setFinishTime(new Date());
outRechargeOrderService.updateOrder(order);
outRechargeChildOrderService.updateOrder(childOrder);
// 修改订单状态
HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo());
if (highOrder != null) { if (highOrder != null) {
highOrder.setOrderStatus(OrderStatusEnum.type3.getType()); highOrder.setOrderStatus(OrderStatusEnum.type3.getType());
@ -788,8 +794,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
orderService.updateOrderData(highOrder); orderService.updateOrderData(highOrder);
} }
outRechargeOrderService.updateOrder(order);
outRechargeChildOrderService.updateOrder(childOrder); // 推送小程序消息
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(highOrder.getMemId());
WxMsgConfig.rechargedSuccess(
order.getRechargeContent() + "充值成功",
String.valueOf(order.getPayRealPrice()),
order.getOrderNo(),
order.getFinishTime(),
OrderPayType.getDataByType(order.getPayType()).getName(),
highUser.getOpenId());
}).start();
} }
@ -818,18 +835,26 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
@Override @Override
public void rechargeOrderHandle(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception { public void rechargeOrderHandle(String orderNo) throws Exception {
// 定义话费充值业务订单模型 or 充值记录订单模型
OutRechargeOrder outRechargeOrder = findByOrderNo(orderNo);
OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0);
// 状态需要支付状态为已充值 并且 充值状态不为 充值成功
if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) {
// 判断充值记录是否存在
if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) { if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) {
//
OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder(); OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder();
outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId()); outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId());
outRechargeChildOrder.setUpdateTime(new Date()); outRechargeChildOrder.setUpdateTime(new Date());
outRechargeChildOrder.setCreateTime(new Date()); outRechargeChildOrder.setCreateTime(new Date());
outRechargeChildOrderService.insertOrder(outRechargeChildOrder);
// 话费退款
refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); refundOrder(outRechargeOrder.getId() , outRechargeChildOrder);
} else { } else {
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
@ -837,7 +862,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (status == 2 || status == -1) { if (status == 2 || status == -1) {
refundOrder(outRechargeOrder.getId() , childOrder); refundOrder(outRechargeOrder.getId() , childOrder);
} else if (status == 1) { } else if (status == 1) {
completeOrder(outRechargeOrder , childOrder); completeOrder(outRechargeOrder.getOrderNo());
} }
} }
@ -868,7 +893,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
} }
// 嗨购 // 畅停
if (childOrder.getRechargePlatform() == 4) { if (childOrder.getRechargePlatform() == 4) {
object.put("orderid" , childOrder.getOrderNo()); object.put("orderid" , childOrder.getOrderNo());
@ -898,4 +923,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
return 99; return 99;
} }
private Integer getRechargePlatformType() {
OutRechargeChildOrder outRechargeChildOrder = outRechargeChildOrderService.findOutRechargeChildOrderByDesc();
if (outRechargeChildOrder != null) {
return outRechargeChildOrder.getRechargePlatform();
}
return 0;
}
} }

@ -54,6 +54,7 @@ public class RechargeOrderServiceImpl implements PayService {
// todo 当前接口已经废弃
@Override @Override
public void paySuccess(Map<String, String> map, String payType) throws Exception { public void paySuccess(Map<String, String> map, String payType) throws Exception {

Loading…
Cancel
Save