小程序配置增加用户指定收款商户绑定管理。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-15 01:19:37 +08:00
parent 75417417e5
commit a6d339c473

View File

@@ -177,7 +177,7 @@
:closable="false" :closable="false"
show-icon show-icon
class="shop-hint" class="shop-hint"
title="仅影响用户收款发起的微信商家转账按优先级从小到大尝试某号失败余额不足/限额等自动换下一号发起成功后打款单会强制记录 mch_id回调按该记录处理" title="仅影响用户收款未绑定用户按优先级发起仅当微信官方返回超出商户单日/单月转账额度且查单确认未建单时才静默换下一号个人受限/余额不足等不换号下方可给指定用户绑定固定商户绑定后强制只用该号已发出待确认单不会因改绑新建第二笔"
/> />
<div class="asset-toolbar"> <div class="asset-toolbar">
<el-button type="primary" @click="openMchDialog()">新增商户</el-button> <el-button type="primary" @click="openMchDialog()">新增商户</el-button>
@@ -273,6 +273,77 @@
<el-button type="primary" :loading="mchSaving" @click="saveMch">保存</el-button> <el-button type="primary" :loading="mchSaving" @click="saveMch">保存</el-button>
</template> </template>
</el-dialog> </el-dialog>
<el-divider content-position="left">用户指定商户</el-divider>
<el-alert
type="info"
:closable="false"
show-icon
class="shop-hint"
title="绑定用户强制使用所选商户不再自动轮换实时改绑立刻影响下一次新建打款若该用户已有微信待确认单仍只能确认原单防双笔"
/>
<div class="asset-toolbar">
<el-input
v-model="bindFilterYonghuid"
placeholder="按用户ID筛选"
clearable
style="width: 200px"
@keyup.enter="loadBindList"
/>
<el-button type="primary" @click="openBindDialog()">新增绑定</el-button>
<el-button @click="loadBindList">刷新</el-button>
</div>
<el-table :data="bindList" v-loading="bindLoading" border>
<el-table-column prop="yonghuid" label="用户ID" min-width="120" />
<el-table-column prop="mch_id" label="商户号" min-width="120" />
<el-table-column prop="mch_name" label="商户备注" min-width="100" />
<el-table-column label="绑定启用" width="90">
<template #default="{ row }">
<el-tag :type="row.enabled ? 'success' : 'info'" size="small">{{ row.enabled ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="商户启用" width="90">
<template #default="{ row }">
<el-tag :type="row.mch_enabled ? 'success' : 'danger'" size="small">{{ row.mch_enabled ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="120" />
<el-table-column prop="update_time" label="更新时间" min-width="160" />
<el-table-column label="操作" width="160" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openBindDialog(row)">编辑</el-button>
<el-button link type="danger" @click="deleteBind(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog v-model="bindDialogVisible" :title="bindForm.id ? '编辑用户绑定' : '新增用户绑定'" width="520px" destroy-on-close>
<el-form label-width="100px">
<el-form-item label="用户ID" required>
<el-input v-model="bindForm.yonghuid" :disabled="!!bindForm.id" placeholder="小程序用户 yonghuid" />
</el-form-item>
<el-form-item label="商户号" required>
<el-select v-model="bindForm.mch_id" filterable placeholder="选择商户" style="width: 100%">
<el-option
v-for="m in mchList"
:key="m.mch_id"
:label="`${m.mch_id}${m.name ? ' (' + m.name + ')' : ''}${m.enabled ? '' : ' [停用]'}`"
:value="m.mch_id"
/>
</el-select>
</el-form-item>
<el-form-item label="启用">
<el-switch v-model="bindForm.enabled" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="bindForm.remark" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="bindDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="bindSaving" @click="saveBind">保存</el-button>
</template>
</el-dialog>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
@@ -333,6 +404,111 @@ const mchForm = reactive({
platform_pub_key_path: '', platform_pub_key_path: '',
}) })
const bindLoading = ref(false)
const bindSaving = ref(false)
const bindList = ref([])
const bindFilterYonghuid = ref('')
const bindDialogVisible = ref(false)
const bindForm = reactive({
id: null,
yonghuid: '',
mch_id: '',
enabled: true,
remark: '',
})
const loadBindList = async () => {
bindLoading.value = true
try {
const res = await request.post('/peizhi/wxmchUserLb', {
username: username.value,
yonghuid: bindFilterYonghuid.value || '',
page: 1,
limit: 100,
})
if (res.code === 403) {
hasPermission.value = false
return
}
if (res.code === 0 && res.data) {
bindList.value = res.data.list || []
} else {
ElMessage.error(res.msg || '加载用户绑定失败')
}
} catch {
ElMessage.error('网络错误')
} finally {
bindLoading.value = false
}
}
const openBindDialog = (row) => {
if (row) {
Object.assign(bindForm, {
id: row.id,
yonghuid: row.yonghuid,
mch_id: row.mch_id,
enabled: !!row.enabled,
remark: row.remark || '',
})
} else {
Object.assign(bindForm, {
id: null,
yonghuid: '',
mch_id: mchList.value.find((m) => m.enabled)?.mch_id || '',
enabled: true,
remark: '',
})
}
bindDialogVisible.value = true
}
const saveBind = async () => {
if (!bindForm.yonghuid || !bindForm.mch_id) {
ElMessage.warning('请填写用户ID并选择商户号')
return
}
bindSaving.value = true
try {
const res = await request.post('/peizhi/wxmchUserBj', {
username: username.value,
id: bindForm.id,
yonghuid: String(bindForm.yonghuid).trim(),
mch_id: bindForm.mch_id,
enabled: bindForm.enabled,
remark: bindForm.remark,
})
if (res.code === 0) {
ElMessage.success(res.msg || '保存成功')
bindDialogVisible.value = false
await loadBindList()
} else {
ElMessage.error(res.msg || '保存失败')
}
} catch {
ElMessage.error('网络错误')
} finally {
bindSaving.value = false
}
}
const deleteBind = async (row) => {
try {
const res = await request.post('/peizhi/wxmchUserSc', {
username: username.value,
id: row.id,
})
if (res.code === 0) {
ElMessage.success('已删除')
await loadBindList()
} else {
ElMessage.error(res.msg || '删除失败')
}
} catch {
ElMessage.error('网络错误')
}
}
const loadMchList = async () => { const loadMchList = async () => {
mchLoading.value = true mchLoading.value = true
try { try {
@@ -604,6 +780,7 @@ onMounted(() => {
loadSysConfig() loadSysConfig()
loadAssets() loadAssets()
loadMchList() loadMchList()
loadBindList()
}) })
</script> </script>