接单平台退单审核增加商品名与商品详情
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
getWorkerCancelRequestById,
|
||||
getWorkOrderById,
|
||||
listAdminWorkerCancelRequests as listWorkerCancelRequestsForAdmin,
|
||||
reviewWorkerCancelRequest,
|
||||
@@ -22,6 +23,27 @@ export async function listAdminWorkerCancelRequests(query: JsonObject = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAdminWorkerCancelRequestDetail(requestId: number | string) {
|
||||
const request = await getWorkerCancelRequestById(requestId)
|
||||
if (!request) {
|
||||
throw createHttpError('打手退单申请不存在', {
|
||||
statusCode: 404,
|
||||
errorCode: 'worker_cancel_request_not_found',
|
||||
})
|
||||
}
|
||||
const order = await getWorkOrderById(Number(request.work_order_id))
|
||||
if (!order) {
|
||||
throw createHttpError('退单申请关联的工单不存在', {
|
||||
statusCode: 404,
|
||||
errorCode: 'worker_cancel_request_work_order_not_found',
|
||||
})
|
||||
}
|
||||
return {
|
||||
request: mapWorkerCancelRequest(request),
|
||||
order: mapWorkOrderAdmin(order),
|
||||
}
|
||||
}
|
||||
|
||||
export async function reviewAdminWorkerCancelRequest(
|
||||
requestId: number | string,
|
||||
payload: JsonObject = {},
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { mapWorkerCancelRequest } from './worker-finance-mappers.js'
|
||||
|
||||
test('打手退单申请映射保留商品名与来源,供列表和商品详情使用', () => {
|
||||
const mapped = mapWorkerCancelRequest({
|
||||
id: 12,
|
||||
work_order_id: 34,
|
||||
work_order_share_id: 56,
|
||||
worker_id: 78,
|
||||
reason: '客户取消',
|
||||
status: 'pending',
|
||||
review_note: '',
|
||||
reviewed_by: '',
|
||||
created_at: '2026-11-28T10:00:00.000Z',
|
||||
reviewed_at: null,
|
||||
platform_order_id: 'P-20261128',
|
||||
shop_name: '西瓜游戏交易店',
|
||||
product_name: '安卓怒嚎2钻 苏尔南',
|
||||
source_provider: '91kaquan',
|
||||
worker_username: 'worker01',
|
||||
worker_display_name: '古雷儿',
|
||||
share_quantity: 2,
|
||||
})
|
||||
|
||||
assert.equal(mapped.productName, '安卓怒嚎2钻 苏尔南')
|
||||
assert.equal(mapped.sourceProvider, '91kaquan')
|
||||
assert.equal(mapped.shopName, '西瓜游戏交易店')
|
||||
assert.equal(mapped.shareQuantity, 2)
|
||||
})
|
||||
|
||||
test('打手退单申请映射对空商品名和来源返回空字符串,不猜测', () => {
|
||||
const mapped = mapWorkerCancelRequest({
|
||||
id: 13,
|
||||
work_order_id: 35,
|
||||
work_order_share_id: null,
|
||||
worker_id: 79,
|
||||
reason: '',
|
||||
status: 'pending',
|
||||
review_note: '',
|
||||
reviewed_by: '',
|
||||
created_at: '2026-11-28T10:00:00.000Z',
|
||||
reviewed_at: null,
|
||||
})
|
||||
|
||||
assert.equal(mapped.productName, '')
|
||||
assert.equal(mapped.sourceProvider, '')
|
||||
})
|
||||
@@ -139,6 +139,8 @@ export function mapWorkerCancelRequest(request: {
|
||||
reviewed_at: string | null
|
||||
platform_order_id?: string
|
||||
shop_name?: string
|
||||
product_name?: string
|
||||
source_provider?: string
|
||||
worker_username?: string
|
||||
worker_display_name?: string
|
||||
share_quantity?: number | null
|
||||
@@ -150,6 +152,8 @@ export function mapWorkerCancelRequest(request: {
|
||||
workerId: Number(request.worker_id),
|
||||
platformOrderId: String(request.platform_order_id || ''),
|
||||
shopName: String(request.shop_name || ''),
|
||||
productName: String(request.product_name || ''),
|
||||
sourceProvider: String(request.source_provider || ''),
|
||||
workerName: String(request.worker_display_name || request.worker_username || ''),
|
||||
shareQuantity: request.share_quantity ? Number(request.share_quantity) : null,
|
||||
reason: String(request.reason || ''),
|
||||
|
||||
Reference in New Issue
Block a user