diff --git a/src/router/daxpay.ts b/src/router/daxpay.ts index e6df393..f0e075c 100644 --- a/src/router/daxpay.ts +++ b/src/router/daxpay.ts @@ -51,25 +51,25 @@ export const DaxPayRoute: RouteRecordRaw = { }, }, { - path: '/checkout/:code', + path: '/checkout/:orderNo', name: 'ChannelCashier', - component: () => import('@/views/daxpay/cashier/ChannelCheckout.vue'), + component: () => import('@/views/daxpay/checkout/CheckoutPay.vue'), meta: { title: '结算台', }, }, { - path: '/alipay/checkout/:appId/:orderId', + path: '/alipay/checkout/:appId/:orderNo', name: 'AlipayCashier', - component: () => import('@/views/daxpay/cashier/alipay/AlipayCheckout.vue'), + component: () => import('@/views/daxpay/checkout/alipay/AliAggregate.vue'), meta: { title: '支付宝结算台', }, }, { - path: '/wechat/checkout/:appId/:orderId', + path: '/wechat/checkout/:appId/:orderNo', name: 'WechatCheckout', - component: () => import('@/views/daxpay/cashier/wechat/WechatCheckout.vue'), + component: () => import('@/views/daxpay/checkout/wechat/WechatAggregate.vue'), meta: { title: '微信结算台', }, diff --git a/src/views/daxpay/cashier/CashierCode.vue b/src/views/daxpay/cashier/CashierCode.vue index 69e5846..19c033c 100644 --- a/src/views/daxpay/cashier/CashierCode.vue +++ b/src/views/daxpay/cashier/CashierCode.vue @@ -16,7 +16,7 @@ else if (ua.includes('Alipay')) { router.push({ path: `/cashier/alipay/${code}`, replace: true }) } else { - router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等支付程序进行扫码支付' }, replace: true }) + router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true }) } diff --git a/src/views/daxpay/checkout/CheckoutPay.api.ts b/src/views/daxpay/checkout/CheckoutPay.api.ts new file mode 100644 index 0000000..880347d --- /dev/null +++ b/src/views/daxpay/checkout/CheckoutPay.api.ts @@ -0,0 +1,187 @@ +import { http } from '@/utils/http/axios' +import type { Result } from '#/axios' +import {AuthResult} from "@/views/daxpay/auth/ChannelAuth.api"; + +/** + * 获取收银台订单和配置信息 + */ +export function getOrderAndConfig(orderNo, checkoutType){ + return http.request({ + url: '/unipay/checkout/getOrderAndConfig', + method: 'GET', + params: { + orderNo, + checkoutType + } + }) +} +/** + * 获取聚合支付配置 + */ +export function getAggregateConfig(orderNo, aggregateType){ + return http.request>({ + url: '/unipay/checkout/getAggregateConfig', + method: 'GET', + params: { + orderNo, + aggregateType + } + }) + +} +/** + * 获取收银台所需授权链接, 用于获取OpenId一类的信息 + */ +export function generateAuthUrl(param: CheckoutAuthUrlParam){ + return http.request>({ + url: '/unipay/checkout/generateAuthUrl', + method: 'post', + data: param + }) +} +/** + * 获取授权结果 + */ +export function auth(param: CheckoutAuthCodeParam){ + return http.request({ + url: '/unipay/checkout/auth', + method: 'post', + data: param + }) +} +/** + * 发起支付 + */ +export function pay(param: CheckoutPayParam){ + return http.request>({ + url: '/unipay/checkout/pay', + method: 'post', + data: param + }) +} + +/** + * 收银台认证链接生成参数 + */ +export interface CheckoutAuthUrlParam { + /** + * 要支付的订单号 + */ + orderNo?: string; + /** + * 聚合支付类型 + */ + aggregateType?: string; +} +/** + * 获取收银台认证结果参数 + */ +export interface CheckoutAuthCodeParam { + /** + * 要支付的订单号 + */ + orderNo?: string; + /** + * 聚合支付类型 + */ + aggregateType?: string; + /** + * 认证Code + */ + authCode?: string +} + +/** + * 收银台支付参数 + */ +export interface CheckoutPayParam{ + /** + * 订单号 + */ + orderNo?: string; + /** + * 支付配置项ID + */ + itemId?: string; + /** + * 唯一标识 + */ + openId?: string; + /** + * 付款码 + */ + barCode?: string; +} + +/** + * 收银台聚合支付配置 + */ +export interface AggregateOrderAndConfigResult{ + + /** + * 订单信息 + */ + order: CheckoutOrderResult; + /** + * 收银台配置信息 + */ + config: CheckoutConfigResult; + /** + * 收银台聚合配置信息 + */ + aggregateConfig: AggregateConfigResult; +} + +/** + * 订单信息 + */ +export interface CheckoutOrderResult{ + /** 商户订单号 */ + bizOrderNo?: string; + /** 订单号 */ + orderNo?: string; + /** 标题 */ + title?: string; + /** 描述 */ + description?: string; + /** 金额(元) */ + amount?: string; + +} +/** + * 收银台配置信息 + */ +export interface CheckoutConfigResult{ + /** 收银台名称 */ + name?: string; + /** PC收银台是否同时显示聚合收银码 */ + aggregateShow?: boolean; + /** h5收银台自动升级聚合支付 */ + h5AutoUpgrade?: boolean; +} +/** + * 收银台聚合配置信息 + */ +export interface AggregateConfigResult{ + /** 支付类型 */ + type?: string; + /** 通道 */ + channel?: string; + /** 支付方式 */ + payMethod?: string; + /** 自动拉起支付 */ + autoLaunch?: boolean; +} +/** + * 收银台支付结果 + */ +export interface CheckoutPayResult{ + /** + * 链接 + */ + url?: string; + /** + * 支付状态 + */ + payStatus?: string; +} diff --git a/src/views/daxpay/cashier/ChannelCheckout.vue b/src/views/daxpay/checkout/CheckoutPay.vue similarity index 58% rename from src/views/daxpay/cashier/ChannelCheckout.vue rename to src/views/daxpay/checkout/CheckoutPay.vue index 958e4b4..1241995 100644 --- a/src/views/daxpay/cashier/ChannelCheckout.vue +++ b/src/views/daxpay/checkout/CheckoutPay.vue @@ -6,17 +6,17 @@ import { useRoute } from 'vue-router' import router from '@/router' const route = useRoute() -const { appId, orderId } = route.params +const { code: orderNo } = route.params const ua = navigator.userAgent if (ua.includes('MicroMessenger')) { - router.push({ path: `/wechat/checkout/${appId}/${orderId}`, replace: true }) + router.push({ path: `/wechat/checkout/${orderNo}`, replace: true }) } else if (ua.includes('Alipay')) { - router.push({ path: `/alipay/checkout/${appId}/${orderId}`, replace: true }) + router.push({ path: `/alipay/checkout/${orderNo}`, replace: true }) } else { - router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等支付程序进行扫码支付' }, replace: true }) + router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true }) } diff --git a/src/views/daxpay/cashier/alipay/AlipayCheckout.vue b/src/views/daxpay/checkout/alipay/AliAggregate.vue similarity index 87% rename from src/views/daxpay/cashier/alipay/AlipayCheckout.vue rename to src/views/daxpay/checkout/alipay/AliAggregate.vue index f45a085..33640ae 100644 --- a/src/views/daxpay/cashier/alipay/AlipayCheckout.vue +++ b/src/views/daxpay/checkout/alipay/AliAggregate.vue @@ -31,9 +31,10 @@ import { import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum' import router from '@/router' +import {getAggregateConfig} from "@/views/daxpay/checkout/CheckoutPay.api"; const route = useRoute() -const { appId, orderId } = route.params +const { orderNo } = route.params const loading = ref(false) const cashierInfo = ref({}) @@ -49,11 +50,11 @@ onMounted(() => { * 初始化数据 */ function initData() { - // getCashierInfo(CashierTypeEnum.ALIPAY, appId as string).then(({ data }) => { - // cashierInfo.value = data - // }).catch((res) => { - // router.push({ name: 'ErrorResult', query: { msg: res.message } }) - // }) + getAggregateConfig(orderNo, wechat).then(({ data }) => { + cashierInfo.value = data + }).catch((res) => { + router.push({ name: 'ErrorResult', query: { msg: res.message } }) + }) } /** diff --git a/src/views/daxpay/cashier/wechat/WechatCheckout.vue b/src/views/daxpay/checkout/wechat/WechatAggregate.vue similarity index 100% rename from src/views/daxpay/cashier/wechat/WechatCheckout.vue rename to src/views/daxpay/checkout/wechat/WechatAggregate.vue