| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.payment.api.vo.PaymentOrder; |
| | | import com.ruoyi.payment.api.vo.WxRefundNotifyResp; |
| | | import com.ruoyi.payment.wx.enums.RefundEnum; |
| | | import com.ruoyi.payment.api.model.WxPaymentRefundModel; |
| | | import com.ruoyi.payment.wx.resp.NotifyV3PayDecodeRespBody; |
| | |
| | | * 退款回调 |
| | | */ |
| | | @PostMapping("refund/notify") |
| | | public void refundNotify(HttpServletRequest request) throws IOException { |
| | | public R<WxRefundNotifyResp> refundNotify(HttpServletRequest request) throws IOException { |
| | | try { |
| | | Map<String, Object> params = wxV3Pay.verifyNotify(request, new TypeReference<Map<String, Object>>() { |
| | | }); |
| | | // 商户订单号 |
| | | String tradeNo = params.get("out_trade_no").toString(); |
| | | String out_trade_no = params.get("out_trade_no").toString(); |
| | | // 商户退款单号 |
| | | String out_refund_no = params.get("out_refund_no").toString(); |
| | | // 微信支付订单号 |
| | |
| | | // 时间不对的话,可以调用 WxTimeUtils.toRfc3339Date(success_time)转换一下 |
| | | String success_time = params.get("success_time").toString(); |
| | | if (tradeState.equals(RefundEnum.SUCCESS.name())) { |
| | | String substring = out_refund_no.substring(0, 2); |
| | | switch (substring){ |
| | | case "GW": |
| | | break; |
| | | |
| | | } |
| | | // TODO 退款成功处理 |
| | | WxRefundNotifyResp resp = new WxRefundNotifyResp(); |
| | | resp.setOut_trade_no(out_trade_no); |
| | | resp.setOut_refund_no(out_refund_no); |
| | | resp.setTradeState(tradeState); |
| | | resp.setTransaction_id(transaction_id); |
| | | resp.setRefund_id(refund_id); |
| | | resp.setSuccess_time(success_time); |
| | | wxV3Pay.ack(); |
| | | return R.ok(resp); |
| | | } else { |
| | | wxV3Pay.ack(false, "不是成功的退款状态"); |
| | | } |
| | | } catch (Exception e) { |
| | | wxV3Pay.ack(false, e.getMessage()); |
| | | } |
| | | |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |