|
@@ -1,4 +1,4 @@
|
|
|
-package cn.iocoder.yudao.framework.pay.core.client.impl.wx;
|
|
|
+package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
@@ -7,6 +7,7 @@ import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
|
|
|
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
|
|
import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayNotifyReqDTO;
|
|
|
import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayOrderNotifyRespDTO;
|
|
|
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
|
@@ -15,6 +16,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReq
|
|
|
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO;
|
|
|
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
|
|
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
|
|
+import cn.iocoder.yudao.framework.pay.core.enums.PayDisplayModeEnum;
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
|
|
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
@@ -33,6 +35,8 @@ import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
|
|
+
|
|
|
/**
|
|
|
* 微信支付(公众号)的 PayClient 实现类
|
|
|
*
|
|
@@ -70,29 +74,29 @@ public class WXPubPayClient extends AbstractPayClient<WXPayClientConfig> {
|
|
|
|
|
|
@Override
|
|
|
public PayOrderUnifiedRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) {
|
|
|
- throw new UnsupportedOperationException();
|
|
|
-//
|
|
|
-// WxPayMpOrderResult response;
|
|
|
-// try {
|
|
|
-// switch (config.getApiVersion()) {
|
|
|
-// case WXPayClientConfig.API_VERSION_V2:
|
|
|
-// response = this.unifiedOrderV2(reqDTO);
|
|
|
-// break;
|
|
|
-// case WXPayClientConfig.API_VERSION_V3:
|
|
|
-// WxPayUnifiedOrderV3Result.JsapiResult responseV3 = this.unifiedOrderV3(reqDTO);
|
|
|
-// // 将 V3 的结果,统一转换成 V2。返回的字段是一致的
|
|
|
-// response = new WxPayMpOrderResult();
|
|
|
-// BeanUtil.copyProperties(responseV3, response, true);
|
|
|
-// break;
|
|
|
-// default:
|
|
|
-// throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
|
|
-// }
|
|
|
-// } catch (WxPayException e) {
|
|
|
-// log.error("[unifiedOrder][request({}) 发起支付失败,原因({})]", toJsonString(reqDTO), e);
|
|
|
+ WxPayMpOrderResult response = null;
|
|
|
+ try {
|
|
|
+ switch (config.getApiVersion()) {
|
|
|
+ case WXPayClientConfig.API_VERSION_V2:
|
|
|
+ response = this.unifiedOrderV2(reqDTO);
|
|
|
+ break;
|
|
|
+ case WXPayClientConfig.API_VERSION_V3:
|
|
|
+ WxPayUnifiedOrderV3Result.JsapiResult responseV3 = this.unifiedOrderV3(reqDTO);
|
|
|
+ // 将 V3 的结果,统一转换成 V2。返回的字段是一致的
|
|
|
+ response = new WxPayMpOrderResult();
|
|
|
+ BeanUtil.copyProperties(responseV3, response, true);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
|
|
+ }
|
|
|
+ } catch (WxPayException e) {
|
|
|
+ log.error("[unifiedOrder][request({}) 发起支付失败,原因({})]", toJsonString(reqDTO), e);
|
|
|
// return PayCommonResult.build(ObjectUtils.defaultIfNull(e.getErrCode(), e.getReturnCode(), "CustomErrorCode"),
|
|
|
// ObjectUtils.defaultIfNull(e.getErrCodeDes(), e.getCustomErrorMsg()),null, codeMapping);
|
|
|
-// }
|
|
|
-// return PayCommonResult.build(CODE_SUCCESS, MESSAGE_SUCCESS, response, codeMapping);
|
|
|
+ System.out.println();
|
|
|
+ }
|
|
|
+ return new PayOrderUnifiedRespDTO().setDisplayMode(PayDisplayModeEnum.CUSTOM.getMode())
|
|
|
+ .setDisplayContent(JsonUtils.toJsonString(response));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -190,7 +194,8 @@ public class WXPubPayClient extends AbstractPayClient<WXPayClientConfig> {
|
|
|
}
|
|
|
|
|
|
private static String formatDate(LocalDateTime time) {
|
|
|
- return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
+// return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
+ return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), "yyyyMMddHHmmss");
|
|
|
}
|
|
|
|
|
|
}
|