refactor(consignment): 删掉按库存号操作寄卖的卖家入口
手动入库停用后,"没有提报单的现货"已不可能再产生,批次 I 为兜这类货加的两个 按库存号入口(/worker/consignment/inventories/:inventoryId/...)成了纯负担。 - 删除两个按库存号的路由/服务函数、前端两个请求函数与页面里的锚点分派逻辑, 卖家动作只按提报单号(寄卖单号)定位 - 卖家列表里"没有提报单"的兜底行不再暴露内部仓库号(标题改「客服手工入库」), 且一律不给操作能力位,不给用户一个点下去必然失败的按钮 - 加静态守卫测试钉住以上两点,防止以后又长出按库存号的入口 真实库验证:卖家列表三件货都带寄卖单号与 submissionId,没有提报单的现货 0 件。
This commit is contained in:
@@ -35,12 +35,10 @@ import { useEffect, useMemo, useState } from 'react'
|
||||
import ImageUpload from '@/components/files/ImageUpload'
|
||||
import {
|
||||
confirmWorkerConsignmentFriendAdded,
|
||||
confirmWorkerConsignmentInventoryFriendAdded,
|
||||
fetchWorkerConsignments,
|
||||
fetchWorkerProfile,
|
||||
publishWorkerConsignment,
|
||||
submitWorkerConsignmentGiftEvidence,
|
||||
submitWorkerConsignmentInventoryGiftEvidence,
|
||||
} from '@/services/worker'
|
||||
import type { WorkerConsignmentRecord } from '@/services/worker'
|
||||
import type { UploadedFile } from '@/types/worker-platform'
|
||||
@@ -252,20 +250,19 @@ export default function WorkerConsignmentPage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位要操作的寄卖单:有提报单号(寄卖单号)就用它,客服手工入库的现货回退用库存号。
|
||||
* 两条路由在后端是分开的,这里用 submissionId/inventoryId 是否为 null 决定,
|
||||
* 前端不会把两个号混用。
|
||||
* 定位要操作的寄卖单:只认提报单号(寄卖单号)。
|
||||
* 客服手动入库已停用,每件货都必然由提报单产出,所以不存在"只能用库存号操作"的货;
|
||||
* 万一遇到没有提报单的历史行,直接拦下并提示联系客服,不做降级操作。
|
||||
*/
|
||||
function resolveActionAnchor(item: WorkerConsignmentRecord) {
|
||||
if (item.submissionId != null) return { kind: 'submission' as const, id: item.submissionId }
|
||||
if (item.inventoryId != null) return { kind: 'inventory' as const, id: item.inventoryId }
|
||||
message.warning('该寄卖单缺少可操作的编号,请联系客服处理')
|
||||
function resolveActionSubmissionId(item: WorkerConsignmentRecord) {
|
||||
if (item.submissionId != null) return item.submissionId
|
||||
message.warning('该寄卖单没有提报单号,无法在这里操作,请联系客服处理')
|
||||
return null
|
||||
}
|
||||
|
||||
function handleConfirmFriend(item: WorkerConsignmentRecord) {
|
||||
const anchor = resolveActionAnchor(item)
|
||||
if (!anchor) return
|
||||
const submissionId = resolveActionSubmissionId(item)
|
||||
if (submissionId == null) return
|
||||
|
||||
modal.confirm({
|
||||
title: '确认已在游戏内加好买家好友?',
|
||||
@@ -287,9 +284,7 @@ export default function WorkerConsignmentPage() {
|
||||
centered: true,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await (anchor.kind === 'submission'
|
||||
? confirmWorkerConsignmentFriendAdded(anchor.id)
|
||||
: confirmWorkerConsignmentInventoryFriendAdded(anchor.id))
|
||||
await confirmWorkerConsignmentFriendAdded(submissionId)
|
||||
message.success('已确认加好友,赠送冷却开始')
|
||||
await myConsignmentsQuery.refetch()
|
||||
} catch (err: any) {
|
||||
@@ -300,7 +295,7 @@ export default function WorkerConsignmentPage() {
|
||||
}
|
||||
|
||||
function openEvidenceModal(item: WorkerConsignmentRecord) {
|
||||
if (!resolveActionAnchor(item)) return
|
||||
if (resolveActionSubmissionId(item) == null) return
|
||||
setEvidenceItem(item)
|
||||
setEvidenceFiles([])
|
||||
setEvidenceNote('')
|
||||
@@ -313,8 +308,8 @@ export default function WorkerConsignmentPage() {
|
||||
}
|
||||
|
||||
async function handleEvidenceSubmit() {
|
||||
const anchor = evidenceItem ? resolveActionAnchor(evidenceItem) : null
|
||||
if (!anchor) return
|
||||
const submissionId = evidenceItem ? resolveActionSubmissionId(evidenceItem) : null
|
||||
if (submissionId == null) return
|
||||
const urls = evidenceFiles.map((file) => file.url).filter(Boolean)
|
||||
if (urls.length === 0) {
|
||||
message.warning('请先上传赠送完成截图,客服需要凭截图验收')
|
||||
@@ -325,9 +320,7 @@ export default function WorkerConsignmentPage() {
|
||||
try {
|
||||
const note = evidenceNote.trim()
|
||||
const payload = note ? { imageUrls: urls, note } : { imageUrls: urls }
|
||||
await (anchor.kind === 'submission'
|
||||
? submitWorkerConsignmentGiftEvidence(anchor.id, payload)
|
||||
: submitWorkerConsignmentInventoryGiftEvidence(anchor.id, payload))
|
||||
await submitWorkerConsignmentGiftEvidence(submissionId, payload)
|
||||
message.success('赠送截图已提交,等待客服验收')
|
||||
closeEvidenceModal()
|
||||
await myConsignmentsQuery.refetch()
|
||||
|
||||
@@ -483,24 +483,3 @@ export function submitWorkerConsignmentGiftEvidence(
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服手工入库的现货没有提报单号,按库存号走同一套动作
|
||||
* (后端单独开路由,不用"一个 id 两义",避免提报单号与库存号撞号时误操作)。
|
||||
*/
|
||||
export function confirmWorkerConsignmentInventoryFriendAdded(inventoryId: number | string) {
|
||||
return apiPost<{ order: WorkOrder }>(
|
||||
`/api/v1/worker/consignment/inventories/${inventoryId}/confirm-friend`,
|
||||
{},
|
||||
)
|
||||
}
|
||||
|
||||
export function submitWorkerConsignmentInventoryGiftEvidence(
|
||||
inventoryId: number | string,
|
||||
payload: { imageUrls: string[]; note?: string },
|
||||
) {
|
||||
return apiPost<{ order: WorkOrder }>(
|
||||
`/api/v1/worker/consignment/inventories/${inventoryId}/gift-evidence`,
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user