feat: 支付可选跳过余额,配置项提示与构建内存收敛
Some checks failed
Build and Deploy Front / deploy (push) Failing after 3m53s

混合支付支持 UseBalance;微信/支付宝配置改为问号提示;Vite 堆降至 4G 并关闭 gzip 体积统计,减轻生产同机 CI 压力。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zzh 2026-12-04 17:19:53 +08:00
parent b453f0a47c
commit d9185f34ed
11 changed files with 550 additions and 87 deletions

View File

@ -13,10 +13,10 @@
"dev": "vite", "dev": "vite",
"dev:test": "vite --mode bcdship-test", "dev:test": "vite --mode bcdship-test",
"dev:nanafa": "vite --mode nanafa", "dev:nanafa": "vite --mode nanafa",
"build": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=8192 node_modules/vite/bin/vite.js build", "build": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=4096 node_modules/vite/bin/vite.js build",
"build:prod": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=8192 node_modules/vite/bin/vite.js build --mode production", "build:prod": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=4096 node_modules/vite/bin/vite.js build --mode production",
"build:test": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=8192 node_modules/vite/bin/vite.js build --mode bcdship-test", "build:test": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=4096 node_modules/vite/bin/vite.js build --mode bcdship-test",
"build:nanafa": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=8192 node_modules/vite/bin/vite.js build --mode nanafa", "build:nanafa": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=1 node --max-old-space-size=4096 node_modules/vite/bin/vite.js build --mode nanafa",
"postbuild": "node scripts/postbuild-cleanup-dist.js", "postbuild": "node scripts/postbuild-cleanup-dist.js",
"report": "cross-env REPORT=true pnpm run build", "report": "cross-env REPORT=true pnpm run build",
"preview": "npm run build && vite preview --host", "preview": "npm run build && vite preview --host",

View File

