feat: pay refund [未测试]
parent
70bb20b41f
commit
15557250b0
|
@ -31,6 +31,7 @@ export namespace PayRefundApi {
|
|||
successTime: Date;
|
||||
notifyTime: Date;
|
||||
createTime: Date;
|
||||
updateTime: Date;
|
||||
}
|
||||
|
||||
/** 退款订单分页请求 */
|
||||
|
|
|
@ -67,7 +67,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
} as VxeTableGridOptions<any>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { PayRefundApi } from '#/api/pay/refund';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
import { getAppList } from '#/api/pay/app';
|
||||
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '#/utils/dict';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'appId',
|
||||
label: '应用编号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: async () => {
|
||||
const data = await getAppList();
|
||||
return data.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}));
|
||||
},
|
||||
autoSelect: 'first',
|
||||
placeholder: '请选择数据源',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'channelCode',
|
||||
label: '退款渠道',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getStrDictOptions(DICT_TYPE.PAY_CHANNEL_CODE),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'merchantOrderId',
|
||||
label: '商户支付单号',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'merchantRefundId',
|
||||
label: '商户退款单号',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'channelOrderNo',
|
||||
label: '渠道支付单号',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'channelRefundNo',
|
||||
label: '渠道退款单号',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '退款状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getIntDictOptions(DICT_TYPE.PAY_REFUND_STATUS),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'daterange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns<T = PayRefundApi.Refund>(
|
||||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'payPrice',
|
||||
title: '支付金额',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'success',
|
||||
content: '¥{payPrice}',
|
||||
formatter: (value: number) => (value / 100).toFixed(2),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'refundPrice',
|
||||
title: '退款金额',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'danger',
|
||||
content: '¥{refundPrice}',
|
||||
formatter: (value: number) => (value / 100).toFixed(2),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'merchantRefundId',
|
||||
title: '退款订单号',
|
||||
minWidth: 300,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'info',
|
||||
content: '商户 {merchantRefundId}',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'channelRefundNo',
|
||||
title: '渠道退款单号',
|
||||
minWidth: 200,
|
||||
cellRender: {
|
||||
name: 'CellTag',
|
||||
props: {
|
||||
type: 'success',
|
||||
content: '{channelRefundNo}',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '退款状态',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.PAY_REFUND_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'operation',
|
||||
title: '操作',
|
||||
minWidth: 100,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
cellRender: {
|
||||
attrs: {
|
||||
onClick: onActionClick,
|
||||
},
|
||||
name: 'CellOperation',
|
||||
options: [
|
||||
{
|
||||
code: 'detail',
|
||||
show: hasAccessByCodes(['pay:refund:query']),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
|
@ -1,34 +1,104 @@
|
|||
<script lang="ts" setup>
|
||||
import { Page } from '@vben/common-ui';
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Download } from '@vben/icons';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import * as RefundApi from '#/api/pay/refund';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
</script>
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Detail from './modules/detail.vue';
|
||||
|
||||
const [RefundDetailModal, refundDetailModalApi] = useVbenModal({
|
||||
connectedComponent: Detail,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function onExport() {
|
||||
const data = await RefundApi.exportRefund(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '支付退款.xls', source: data });
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function onDetail(row: any) {
|
||||
refundDetailModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({ code, row }: OnActionClickParams<any>) {
|
||||
switch (code) {
|
||||
case 'detail': {
|
||||
onDetail(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(onActionClick),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await RefundApi.getRefundPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<any>,
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Page>
|
||||
<DocAlert
|
||||
title="支付宝、微信退款接入"
|
||||
url="https://doc.iocoder.cn/pay/refund-demo/"
|
||||
/>
|
||||
<Button
|
||||
danger
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
||||
>
|
||||
该功能支持 Vue3 + element-plus 版本!
|
||||
</Button>
|
||||
<br />
|
||||
<Button
|
||||
type="link"
|
||||
target="_blank"
|
||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/pay/refund/index"
|
||||
>
|
||||
可参考
|
||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/pay/refund/index
|
||||
代码,pull request 贡献给我们!
|
||||
</Button>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="支付宝、微信退款接入"
|
||||
url="https://doc.iocoder.cn/pay/refund-demo/"
|
||||
/>
|
||||
</template>
|
||||
<RefundDetailModal @success="onRefresh" />
|
||||
<Grid table-title="支付退款列表">
|
||||
<template #toolbar-tools>
|
||||
<Button
|
||||
type="primary"
|
||||
class="ml-2"
|
||||
@click="onExport"
|
||||
v-access:code="['pay:refund:export']"
|
||||
>
|
||||
<Download class="size-5" />
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</Button>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
<script lang="ts" setup>
|
||||
import type { PayRefundApi } from '#/api/pay/refund';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { Descriptions, Divider, Tag } from 'ant-design-vue';
|
||||
|
||||
import { getRefund } from '#/api/pay/refund';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { DICT_TYPE } from '#/utils/dict';
|
||||
|
||||
const formData = ref<PayRefundApi.Refund>();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<PayRefundApi.Refund>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getRefund(data.id);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = (id: number) => {
|
||||
modalApi.setData({ id }).open();
|
||||
};
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
title="退款详情"
|
||||
class="w-1/2"
|
||||
:show-cancel-button="false"
|
||||
:show-confirm-button="false"
|
||||
>
|
||||
<Descriptions bordered :column="2" size="middle" class="mx-4">
|
||||
<Descriptions.Item label="商户退款单号">
|
||||
<Tag size="small">{{ formData?.merchantRefundId }}</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="渠道退款单号">
|
||||
<Tag type="success" size="small" v-if="formData?.channelRefundNo">
|
||||
{{ formData?.channelRefundNo }}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="商户支付单号">
|
||||
<Tag size="small">{{ formData?.merchantOrderId }}</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="渠道支付单号">
|
||||
<Tag type="success" size="small">
|
||||
{{ formData?.channelOrderNo }}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="应用编号">
|
||||
{{ formData?.appId }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="应用名称">
|
||||
{{ formData?.appName }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="支付金额">
|
||||
<Tag type="success" size="small">
|
||||
¥{{ (formData?.payPrice || 0) / 100.0 }}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="退款金额">
|
||||
<Tag size="mini" type="danger">
|
||||
¥{{ (formData?.refundPrice || 0) / 100.0 }}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="退款状态">
|
||||
<DictTag
|
||||
:type="DICT_TYPE.PAY_REFUND_STATUS"
|
||||
:value="formData?.status"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="退款时间">
|
||||
{{ formatDateTime(formData?.successTime || '') }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">
|
||||
{{ formatDateTime(formData?.createTime || '') }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="更新时间">
|
||||
{{ formatDateTime(formData?.updateTime || '') }}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Divider />
|
||||
<Descriptions bordered :column="2" size="middle" class="mx-4">
|
||||
<Descriptions.Item label="退款渠道">
|
||||
<DictTag
|
||||
:type="DICT_TYPE.PAY_CHANNEL_CODE"
|
||||
:value="formData?.channelCode"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="退款原因">
|
||||
{{ formData?.reason }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="退款 IP">
|
||||
{{ formData?.userIp }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="通知 URL">
|
||||
{{ formData?.notifyUrl }}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Divider />
|
||||
<Descriptions bordered :column="2" size="middle" class="mx-4">
|
||||
<Descriptions.Item label="渠道错误码">
|
||||
{{ formData?.channelErrorCode }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="渠道错误码描述">
|
||||
{{ formData?.channelErrorMsg }}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
||||
<Descriptions.Item label="支付通道异步回调内容">
|
||||
<p class="whitespace-pre-wrap break-words">
|
||||
{{ formData?.channelNotifyData }}
|
||||
</p>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Modal>
|
||||
</template>
|
Loading…
Reference in New Issue