feat(consignment): 苏尔南寄卖接入打手端押金履约
打手可直接提报寄卖,关联 worker 与履约押金后指派交枪;后台去掉旧收集链接管理,提报审核与库存/工单流程对齐接单平台。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
updateAdminConsignmentLink,
|
||||
} from '../../../services/worker-platform/consignment-admin-service.js'
|
||||
import {
|
||||
assignWorkOrderWithConsignmentWorker,
|
||||
checkWorkOrderInventoryMatches,
|
||||
fulfillWorkOrderWithConsignment,
|
||||
revokeWorkOrderConsignmentFulfillment,
|
||||
@@ -253,6 +254,25 @@ router.post(
|
||||
),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/worker-platform/consignment/assign-worker',
|
||||
requireAdminRoles(['admin', 'operator', 'support']),
|
||||
createJsonHandler(
|
||||
(req) =>
|
||||
assignWorkOrderWithConsignmentWorker({
|
||||
workOrderId: String(req.body?.workOrderId || ''),
|
||||
inventoryId: String(req.body?.inventoryId || ''),
|
||||
workerId: req.body?.workerId ? Number(req.body.workerId) : null,
|
||||
actorName: req.adminSession?.username || 'admin',
|
||||
}),
|
||||
{
|
||||
successMessage: '已指派打手,押金已冻结,工单流转进行中!',
|
||||
errorMessage: '指派打手履约失败',
|
||||
scope: '[admin/consignment/assign-worker]',
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/worker-platform/consignment/revoke',
|
||||
requireAdminRoles(['admin', 'operator', 'support']),
|
||||
|
||||
@@ -5,6 +5,7 @@ import workerAuthSessionRoutes from './worker/auth-session.js'
|
||||
import workerProfileRoutes from './worker/profile.js'
|
||||
import workerHallRoutes from './worker/hall.js'
|
||||
import workerOrdersRoutes from './worker/orders.js'
|
||||
import workerConsignmentRoutes from './worker/consignment.js'
|
||||
import { requireWorkerSession } from './worker/session.js'
|
||||
import { buildNotFoundPayload } from '../utils/http.js'
|
||||
|
||||
@@ -22,6 +23,8 @@ router.use(workerHallRoutes)
|
||||
|
||||
router.use(workerOrdersRoutes)
|
||||
|
||||
router.use(workerConsignmentRoutes)
|
||||
|
||||
router.use((req, res) => {
|
||||
res.status(404).json(buildNotFoundPayload(req))
|
||||
})
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Router } from 'express'
|
||||
|
||||
import {
|
||||
listWorkerConsignments,
|
||||
publishWorkerConsignment,
|
||||
} from '../../services/worker-platform/consignment-worker-service.js'
|
||||
import { sendRouteError } from '../../utils/http.js'
|
||||
import { getRequiredWorkerSession } from './session.js'
|
||||
|
||||
const router = Router()
|
||||
|
||||
/**
|
||||
* POST /api/v1/worker/consignment/publish
|
||||
* 打手在接单平台直接提报苏尔南手枪寄卖
|
||||
*/
|
||||
router.post('/consignment/publish', async (req, res) => {
|
||||
try {
|
||||
const session = getRequiredWorkerSession(req)
|
||||
const result = await publishWorkerConsignment(session.workerId, req.body || {})
|
||||
res.json({ ok: true, data: result })
|
||||
} catch (error) {
|
||||
sendRouteError(res, error, '提交寄卖失败', '[worker/consignment/publish]')
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* GET /api/v1/worker/consignment/my-items
|
||||
* 打手查看自己在接单平台寄卖的手枪列表与状态
|
||||
*/
|
||||
router.get('/consignment/my-items', async (req, res) => {
|
||||
try {
|
||||
const session = getRequiredWorkerSession(req)
|
||||
const result = await listWorkerConsignments(session.workerId)
|
||||
res.json({ ok: true, data: result })
|
||||
} catch (error) {
|
||||
sendRouteError(res, error, '获取我的寄卖列表失败', '[worker/consignment/my-items]')
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user