Implement batch fee management features in BillingController, including preview, submission, and task retrieval. Update related services and mappers to support batch processing. Add necessary error messages in properties file and enhance front-end API for batch operations.
This commit is contained in:
@@ -97,6 +97,62 @@ export function addIncomeBillFee(data) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 批量增加费用:按筛选预览匹配订单 */
|
||||
export function previewBatchAddIncomeFee(data) {
|
||||
return request({
|
||||
url: '/price/billing/bill/fee/batch/preview',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/** 批量增加费用:提交异步任务 */
|
||||
export function submitBatchAddIncomeFee(data) {
|
||||
return request({
|
||||
url: '/price/billing/bill/fee/batch',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getBatchAddIncomeFeeTask(taskId) {
|
||||
return request({
|
||||
url: '/price/billing/bill/fee/batch/task/' + taskId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
async function pollBatchAddIncomeFeeTask(taskId, onProgress) {
|
||||
const started = Date.now()
|
||||
const maxMs = 30 * 60 * 1000
|
||||
while (Date.now() - started < maxMs) {
|
||||
const res = await getBatchAddIncomeFeeTask(taskId)
|
||||
const task = res.data || {}
|
||||
if (typeof onProgress === 'function') onProgress(task)
|
||||
if (task.status === 'SUCCESS') return { task }
|
||||
if (task.status === 'FAIL') {
|
||||
const err = new Error(task.error || task.message || 'batch add fee failed')
|
||||
err.task = task
|
||||
throw err
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 800))
|
||||
}
|
||||
throw new Error('batch add fee timeout')
|
||||
}
|
||||
|
||||
/**
|
||||
* Async batch add fee; poll until done.
|
||||
* @param {object} data BatchAddIncomeBillFeeRequest
|
||||
* @param {(task: object) => void} [onProgress]
|
||||
*/
|
||||
export async function batchAddIncomeFeeAsync(data, onProgress) {
|
||||
const submitRes = await submitBatchAddIncomeFee(data)
|
||||
const d = submitRes && submitRes.data
|
||||
const taskId = d && (d.taskId || d)
|
||||
if (!taskId) throw new Error('missing batch fee taskId')
|
||||
return pollBatchAddIncomeFeeTask(String(taskId), onProgress)
|
||||
}
|
||||
|
||||
/** 计费详情:编辑手动应收费用 */
|
||||
export function updateIncomeBillFee(data) {
|
||||
return request({
|
||||
|
||||
Reference in New Issue
Block a user