feat: 退款

pull/4/MERGE
xingyu 2023-03-29 23:56:48 +08:00
parent c262854a52
commit fae8ef469f
3 changed files with 419 additions and 1 deletions

View File

@ -0,0 +1,28 @@
<template>
<BasicModal v-bind="$attrs" width="60%" @register="registerModal" title="查看详情" @ok="handleSubmit">
<Description :bordered="false" :column="3" :data="refundData" :schema="descSchema" />
</BasicModal>
</template>
<script lang="ts" setup name="RefundModal">
import { ref } from 'vue'
import { BasicModal, useModalInner } from '@/components/Modal'
import { Description } from '@/components/Description'
import { descSchema } from './refund.data'
import { getRefund } from '@/api/pay/refund'
const emit = defineEmits(['success', 'register'])
const refundData = ref()
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false })
const res = await getRefund(data.record.id)
refundData.value = res
})
async function handleSubmit() {
closeModal()
emit('success')
setModalProps({ confirmLoading: false })
}
</script>

View File

@ -1,3 +1,66 @@
<template>
<div>开发中</div>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="warning" v-auth="['pay:order:export']" :preIcon="IconEnum.EXPORT" @click="handleExport">
{{ t('action.export') }}
</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.DATA, label: t('action.detail'), auth: 'pay:order:query', onClick: handleQueryDetails.bind(null, record) }
]"
/>
</template>
</template>
</BasicTable>
<RefundModal @register="registerModal" @success="reload()" />
</div>
</template>
<script lang="ts" setup name="Refund">
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { useModal } from '@/components/Modal'
import RefundModal from './RefundModal.vue'
import { IconEnum } from '@/enums/appEnum'
import { BasicTable, useTable, TableAction } from '@/components/Table'
import { getRefundPage, exportRefund, PayRefundExportReqVO } from '@/api/pay/refund'
import { columns, searchFormSchema } from './refund.data'
const { t } = useI18n()
const { createConfirm, createMessage } = useMessage()
const [registerModal, { openModal }] = useModal()
const [registerTable, { getForm, reload }] = useTable({
title: '退款列表',
api: getRefundPage,
columns,
formConfig: { labelWidth: 120, schemas: searchFormSchema },
useSearchForm: true,
showTableSetting: true,
actionColumn: {
width: 140,
title: t('common.action'),
dataIndex: 'action',
fixed: 'right'
}
})
function handleQueryDetails(record: Recordable) {
openModal(true, { record, isUpdate: true })
}
async function handleExport() {
createConfirm({
title: t('common.exportTitle'),
iconType: 'warning',
content: t('common.exportMessage'),
async onOk() {
await exportRefund(getForm().getFieldsValue() as PayRefundExportReqVO)
createMessage.success(t('common.exportSuccessText'))
}
})
}
</script>

View File

