Browse Source

feat: pay notify

main
xingyu 2 years ago
parent
commit
26dbe8ca94
  1. 5
      src/api/pay/app/index.ts
  2. 11
      src/api/pay/notify/index.ts
  3. 2
      src/components/Table/src/hooks/useRender.ts
  4. 2
      src/utils/dict.ts
  5. 34
      src/views/pay/notify/NotifyModal.vue
  6. 50
      src/views/pay/notify/index.vue
  7. 228
      src/views/pay/notify/notify.data.ts

5
src/api/pay/app/index.ts

@ -76,3 +76,8 @@ export function exportApp(params: AppExportReqVO) {
export function getAppListByMerchantId(merchantId: number) {
return defHttp.get({ url: '/pay/app/list-merchant-id', params: { merchantId } })
}
// 获得支付应用列表
export function getAppList() {
return defHttp.get({ url: '/pay/app/list' })
}

11
src/api/pay/notify/index.ts

@ -0,0 +1,11 @@
import { defHttp } from '@/utils/http/axios'
// 获得支付通知明细
export function getNotifyTaskDetail(id) {
return defHttp.get({ url: `/pay/notify/get-detail?id=${id}` })
}
// 获得支付通知分页
export function getNotifyTaskPage(params) {
return defHttp.get({ url: '/pay/notify/page', params })
}

2
src/components/Table/src/hooks/useRender.ts

@ -52,7 +52,7 @@ export const useRender = {
* @param color
* @returns
*/
renderTag: (text: string, color?: string) => {
renderTag: (text: string | number, color?: string) => {
if (color)
return h(Tag, { color }, () => text)
else

2
src/utils/dict.ts

@ -127,6 +127,8 @@ export enum DICT_TYPE {
PAY_ORDER_REFUND_STATUS = 'pay_order_refund_status', // 商户支付订单退款状态
PAY_REFUND_ORDER_STATUS = 'pay_refund_order_status', // 退款订单状态
PAY_REFUND_ORDER_TYPE = 'pay_refund_order_type', // 退款订单类别
PAY_NOTIFY_STATUS = 'pay_notify_status', // 商户支付回调状态
PAY_NOTIFY_TYPE = 'pay_notify_type', // 商户支付回调状态
// ========== MP 模块 ==========
MP_AUTO_REPLY_REQUEST_MATCH = 'mp_auto_reply_request_match', // 自动回复请求匹配类型

34
src/views/pay/notify/NotifyModal.vue

@ -0,0 +1,34 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { Divider } from 'ant-design-vue'
import { descColumns, descSchema } from './notify.data'
import { BasicModal, useModalInner } from '@/components/Modal'
import { Description } from '@/components/Description'
import { BasicTable } from '@/components/Table'
import { getNotifyTaskDetail } from '@/api/pay/notify'
defineOptions({ name: 'PayNotifyDetail' })
const notifyData = ref<any>()
const notifyLogs = ref<any[]>([])
const [registerModal, { setModalProps }] = useModalInner(async (data) => {
const res = await getNotifyTaskDetail(data.record.id)
notifyData.value = res
if (res.logs)
notifyLogs.value = res.logs
setModalProps({ confirmLoading: false })
})
</script>
<template>
<BasicModal v-bind="$attrs" width="60%" title="通知详情" :show-ok-btn="false" @register="registerModal">
<Description :bordered="false" :column="3" :data="notifyData" :schema="descSchema" />
<Divider />
<BasicTable
title="回调日志" :columns="descColumns" :data-source="notifyLogs" :bordered="true" :pagination="false"
:can-resize="true" :max-height="400"
/>
</BasicModal>
</template>

50
src/views/pay/notify/index.vue

@ -0,0 +1,50 @@
<script lang="ts" setup>
import NotifyModal from './NotifyModal.vue'
import { columns, searchFormSchema } from './notify.data'
import { useI18n } from '@/hooks/web/useI18n'
import { useModal } from '@/components/Modal'
import { IconEnum } from '@/enums/appEnum'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { getNotifyTaskPage } from '@/api/pay/notify'
defineOptions({ name: 'PayNotify' })
const { t } = useI18n()
const [registerModal, { openModal }] = useModal()
const [registerTable] = useTable({
title: '通知列表',
api: getNotifyTaskPage,
columns,
formConfig: { labelWidth: 120, schemas: searchFormSchema },
useSearchForm: true,
showTableSetting: true,
actionColumn: {
width: 140,
title: t('common.action'),
dataIndex: 'action',
fixed: 'right',
},
})
async function handleQueryDetails(record: Recordable) {
openModal(true, { record, isUpdate: true })
}
</script>
<template>
<div>
<BasicTable @register="registerTable">
<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>
<NotifyModal @register="registerModal" />
</div>
</template>

228
src/views/pay/notify/notify.data.ts

@ -0,0 +1,228 @@
import { getAppList } from '@/api/pay/app'
import type { DescItem } from '@/components/Description'
import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
export const columns: BasicColumn[] = [
{
title: '任务编号',
dataIndex: 'id',
width: 100,
},
{
title: '应用编号',
dataIndex: 'appName',
width: 200,
},
{
title: '商户订单编号',
dataIndex: 'merchantOrderId',
width: 200,
},
{
title: '通知类型',
dataIndex: 'type',
width: 100,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.PAY_NOTIFY_TYPE)
},
},
{
title: '关联编号',
dataIndex: 'dataId',
width: 200,
},
{
title: '通知状态',
dataIndex: 'status',
width: 100,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.PAY_NOTIFY_STATUS)
},
},
{
title: '最后通知时间',
dataIndex: 'lastExecuteTime',
width: 180,
customRender: ({ text }) => {
return useRender.renderDate(text)
},
},
{
title: '下次通知时间',
dataIndex: 'nextNotifyTime',
width: 180,
customRender: ({ text }) => {
return useRender.renderDate(text)
},
},
{
title: '最大通知次数',
dataIndex: 'maxNotifyTimes',
width: 120,
ifShow: false,
},
{
title: '通知次数',
dataIndex: 'notifyTimes',
width: 120,
customRender: ({ record, text }) => {
return useRender.renderTag(`${text}/${record.maxNotifyTimes}`)
},
},
]
export const searchFormSchema: FormSchema[] = [
{
label: '应用编号',
field: 'appId',
component: 'ApiSelect',
componentProps: {
api: () => getAppList(),
labelField: 'name',
valueField: 'id',
},
colProps: { span: 8 },
},
{
label: '通知类型',
field: 'type',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.PAY_NOTIFY_TYPE, 'number'),
},
colProps: { span: 8 },
},
{
label: '关联编号',
field: 'dataId',
component: 'Input',
colProps: { span: 8 },
},
{
label: '通知状态',
field: 'status',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.PAY_NOTIFY_STATUS),
},
colProps: { span: 8 },
},
{
label: '商户订单编号',
field: 'merchantOrderId',
component: 'Input',
colProps: { span: 8 },
},
{
label: '创建时间',
field: 'createTime',
component: 'RangePicker',
colProps: { span: 8 },
},
]
export const descSchema: DescItem[] = [
{
label: '商户订单编号',
field: 'merchantOrderId',
},
{
label: '通知状态',
field: 'status',
render: (curVal) => {
return useRender.renderDict(curVal, DICT_TYPE.PAY_NOTIFY_STATUS)
},
},
{
label: '应用编号',
field: 'appId',
},
{
label: '应用名称',
field: 'appName',
},
{
label: '关联编号',
field: 'dataId',
},
{
label: '通知类型',
field: 'type',
render: (curVal) => {
return useRender.renderDict(curVal, DICT_TYPE.PAY_NOTIFY_TYPE)
},
},
{
label: '通知次数',
field: 'notifyTimes',
},
{
label: '最大通知次数',
field: 'maxNotifyTimes',
},
{
label: '最后通知时间',
field: 'lastExecuteTime',
render: (curVal) => {
return useRender.renderDate(curVal)
},
},
{
label: '下次通知时间',
field: 'nextNotifyTime',
render: (curVal) => {
return useRender.renderDate(curVal)
},
},
{
label: '创建时间',
field: 'createTime',
render: (curVal) => {
return useRender.renderDate(curVal)
},
},
{
label: '更新时间',
field: 'updateTime',
render: (curVal) => {
return useRender.renderDate(curVal)
},
},
]
export const descColumns: BasicColumn[] = [
{
title: '日志编号',
dataIndex: 'id',
width: 100,
},
{
title: '通知状态',
dataIndex: 'status',
width: 100,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.PAY_NOTIFY_STATUS)
},
},
{
title: '通知次数',
dataIndex: 'notifyTimes',
width: 100,
},
{
title: '通知时间',
dataIndex: 'lastExecuteTime',
width: 100,
customRender: ({ text }) => {
return useRender.renderDate(text)
},
},
{
title: '响应结果',
dataIndex: 'response',
width: 100,
},
]