From 044be6bd115a2a0e702361935655fa733b3be41d Mon Sep 17 00:00:00 2001 From: xingyu Date: Fri, 8 Sep 2023 14:20:07 +0800 Subject: [PATCH] feat: pay --- src/api/pay/app/index.ts | 10 -- src/api/pay/channel/index.ts | 6 +- src/api/pay/merchant/index.ts | 77 ---------- src/api/pay/order/index.ts | 25 +--- src/router/routes/index.ts | 6 +- src/views/pay/cashier/cashier.data.ts | 113 +++++++++++++++ src/views/pay/{submit => cashier}/index.vue | 2 +- src/views/pay/merchant/MerchantModal.vue | 58 -------- src/views/pay/merchant/index.vue | 94 ------------ src/views/pay/merchant/merchant.data.ts | 151 -------------------- src/views/pay/submit/submit.data.ts | 38 ----- 11 files changed, 125 insertions(+), 455 deletions(-) delete mode 100644 src/api/pay/merchant/index.ts create mode 100644 src/views/pay/cashier/cashier.data.ts rename src/views/pay/{submit => cashier}/index.vue (98%) delete mode 100644 src/views/pay/merchant/MerchantModal.vue delete mode 100644 src/views/pay/merchant/index.vue delete mode 100644 src/views/pay/merchant/merchant.data.ts delete mode 100644 src/views/pay/submit/submit.data.ts diff --git a/src/api/pay/app/index.ts b/src/api/pay/app/index.ts index 322fb21..dcad227 100644 --- a/src/api/pay/app/index.ts +++ b/src/api/pay/app/index.ts @@ -67,16 +67,6 @@ export function deleteApp(id: number) { return defHttp.delete({ url: `/pay/app/delete?id=${id}` }) } -// 导出支付应用 -export function exportApp(params: AppExportReqVO) { - return defHttp.download({ url: '/pay/app/export-excel', params }, '支付应用.xls') -} - -// 根据商ID称搜索应用列表 -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' }) diff --git a/src/api/pay/channel/index.ts b/src/api/pay/channel/index.ts index 56eb733..9a1f079 100644 --- a/src/api/pay/channel/index.ts +++ b/src/api/pay/channel/index.ts @@ -35,7 +35,7 @@ export interface ChannelExportReqVO { } // 查询列表支付渠道 -export function getChannelPage(params: ChannelPageReqVO) { +export function getChannelPage(params: PageParam) { return defHttp.get({ url: '/pay/channel/page', params }) } @@ -45,7 +45,7 @@ export function getChannel(appId: string, code: string) { appId, code, } - return defHttp.get({ url: '/pay/channel/get-channel', params }) + return defHttp.get({ url: '/pay/channel/get', params }) } // 新增支付渠道 @@ -64,6 +64,6 @@ export function deleteChannel(id: number) { } // 导出支付渠道 -export function exportChannel(params: ChannelExportReqVO) { +export function exportChannel(params) { return defHttp.download({ url: '/pay/channel/export-excel', params }, '支付渠道.xls') } diff --git a/src/api/pay/merchant/index.ts b/src/api/pay/merchant/index.ts deleted file mode 100644 index 8244587..0000000 --- a/src/api/pay/merchant/index.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { defHttp } from '@/utils/http/axios' - -export interface MerchantVO { - id: number - no: string - name: string - shortName: string - status: number - remark: string - createTime: Date -} - -export interface MerchantPageReqVO extends PageParam { - no?: string - name?: string - shortName?: string - status?: number - remark?: string - createTime?: Date[] -} - -export interface MerchantExportReqVO { - no?: string - name?: string - shortName?: string - status?: number - remark?: string - createTime?: Date[] -} - -// 查询列表支付商户 -export function getMerchantPage(params: MerchantPageReqVO) { - return defHttp.get({ url: '/pay/merchant/page', params }) -} - -// 查询详情支付商户 -export function getMerchant(id: number) { - return defHttp.get({ url: `/pay/merchant/get?id=${id}` }) -} - -// 根据商户名称搜索商户列表 -export function getMerchantListByName(name: string) { - return defHttp.get({ - url: '/pay/merchant/list-by-name?id=', - params: { - name, - }, - }) -} - -// 新增支付商户 -export function createMerchant(data: MerchantVO) { - return defHttp.post({ url: '/pay/merchant/create', data }) -} - -// 修改支付商户 -export function updateMerchant(data: MerchantVO) { - return defHttp.put({ url: '/pay/merchant/update', data }) -} - -// 删除支付商户 -export function deleteMerchant(id: number) { - return defHttp.delete({ url: `/pay/merchant/delete?id=${id}` }) -} - -// 导出支付商户 -export function exportMerchant(params: MerchantExportReqVO) { - return defHttp.download({ url: '/pay/merchant/export-excel', params }, '支付商户.xls') -} -// 支付商户状态修改 -export function changeMerchantStatus(id: number, status: number) { - const data = { - id, - status, - } - return defHttp.put({ url: '/pay/merchant/update-status', data }) -} diff --git a/src/api/pay/order/index.ts b/src/api/pay/order/index.ts index f136a2b..ea6a969 100644 --- a/src/api/pay/order/index.ts +++ b/src/api/pay/order/index.ts @@ -88,32 +88,17 @@ export function getOrder(id: number) { return defHttp.get({ url: `/pay/order/get?id=${id}` }) } -// 查询详情支付订单 +// 获得支付订单的明细 export function getOrderDetail(id: number) { return defHttp.get({ url: `/pay/order/get-detail?id=${id}` }) } -// 新增支付订单 -export function createOrder(data: OrderVO) { - return defHttp.post({ url: '/pay/order/create', data }) -} - -// 修改支付订单 -export function updateOrder(data: OrderVO) { - return defHttp.put({ url: '/pay/order/update', data }) -} - -// 删除支付订单 -export function deleteOrder(id: number) { - return defHttp.delete({ url: `/pay/order/delete?id=${id}` }) +// 提交支付订单 +export function submitOrder(data: any) { + return defHttp.post({ url: '/pay/order/submit', data }) } // 导出支付订单 export function exportOrder(params: OrderExportReqVO) { - return defHttp.download({ url: '/pay/order/export-excel', params }, '支付订单.xls') -} - -// 提交支付订单 -export function submitOrder(data) { - return defHttp.post({ url: '/pay/order/submit', data }) + return defHttp.download({ url: '/pay/order/export-excel', params }) } diff --git a/src/router/routes/index.ts b/src/router/routes/index.ts index 80faf23..2575fab 100644 --- a/src/router/routes/index.ts +++ b/src/router/routes/index.ts @@ -143,9 +143,9 @@ export const PayRoute: AppRouteRecordRaw = { }, children: [ { - path: 'submit', - component: () => import('@/views/pay/submit/index.vue'), - name: 'PayOrderSubmit', + path: 'cashier', + component: () => import('@/views/pay/cashier/index.vue'), + name: 'PayCashier', meta: { canTo: true, hidden: true, diff --git a/src/views/pay/cashier/cashier.data.ts b/src/views/pay/cashier/cashier.data.ts new file mode 100644 index 0000000..30d590b --- /dev/null +++ b/src/views/pay/cashier/cashier.data.ts @@ -0,0 +1,113 @@ +import type { DescItem } from '@/components/Description' +import { useRender } from '@/components/Table' + +// 导入图标 +import svg_alipay_pc from '@/assets/svgs/pay/icon/alipay_pc.svg' +import svg_alipay_wap from '@/assets/svgs/pay/icon/alipay_wap.svg' +import svg_alipay_app from '@/assets/svgs/pay/icon/alipay_app.svg' +import svg_alipay_qr from '@/assets/svgs/pay/icon/alipay_qr.svg' +import svg_alipay_bar from '@/assets/svgs/pay/icon/alipay_bar.svg' +import svg_wx_pub from '@/assets/svgs/pay/icon/wx_pub.svg' +import svg_wx_lite from '@/assets/svgs/pay/icon/wx_lite.svg' +import svg_wx_app from '@/assets/svgs/pay/icon/wx_app.svg' +import svg_wx_native from '@/assets/svgs/pay/icon/wx_native.svg' +import svg_wx_bar from '@/assets/svgs/pay/icon/wx_bar.svg' +import svg_mock from '@/assets/svgs/pay/icon/mock.svg' + +export const descSchema: DescItem[] = [ + { + label: '支付单号', + field: 'id', + }, + { + label: '商品标题', + field: 'subject', + }, + { + label: '商品内容', + field: 'body', + }, + { + label: '支付金额', + field: 'amount', + render: (curVal) => { + return useRender.renderText('¥', Number.parseFloat(curVal || 0 / 100).toFixed(2)) + }, + }, + { + label: '创建时间', + field: 'createTime', + render: (curVal) => { + return useRender.renderDate(curVal) + }, + }, + { + label: '过期时间', + field: 'expireTime', + render: (curVal) => { + return useRender.renderDate(curVal) + }, + }, +] + +export const channelsAlipay = [ + { + name: '支付宝 PC 网站支付', + icon: svg_alipay_pc, + code: 'alipay_pc', + }, + { + name: '支付宝 Wap 网站支付', + icon: svg_alipay_wap, + code: 'alipay_wap', + }, + { + name: '支付宝 App 网站支付', + icon: svg_alipay_app, + code: 'alipay_app', + }, + { + name: '支付宝扫码支付', + icon: svg_alipay_qr, + code: 'alipay_qr', + }, + { + name: '支付宝条码支付', + icon: svg_alipay_bar, + code: 'alipay_bar', + }, +] +export const channelsWechat = [ + { + name: '微信公众号支付', + icon: svg_wx_pub, + code: 'wx_pub', + }, + { + name: '微信小程序支付', + icon: svg_wx_lite, + code: 'wx_lite', + }, + { + name: '微信 App 支付', + icon: svg_wx_app, + code: 'wx_app', + }, + { + name: '微信扫码支付', + icon: svg_wx_native, + code: 'wx_native', + }, + { + name: '微信条码支付', + icon: svg_wx_bar, + code: 'wx_bar', + }, +] +export const channelsMock = [ + { + name: '模拟支付', + icon: svg_mock, + code: 'mock', + }, +] diff --git a/src/views/pay/submit/index.vue b/src/views/pay/cashier/index.vue similarity index 98% rename from src/views/pay/submit/index.vue rename to src/views/pay/cashier/index.vue index 2413fcc..02c7e7a 100644 --- a/src/views/pay/submit/index.vue +++ b/src/views/pay/cashier/index.vue @@ -16,7 +16,7 @@ import wx_lite from '@/assets/images/pay/icon/wx_lite.svg' import wx_pub from '@/assets/images/pay/icon/wx_pub.svg' import mock from '@/assets/images/pay/icon/mock.svg' -defineOptions({ name: 'PayOrderSubmit' }) +defineOptions({ name: 'PayCashier' }) const ListItem = List.Item diff --git a/src/views/pay/merchant/MerchantModal.vue b/src/views/pay/merchant/MerchantModal.vue deleted file mode 100644 index a428a76..0000000 --- a/src/views/pay/merchant/MerchantModal.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - diff --git a/src/views/pay/merchant/index.vue b/src/views/pay/merchant/index.vue deleted file mode 100644 index d1c3f19..0000000 --- a/src/views/pay/merchant/index.vue +++ /dev/null @@ -1,94 +0,0 @@ - - - diff --git a/src/views/pay/merchant/merchant.data.ts b/src/views/pay/merchant/merchant.data.ts deleted file mode 100644 index 752f042..0000000 --- a/src/views/pay/merchant/merchant.data.ts +++ /dev/null @@ -1,151 +0,0 @@ -import { Switch } from 'ant-design-vue' -import { h } from 'vue' -import { changeMerchantStatus } from '@/api/pay/merchant' -import type { BasicColumn, FormSchema } from '@/components/Table' -import { useRender } from '@/components/Table' -import { useMessage } from '@/hooks/web/useMessage' -import { DICT_TYPE, getDictOptions } from '@/utils/dict' - -export const columns: BasicColumn[] = [ - { - title: '商户编号', - dataIndex: 'id', - width: 100, - }, - { - title: '商户号', - dataIndex: 'no', - width: 180, - }, - { - title: '商户全称', - dataIndex: 'name', - width: 100, - }, - { - title: '商户简称', - dataIndex: 'shortName', - width: 120, - }, - { - title: '开启状态', - dataIndex: 'status', - width: 180, - customRender: ({ record }) => { - if (!Reflect.has(record, 'pendingStatus')) - record.pendingStatus = false - - return h(Switch, { - checked: record.status === 0, - checkedChildren: '已启用', - unCheckedChildren: '已禁用', - loading: record.pendingStatus, - onChange(checked: boolean) { - record.pendingStatus = true - const newStatus = checked ? 0 : 1 - const { createMessage } = useMessage() - changeMerchantStatus(record.id, newStatus) - .then(() => { - record.status = newStatus - createMessage.success('已成功修改商户状态') - }) - .catch(() => { - createMessage.error('修改商户状态失败') - }) - .finally(() => { - record.pendingStatus = false - }) - }, - }) - }, - }, - { - title: '备注', - dataIndex: 'remark', - width: 180, - }, - { - title: '创建时间', - dataIndex: 'createTime', - width: 180, - customRender: ({ text }) => { - return useRender.renderDate(text) - }, - }, -] - -export const searchFormSchema: FormSchema[] = [ - { - label: '商户号', - field: 'no', - component: 'Input', - colProps: { span: 8 }, - }, - { - label: '商户全称', - field: 'name', - component: 'Input', - colProps: { span: 8 }, - }, - { - label: '商户简称', - field: 'shortName', - component: 'Input', - colProps: { span: 8 }, - }, - { - label: '状态', - field: 'status', - component: 'Select', - componentProps: { - options: getDictOptions(DICT_TYPE.COMMON_STATUS), - }, - colProps: { span: 8 }, - }, - { - label: '备注', - field: 'remark', - component: 'Input', - colProps: { span: 8 }, - }, - { - label: '创建时间', - field: 'createTime', - component: 'RangePicker', - colProps: { span: 8 }, - }, -] - -export const formSchema: FormSchema[] = [ - { - label: '编号', - field: 'id', - show: false, - component: 'Input', - }, - { - label: '商户全称', - field: 'name', - required: true, - component: 'Input', - }, - { - label: '商户简称', - field: 'shortName', - required: true, - component: 'Input', - }, - { - label: '开启状态', - field: 'status', - component: 'Select', - componentProps: { - options: getDictOptions(DICT_TYPE.COMMON_STATUS), - }, - }, - { - label: '备注', - field: 'remark', - component: 'InputTextArea', - }, -] diff --git a/src/views/pay/submit/submit.data.ts b/src/views/pay/submit/submit.data.ts deleted file mode 100644 index d985edf..0000000 --- a/src/views/pay/submit/submit.data.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { DescItem } from '@/components/Description' -import { useRender } from '@/components/Table' - -export const descSchema: DescItem[] = [ - { - label: '支付单号', - field: 'id', - }, - { - label: '商品标题', - field: 'subject', - }, - { - label: '商品内容', - field: 'body', - }, - { - label: '支付金额', - field: 'amount', - render: (curVal) => { - return useRender.renderText('¥', Number.parseFloat(curVal || 0 / 100).toFixed(2)) - }, - }, - { - label: '创建时间', - field: 'createTime', - render: (curVal) => { - return useRender.renderDate(curVal) - }, - }, - { - label: '过期时间', - field: 'expireTime', - render: (curVal) => { - return useRender.renderDate(curVal) - }, - }, -]