@ -106,17 +106,20 @@ export interface CreateOrderAlipayPayResult {
lines: CreateOrderAlipayPayLine[] lines: CreateOrderAlipayPayLine[]
} }
/** POST /order/pay/alipay/create — 余额优先,差额支付宝 */ /** POST /order/pay/alipay/create — 可选余额,差额支付宝 */
export async function createOrderAlipayPay(params: { export async function createOrderAlipayPay(params: {
orderIds: number[] orderIds: number[]
couponByOrderId?: Record<number, number | null> couponByOrderId?: Record<number, number | null>
scene: AlipayPayScene scene: AlipayPayScene
/** 是否使用账户余额抵扣,默认 true */
useBalance?: boolean
returnUrl?: string returnUrl?: string
}) { }) {
const res = await axiosInstance.post(omsUrl('/order/pay/alipay/create'), { const res = await axiosInstance.post(omsUrl('/order/pay/alipay/create'), {
orderIds: params.orderIds, orderIds: params.orderIds,
couponByOrderId: params.couponByOrderId, couponByOrderId: params.couponByOrderId,
scene: params.scene, scene: params.scene,
useBalance: params.useBalance !== false,
returnUrl: params.returnUrl, returnUrl: params.returnUrl,
}) })
const raw = unwrapData(res.data) ?? res.data const raw = unwrapData(res.data) ?? res.data

View File

@ -135,6 +135,8 @@ export async function createOrderWeChatPay(params: {
orderIds: number[] orderIds: number[]
couponByOrderId?: Record<number, number | null> couponByOrderId?: Record<number, number | null>
scene: WeChatPayScene scene: WeChatPayScene
/** 是否使用账户余额抵扣,默认 true */
useBalance?: boolean
oauthCode?: string oauthCode?: string
}) { }) {
const headers: Record<string, string> = {} const headers: Record<string, string> = {}
@ -147,6 +149,7 @@ export async function createOrderWeChatPay(params: {
orderIds: params.orderIds, orderIds: params.orderIds,
couponByOrderId: params.couponByOrderId, couponByOrderId: params.couponByOrderId,
scene: params.scene, scene: params.scene,
useBalance: params.useBalance !== false,
oauthCode: params.oauthCode, oauthCode: params.oauthCode,
}, },
{ headers }, { headers },
@ -191,9 +194,11 @@ export interface WeChatPayMerchantConfig {
enabled: boolean enabled: boolean
mchId: string mchId: string
mchSerialNo: string mchSerialNo: string
platformPublicKeyId: string
notifyUrl: string notifyUrl: string
hasApiV3Key: boolean hasApiV3Key: boolean
hasPrivateKey: boolean hasPrivateKey: boolean
hasPlatformPublicKey: boolean
appId?: string appId?: string
} }
@ -205,9 +210,11 @@ export async function getWeChatPayMerchantConfig(): Promise<WeChatPayMerchantCon
enabled: Boolean(data?.enabled ?? data?.Enabled), enabled: Boolean(data?.enabled ?? data?.Enabled),
mchId: String(data?.mchId ?? data?.MchId ?? ''), mchId: String(data?.mchId ?? data?.MchId ?? ''),
mchSerialNo: String(data?.mchSerialNo ?? data?.MchSerialNo ?? ''), mchSerialNo: String(data?.mchSerialNo ?? data?.MchSerialNo ?? ''),
platformPublicKeyId: String(data?.platformPublicKeyId ?? data?.PlatformPublicKeyId ?? ''),
notifyUrl: String(data?.notifyUrl ?? data?.NotifyUrl ?? ''), notifyUrl: String(data?.notifyUrl ?? data?.NotifyUrl ?? ''),
hasApiV3Key: Boolean(data?.hasApiV3Key ?? data?.HasApiV3Key), hasApiV3Key: Boolean(data?.hasApiV3Key ?? data?.HasApiV3Key),
hasPrivateKey: Boolean(data?.hasPrivateKey ?? data?.HasPrivateKey), hasPrivateKey: Boolean(data?.hasPrivateKey ?? data?.HasPrivateKey),
hasPlatformPublicKey: Boolean(data?.hasPlatformPublicKey ?? data?.HasPlatformPublicKey),
appId: (data?.appId ?? data?.AppId) || undefined, appId: (data?.appId ?? data?.AppId) || undefined,
} }
} }
@ -216,9 +223,11 @@ export async function saveWeChatPayMerchantConfig(payload: {
enabled: boolean enabled: boolean
mchId: string mchId: string
mchSerialNo: string mchSerialNo: string
platformPublicKeyId: string
notifyUrl?: string notifyUrl?: string
apiV3Key?: string apiV3Key?: string
privateKeyPem?: string privateKeyPem?: string
platformPublicKeyPem?: string
}) { }) {
const res = await axiosInstance.post( const res = await axiosInstance.post(
omsUrl('/system/other-config/wechat-pay-merchant/save'), omsUrl('/system/other-config/wechat-pay-merchant/save'),

View File

@ -2150,17 +2150,22 @@ export default {
'order.myOrders.modal.payBatchSuccess': '{count} orders paid', 'order.myOrders.modal.payBatchSuccess': '{count} orders paid',
'order.myOrders.modal.payPartialResult': '{success} paid, {failed} failed. Check the reasons and retry.', 'order.myOrders.modal.payPartialResult': '{success} paid, {failed} failed. Check the reasons and retry.',
'order.myOrders.modal.payMethodBalance': 'Payment method: account balance', 'order.myOrders.modal.payMethodBalance': 'Payment method: account balance',
'order.myOrders.modal.payMethodHybrid': 'Payment method: balance + WeChat shortfall', 'order.myOrders.modal.payMethodHybrid': 'Payment method: balance + QR shortfall',
'order.myOrders.modal.paySplitBalance': 'Balance {amount}', 'order.myOrders.modal.paySplitBalance': 'Balance {amount}',
'order.myOrders.modal.paySplitWechat': 'WeChat {amount}', 'order.myOrders.modal.paySplitWechat': 'WeChat {amount}',
'order.myOrders.modal.paySplitAlipay': 'Alipay {amount}', 'order.myOrders.modal.paySplitAlipay': 'Alipay {amount}',
'order.myOrders.modal.payOnlineChannel': 'Top-up method', 'order.myOrders.modal.payUseBalance': 'Use account balance',
'order.myOrders.modal.payOnlineChannel': 'Pay with',
'order.myOrders.modal.payChannelWechat': 'WeChat', 'order.myOrders.modal.payChannelWechat': 'WeChat',
'order.myOrders.modal.payChannelAlipay': 'Alipay', 'order.myOrders.modal.payChannelAlipay': 'Alipay',
'order.myOrders.modal.payChannelWechatHint': 'Scan with WeChat',
'order.myOrders.modal.payChannelAlipayHint': 'Scan with Alipay',
'order.myOrders.modal.payAlipayTitle': 'Alipay QR top-up', 'order.myOrders.modal.payAlipayTitle': 'Alipay QR top-up',
'order.myOrders.modal.payAlipayTip': 'Scan with Alipay to finish payment', 'order.myOrders.modal.payAlipayTip': 'Scan with Alipay to finish payment',
'order.myOrders.modal.payAlipayCreateFailed': 'Failed to create Alipay top-up', 'order.myOrders.modal.payAlipayCreateFailed': 'Failed to create Alipay top-up',
'order.myOrders.modal.payHybridHint': 'Shortfall will be paid via online QR: {amount}', 'order.myOrders.modal.payHybridHint': 'Shortfall will be paid via online QR: {amount}',
'order.myOrders.modal.payHybridBalanceLabel': 'Balance used',
'order.myOrders.modal.payHybridOnlineLabel': 'Still due',
'order.myOrders.modal.payMultiCustomerWxHint': 'Multi-customer batch supports balance only. Split by customer to use WeChat.', 'order.myOrders.modal.payMultiCustomerWxHint': 'Multi-customer batch supports balance only. Split by customer to use WeChat.',
'order.myOrders.modal.payWxTitle': 'WeChat QR shortfall', 'order.myOrders.modal.payWxTitle': 'WeChat QR shortfall',
'order.myOrders.modal.payWxTip': 'Scan with WeChat to finish payment. This dialog closes on success.', 'order.myOrders.modal.payWxTip': 'Scan with WeChat to finish payment. This dialog closes on success.',
@ -4436,16 +4441,26 @@ export default {
'system.otherConfig.paymentQr.alipayPay.sectionSecretHint': 'Server-side only; never echoed', 'system.otherConfig.paymentQr.alipayPay.sectionSecretHint': 'Server-side only; never echoed',
'system.otherConfig.paymentQr.alipayPay.appId': 'App Id', 'system.otherConfig.paymentQr.alipayPay.appId': 'App Id',
'system.otherConfig.paymentQr.alipayPay.appIdPlaceholder': 'Open platform AppId', 'system.otherConfig.paymentQr.alipayPay.appIdPlaceholder': 'Open platform AppId',
'system.otherConfig.paymentQr.alipayPay.appIdPath':
'open.alipay.com → Console → your app (AppId under the app name)',
'system.otherConfig.paymentQr.alipayPay.notifyUrl': 'Notify URL', 'system.otherConfig.paymentQr.alipayPay.notifyUrl': 'Notify URL',
'system.otherConfig.paymentQr.alipayPay.notifyUrlPath':
'Not from Open Platform: use this system public HTTPS callback; click “Use suggested URL”',
'system.otherConfig.paymentQr.alipayPay.fillNotify': 'Use suggested URL', 'system.otherConfig.paymentQr.alipayPay.fillNotify': 'Use suggested URL',
'system.otherConfig.paymentQr.alipayPay.returnUrl': 'H5 return URL base', 'system.otherConfig.paymentQr.alipayPay.returnUrl': 'H5 return URL base',
'system.otherConfig.paymentQr.alipayPay.returnUrlPlaceholder': 'e.g. https://your-host/h5/recharge', 'system.otherConfig.paymentQr.alipayPay.returnUrlPlaceholder': 'e.g. https://your-host/h5/recharge',
'system.otherConfig.paymentQr.alipayPay.returnUrlPath':
'Not from Open Platform: H5 recharge base, e.g. https://{front}/h5/recharge',
'system.otherConfig.paymentQr.alipayPay.privateKeyPem': 'App private key', 'system.otherConfig.paymentQr.alipayPay.privateKeyPem': 'App private key',
'system.otherConfig.paymentQr.alipayPay.privateKeyPlaceholder': 'Leave blank to keep', 'system.otherConfig.paymentQr.alipayPay.privateKeyPlaceholder': 'Leave blank to keep',
'system.otherConfig.paymentQr.alipayPay.privateKeyRequired': 'Required on first save', 'system.otherConfig.paymentQr.alipayPay.privateKeyRequired': 'Required on first save',
'system.otherConfig.paymentQr.alipayPay.privateKeyPemPath':
'App detail → Dev Settings → Interface signing (key) → RSA2 via key tool; keep private key locally (not shown on portal)',
'system.otherConfig.paymentQr.alipayPay.alipayPublicKey': 'Alipay public key', 'system.otherConfig.paymentQr.alipayPay.alipayPublicKey': 'Alipay public key',
'system.otherConfig.paymentQr.alipayPay.publicKeyPlaceholder': 'Leave blank to keep', 'system.otherConfig.paymentQr.alipayPay.publicKeyPlaceholder': 'Leave blank to keep',
'system.otherConfig.paymentQr.alipayPay.publicKeyRequired': 'Required on first save', 'system.otherConfig.paymentQr.alipayPay.publicKeyRequired': 'Required on first save',
'system.otherConfig.paymentQr.alipayPay.alipayPublicKeyPath':
'App detail → Dev Settings → Interface signing → Set/View → copy Alipay public key',
'system.otherConfig.paymentQr.alipayPay.importPem': 'Import key file', 'system.otherConfig.paymentQr.alipayPay.importPem': 'Import key file',
'system.otherConfig.paymentQr.alipayPay.clearPem': 'Clear draft', 'system.otherConfig.paymentQr.alipayPay.clearPem': 'Clear draft',
'system.otherConfig.paymentQr.alipayPay.pemImported': 'Private key imported', 'system.otherConfig.paymentQr.alipayPay.pemImported': 'Private key imported',
@ -5360,7 +5375,7 @@ export default {
'user.recharge.deposit.message.wxOnlineClosed': 'Payment closed or failed. Please try again.', 'user.recharge.deposit.message.wxOnlineClosed': 'Payment closed or failed. Please try again.',
'user.recharge.deposit.message.wxOnlineNoCode': 'No payment QR returned', 'user.recharge.deposit.message.wxOnlineNoCode': 'No payment QR returned',
'user.recharge.deposit.message.wxOnlineCreateFailed': 'Failed to create WeChat payment', 'user.recharge.deposit.message.wxOnlineCreateFailed': 'Failed to create WeChat payment',
'system.otherConfig.paymentQr.wechatPay.panelTitle': 'WeChat Pay merchant (APIv3)', 'system.otherConfig.paymentQr.wechatPay.panelTitle': 'WeChat Pay merchant (APIv3 public-key verify)',
'system.otherConfig.paymentQr.wechatPay.enabled': 'Enable online pay', 'system.otherConfig.paymentQr.wechatPay.enabled': 'Enable online pay',
'system.otherConfig.paymentQr.wechatPay.enabledOn': 'Native / JSAPI available', 'system.otherConfig.paymentQr.wechatPay.enabledOn': 'Native / JSAPI available',
'system.otherConfig.paymentQr.wechatPay.enabledOff': 'Online pay disabled when off', 'system.otherConfig.paymentQr.wechatPay.enabledOff': 'Online pay disabled when off',
@ -5371,29 +5386,52 @@ export default {
'system.otherConfig.paymentQr.wechatPay.checkSecret': 'Secrets', 'system.otherConfig.paymentQr.wechatPay.checkSecret': 'Secrets',
'system.otherConfig.paymentQr.wechatPay.checkAppId': 'MP AppId', 'system.otherConfig.paymentQr.wechatPay.checkAppId': 'MP AppId',
'system.otherConfig.paymentQr.wechatPay.sectionBasic': 'Merchant basics', 'system.otherConfig.paymentQr.wechatPay.sectionBasic': 'Merchant basics',
'system.otherConfig.paymentQr.wechatPay.sectionBasicHint': 'MchId, cert serial, public notify URL', 'system.otherConfig.paymentQr.wechatPay.sectionBasicHint': 'MchId, cert serial, public-key ID, notify URL',
'system.otherConfig.paymentQr.wechatPay.sectionSecret': 'Keys & cert', 'system.otherConfig.paymentQr.wechatPay.sectionSecret': 'Keys & cert',
'system.otherConfig.paymentQr.wechatPay.sectionSecretHint': 'Server-side only; never echoed', 'system.otherConfig.paymentQr.wechatPay.sectionSecretHint': 'Server-side only; never echoed',
'system.otherConfig.paymentQr.wechatPay.sectionBind': 'Official Account binding', 'system.otherConfig.paymentQr.wechatPay.sectionBind': 'Official Account binding',
'system.otherConfig.paymentQr.wechatPay.sectionBindHint': 'Must match merchant-bound AppId', 'system.otherConfig.paymentQr.wechatPay.sectionBindHint': 'Must match merchant-bound AppId',
'system.otherConfig.paymentQr.wechatPay.mchId': 'Merchant ID (MchId)', 'system.otherConfig.paymentQr.wechatPay.mchId': 'Merchant ID (MchId)',
'system.otherConfig.paymentQr.wechatPay.mchIdPlaceholder': 'e.g. 1900000109', 'system.otherConfig.paymentQr.wechatPay.mchIdPlaceholder': 'e.g. 1900000109',
'system.otherConfig.paymentQr.wechatPay.mchIdPath':
'pay.weixin.qq.com → Account Center → Merchant Info',
'system.otherConfig.paymentQr.wechatPay.mchSerialNo': 'Merchant cert serial', 'system.otherConfig.paymentQr.wechatPay.mchSerialNo': 'Merchant cert serial',
'system.otherConfig.paymentQr.wechatPay.mchSerialNoPlaceholder': 'API certificate serial from merchant portal', 'system.otherConfig.paymentQr.wechatPay.mchSerialNoPlaceholder': 'API certificate serial from merchant portal',
'system.otherConfig.paymentQr.wechatPay.mchSerialNoPath':
'Account Center → Account Settings → API Security → Merchant API Cert → Manage Cert',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyId': 'WeChat Pay public key ID',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyIdPlaceholder': 'Starts with PUB_KEY_ID_',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyIdPath':
'Account Center → API Security → WeChat Pay Public Key → apply/download to see key ID',
'system.otherConfig.paymentQr.wechatPay.notifyUrl': 'Notify URL', 'system.otherConfig.paymentQr.wechatPay.notifyUrl': 'Notify URL',
'system.otherConfig.paymentQr.wechatPay.notifyUrlPath':
'Not from merchant portal: use this system public HTTPS callback; click “Use suggested URL”',
'system.otherConfig.paymentQr.wechatPay.fillNotify': 'Use suggested URL', 'system.otherConfig.paymentQr.wechatPay.fillNotify': 'Use suggested URL',
'system.otherConfig.paymentQr.wechatPay.apiV3Key': 'APIv3 key', 'system.otherConfig.paymentQr.wechatPay.apiV3Key': 'APIv3 key',
'system.otherConfig.paymentQr.wechatPay.apiV3KeyPlaceholder': 'Leave blank to keep existing key', 'system.otherConfig.paymentQr.wechatPay.apiV3KeyPlaceholder': 'Leave blank to keep existing key',
'system.otherConfig.paymentQr.wechatPay.apiV3KeyRequired': 'Required on first save (32-char APIv3 key)', 'system.otherConfig.paymentQr.wechatPay.apiV3KeyRequired': 'Required on first save (32-char APIv3 key)',
'system.otherConfig.paymentQr.wechatPay.apiV3KeyPath':
'Account Center → Account Settings → API Security → Set APIv3 key (not viewable after set)',
'system.otherConfig.paymentQr.wechatPay.privateKeyPem': 'Merchant API private key (PEM)', 'system.otherConfig.paymentQr.wechatPay.privateKeyPem': 'Merchant API private key (PEM)',
'system.otherConfig.paymentQr.wechatPay.privateKeyPlaceholder': 'Leave blank to keep; must include BEGIN PRIVATE KEY', 'system.otherConfig.paymentQr.wechatPay.privateKeyPlaceholder': 'Leave blank to keep; must include BEGIN PRIVATE KEY',
'system.otherConfig.paymentQr.wechatPay.privateKeyRequired': 'Paste or import PEM on first save', 'system.otherConfig.paymentQr.wechatPay.privateKeyRequired': 'Paste or import PEM on first save',
'system.otherConfig.paymentQr.wechatPay.privateKeyPemPath':
'Account Center → API Security → Apply Merchant API Cert; cert tool writes local apiclient_key.pem',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyPem': 'WeChat Pay public key (PEM)',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyPlaceholder': 'Leave blank to keep; must include BEGIN PUBLIC KEY',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyRequired': 'Paste or import WeChat Pay public key on first save',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyPemPath':
'Account Center → API Security → WeChat Pay Public Key → apply and download pub_key.pem',
'system.otherConfig.paymentQr.wechatPay.importPem': 'Import PEM file', 'system.otherConfig.paymentQr.wechatPay.importPem': 'Import PEM file',
'system.otherConfig.paymentQr.wechatPay.clearPem': 'Clear draft', 'system.otherConfig.paymentQr.wechatPay.clearPem': 'Clear draft',
'system.otherConfig.paymentQr.wechatPay.pemInvalid': 'File does not look like a PEM private key', 'system.otherConfig.paymentQr.wechatPay.pemInvalid': 'File does not look like a PEM private key',
'system.otherConfig.paymentQr.wechatPay.publicPemInvalid': 'File does not look like a PEM public key',
'system.otherConfig.paymentQr.wechatPay.pemImported': 'Private key imported', 'system.otherConfig.paymentQr.wechatPay.pemImported': 'Private key imported',
'system.otherConfig.paymentQr.wechatPay.publicPemImported': 'WeChat Pay public key imported',
'system.otherConfig.paymentQr.wechatPay.pemReadFailed': 'Failed to read file', 'system.otherConfig.paymentQr.wechatPay.pemReadFailed': 'Failed to read file',
'system.otherConfig.paymentQr.wechatPay.appId': 'Bound Official Account AppId', 'system.otherConfig.paymentQr.wechatPay.appId': 'Bound Official Account AppId',
'system.otherConfig.paymentQr.wechatPay.appIdPath':
'Product Center → APPID Account / Authorization → link; must match system WeChat MP config',
'system.otherConfig.paymentQr.wechatPay.appIdEmpty': 'Official Account AppId missing (configure WeChat MP first)', 'system.otherConfig.paymentQr.wechatPay.appIdEmpty': 'Official Account AppId missing (configure WeChat MP first)',
'system.otherConfig.paymentQr.wechatPay.openMpConfig': 'Configure Official Account', 'system.otherConfig.paymentQr.wechatPay.openMpConfig': 'Configure Official Account',
'system.otherConfig.paymentQr.wechatPay.mpMissing': 'No WeChat MP config in list; create one first', 'system.otherConfig.paymentQr.wechatPay.mpMissing': 'No WeChat MP config in list; create one first',
@ -5405,14 +5443,17 @@ export default {
'system.otherConfig.paymentQr.wechatPay.save': 'Save merchant config', 'system.otherConfig.paymentQr.wechatPay.save': 'Save merchant config',
'system.otherConfig.paymentQr.wechatPay.needMchId': 'Merchant ID is required', 'system.otherConfig.paymentQr.wechatPay.needMchId': 'Merchant ID is required',
'system.otherConfig.paymentQr.wechatPay.needSerial': 'Cert serial is required', 'system.otherConfig.paymentQr.wechatPay.needSerial': 'Cert serial is required',
'system.otherConfig.paymentQr.wechatPay.needPublicKeyId': 'WeChat Pay public key ID is required',
'system.otherConfig.paymentQr.wechatPay.needNotify': 'Notify URL is required', 'system.otherConfig.paymentQr.wechatPay.needNotify': 'Notify URL is required',
'system.otherConfig.paymentQr.wechatPay.needHttps': 'Notify URL must start with https://', 'system.otherConfig.paymentQr.wechatPay.needHttps': 'Notify URL must start with https://',
'system.otherConfig.paymentQr.wechatPay.needApiV3Key': 'APIv3 key is required on first save', 'system.otherConfig.paymentQr.wechatPay.needApiV3Key': 'APIv3 key is required on first save',
'system.otherConfig.paymentQr.wechatPay.needPrivateKey': 'Private key is required on first save', 'system.otherConfig.paymentQr.wechatPay.needPrivateKey': 'Private key is required on first save',
'system.otherConfig.paymentQr.wechatPay.needPlatformPublicKey': 'WeChat Pay public key is required on first save',
'system.otherConfig.paymentQr.wechatPay.loadFailed': 'Failed to load WeChat Pay merchant config', 'system.otherConfig.paymentQr.wechatPay.loadFailed': 'Failed to load WeChat Pay merchant config',
'system.otherConfig.paymentQr.wechatPay.saveSuccess': 'WeChat Pay merchant config saved', 'system.otherConfig.paymentQr.wechatPay.saveSuccess': 'WeChat Pay merchant config saved',
'system.otherConfig.paymentQr.wechatPay.saveFailed': 'Save failed', 'system.otherConfig.paymentQr.wechatPay.saveFailed': 'Save failed',
'system.otherConfig.paymentQr.wechatPay.tip': 'Direct merchant APIv3. Secrets stay server-side. NotifyUrl must be public HTTPS.', 'system.otherConfig.paymentQr.wechatPay.tip':
'Direct merchant APIv3 with WeChat Pay public-key verify. Secrets stay server-side. NotifyUrl must be public HTTPS.',
'user.recharge.deposit.result.title': 'Submitted Successfully', 'user.recharge.deposit.result.title': 'Submitted Successfully',
'user.recharge.deposit.result.subtitle': 'Under review, please wait patiently', 'user.recharge.deposit.result.subtitle': 'Under review, please wait patiently',
'user.recharge.deposit.result.actions.rechargeAgain': 'Recharge Again', 'user.recharge.deposit.result.actions.rechargeAgain': 'Recharge Again',

View File

@ -1918,14 +1918,19 @@ export default {
'order.myOrders.modal.payBatchSuccess': '已成功支付 {count} 单', 'order.myOrders.modal.payBatchSuccess': '已成功支付 {count} 单',
'order.myOrders.modal.payPartialResult': '成功 {success} 单,失败 {failed} 单,请查看失败原因后重试', 'order.myOrders.modal.payPartialResult': '成功 {success} 单,失败 {failed} 单,请查看失败原因后重试',
'order.myOrders.modal.payMethodBalance': '支付方式:账户余额', 'order.myOrders.modal.payMethodBalance': '支付方式:账户余额',
'order.myOrders.modal.payMethodHybrid': '支付方式:余额 + 微信补差', 'order.myOrders.modal.payMethodHybrid': '支付方式:余额 + 扫码补差',
'order.myOrders.modal.paySplitBalance': '余额 {amount}', 'order.myOrders.modal.paySplitBalance': '余额 {amount}',
'order.myOrders.modal.paySplitWechat': '微信 {amount}', 'order.myOrders.modal.paySplitWechat': '微信 {amount}',
'order.myOrders.modal.paySplitAlipay': '支付宝 {amount}', 'order.myOrders.modal.paySplitAlipay': '支付宝 {amount}',
'order.myOrders.modal.payHybridHint': '余额不足部分将通过在线扫码补差 {amount}', 'order.myOrders.modal.payHybridHint': '余额不足部分将通过在线扫码补差 {amount}',
'order.myOrders.modal.payOnlineChannel': '补差方式', 'order.myOrders.modal.payUseBalance': '使用账户余额',
'order.myOrders.modal.payHybridBalanceLabel': '余额抵扣',
'order.myOrders.modal.payHybridOnlineLabel': '还需支付',
'order.myOrders.modal.payOnlineChannel': '支付方式',
'order.myOrders.modal.payChannelWechat': '微信', 'order.myOrders.modal.payChannelWechat': '微信',
'order.myOrders.modal.payChannelAlipay': '支付宝', 'order.myOrders.modal.payChannelAlipay': '支付宝',
'order.myOrders.modal.payChannelWechatHint': '打开微信扫一扫',
'order.myOrders.modal.payChannelAlipayHint': '打开支付宝扫一扫',
'order.myOrders.modal.payAlipayTitle': '支付宝扫码补差', 'order.myOrders.modal.payAlipayTitle': '支付宝扫码补差',
'order.myOrders.modal.payAlipayTip': '请使用支付宝扫一扫完成支付', 'order.myOrders.modal.payAlipayTip': '请使用支付宝扫一扫完成支付',
'order.myOrders.modal.payAlipayCreateFailed': '创建支付宝补差失败', 'order.myOrders.modal.payAlipayCreateFailed': '创建支付宝补差失败',
@ -5346,16 +5351,26 @@ export default {
'system.otherConfig.paymentQr.alipayPay.sectionSecretHint': '仅服务端保存,前端不回显明文', 'system.otherConfig.paymentQr.alipayPay.sectionSecretHint': '仅服务端保存,前端不回显明文',
'system.otherConfig.paymentQr.alipayPay.appId': '应用 AppId', 'system.otherConfig.paymentQr.alipayPay.appId': '应用 AppId',
'system.otherConfig.paymentQr.alipayPay.appIdPlaceholder': '开放平台应用 AppId', 'system.otherConfig.paymentQr.alipayPay.appIdPlaceholder': '开放平台应用 AppId',
'system.otherConfig.paymentQr.alipayPay.appIdPath':
'open.alipay.com → 控制台 → 对应应用(应用名称下方数字即为 AppId)',
'system.otherConfig.paymentQr.alipayPay.notifyUrl': '异步通知 URL', 'system.otherConfig.paymentQr.alipayPay.notifyUrl': '异步通知 URL',
'system.otherConfig.paymentQr.alipayPay.notifyUrlPath':
'非开放平台项:填本系统公网 HTTPS 回调,可点「填入建议地址」',
'system.otherConfig.paymentQr.alipayPay.fillNotify': '填入建议地址', 'system.otherConfig.paymentQr.alipayPay.fillNotify': '填入建议地址',
'system.otherConfig.paymentQr.alipayPay.returnUrl': 'H5 同步回跳基址', 'system.otherConfig.paymentQr.alipayPay.returnUrl': 'H5 同步回跳基址',
'system.otherConfig.paymentQr.alipayPay.returnUrlPlaceholder': '如 https://your-host/h5/recharge(可选)', 'system.otherConfig.paymentQr.alipayPay.returnUrlPlaceholder': '如 https://your-host/h5/recharge(可选)',
'system.otherConfig.paymentQr.alipayPay.returnUrlPath':
'非开放平台项:填本系统 H5 充值页基址,如 https://{front}/h5/recharge',
'system.otherConfig.paymentQr.alipayPay.privateKeyPem': '应用私钥', 'system.otherConfig.paymentQr.alipayPay.privateKeyPem': '应用私钥',
'system.otherConfig.paymentQr.alipayPay.privateKeyPlaceholder': '留空表示不修改', 'system.otherConfig.paymentQr.alipayPay.privateKeyPlaceholder': '留空表示不修改',
'system.otherConfig.paymentQr.alipayPay.privateKeyRequired': '首次保存须粘贴应用私钥', 'system.otherConfig.paymentQr.alipayPay.privateKeyRequired': '首次保存须粘贴应用私钥',
'system.otherConfig.paymentQr.alipayPay.privateKeyPemPath':
'应用详情 → 开发设置 → 接口加签方式(密钥)→ 用密钥工具生成 RSA2,本地保存应用私钥(平台不回显)',
'system.otherConfig.paymentQr.alipayPay.alipayPublicKey': '支付宝公钥', 'system.otherConfig.paymentQr.alipayPay.alipayPublicKey': '支付宝公钥',
'system.otherConfig.paymentQr.alipayPay.publicKeyPlaceholder': '留空表示不修改', 'system.otherConfig.paymentQr.alipayPay.publicKeyPlaceholder': '留空表示不修改',
'system.otherConfig.paymentQr.alipayPay.publicKeyRequired': '首次保存须粘贴支付宝公钥', 'system.otherConfig.paymentQr.alipayPay.publicKeyRequired': '首次保存须粘贴支付宝公钥',
'system.otherConfig.paymentQr.alipayPay.alipayPublicKeyPath':
'应用详情 → 开发设置 → 接口加签方式 → 设置/查看 → 下载/复制「支付宝公钥」',
'system.otherConfig.paymentQr.alipayPay.importPem': '导入私钥文件', 'system.otherConfig.paymentQr.alipayPay.importPem': '导入私钥文件',
'system.otherConfig.paymentQr.alipayPay.clearPem': '清空草稿', 'system.otherConfig.paymentQr.alipayPay.clearPem': '清空草稿',
'system.otherConfig.paymentQr.alipayPay.pemImported': '私钥已导入', 'system.otherConfig.paymentQr.alipayPay.pemImported': '私钥已导入',
@ -5376,7 +5391,7 @@ export default {
'system.otherConfig.paymentQr.alipayPay.saveFailed': '保存失败', 'system.otherConfig.paymentQr.alipayPay.saveFailed': '保存失败',
'system.otherConfig.paymentQr.alipayPay.tip': 'system.otherConfig.paymentQr.alipayPay.tip':
'密钥模式 RSA2:应用私钥与支付宝公钥仅服务端保存。需开通当面付与手机网站支付;NotifyUrl 须公网 HTTPS。', '密钥模式 RSA2:应用私钥与支付宝公钥仅服务端保存。需开通当面付与手机网站支付;NotifyUrl 须公网 HTTPS。',
'system.otherConfig.paymentQr.wechatPay.panelTitle': '微信支付商户(APIv3)', 'system.otherConfig.paymentQr.wechatPay.panelTitle': '微信支付商户(APIv3 公钥验签)',
'system.otherConfig.paymentQr.wechatPay.enabled': '启用在线支付', 'system.otherConfig.paymentQr.wechatPay.enabled': '启用在线支付',
'system.otherConfig.paymentQr.wechatPay.enabledOn': 'Native / JSAPI 可用', 'system.otherConfig.paymentQr.wechatPay.enabledOn': 'Native / JSAPI 可用',
'system.otherConfig.paymentQr.wechatPay.enabledOff': '关闭后无法发起在线支付', 'system.otherConfig.paymentQr.wechatPay.enabledOff': '关闭后无法发起在线支付',
@ -5387,29 +5402,52 @@ export default {
'system.otherConfig.paymentQr.wechatPay.checkSecret': '密钥证书', 'system.otherConfig.paymentQr.wechatPay.checkSecret': '密钥证书',
'system.otherConfig.paymentQr.wechatPay.checkAppId': '公众号 AppId', 'system.otherConfig.paymentQr.wechatPay.checkAppId': '公众号 AppId',
'system.otherConfig.paymentQr.wechatPay.sectionBasic': '商户基础信息', 'system.otherConfig.paymentQr.wechatPay.sectionBasic': '商户基础信息',
'system.otherConfig.paymentQr.wechatPay.sectionBasicHint': '商户号、证书序列号与公网回调', 'system.otherConfig.paymentQr.wechatPay.sectionBasicHint': '商户号、证书序列号、公钥 ID 与公网回调',
'system.otherConfig.paymentQr.wechatPay.sectionSecret': '密钥与证书', 'system.otherConfig.paymentQr.wechatPay.sectionSecret': '密钥与证书',
'system.otherConfig.paymentQr.wechatPay.sectionSecretHint': '仅服务端保存,前端不回显明文', 'system.otherConfig.paymentQr.wechatPay.sectionSecretHint': '仅服务端保存,前端不回显明文',
'system.otherConfig.paymentQr.wechatPay.sectionBind': '公众号绑定', 'system.otherConfig.paymentQr.wechatPay.sectionBind': '公众号绑定',
'system.otherConfig.paymentQr.wechatPay.sectionBindHint': '须与商户平台绑定同一主体 AppId', 'system.otherConfig.paymentQr.wechatPay.sectionBindHint': '须与商户平台绑定同一主体 AppId',
'system.otherConfig.paymentQr.wechatPay.mchId': '商户号 MchId', 'system.otherConfig.paymentQr.wechatPay.mchId': '商户号 MchId',
'system.otherConfig.paymentQr.wechatPay.mchIdPlaceholder': '例如 1900000109', 'system.otherConfig.paymentQr.wechatPay.mchIdPlaceholder': '例如 1900000109',
'system.otherConfig.paymentQr.wechatPay.mchIdPath':
'pay.weixin.qq.com → 账户中心 → 商户信息',
'system.otherConfig.paymentQr.wechatPay.mchSerialNo': '商户证书序列号', 'system.otherConfig.paymentQr.wechatPay.mchSerialNo': '商户证书序列号',
'system.otherConfig.paymentQr.wechatPay.mchSerialNoPlaceholder': 'API 证书序列号(商户平台可查)', 'system.otherConfig.paymentQr.wechatPay.mchSerialNoPlaceholder': 'API 证书序列号(商户平台可查)',
'system.otherConfig.paymentQr.wechatPay.mchSerialNoPath':
'账户中心 → 账户设置 → API安全 → 商户API证书 → 管理证书',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyId': '微信支付公钥 ID',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyIdPlaceholder': 'PUB_KEY_ID_ 开头',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyIdPath':
'账户中心 → API安全 → 微信支付公钥 → 申请/下载后可见公钥 ID',
'system.otherConfig.paymentQr.wechatPay.notifyUrl': '支付回调 NotifyUrl', 'system.otherConfig.paymentQr.wechatPay.notifyUrl': '支付回调 NotifyUrl',
'system.otherConfig.paymentQr.wechatPay.notifyUrlPath':
'非商户后台项:填本系统公网 HTTPS 回调,可点「填充推荐地址」',
'system.otherConfig.paymentQr.wechatPay.fillNotify': '填充推荐地址', 'system.otherConfig.paymentQr.wechatPay.fillNotify': '填充推荐地址',
'system.otherConfig.paymentQr.wechatPay.apiV3Key': 'APIv3 密钥', 'system.otherConfig.paymentQr.wechatPay.apiV3Key': 'APIv3 密钥',
'system.otherConfig.paymentQr.wechatPay.apiV3KeyPlaceholder': '留空则保留原密钥', 'system.otherConfig.paymentQr.wechatPay.apiV3KeyPlaceholder': '留空则保留原密钥',
'system.otherConfig.paymentQr.wechatPay.apiV3KeyRequired': '首次保存须填写 32 位 APIv3 密钥', 'system.otherConfig.paymentQr.wechatPay.apiV3KeyRequired': '首次保存须填写 32 位 APIv3 密钥',
'system.otherConfig.paymentQr.wechatPay.apiV3KeyPath':
'账户中心 → 账户设置 → API安全 → 设置 APIv3密钥(设置后不可回看)',
'system.otherConfig.paymentQr.wechatPay.privateKeyPem': '商户 API 私钥 PEM', 'system.otherConfig.paymentQr.wechatPay.privateKeyPem': '商户 API 私钥 PEM',
'system.otherConfig.paymentQr.wechatPay.privateKeyPlaceholder': '留空则保留原私钥;须含 BEGIN PRIVATE KEY', 'system.otherConfig.paymentQr.wechatPay.privateKeyPlaceholder': '留空则保留原私钥;须含 BEGIN PRIVATE KEY',
'system.otherConfig.paymentQr.wechatPay.privateKeyRequired': '首次保存须粘贴或导入私钥 PEM', 'system.otherConfig.paymentQr.wechatPay.privateKeyRequired': '首次保存须粘贴或导入私钥 PEM',
'system.otherConfig.paymentQr.wechatPay.privateKeyPemPath':
'账户中心 → API安全 → 申请商户API证书,用证书工具生成本地 apiclient_key.pem',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyPem': '微信支付公钥 PEM',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyPlaceholder': '留空则保留原公钥;须含 BEGIN PUBLIC KEY',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyRequired': '首次保存须粘贴或导入微信支付公钥',
'system.otherConfig.paymentQr.wechatPay.platformPublicKeyPemPath':
'账户中心 → API安全 → 微信支付公钥 → 申请并下载 pub_key.pem',
'system.otherConfig.paymentQr.wechatPay.importPem': '导入 PEM 文件', 'system.otherConfig.paymentQr.wechatPay.importPem': '导入 PEM 文件',
'system.otherConfig.paymentQr.wechatPay.clearPem': '清空本次输入', 'system.otherConfig.paymentQr.wechatPay.clearPem': '清空本次输入',
'system.otherConfig.paymentQr.wechatPay.pemInvalid': '文件内容不像 PEM 私钥', 'system.otherConfig.paymentQr.wechatPay.pemInvalid': '文件内容不像 PEM 私钥',
'system.otherConfig.paymentQr.wechatPay.publicPemInvalid': '文件内容不像 PEM 公钥',
'system.otherConfig.paymentQr.wechatPay.pemImported': '已导入私钥内容', 'system.otherConfig.paymentQr.wechatPay.pemImported': '已导入私钥内容',
'system.otherConfig.paymentQr.wechatPay.publicPemImported': '已导入微信支付公钥',
'system.otherConfig.paymentQr.wechatPay.pemReadFailed': '读取文件失败', 'system.otherConfig.paymentQr.wechatPay.pemReadFailed': '读取文件失败',
'system.otherConfig.paymentQr.wechatPay.appId': '绑定公众号 AppId', 'system.otherConfig.paymentQr.wechatPay.appId': '绑定公众号 AppId',
'system.otherConfig.paymentQr.wechatPay.appIdPath':
'产品中心 → APPID账号管理 / APPID授权管理 → 关联;须与系统「微信公众号」一致',
'system.otherConfig.paymentQr.wechatPay.appIdEmpty': '未配置公众号 AppId(请先配置「微信公众号」)', 'system.otherConfig.paymentQr.wechatPay.appIdEmpty': '未配置公众号 AppId(请先配置「微信公众号」)',
'system.otherConfig.paymentQr.wechatPay.openMpConfig': '去配置公众号', 'system.otherConfig.paymentQr.wechatPay.openMpConfig': '去配置公众号',
'system.otherConfig.paymentQr.wechatPay.mpMissing': '列表中暂无微信公众号配置,请先新增', 'system.otherConfig.paymentQr.wechatPay.mpMissing': '列表中暂无微信公众号配置,请先新增',
@ -5421,14 +5459,17 @@ export default {
'system.otherConfig.paymentQr.wechatPay.save': '保存商户配置', 'system.otherConfig.paymentQr.wechatPay.save': '保存商户配置',
'system.otherConfig.paymentQr.wechatPay.needMchId': '请填写商户号', 'system.otherConfig.paymentQr.wechatPay.needMchId': '请填写商户号',
'system.otherConfig.paymentQr.wechatPay.needSerial': '请填写证书序列号', 'system.otherConfig.paymentQr.wechatPay.needSerial': '请填写证书序列号',
'system.otherConfig.paymentQr.wechatPay.needPublicKeyId': '请填写微信支付公钥 ID',
'system.otherConfig.paymentQr.wechatPay.needNotify': '请填写支付回调地址', 'system.otherConfig.paymentQr.wechatPay.needNotify': '请填写支付回调地址',
'system.otherConfig.paymentQr.wechatPay.needHttps': 'NotifyUrl 须为 https:// 开头的公网地址', 'system.otherConfig.paymentQr.wechatPay.needHttps': 'NotifyUrl 须为 https:// 开头的公网地址',
'system.otherConfig.paymentQr.wechatPay.needApiV3Key': '首次保存须填写 APIv3 密钥', 'system.otherConfig.paymentQr.wechatPay.needApiV3Key': '首次保存须填写 APIv3 密钥',
'system.otherConfig.paymentQr.wechatPay.needPrivateKey': '首次保存须填写商户 API 私钥', 'system.otherConfig.paymentQr.wechatPay.needPrivateKey': '首次保存须填写商户 API 私钥',
'system.otherConfig.paymentQr.wechatPay.needPlatformPublicKey': '首次保存须填写微信支付公钥',
'system.otherConfig.paymentQr.wechatPay.loadFailed': '加载微信支付商户配置失败', 'system.otherConfig.paymentQr.wechatPay.loadFailed': '加载微信支付商户配置失败',
'system.otherConfig.paymentQr.wechatPay.saveSuccess': '微信支付商户配置已保存', 'system.otherConfig.paymentQr.wechatPay.saveSuccess': '微信支付商户配置已保存',
'system.otherConfig.paymentQr.wechatPay.saveFailed': '保存失败', 'system.otherConfig.paymentQr.wechatPay.saveFailed': '保存失败',
'system.otherConfig.paymentQr.wechatPay.tip': '普通商户直连 APIv3:密钥仅服务端保存,前端不回显明文。NotifyUrl 须公网 HTTPS。', 'system.otherConfig.paymentQr.wechatPay.tip':
'普通商户直连 APIv3(微信支付公钥验签):密钥仅服务端保存。NotifyUrl 须公网 HTTPS。',
'user.recharge.deposit.result.title': '提交成功', 'user.recharge.deposit.result.title': '提交成功',
'user.recharge.deposit.result.subtitle': '审核中,请耐心等待', 'user.recharge.deposit.result.subtitle': '审核中,请耐心等待',
'user.recharge.deposit.result.actions.rechargeAgain': '再转一笔', 'user.recharge.deposit.result.actions.rechargeAgain': '再转一笔',

View File

@ -178,17 +178,27 @@
<span class="h5-pay__settle-title">{{ t('h5.pay.settleTitle') }}</span> <span class="h5-pay__settle-title">{{ t('h5.pay.settleTitle') }}</span>
<span class="h5-pay__settle-mode"> <span class="h5-pay__settle-mode">
{{ {{
needsWechatPay !useAccountBalance
? onlinePayChannel === 'alipay' ? onlinePayChannel === 'alipay'
? t('h5.pay.methodHybridAlipay') ? t('h5.pay.channelAlipay')
: t('h5.pay.methodHybrid') : t('h5.pay.channelWechat')
: t('h5.pay.methodBalance') : needsWechatPay
? onlinePayChannel === 'alipay'
? t('h5.pay.methodHybridAlipay')
: t('h5.pay.methodHybrid')
: t('h5.pay.methodBalance')
}} }}
</span> </span>
</div> </div>
<label v-if="canUseAccountBalance" class="h5-pay__use-balance">
<input v-model="useAccountBalance" type="checkbox" />
<span>{{ t('h5.pay.useBalance') }}</span>
<em>{{ formatPayMoney(customerBalance) }}</em>
</label>
<div class="h5-pay__split-inline"> <div class="h5-pay__split-inline">
<span class="h5-pay__split-pill is-balance"> <span v-if="useAccountBalance" class="h5-pay__split-pill is-balance">
{{ t('h5.pay.splitBalance') }} {{ t('h5.pay.splitBalance') }}
<b>{{ formatPayMoney(needsWechatPay ? hybridBalanceUse : payableTotal) }}</b> <b>{{ formatPayMoney(needsWechatPay ? hybridBalanceUse : payableTotal) }}</b>
</span> </span>
@ -440,12 +450,16 @@ const payableTotal = computed(() => {
return couponPricing.totalPayable.value; return couponPricing.totalPayable.value;
}); });
const useAccountBalance = ref(true);
const canUseAccountBalance = computed(
() => customerBalance.value != null && customerBalance.value > 1e-6,
);
const hybridBalanceUse = computed(() => { const hybridBalanceUse = computed(() => {
if (customerBalance.value == null) return 0; if (customerBalance.value == null || !useAccountBalance.value) return 0;
return Math.min(customerBalance.value, payableTotal.value); return Math.min(customerBalance.value, payableTotal.value);
}); });
const hybridWechatAmount = computed(() => { const hybridWechatAmount = computed(() => {
if (customerBalance.value == null) return 0; if (customerBalance.value == null && useAccountBalance.value) return 0;
return Math.max(0, payableTotal.value - hybridBalanceUse.value); return Math.max(0, payableTotal.value - hybridBalanceUse.value);
}); });
const needsWechatPay = computed(() => hybridWechatAmount.value > 1e-6); const needsWechatPay = computed(() => hybridWechatAmount.value > 1e-6);
@ -805,6 +819,7 @@ async function payWithWechatHybrid(oauthCode?: string) {
orderIds: props.orders.map((o) => Number(o.id)).filter((id) => id > 0), orderIds: props.orders.map((o) => Number(o.id)).filter((id) => id > 0),
couponByOrderId, couponByOrderId,
scene: 'jsapi', scene: 'jsapi',
useBalance: useAccountBalance.value,
oauthCode, oauthCode,
}); });
} catch (e: any) { } catch (e: any) {
@ -869,6 +884,7 @@ async function payWithAlipayHybrid() {
orderIds: props.orders.map((o) => Number(o.id)).filter((id) => id > 0), orderIds: props.orders.map((o) => Number(o.id)).filter((id) => id > 0),
couponByOrderId, couponByOrderId,
scene: 'wap', scene: 'wap',
useBalance: useAccountBalance.value,
returnUrl, returnUrl,
}); });
@ -1477,6 +1493,30 @@ watch(
color: #4e5969; color: #4e5969;
} }
.h5-pay__use-balance {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
font-size: 13px;
color: #1d2129;
cursor: pointer;
input {
width: 16px;
height: 16px;
accent-color: var(--app-primary-color);
}
em {
margin-left: auto;
font-style: normal;
font-size: 12px;
color: #86909c;
font-variant-numeric: tabular-nums;
}
}
.h5-pay__split-inline { .h5-pay__split-inline {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;

View File

@ -1092,6 +1092,7 @@ export default {
'h5.pay.waybillNo': 'Waybill', 'h5.pay.waybillNo': 'Waybill',
'h5.pay.orderTotal': 'Order due', 'h5.pay.orderTotal': 'Order due',
'h5.pay.methodBalance': 'Pay with balance', 'h5.pay.methodBalance': 'Pay with balance',
'h5.pay.useBalance': 'Use account balance',
'h5.pay.methodHybrid': 'Balance first · WeChat shortfall', 'h5.pay.methodHybrid': 'Balance first · WeChat shortfall',
'h5.pay.methodHybridHint': 'Use balance {balance}, WeChat {wechat}', 'h5.pay.methodHybridHint': 'Use balance {balance}, WeChat {wechat}',
'h5.pay.settleTitle': 'Payment', 'h5.pay.settleTitle': 'Payment',

View File

@ -1072,6 +1072,7 @@ export default {
'h5.pay.orderTotal': '本单应付', 'h5.pay.orderTotal': '本单应付',
'h5.pay.methodBalance': '账户余额支付', 'h5.pay.methodBalance': '账户余额支付',
'h5.pay.methodHint': '支付成功后将从账户余额扣款', 'h5.pay.methodHint': '支付成功后将从账户余额扣款',
'h5.pay.useBalance': '使用账户余额',
'h5.pay.methodHybrid': '余额优先 · 微信补差', 'h5.pay.methodHybrid': '余额优先 · 微信补差',
'h5.pay.methodHybridAlipay': '余额优先 · 支付宝补差', 'h5.pay.methodHybridAlipay': '余额优先 · 支付宝补差',
'h5.pay.methodHybridHint': '本次用余额 {balance},在线补差 {wechat}', 'h5.pay.methodHybridHint': '本次用余额 {balance},在线补差 {wechat}',

View File

@ -17,6 +17,8 @@ import {
createOrderAlipayPay, createOrderAlipayPay,
getAlipayPayStatus, getAlipayPayStatus,
} from '@/api/recharge/alipayPay' } from '@/api/recharge/alipayPay'
import wxIcon from '@/assets/wx.png'
import zfbIcon from '@/assets/zfb.png'
import { import {
formatCouponBenefit, formatCouponBenefit,
formatPayMoney, formatPayMoney,
@ -172,13 +174,21 @@ const singleBalance = computed(() => {
const pricingLoading = computed(() => couponPricing.anyLoading.value) const pricingLoading = computed(() => couponPricing.anyLoading.value)
/** 单客户:余额优先;多客户:仅余额(不足不可确认) */ /** 单客户:是否用账户余额抵扣(可关,关则全额扫码) */
const useAccountBalance = ref(true)
const canUseAccountBalance = computed(
() => !isMultiCustomer.value && singleBalance.value != null && singleBalance.value > 1e-6,
)
/** 单客户:可选余额;多客户:仅余额(不足不可确认) */
const hybridBalanceUse = computed(() => { const hybridBalanceUse = computed(() => {
if (isMultiCustomer.value || singleBalance.value == null) return 0 if (isMultiCustomer.value || singleBalance.value == null) return 0
if (!useAccountBalance.value) return 0
return Math.min(singleBalance.value, totals.value.payable) return Math.min(singleBalance.value, totals.value.payable)
}) })
const hybridWechatAmount = computed(() => { const hybridWechatAmount = computed(() => {
if (isMultiCustomer.value || singleBalance.value == null) return 0 if (isMultiCustomer.value) return 0
if (singleBalance.value == null && useAccountBalance.value) return 0
return Math.max(0, totals.value.payable - hybridBalanceUse.value) return Math.max(0, totals.value.payable - hybridBalanceUse.value)
}) })
const needsWechatPay = computed(() => hybridWechatAmount.value > 1e-6) const needsWechatPay = computed(() => hybridWechatAmount.value > 1e-6)
@ -473,11 +483,13 @@ async function handleConfirm() {
orderIds: queue.map((p) => Number(p.id)), orderIds: queue.map((p) => Number(p.id)),
couponByOrderId, couponByOrderId,
scene: 'precreate', scene: 'precreate',
useBalance: useAccountBalance.value,
}) })
: await createOrderWeChatPay({ : await createOrderWeChatPay({
orderIds: queue.map((p) => Number(p.id)), orderIds: queue.map((p) => Number(p.id)),
couponByOrderId, couponByOrderId,
scene: 'native', scene: 'native',
useBalance: useAccountBalance.value,
}) })
if (created.paidImmediately) { if (created.paidImmediately) {
for (const p of queue) { for (const p of queue) {
@ -594,6 +606,8 @@ watch(
() => [props.visible, props.orders] as const, () => [props.visible, props.orders] as const,
([visible]) => { ([visible]) => {
if (visible) { if (visible) {
useAccountBalance.value = true
onlinePayChannel.value = 'wechat'
loadPreviews() loadPreviews()
} else { } else {
stopWxPoll() stopWxPoll()
@ -640,7 +654,21 @@ watch(
<dt>{{ t('order.myOrders.modal.paySubtotal') }}</dt> <dt>{{ t('order.myOrders.modal.paySubtotal') }}</dt>
<dd>{{ formatPayMoney(totals.subtotal) }}</dd> <dd>{{ formatPayMoney(totals.subtotal) }}</dd>
</div> </div>
<div v-if="singleBalance != null"> <template v-if="!isMultiCustomer && (needsWechatPay || canUseAccountBalance)">
<div v-if="useAccountBalance">
<dt>{{ t('order.myOrders.modal.payHybridBalanceLabel') }}</dt>
<dd>{{ formatPayMoney(hybridBalanceUse) }}</dd>
</div>
<div v-if="needsWechatPay">
<dt>{{ t('order.myOrders.modal.payHybridOnlineLabel') }}</dt>
<dd class="is-emphasis">{{ formatPayMoney(hybridWechatAmount) }}</dd>
</div>
<div v-else-if="singleBalance != null">
<dt>{{ t('order.myOrders.modal.payBalance') }}</dt>
<dd>{{ formatPayMoney(singleBalance) }}</dd>
</div>
</template>
<div v-else-if="singleBalance != null">
<dt>{{ t('order.myOrders.modal.payBalance') }}</dt> <dt>{{ t('order.myOrders.modal.payBalance') }}</dt>
<dd :class="{ 'is-danger': balanceShortfalls.length }">{{ formatPayMoney(singleBalance) }}</dd> <dd :class="{ 'is-danger': balanceShortfalls.length }">{{ formatPayMoney(singleBalance) }}</dd>
</div> </div>
@ -658,21 +686,46 @@ watch(
</div> </div>
<div>{{ t('order.myOrders.modal.payMultiCustomerWxHint') }}</div> <div>{{ t('order.myOrders.modal.payMultiCustomerWxHint') }}</div>
</a-alert> </a-alert>
<a-alert <div v-else-if="!isMultiCustomer && (canUseAccountBalance || needsWechatPay)" class="pay-method-block">
v-else-if="needsWechatPay" <label v-if="canUseAccountBalance" class="pay-balance-toggle">
type="info" <a-checkbox v-model="useAccountBalance" :disabled="submitting">
show-icon {{ t('order.myOrders.modal.payUseBalance') }}
class="pay-alert" </a-checkbox>
> <span class="pay-balance-toggle__amt">{{ formatPayMoney(singleBalance) }}</span>
{{ t('order.myOrders.modal.payHybridHint', { amount: formatPayMoney(hybridWechatAmount) }) }} </label>
<div class="pay-online-channel"> <div
<span>{{ t('order.myOrders.modal.payOnlineChannel') }}</span> v-if="needsWechatPay"
<a-radio-group v-model="onlinePayChannel" type="button" size="small" :disabled="submitting"> class="pay-method-row"
<a-radio value="wechat">{{ t('order.myOrders.modal.payChannelWechat') }}</a-radio> role="radiogroup"
<a-radio value="alipay">{{ t('order.myOrders.modal.payChannelAlipay') }}</a-radio> :aria-label="t('order.myOrders.modal.payOnlineChannel')"
</a-radio-group> >
<span class="pay-method-row__label">{{ t('order.myOrders.modal.payOnlineChannel') }}</span>
<button
type="button"
class="pay-method-chip"
:class="{ 'is-active': onlinePayChannel === 'wechat' }"
:disabled="submitting"
role="radio"
:aria-checked="onlinePayChannel === 'wechat'"
@click="onlinePayChannel = 'wechat'"
>
<img :src="wxIcon" alt="" />
{{ t('order.myOrders.modal.payChannelWechat') }}
</button>
<button
type="button"
class="pay-method-chip"
:class="{ 'is-active': onlinePayChannel === 'alipay' }"
:disabled="submitting"
role="radio"
:aria-checked="onlinePayChannel === 'alipay'"
@click="onlinePayChannel = 'alipay'"
>
<img :src="zfbIcon" alt="" />
{{ t('order.myOrders.modal.payChannelAlipay') }}
</button>
</div> </div>
</a-alert> </div>
<a-alert v-if="isMulti && blockedOrders.length" type="info" show-icon class="pay-alert"> <a-alert v-if="isMulti && blockedOrders.length" type="info" show-icon class="pay-alert">
{{ t('order.myOrders.modal.paySkipHint', { count: blockedOrders.length }) }} {{ t('order.myOrders.modal.paySkipHint', { count: blockedOrders.length }) }}
</a-alert> </a-alert>
@ -840,26 +893,6 @@ watch(
<template #footer> <template #footer>
<div class="pay-footer"> <div class="pay-footer">
<div class="pay-footer__method">
<template v-if="isMultiCustomer">
{{ t('order.myOrders.modal.payMethodBalance') }}
</template>
<template v-else-if="needsWechatPay">
<span>{{ t('order.myOrders.modal.payMethodHybrid') }}</span>
<span class="pay-footer__split">
{{ t('order.myOrders.modal.paySplitBalance', { amount: formatPayMoney(hybridBalanceUse) }) }}
·
{{
onlinePayChannel === 'alipay'
? t('order.myOrders.modal.paySplitAlipay', { amount: formatPayMoney(hybridWechatAmount) })
: t('order.myOrders.modal.paySplitWechat', { amount: formatPayMoney(hybridWechatAmount) })
}}
</span>
</template>
<template v-else>
{{ t('order.myOrders.modal.payMethodBalance') }}
</template>
</div>
<a-button :disabled="submitting" @click="closeModal">{{ t('warehouse.common.cancel') }}</a-button> <a-button :disabled="submitting" @click="closeModal">{{ t('warehouse.common.cancel') }}</a-button>
<a-button <a-button
type="primary" type="primary"
@ -954,6 +987,10 @@ watch(
&.is-danger { &.is-danger {
color: rgb(var(--danger-6)); color: rgb(var(--danger-6));
} }
&.is-emphasis {
color: var(--app-primary-color);
}
} }
} }
@ -961,12 +998,74 @@ watch(
margin: 0; margin: 0;
} }
.pay-online-channel { .pay-method-block {
display: flex;
flex-direction: column;
gap: 10px;
}
.pay-balance-toggle {
display: inline-flex;
align-items: center;
gap: 10px;
min-height: 32px;
cursor: pointer;
user-select: none;
}
.pay-balance-toggle__amt {
font-size: 13px;
color: var(--color-text-3);
font-variant-numeric: tabular-nums;
}
.pay-method-row {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
margin-top: 8px; }
.pay-method-row__label {
margin-right: 4px;
font-size: 13px;
color: var(--color-text-2);
}
.pay-method-chip {
display: inline-flex;
align-items: center;
gap: 6px;
height: 32px;
padding: 0 12px;
border-radius: 4px;
border: 1px solid var(--color-border-2);
background: #fff;
color: var(--color-text-1);
font-size: 13px;
cursor: pointer;
transition: border-color 0.15s, background 0.15s, color 0.15s;
img {
width: 18px;
height: 18px;
object-fit: contain;
}
&:hover:not(:disabled) {
border-color: color-mix(in srgb, var(--app-primary-color) 40%, var(--color-border-2));
}
&.is-active {
border-color: var(--app-primary-color);
color: var(--app-primary-color);
background: color-mix(in srgb, var(--app-primary-color) 8%, #fff);
}
&:disabled {
opacity: 0.55;
cursor: not-allowed;
}
} }
.pay-list-head { .pay-list-head {
@ -1177,21 +1276,6 @@ watch(
width: 100%; width: 100%;
} }
.pay-footer__method {
margin-right: auto;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 2px;
font-size: 13px;
color: var(--color-text-2);
}
.pay-footer__split {
font-size: 12px;
color: var(--color-text-3);
}
.pay-wx-layer { .pay-wx-layer {
position: absolute; position: absolute;
inset: 0; inset: 0;

View File

@ -339,11 +339,22 @@
</header> </header>
<a-form :model="wechatPayForm" layout="vertical" class="wx-pay-form"> <a-form :model="wechatPayForm" layout="vertical" class="wx-pay-form">
<a-form-item <a-form-item
:label="t('system.otherConfig.paymentQr.wechatPay.mchId')"
required required
:validate-status="wechatPayErrors.mchId ? 'error' : undefined" :validate-status="wechatPayErrors.mchId ? 'error' : undefined"
:help="wechatPayErrors.mchId" :help="wechatPayErrors.mchId"
> >
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.wechatPay.mchId') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.mchIdPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span>
</template>
<a-input <a-input
v-model="wechatPayForm.mchId" v-model="wechatPayForm.mchId"
allow-clear allow-clear
@ -352,11 +363,22 @@
/> />
</a-form-item> </a-form-item>
<a-form-item <a-form-item
:label="t('system.otherConfig.paymentQr.wechatPay.mchSerialNo')"
required required
:validate-status="wechatPayErrors.mchSerialNo ? 'error' : undefined" :validate-status="wechatPayErrors.mchSerialNo ? 'error' : undefined"
:help="wechatPayErrors.mchSerialNo" :help="wechatPayErrors.mchSerialNo"
> >
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.wechatPay.mchSerialNo') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.mchSerialNoPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span>
</template>
<a-input <a-input
v-model="wechatPayForm.mchSerialNo" v-model="wechatPayForm.mchSerialNo"
allow-clear allow-clear
@ -365,11 +387,48 @@
/> />
</a-form-item> </a-form-item>
<a-form-item <a-form-item
:label="t('system.otherConfig.paymentQr.wechatPay.notifyUrl')" required
:validate-status="wechatPayErrors.platformPublicKeyId ? 'error' : undefined"
:help="wechatPayErrors.platformPublicKeyId"
>
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.wechatPay.platformPublicKeyId') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.platformPublicKeyIdPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span>
</template>
<a-input
v-model="wechatPayForm.platformPublicKeyId"
allow-clear
:placeholder="
t('system.otherConfig.paymentQr.wechatPay.platformPublicKeyIdPlaceholder')
"
@input="wechatPayErrors.platformPublicKeyId = ''"
/>
</a-form-item>
<a-form-item
required required
:validate-status="wechatPayErrors.notifyUrl ? 'error' : undefined" :validate-status="wechatPayErrors.notifyUrl ? 'error' : undefined"
:help="wechatPayErrors.notifyUrl" :help="wechatPayErrors.notifyUrl"
> >
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.wechatPay.notifyUrl') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.notifyUrlPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span>
</template>
<div class="wx-pay-field-row"> <div class="wx-pay-field-row">
<a-input <a-input
v-model="wechatPayForm.notifyUrl" v-model="wechatPayForm.notifyUrl"
@ -395,6 +454,13 @@
<template #label> <template #label>
<span class="wx-pay-label"> <span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.wechatPay.apiV3Key') }} {{ t('system.otherConfig.paymentQr.wechatPay.apiV3Key') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.apiV3KeyPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
<span <span
class="wx-pay-tag" class="wx-pay-tag"
:class="wechatPayMeta.hasApiV3Key ? 'is-ok' : 'is-miss'" :class="wechatPayMeta.hasApiV3Key ? 'is-ok' : 'is-miss'"
@ -421,6 +487,13 @@
<template #label> <template #label>
<span class="wx-pay-label"> <span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.wechatPay.privateKeyPem') }} {{ t('system.otherConfig.paymentQr.wechatPay.privateKeyPem') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.privateKeyPemPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
<span <span
class="wx-pay-tag" class="wx-pay-tag"
:class="wechatPayMeta.hasPrivateKey ? 'is-ok' : 'is-miss'" :class="wechatPayMeta.hasPrivateKey ? 'is-ok' : 'is-miss'"
@ -437,7 +510,7 @@
<a-textarea <a-textarea
v-model="wechatPayForm.privateKeyPem" v-model="wechatPayForm.privateKeyPem"
class="wx-pay-pem" class="wx-pay-pem"
:auto-size="{ minRows: 5, maxRows: 12 }" :auto-size="{ minRows: 4, maxRows: 10 }"
:placeholder=" :placeholder="
wechatPayMeta.hasPrivateKey wechatPayMeta.hasPrivateKey
? t('system.otherConfig.paymentQr.wechatPay.privateKeyPlaceholder') ? t('system.otherConfig.paymentQr.wechatPay.privateKeyPlaceholder')
@ -464,6 +537,60 @@
</div> </div>
</div> </div>
</a-form-item> </a-form-item>
<a-form-item>
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.wechatPay.platformPublicKeyPem') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.platformPublicKeyPemPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
<span
class="wx-pay-tag"
:class="wechatPayMeta.hasPlatformPublicKey ? 'is-ok' : 'is-miss'"
>
{{
wechatPayMeta.hasPlatformPublicKey
? t('system.otherConfig.paymentQr.wechatPay.hasKey')
: t('system.otherConfig.paymentQr.wechatPay.missingKey')
}}
</span>
</span>
</template>
<div class="wx-pay-pem-block">
<a-textarea
v-model="wechatPayForm.platformPublicKeyPem"
class="wx-pay-pem"
:auto-size="{ minRows: 4, maxRows: 10 }"
:placeholder="
wechatPayMeta.hasPlatformPublicKey
? t('system.otherConfig.paymentQr.wechatPay.platformPublicKeyPlaceholder')
: t('system.otherConfig.paymentQr.wechatPay.platformPublicKeyRequired')
"
/>
<div class="wx-pay-pem-actions">
<label class="wx-pay-file">
<input
type="file"
accept=".pem,.key,text/plain"
@change="onWechatPayPublicPemFile"
/>
{{ t('system.otherConfig.paymentQr.wechatPay.importPem') }}
</label>
<button
v-if="wechatPayForm.platformPublicKeyPem"
type="button"
class="wx-pay-link-btn"
@click="wechatPayForm.platformPublicKeyPem = ''"
>
{{ t('system.otherConfig.paymentQr.wechatPay.clearPem') }}
</button>
</div>
</div>
</a-form-item>
</a-form> </a-form>
</section> </section>
@ -476,6 +603,13 @@
<div class="wx-pay-bind__field"> <div class="wx-pay-bind__field">
<span class="wx-pay-bind__label"> <span class="wx-pay-bind__label">
{{ t('system.otherConfig.paymentQr.wechatPay.appId') }} {{ t('system.otherConfig.paymentQr.wechatPay.appId') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.wechatPay.appIdPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span> </span>
<code v-if="wechatPayMeta.appId" class="wx-pay-bind__value"> <code v-if="wechatPayMeta.appId" class="wx-pay-bind__value">
{{ wechatPayMeta.appId }} {{ wechatPayMeta.appId }}
@ -580,11 +714,22 @@
</header> </header>
<a-form :model="alipayPayForm" layout="vertical" class="wx-pay-form"> <a-form :model="alipayPayForm" layout="vertical" class="wx-pay-form">
<a-form-item <a-form-item
:label="t('system.otherConfig.paymentQr.alipayPay.appId')"
required required
:validate-status="alipayPayErrors.appId ? 'error' : undefined" :validate-status="alipayPayErrors.appId ? 'error' : undefined"
:help="alipayPayErrors.appId" :help="alipayPayErrors.appId"
> >
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.alipayPay.appId') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.alipayPay.appIdPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span>
</template>
<a-input <a-input
v-model="alipayPayForm.appId" v-model="alipayPayForm.appId"
allow-clear allow-clear
@ -593,11 +738,22 @@
/> />
</a-form-item> </a-form-item>
<a-form-item <a-form-item
:label="t('system.otherConfig.paymentQr.alipayPay.notifyUrl')"
required required
:validate-status="alipayPayErrors.notifyUrl ? 'error' : undefined" :validate-status="alipayPayErrors.notifyUrl ? 'error' : undefined"
:help="alipayPayErrors.notifyUrl" :help="alipayPayErrors.notifyUrl"
> >
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.alipayPay.notifyUrl') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.alipayPay.notifyUrlPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span>
</template>
<div class="wx-pay-field-row"> <div class="wx-pay-field-row">
<a-input <a-input
v-model="alipayPayForm.notifyUrl" v-model="alipayPayForm.notifyUrl"
@ -610,7 +766,19 @@
</a-button> </a-button>
</div> </div>
</a-form-item> </a-form-item>
<a-form-item :label="t('system.otherConfig.paymentQr.alipayPay.returnUrl')"> <a-form-item>
<template #label>
<span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.alipayPay.returnUrl') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.alipayPay.returnUrlPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
</span>
</template>
<a-input <a-input
v-model="alipayPayForm.returnUrl" v-model="alipayPayForm.returnUrl"
allow-clear allow-clear
@ -630,6 +798,13 @@
<template #label> <template #label>
<span class="wx-pay-label"> <span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.alipayPay.privateKeyPem') }} {{ t('system.otherConfig.paymentQr.alipayPay.privateKeyPem') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.alipayPay.privateKeyPemPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
<span <span
class="wx-pay-tag" class="wx-pay-tag"
:class="alipayPayMeta.hasPrivateKey ? 'is-ok' : 'is-miss'" :class="alipayPayMeta.hasPrivateKey ? 'is-ok' : 'is-miss'"
@ -677,6 +852,13 @@
<template #label> <template #label>
<span class="wx-pay-label"> <span class="wx-pay-label">
{{ t('system.otherConfig.paymentQr.alipayPay.alipayPublicKey') }} {{ t('system.otherConfig.paymentQr.alipayPay.alipayPublicKey') }}
<a-tooltip
:content="t('system.otherConfig.paymentQr.alipayPay.alipayPublicKeyPath')"
position="top"
:content-style="{ maxWidth: '360px' }"
>
<IconQuestionCircle class="wechat-notify-editor__help-icon" />
</a-tooltip>
<span <span
class="wx-pay-tag" class="wx-pay-tag"
:class="alipayPayMeta.hasAlipayPublicKey ? 'is-ok' : 'is-miss'" :class="alipayPayMeta.hasAlipayPublicKey ? 'is-ok' : 'is-miss'"
@ -2236,27 +2418,33 @@ const wechatPayMeta = reactive({
configured: false, configured: false,
hasApiV3Key: false, hasApiV3Key: false,
hasPrivateKey: false, hasPrivateKey: false,
hasPlatformPublicKey: false,
appId: '' as string | undefined, appId: '' as string | undefined,
}) })
const wechatPayForm = reactive({ const wechatPayForm = reactive({
enabled: false, enabled: false,
mchId: '', mchId: '',
mchSerialNo: '', mchSerialNo: '',
platformPublicKeyId: '',
notifyUrl: '', notifyUrl: '',
apiV3Key: '', apiV3Key: '',
privateKeyPem: '', privateKeyPem: '',
platformPublicKeyPem: '',
}) })
const wechatPaySnapshot = reactive({ const wechatPaySnapshot = reactive({
enabled: false, enabled: false,
mchId: '', mchId: '',
mchSerialNo: '', mchSerialNo: '',
platformPublicKeyId: '',
notifyUrl: '', notifyUrl: '',
apiV3Key: '', apiV3Key: '',
privateKeyPem: '', privateKeyPem: '',
platformPublicKeyPem: '',
}) })
const wechatPayErrors = reactive({ const wechatPayErrors = reactive({
mchId: '', mchId: '',
mchSerialNo: '', mchSerialNo: '',
platformPublicKeyId: '',
notifyUrl: '', notifyUrl: '',
}) })
const bankAccountLoading = ref(false) const bankAccountLoading = ref(false)
@ -2271,9 +2459,11 @@ const wechatPayDirty = computed(() => {
wechatPayForm.enabled !== wechatPaySnapshot.enabled || wechatPayForm.enabled !== wechatPaySnapshot.enabled ||
wechatPayForm.mchId !== wechatPaySnapshot.mchId || wechatPayForm.mchId !== wechatPaySnapshot.mchId ||
wechatPayForm.mchSerialNo !== wechatPaySnapshot.mchSerialNo || wechatPayForm.mchSerialNo !== wechatPaySnapshot.mchSerialNo ||
wechatPayForm.platformPublicKeyId !== wechatPaySnapshot.platformPublicKeyId ||
wechatPayForm.notifyUrl !== wechatPaySnapshot.notifyUrl || wechatPayForm.notifyUrl !== wechatPaySnapshot.notifyUrl ||
wechatPayForm.apiV3Key !== wechatPaySnapshot.apiV3Key || wechatPayForm.apiV3Key !== wechatPaySnapshot.apiV3Key ||
wechatPayForm.privateKeyPem !== wechatPaySnapshot.privateKeyPem wechatPayForm.privateKeyPem !== wechatPaySnapshot.privateKeyPem ||
wechatPayForm.platformPublicKeyPem !== wechatPaySnapshot.platformPublicKeyPem
) )
}) })
@ -2282,9 +2472,11 @@ const wechatPayReady = computed(() => {
wechatPayForm.enabled && wechatPayForm.enabled &&
!!wechatPayForm.mchId.trim() && !!wechatPayForm.mchId.trim() &&
!!wechatPayForm.mchSerialNo.trim() && !!wechatPayForm.mchSerialNo.trim() &&
!!wechatPayForm.platformPublicKeyId.trim() &&
!!wechatPayForm.notifyUrl.trim() && !!wechatPayForm.notifyUrl.trim() &&
(wechatPayMeta.hasApiV3Key || !!wechatPayForm.apiV3Key.trim()) && (wechatPayMeta.hasApiV3Key || !!wechatPayForm.apiV3Key.trim()) &&
(wechatPayMeta.hasPrivateKey || !!wechatPayForm.privateKeyPem.trim()) && (wechatPayMeta.hasPrivateKey || !!wechatPayForm.privateKeyPem.trim()) &&
(wechatPayMeta.hasPlatformPublicKey || !!wechatPayForm.platformPublicKeyPem.trim()) &&
!!wechatPayMeta.appId !!wechatPayMeta.appId
) )
}) })
@ -2292,7 +2484,10 @@ const wechatPayReady = computed(() => {
const wechatPayChecklist = computed(() => [ const wechatPayChecklist = computed(() => [
{ {
key: 'mch', key: 'mch',
ok: !!wechatPayForm.mchId.trim() && !!wechatPayForm.mchSerialNo.trim(), ok:
!!wechatPayForm.mchId.trim() &&
!!wechatPayForm.mchSerialNo.trim() &&
!!wechatPayForm.platformPublicKeyId.trim(),
label: t('system.otherConfig.paymentQr.wechatPay.checkMerchant'), label: t('system.otherConfig.paymentQr.wechatPay.checkMerchant'),
}, },
{ {
@ -2302,8 +2497,10 @@ const wechatPayChecklist = computed(() => [
}, },
{ {
key: 'secret', key: 'secret',
ok: (wechatPayMeta.hasApiV3Key || !!wechatPayForm.apiV3Key.trim()) && ok:
(wechatPayMeta.hasPrivateKey || !!wechatPayForm.privateKeyPem.trim()), (wechatPayMeta.hasApiV3Key || !!wechatPayForm.apiV3Key.trim()) &&
(wechatPayMeta.hasPrivateKey || !!wechatPayForm.privateKeyPem.trim()) &&
(wechatPayMeta.hasPlatformPublicKey || !!wechatPayForm.platformPublicKeyPem.trim()),
label: t('system.otherConfig.paymentQr.wechatPay.checkSecret'), label: t('system.otherConfig.paymentQr.wechatPay.checkSecret'),
}, },
{ {
@ -2321,9 +2518,11 @@ function applyWechatPaySnapshot() {
wechatPaySnapshot.enabled = wechatPayForm.enabled wechatPaySnapshot.enabled = wechatPayForm.enabled
wechatPaySnapshot.mchId = wechatPayForm.mchId wechatPaySnapshot.mchId = wechatPayForm.mchId
wechatPaySnapshot.mchSerialNo = wechatPayForm.mchSerialNo wechatPaySnapshot.mchSerialNo = wechatPayForm.mchSerialNo
wechatPaySnapshot.platformPublicKeyId = wechatPayForm.platformPublicKeyId
wechatPaySnapshot.notifyUrl = wechatPayForm.notifyUrl wechatPaySnapshot.notifyUrl = wechatPayForm.notifyUrl
wechatPaySnapshot.apiV3Key = wechatPayForm.apiV3Key wechatPaySnapshot.apiV3Key = wechatPayForm.apiV3Key
wechatPaySnapshot.privateKeyPem = wechatPayForm.privateKeyPem wechatPaySnapshot.privateKeyPem = wechatPayForm.privateKeyPem
wechatPaySnapshot.platformPublicKeyPem = wechatPayForm.platformPublicKeyPem
} }
function fillWechatPayNotifyUrl() { function fillWechatPayNotifyUrl() {
@ -2335,11 +2534,14 @@ function resetWechatPayForm() {
wechatPayForm.enabled = wechatPaySnapshot.enabled wechatPayForm.enabled = wechatPaySnapshot.enabled
wechatPayForm.mchId = wechatPaySnapshot.mchId wechatPayForm.mchId = wechatPaySnapshot.mchId
wechatPayForm.mchSerialNo = wechatPaySnapshot.mchSerialNo wechatPayForm.mchSerialNo = wechatPaySnapshot.mchSerialNo
wechatPayForm.platformPublicKeyId = wechatPaySnapshot.platformPublicKeyId
wechatPayForm.notifyUrl = wechatPaySnapshot.notifyUrl wechatPayForm.notifyUrl = wechatPaySnapshot.notifyUrl
wechatPayForm.apiV3Key = wechatPaySnapshot.apiV3Key wechatPayForm.apiV3Key = wechatPaySnapshot.apiV3Key
wechatPayForm.privateKeyPem = wechatPaySnapshot.privateKeyPem wechatPayForm.privateKeyPem = wechatPaySnapshot.privateKeyPem
wechatPayForm.platformPublicKeyPem = wechatPaySnapshot.platformPublicKeyPem
wechatPayErrors.mchId = '' wechatPayErrors.mchId = ''
wechatPayErrors.mchSerialNo = '' wechatPayErrors.mchSerialNo = ''
wechatPayErrors.platformPublicKeyId = ''
wechatPayErrors.notifyUrl = '' wechatPayErrors.notifyUrl = ''
} }
@ -2369,6 +2571,24 @@ async function onWechatPayPemFile(ev: Event) {
Message.error(t('system.otherConfig.paymentQr.wechatPay.pemReadFailed')) Message.error(t('system.otherConfig.paymentQr.wechatPay.pemReadFailed'))
} }
} }
async function onWechatPayPublicPemFile(ev: Event) {
const input = ev.target as HTMLInputElement
const file = input.files?.[0]
input.value = ''
if (!file) return
try {
const text = await file.text()
if (!text.includes('BEGIN PUBLIC KEY')) {
Message.warning(t('system.otherConfig.paymentQr.wechatPay.publicPemInvalid'))
return
}
wechatPayForm.platformPublicKeyPem = text.trim()
Message.success(t('system.otherConfig.paymentQr.wechatPay.publicPemImported'))
} catch {
Message.error(t('system.otherConfig.paymentQr.wechatPay.pemReadFailed'))
}
}
const bankAccountRows = ref<FinanceCompanyAccount[]>([]) const bankAccountRows = ref<FinanceCompanyAccount[]>([])
const bankAccountFormVisible = ref(false) const bankAccountFormVisible = ref(false)
const bankAccountSaving = ref(false) const bankAccountSaving = ref(false)
@ -2401,15 +2621,19 @@ async function loadWechatPayMerchant() {
wechatPayForm.enabled = cfg.enabled wechatPayForm.enabled = cfg.enabled
wechatPayForm.mchId = cfg.mchId wechatPayForm.mchId = cfg.mchId
wechatPayForm.mchSerialNo = cfg.mchSerialNo wechatPayForm.mchSerialNo = cfg.mchSerialNo
wechatPayForm.platformPublicKeyId = cfg.platformPublicKeyId
wechatPayForm.notifyUrl = cfg.notifyUrl wechatPayForm.notifyUrl = cfg.notifyUrl
wechatPayForm.apiV3Key = '' wechatPayForm.apiV3Key = ''
wechatPayForm.privateKeyPem = '' wechatPayForm.privateKeyPem = ''
wechatPayForm.platformPublicKeyPem = ''
wechatPayMeta.configured = cfg.configured wechatPayMeta.configured = cfg.configured
wechatPayMeta.hasApiV3Key = cfg.hasApiV3Key wechatPayMeta.hasApiV3Key = cfg.hasApiV3Key
wechatPayMeta.hasPrivateKey = cfg.hasPrivateKey wechatPayMeta.hasPrivateKey = cfg.hasPrivateKey
wechatPayMeta.hasPlatformPublicKey = cfg.hasPlatformPublicKey
wechatPayMeta.appId = cfg.appId wechatPayMeta.appId = cfg.appId
wechatPayErrors.mchId = '' wechatPayErrors.mchId = ''
wechatPayErrors.mchSerialNo = '' wechatPayErrors.mchSerialNo = ''
wechatPayErrors.platformPublicKeyId = ''
wechatPayErrors.notifyUrl = '' wechatPayErrors.notifyUrl = ''
applyWechatPaySnapshot() applyWechatPaySnapshot()
} catch (e) { } catch (e) {
@ -2423,6 +2647,7 @@ function validateWechatPayForm(): boolean {
let ok = true let ok = true
wechatPayErrors.mchId = '' wechatPayErrors.mchId = ''
wechatPayErrors.mchSerialNo = '' wechatPayErrors.mchSerialNo = ''
wechatPayErrors.platformPublicKeyId = ''
wechatPayErrors.notifyUrl = '' wechatPayErrors.notifyUrl = ''
if (!wechatPayForm.mchId.trim()) { if (!wechatPayForm.mchId.trim()) {
wechatPayErrors.mchId = t('system.otherConfig.paymentQr.wechatPay.needMchId') wechatPayErrors.mchId = t('system.otherConfig.paymentQr.wechatPay.needMchId')
@ -2432,6 +2657,10 @@ function validateWechatPayForm(): boolean {
wechatPayErrors.mchSerialNo = t('system.otherConfig.paymentQr.wechatPay.needSerial') wechatPayErrors.mchSerialNo = t('system.otherConfig.paymentQr.wechatPay.needSerial')
ok = false ok = false
} }
if (!wechatPayForm.platformPublicKeyId.trim()) {
wechatPayErrors.platformPublicKeyId = t('system.otherConfig.paymentQr.wechatPay.needPublicKeyId')
ok = false
}
if (!wechatPayForm.notifyUrl.trim()) { if (!wechatPayForm.notifyUrl.trim()) {
wechatPayErrors.notifyUrl = t('system.otherConfig.paymentQr.wechatPay.needNotify') wechatPayErrors.notifyUrl = t('system.otherConfig.paymentQr.wechatPay.needNotify')
ok = false ok = false
@ -2447,6 +2676,10 @@ function validateWechatPayForm(): boolean {
Message.warning(t('system.otherConfig.paymentQr.wechatPay.needPrivateKey')) Message.warning(t('system.otherConfig.paymentQr.wechatPay.needPrivateKey'))
ok = false ok = false
} }
if (!wechatPayMeta.hasPlatformPublicKey && !wechatPayForm.platformPublicKeyPem.trim()) {
Message.warning(t('system.otherConfig.paymentQr.wechatPay.needPlatformPublicKey'))
ok = false
}
return ok return ok
} }
@ -2458,19 +2691,24 @@ async function handleWechatPaySave() {
enabled: wechatPayForm.enabled, enabled: wechatPayForm.enabled,
mchId: wechatPayForm.mchId.trim(), mchId: wechatPayForm.mchId.trim(),
mchSerialNo: wechatPayForm.mchSerialNo.trim(), mchSerialNo: wechatPayForm.mchSerialNo.trim(),
platformPublicKeyId: wechatPayForm.platformPublicKeyId.trim(),
notifyUrl: wechatPayForm.notifyUrl.trim() || undefined, notifyUrl: wechatPayForm.notifyUrl.trim() || undefined,
apiV3Key: wechatPayForm.apiV3Key.trim() || undefined, apiV3Key: wechatPayForm.apiV3Key.trim() || undefined,
privateKeyPem: wechatPayForm.privateKeyPem.trim() || undefined, privateKeyPem: wechatPayForm.privateKeyPem.trim() || undefined,
platformPublicKeyPem: wechatPayForm.platformPublicKeyPem.trim() || undefined,
}) })
wechatPayForm.apiV3Key = '' wechatPayForm.apiV3Key = ''
wechatPayForm.privateKeyPem = '' wechatPayForm.privateKeyPem = ''
wechatPayForm.platformPublicKeyPem = ''
wechatPayForm.enabled = cfg.enabled wechatPayForm.enabled = cfg.enabled
wechatPayForm.mchId = cfg.mchId wechatPayForm.mchId = cfg.mchId
wechatPayForm.mchSerialNo = cfg.mchSerialNo wechatPayForm.mchSerialNo = cfg.mchSerialNo
wechatPayForm.platformPublicKeyId = cfg.platformPublicKeyId
wechatPayForm.notifyUrl = cfg.notifyUrl wechatPayForm.notifyUrl = cfg.notifyUrl
wechatPayMeta.configured = cfg.configured wechatPayMeta.configured = cfg.configured
wechatPayMeta.hasApiV3Key = cfg.hasApiV3Key wechatPayMeta.hasApiV3Key = cfg.hasApiV3Key
wechatPayMeta.hasPrivateKey = cfg.hasPrivateKey wechatPayMeta.hasPrivateKey = cfg.hasPrivateKey
wechatPayMeta.hasPlatformPublicKey = cfg.hasPlatformPublicKey
wechatPayMeta.appId = cfg.appId wechatPayMeta.appId = cfg.appId
applyWechatPaySnapshot() applyWechatPaySnapshot()
Message.success(t('system.otherConfig.paymentQr.wechatPay.saveSuccess')) Message.success(t('system.otherConfig.paymentQr.wechatPay.saveSuccess'))
@ -4357,6 +4595,9 @@ onMounted(() => {
} }
.wx-pay-bind__label { .wx-pay-bind__label {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 12px; font-size: 12px;
color: var(--color-text-3); color: var(--color-text-3);
} }

View File

@ -584,6 +584,8 @@ export default defineConfig(({ mode }) => {
cssCodeSplit: true, cssCodeSplit: true,
// 生成 source map(默认关闭,避免线上包体积变大;需要排查问题时可临时打开) // 生成 source map(默认关闭,避免线上包体积变大;需要排查问题时可临时打开)
sourcemap: false, sourcemap: false,
// 跳过 gzip 体积统计:chunk 多时收尾很吃 CPU/内存(8c16g 生产+CI 同机更明显)
reportCompressedSize: false,
// 构建输出配置:使用 Vite 默认的代码分割策略,避免过度自定义导致库初始化顺序问题 // 构建输出配置:使用 Vite 默认的代码分割策略,避免过度自定义导致库初始化顺序问题
rollupOptions: { rollupOptions: {
onwarn(warning, warn) { onwarn(warning, warn) {