From 0a797760a0563fceb7f3e66153519ee6c38deca2 Mon Sep 17 00:00:00 2001
From: xingyu <xingyu4j@vip.qq.com>
Date: Tue, 22 Aug 2023 11:47:37 +0800
Subject: [PATCH] feat: pay order

---
 src/utils/dict.ts                  |   4 +-
 src/views/pay/order/OrderModal.vue |   2 +-
 src/views/pay/order/order.data.ts  | 216 ++++++++++++-----------------
 3 files changed, 92 insertions(+), 130 deletions(-)

diff --git a/src/utils/dict.ts b/src/utils/dict.ts
index 62adc63..c4c58b4 100644
--- a/src/utils/dict.ts
+++ b/src/utils/dict.ts
@@ -123,10 +123,12 @@ export enum DICT_TYPE {
   PAY_CHANNEL_ALIPAY_SERVER_TYPE = 'pay_channel_alipay_server_type', // 支付宝网关地址
   PAY_CHANNEL_CODE_TYPE = 'pay_channel_code_type', // 支付渠道编码类型
   PAY_ORDER_NOTIFY_STATUS = 'pay_order_notify_status', // 商户支付订单回调状态
-  PAY_ORDER_STATUS = 'pay_order_status', // 商户支付订单状态
   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_CHANNEL_CODE = 'pay_channel_code', // 支付渠道编码类型
+  PAY_ORDER_STATUS = 'pay_order_status', // 商户支付订单状态
+  PAY_REFUND_STATUS = 'pay_refund_status', // 退款订单状态
   PAY_NOTIFY_STATUS = 'pay_notify_status', // 商户支付回调状态
   PAY_NOTIFY_TYPE = 'pay_notify_type', // 商户支付回调状态
 
diff --git a/src/views/pay/order/OrderModal.vue b/src/views/pay/order/OrderModal.vue
index 1c56b44..6782c8b 100644
--- a/src/views/pay/order/OrderModal.vue
+++ b/src/views/pay/order/OrderModal.vue
@@ -18,6 +18,6 @@ const [registerModal, { setModalProps }] = useModalInner(async (data) => {
 
 <template>
   <BasicModal v-bind="$attrs" width="60%" title="查看详情" :show-ok-btn="false" @register="registerModal">
-    <Description :bordered="false" :column="3" :data="refundData" :schema="descSchema" />
+    <Description :bordered="false" :column="2" :data="refundData" :schema="descSchema" />
   </BasicModal>
 </template>
diff --git a/src/views/pay/order/order.data.ts b/src/views/pay/order/order.data.ts
index c0fe49f..56214c8 100644
--- a/src/views/pay/order/order.data.ts
+++ b/src/views/pay/order/order.data.ts
@@ -1,4 +1,4 @@
-import { getMerchantListByName } from '@/api/pay/merchant'
+import { getAppList } from '@/api/pay/app'
 import type { DescItem } from '@/components/Description'
 import type { BasicColumn, FormSchema } from '@/components/Table'
 import { useRender } from '@/components/Table'
@@ -10,46 +10,6 @@ export const columns: BasicColumn[] = [
     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: 'merchantOrderId',
-        width: 100,
-      },
-      {
-        title: '支付',
-        dataIndex: 'channelOrderNo',
-        width: 200,
-      },
-    ],
-  },
-  {
-    title: '商品标题',
-    dataIndex: 'subject',
-    width: 200,
-  },
   {
     title: '支付金额(元)',
     dataIndex: 'amount',
@@ -74,6 +34,26 @@ export const columns: BasicColumn[] = [
       return `¥${Number.parseFloat(text || 0 / 100).toFixed(2)}`
     },
   },
+  {
+    title: '订单号',
+    children: [
+      {
+        title: '商户',
+        dataIndex: 'merchantOrderId',
+        width: 120,
+      },
+      {
+        title: '支付',
+        dataIndex: 'no',
+        width: 120,
+      },
+      {
+        title: '渠道',
+        dataIndex: 'channelOrderNo',
+        width: 160,
+      },
+    ],
+  },
   {
     title: '支付状态',
     dataIndex: 'status',
@@ -83,13 +63,23 @@ export const columns: BasicColumn[] = [
     },
   },
   {
-    title: '回调状态',
-    dataIndex: 'notifyStatus',
+    title: '支付渠道',
+    dataIndex: 'channelCode',
     width: 100,
     customRender: ({ text }) => {
-      return useRender.renderDict(text, DICT_TYPE.PAY_ORDER_NOTIFY_STATUS)
+      return useRender.renderDict(text, DICT_TYPE.PAY_CHANNEL_CODE)
     },
   },
+  {
+    title: '支付应用',
+    dataIndex: 'appName',
+    width: 100,
+  },
+  {
+    title: '商品标题',
+    dataIndex: 'subject',
+    width: 180,
+  },
   {
     title: '创建时间',
     dataIndex: 'createTime',
@@ -110,22 +100,18 @@ export const columns: BasicColumn[] = [
 
 export const searchFormSchema: FormSchema[] = [
   {
-    label: '所属商户',
-    field: 'merchantId',
+    label: '应用编号',
+    field: 'appId',
     component: 'ApiSelect',
     componentProps: {
-      api: () => getMerchantListByName(''),
+      api: () => getAppList(),
+      labelField: 'name',
+      valueField: 'id',
     },
     colProps: { span: 8 },
   },
   {
-    label: '应用编号',
-    field: 'appId',
-    component: 'Input',
-    colProps: { span: 8 },
-  },
-  {
-    label: '渠道编码',
+    label: '支付渠道',
     field: 'channelCode',
     component: 'Select',
     componentProps: {
@@ -134,13 +120,19 @@ export const searchFormSchema: FormSchema[] = [
     colProps: { span: 8 },
   },
   {
-    label: '商户订单编号',
+    label: '商户单号',
     field: 'merchantOrderId',
     component: 'Input',
     colProps: { span: 8 },
   },
   {
-    label: '渠道订单号',
+    label: '支付单号',
+    field: 'no',
+    component: 'Input',
+    colProps: { span: 8 },
+  },
+  {
+    label: '渠道单号',
     field: 'channelOrderNo',
     component: 'Input',
     colProps: { span: 8 },
@@ -154,24 +146,6 @@ export const searchFormSchema: FormSchema[] = [
     },
     colProps: { span: 8 },
   },
-  {
-    label: '退款状态',
-    field: 'refundStatus',
-    component: 'Select',
-    componentProps: {
-      options: getDictOptions(DICT_TYPE.PAY_ORDER_REFUND_STATUS),
-    },
-    colProps: { span: 8 },
-  },
-  {
-    label: '回调商户状态',
-    field: 'notifyStatus',
-    component: 'Select',
-    componentProps: {
-      options: getDictOptions(DICT_TYPE.PAY_ORDER_NOTIFY_STATUS),
-    },
-    colProps: { span: 8 },
-  },
   {
     label: '创建时间',
     field: 'createTime',
@@ -182,36 +156,29 @@ export const searchFormSchema: FormSchema[] = [
 
 export const descSchema: DescItem[] = [
   {
-    label: '商户名称',
-    field: 'merchantName',
-  },
-  {
-    label: '应用名称',
-    field: 'appName',
-  },
-  {
-    label: '商品名称',
-    field: 'subject',
+    label: '商户单号',
+    field: 'merchantOrderId',
   },
   {
-    label: '商户订单号',
-    field: 'merchantOrderId',
+    label: '支付单号',
+    field: 'no',
     render: (curVal) => {
       return useRender.renderTag(curVal)
     },
   },
   {
-    label: '渠道订单号',
-    field: 'channelOrderNo',
-    render: (curVal) => {
-      return useRender.renderTag(curVal)
-    },
+    label: '应用编号',
+    field: 'appId',
+  },
+  {
+    label: '应用名称',
+    field: 'appName',
   },
   {
-    label: '支付订单号',
-    field: 'payOrderExtension.no',
+    label: '支付状态',
+    field: 'status',
     render: (curVal) => {
-      return useRender.renderTag(curVal)
+      return useRender.renderDict(curVal, DICT_TYPE.PAY_ORDER_STATUS)
     },
   },
   {
@@ -236,23 +203,19 @@ export const descSchema: DescItem[] = [
     },
   },
   {
-    label: '支付状态',
-    field: 'status',
+    label: '支付时间',
+    field: 'successTime',
     render: (curVal) => {
-      return useRender.renderDict(curVal, DICT_TYPE.PAY_ORDER_STATUS)
+      return useRender.renderDate(curVal)
     },
   },
   {
-    label: '回调状态',
-    field: 'notifyStatus',
+    label: '失效时间',
+    field: 'expireTime',
     render: (curVal) => {
-      return useRender.renderDict(curVal, DICT_TYPE.PAY_ORDER_NOTIFY_STATUS)
+      return useRender.renderDate(curVal)
     },
   },
-  {
-    label: '回调地址',
-    field: 'notifyUrl',
-  },
   {
     label: '创建时间',
     field: 'createTime',
@@ -261,58 +224,55 @@ export const descSchema: DescItem[] = [
     },
   },
   {
-    label: '支付时间',
-    field: 'successTime',
+    label: '更新时间',
+    field: 'updateTime',
     render: (curVal) => {
       return useRender.renderDate(curVal)
     },
   },
   {
-    label: '失效时间',
-    field: 'expireTime',
-    render: (curVal) => {
-      return useRender.renderDate(curVal)
-    },
+    label: '商品标题',
+    field: 'subject',
   },
   {
-    label: '通知时间',
-    field: 'notifyTime',
-    render: (curVal) => {
-      return useRender.renderDate(curVal)
-    },
+    label: '商品描述',
+    field: 'body',
   },
   {
     label: '支付渠道',
-    field: 'channelCodeName',
+    field: 'channelCode',
+    render: (curVal) => {
+      return useRender.renderDict(curVal, DICT_TYPE.PAY_CHANNEL_CODE)
+    },
   },
   {
-    label: '支付IP',
+    label: '支付 IP',
     field: 'userIp',
   },
   {
-    label: '退款状态',
-    field: 'notifyStatus',
+    label: '渠道单号',
+    field: 'channelOrderNo',
     render: (curVal) => {
-      return useRender.renderDict(curVal, DICT_TYPE.PAY_ORDER_REFUND_STATUS)
+      return useRender.renderTag(curVal)
     },
   },
   {
-    label: '退款次数',
-    field: 'refundTimes',
+    label: '渠道用户',
+    field: 'channelUserId',
   },
   {
     label: '退款金额',
-    field: 'refundAmount',
+    field: 'refundPrice',
     render: (curVal) => {
-      return `¥${Number.parseFloat(curVal / 100).toFixed(2)}`
+      return `¥${Number.parseFloat(`${curVal / 100}`).toFixed(2)}`
     },
   },
   {
-    label: '商品描述',
-    field: 'body',
+    label: '通知 URL',
+    field: 'notifyUrl',
   },
   {
     label: '支付通道异步回调内容',
-    field: 'payOrderExtension.channelNotifyData',
+    field: 'extension.channelNotifyData',
   },
 ]