fix: 支付页去掉货币列,包年/永久货币由后端自动带
Product 映射只保留计划与 PROD_xxx;包年默认 CNY、永久默认 USD,避免误填干扰。
This commit is contained in:
1 parent
7c146cb639
commit
d94da2129c
2 files changed
+19
-42
No files matched your search
@@ -453,15 +453,17 @@ func productIDForPlan(cfg WaffoConfig, planType string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func currencyForPlan(cfg WaffoConfig, planType string) string {
|
func currencyForPlan(cfg WaffoConfig, planType string) string {
|
||||||
switch strings.TrimSpace(planType) {
|
switch strings.TrimSpace(strings.ToLower(planType)) {
|
||||||
case "yearly", "monthly":
|
case "yearly", "monthly":
|
||||||
if cfg.CurrencyYearly != "" {
|
if cfg.CurrencyYearly != "" {
|
||||||
return cfg.CurrencyYearly
|
return cfg.CurrencyYearly
|
||||||
}
|
}
|
||||||
|
return "CNY" // OpsXshell 包年默认人民币 // Logan.Li
|
||||||
case "perpetual", "lifetime":
|
case "perpetual", "lifetime":
|
||||||
if cfg.CurrencyPerpetual != "" {
|
if cfg.CurrencyPerpetual != "" {
|
||||||
return cfg.CurrencyPerpetual
|
return cfg.CurrencyPerpetual
|
||||||
}
|
}
|
||||||
|
return "USD" // OpsXshell 永久默认美元 // Logan.Li
|
||||||
}
|
}
|
||||||
if cfg.Currency != "" {
|
if cfg.Currency != "" {
|
||||||
return cfg.Currency
|
return cfg.Currency
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
type="info"
|
type="info"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
show-icon
|
show-icon
|
||||||
title="测试 / 生产的私钥与 Product 映射相互隔离。改映射后需点「保存」;调试不会自动写库。生产 create-session 需 Waffo 门店已 Go-Live。"
|
title="改映射后需点「保存」。调试只探测不写库。生产 create-session 需 Waffo 门店已 Go-Live。"
|
||||||
style="margin-bottom: 16px"
|
style="margin-bottom: 16px"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
{{ isLive ? 'live' : 'test' }}
|
{{ isLive ? 'live' : 'test' }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<div class="hint">切换前会暂存当前映射到对应环境;未配置私钥的环境需单独粘贴保存。</div>
|
<div class="hint">测试 / 生产私钥与 Product 映射隔离;未配私钥的环境需单独粘贴保存。</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商户 ID">
|
<el-form-item label="商户 ID">
|
||||||
<el-input v-model="waffo.merchant_id" placeholder="MER_…" />
|
<el-input v-model="waffo.merchant_id" placeholder="MER_…" />
|
||||||
@@ -76,10 +76,6 @@
|
|||||||
style="margin-top: 8px"
|
style="margin-top: 8px"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="默认货币">
|
|
||||||
<el-input v-model="waffo.currency" style="width: 120px" placeholder="CNY" />
|
|
||||||
<div class="hint">映射表可按计划覆盖(包年 CNY / 永久 USD)</div>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="SUCCESS_URL">
|
<el-form-item label="SUCCESS_URL">
|
||||||
<el-input v-model="waffo.success_url" placeholder="支付成功回跳" />
|
<el-input v-model="waffo.success_url" placeholder="支付成功回跳" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -111,7 +107,7 @@
|
|||||||
type="warning"
|
type="warning"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
show-icon
|
show-icon
|
||||||
title="调试按钮不会写库。改完映射请点右上角「保存配置」。生产与测试可点「填充 OpsXshell 商品」一键写入包年/永久 Product ID。"
|
title="下单时按计划选用对应 PROD_xxx:包年→yearly,永久→perpetual。货币由后端按计划自动带(包年 CNY / 永久 USD),无需手填。"
|
||||||
style="margin-bottom: 12px"
|
style="margin-bottom: 12px"
|
||||||
/>
|
/>
|
||||||
<el-table :data="productMappings" border stripe>
|
<el-table :data="productMappings" border stripe>
|
||||||
@@ -129,24 +125,16 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="说明" min-width="120">
|
<el-table-column label="说明" min-width="140">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-input v-model="row.label" placeholder="可选" />
|
<el-input v-model="row.label" placeholder="可选" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="Waffo Product ID" min-width="240">
|
<el-table-column label="Waffo Product ID" min-width="280">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-input v-model="row.product_id" placeholder="PROD_…" />
|
<el-input v-model="row.product_id" placeholder="PROD_…" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="货币" width="110">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-select v-model="row.currency" allow-create filterable placeholder="CNY" style="width: 100%">
|
|
||||||
<el-option label="CNY" value="CNY" />
|
|
||||||
<el-option label="USD" value="USD" />
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="90" fixed="right">
|
<el-table-column label="操作" width="90" fixed="right">
|
||||||
<template #default="{ $index }">
|
<template #default="{ $index }">
|
||||||
<el-button size="small" type="danger" link @click="removeMapping($index)">删除</el-button>
|
<el-button size="small" type="danger" link @click="removeMapping($index)">删除</el-button>
|
||||||
@@ -169,19 +157,17 @@ import { getWaffoSettings, updateWaffoSettings, testWaffoConnection } from '@/ap
|
|||||||
|
|
||||||
const planKeyOptions = ['trial', 'yearly', 'perpetual', 'monthly', 'lifetime']
|
const planKeyOptions = ['trial', 'yearly', 'perpetual', 'monthly', 'lifetime']
|
||||||
|
|
||||||
// OpsXshell 线上商品(pancake 购买链接对应) // Logan.Li
|
// OpsXshell 线上商品(与 pancake 购买链接一致) // Logan.Li
|
||||||
const OPSXSHELL_PRODUCTS = [
|
const OPSXSHELL_PRODUCTS = [
|
||||||
{
|
{
|
||||||
plan_key: 'yearly',
|
plan_key: 'yearly',
|
||||||
label: 'OpsXshell Yearly',
|
label: 'OpsXshell Yearly',
|
||||||
product_id: 'PROD_5PqVJyEiCM4nDgVoA0RKjN',
|
product_id: 'PROD_5PqVJyEiCM4nDgVoA0RKjN',
|
||||||
currency: 'CNY',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
plan_key: 'perpetual',
|
plan_key: 'perpetual',
|
||||||
label: 'OpsXshell Perpetual',
|
label: 'OpsXshell Perpetual',
|
||||||
product_id: 'PROD_3BSJqDRkVBoYNgO78NsTAU',
|
product_id: 'PROD_3BSJqDRkVBoYNgO78NsTAU',
|
||||||
currency: 'USD',
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -217,8 +203,8 @@ const isLive = computed(() => waffo.environment === 'live')
|
|||||||
|
|
||||||
function defaultMappings() {
|
function defaultMappings() {
|
||||||
return [
|
return [
|
||||||
{ plan_key: 'yearly', label: '包年', product_id: '', currency: 'CNY' },
|
{ plan_key: 'yearly', label: '包年', product_id: '' },
|
||||||
{ plan_key: 'perpetual', label: '永久', product_id: '', currency: 'USD' },
|
{ plan_key: 'perpetual', label: '永久', product_id: '' },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,30 +214,24 @@ function normalizeMappings(data = {}) {
|
|||||||
plan_key: m.plan_key || m.key || m.plan_type || '',
|
plan_key: m.plan_key || m.key || m.plan_type || '',
|
||||||
label: m.label || '',
|
label: m.label || '',
|
||||||
product_id: m.product_id || '',
|
product_id: m.product_id || '',
|
||||||
currency: (m.currency || '').toUpperCase() || guessCurrency(m.plan_key),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
const rows = []
|
const rows = []
|
||||||
if (data.product_id_yearly) {
|
if (data.product_id_yearly) {
|
||||||
rows.push({
|
rows.push({ plan_key: 'yearly', label: '包年', product_id: data.product_id_yearly })
|
||||||
plan_key: 'yearly',
|
|
||||||
label: '包年',
|
|
||||||
product_id: data.product_id_yearly,
|
|
||||||
currency: 'CNY',
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
if (data.product_id_perpetual || data.product_id) {
|
if (data.product_id_perpetual || data.product_id) {
|
||||||
rows.push({
|
rows.push({
|
||||||
plan_key: 'perpetual',
|
plan_key: 'perpetual',
|
||||||
label: '永久',
|
label: '永久',
|
||||||
product_id: data.product_id_perpetual || data.product_id,
|
product_id: data.product_id_perpetual || data.product_id,
|
||||||
currency: 'USD',
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return rows.length ? rows : defaultMappings()
|
return rows.length ? rows : defaultMappings()
|
||||||
}
|
}
|
||||||
|
|
||||||
function guessCurrency(planKey) {
|
// 按计划自动带货币,不再展示币种列 // Logan.Li
|
||||||
|
function currencyForKey(planKey) {
|
||||||
const k = (planKey || '').toLowerCase()
|
const k = (planKey || '').toLowerCase()
|
||||||
if (k === 'perpetual' || k === 'lifetime') return 'USD'
|
if (k === 'perpetual' || k === 'lifetime') return 'USD'
|
||||||
return 'CNY'
|
return 'CNY'
|
||||||
@@ -259,12 +239,10 @@ function guessCurrency(planKey) {
|
|||||||
|
|
||||||
function mappingsToCompatFields(rows) {
|
function mappingsToCompatFields(rows) {
|
||||||
const map = {}
|
const map = {}
|
||||||
const currencyMap = {}
|
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const key = (row.plan_key || '').trim()
|
const key = (row.plan_key || '').trim()
|
||||||
if (!key) continue
|
if (!key) continue
|
||||||
map[key] = (row.product_id || '').trim()
|
map[key] = (row.product_id || '').trim()
|
||||||
currencyMap[key] = (row.currency || '').trim().toUpperCase()
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
product_mappings: rows
|
product_mappings: rows
|
||||||
@@ -273,13 +251,13 @@ function mappingsToCompatFields(rows) {
|
|||||||
plan_key: r.plan_key.trim(),
|
plan_key: r.plan_key.trim(),
|
||||||
label: r.label || '',
|
label: r.label || '',
|
||||||
product_id: (r.product_id || '').trim(),
|
product_id: (r.product_id || '').trim(),
|
||||||
currency: (r.currency || '').trim().toUpperCase(),
|
currency: currencyForKey(r.plan_key),
|
||||||
})),
|
})),
|
||||||
product_id_yearly: map.yearly || '',
|
product_id_yearly: map.yearly || '',
|
||||||
product_id_perpetual: map.perpetual || map.lifetime || '',
|
product_id_perpetual: map.perpetual || map.lifetime || '',
|
||||||
product_id: map.perpetual || map.lifetime || map.yearly || '',
|
product_id: map.perpetual || map.lifetime || map.yearly || '',
|
||||||
currency_yearly: currencyMap.yearly || '',
|
currency_yearly: 'CNY',
|
||||||
currency_perpetual: currencyMap.perpetual || currencyMap.lifetime || '',
|
currency_perpetual: 'USD',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,14 +285,13 @@ function onEnvSwitch(live) {
|
|||||||
const next = live ? 'live' : 'test'
|
const next = live ? 'live' : 'test'
|
||||||
const prev = waffo.environment === 'live' ? 'live' : 'test'
|
const prev = waffo.environment === 'live' ? 'live' : 'test'
|
||||||
if (next === prev) return
|
if (next === prev) return
|
||||||
// 必须先把当前表写入「切换前」环境,再加载目标环境(勿用会提前改 environment 的 v-model) // Logan.Li
|
|
||||||
stashEnv(prev)
|
stashEnv(prev)
|
||||||
applyEnv(next)
|
applyEnv(next)
|
||||||
ElMessage.info(live ? '已切换到生产映射(记得保存)' : '已切换到测试映射(记得保存)')
|
ElMessage.info(live ? '已切换到生产映射(记得保存)' : '已切换到测试映射(记得保存)')
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMapping() {
|
function addMapping() {
|
||||||
productMappings.value.push({ plan_key: '', label: '', product_id: '', currency: 'CNY' })
|
productMappings.value.push({ plan_key: '', label: '', product_id: '' })
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeMapping(index) {
|
function removeMapping(index) {
|
||||||
@@ -328,12 +305,10 @@ function fillOpsxshellProducts() {
|
|||||||
if (byKey[item.plan_key]) {
|
if (byKey[item.plan_key]) {
|
||||||
byKey[item.plan_key].product_id = item.product_id
|
byKey[item.plan_key].product_id = item.product_id
|
||||||
byKey[item.plan_key].label = item.label
|
byKey[item.plan_key].label = item.label
|
||||||
byKey[item.plan_key].currency = item.currency
|
|
||||||
} else {
|
} else {
|
||||||
productMappings.value.push({ ...item })
|
productMappings.value.push({ ...item })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 保证 yearly / perpetual 在前 // Logan.Li
|
|
||||||
const order = ['yearly', 'perpetual']
|
const order = ['yearly', 'perpetual']
|
||||||
productMappings.value.sort((a, b) => {
|
productMappings.value.sort((a, b) => {
|
||||||
const ia = order.indexOf(a.plan_key)
|
const ia = order.indexOf(a.plan_key)
|
||||||
@@ -397,7 +372,7 @@ async function save() {
|
|||||||
store_id: waffo.store_id,
|
store_id: waffo.store_id,
|
||||||
store_slug: waffo.store_slug,
|
store_slug: waffo.store_slug,
|
||||||
environment: waffo.environment,
|
environment: waffo.environment,
|
||||||
currency: waffo.currency,
|
currency: waffo.currency || 'CNY',
|
||||||
success_url: waffo.success_url,
|
success_url: waffo.success_url,
|
||||||
clear_private_key: clearKeyFlag.value,
|
clear_private_key: clearKeyFlag.value,
|
||||||
...compat,
|
...compat,
|
||||||
|
|||||||
Reference in new issue
Block a user