feat(consignment): 寄卖物品已验收后隐藏退单回库按钮并拦截退库
1. 寄卖库存管理面板中,已验收通过的现货记录不再展示「退单回库」按钮; 2. 后端 returnAdminConsignmentInventory 接口增加校验,若关联工单已验收结算则拒绝退库,后续问题引导走售后流程。
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
getWorkerUserById,
|
getWorkerUserById,
|
||||||
getWorkerUserByPhone,
|
getWorkerUserByPhone,
|
||||||
|
listWorkOrdersByIds,
|
||||||
} from '../../repositories/worker-platform/index.js'
|
} from '../../repositories/worker-platform/index.js'
|
||||||
import type { JsonObject } from '../../types/json.js'
|
import type { JsonObject } from '../../types/json.js'
|
||||||
import { createHttpError } from '../../utils/http.js'
|
import { createHttpError } from '../../utils/http.js'
|
||||||
@@ -468,6 +469,24 @@ export async function returnAdminConsignmentInventory(
|
|||||||
payload: JsonObject,
|
payload: JsonObject,
|
||||||
_actorName = '',
|
_actorName = '',
|
||||||
) {
|
) {
|
||||||
|
const currentItem = await getConsignmentInventoryById(id)
|
||||||
|
if (!currentItem) {
|
||||||
|
throw createHttpError('寄卖物品不存在', {
|
||||||
|
statusCode: 404,
|
||||||
|
errorCode: 'consignment_not_found',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const boundWorkOrderId = Number(currentItem.bound_work_order_id || 0)
|
||||||
|
if (boundWorkOrderId > 0) {
|
||||||
|
const [boundWo] = await listWorkOrdersByIds([boundWorkOrderId])
|
||||||
|
if (boundWo && (boundWo.status === 'accepted' || boundWo.status === 'completed')) {
|
||||||
|
throw createHttpError('该物品关联工单已验收结算,无法退回复库;后续问题请走售后流程', {
|
||||||
|
statusCode: 409,
|
||||||
|
errorCode: 'consignment_order_already_accepted',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const now = nowIso()
|
const now = nowIso()
|
||||||
const reason = String(payload.reason || '').trim()
|
const reason = String(payload.reason || '').trim()
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -610,7 +610,10 @@ export default function ConsignmentInventoryPanel() {
|
|||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{record.status === 'consumed' && canManageConsignment ? (
|
{record.status === 'consumed' &&
|
||||||
|
canManageConsignment &&
|
||||||
|
record.giftEvidenceReviewStatus !== 'accepted' &&
|
||||||
|
record.giftWorkOrderStatus !== 'accepted' ? (
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|||||||
Reference in New Issue
Block a user