修改微信退款为第三方支付

main
孟权伟 1 month ago
parent e821293fcb
commit bbd9df5622

@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.date.TemporalAccessorUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
@ -17,6 +18,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifie
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;
import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyV3Result;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
@ -284,7 +286,28 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
.setTotalFee(reqDTO.getPayPrice())
.setNotifyUrl(reqDTO.getNotifyUrl());
// 2.1 执行请求
WxPayRefundResult response = client.refundV2(request);
// WxPayRefundResult response = client.refundV2(request);
JSONObject paramMap = new JSONObject();
paramMap.put("appid", config.getAppId());
paramMap.put("mchid", config.getMchId());
paramMap.put("keyString", config.getKeyContent());
paramMap.put("apiv2", config.getMchKey());
paramMap.put("domainUrl", request.getNotifyUrl());
paramMap.put("outTradeNo",request.getOutTradeNo());
paramMap.put("outRefundNo",request.getOutRefundNo());
paramMap.put("totalAmount", request.getTotalFee().toString());
paramMap.put("refundAmount", request.getRefundFee().toString());
paramMap.put("refundReason", request.getRefundDesc());
String json = HttpRequest.post("http://alipay.huamar.com/pay/order/doRefund")
.body(paramMap.toJSONString())
.execute().body();
WxPayRefundResult response = JSONObject.parseObject(JSONObject.parseObject(json).getString("data"), WxPayRefundResult.class);
if (response == null){
return PayRefundRespDTO.failureOf(reqDTO.getOutRefundNo(), "退款失败,请联系技术人员排查!");
}
// 2.2 创建返回结果
if (Objects.equals("SUCCESS", response.getResultCode())) { // V2 情况下,不直接返回退款成功,而是等待异步通知
return PayRefundRespDTO.waitingOf(response.getRefundId(),

@ -62,6 +62,7 @@ public class WxPubPayClient extends AbstractWxPayClient {
paramMap.put("domainUrl", request.getNotifyUrl());
paramMap.put("orderSn",request.getOutTradeNo());
paramMap.put("openId",request.getOpenid());
paramMap.put("body",request.getBody());
String json = HttpRequest.post("http://alipay.huamar.com/pay/order/createOrder")
.body(paramMap.toJSONString())
.execute().body();

Loading…
Cancel
Save