diff --git a/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java b/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java index c06f31a2..56fefa4b 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java @@ -9,7 +9,10 @@ import com.hai.config.WxMsgConfig; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.OrderPushType; +import com.hai.enum_type.OrderStatusEnum; import com.hai.enum_type.RechargePayType; +import com.hai.order.service.OrderService; +import com.hai.order.type.OrderChildStatus; import com.hai.service.*; import com.hai.service.impl.OutRechargeOrderServiceImpl; import io.swagger.annotations.Api; @@ -47,6 +50,12 @@ public class OrderTelChargeCallbackController { @Resource private ApiOrderRecordService apiOrderRecordService; + @Resource + private HighOrderService highOrderService; + + @Resource + private OrderService orderService; + @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) @ApiOperation(value = "尖椒充值回调") @@ -90,6 +99,7 @@ public class OrderTelChargeCallbackController { outRechargeOrderService.updateOrder(rechargeOrder); outRechargeChildOrderService.updateOrder(childOrder); + orderFinish(rechargeOrder); // api商户订单 if (rechargeOrder.getPayType() == 6) { @@ -153,6 +163,7 @@ public class OrderTelChargeCallbackController { outRechargeOrderService.updateOrder(rechargeOrder); outRechargeChildOrderService.updateOrder(childOrder); + orderFinish(rechargeOrder); if (rechargeOrder.getPayType() == 6) { apiOrderRecord(rechargeOrder); } @@ -176,7 +187,7 @@ public class OrderTelChargeCallbackController { // 101:充值成功 102: 充值中 103:充值失败 104 未充值 // 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) { + if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) { Date rechargeTime = rechargeOrder.getCreateTimed(); Date currentTime = new Date(); @@ -194,13 +205,7 @@ public class OrderTelChargeCallbackController { return; } - rechargeOrder.setRechargeStatus(203); - childOrder.setStatus(103); - outRechargeOrderService.updateOrder(rechargeOrder); - outRechargeChildOrderService.updateOrder(childOrder); - - outRechargeOrderService.rechargeOrderToRefund(rechargeOrder.getId()); - + outRechargeOrderService.refundOrder(rechargeOrder.getId() , childOrder); // 发送充值失败 微信小程序服务通知 new Thread(() -> { @@ -215,6 +220,21 @@ public class OrderTelChargeCallbackController { } + // 订单完成操作 + private void orderFinish(OutRechargeOrder rechargeOrder) { + HighOrder highOrder = highOrderService.getOrderByOrderNo(rechargeOrder.getOrderNo()); + if (highOrder != null) { + highOrder.setOrderStatus(OrderStatusEnum.type3.getType()); + highOrder.setFinishTime(new Date()); + for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { + highChildOrder.setChildOrderStatus(OrderChildStatus.STATUS3.getNumber()); + highChildOrder.setFinishTime(new Date()); + } + orderService.updateOrderData(highOrder); + } + + } + private void apiOrderRecord(OutRechargeOrder rechargeOrder) { Map orderMap = new HashMap<>(); orderMap.put("orderId" , rechargeOrder.getId()); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 2acc5501..1764be8a 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -540,7 +540,7 @@ public class OrderServiceImpl implements OrderService { , OrderPayType.getDataByType(order.getPayType()) , order.getPayRealPrice() , order.getPayGold()); - if (refundPrice.getRefundSuccess() == false) { + if (!refundPrice.getRefundSuccess()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,请稍后重试"); } diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java index b20bd387..423955e5 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -158,12 +158,12 @@ public interface OutRechargeOrderService { /** * @Author Sum1Dream * @Name refundOrder - * @Description //TODO + * @Description // 话费退款 * @Date 15:18 2022/11/2 * @Param [orderId] * @Return void */ - void refundOrder(Long orderId) throws Exception; + void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception; /** * @Author Sum1Dream 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 fd3292ef..95a187cd 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 @@ -811,7 +811,12 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } @Override - public void refundOrder(Long orderId) throws Exception { + @Transactional( + propagation= Propagation.REQUIRES_NEW, + isolation = Isolation.READ_COMMITTED, + timeout = 10, + rollbackFor = Exception.class) + public void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 @@ -820,8 +825,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } // 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值 - if (outRechargeOrder.getRechargeStatus() == 201) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态"); + if (outRechargeOrder.getRechargeStatus() == 202) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款z"); } HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); @@ -832,6 +837,10 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { outRechargeOrder.setRechargeStatus(203); outRechargeOrder.setRefundTime(new Date()); outRechargeOrderService.updateOrder(outRechargeOrder); + + // 子订单修改状态 + childOrder.setStatus(103); + outRechargeChildOrderService.updateOrder(childOrder); } public String doRefundRequest(String mchId, String data) throws Exception {