fix: 测试包年商品改用 USD,避免 CNY 不被支持
Waffo 测试侧 Yearly Product 仅支持 USD;按 Product ID 自动选币种。
This commit is contained in:
1 parent
2b44e8dcb3
commit
37d9e8ca56
3 files changed
+51
-23
No files matched your search
@@ -107,7 +107,7 @@
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
title="下单时按计划选用对应 PROD_xxx:包年→yearly,永久→perpetual。货币由后端按计划自动带(包年 CNY / 永久 USD),无需手填。"
|
||||
title="下单时按计划选用对应 PROD_xxx。币种按商品自动选择(测试包年 USD;生产包年 CNY;永久 USD)。"
|
||||
style="margin-bottom: 12px"
|
||||
/>
|
||||
<el-table :data="productMappings" border stripe>
|
||||
@@ -157,16 +157,24 @@ import { getWaffoSettings, updateWaffoSettings, testWaffoConnection } from '@/ap
|
||||
|
||||
const planKeyOptions = ['trial', 'yearly', 'perpetual', 'monthly', 'lifetime']
|
||||
|
||||
// OpsXshell 商品:测试 / 生产各一套 // Logan.Li
|
||||
// OpsXshell 商品:测试 / 生产各一套(币种跟 Waffo 商品实际支持走) // Logan.Li
|
||||
const OPSXSHELL_PRODUCTS_LIVE = [
|
||||
{ plan_key: 'yearly', label: 'OpsXshell Yearly', product_id: 'PROD_5PqVJyEiCM4nDgVoA0RKjN' },
|
||||
{ plan_key: 'perpetual', label: 'OpsXshell Perpetual', product_id: 'PROD_3BSJqDRkVBoYNgO78NsTAU' },
|
||||
{ plan_key: 'yearly', label: 'OpsXshell Yearly', product_id: 'PROD_5PqVJyEiCM4nDgVoA0RKjN', currency: 'CNY' },
|
||||
{ plan_key: 'perpetual', label: 'OpsXshell Perpetual', product_id: 'PROD_3BSJqDRkVBoYNgO78NsTAU', currency: 'USD' },
|
||||
]
|
||||
const OPSXSHELL_PRODUCTS_TEST = [
|
||||
{ plan_key: 'yearly', label: 'OpsXshell Yearly', product_id: 'PROD_1BIezCi932IbgCzRIV8hcJ' },
|
||||
{ plan_key: 'perpetual', label: 'OpsXshell Perpetual', product_id: 'PROD_0pcnzzT4nalEkkcdyIUoD5' },
|
||||
// 测试包年商品不支持 CNY,须用 USD // Logan.Li
|
||||
{ plan_key: 'yearly', label: 'OpsXshell Yearly', product_id: 'PROD_1BIezCi932IbgCzRIV8hcJ', currency: 'USD' },
|
||||
{ plan_key: 'perpetual', label: 'OpsXshell Perpetual', product_id: 'PROD_0pcnzzT4nalEkkcdyIUoD5', currency: 'USD' },
|
||||
]
|
||||
|
||||
const PRODUCT_CURRENCY = {
|
||||
PROD_5PqVJyEiCM4nDgVoA0RKjN: 'CNY',
|
||||
PROD_3BSJqDRkVBoYNgO78NsTAU: 'USD',
|
||||
PROD_1BIezCi932IbgCzRIV8hcJ: 'USD',
|
||||
PROD_0pcnzzT4nalEkkcdyIUoD5: 'USD',
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const debugging = ref(false)
|
||||
@@ -226,19 +234,24 @@ function normalizeMappings(data = {}) {
|
||||
return rows.length ? rows : defaultMappings()
|
||||
}
|
||||
|
||||
// 按计划自动带货币,不再展示币种列 // Logan.Li
|
||||
function currencyForKey(planKey) {
|
||||
const k = (planKey || '').toLowerCase()
|
||||
// 按 Product ID / 计划推断币种(测试包年是 USD,生产包年才是 CNY) // Logan.Li
|
||||
function currencyForRow(row = {}) {
|
||||
const pid = (row.product_id || '').trim()
|
||||
if (pid && PRODUCT_CURRENCY[pid]) return PRODUCT_CURRENCY[pid]
|
||||
if ((row.currency || '').trim()) return row.currency.trim().toUpperCase()
|
||||
const k = (row.plan_key || '').toLowerCase()
|
||||
if (k === 'perpetual' || k === 'lifetime') return 'USD'
|
||||
return 'CNY'
|
||||
return isLive.value ? 'CNY' : 'USD'
|
||||
}
|
||||
|
||||
function mappingsToCompatFields(rows) {
|
||||
const map = {}
|
||||
const currencyMap = {}
|
||||
for (const row of rows) {
|
||||
const key = (row.plan_key || '').trim()
|
||||
if (!key) continue
|
||||
map[key] = (row.product_id || '').trim()
|
||||
currencyMap[key] = currencyForRow(row)
|
||||
}
|
||||
return {
|
||||
product_mappings: rows
|
||||
@@ -247,13 +260,13 @@ function mappingsToCompatFields(rows) {
|
||||
plan_key: r.plan_key.trim(),
|
||||
label: r.label || '',
|
||||
product_id: (r.product_id || '').trim(),
|
||||
currency: currencyForKey(r.plan_key),
|
||||
currency: currencyForRow(r),
|
||||
})),
|
||||
product_id_yearly: map.yearly || '',
|
||||
product_id_perpetual: map.perpetual || map.lifetime || '',
|
||||
product_id: map.perpetual || map.lifetime || map.yearly || '',
|
||||
currency_yearly: 'CNY',
|
||||
currency_perpetual: 'USD',
|
||||
currency_yearly: currencyMap.yearly || (isLive.value ? 'CNY' : 'USD'),
|
||||
currency_perpetual: currencyMap.perpetual || currencyMap.lifetime || 'USD',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +315,7 @@ function fillOpsxshellProducts() {
|
||||
if (byKey[item.plan_key]) {
|
||||
byKey[item.plan_key].product_id = item.product_id
|
||||
byKey[item.plan_key].label = item.label
|
||||
byKey[item.plan_key].currency = item.currency
|
||||
} else {
|
||||
productMappings.value.push({ ...item })
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user