Commit d61ce80c by zhuzhequan

feat:需求功能完善

parent 1997abcf
import axios from '../axios'
/**
* 付款账户管理 - 请求方法
* 说明:后端接口暂未联调,当前数据使用本地 mock;
* 联调时只需将函数体内的 mock 逻辑替换为真实 axios 请求即可(URL 已注释)。
*/
// ==================== mock 数据 ====================
let paymentAccountList = [
{
id: 1,
accountName: '九猫科技团队CNY账户',
accountNo: 'CNY260804001',
balance: 12800.5,
totalRecharge: 20000,
arrears: 0,
currency: 'CNY',
creator: '张三',
createTime: '2026-08-04 10:20:33',
hasDetail: true
},
{
id: 2,
accountName: '一衣蔓蔓团队CNY账户',
accountNo: 'CNY260804002',
balance: 5632,
totalRecharge: 8000,
arrears: 0,
currency: 'CNY',
creator: '张三',
createTime: '2026-08-04 10:25:11',
hasDetail: false
},
{
id: 3,
accountName: '一本万利团队CNY账户',
accountNo: 'CNY260804003',
balance: 0,
totalRecharge: 5000,
arrears: 300,
currency: 'CNY',
creator: '李四',
createTime: '2026-08-04 10:30:45',
hasDetail: true
},
{
id: 4,
accountName: '九猫海外业务USD账户',
accountNo: 'USD260804001',
balance: 2200,
totalRecharge: 5000,
arrears: 0,
currency: 'USD',
creator: '李四',
createTime: '2026-08-05 09:12:08',
hasDetail: false
}
]
let rechargeRecordList = [
{
id: 1,
accountId: 1,
rechargeNo: 'CZ20260805001',
status: '充值成功',
payType: '支付宝扫码充值',
currency: 'CNY',
amount: 10000,
serviceFee: 0,
actualAmount: 10000,
remark: '线下充值',
createTime: '2026-08-05 14:00:00'
},
{
id: 2,
accountId: 1,
rechargeNo: 'CZ20260804002',
status: '充值中',
payType: '线下充值',
currency: 'CNY',
amount: 5000,
serviceFee: 0,
actualAmount: 5000,
remark: '待审核',
createTime: '2026-08-04 18:30:00'
},
{
id: 3,
accountId: 4,
rechargeNo: 'CZ20260805002',
status: '充值失败',
payType: '线下充值',
currency: 'USD',
amount: 3000,
serviceFee: 0,
actualAmount: 3000,
remark: '水单不清晰',
createTime: '2026-08-05 16:00:00'
}
]
let operationLogList = [
{
id: 1,
accountId: 1,
createTime: '2026-08-05 14:22:10',
description:
'XXX审核充值单通过,充值单号为:CZ20260805001,入账金额为:10000¥'
},
{
id: 2,
accountId: 1,
createTime: '2026-08-04 15:40:55',
description:
'XXX对账户九猫科技团队CNY账户进行手动调整,调整金额为:5000$,备注:测试调整;'
},
{
id: 3,
accountId: 1,
createTime: '2026-08-04 10:20:33',
description:
'demo客户XXX添加了一个付款账户,账户名为:九猫科技团队CNY账户,账户币种为:CNY;'
}
]
// ==================== 工具 ====================
const sleep = (ms = 300) => new Promise((resolve) => setTimeout(resolve, ms))
const ok = (data, message = '操作成功') => ({ code: 200, data, message })
// 生成账号:币种 + 年月日 + 三位数,如 CNY260805001
export function genAccountNo(currency) {
const now = new Date()
const ymd =
`${now.getFullYear()}` +
`${String(now.getMonth() + 1).padStart(2, '0')}` +
`${String(now.getDate()).padStart(2, '0')}`
const suffix = String(Math.floor(Math.random() * 900) + 100)
return `${currency}${ymd}${suffix}`
}
// ==================== 请求方法 ====================
// 分页查询付款账户列表
export async function getPaymentAccountPage(params) {
await sleep()
let list = [...paymentAccountList]
if (params.accountName) {
list = list.filter((item) => item.accountName.includes(params.accountName))
}
if (params.accountNo) {
list = list.filter((item) => item.accountNo.includes(params.accountNo))
}
if (params.currency) {
list = list.filter((item) => item.currency === params.currency)
}
const { currentPage = 1, pageSize = 10 } = params
const start = (currentPage - 1) * pageSize
const records = list.slice(start, start + pageSize)
// 真实接口: axios.post('/customer/paymentAccount/pageList', params)
return ok({ records, total: list.length })
}
// 新增付款账户
export async function addPaymentAccount(params) {
await sleep()
paymentAccountList.unshift({
id: Date.now(),
...params,
balance: 0,
totalRecharge: 0,
arrears: 0,
creator: '当前用户',
createTime: '2026-08-06 09:00:00',
hasDetail: false
})
operationLogList.unshift({
id: Date.now() + 1,
accountId: paymentAccountList[0].id,
createTime: '2026-08-06 09:00:00',
description: `demo客户XXX添加了一个付款账户,账户名为:${params.accountName},账户币种为:${params.currency};`
})
// 真实接口: axios.post('/customer/paymentAccount/add', params)
return ok(null, '新增成功')
}
// 编辑付款账户
export async function updatePaymentAccount(params) {
await sleep()
const target = paymentAccountList.find((item) => item.id === params.id)
if (target) {
target.accountName = params.accountName
}
// 真实接口: axios.post('/customer/paymentAccount/update', params)
return ok(null, '编辑成功')
}
// 手动调整账户余额(amount 支持正负数)
export async function adjustPaymentAccount(params) {
await sleep()
const target = paymentAccountList.find((item) => item.id === params.id)
if (target) {
target.balance = Number((target.balance + params.amount).toFixed(2))
if (target.balance < 0) {
target.arrears = Number(Math.abs(target.balance).toFixed(2))
} else {
target.arrears = 0
}
}
operationLogList.unshift({
id: Date.now(),
accountId: params.id,
createTime: '2026-08-06 09:30:00',
description: `XXX对账户${params.accountName}进行手动调整,调整金额为:${params.amount}$,备注:${params.remark || '无'};`
})
// 真实接口: axios.post('/customer/paymentAccount/adjust', params)
return ok(null, '调整成功')
}
// 删除付款账户
export async function deletePaymentAccount(params) {
await sleep()
const target = paymentAccountList.find((item) => item.id === params.id)
if (target && target.hasDetail) {
return {
code: 500,
message: `您要删除的账户${target.accountName}(${target.accountNo})存在消费或充值明细,无法进行删除操作!`,
data: null
}
}
paymentAccountList = paymentAccountList.filter((item) => item.id !== params.id)
// 真实接口: axios.post('/customer/paymentAccount/delete', params)
return ok(null, '删除成功')
}
// 分页查询充值记录
export async function getRechargeRecordPage(params) {
await sleep()
let list = rechargeRecordList.filter((item) => item.accountId === params.accountId)
const { currentPage = 1, pageSize = 10 } = params
const start = (currentPage - 1) * pageSize
const records = list.slice(start, start + pageSize)
// 真实接口: axios.post('/customer/paymentAccount/rechargeRecord/pageList', params)
return ok({ records, total: list.length })
}
// 分页查询操作日志
export async function getOperationLogPage(params) {
await sleep()
let list = operationLogList
.filter((item) => item.accountId === params.accountId)
.sort((a, b) => (a.createTime < b.createTime ? 1 : -1))
const { currentPage = 1, pageSize = 10 } = params
const start = (currentPage - 1) * pageSize
const records = list.slice(start, start + pageSize)
// 真实接口: axios.post('/customer/paymentAccount/operationLog/pageList', params)
return ok({ records, total: list.length })
}
......@@ -382,6 +382,16 @@ export default {
width: 130
},
{
label: '订单账户',
key: 'createTime',
width: 130
},
{
label: '付款账户数量',
key: 'createTime',
width: 130
},
{
label: '操作',
fixed: 'right',
align: 'center',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment