|
|
|
@ -2,10 +2,12 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
|
|
|
|
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
|
|
|
|
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
|
|
|
|
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
|
|
|
@ -15,6 +17,8 @@ import com.github.binarywang.wxpay.constant.WxPayConstants;
|
|
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
|
|
|
|
|
|
|
|
@ -47,8 +51,24 @@ public class WxPubPayClient extends AbstractWxPayClient {
|
|
|
|
|
WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO)
|
|
|
|
|
.setOpenid(getOpenid(reqDTO));
|
|
|
|
|
// 执行请求
|
|
|
|
|
WxPayMpOrderResult response = client.createOrder(request);
|
|
|
|
|
// WxPayMpOrderResult response = client.createOrder(request);
|
|
|
|
|
|
|
|
|
|
JSONObject paramMap = new JSONObject();
|
|
|
|
|
paramMap.put("payAmount", request.getTotalFee().toString());
|
|
|
|
|
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("orderSn",request.getOutTradeNo());
|
|
|
|
|
paramMap.put("openId",request.getOpenid());
|
|
|
|
|
String json = HttpRequest.post("http://alipay.huamar.com/pay/order/createOrder")
|
|
|
|
|
.body(paramMap.toJSONString())
|
|
|
|
|
.execute().body();
|
|
|
|
|
WxPayMpOrderResult response = JSONObject.parseObject(JSONObject.parseObject(json).getString("data"), WxPayMpOrderResult.class);
|
|
|
|
|
if (response == null){
|
|
|
|
|
throw invalidParamException("支付请求失败!");
|
|
|
|
|
}
|
|
|
|
|
// 转换结果
|
|
|
|
|
return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response),
|
|
|
|
|
reqDTO.getOutTradeNo(), response);
|
|
|
|
|