mirror of
https://gitee.com/bootx/dax-pay-ui
synced 2026-08-12 15:35:39 +08:00
refactor: 移除精细模式(advanced)及路由模拟面板
- PayRouteMode 类型改为 'basic' | 'scene' - 删除 modeDisplayName 中 advanced 分支 - 删除 PayRouteModeToolbar 中 advanced radio 按钮 - 删除 PayRouteConfig 中 simulate Tab 及相关引用 - 删除 PayRouteSimulatePanel.vue - 删除 payRoute.api.ts 中 simulate API 及对应接口类型 - 清理 i18n 中 advanced/simulate 相关条目
This commit is contained in:
@@ -3,7 +3,7 @@ import type { BaseEntity, Result } from '#/types/web';
|
||||
|
||||
import { defHttp } from '#/api/request';
|
||||
|
||||
// 通道路由 API(管理端):策略、基础/场景配置、试算及已启用目录;精细模式规则接口已移除,advanced 仅前端占位
|
||||
// 通道路由 API(管理端):策略、基础/场景配置及已启用目录
|
||||
export const PayRouteApi = {
|
||||
/** 已启用渠道+方式扁平目录(`PayProviderMethodService`,权限归属通道路由菜单) */
|
||||
listMethodDirectoryFlat(): Promise<Result<PayProviderMethod[]>> {
|
||||
@@ -76,9 +76,6 @@ export const PayRouteApi = {
|
||||
return defHttp.post({ url: '/admin/merchant/pay-route/basic-config/save-batch', data });
|
||||
},
|
||||
|
||||
simulate(data: PayRouteSimulateParam): Promise<Result<PayRouteResolveResult>> {
|
||||
return defHttp.post({ url: '/admin/merchant/pay-route/simulate', data });
|
||||
},
|
||||
};
|
||||
|
||||
export interface LabelValue {
|
||||
@@ -152,18 +149,6 @@ export interface PayRouteSceneCapabilityBatchItem {
|
||||
product: string;
|
||||
}
|
||||
|
||||
export interface PayRouteSimulateParam {
|
||||
appId: string;
|
||||
mchNo: string;
|
||||
/** 支付渠道(基础/场景模式模拟时必填) */
|
||||
provider?: string;
|
||||
/** 支付方式(场景模式试算时必填) */
|
||||
method?: string;
|
||||
amount?: number;
|
||||
/** 模拟使用的路由模式(不传则按策略生效模式) */
|
||||
mode?: string;
|
||||
}
|
||||
|
||||
/** 基础模式配置(含可选产品列表) */
|
||||
export interface PayRouteBasicConfigResult extends BaseEntity {
|
||||
provider?: string;
|
||||
@@ -181,12 +166,3 @@ export interface PayRouteBasicConfigBatchParam {
|
||||
appId: string;
|
||||
items: PayRouteBasicConfigItem[];
|
||||
}
|
||||
|
||||
export interface PayRouteResolveResult {
|
||||
channel?: string;
|
||||
method?: string;
|
||||
product?: string;
|
||||
hitRuleId?: string;
|
||||
hitConfigId?: string;
|
||||
mode?: string;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
"setActiveModeConfirm": "This app's payment channel routing will be set to \"{mode}\". New orders will resolve routes using this mode. Continue?",
|
||||
"alreadyActiveMode": "Already the active mode",
|
||||
"activeModeTag": "Active",
|
||||
"simulateUsesEditMode": "Trial resolve using configured mode \"{mode}\" (does not affect live payments)",
|
||||
"modeBasic": "Basic",
|
||||
"modeScene": "Scene",
|
||||
"modeAdvanced": "Advanced",
|
||||
"basicProduct": "Payment product",
|
||||
"payCapability": "Payment capability",
|
||||
"payCapabilityPlaceholder": "Select a capability",
|
||||
@@ -24,9 +22,7 @@
|
||||
"configTab": "Routing",
|
||||
"channel": "Channel",
|
||||
"method": "Pay Method",
|
||||
"simulate": "Simulate",
|
||||
"missingAppContext": "Open channel routing from App Management",
|
||||
"simulateProvider": "Payment provider",
|
||||
"providers": {
|
||||
"aggregate_pay": "Aggregate Pay",
|
||||
"wechat": "WeChat Pay",
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
"setActiveModeConfirm": "将把本应用的支付通道路由设为「{mode}」,之后下单按该模式解析。是否继续?",
|
||||
"alreadyActiveMode": "已是当前生效模式",
|
||||
"activeModeTag": "生效中",
|
||||
"simulateUsesEditMode": "按当前配置模式「{mode}」试算(不影响支付生效)",
|
||||
"modeBasic": "基础模式",
|
||||
"modeScene": "场景模式",
|
||||
"modeAdvanced": "精细模式",
|
||||
"basicProduct": "支付产品",
|
||||
"payCapability": "支付能力",
|
||||
"payCapabilityPlaceholder": "请选择支付能力",
|
||||
@@ -24,9 +22,7 @@
|
||||
"configTab": "路由配置",
|
||||
"channel": "支付通道",
|
||||
"method": "支付方式",
|
||||
"simulate": "模拟路由",
|
||||
"missingAppContext": "请从应用管理进入通道路由配置",
|
||||
"simulateProvider": "支付渠道",
|
||||
"providers": {
|
||||
"aggregate_pay": "聚合支付",
|
||||
"wechat": "微信支付",
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
import PayRouteModeToolbar from './components/PayRouteModeToolbar.vue';
|
||||
import PayRouteScenePanel from './scene/PayRouteScenePanel.vue';
|
||||
import { modeDisplayName, normalizePayRouteMode } from './shared/payRoute.labels';
|
||||
import PayRouteSimulatePanel from './simulate/PayRouteSimulatePanel.vue';
|
||||
|
||||
defineOptions({ name: 'PayRouteConfig' });
|
||||
|
||||
@@ -55,7 +54,6 @@
|
||||
|
||||
const basicPanelRef = ref<InstanceType<typeof PayRouteBasicPanel> | null>(null);
|
||||
const scenePanelRef = ref<InstanceType<typeof PayRouteScenePanel> | null>(null);
|
||||
const simulatePanelRef = ref<InstanceType<typeof PayRouteSimulatePanel> | null>(null);
|
||||
|
||||
// 策略库中当前生效的路由模式
|
||||
const effectiveMode = computed<PayRouteMode>(() => normalizePayRouteMode(strategy.value.mode));
|
||||
@@ -145,7 +143,6 @@
|
||||
await loadProductNameMap();
|
||||
await nextTick();
|
||||
await loadStrategy();
|
||||
simulatePanelRef.value?.syncContextIds();
|
||||
editMode.value = effectiveMode.value;
|
||||
});
|
||||
</script>
|
||||
@@ -200,10 +197,6 @@
|
||||
:product-name-map="productNameMap"
|
||||
/>
|
||||
</a-tab-pane>
|
||||
|
||||
<a-tab-pane key="simulate" :tab="$t('payment.merchant.route.route.simulate')">
|
||||
<PayRouteSimulatePanel ref="simulatePanelRef" :app-id="appId" :mch-no="mchNo" :edit-mode="editMode" />
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
applyActiveMode: [];
|
||||
}>();
|
||||
|
||||
// 当前编辑的配置模式(基础/场景可切换;精细模式仅展示)
|
||||
// 当前编辑的配置模式(基础/场景可切换)
|
||||
const editMode = defineModel<PayRouteMode>('editMode', { required: true });
|
||||
|
||||
const { hasPermission } = usePermission();
|
||||
@@ -46,15 +46,6 @@
|
||||
</a-tag>
|
||||
</span>
|
||||
</a-radio>
|
||||
<!-- 精细模式:功能未实现,固定 disabled,若历史数据为 advanced 仍显示「生效中」 -->
|
||||
<a-radio value="advanced" disabled>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
{{ $t('payment.merchant.route.route.modeAdvanced') }}
|
||||
<a-tag v-if="effectiveMode === 'advanced'" color="processing" class="!m-0 !text-xs">
|
||||
{{ $t('payment.merchant.route.route.activeModeTag') }}
|
||||
</a-tag>
|
||||
</span>
|
||||
</a-radio>
|
||||
</a-radio-group>
|
||||
<a-tooltip
|
||||
v-if="hasPermission(PermCodes.Payment.AppPayRoute.EDIT)"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// 通道路由配置模式(与后端 PayRouteModeEnum 对齐)
|
||||
export type PayRouteMode = 'advanced' | 'basic' | 'scene';
|
||||
|
||||
// advanced:精细模式预留,管理端仅展示 disabled,不可编辑与设为生效
|
||||
export type PayRouteMode = 'basic' | 'scene';
|
||||
|
||||
import { PAY_PROVIDER_DISPLAY } from '#/views/payment/shared/payProviderDisplay';
|
||||
|
||||
|
||||
@@ -14,16 +14,10 @@ export function modeDisplayName(mode: PayRouteMode) {
|
||||
if (mode === 'basic') {
|
||||
return $t('payment.merchant.route.route.modeBasic');
|
||||
}
|
||||
if (mode === 'advanced') {
|
||||
return $t('payment.merchant.route.route.modeAdvanced');
|
||||
}
|
||||
return $t('payment.merchant.route.route.modeScene');
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范化路由模式(兼容历史 simple → scene)
|
||||
* advanced 保留用于展示「生效中」标签,不可通过工具栏切换编辑
|
||||
*/
|
||||
/** 规范化路由模式(兼容历史 simple → scene) */
|
||||
export function normalizePayRouteMode(mode?: string): PayRouteMode {
|
||||
if (!mode || mode === 'simple') {
|
||||
return 'scene';
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { PayRouteApi, type PayRouteSimulateParam } from '#/api/payment/payRoute.api';
|
||||
|
||||
import { usePayProviderMethodDirectory } from '#/views/payment/shared/usePayProviderMethodDirectory';
|
||||
import { ROUTE_PAY_PROVIDERS, type PayRouteMode } from '../shared/payRoute.constants';
|
||||
import { modeDisplayName, providerLabel } from '../shared/payRoute.labels';
|
||||
|
||||
defineOptions({ name: 'PayRouteSimulatePanel' });
|
||||
|
||||
const props = defineProps<{
|
||||
appId: string;
|
||||
// 当前配置模式,作为试算 mode 传给后端(advanced 会返回暂未开放)
|
||||
editMode: PayRouteMode;
|
||||
mchNo: string;
|
||||
}>();
|
||||
|
||||
const { loadDirectory, methodsForProvider } = usePayProviderMethodDirectory();
|
||||
|
||||
const simulateParam = ref<PayRouteSimulateParam>({
|
||||
appId: '',
|
||||
mchNo: '',
|
||||
provider: 'wechat',
|
||||
method: 'wechat_jsapi',
|
||||
amount: 0.01,
|
||||
});
|
||||
const simulateResult = ref<string>('');
|
||||
|
||||
const methodOptions = computed(() => {
|
||||
if (!simulateParam.value.provider) {
|
||||
return [];
|
||||
}
|
||||
return methodsForProvider(simulateParam.value.provider).map((item) => ({
|
||||
label: item.methodLabel || item.method,
|
||||
value: item.method,
|
||||
}));
|
||||
});
|
||||
|
||||
function syncContextIds() {
|
||||
simulateParam.value.appId = props.appId;
|
||||
simulateParam.value.mchNo = props.mchNo;
|
||||
}
|
||||
|
||||
/** 按 editMode 试算路由解析结果(不写真实订单) */
|
||||
async function runSimulate() {
|
||||
syncContextIds();
|
||||
simulateParam.value.mode = props.editMode;
|
||||
const { data } = await PayRouteApi.simulate(simulateParam.value);
|
||||
simulateResult.value = JSON.stringify(data, null, 2);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => simulateParam.value.provider,
|
||||
async (provider) => {
|
||||
await loadDirectory();
|
||||
const methods = methodsForProvider(provider || '');
|
||||
if (methods.length && !methods.some((m) => m.method === simulateParam.value.method)) {
|
||||
simulateParam.value.method = methods[0]!.method;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [props.appId, props.mchNo] as const,
|
||||
async () => {
|
||||
syncContextIds();
|
||||
await loadDirectory();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
syncContextIds,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p class="mb-3 text-sm text-muted-foreground">
|
||||
{{
|
||||
$t('payment.merchant.route.route.simulateUsesEditMode', {
|
||||
mode: modeDisplayName(editMode),
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
<div class="mb-4 flex flex-wrap gap-4">
|
||||
<a-select
|
||||
v-if="editMode === 'basic' || editMode === 'scene'"
|
||||
v-model:value="simulateParam.provider"
|
||||
class="w-40"
|
||||
allow-clear
|
||||
:placeholder="$t('payment.merchant.route.route.simulateProvider')"
|
||||
:options="ROUTE_PAY_PROVIDERS.map((v) => ({ label: providerLabel(v.code), value: v.code }))"
|
||||
/>
|
||||
<a-select
|
||||
v-if="editMode === 'scene'"
|
||||
v-model:value="simulateParam.method"
|
||||
class="w-48"
|
||||
allow-clear
|
||||
:placeholder="$t('payment.merchant.route.route.method')"
|
||||
:options="methodOptions"
|
||||
/>
|
||||
<a-input-number v-model:value="simulateParam.amount" :min="0.01" class="w-32" />
|
||||
<a-button type="primary" @click="runSimulate">
|
||||
{{ $t('payment.merchant.route.route.simulate') }}
|
||||
</a-button>
|
||||
</div>
|
||||
<pre v-if="simulateResult" class="rounded bg-muted p-4 text-sm">{{ simulateResult }}</pre>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user