pay: 增加支付宝的条形码支付的配置
This commit is contained in:
parent
379aeeae16
commit
8e1be01451
@ -4,10 +4,7 @@ import cn.hutool.core.lang.Assert;
|
|||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory;
|
import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPcPayClient;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXLitePayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXLitePayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXNativePayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXNativePayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
|
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
|
||||||
@ -71,6 +68,7 @@ public class PayClientFactoryImpl implements PayClientFactory {
|
|||||||
case ALIPAY_QR: return (AbstractPayClient<Config>) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config);
|
case ALIPAY_QR: return (AbstractPayClient<Config>) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config);
|
||||||
case ALIPAY_APP: return (AbstractPayClient<Config>) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config);
|
case ALIPAY_APP: return (AbstractPayClient<Config>) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config);
|
||||||
case ALIPAY_PC: return (AbstractPayClient<Config>) new AlipayPcPayClient(channelId, (AlipayPayClientConfig) config);
|
case ALIPAY_PC: return (AbstractPayClient<Config>) new AlipayPcPayClient(channelId, (AlipayPayClientConfig) config);
|
||||||
|
case ALIPAY_BAR: return (AbstractPayClient<Config>) new AlipayBarPayClient(channelId, (AlipayPayClientConfig) config);
|
||||||
}
|
}
|
||||||
// 创建失败,错误日志 + 抛出异常
|
// 创建失败,错误日志 + 抛出异常
|
||||||
log.error("[createPayClient][配置({}) 找不到合适的客户端实现]", config);
|
log.error("[createPayClient][配置({}) 找不到合适的客户端实现]", config);
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.PayCommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||||
|
import cn.iocoder.yudao.framework.pay.core.enums.PayDisplayModeEnum;
|
||||||
|
import com.alipay.api.AlipayApiException;
|
||||||
|
import com.alipay.api.domain.AlipayTradePayModel;
|
||||||
|
import com.alipay.api.request.AlipayTradePayRequest;
|
||||||
|
import com.alipay.api.response.AlipayTradePayResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝【条码支付】的 PayClient 实现类
|
||||||
|
*
|
||||||
|
* 文档:https://opendocs.alipay.com/open/194/105072
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class AlipayBarPayClient extends AbstractAlipayClient {
|
||||||
|
|
||||||
|
public AlipayBarPayClient(Long channelId, AlipayPayClientConfig config) {
|
||||||
|
super(channelId, PayChannelEnum.ALIPAY_BAR.getCode(), config,
|
||||||
|
new AlipayPayCodeMapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PayCommonResult<PayOrderUnifiedRespDTO> doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) {
|
||||||
|
// 1.1 构建 AlipayTradePayModel 请求
|
||||||
|
AlipayTradePayModel model = new AlipayTradePayModel();
|
||||||
|
// ① 通用的参数
|
||||||
|
model.setOutTradeNo(reqDTO.getMerchantOrderId());
|
||||||
|
model.setSubject(reqDTO.getSubject());
|
||||||
|
model.setBody(reqDTO.getBody());
|
||||||
|
model.setTotalAmount(formatAmount(reqDTO.getAmount()));
|
||||||
|
model.setScene("bar_code"); // 当面付条码支付场景
|
||||||
|
// ② 个性化的参数【无】
|
||||||
|
// ③ 支付宝条码支付只有一种展示
|
||||||
|
String displayMode = PayDisplayModeEnum.BAR_CODE.getMode();
|
||||||
|
|
||||||
|
// 1.2 构建 AlipayTradePayRequest 请求
|
||||||
|
AlipayTradePayRequest request = new AlipayTradePayRequest();
|
||||||
|
request.setBizModel(model);
|
||||||
|
request.setNotifyUrl(reqDTO.getNotifyUrl());
|
||||||
|
request.setReturnUrl(reqDTO.getReturnUrl()); // TODO 芋艿,待搞
|
||||||
|
|
||||||
|
// 2.1 执行请求
|
||||||
|
AlipayTradePayResponse response;
|
||||||
|
try {
|
||||||
|
response = client.execute(request);
|
||||||
|
} catch (AlipayApiException e) {
|
||||||
|
log.error("[unifiedOrder][request({}) 发起支付失败]", toJsonString(reqDTO), e);
|
||||||
|
return PayCommonResult.build(e.getErrCode(), e.getErrMsg(), null, codeMapping);
|
||||||
|
}
|
||||||
|
// 2.2 处理结果
|
||||||
|
PayOrderUnifiedRespDTO respDTO = new PayOrderUnifiedRespDTO()
|
||||||
|
.setDisplayMode(displayMode).setDisplayContent(response.getCode());
|
||||||
|
return PayCommonResult.build(StrUtil.blankToDefault(response.getCode(),"10000"),
|
||||||
|
response.getMsg(), respDTO, codeMapping);
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,8 @@ public enum PayChannelEnum {
|
|||||||
ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class),
|
ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class),
|
||||||
ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class),
|
ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class),
|
||||||
ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class),
|
ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class),
|
||||||
ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class);
|
ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class),
|
||||||
|
ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码
|
* 编码
|
||||||
|
@ -17,6 +17,7 @@ public enum PayDisplayModeEnum {
|
|||||||
FORM("form"), // HTML 表单提交
|
FORM("form"), // HTML 表单提交
|
||||||
QR_CODE("qr_code"), // 二维码的文字内容
|
QR_CODE("qr_code"), // 二维码的文字内容
|
||||||
QR_CODE_URL("qr_code_url"), // 二维码的图片链接
|
QR_CODE_URL("qr_code_url"), // 二维码的图片链接
|
||||||
|
BAR_CODE("bar_code"), // 条形码
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
2
yudao-ui-admin/src/assets/images/pay/icon/alipay_bar.svg
Normal file
2
yudao-ui-admin/src/assets/images/pay/icon/alipay_bar.svg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1627279586085" class="icon" viewBox="0 0 1036 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6737" xmlns:xlink="http://www.w3.org/1999/xlink" width="40.46875" height="40"><defs><style type="text/css">@font-face { font-family: feedback-iconfont; src: url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.eot?#iefix") format("embedded-opentype"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.woff2") format("woff2"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.woff") format("woff"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.ttf") format("truetype"), url("//at.alicdn.com/t/font_1031158_1uhr8ri0pk5.svg#iconfont") format("svg"); }
|
||||||
|
</style></defs><path d="M27.587124 336.619083h69.148134a13.978733 13.978733 0 0 0 13.79235-13.978733V13.989916A13.978733 13.978733 0 0 0 96.735258 0.011183H27.587124a13.978733 13.978733 0 0 0-13.792351 13.978733v308.650434a13.978733 13.978733 0 0 0 13.792351 13.978733z m165.880969 0h27.584701a13.978733 13.978733 0 0 0 13.79235-13.978733V13.989916a13.978733 13.978733 0 0 0-13.79235-13.978733h-27.584701a13.978733 13.978733 0 0 0-13.79235 13.978733v308.650434a13.978733 13.978733 0 0 0 13.79235 13.978733z m138.109886 322.629167h-110.525185a27.771084 27.771084 0 0 0-27.584701 28.14385v111.829867a27.771084 27.771084 0 0 0 27.584701 28.14385h110.525185a27.957467 27.957467 0 0 0 27.584701-28.14385v-111.829867a27.957467 27.957467 0 0 0-27.584701-28.14385z m484.596091-322.629167h27.584701a13.978733 13.978733 0 0 0 13.79235-13.978733V13.989916a13.978733 13.978733 0 0 0-14.537883-13.978733h-27.5847a13.978733 13.978733 0 0 0-13.978734 13.978733v308.650434a13.978733 13.978733 0 0 0 13.978734 13.978733z m-469.871825 0H428.68358a13.978733 13.978733 0 0 0 13.792351-13.978733V13.989916A13.978733 13.978733 0 0 0 428.68358 0.011183h-83.126867a13.978733 13.978733 0 0 0-13.792351 13.978733v308.650434a13.978733 13.978733 0 0 0 13.792351 13.978733z m594.189361 0h69.148134a13.978733 13.978733 0 0 0 13.792351-13.978733V13.989916a13.978733 13.978733 0 0 0-14.537883-13.978733h-69.148135a13.978733 13.978733 0 0 0-13.79235 13.978733v308.650434a13.978733 13.978733 0 0 0 13.79235 13.978733z m-412.279444 126.181367H66.91396A67.470687 67.470687 0 0 0 0.002423 530.830286v425.139878a67.470687 67.470687 0 0 0 66.911537 68.029836h418.802853a67.470687 67.470687 0 0 0 66.911537-68.029836V487.775787a24.788954 24.788954 0 0 0-24.416188-24.975337z m-58.337914 433.899885a42.681733 42.681733 0 0 1-42.495349 43.054498H125.438257a42.681733 42.681733 0 0 1-42.495349-43.054498V590.100115a42.681733 42.681733 0 0 1 42.495349-43.054498h301.940642a42.681733 42.681733 0 0 1 42.495349 43.054498z m525.22761-433.899885a41.749817 41.749817 0 0 0-41.377051 42.122583v55.914934a41.377051 41.377051 0 1 0 82.940485 0v-55.914934a41.749817 41.749817 0 0 0-41.563434-42.122583z m0 223.659734a41.749817 41.749817 0 0 0-41.377051 42.122584V894.65012a45.477479 45.477479 0 0 1-45.291096 45.850246h-159.730327a43.240882 43.240882 0 0 0-43.613649 37.276622A41.9362 41.9362 0 0 0 745.534871 1024h233.538039a57.778765 57.778765 0 0 0 57.405999-58.337914V729.3283a41.749817 41.749817 0 0 0-41.377051-41.9362zM732.488053 322.64035V13.989916a13.978733 13.978733 0 0 0-13.79235-13.978733h-82.940485a13.978733 13.978733 0 0 0-13.79235 13.978733v308.650434a13.978733 13.978733 0 0 0 13.79235 13.978733h82.940485a13.978733 13.978733 0 0 0 13.79235-13.978733zM532.126208 0.011183c-11.36937 0-20.688525 6.337026-20.688526 13.978733v308.650434c0 7.828091 9.319156 13.978733 20.688526 13.978733s20.688525-6.337026 20.688525-13.978733V13.989916c0-7.641708-9.319156-13.978733-20.688525-13.978733z" p-id="6738" fill="#1977FD"></path><path d="M745.534871 462.80045a41.749817 41.749817 0 0 0-41.377051 42.122583v252.549117a41.377051 41.377051 0 1 0 82.940485 0V504.923033A41.749817 41.749817 0 0 0 745.534871 462.80045" p-id="6739" fill="#1977FD"></path></svg>
|
After Width: | Height: | Size: 3.9 KiB |
@ -148,6 +148,10 @@ export const PayChannelEnum = {
|
|||||||
"code": "alipay_qr",
|
"code": "alipay_qr",
|
||||||
"name": "支付宝扫码支付"
|
"name": "支付宝扫码支付"
|
||||||
},
|
},
|
||||||
|
ALIPAY_BAR: {
|
||||||
|
"code": "alipay_bar",
|
||||||
|
"name": "支付宝条码支付"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,11 +53,6 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="商户名称" align="center" prop="payMerchant.name"/>
|
<el-table-column label="商户名称" align="center" prop="payMerchant.name"/>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
|
||||||
<template v-slot="scope">
|
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="支付宝配置" align="center">
|
<el-table-column label="支付宝配置" align="center">
|
||||||
<el-table-column :label="payChannelEnum.ALIPAY_APP.name" align="center">
|
<el-table-column :label="payChannelEnum.ALIPAY_APP.name" align="center">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
@ -107,6 +102,18 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column :label="payChannelEnum.ALIPAY_BAR.name" align="center">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<el-button type="success" icon="el-icon-check" circle
|
||||||
|
v-if="judgeChannelExist(scope.row.channelCodes,payChannelEnum.ALIPAY_BAR.code)"
|
||||||
|
@click="handleUpdateChannel(scope.row,payChannelEnum.ALIPAY_BAR.code,payType.ALIPAY)">
|
||||||
|
</el-button>
|
||||||
|
<el-button v-else
|
||||||
|
type="danger" icon="el-icon-close" circle
|
||||||
|
@click="handleCreateChannel(scope.row,payChannelEnum.ALIPAY_BAR.code,payType.ALIPAY)">
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="微信配置" align="center">
|
<el-table-column label="微信配置" align="center">
|
||||||
<el-table-column :label="payChannelEnum.WX_LITE.name" align="center">
|
<el-table-column :label="payChannelEnum.WX_LITE.name" align="center">
|
||||||
|
@ -82,6 +82,7 @@ export default {
|
|||||||
alipay_app: require("@/assets/images/pay/icon/alipay_app.svg"),
|
alipay_app: require("@/assets/images/pay/icon/alipay_app.svg"),
|
||||||
alipay_wap: require("@/assets/images/pay/icon/alipay_wap.svg"),
|
alipay_wap: require("@/assets/images/pay/icon/alipay_wap.svg"),
|
||||||
alipay_pc: require("@/assets/images/pay/icon/alipay_pc.svg"),
|
alipay_pc: require("@/assets/images/pay/icon/alipay_pc.svg"),
|
||||||
|
alipay_bar: require("@/assets/images/pay/icon/alipay_bar.svg"),
|
||||||
wx_app: require("@/assets/images/pay/icon/wx_app.svg"),
|
wx_app: require("@/assets/images/pay/icon/wx_app.svg"),
|
||||||
wx_lite: require("@/assets/images/pay/icon/wx_lite.svg"),
|
wx_lite: require("@/assets/images/pay/icon/wx_lite.svg"),
|
||||||
wx_pub: require("@/assets/images/pay/icon/wx_pub.svg"),
|
wx_pub: require("@/assets/images/pay/icon/wx_pub.svg"),
|
||||||
@ -102,6 +103,11 @@ export default {
|
|||||||
form: { // 展示形式:form
|
form: { // 展示形式:form
|
||||||
html: '',
|
html: '',
|
||||||
},
|
},
|
||||||
|
barCode: { // 展示形式:条形码
|
||||||
|
value: '',
|
||||||
|
title: '',
|
||||||
|
visible: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -155,6 +161,16 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 提交支付 */
|
/** 提交支付 */
|
||||||
submit(channelCode) {
|
submit(channelCode) {
|
||||||
|
// 条形码支付,需要特殊处理
|
||||||
|
if (channelCode === PayChannelEnum.ALIPAY_BAR.code) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认的提交处理
|
||||||
|
this.submit0(channelCode)
|
||||||
|
},
|
||||||
|
submit0(channelCode) {
|
||||||
this.submitLoading = true
|
this.submitLoading = true
|
||||||
submitOrder({
|
submitOrder({
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user