feat(consignment): 寄卖规格与价格动态配置重构
This commit is contained in:
@@ -54,6 +54,12 @@ export type ConsignmentInventoryRow = {
|
||||
profile_id?: string | number | null
|
||||
profile_version_id?: string | number | null
|
||||
profile_snapshot_json?: string | Record<string, unknown> | null
|
||||
/** 动态规格值 / 匹配 key / 展示文本 */
|
||||
spec_values_json?: string | Record<string, unknown> | null
|
||||
spec_key?: string
|
||||
spec_text?: string
|
||||
/** 打手改价上限(分);0 = 不限制 */
|
||||
price_cap_fen?: number
|
||||
/** 该批次总数量 / 剩余可匹配数量 */
|
||||
quantity?: number
|
||||
remaining_quantity?: number
|
||||
@@ -97,6 +103,12 @@ export type ConsignmentSubmissionRow = {
|
||||
profile_id?: string | number | null
|
||||
profile_version_id?: string | number | null
|
||||
profile_snapshot_json?: string | Record<string, unknown> | null
|
||||
/** 动态规格值 / 匹配 key / 展示文本 */
|
||||
spec_values_json?: string | Record<string, unknown> | null
|
||||
spec_key?: string
|
||||
spec_text?: string
|
||||
/** 打手改价上限(分);0 = 不限制 */
|
||||
price_cap_fen?: number
|
||||
/** 本次提报数量与期望售价 */
|
||||
quantity?: number
|
||||
requested_sale_price_fen?: number
|
||||
@@ -413,6 +425,10 @@ export async function updateConsignmentInventory(
|
||||
brillianceCount?: number | undefined
|
||||
costPriceFen?: number | undefined
|
||||
salePriceFen?: number | undefined
|
||||
specValuesJson?: Record<string, unknown> | undefined
|
||||
specKey?: string | undefined
|
||||
specText?: string | undefined
|
||||
priceCapFen?: number | undefined
|
||||
buyerName?: string | undefined
|
||||
inboundBatch?: string | undefined
|
||||
sellerContact?: string | undefined
|
||||
@@ -467,6 +483,22 @@ export async function updateConsignmentInventory(
|
||||
values.push(input.salePriceFen)
|
||||
updates.push(`sale_price_fen = $${values.length}`)
|
||||
}
|
||||
if (input.specValuesJson !== undefined) {
|
||||
values.push(toJsonString(input.specValuesJson))
|
||||
updates.push(`spec_values_json = $${values.length}::jsonb`)
|
||||
}
|
||||
if (input.specKey !== undefined) {
|
||||
values.push(input.specKey)
|
||||
updates.push(`spec_key = $${values.length}`)
|
||||
}
|
||||
if (input.specText !== undefined) {
|
||||
values.push(input.specText)
|
||||
updates.push(`spec_text = $${values.length}`)
|
||||
}
|
||||
if (input.priceCapFen !== undefined) {
|
||||
values.push(Math.max(0, Math.round(input.priceCapFen)))
|
||||
updates.push(`price_cap_fen = $${values.length}`)
|
||||
}
|
||||
if (input.buyerName !== undefined) {
|
||||
values.push(input.buyerName)
|
||||
updates.push(`buyer_name = $${values.length}`)
|
||||
@@ -1060,6 +1092,7 @@ export async function listWorkerConsignmentPage(input: {
|
||||
AND (
|
||||
cs.submission_no ILIKE ${p}
|
||||
OR cs.item_name ILIKE ${p}
|
||||
OR cs.spec_text ILIKE ${p}
|
||||
OR cs.system ILIKE ${p}
|
||||
OR cs.server_zone ILIKE ${p}
|
||||
OR cs.series ILIKE ${p}
|
||||
@@ -1069,6 +1102,7 @@ export async function listWorkerConsignmentPage(input: {
|
||||
OR cs.seller_phone ILIKE ${p}
|
||||
OR ci.inventory_no ILIKE ${p}
|
||||
OR ci.item_name ILIKE ${p}
|
||||
OR ci.spec_text ILIKE ${p}
|
||||
OR ci.seller_game_id ILIKE ${p}
|
||||
OR ci.seller_contact ILIKE ${p}
|
||||
OR ci.seller_phone ILIKE ${p}
|
||||
@@ -1338,6 +1372,10 @@ export async function createConsignmentSubmissionWithClient(
|
||||
profileId?: number | null
|
||||
profileVersionId?: number | null
|
||||
profileSnapshotJson?: Record<string, unknown> | null
|
||||
specValuesJson?: Record<string, unknown> | null
|
||||
specKey?: string
|
||||
specText?: string
|
||||
priceCapFen?: number
|
||||
quantity?: number
|
||||
requestedSalePriceFen?: number
|
||||
now: string
|
||||
@@ -1352,6 +1390,7 @@ export async function createConsignmentSubmissionWithClient(
|
||||
worker_id, worker_name, worker_phone, deposit_amount_fen,
|
||||
contact_supporter_id,
|
||||
profile_id, profile_version_id, profile_snapshot_json, quantity, requested_sale_price_fen,
|
||||
spec_values_json, spec_key, spec_text, price_cap_fen,
|
||||
status, created_at, updated_at
|
||||
) VALUES (
|
||||
$1, $2, $3, $4,
|
||||
@@ -1361,7 +1400,8 @@ export async function createConsignmentSubmissionWithClient(
|
||||
$17, $18, $19, $20,
|
||||
$21,
|
||||
$22, $23, $24::jsonb, $25, $26,
|
||||
'pending_review', $27, $27
|
||||
$27::jsonb, $28, $29, $30,
|
||||
'pending_review', $31, $31
|
||||
)
|
||||
RETURNING *
|
||||
`
|
||||
@@ -1392,6 +1432,10 @@ export async function createConsignmentSubmissionWithClient(
|
||||
input.profileSnapshotJson ? toJsonString(input.profileSnapshotJson) : null,
|
||||
Math.max(1, Math.round(Number(input.quantity || 1))),
|
||||
Math.max(0, Math.round(Number(input.requestedSalePriceFen || input.askingPriceFen || 0))),
|
||||
toJsonString(input.specValuesJson || {}),
|
||||
String(input.specKey || ''),
|
||||
String(input.specText || ''),
|
||||
Math.max(0, Math.round(Number(input.priceCapFen || 0))),
|
||||
input.now,
|
||||
])
|
||||
return res.rows[0]!
|
||||
@@ -1463,6 +1507,10 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
profileId?: number | null | undefined
|
||||
profileVersionId?: number | null | undefined
|
||||
profileSnapshotJson?: string | Record<string, unknown> | null | undefined
|
||||
specValuesJson?: string | Record<string, unknown> | null | undefined
|
||||
specKey?: string | undefined
|
||||
specText?: string | undefined
|
||||
priceCapFen?: number | undefined
|
||||
quantity?: number | undefined
|
||||
salePriceFen?: number | undefined
|
||||
now: string
|
||||
@@ -1501,6 +1549,7 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
contact_supporter_id,
|
||||
profile_id, profile_version_id, profile_snapshot_json, quantity, remaining_quantity,
|
||||
sale_price_fen, listed_at,
|
||||
spec_values_json, spec_key, spec_text, price_cap_fen,
|
||||
inbound_at, created_at, updated_at
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6,
|
||||
@@ -1512,6 +1561,7 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
$25,
|
||||
$26, $27, $28::jsonb, $29, $29,
|
||||
$30, $31,
|
||||
$32::jsonb, $33, $34, $35,
|
||||
$31, $31, $31
|
||||
)
|
||||
RETURNING *
|
||||
@@ -1563,6 +1613,10 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
),
|
||||
),
|
||||
input.now,
|
||||
toJsonString(input.specValuesJson ?? submission.spec_values_json ?? {}),
|
||||
input.specKey ?? submission.spec_key ?? '',
|
||||
input.specText ?? submission.spec_text ?? '',
|
||||
Math.max(0, Math.round(Number(input.priceCapFen ?? submission.price_cap_fen ?? 0))),
|
||||
]
|
||||
const invRes = await client.query<ConsignmentInventoryRow>(invSql, invValues)
|
||||
const inventory = invRes.rows[0]!
|
||||
|
||||
Reference in New Issue
Block a user