优化打手提现审核流程

This commit is contained in:
yml2213
2026-08-17 11:18:14 +08:00
parent 9ed2e0d4fe
commit ea5c2a4105
13 changed files with 623 additions and 138 deletions
@@ -94,6 +94,15 @@ export type WorkerFinanceRequestRow = {
worker_phone?: string
}
export type WorkerWithdrawalAccountRow = {
worker_id: number
account_channel: string
account_name: string
account_no: string
wechat_qr_code_json: string | Record<string, unknown>
created_at: string
}
export type WorkCategoryRow = {
id: number
category_key: string
@@ -8,6 +8,7 @@ import type {
WorkerFinanceRequestRow,
WorkerLevelRow,
WorkerUserRow,
WorkerWithdrawalAccountRow,
WorkerWalletLedgerRow,
WorkerWalletRow,
} from './types.js'
@@ -437,6 +438,65 @@ export async function createWorkerFinanceRequest(input: {
return result.rows[0] || null
}
export async function getWorkerWithdrawalAccount(
workerId: number | string,
accountChannel: string,
): Promise<WorkerWithdrawalAccountRow | null> {
const result = await query<WorkerWithdrawalAccountRow>(
`
SELECT *
FROM worker_withdrawal_accounts
WHERE worker_id = $1 AND account_channel = $2
LIMIT 1
`,
[Number(workerId), accountChannel],
)
return result.rows[0] || null
}
export async function listWorkerWithdrawalAccounts(
workerId: number | string,
): Promise<WorkerWithdrawalAccountRow[]> {
const result = await query<WorkerWithdrawalAccountRow>(
`
SELECT *
FROM worker_withdrawal_accounts
WHERE worker_id = $1
ORDER BY account_channel ASC
`,
[Number(workerId)],
)
return result.rows
}
export async function createWorkerWithdrawalAccount(input: {
workerId: number
accountChannel: string
accountName: string
accountNo: string
wechatQrCodeJson: string
now: string
}): Promise<WorkerWithdrawalAccountRow | null> {
const result = await query<WorkerWithdrawalAccountRow>(
`
INSERT INTO worker_withdrawal_accounts (
worker_id, account_channel, account_name, account_no, wechat_qr_code_json, created_at
) VALUES ($1, $2, $3, $4, $5::jsonb, $6)
ON CONFLICT (worker_id, account_channel) DO NOTHING
RETURNING *
`,
[
input.workerId,
input.accountChannel,
input.accountName,
input.accountNo,
input.wechatQrCodeJson,
input.now,
],
)
return result.rows[0] || null
}
export async function getWorkerFinanceRequestById(
requestId: number | string,
): Promise<WorkerFinanceRequestRow | null> {