@ -0,0 +1,327 @@
import { getMerchantListByName } from '@/api/pay/merchant'
import { DescItem } from '@/components/Description'
import { BasicColumn, FormSchema, useRender } from '@/components/Table'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'id',
width: 100
},
{
title: '支付渠道',
children: [
{
title: '商户名称',
dataIndex: 'merchantName',
width: 120
},
{
title: '应用名称',
dataIndex: 'appName',
width: 120
},
{
title: '渠道名称',
dataIndex: 'channelCodeName',
width: 160
}
]
},
{
title: '商户订单号',
children: [
{
title: '退款',
dataIndex: 'merchantRefundNo',
width: 200
},
{
title: '交易',
dataIndex: 'merchantOrderId',
width: 100
}
]
},
{
title: '支付订单号',
children: [
{
title: '交易',
dataIndex: 'tradeNo',
width: 100
},
{
title: '渠道',
dataIndex: 'channelOrderNo',
width: 200
}
]
},
{
title: '支付金额(元)',
dataIndex: 'payAmount',
width: 120,
customRender: ({ text }) => {
return '¥' + parseFloat(text / 100).toFixed(2)
}
},
{
title: '退款金额(元)',
dataIndex: 'refundAmount',
width: 120,
customRender: ({ text }) => {
return '¥' + parseFloat(text / 100).toFixed(2)
}
},
{
title: '退款类型',
dataIndex: 'type',
width: 100,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.PAY_REFUND_ORDER_TYPE)
}
},
{
title: '退款状态',
dataIndex: 'status',
width: 100,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.PAY_REFUND_ORDER_STATUS)
}
},
{
title: '回调状态',
dataIndex: 'notifyStatus',
width: 100,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.PAY_ORDER_NOTIFY_STATUS)
}
},
{
title: '退款原因',
dataIndex: 'reason',
width: 100
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 180,
customRender: ({ text }) => {
return useRender.renderDate(text)
}
},
{
title: '退款成功时间',
dataIndex: 'successTime',
width: 180,
customRender: ({ text }) => {
return useRender.renderDate(text)
}
}
]
export const searchFormSchema: FormSchema[] = [
{
label: '所属商户',
field: 'merchantId',
component: 'ApiSelect',
componentProps: {
api: () => getMerchantListByName('')
},
colProps: { span: 8 }
},
{
label: '应用编号',
field: 'appId',
component: 'Input',
colProps: { span: 8 }
},
{
label: '渠道编码',
field: 'channelCode',
component: 'Select',
componentProps: {
options: getIntDictOptions(DICT_TYPE.PAY_CHANNEL_CODE_TYPE)
},
colProps: { span: 8 }
},
{
label: '退款类型',
field: 'type',
component: 'Select',
componentProps: {
options: getIntDictOptions(DICT_TYPE.PAY_REFUND_ORDER_TYPE)
},
colProps: { span: 8 }
},
{
label: '商户退款订单号',
field: 'merchantRefundNo',
component: 'Input',
colProps: { span: 8 }
},
{
label: '应用编号',
field: 'appId',
component: 'Input',
colProps: { span: 8 }
},
{
label: '退款状态',
field: 'status',
component: 'Select',
componentProps: {
options: getIntDictOptions(DICT_TYPE.PAY_REFUND_ORDER_STATUS)
},
colProps: { span: 8 }
},
{
label: '退款回调状态',
field: 'notifyStatus',
component: 'Select',
componentProps: {
options: getIntDictOptions(DICT_TYPE.PAY_ORDER_NOTIFY_STATUS)
},
colProps: { span: 8 }
},
{
label: '创建时间',
field: 'createTime',
component: 'RangePicker',
colProps: { span: 8 }
}
]
export const descSchema: DescItem[] = [
{
label: '商户名称',
field: 'merchantName'
},
{
label: '应用名称',
field: 'appName'
},
{
label: '商品名称',
field: 'subject'
},
{
label: '商户退款单号',
field: 'merchantRefundNo',
render: (curVal) => {
return useRender.renderTag(curVal)
}
},
{
label: '商户订单号',
field: 'merchantOrderId'
},
{
label: '支付金额',
field: 'payAmount',
render: (curVal) => {
return '¥' + parseFloat(curVal / 100).toFixed(2)
}
},
{
label: '退款金额',
field: 'refundAmount',
render: (curVal) => {
return '¥' + parseFloat(curVal / 100).toFixed(2)
}
},
{
label: '退款类型',
field: 'type',
render: (curVal) => {
return useRender.renderDict(curVal, DICT_TYPE.PAY_REFUND_ORDER_TYPE)
}
},
{
label: '退款状态',
field: 'status',
render: (curVal) => {
return useRender.renderDict(curVal, DICT_TYPE.PAY_REFUND_ORDER_STATUS)
}
},
{
label: '创建时间',
field: 'createTime',
render: (curVal) => {
return useRender.renderDate(curVal)
}
},
{
label: '退款成功时间',
field: 'successTime',
render: (curVal) => {
return useRender.renderDate(curVal)
}
},
{
label: '退款失效时间',
field: 'expireTime',
render: (curVal) => {
return useRender.renderDate(curVal)
}
},
{
label: '更新时间',
field: 'updateTime',
render: (curVal) => {
return useRender.renderDate(curVal)
}
},
{
label: '支付渠道',
field: 'channelCodeName'
},
{
label: '支付IP',
field: 'userIp'
},
{
label: '回调地址',
field: 'notifyUrl'
},
{
label: '回调状态',
field: 'notifyStatus',
render: (curVal) => {
return useRender.renderDict(curVal, DICT_TYPE.PAY_ORDER_NOTIFY_STATUS)
}
},
{
label: '回调时间',
field: 'notifyTime',
render: (curVal) => {
return useRender.renderDate(curVal)
}
},
{
label: '渠道订单号',
field: 'channelOrderNo'
},
{
label: '渠道退款单号',
field: 'channelRefundNo'
},
{
label: '渠道错误码',
field: 'channelErrorCode'
},
{
label: '渠道错误码描述',
field: 'notifchannelErrorMsgyUrl'
},
{
label: '渠道额外参数',
field: 'channelExtras'
},
{
label: '退款原因',
field: 'reason'
}
]