feat:寄卖增加对接客服,db脚本迁移修复
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
import { query } from '../../db/client.js'
|
||||
|
||||
/**
|
||||
* 寄卖「对接客服」名单。
|
||||
*
|
||||
* 独立于后台账号表:客服离职或后台账号改角色,都不应影响历史寄卖归属;
|
||||
* 提报单 / 现货只保存名单 id,展示时 join 出当时选择的客服资料。
|
||||
*/
|
||||
export type ConsignmentContactRow = {
|
||||
id: string | number
|
||||
name: string
|
||||
phone: string
|
||||
wechat: string
|
||||
note: string
|
||||
enabled: boolean
|
||||
sort_order: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export async function listConsignmentContacts(filters: {
|
||||
keyword?: string | undefined
|
||||
enabled?: boolean | undefined
|
||||
}): Promise<ConsignmentContactRow[]> {
|
||||
const conditions: string[] = []
|
||||
const values: unknown[] = []
|
||||
|
||||
if (filters.enabled !== undefined) {
|
||||
values.push(filters.enabled)
|
||||
conditions.push(`enabled = $${values.length}`)
|
||||
}
|
||||
if (filters.keyword) {
|
||||
values.push(`%${filters.keyword.trim()}%`)
|
||||
conditions.push(
|
||||
`(name ILIKE $${values.length} OR phone ILIKE $${values.length} OR wechat ILIKE $${values.length} OR note ILIKE $${values.length})`,
|
||||
)
|
||||
}
|
||||
|
||||
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''
|
||||
const res = await query<ConsignmentContactRow>(
|
||||
`SELECT * FROM consignment_contact_supporters ${whereClause} ORDER BY sort_order ASC, id ASC`,
|
||||
values,
|
||||
)
|
||||
return res.rows
|
||||
}
|
||||
|
||||
/** 打手端发布下拉:只返回启用中的客服。 */
|
||||
export async function listEnabledConsignmentContacts(): Promise<ConsignmentContactRow[]> {
|
||||
return listConsignmentContacts({ enabled: true })
|
||||
}
|
||||
|
||||
export async function getConsignmentContactById(
|
||||
id: number | string,
|
||||
): Promise<ConsignmentContactRow | null> {
|
||||
const res = await query<ConsignmentContactRow>(
|
||||
'SELECT * FROM consignment_contact_supporters WHERE id = $1 LIMIT 1',
|
||||
[id],
|
||||
)
|
||||
return res.rows[0] || null
|
||||
}
|
||||
|
||||
/** 重名检查:名单用于归属统计,同名会让运营无法判断到底是谁。 */
|
||||
export async function findConsignmentContactByName(
|
||||
name: string,
|
||||
excludeId?: number | string,
|
||||
): Promise<ConsignmentContactRow | null> {
|
||||
const res = await query<ConsignmentContactRow>(
|
||||
`SELECT * FROM consignment_contact_supporters
|
||||
WHERE name = $1 ${excludeId !== undefined ? 'AND id <> $2' : ''}
|
||||
ORDER BY id ASC
|
||||
LIMIT 1`,
|
||||
excludeId !== undefined ? [name, excludeId] : [name],
|
||||
)
|
||||
return res.rows[0] || null
|
||||
}
|
||||
|
||||
export async function createConsignmentContact(input: {
|
||||
name: string
|
||||
phone?: string | undefined
|
||||
wechat?: string | undefined
|
||||
note?: string | undefined
|
||||
enabled?: boolean | undefined
|
||||
sortOrder?: number | undefined
|
||||
now: string
|
||||
}): Promise<ConsignmentContactRow> {
|
||||
const res = await query<ConsignmentContactRow>(
|
||||
`INSERT INTO consignment_contact_supporters (
|
||||
name, phone, wechat, note, enabled, sort_order, created_at, updated_at
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $7)
|
||||
RETURNING *`,
|
||||
[
|
||||
input.name,
|
||||
input.phone || '',
|
||||
input.wechat || '',
|
||||
input.note || '',
|
||||
input.enabled !== false,
|
||||
input.sortOrder || 0,
|
||||
input.now,
|
||||
],
|
||||
)
|
||||
return res.rows[0]!
|
||||
}
|
||||
|
||||
export async function updateConsignmentContact(
|
||||
id: number | string,
|
||||
input: {
|
||||
name?: string | undefined
|
||||
phone?: string | undefined
|
||||
wechat?: string | undefined
|
||||
note?: string | undefined
|
||||
sortOrder?: number | undefined
|
||||
now: string
|
||||
},
|
||||
): Promise<ConsignmentContactRow | null> {
|
||||
const updates: string[] = []
|
||||
const values: unknown[] = []
|
||||
|
||||
if (input.name !== undefined) {
|
||||
values.push(input.name)
|
||||
updates.push(`name = $${values.length}`)
|
||||
}
|
||||
if (input.phone !== undefined) {
|
||||
values.push(input.phone)
|
||||
updates.push(`phone = $${values.length}`)
|
||||
}
|
||||
if (input.wechat !== undefined) {
|
||||
values.push(input.wechat)
|
||||
updates.push(`wechat = $${values.length}`)
|
||||
}
|
||||
if (input.note !== undefined) {
|
||||
values.push(input.note)
|
||||
updates.push(`note = $${values.length}`)
|
||||
}
|
||||
if (input.sortOrder !== undefined) {
|
||||
values.push(input.sortOrder)
|
||||
updates.push(`sort_order = $${values.length}`)
|
||||
}
|
||||
|
||||
if (updates.length === 0) {
|
||||
return getConsignmentContactById(id)
|
||||
}
|
||||
|
||||
values.push(input.now)
|
||||
updates.push(`updated_at = $${values.length}`)
|
||||
values.push(id)
|
||||
|
||||
const res = await query<ConsignmentContactRow>(
|
||||
`UPDATE consignment_contact_supporters
|
||||
SET ${updates.join(', ')}
|
||||
WHERE id = $${values.length}
|
||||
RETURNING *`,
|
||||
values,
|
||||
)
|
||||
return res.rows[0] || null
|
||||
}
|
||||
|
||||
export async function setConsignmentContactEnabled(
|
||||
id: number | string,
|
||||
enabled: boolean,
|
||||
now: string,
|
||||
): Promise<ConsignmentContactRow | null> {
|
||||
const res = await query<ConsignmentContactRow>(
|
||||
`UPDATE consignment_contact_supporters
|
||||
SET enabled = $1, updated_at = $2
|
||||
WHERE id = $3
|
||||
RETURNING *`,
|
||||
[enabled, now, id],
|
||||
)
|
||||
return res.rows[0] || null
|
||||
}
|
||||
|
||||
/** 删除前统计引用:有历史寄卖时禁止硬删,避免历史单据的对接客服变成空白。 */
|
||||
export async function countConsignmentContactReferences(id: number | string): Promise<number> {
|
||||
const res = await query<{ total: number }>(
|
||||
`SELECT (
|
||||
(SELECT COUNT(*) FROM consignment_submissions WHERE contact_supporter_id = $1) +
|
||||
(SELECT COUNT(*) FROM consignment_inventories WHERE contact_supporter_id = $1)
|
||||
)::integer AS total`,
|
||||
[id],
|
||||
)
|
||||
return Number(res.rows[0]?.total || 0)
|
||||
}
|
||||
|
||||
export async function deleteConsignmentContact(id: number | string): Promise<boolean> {
|
||||
const res = await query<{ id: string | number }>(
|
||||
'DELETE FROM consignment_contact_supporters WHERE id = $1 RETURNING id',
|
||||
[id],
|
||||
)
|
||||
return res.rows.length > 0
|
||||
}
|
||||
@@ -50,6 +50,11 @@ export type ConsignmentInventoryRow = {
|
||||
worker_phone?: string
|
||||
assigned_worker_id?: string | number | null
|
||||
deposit_amount_fen?: number
|
||||
/** 对接客服(发布/审核入库时选定,用于提成归属与联系) */
|
||||
contact_supporter_id?: string | number | null
|
||||
contact_supporter_name?: string
|
||||
contact_supporter_phone?: string
|
||||
contact_supporter_wechat?: string
|
||||
inbound_at: string
|
||||
consumed_at: string | null
|
||||
created_at: string
|
||||
@@ -79,6 +84,11 @@ export type ConsignmentSubmissionRow = {
|
||||
worker_name?: string
|
||||
worker_phone?: string
|
||||
deposit_amount_fen?: number
|
||||
/** 对接客服(发布时选定,用于提成归属与联系) */
|
||||
contact_supporter_id?: string | number | null
|
||||
contact_supporter_name?: string
|
||||
contact_supporter_phone?: string
|
||||
contact_supporter_wechat?: string
|
||||
status: 'pending_review' | 'approved' | 'rejected'
|
||||
review_note: string
|
||||
reviewer_name: string
|
||||
@@ -175,13 +185,13 @@ export async function listConsignmentInventories(filters: {
|
||||
if (filters.keyword) {
|
||||
values.push(`%${filters.keyword.trim()}%`)
|
||||
conditions.push(
|
||||
`(ci.item_name ILIKE $${values.length} OR ci.inventory_no ILIKE $${values.length} OR ci.bound_platform_order_id ILIKE $${values.length} OR ci.seller_contact ILIKE $${values.length} OR ci.seller_game_id ILIKE $${values.length} OR ci.seller_payment_info ILIKE $${values.length} OR ci.remark ILIKE $${values.length} OR cs.submission_no ILIKE $${values.length})`,
|
||||
`(ci.item_name ILIKE $${values.length} OR ci.inventory_no ILIKE $${values.length} OR ci.bound_platform_order_id ILIKE $${values.length} OR ci.seller_contact ILIKE $${values.length} OR ci.seller_game_id ILIKE $${values.length} OR ci.seller_payment_info ILIKE $${values.length} OR ci.remark ILIKE $${values.length} OR cs.submission_no ILIKE $${values.length} OR ccs.name ILIKE $${values.length})`,
|
||||
)
|
||||
}
|
||||
|
||||
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''
|
||||
// 计数也要带上提报单 join:关键字现在包含 cs.submission_no(卖家端主标识就是它)
|
||||
const countSql = `SELECT COUNT(*)::integer AS total FROM consignment_inventories ci LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_id ${whereClause}`
|
||||
// 计数也要带上提报单 / 对接客服 join:关键字现在包含 cs.submission_no 与 ccs.name
|
||||
const countSql = `SELECT COUNT(*)::integer AS total FROM consignment_inventories ci LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_id LEFT JOIN consignment_contact_supporters ccs ON ccs.id = ci.contact_supporter_id ${whereClause}`
|
||||
const countRes = await query<{ total: number }>(countSql, values)
|
||||
const total = countRes.rows[0]?.total || 0
|
||||
|
||||
@@ -202,10 +212,14 @@ export async function listConsignmentInventories(filters: {
|
||||
wo.gift_phase AS gift_phase,
|
||||
wo.friend_added_at AS gift_friend_added_at,
|
||||
wo.material_json AS bound_work_order_material_json,
|
||||
wo.requirement_json AS bound_work_order_requirement_json
|
||||
wo.requirement_json AS bound_work_order_requirement_json,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_inventories ci
|
||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
||||
LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = ci.contact_supporter_id
|
||||
LEFT JOIN work_orders wo ON wo.id = ci.bound_work_order_id
|
||||
${whereClause}
|
||||
ORDER BY ci.id DESC
|
||||
@@ -321,10 +335,14 @@ export async function getConsignmentInventoryById(
|
||||
wo.gift_phase AS gift_phase,
|
||||
wo.friend_added_at AS gift_friend_added_at,
|
||||
wo.material_json AS bound_work_order_material_json,
|
||||
wo.requirement_json AS bound_work_order_requirement_json
|
||||
wo.requirement_json AS bound_work_order_requirement_json,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_inventories ci
|
||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
||||
LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = ci.contact_supporter_id
|
||||
LEFT JOIN work_orders wo ON wo.id = ci.bound_work_order_id
|
||||
WHERE ci.id = $1
|
||||
LIMIT 1
|
||||
@@ -344,10 +362,14 @@ export async function listConsignmentInventoriesByIds(
|
||||
ci.*,
|
||||
wc.name AS category_name,
|
||||
cs.submission_no AS source_submission_no,
|
||||
cs.screenshots_json AS submission_screenshots_json
|
||||
cs.screenshots_json AS submission_screenshots_json,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_inventories ci
|
||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
||||
LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = ci.contact_supporter_id
|
||||
WHERE ci.id = ANY($1::bigint[])
|
||||
`
|
||||
const res = await query<ConsignmentInventoryRow>(sql, [numericIds])
|
||||
@@ -379,6 +401,7 @@ export async function updateConsignmentInventory(
|
||||
workerName?: string | undefined
|
||||
workerPhone?: string | undefined
|
||||
depositAmountFen?: number | undefined
|
||||
contactSupporterId?: number | null | undefined
|
||||
now: string
|
||||
},
|
||||
): Promise<ConsignmentInventoryRow | null> {
|
||||
@@ -473,6 +496,10 @@ export async function updateConsignmentInventory(
|
||||
values.push(input.depositAmountFen)
|
||||
updates.push(`deposit_amount_fen = $${values.length}`)
|
||||
}
|
||||
if (input.contactSupporterId !== undefined) {
|
||||
values.push(input.contactSupporterId)
|
||||
updates.push(`contact_supporter_id = $${values.length}`)
|
||||
}
|
||||
|
||||
if (updates.length === 0) return getConsignmentInventoryById(id)
|
||||
|
||||
@@ -484,10 +511,13 @@ export async function updateConsignmentInventory(
|
||||
UPDATE consignment_inventories
|
||||
SET ${updates.join(', ')}
|
||||
WHERE id = $${values.length}
|
||||
RETURNING *
|
||||
RETURNING id
|
||||
`
|
||||
const res = await query<ConsignmentInventoryRow>(sql, values)
|
||||
return res.rows[0] || null
|
||||
const res = await query<{ id: string | number }>(sql, values)
|
||||
const updatedId = res.rows[0]?.id
|
||||
// 重新走带 join 的详情查询:RETURNING * 拿不到对接客服姓名,
|
||||
// 编辑保存后的即时回显会变成空白(列表刷新前)。
|
||||
return updatedId === undefined ? null : getConsignmentInventoryById(updatedId)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -880,9 +910,13 @@ export async function listActiveConsignmentInventoriesForMatching(options?: {
|
||||
const sql = `
|
||||
SELECT
|
||||
ci.*,
|
||||
cs.submission_no AS source_submission_no
|
||||
cs.submission_no AS source_submission_no,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_inventories ci
|
||||
LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = ci.contact_supporter_id
|
||||
WHERE ${conditions.join(' AND ')}
|
||||
ORDER BY ci.id ASC
|
||||
`
|
||||
@@ -913,12 +947,12 @@ export async function listConsignmentSubmissions(filters: {
|
||||
if (filters.keyword) {
|
||||
values.push(`%${filters.keyword.trim()}%`)
|
||||
conditions.push(
|
||||
`(cs.item_name ILIKE $${values.length} OR cs.submission_no ILIKE $${values.length} OR cs.contact_info ILIKE $${values.length} OR cs.seller_game_id ILIKE $${values.length} OR cs.seller_phone ILIKE $${values.length})`,
|
||||
`(cs.item_name ILIKE $${values.length} OR cs.submission_no ILIKE $${values.length} OR cs.contact_info ILIKE $${values.length} OR cs.seller_game_id ILIKE $${values.length} OR cs.seller_phone ILIKE $${values.length} OR ccs.name ILIKE $${values.length})`,
|
||||
)
|
||||
}
|
||||
|
||||
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''
|
||||
const countSql = `SELECT COUNT(*)::integer AS total FROM consignment_submissions cs ${whereClause}`
|
||||
const countSql = `SELECT COUNT(*)::integer AS total FROM consignment_submissions cs LEFT JOIN consignment_contact_supporters ccs ON ccs.id = cs.contact_supporter_id ${whereClause}`
|
||||
const countRes = await query<{ total: number }>(countSql, values)
|
||||
const total = countRes.rows[0]?.total || 0
|
||||
|
||||
@@ -934,9 +968,13 @@ export async function listConsignmentSubmissions(filters: {
|
||||
wc.name AS category_name,
|
||||
wo.acceptance_json AS gift_evidence_json,
|
||||
wo.work_order_no AS gift_work_order_no,
|
||||
wo.status AS gift_work_order_status
|
||||
wo.status AS gift_work_order_status,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_submissions cs
|
||||
LEFT JOIN work_categories wc ON wc.id = cs.category_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = cs.contact_supporter_id
|
||||
LEFT JOIN consignment_inventories rinv ON (rinv.id = cs.result_inventory_id OR rinv.source_submission_id = cs.id)
|
||||
LEFT JOIN work_orders wo ON wo.id = rinv.bound_work_order_id
|
||||
${whereClause}
|
||||
@@ -1152,9 +1190,13 @@ export async function listConsignmentSubmissionsByIds(
|
||||
wc.name AS category_name,
|
||||
wo.acceptance_json AS gift_evidence_json,
|
||||
wo.work_order_no AS gift_work_order_no,
|
||||
wo.status AS gift_work_order_status
|
||||
wo.status AS gift_work_order_status,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_submissions cs
|
||||
LEFT JOIN work_categories wc ON wc.id = cs.category_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = cs.contact_supporter_id
|
||||
LEFT JOIN consignment_inventories rinv
|
||||
ON (rinv.id = cs.result_inventory_id OR rinv.source_submission_id = cs.id)
|
||||
LEFT JOIN work_orders wo ON wo.id = rinv.bound_work_order_id
|
||||
@@ -1179,10 +1221,14 @@ export async function getConsignmentInventoryBySubmissionId(
|
||||
SELECT
|
||||
ci.*,
|
||||
wc.name AS category_name,
|
||||
cs.submission_no AS source_submission_no
|
||||
cs.submission_no AS source_submission_no,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_inventories ci
|
||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
||||
LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = ci.contact_supporter_id
|
||||
WHERE ci.source_submission_id = $1
|
||||
ORDER BY ci.id DESC
|
||||
LIMIT 1
|
||||
@@ -1201,9 +1247,13 @@ export async function getConsignmentSubmissionById(
|
||||
wc.name AS category_name,
|
||||
wo.acceptance_json AS gift_evidence_json,
|
||||
wo.work_order_no AS gift_work_order_no,
|
||||
wo.status AS gift_work_order_status
|
||||
wo.status AS gift_work_order_status,
|
||||
ccs.name AS contact_supporter_name,
|
||||
ccs.phone AS contact_supporter_phone,
|
||||
ccs.wechat AS contact_supporter_wechat
|
||||
FROM consignment_submissions cs
|
||||
LEFT JOIN work_categories wc ON wc.id = cs.category_id
|
||||
LEFT JOIN consignment_contact_supporters ccs ON ccs.id = cs.contact_supporter_id
|
||||
LEFT JOIN consignment_inventories rinv ON (rinv.id = cs.result_inventory_id OR rinv.source_submission_id = cs.id)
|
||||
LEFT JOIN work_orders wo ON wo.id = rinv.bound_work_order_id
|
||||
WHERE cs.id = $1
|
||||
@@ -1234,6 +1284,7 @@ export async function createConsignmentSubmission(input: {
|
||||
workerName?: string
|
||||
workerPhone?: string
|
||||
depositAmountFen?: number
|
||||
contactSupporterId?: number | null
|
||||
now: string
|
||||
}): Promise<ConsignmentSubmissionRow> {
|
||||
return withTransaction((client) => createConsignmentSubmissionWithClient(client, input))
|
||||
@@ -1262,6 +1313,7 @@ export async function createConsignmentSubmissionWithClient(
|
||||
workerName?: string
|
||||
workerPhone?: string
|
||||
depositAmountFen?: number
|
||||
contactSupporterId?: number | null
|
||||
now: string
|
||||
},
|
||||
): Promise<ConsignmentSubmissionRow> {
|
||||
@@ -1272,14 +1324,14 @@ export async function createConsignmentSubmissionWithClient(
|
||||
seller_game_id, seller_payment_info, seller_phone, contact_info,
|
||||
content_json, screenshots_json, asking_price_fen,
|
||||
worker_id, worker_name, worker_phone, deposit_amount_fen,
|
||||
status, created_at, updated_at
|
||||
contact_supporter_id, status, created_at, updated_at
|
||||
) VALUES (
|
||||
$1, $2, $3, $4,
|
||||
$5, $6, $7, $8, $9,
|
||||
$10, $11, $12, $13,
|
||||
$14::jsonb, $15::jsonb, $16,
|
||||
$17, $18, $19, $20,
|
||||
'pending_review', $21, $21
|
||||
$21, 'pending_review', $22, $22
|
||||
)
|
||||
RETURNING *
|
||||
`
|
||||
@@ -1304,6 +1356,7 @@ export async function createConsignmentSubmissionWithClient(
|
||||
input.workerName || '',
|
||||
input.workerPhone || '',
|
||||
input.depositAmountFen || 0,
|
||||
input.contactSupporterId || null,
|
||||
input.now,
|
||||
])
|
||||
return res.rows[0]!
|
||||
@@ -1371,6 +1424,7 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
workerName?: string | undefined
|
||||
workerPhone?: string | undefined
|
||||
depositAmountFen?: number | undefined
|
||||
contactSupporterId?: number | null | undefined
|
||||
now: string
|
||||
}): Promise<{ submission: ConsignmentSubmissionRow; inventory: ConsignmentInventoryRow }> {
|
||||
return withTransaction(async (client: PoolClient) => {
|
||||
@@ -1391,6 +1445,10 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
input.depositAmountFen !== undefined
|
||||
? input.depositAmountFen
|
||||
: submission.deposit_amount_fen || 0
|
||||
const contactSupporterId =
|
||||
input.contactSupporterId !== undefined
|
||||
? input.contactSupporterId
|
||||
: (submission.contact_supporter_id ?? null)
|
||||
|
||||
const invSql = `
|
||||
INSERT INTO consignment_inventories (
|
||||
@@ -1400,7 +1458,7 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
seller_phone, credentials_json, screenshots_json, remark,
|
||||
allow_matching, status, allocation_status, source_type,
|
||||
source_submission_id, worker_id, worker_name, worker_phone, deposit_amount_fen,
|
||||
inbound_at, created_at, updated_at
|
||||
contact_supporter_id, inbound_at, created_at, updated_at
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6,
|
||||
$7, $8, $9, $10, $11,
|
||||
@@ -1408,7 +1466,7 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
$16, $17::jsonb, $18::jsonb, $19,
|
||||
TRUE, 'in_stock', '待安排', 'worker_portal',
|
||||
$20, $21, $22, $23, $24,
|
||||
$25, $25, $25
|
||||
$25, $26, $26, $26
|
||||
)
|
||||
RETURNING *
|
||||
`
|
||||
@@ -1437,6 +1495,7 @@ export async function approveConsignmentSubmissionWithInbound(input: {
|
||||
workerName,
|
||||
workerPhone,
|
||||
depositAmountFen,
|
||||
contactSupporterId,
|
||||
input.now,
|
||||
]
|
||||
const invRes = await client.query<ConsignmentInventoryRow>(invSql, invValues)
|
||||
|
||||
@@ -26,3 +26,4 @@ export * from './after-sales-repo.js'
|
||||
export * from './product-match-repo.js'
|
||||
export * from './sms-code-repo.js'
|
||||
export * from './consignment-repo.js'
|
||||
export * from './consignment-contact-repo.js'
|
||||
|
||||
Reference in New Issue
Block a user