feat(consignment): 寄卖配置价格/匹配/超时/收货字段全面改造

- 价格:固定价格改为模板价固定下调,移除绝对固定价;没有模板价时统一阻止发布
- 配置面板:按下拉选项动态显隐,超时与降价提示拆成两张卡片,超时单位改为小时(默认 0.5)
- 匹配:新增关闭匹配并设为默认,移除自动匹配开关;关闭后新单直接进大厅
- 超时:新增重新匹配退/扣押金,回内部匹配池并排除原卖家与原库存(迁移 147)
- 日志:新增 consignment_match_logs,自动/手动匹配成功、失败、跳过统一留痕,后台新增匹配日志抽屉
- 打手端:顶部分类下拉替换多 tab,默认苏尔南手枪;联系方式与游戏凭据改为动态字段(默认 7 项,手机号必填)
- 降价提示默认开启、默认 24 小时
This commit is contained in:
2026-11-06 13:32:24 +08:00
parent e0a85359b6
commit 3aa01136a5
31 changed files with 2311 additions and 568 deletions
@@ -425,6 +425,9 @@ export type WorkOrderRow = {
internal_match_deadline_at?: string | null
hall_visible_at?: string | null
internal_match_attempts?: number
/** 超时「重新匹配」时排除的原卖家与原库存,避免同一卖家立刻再次接回同一单。 */
rematch_excluded_worker_id?: number | null
rematch_excluded_inventory_id?: number | null
acceptance_json: string | Record<string, unknown>
draft_acceptance_json: string | Record<string, unknown>
admin_note: string
@@ -573,7 +573,7 @@ export async function disposeWorkOrderShareProblem(input: {
export async function settleOverdueWorkOrder(input: {
workOrderId: number
policy: 'reopen' | 'cancel_release' | 'cancel_deduct'
policy: 'reopen' | 'cancel_release' | 'cancel_deduct' | 'rematch_release' | 'rematch_deduct'
now: string
}): Promise<{
order: WorkOrderRow | null
@@ -613,13 +613,15 @@ export async function settleOverdueWorkOrder(input: {
now: input.now,
})
}
const releasePolicies = ['reopen', 'cancel_release']
const releasePolicies = ['reopen', 'cancel_release', 'rematch_release']
const isRematch = input.policy === 'rematch_release' || input.policy === 'rematch_deduct'
const shouldReleaseDeposit = releasePolicies.includes(input.policy) && !forfeitGiftDeposit
const shouldDeductDeposit =
input.policy === 'cancel_deduct' ||
input.policy === 'rematch_deduct' ||
(releasePolicies.includes(input.policy) && forfeitGiftDeposit)
const effectivePolicy =
input.policy === 'cancel_release' && forfeitGiftDeposit ? 'cancel_deduct' : input.policy
releasePolicies.includes(input.policy) && forfeitGiftDeposit ? 'cancel_deduct' : input.policy
const workerId = Number(workOrder.assigned_worker_id || 0)
let resolvedDepositAmount = 0
@@ -672,7 +674,11 @@ export async function settleOverdueWorkOrder(input: {
}
}
const targetStatus = input.policy === 'reopen' ? 'open' : 'cancelled'
const targetStatus = isRematch
? 'internal_matching'
: input.policy === 'reopen'
? 'open'
: 'cancelled'
await client.query(
`
@@ -685,6 +691,8 @@ export async function settleOverdueWorkOrder(input: {
${CLEAR_DELIVERY_RESIDUE_SQL},
published_at = CASE WHEN $1 = 'open' THEN $2 ELSE published_at END,
hall_queued_at = CASE WHEN $1 = 'open' THEN $2 ELSE hall_queued_at END,
internal_match_deadline_at = CASE WHEN $1 = 'internal_matching' THEN NULL ELSE internal_match_deadline_at END,
hall_visible_at = CASE WHEN $1 = 'internal_matching' THEN NULL ELSE hall_visible_at END,
${RESET_GIFT_FLOW_SQL},
updated_at = $2
WHERE id = $3
@@ -893,6 +893,8 @@ export interface OverdueWorkOrderShareItem {
timeoutMinutes: number
timeoutPolicy: string
shareCreatedAt: string
/** 寄卖份额对应的库存;重新匹配时用于排除原库存 */
consignmentInventoryId: number | null
}
/**
@@ -921,6 +923,7 @@ export async function listOverdueWorkOrderShares({
timeout_minutes: number
timeout_policy: string
share_created_at: string
consignment_inventory_id: string | null
}>(
`SELECT
wos.id AS share_id,
@@ -930,7 +933,8 @@ export async function listOverdueWorkOrderShares({
wos.share_deposit,
wos.timeout_minutes,
wos.timeout_policy,
wos.created_at AS share_created_at
wos.created_at AS share_created_at,
wos.consignment_inventory_id
FROM work_order_shares wos
INNER JOIN work_orders wo ON wo.id = wos.work_order_id
WHERE wos.status = 'joined'
@@ -951,6 +955,9 @@ export async function listOverdueWorkOrderShares({
timeoutMinutes: Number(row.timeout_minutes),
timeoutPolicy: String(row.timeout_policy || 'reopen'),
shareCreatedAt: String(row.share_created_at),
consignmentInventoryId: row.consignment_inventory_id
? Number(row.consignment_inventory_id)
: null,
}))
}
@@ -990,7 +990,7 @@ export async function cancelWorkOrderShare(input: {
export async function settleOverdueWorkOrderShare(input: {
workOrderId: number
shareId: number
policy: 'reopen' | 'cancel_release' | 'cancel_deduct'
policy: 'reopen' | 'cancel_release' | 'cancel_deduct' | 'rematch_release' | 'rematch_deduct'
now: string
}): Promise<{
order: WorkOrderRow | null
@@ -1065,7 +1065,7 @@ export async function settleOverdueWorkOrderShare(input: {
Number(wallet?.frozen_deposit_amount || 0),
)
if (frozenDeposit > 0) {
if (input.policy === 'cancel_deduct') {
if (input.policy === 'cancel_deduct' || input.policy === 'rematch_deduct') {
deductedDepositAmount = frozenDeposit
const nextFrozen = Math.max(0, Number(wallet?.frozen_deposit_amount || 0) - frozenDeposit)
await client.query(