接入顺成支付并优化配置列表

This commit is contained in:
yml
2026-06-18 21:33:15 +08:00
parent 40ae14d450
commit 6d385478a6
13 changed files with 1763 additions and 40 deletions
@@ -34,6 +34,11 @@ const defaultGateways: Record<string, string> = {
mock: '',
}
const shunchengGateways: Record<string, string> = {
production: 'http://jyzxapi.ydxnhb.com',
sandbox: 'http://jyzxapi.ydxnhb.com',
}
const lakalaGateways: Record<string, string> = {
production: 'https://s2.lakala.com',
sandbox: 'https://test.wsmsd.cn/sit',
@@ -42,12 +47,14 @@ const lakalaGateways: Record<string, string> = {
const defaultNotifyURLs: Record<string, string> = {
leshua: 'https://hao858.com/api/payments/leshua/notify',
lakala: 'https://hao858.com/api/payments/lakala/notify',
shuncheng: 'https://hao858.com/api/payments/shuncheng/notify',
mock: '',
}
const defaultJumpURLs: Record<string, string> = {
leshua: 'https://hao858.com/orders',
lakala: 'https://hao858.com/orders',
shuncheng: 'https://hao858.com/orders',
mock: '',
}
@@ -66,6 +73,9 @@ function defaultGateway(provider: string, environment = defaultEnvironment(provi
if (provider === 'lakala') {
return lakalaGateways[environment] || lakalaGateways.production
}
if (provider === 'shuncheng') {
return shunchengGateways[environment] || shunchengGateways.production
}
return defaultGateways[provider] || ''
}
@@ -74,6 +84,11 @@ function isDefaultLakalaGateway(value?: string) {
return !value || Object.values(lakalaGateways).includes(value)
}
// isDefaultShunchengGateway 判断当前网关是否仍是顺成系统默认值。
function isDefaultShunchengGateway(value?: string) {
return !value || Object.values(shunchengGateways).includes(value)
}
function defaultExtraConfig(provider: string) {
if (provider === 'lakala') {
return {
@@ -85,6 +100,14 @@ function defaultExtraConfig(provider: string) {
order_expire_minutes: 15,
}
}
if (provider === 'shuncheng') {
return {
secret_id: '',
shop_no: '',
refund_type: '',
token_refresh_margin_seconds: 300,
}
}
return {}
}
@@ -125,8 +148,13 @@ const dialogTitle = computed(() => {
const isReadonly = computed(() => props.mode === 'view')
const isLakala = computed(() => formData.value.provider === 'lakala')
const isShuncheng = computed(() => formData.value.provider === 'shuncheng')
const isMock = computed(() => formData.value.provider === 'mock')
const signKeyLabel = computed(() => (isLakala.value ? '商户私钥' : '签名密钥'))
const signKeyLabel = computed(() => {
if (isLakala.value) return '商户私钥'
if (isShuncheng.value) return 'SecretKey'
return '签名密钥'
})
const notifyKeyLabel = computed(() => (isLakala.value ? '通知证书' : '通知密钥'))
const extraConfig = computed<Record<string, any>>(() => formData.value.extra_config || {})
@@ -200,10 +228,15 @@ function handlePayWayChange(payWay: string | number | boolean) {
syncLakalaPayMode(String(payWay))
}
// handleEnvironmentChange 处理环境切换,并同步拉卡拉默认网关。
// handleEnvironmentChange 处理环境切换,并同步渠道默认网关。
function handleEnvironmentChange(environment: string) {
if (!isLakala.value || !isDefaultLakalaGateway(formData.value.gateway_url)) return
formData.value.gateway_url = defaultGateway('lakala', environment)
if (isLakala.value && isDefaultLakalaGateway(formData.value.gateway_url)) {
formData.value.gateway_url = defaultGateway('lakala', environment)
return
}
if (isShuncheng.value && isDefaultShunchengGateway(formData.value.gateway_url)) {
formData.value.gateway_url = defaultGateway('shuncheng', environment)
}
}
async function handleViewSecrets() {
@@ -284,6 +317,7 @@ function handleClose() {
>
<el-option label="乐刷支付" value="leshua" />
<el-option label="拉卡拉支付" value="lakala" />
<el-option label="顺成支付" value="shuncheng" />
<el-option label="模拟支付" value="mock" />
</el-select>
</el-form-item>
@@ -328,6 +362,14 @@ function handleClose() {
<el-input v-model="extraConfig.term_no" placeholder="拉卡拉终端号" :disabled="isReadonly" />
</el-form-item>
<el-form-item v-if="isShuncheng" label="Secret ID" required>
<el-input
v-model="extraConfig.secret_id"
placeholder="顺成接口调用凭据 SecretId"
:disabled="isReadonly"
/>
</el-form-item>
<el-form-item v-if="!isMock" :label="signKeyLabel" required>
<el-input
v-model="formData.sign_key"
@@ -436,6 +478,37 @@ function handleClose() {
/>
</el-form-item>
<el-form-item v-if="isShuncheng" label="门店编号">
<el-input
v-model="extraConfig.shop_no"
placeholder="可选,顺成商户门店编号"
:disabled="isReadonly"
/>
</el-form-item>
<el-form-item v-if="isShuncheng" label="退款出资">
<el-select
v-model="extraConfig.refund_type"
clearable
placeholder="使用顺成默认规则"
:disabled="isReadonly"
>
<el-option label="顺成默认" value="" />
<el-option label="当日交易抵扣" value="0" />
<el-option label="优先交易抵扣,不足走余额" value="1" />
<el-option label="仅商户余额" value="2" />
</el-select>
</el-form-item>
<el-form-item v-if="isShuncheng" label="Token刷新秒">
<el-input-number
v-model="extraConfig.token_refresh_margin_seconds"
:min="60"
:max="1800"
:disabled="isReadonly"
/>
</el-form-item>
<el-form-item label="支付形态">
<el-select v-model="formData.jspay_flag" :disabled="isReadonly">
<el-option label="H5 / JSAPI" value="1" />