mirror of
https://gitee.com/bootx/dax-pay-ui
synced 2026-08-13 15:55:43 +08:00
feat 结算台和支付配置调整
This commit is contained in:
14
src/enums/payChannelEnum.ts
Normal file
14
src/enums/payChannelEnum.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 支付通道
|
||||
*/
|
||||
export enum payChannelEnum {
|
||||
ALI = 'ali_pay',
|
||||
WECHAT = 'wechat_pay',
|
||||
UNION_PAY = 'union_pay',
|
||||
CASH = 'cash_pay',
|
||||
WALLET = 'wallet_pay',
|
||||
VOUCHER = 'voucher_pay',
|
||||
CREDIT_CARD = 'credit_pay',
|
||||
APPLE_PAY = 'apple_pay',
|
||||
AGGREGATION = 'aggregation_pay',
|
||||
}
|
||||
12
src/enums/payWayEnum.ts
Normal file
12
src/enums/payWayEnum.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 支付通道
|
||||
*/
|
||||
export enum payWayEnum {
|
||||
NORMAL = 'NORMAL',
|
||||
WAP = 'WAP',
|
||||
APP = 'APP',
|
||||
WEB = 'WEB',
|
||||
QRCODE = 'QRCODE',
|
||||
BARCODE = 'BARCODE',
|
||||
JSAPI = 'JSAPI',
|
||||
}
|
||||
@@ -113,12 +113,18 @@
|
||||
import QrCode from '/@/components/Qrcode/src/Qrcode.vue'
|
||||
import { useIntervalFn } from '@vueuse/core'
|
||||
import { findByParamKey } from '/@/api/common/Parameter'
|
||||
import { payChannelEnum } from '/@/enums/payChannelEnum'
|
||||
import { payWayEnum } from '/@/enums/payWayEnum'
|
||||
|
||||
const { createMessage } = useMessage()
|
||||
|
||||
const cashierQrCode = $ref<any>()
|
||||
const cashierBarCode = $ref<any>()
|
||||
|
||||
// 商户和通道
|
||||
let mchCode = $ref<string>()
|
||||
let mchAppCode = $ref<string>()
|
||||
|
||||
// 业务单号
|
||||
let businessId = $ref('')
|
||||
let title = $ref('测试支付')
|
||||
@@ -135,23 +141,50 @@
|
||||
payWay: null,
|
||||
})
|
||||
let AliPayList = $ref([
|
||||
{ img: new URL('./imgs/ali/ali_qr.svg', import.meta.url).href, title: '支付宝二维码', payInfo: { payChannel: 1, payWay: 4 } },
|
||||
{ img: new URL('./imgs/ali/ali_bar.svg', import.meta.url).href, title: '支付宝条码', payInfo: { payChannel: 1, payWay: 5 } },
|
||||
{ img: new URL('./imgs/ali/ali_pc.svg', import.meta.url).href, title: '支付宝PC网站', payInfo: { payChannel: 1, payWay: 3 } },
|
||||
{ img: new URL('./imgs/ali/ali_wap.svg', import.meta.url).href, title: '支付宝wap支付', payInfo: { payChannel: 1, payWay: 1 } },
|
||||
{
|
||||
img: new URL('./imgs/ali/ali_qr.svg', import.meta.url).href,
|
||||
title: '支付宝二维码',
|
||||
payInfo: { payChannel: payChannelEnum.ALI, payWay: payWayEnum.QRCODE },
|
||||
},
|
||||
{
|
||||
img: new URL('./imgs/ali/ali_bar.svg', import.meta.url).href,
|
||||
title: '支付宝条码',
|
||||
payInfo: { payChannel: payChannelEnum.ALI, payWay: payWayEnum.BARCODE },
|
||||
},
|
||||
{
|
||||
img: new URL('./imgs/ali/ali_pc.svg', import.meta.url).href,
|
||||
title: '支付宝PC网站',
|
||||
payInfo: { payChannel: payChannelEnum.ALI, payWay: payWayEnum.WEB },
|
||||
},
|
||||
{
|
||||
img: new URL('./imgs/ali/ali_wap.svg', import.meta.url).href,
|
||||
title: '支付宝wap支付',
|
||||
payInfo: { payChannel: payChannelEnum.ALI, payWay: payWayEnum.WAP },
|
||||
},
|
||||
])
|
||||
let WxPayList = $ref([
|
||||
{ img: new URL('./imgs/wechat/wx_native.svg', import.meta.url), title: '微信二维码', payInfo: { payChannel: 2, payWay: 4 } },
|
||||
{ img: new URL('./imgs/wechat/wx_bar.svg', import.meta.url), title: '微信条码', payInfo: { payChannel: 2, payWay: 5 } },
|
||||
// { img: new URL('./imgs/wechat/wx_jsapi.svg', import.meta.url), title: '公众号/小程序', payInfo: { payChannel: 2, payWay: 23 } }
|
||||
{
|
||||
img: new URL('./imgs/wechat/wx_native.svg', import.meta.url),
|
||||
title: '微信二维码',
|
||||
payInfo: { payChannel: payChannelEnum.WECHAT, payWay: payWayEnum.QRCODE },
|
||||
},
|
||||
{
|
||||
img: new URL('./imgs/wechat/wx_bar.svg', import.meta.url),
|
||||
title: '微信条码',
|
||||
payInfo: { payChannel: payChannelEnum.WECHAT, payWay: payWayEnum.BARCODE },
|
||||
},
|
||||
])
|
||||
let aggregationPayList = $ref([
|
||||
{
|
||||
img: new URL('./imgs/qr/qr_cashier.svg', import.meta.url).href,
|
||||
title: '聚合扫码(用户扫商家)',
|
||||
payInfo: { payChannel: 99, payWay: 4 },
|
||||
payInfo: { payChannel: payChannelEnum.AGGREGATION, payWay: payWayEnum.QRCODE },
|
||||
},
|
||||
{
|
||||
img: new URL('./imgs/qr/auto_bar.svg', import.meta.url).href,
|
||||
title: '聚合条码(商家扫用户)',
|
||||
payInfo: { payChannel: payChannelEnum.AGGREGATION, payWay: payWayEnum.BARCODE },
|
||||
},
|
||||
{ img: new URL('./imgs/qr/auto_bar.svg', import.meta.url).href, title: '聚合条码(商家扫用户)', payInfo: { payChannel: 99, payWay: 5 } },
|
||||
])
|
||||
let payMoneyList = [
|
||||
// 支付金额列表
|
||||
@@ -184,7 +217,19 @@
|
||||
{ immediate: false },
|
||||
)
|
||||
|
||||
// 支付金额变动
|
||||
/**
|
||||
* 初始化业务数据
|
||||
*/
|
||||
async function initData() {
|
||||
// 获取业务编码
|
||||
refreshBusinessId()
|
||||
// 获取商户和应用编码
|
||||
mchCode = (await findByParamKey('CashierMchCode')).data
|
||||
mchAppCode = (await findByParamKey('CashierMchAppCode')).data
|
||||
}
|
||||
/**
|
||||
* 支付金额变动
|
||||
*/
|
||||
function payMoneyValueChange(e) {
|
||||
totalMoney = null
|
||||
if (e.target.value === '6') {
|
||||
@@ -194,26 +239,30 @@
|
||||
payMoneyShow = false
|
||||
}
|
||||
}
|
||||
// 发起支付
|
||||
/**
|
||||
* 发起支付
|
||||
*/
|
||||
function pay() {
|
||||
const { payChannel, payWay } = currentActive
|
||||
// 聚合扫码
|
||||
if (payChannel === 99 && payWay === 4) {
|
||||
if (payChannel === payChannelEnum.AGGREGATION && payWay === payWayEnum.QRCODE) {
|
||||
aggregationQr()
|
||||
} else if (payChannel === 99 && payWay === 5) {
|
||||
} else if (payChannel === payChannelEnum.AGGREGATION && payWay === payWayEnum.BARCODE) {
|
||||
// 聚合条码
|
||||
cashierBarCode.init('请输入支付宝、微信条码')
|
||||
} else {
|
||||
// 普通支付
|
||||
// 付款码
|
||||
if (payWay === 5) {
|
||||
cashierBarCode.init(payChannel === 1 ? '请输入支付宝条码' : '请输入微信条码')
|
||||
if (payWay === payWayEnum.BARCODE) {
|
||||
cashierBarCode.init(payChannel === payChannelEnum.ALI ? '请输入支付宝条码' : '请输入微信条码')
|
||||
} else {
|
||||
qrPay(payChannel, payWay)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 扫码支付
|
||||
/**
|
||||
* 扫码支付
|
||||
*/
|
||||
async function qrPay(payChannel, payWay) {
|
||||
const param = {
|
||||
businessId: businessId,
|
||||
@@ -221,15 +270,17 @@
|
||||
title: title,
|
||||
payChannel,
|
||||
payWay,
|
||||
mchCode,
|
||||
mchAppCode,
|
||||
}
|
||||
// 接受结果
|
||||
loading = true
|
||||
const { data } = await singlePay(param).catch(() => (loading = false))
|
||||
loading = false
|
||||
// pc支付
|
||||
if ([1, 3].includes(payWay)) {
|
||||
if ([payWayEnum.WAP, payWayEnum.WEB].includes(payWay)) {
|
||||
window.open(data.asyncPayInfo.payBody)
|
||||
} else if (payChannel === 1) {
|
||||
} else if (payChannel === payChannelEnum.ALI) {
|
||||
cashierQrCode.init(data.asyncPayInfo.payBody, '请使用支付宝"扫一扫"扫码支付')
|
||||
resume()
|
||||
} else {
|
||||
@@ -237,23 +288,29 @@
|
||||
resume()
|
||||
}
|
||||
}
|
||||
// 聚合扫码
|
||||
/**
|
||||
* 聚合扫码
|
||||
*/
|
||||
async function aggregationQr() {
|
||||
const param = {
|
||||
businessId: businessId,
|
||||
amount: totalMoney,
|
||||
title: title,
|
||||
mchCode,
|
||||
mchAppCode,
|
||||
}
|
||||
// 获取聚合支付的地址
|
||||
const { data: cashierAggregateUrl } = await findByParamKey('CashierAggregateUrl')
|
||||
// 获取聚合支付的标识key
|
||||
const { data: qrKey } = await createAggregatePay(param)
|
||||
// 发起支付
|
||||
const qrUrl = `${cashierAggregateUrl}/cashier/aggregatePay?key=${qrKey}`
|
||||
const qrUrl = `${cashierAggregateUrl}/cashier/aggregatePay/${mchAppCode}?key=${qrKey}`
|
||||
cashierQrCode.init(qrUrl, '请使用支付宝或微信"扫一扫"扫码支付')
|
||||
resume()
|
||||
}
|
||||
// 条码支付
|
||||
/**
|
||||
* 条码支付
|
||||
*/
|
||||
function barPay(authCode) {
|
||||
const { payChannel, payWay } = currentActive
|
||||
const param = {
|
||||
@@ -263,21 +320,28 @@
|
||||
authCode,
|
||||
payChannel,
|
||||
payWay,
|
||||
mchCode,
|
||||
mchAppCode,
|
||||
}
|
||||
singlePay(param).then(() => {
|
||||
resume()
|
||||
})
|
||||
}
|
||||
// 生成业务id
|
||||
/**
|
||||
* 生成业务id
|
||||
*/
|
||||
function refreshBusinessId() {
|
||||
businessId = 'P' + new Date().getTime()
|
||||
}
|
||||
// 当前选择的支付类型
|
||||
/**
|
||||
* 当前选择的支付类型
|
||||
*/
|
||||
function handleActive(payInfo) {
|
||||
console.log(payInfo)
|
||||
currentActive = payInfo
|
||||
}
|
||||
// 关闭
|
||||
/**
|
||||
* 关闭
|
||||
*/
|
||||
function handleCancel() {
|
||||
cashierQrCode.handleClose()
|
||||
cashierBarCode.handleClose()
|
||||
@@ -285,9 +349,15 @@
|
||||
pause()
|
||||
}
|
||||
|
||||
/**
|
||||
* 入口
|
||||
*/
|
||||
onMounted(() => {
|
||||
refreshBusinessId()
|
||||
initData()
|
||||
})
|
||||
/**
|
||||
* 出口
|
||||
*/
|
||||
onUnmounted(() => {
|
||||
handleCancel()
|
||||
})
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
import { useIntervalFn } from '@vueuse/core'
|
||||
import { onMounted } from 'vue'
|
||||
import CashierQrCode from './CashierQrCode.vue'
|
||||
import { Wallet } from "/@/views/modules/payment/wallet/list/Wallet.api";
|
||||
|
||||
const { createMessage } = useMessage()
|
||||
|
||||
@@ -68,7 +69,7 @@
|
||||
]
|
||||
let loading = $ref(false)
|
||||
let visible = $ref(false)
|
||||
let wallet = $ref({ balance: 0 })
|
||||
let wallet = $ref<Wallet>({ balance: 0 })
|
||||
let voucher = $ref<Voucher>({})
|
||||
let form = $ref({
|
||||
payChannel: 1,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
* 打开
|
||||
*/
|
||||
function show(record: MchAppPayConfigResult) {
|
||||
console.log(record)
|
||||
switch (record.channelCode) {
|
||||
case 'ali_pay': {
|
||||
alipay.init(record)
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
<a-form-item label="主键" name="id" :hidden="true">
|
||||
<a-input v-model:value="form.id" :disabled="showable" />
|
||||
</a-form-item>
|
||||
<a-form-item label="名称" name="name">
|
||||
<a-input v-model:value="form.name" :disabled="showable" placeholder="请输入名称" />
|
||||
</a-form-item>
|
||||
<a-form-item label="AppId" name="appId">
|
||||
<a-input v-model:value="form.appId" :disabled="showable" placeholder="请输入支付宝商户AppId" />
|
||||
</a-form-item>
|
||||
@@ -105,6 +102,8 @@
|
||||
import { BasicDrawer } from '/@/components/Drawer'
|
||||
import { KeyValue } from '/#/web'
|
||||
import { MchAppPayConfigResult } from '/@/views/modules/payment/app/MchApplication.api'
|
||||
import { dropdownTranslate } from '/@/utils/dataUtil'
|
||||
import { LabeledValue } from 'ant-design-vue/lib/select'
|
||||
const {
|
||||
initFormEditType,
|
||||
handleCancel,
|
||||
@@ -124,9 +123,9 @@
|
||||
const formRef = $ref<FormInstance>()
|
||||
|
||||
let editType = $ref<FormEditType>()
|
||||
let payWayList = $ref<KeyValue[]>([])
|
||||
let payWayList = $ref<LabeledValue[]>([])
|
||||
let form = $ref({
|
||||
name: '',
|
||||
// name: '',
|
||||
appId: '',
|
||||
notifyUrl: '',
|
||||
returnUrl: '',
|
||||
@@ -147,7 +146,7 @@
|
||||
// 校验
|
||||
const rules = computed(() => {
|
||||
return {
|
||||
name: [{ required: true, message: '请输入配置名称' }],
|
||||
// name: [{ required: true, message: '请输入配置名称' }],
|
||||
appId: [{ required: true, message: '请输入AppId' }],
|
||||
notifyUrl: [{ required: true, message: '请输入异步通知页面地址' }],
|
||||
returnUrl: [{ required: true, message: '请输入同步通知页面地址' }],
|
||||
@@ -169,7 +168,7 @@
|
||||
// 入口
|
||||
function init(record: MchAppPayConfigResult) {
|
||||
findPayWayList().then(({ data }) => {
|
||||
payWayList = data
|
||||
payWayList = dropdownTranslate(data, 'value', 'key')
|
||||
})
|
||||
editType = record.configId ? FormEditType.Edit : FormEditType.Add
|
||||
initFormEditType(editType)
|
||||
|
||||
@@ -13,14 +13,11 @@
|
||||
<a-form-item label="主键" name="id" :hidden="true">
|
||||
<a-input v-model:value="form.id" :disabled="showable" />
|
||||
</a-form-item>
|
||||
<a-form-item label="名称" name="name">
|
||||
<a-input v-model:value="form.name" :disabled="showable" placeholder="请输入名称" />
|
||||
<a-form-item label="商户号" name="wxMchId">
|
||||
<a-input v-model:value="form.wxMchId" :disabled="showable" placeholder="请输入商户号" />
|
||||
</a-form-item>
|
||||
<a-form-item label="商户号" name="mchId">
|
||||
<a-input v-model:value="form.mchId" :disabled="showable" placeholder="请输入商户号" />
|
||||
</a-form-item>
|
||||
<a-form-item label="应用编号" name="appId">
|
||||
<a-input v-model:value="form.appId" :disabled="showable" placeholder="请输入微信应用AppId" />
|
||||
<a-form-item label="应用编号" name="wxAppId">
|
||||
<a-input v-model:value="form.wxAppId" :disabled="showable" placeholder="请输入微信应用AppId" />
|
||||
</a-form-item>
|
||||
<a-form-item label="AppSecret" name="appSecret">
|
||||
<a-input v-model:value="form.appSecret" :disabled="showable" placeholder="APPID对应的接口密码,用于获取接口调用凭证时使用" />
|
||||
@@ -86,7 +83,7 @@
|
||||
<a-textarea :rows="5" :disabled="showable" v-model:value="form.certPem" placeholder="请填入证书内容" />
|
||||
</a-form-item>
|
||||
<a-form-item label="私钥(key.pem)" name="keyPem">
|
||||
<a-input v-model:value="form.keyPem" :disabled="showable" placeholder="请填入私钥内容" />
|
||||
<a-textarea :rows="5" v-model:value="form.keyPem" :disabled="showable" placeholder="请填入私钥内容" />
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" name="remark">
|
||||
<a-textarea v-model:value="form.remark" :disabled="showable" placeholder="请输入备注" />
|
||||
@@ -103,18 +100,19 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, nextTick, reactive } from 'vue'
|
||||
import { computed, nextTick } from 'vue'
|
||||
import { $ref } from 'vue/macros'
|
||||
import useFormEdit from '/@/hooks/bootx/useFormEdit'
|
||||
import { add, get, update, findPayWayList, WechatPayConfig } from './WechatPayConfig.api'
|
||||
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
|
||||
import { FormEditType } from '/@/enums/formTypeEnum'
|
||||
import { BasicDrawer } from '/@/components/Drawer'
|
||||
import { KeyValue } from '/#/web'
|
||||
import Icon from '/@/components/Icon/src/Icon.vue'
|
||||
import { useUpload } from '/@/hooks/bootx/useUpload'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
import { MchAppPayConfigResult } from '/@/views/modules/payment/app/MchApplication.api'
|
||||
import { dropdownTranslate } from '/@/utils/dataUtil'
|
||||
import { LabeledValue } from 'ant-design-vue/lib/select'
|
||||
|
||||
const {
|
||||
initFormEditType,
|
||||
@@ -141,9 +139,8 @@
|
||||
let rawForm
|
||||
let form = $ref<WechatPayConfig>({
|
||||
id: null,
|
||||
name: '',
|
||||
mchId: '',
|
||||
appId: '',
|
||||
wxMchId: '',
|
||||
wxAppId: '',
|
||||
appSecret: '',
|
||||
apiVersion: 'api_v2',
|
||||
p12: null,
|
||||
@@ -162,7 +159,6 @@
|
||||
// 校验
|
||||
const rules = computed(() => {
|
||||
return {
|
||||
name: [{ required: true, message: '请输入配置名称' }],
|
||||
mchId: [{ required: true, message: '请输入商户号' }],
|
||||
appId: [{ required: true, message: '请输入应用编号' }],
|
||||
notifyUrl: [{ required: true, message: '请输入异步通知页面地址' }],
|
||||
@@ -176,15 +172,14 @@
|
||||
} as Record<string, Rule[]>
|
||||
})
|
||||
|
||||
let payWayList = $ref<KeyValue[]>([])
|
||||
let payWayList = $ref<LabeledValue[]>([])
|
||||
|
||||
// 事件
|
||||
const emits = defineEmits(['ok'])
|
||||
// 入口
|
||||
function init(record: MchAppPayConfigResult) {
|
||||
findPayWayList().then(({ data }) => {
|
||||
payWayList = data
|
||||
console.log(payWayList)
|
||||
payWayList = dropdownTranslate(data, 'value', 'key')
|
||||
})
|
||||
editType = record.configId ? FormEditType.Edit : FormEditType.Add
|
||||
initFormEditType(editType)
|
||||
|
||||
@@ -101,9 +101,9 @@ export interface WechatPayConfig extends BaseEntity {
|
||||
// 商户应用编码
|
||||
mchAppCode?: string
|
||||
// 微信应用AppId
|
||||
appId?: string
|
||||
// 商户号
|
||||
mchId?: string
|
||||
wxAppId?: string
|
||||
// 微信商户号
|
||||
wxMchId?: string
|
||||
// 服务商应用编号
|
||||
apiVersion?: string
|
||||
// 商户平台「API安全」中的 APIv2 密钥
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
import { useDict } from '/@/hooks/bootx/useDict'
|
||||
import { cancelByPaymentId, syncByBusinessId } from '/@/api/common/Pay'
|
||||
import BSuperQuery from '/@/components/Bootx/SuperQuery/BSuperQuery.vue'
|
||||
import { VxePager, VxeTable, VxeToolbar } from "../../../../../../dist/assets/index.669df1fd";
|
||||
|
||||
// 使用hooks
|
||||
const { handleTableChange, pageQueryResHandel, resetQuery, resetQueryParams, pagination, pages, model, loading, superQueryFlag } =
|
||||
|
||||
Reference in New Issue
Block a user