feat:寄卖增加对接客服,db脚本迁移修复
This commit is contained in:
@@ -7,8 +7,6 @@
|
|||||||
CREATE TABLE IF NOT EXISTS consignment_contact_supporters (
|
CREATE TABLE IF NOT EXISTS consignment_contact_supporters (
|
||||||
id BIGSERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
phone TEXT NOT NULL DEFAULT '',
|
|
||||||
wechat TEXT NOT NULL DEFAULT '',
|
|
||||||
note TEXT NOT NULL DEFAULT '',
|
note TEXT NOT NULL DEFAULT '',
|
||||||
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
@@ -35,7 +33,7 @@ CREATE INDEX IF NOT EXISTS idx_consignment_inventories_contact_supporter
|
|||||||
ON consignment_inventories (contact_supporter_id);
|
ON consignment_inventories (contact_supporter_id);
|
||||||
|
|
||||||
-- 首次部署给一个可用默认项:打手端「必填 + 默认选第一个」不会因名单为空而无法发布。
|
-- 首次部署给一个可用默认项:打手端「必填 + 默认选第一个」不会因名单为空而无法发布。
|
||||||
-- 后台可直接改名/补充联系方式,不会重复插入。
|
-- 后台可直接改名/补充备注,不会重复插入。
|
||||||
INSERT INTO consignment_contact_supporters (name, note, sort_order)
|
INSERT INTO consignment_contact_supporters (name, note, sort_order)
|
||||||
SELECT '默认客服', '系统初始化,请在「配置 - 对接客服」中修改', 0
|
SELECT '默认客服', '系统初始化,请在「配置 - 对接客服」中修改', 0
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM consignment_contact_supporters);
|
WHERE NOT EXISTS (SELECT 1 FROM consignment_contact_supporters);
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import { query } from '../../db/client.js'
|
|||||||
export type ConsignmentContactRow = {
|
export type ConsignmentContactRow = {
|
||||||
id: string | number
|
id: string | number
|
||||||
name: string
|
name: string
|
||||||
phone: string
|
|
||||||
wechat: string
|
|
||||||
note: string
|
note: string
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
sort_order: number
|
sort_order: number
|
||||||
@@ -31,9 +29,7 @@ export async function listConsignmentContacts(filters: {
|
|||||||
}
|
}
|
||||||
if (filters.keyword) {
|
if (filters.keyword) {
|
||||||
values.push(`%${filters.keyword.trim()}%`)
|
values.push(`%${filters.keyword.trim()}%`)
|
||||||
conditions.push(
|
conditions.push(`(name ILIKE $${values.length} OR note ILIKE $${values.length})`)
|
||||||
`(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 whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''
|
||||||
@@ -76,8 +72,6 @@ export async function findConsignmentContactByName(
|
|||||||
|
|
||||||
export async function createConsignmentContact(input: {
|
export async function createConsignmentContact(input: {
|
||||||
name: string
|
name: string
|
||||||
phone?: string | undefined
|
|
||||||
wechat?: string | undefined
|
|
||||||
note?: string | undefined
|
note?: string | undefined
|
||||||
enabled?: boolean | undefined
|
enabled?: boolean | undefined
|
||||||
sortOrder?: number | undefined
|
sortOrder?: number | undefined
|
||||||
@@ -85,18 +79,10 @@ export async function createConsignmentContact(input: {
|
|||||||
}): Promise<ConsignmentContactRow> {
|
}): Promise<ConsignmentContactRow> {
|
||||||
const res = await query<ConsignmentContactRow>(
|
const res = await query<ConsignmentContactRow>(
|
||||||
`INSERT INTO consignment_contact_supporters (
|
`INSERT INTO consignment_contact_supporters (
|
||||||
name, phone, wechat, note, enabled, sort_order, created_at, updated_at
|
name, note, enabled, sort_order, created_at, updated_at
|
||||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $7)
|
) VALUES ($1, $2, $3, $4, $5, $5)
|
||||||
RETURNING *`,
|
RETURNING *`,
|
||||||
[
|
[input.name, input.note || '', input.enabled !== false, input.sortOrder || 0, input.now],
|
||||||
input.name,
|
|
||||||
input.phone || '',
|
|
||||||
input.wechat || '',
|
|
||||||
input.note || '',
|
|
||||||
input.enabled !== false,
|
|
||||||
input.sortOrder || 0,
|
|
||||||
input.now,
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
return res.rows[0]!
|
return res.rows[0]!
|
||||||
}
|
}
|
||||||
@@ -105,8 +91,6 @@ export async function updateConsignmentContact(
|
|||||||
id: number | string,
|
id: number | string,
|
||||||
input: {
|
input: {
|
||||||
name?: string | undefined
|
name?: string | undefined
|
||||||
phone?: string | undefined
|
|
||||||
wechat?: string | undefined
|
|
||||||
note?: string | undefined
|
note?: string | undefined
|
||||||
sortOrder?: number | undefined
|
sortOrder?: number | undefined
|
||||||
now: string
|
now: string
|
||||||
@@ -119,14 +103,6 @@ export async function updateConsignmentContact(
|
|||||||
values.push(input.name)
|
values.push(input.name)
|
||||||
updates.push(`name = $${values.length}`)
|
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) {
|
if (input.note !== undefined) {
|
||||||
values.push(input.note)
|
values.push(input.note)
|
||||||
updates.push(`note = $${values.length}`)
|
updates.push(`note = $${values.length}`)
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ export type ConsignmentInventoryRow = {
|
|||||||
/** 对接客服(发布/审核入库时选定,用于提成归属与联系) */
|
/** 对接客服(发布/审核入库时选定,用于提成归属与联系) */
|
||||||
contact_supporter_id?: string | number | null
|
contact_supporter_id?: string | number | null
|
||||||
contact_supporter_name?: string
|
contact_supporter_name?: string
|
||||||
contact_supporter_phone?: string
|
|
||||||
contact_supporter_wechat?: string
|
|
||||||
inbound_at: string
|
inbound_at: string
|
||||||
consumed_at: string | null
|
consumed_at: string | null
|
||||||
created_at: string
|
created_at: string
|
||||||
@@ -87,8 +85,6 @@ export type ConsignmentSubmissionRow = {
|
|||||||
/** 对接客服(发布时选定,用于提成归属与联系) */
|
/** 对接客服(发布时选定,用于提成归属与联系) */
|
||||||
contact_supporter_id?: string | number | null
|
contact_supporter_id?: string | number | null
|
||||||
contact_supporter_name?: string
|
contact_supporter_name?: string
|
||||||
contact_supporter_phone?: string
|
|
||||||
contact_supporter_wechat?: string
|
|
||||||
status: 'pending_review' | 'approved' | 'rejected'
|
status: 'pending_review' | 'approved' | 'rejected'
|
||||||
review_note: string
|
review_note: string
|
||||||
reviewer_name: string
|
reviewer_name: string
|
||||||
@@ -213,9 +209,7 @@ export async function listConsignmentInventories(filters: {
|
|||||||
wo.friend_added_at AS gift_friend_added_at,
|
wo.friend_added_at AS gift_friend_added_at,
|
||||||
wo.material_json AS bound_work_order_material_json,
|
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.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_inventories ci
|
FROM consignment_inventories ci
|
||||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
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_submissions cs ON cs.id = ci.source_submission_id
|
||||||
@@ -336,9 +330,7 @@ export async function getConsignmentInventoryById(
|
|||||||
wo.friend_added_at AS gift_friend_added_at,
|
wo.friend_added_at AS gift_friend_added_at,
|
||||||
wo.material_json AS bound_work_order_material_json,
|
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.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_inventories ci
|
FROM consignment_inventories ci
|
||||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
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_submissions cs ON cs.id = ci.source_submission_id
|
||||||
@@ -363,9 +355,7 @@ export async function listConsignmentInventoriesByIds(
|
|||||||
wc.name AS category_name,
|
wc.name AS category_name,
|
||||||
cs.submission_no AS source_submission_no,
|
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.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_inventories ci
|
FROM consignment_inventories ci
|
||||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
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_submissions cs ON cs.id = ci.source_submission_id
|
||||||
@@ -911,9 +901,7 @@ export async function listActiveConsignmentInventoriesForMatching(options?: {
|
|||||||
SELECT
|
SELECT
|
||||||
ci.*,
|
ci.*,
|
||||||
cs.submission_no AS source_submission_no,
|
cs.submission_no AS source_submission_no,
|
||||||
ccs.name AS contact_supporter_name,
|
ccs.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_inventories ci
|
FROM consignment_inventories ci
|
||||||
LEFT JOIN consignment_submissions cs ON cs.id = ci.source_submission_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 consignment_contact_supporters ccs ON ccs.id = ci.contact_supporter_id
|
||||||
@@ -969,9 +957,7 @@ export async function listConsignmentSubmissions(filters: {
|
|||||||
wo.acceptance_json AS gift_evidence_json,
|
wo.acceptance_json AS gift_evidence_json,
|
||||||
wo.work_order_no AS gift_work_order_no,
|
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.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_submissions cs
|
FROM consignment_submissions cs
|
||||||
LEFT JOIN work_categories wc ON wc.id = cs.category_id
|
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_contact_supporters ccs ON ccs.id = cs.contact_supporter_id
|
||||||
@@ -1191,9 +1177,7 @@ export async function listConsignmentSubmissionsByIds(
|
|||||||
wo.acceptance_json AS gift_evidence_json,
|
wo.acceptance_json AS gift_evidence_json,
|
||||||
wo.work_order_no AS gift_work_order_no,
|
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.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_submissions cs
|
FROM consignment_submissions cs
|
||||||
LEFT JOIN work_categories wc ON wc.id = cs.category_id
|
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_contact_supporters ccs ON ccs.id = cs.contact_supporter_id
|
||||||
@@ -1222,9 +1206,7 @@ export async function getConsignmentInventoryBySubmissionId(
|
|||||||
ci.*,
|
ci.*,
|
||||||
wc.name AS category_name,
|
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.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_inventories ci
|
FROM consignment_inventories ci
|
||||||
LEFT JOIN work_categories wc ON wc.id = ci.category_id
|
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_submissions cs ON cs.id = ci.source_submission_id
|
||||||
@@ -1248,9 +1230,7 @@ export async function getConsignmentSubmissionById(
|
|||||||
wo.acceptance_json AS gift_evidence_json,
|
wo.acceptance_json AS gift_evidence_json,
|
||||||
wo.work_order_no AS gift_work_order_no,
|
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.name AS contact_supporter_name
|
||||||
ccs.phone AS contact_supporter_phone,
|
|
||||||
ccs.wechat AS contact_supporter_wechat
|
|
||||||
FROM consignment_submissions cs
|
FROM consignment_submissions cs
|
||||||
LEFT JOIN work_categories wc ON wc.id = cs.category_id
|
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_contact_supporters ccs ON ccs.id = cs.contact_supporter_id
|
||||||
|
|||||||
@@ -228,8 +228,6 @@ export function mapConsignmentInventory(row: ConsignmentInventoryRow) {
|
|||||||
depositAmountFen: Number(row.deposit_amount_fen || 0),
|
depositAmountFen: Number(row.deposit_amount_fen || 0),
|
||||||
contactSupporterId: row.contact_supporter_id ? Number(row.contact_supporter_id) : null,
|
contactSupporterId: row.contact_supporter_id ? Number(row.contact_supporter_id) : null,
|
||||||
contactSupporterName: row.contact_supporter_name || '',
|
contactSupporterName: row.contact_supporter_name || '',
|
||||||
contactSupporterPhone: row.contact_supporter_phone || '',
|
|
||||||
contactSupporterWechat: row.contact_supporter_wechat || '',
|
|
||||||
inboundAt: row.inbound_at || row.created_at,
|
inboundAt: row.inbound_at || row.created_at,
|
||||||
consumedAt: row.consumed_at,
|
consumedAt: row.consumed_at,
|
||||||
createdAt: row.created_at,
|
createdAt: row.created_at,
|
||||||
@@ -272,8 +270,6 @@ export function mapConsignmentSubmission(row: ConsignmentSubmissionRow) {
|
|||||||
depositAmountFen: Number(row.deposit_amount_fen || 0),
|
depositAmountFen: Number(row.deposit_amount_fen || 0),
|
||||||
contactSupporterId: row.contact_supporter_id ? Number(row.contact_supporter_id) : null,
|
contactSupporterId: row.contact_supporter_id ? Number(row.contact_supporter_id) : null,
|
||||||
contactSupporterName: row.contact_supporter_name || '',
|
contactSupporterName: row.contact_supporter_name || '',
|
||||||
contactSupporterPhone: row.contact_supporter_phone || '',
|
|
||||||
contactSupporterWechat: row.contact_supporter_wechat || '',
|
|
||||||
status: row.status,
|
status: row.status,
|
||||||
reviewNote: row.review_note || '',
|
reviewNote: row.review_note || '',
|
||||||
reviewerName: row.reviewer_name || '',
|
reviewerName: row.reviewer_name || '',
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ export function mapConsignmentContact(row: ConsignmentContactRow) {
|
|||||||
return {
|
return {
|
||||||
id: Number(row.id),
|
id: Number(row.id),
|
||||||
name: row.name,
|
name: row.name,
|
||||||
phone: row.phone || '',
|
|
||||||
wechat: row.wechat || '',
|
|
||||||
note: row.note || '',
|
note: row.note || '',
|
||||||
enabled: Boolean(row.enabled),
|
enabled: Boolean(row.enabled),
|
||||||
sortOrder: Number(row.sort_order || 0),
|
sortOrder: Number(row.sort_order || 0),
|
||||||
@@ -92,8 +90,6 @@ export async function createAdminConsignmentContact(payload: JsonObject) {
|
|||||||
await assertContactNameAvailable(name)
|
await assertContactNameAvailable(name)
|
||||||
const row = await createConsignmentContact({
|
const row = await createConsignmentContact({
|
||||||
name,
|
name,
|
||||||
phone: normalizeText(payload.phone),
|
|
||||||
wechat: normalizeText(payload.wechat),
|
|
||||||
note: normalizeText(payload.note),
|
note: normalizeText(payload.note),
|
||||||
enabled: payload.enabled !== false,
|
enabled: payload.enabled !== false,
|
||||||
sortOrder: normalizeSortOrder(payload.sortOrder),
|
sortOrder: normalizeSortOrder(payload.sortOrder),
|
||||||
@@ -118,8 +114,6 @@ export async function updateAdminConsignmentContact(id: number | string, payload
|
|||||||
|
|
||||||
const updated = await updateConsignmentContact(id, {
|
const updated = await updateConsignmentContact(id, {
|
||||||
name,
|
name,
|
||||||
phone: payload.phone !== undefined ? normalizeText(payload.phone) : undefined,
|
|
||||||
wechat: payload.wechat !== undefined ? normalizeText(payload.wechat) : undefined,
|
|
||||||
note: payload.note !== undefined ? normalizeText(payload.note) : undefined,
|
note: payload.note !== undefined ? normalizeText(payload.note) : undefined,
|
||||||
sortOrder: payload.sortOrder !== undefined ? normalizeSortOrder(payload.sortOrder) : undefined,
|
sortOrder: payload.sortOrder !== undefined ? normalizeSortOrder(payload.sortOrder) : undefined,
|
||||||
now: nowIso(),
|
now: nowIso(),
|
||||||
|
|||||||
@@ -511,8 +511,6 @@ export async function fulfillWorkOrderWithConsignment(input: {
|
|||||||
? Number(inventory.contact_supporter_id)
|
? Number(inventory.contact_supporter_id)
|
||||||
: null,
|
: null,
|
||||||
contactSupporterName: inventory.contact_supporter_name || '',
|
contactSupporterName: inventory.contact_supporter_name || '',
|
||||||
contactSupporterPhone: inventory.contact_supporter_phone || '',
|
|
||||||
contactSupporterWechat: inventory.contact_supporter_wechat || '',
|
|
||||||
workerName: inv.worker_name || '',
|
workerName: inv.worker_name || '',
|
||||||
workerPhone: inv.worker_phone || '',
|
workerPhone: inv.worker_phone || '',
|
||||||
remark: inv.remark || '',
|
remark: inv.remark || '',
|
||||||
@@ -771,8 +769,6 @@ export async function assignWorkOrderWithConsignmentWorker(input: {
|
|||||||
? Number(inventory.contact_supporter_id)
|
? Number(inventory.contact_supporter_id)
|
||||||
: null,
|
: null,
|
||||||
contactSupporterName: inventory.contact_supporter_name || '',
|
contactSupporterName: inventory.contact_supporter_name || '',
|
||||||
contactSupporterPhone: inventory.contact_supporter_phone || '',
|
|
||||||
contactSupporterWechat: inventory.contact_supporter_wechat || '',
|
|
||||||
workerId: Number(targetWorkerId),
|
workerId: Number(targetWorkerId),
|
||||||
workerName: claimed.worker_name || '',
|
workerName: claimed.worker_name || '',
|
||||||
workerPhone: claimed.worker_phone || '',
|
workerPhone: claimed.worker_phone || '',
|
||||||
|
|||||||
@@ -48,14 +48,10 @@ function toRecord(value: unknown): Record<string, unknown> | null {
|
|||||||
function mapConsignmentContactSupporter(source: {
|
function mapConsignmentContactSupporter(source: {
|
||||||
contact_supporter_id?: string | number | null
|
contact_supporter_id?: string | number | null
|
||||||
contact_supporter_name?: string
|
contact_supporter_name?: string
|
||||||
contact_supporter_phone?: string
|
|
||||||
contact_supporter_wechat?: string
|
|
||||||
}) {
|
}) {
|
||||||
return {
|
return {
|
||||||
contactSupporterId: source.contact_supporter_id ? Number(source.contact_supporter_id) : null,
|
contactSupporterId: source.contact_supporter_id ? Number(source.contact_supporter_id) : null,
|
||||||
contactSupporterName: source.contact_supporter_name || '',
|
contactSupporterName: source.contact_supporter_name || '',
|
||||||
contactSupporterPhone: source.contact_supporter_phone || '',
|
|
||||||
contactSupporterWechat: source.contact_supporter_wechat || '',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,8 +350,6 @@ export async function publishWorkerConsignment(workerId: number, payload: JsonOb
|
|||||||
? Number(submission.contact_supporter_id)
|
? Number(submission.contact_supporter_id)
|
||||||
: null,
|
: null,
|
||||||
contactSupporterName: contactSupporter.name,
|
contactSupporterName: contactSupporter.name,
|
||||||
contactSupporterPhone: contactSupporter.phone || '',
|
|
||||||
contactSupporterWechat: contactSupporter.wechat || '',
|
|
||||||
createdAt: submission.created_at,
|
createdAt: submission.created_at,
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ type Selected = {
|
|||||||
workerName?: string
|
workerName?: string
|
||||||
/** 对接客服(用于履约前核对归属) */
|
/** 对接客服(用于履约前核对归属) */
|
||||||
contactSupporterName?: string
|
contactSupporterName?: string
|
||||||
contactSupporterPhone?: string
|
|
||||||
contactSupporterWechat?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ConsignmentManualMatchModalProps = {
|
export type ConsignmentManualMatchModalProps = {
|
||||||
@@ -86,8 +84,6 @@ export default function ConsignmentManualMatchModal({
|
|||||||
} | null>(null)
|
} | null>(null)
|
||||||
const [inventoryContact, setInventoryContact] = useState<{
|
const [inventoryContact, setInventoryContact] = useState<{
|
||||||
contactSupporterName: string
|
contactSupporterName: string
|
||||||
contactSupporterPhone: string
|
|
||||||
contactSupporterWechat: string
|
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
const [selected, setSelected] = useState<Selected | null>(null)
|
const [selected, setSelected] = useState<Selected | null>(null)
|
||||||
const [confirmedPartial, setConfirmedPartial] = useState(false)
|
const [confirmedPartial, setConfirmedPartial] = useState(false)
|
||||||
@@ -129,8 +125,6 @@ export default function ConsignmentManualMatchModal({
|
|||||||
})
|
})
|
||||||
setInventoryContact({
|
setInventoryContact({
|
||||||
contactSupporterName: res.data?.inventory?.contactSupporterName || '',
|
contactSupporterName: res.data?.inventory?.contactSupporterName || '',
|
||||||
contactSupporterPhone: res.data?.inventory?.contactSupporterPhone || '',
|
|
||||||
contactSupporterWechat: res.data?.inventory?.contactSupporterWechat || '',
|
|
||||||
})
|
})
|
||||||
} else if (workOrder) {
|
} else if (workOrder) {
|
||||||
const res = await fetchWorkOrderConsignmentMatchOptions(workOrder.workOrderId)
|
const res = await fetchWorkOrderConsignmentMatchOptions(workOrder.workOrderId)
|
||||||
@@ -374,8 +368,6 @@ export default function ConsignmentManualMatchModal({
|
|||||||
workerId: option.inventory.workerId,
|
workerId: option.inventory.workerId,
|
||||||
workerName: option.inventory.workerName,
|
workerName: option.inventory.workerName,
|
||||||
contactSupporterName: option.inventory.contactSupporterName,
|
contactSupporterName: option.inventory.contactSupporterName,
|
||||||
contactSupporterPhone: option.inventory.contactSupporterPhone,
|
|
||||||
contactSupporterWechat: option.inventory.contactSupporterWechat,
|
|
||||||
})
|
})
|
||||||
setConfirmedPartial(false)
|
setConfirmedPartial(false)
|
||||||
setConfirmedMismatch(false)
|
setConfirmedMismatch(false)
|
||||||
@@ -460,8 +452,6 @@ export default function ConsignmentManualMatchModal({
|
|||||||
workerId: inventoryWorker?.workerId ?? null,
|
workerId: inventoryWorker?.workerId ?? null,
|
||||||
workerName: inventoryWorker?.workerName || '',
|
workerName: inventoryWorker?.workerName || '',
|
||||||
contactSupporterName: inventoryContact?.contactSupporterName || '',
|
contactSupporterName: inventoryContact?.contactSupporterName || '',
|
||||||
contactSupporterPhone: inventoryContact?.contactSupporterPhone || '',
|
|
||||||
contactSupporterWechat: inventoryContact?.contactSupporterWechat || '',
|
|
||||||
})
|
})
|
||||||
setConfirmedPartial(false)
|
setConfirmedPartial(false)
|
||||||
setConfirmedMismatch(false)
|
setConfirmedMismatch(false)
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ const { Text } = Typography
|
|||||||
|
|
||||||
type ContactForm = {
|
type ContactForm = {
|
||||||
name: string
|
name: string
|
||||||
phone?: string
|
|
||||||
wechat?: string
|
|
||||||
note?: string
|
note?: string
|
||||||
sortOrder?: number
|
sortOrder?: number
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
@@ -98,8 +96,6 @@ export default function AdminConsignmentContactsPage() {
|
|||||||
setEditingContact(record)
|
setEditingContact(record)
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
name: record.name,
|
name: record.name,
|
||||||
phone: record.phone,
|
|
||||||
wechat: record.wechat,
|
|
||||||
note: record.note,
|
note: record.note,
|
||||||
sortOrder: record.sortOrder,
|
sortOrder: record.sortOrder,
|
||||||
enabled: record.enabled,
|
enabled: record.enabled,
|
||||||
@@ -113,8 +109,6 @@ export default function AdminConsignmentContactsPage() {
|
|||||||
setSubmitting(true)
|
setSubmitting(true)
|
||||||
const payload = {
|
const payload = {
|
||||||
name: values.name,
|
name: values.name,
|
||||||
phone: values.phone || '',
|
|
||||||
wechat: values.wechat || '',
|
|
||||||
note: values.note || '',
|
note: values.note || '',
|
||||||
sortOrder: Number(values.sortOrder || 0),
|
sortOrder: Number(values.sortOrder || 0),
|
||||||
enabled: values.enabled !== false,
|
enabled: values.enabled !== false,
|
||||||
@@ -174,30 +168,17 @@ export default function AdminConsignmentContactsPage() {
|
|||||||
const columns: TableColumnsType<ConsignmentContactSupporter> = [
|
const columns: TableColumnsType<ConsignmentContactSupporter> = [
|
||||||
{
|
{
|
||||||
title: '姓名',
|
title: '姓名',
|
||||||
key: 'name',
|
dataIndex: 'name',
|
||||||
width: 160,
|
width: 160,
|
||||||
render: (_, record) => (
|
render: (value: string) => <Text strong>{value}</Text>,
|
||||||
<Space direction="vertical" size={2}>
|
|
||||||
<Text strong>{record.name}</Text>
|
|
||||||
{record.note ? (
|
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
|
||||||
{record.note}
|
|
||||||
</Text>
|
|
||||||
) : null}
|
|
||||||
</Space>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '手机号',
|
title: '备注',
|
||||||
dataIndex: 'phone',
|
dataIndex: 'note',
|
||||||
width: 150,
|
width: 240,
|
||||||
render: (value: string) => value || <Text type="secondary">-</Text>,
|
ellipsis: true,
|
||||||
},
|
render: (value: string) =>
|
||||||
{
|
value ? <Text style={{ fontSize: 12 }}>{value}</Text> : <Text type="secondary">-</Text>,
|
||||||
title: '微信号',
|
|
||||||
dataIndex: 'wechat',
|
|
||||||
width: 160,
|
|
||||||
render: (value: string) => value || <Text type="secondary">-</Text>,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '排序',
|
title: '排序',
|
||||||
@@ -265,7 +246,7 @@ export default function AdminConsignmentContactsPage() {
|
|||||||
<Input
|
<Input
|
||||||
allowClear
|
allowClear
|
||||||
prefix={<SearchOutlined />}
|
prefix={<SearchOutlined />}
|
||||||
placeholder="搜索姓名 / 手机 / 微信 / 备注"
|
placeholder="搜索姓名 / 备注"
|
||||||
value={keywordInput}
|
value={keywordInput}
|
||||||
onChange={(event) => setKeywordInput(event.target.value)}
|
onChange={(event) => setKeywordInput(event.target.value)}
|
||||||
style={{ width: 280 }}
|
style={{ width: 280 }}
|
||||||
@@ -313,14 +294,6 @@ export default function AdminConsignmentContactsPage() {
|
|||||||
>
|
>
|
||||||
<Input placeholder="如:小张" maxLength={60} />
|
<Input placeholder="如:小张" maxLength={60} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Space size={12} style={{ width: '100%' }} align="start">
|
|
||||||
<Form.Item name="phone" label="手机号" style={{ width: 240 }}>
|
|
||||||
<Input placeholder="选填" maxLength={30} />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="wechat" label="微信号" style={{ width: 240 }}>
|
|
||||||
<Input placeholder="选填" maxLength={60} />
|
|
||||||
</Form.Item>
|
|
||||||
</Space>
|
|
||||||
<Form.Item name="note" label="备注">
|
<Form.Item name="note" label="备注">
|
||||||
<Input.TextArea rows={2} placeholder="如:负责苏尔南寄卖 / 白班" maxLength={200} />
|
<Input.TextArea rows={2} placeholder="如:负责苏尔南寄卖 / 白班" maxLength={200} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -182,9 +182,7 @@ export default function ConsignmentInventoryPanel() {
|
|||||||
queryFn: () => fetchAdminConsignmentContacts(),
|
queryFn: () => fetchAdminConsignmentContacts(),
|
||||||
})
|
})
|
||||||
const contactSupporterOptions = (contactsQuery.data?.data.items || []).map((item) => ({
|
const contactSupporterOptions = (contactsQuery.data?.data.items || []).map((item) => ({
|
||||||
label: `${item.name}${item.enabled ? '' : '(已禁用)'}${
|
label: `${item.name}${item.enabled ? '' : '(已禁用)'}`,
|
||||||
item.phone ? ` · ${item.phone}` : item.wechat ? ` · ${item.wechat}` : ''
|
|
||||||
}`,
|
|
||||||
value: item.id,
|
value: item.id,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -475,17 +473,11 @@ export default function ConsignmentInventoryPanel() {
|
|||||||
title: '对接客服',
|
title: '对接客服',
|
||||||
key: 'contactSupporter',
|
key: 'contactSupporter',
|
||||||
width: 150,
|
width: 150,
|
||||||
render: (_, record) => {
|
render: (_, record) => (
|
||||||
const contact = formatConsignmentContactSupporter(record)
|
<div style={{ fontSize: 12, fontWeight: 600 }}>
|
||||||
return (
|
{formatConsignmentContactSupporter(record).text}
|
||||||
<div style={{ fontSize: 12 }}>
|
</div>
|
||||||
<div style={{ fontWeight: 600 }}>{contact.name || contact.text}</div>
|
),
|
||||||
{contact.contact ? (
|
|
||||||
<div style={{ color: '#8c8c8c', marginTop: 2 }}>{contact.contact}</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '凭证',
|
title: '凭证',
|
||||||
@@ -1132,21 +1124,7 @@ export default function ConsignmentInventoryPanel() {
|
|||||||
)}
|
)}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="对接客服">
|
<Descriptions.Item label="对接客服">
|
||||||
{(() => {
|
<Text>{formatConsignmentContactSupporter(viewingItem).text}</Text>
|
||||||
const contact = formatConsignmentContactSupporter(viewingItem)
|
|
||||||
return contact.name ? (
|
|
||||||
<Space direction="vertical" size={2}>
|
|
||||||
<Text strong>{contact.name}</Text>
|
|
||||||
{contact.contact ? (
|
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
|
||||||
{contact.contact}
|
|
||||||
</Text>
|
|
||||||
) : null}
|
|
||||||
</Space>
|
|
||||||
) : (
|
|
||||||
<Text type="secondary">未指定</Text>
|
|
||||||
)
|
|
||||||
})()}
|
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="履约押金要求">
|
<Descriptions.Item label="履约押金要求">
|
||||||
{viewingItem.depositAmountFen ? (
|
{viewingItem.depositAmountFen ? (
|
||||||
|
|||||||
@@ -276,17 +276,11 @@ export default function ConsignmentSubmissionsPanel() {
|
|||||||
title: '对接客服',
|
title: '对接客服',
|
||||||
key: 'contactSupporter',
|
key: 'contactSupporter',
|
||||||
width: 150,
|
width: 150,
|
||||||
render: (_, record) => {
|
render: (_, record) => (
|
||||||
const contact = formatConsignmentContactSupporter(record)
|
<div style={{ fontSize: 12, fontWeight: 600 }}>
|
||||||
return (
|
{formatConsignmentContactSupporter(record).text}
|
||||||
<div style={{ fontSize: 12 }}>
|
</div>
|
||||||
<div style={{ fontWeight: 600 }}>{contact.name || contact.text}</div>
|
),
|
||||||
{contact.contact ? (
|
|
||||||
<div style={{ color: '#8c8c8c', marginTop: 2 }}>{contact.contact}</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '提报凭证(游戏主页截图)',
|
title: '提报凭证(游戏主页截图)',
|
||||||
@@ -874,21 +868,7 @@ export default function ConsignmentSubmissionsPanel() {
|
|||||||
)}
|
)}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="对接客服">
|
<Descriptions.Item label="对接客服">
|
||||||
{(() => {
|
<Text>{formatConsignmentContactSupporter(viewingSubmission).text}</Text>
|
||||||
const contact = formatConsignmentContactSupporter(viewingSubmission)
|
|
||||||
return contact.name ? (
|
|
||||||
<Space direction="vertical" size={2}>
|
|
||||||
<Text strong>{contact.name}</Text>
|
|
||||||
{contact.contact ? (
|
|
||||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
|
||||||
{contact.contact}
|
|
||||||
</Text>
|
|
||||||
) : null}
|
|
||||||
</Space>
|
|
||||||
) : (
|
|
||||||
<Text type="secondary">未指定</Text>
|
|
||||||
)
|
|
||||||
})()}
|
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="履约押金要求">
|
<Descriptions.Item label="履约押金要求">
|
||||||
{viewingSubmission.depositAmountFen ? (
|
{viewingSubmission.depositAmountFen ? (
|
||||||
|
|||||||
@@ -863,13 +863,7 @@ export default function WorkerConsignmentPage() {
|
|||||||
placeholder="请选择对接客服"
|
placeholder="请选择对接客服"
|
||||||
options={contactSupporters.map((item) => ({
|
options={contactSupporters.map((item) => ({
|
||||||
value: item.id,
|
value: item.id,
|
||||||
label: `${item.name}${
|
label: item.name,
|
||||||
item.phone
|
|
||||||
? ` · ${item.phone}`
|
|
||||||
: item.wechat
|
|
||||||
? ` · ${item.wechat}`
|
|
||||||
: ''
|
|
||||||
}`,
|
|
||||||
}))}
|
}))}
|
||||||
notFoundContent="暂无启用中的对接客服"
|
notFoundContent="暂无启用中的对接客服"
|
||||||
showSearch
|
showSearch
|
||||||
|
|||||||
@@ -417,8 +417,6 @@ export type WorkerConsignmentItem = {
|
|||||||
contentJson: Record<string, unknown>
|
contentJson: Record<string, unknown>
|
||||||
contactSupporterId?: number | null
|
contactSupporterId?: number | null
|
||||||
contactSupporterName?: string
|
contactSupporterName?: string
|
||||||
contactSupporterPhone?: string
|
|
||||||
contactSupporterWechat?: string
|
|
||||||
createdAt: string
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,8 +460,6 @@ export type WorkerConsignmentRecord = {
|
|||||||
depositAmountFen: number
|
depositAmountFen: number
|
||||||
contactSupporterId?: number | null
|
contactSupporterId?: number | null
|
||||||
contactSupporterName?: string
|
contactSupporterName?: string
|
||||||
contactSupporterPhone?: string
|
|
||||||
contactSupporterWechat?: string
|
|
||||||
reviewNote: string
|
reviewNote: string
|
||||||
screenshotsJson: string[]
|
screenshotsJson: string[]
|
||||||
giftEvidenceImages?: string[]
|
giftEvidenceImages?: string[]
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ export type GiftEvidenceReviewStatus = 'none' | 'pending' | 'accepted' | 'submit
|
|||||||
export type ConsignmentContactSupporter = {
|
export type ConsignmentContactSupporter = {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
phone: string
|
|
||||||
wechat: string
|
|
||||||
note: string
|
note: string
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
sortOrder: number
|
sortOrder: number
|
||||||
@@ -28,8 +26,6 @@ export type ConsignmentContactSupporter = {
|
|||||||
export type ConsignmentContactFields = {
|
export type ConsignmentContactFields = {
|
||||||
contactSupporterId?: number | null
|
contactSupporterId?: number | null
|
||||||
contactSupporterName?: string
|
contactSupporterName?: string
|
||||||
contactSupporterPhone?: string
|
|
||||||
contactSupporterWechat?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,8 +137,6 @@ export type ConsignmentFulfillmentInfo = {
|
|||||||
/** 对接客服(履约时从现货复制到工单物料,用于工单侧联系) */
|
/** 对接客服(履约时从现货复制到工单物料,用于工单侧联系) */
|
||||||
contactSupporterId?: number | null
|
contactSupporterId?: number | null
|
||||||
contactSupporterName?: string
|
contactSupporterName?: string
|
||||||
contactSupporterPhone?: string
|
|
||||||
contactSupporterWechat?: string
|
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,13 @@
|
|||||||
export type ConsignmentContactDisplay = {
|
export type ConsignmentContactDisplay = {
|
||||||
/** 姓名;没有对接客服时为空串 */
|
/** 姓名;没有对接客服时为空串 */
|
||||||
name: string
|
name: string
|
||||||
/** 联系方式(电话 / 微信),没有时为空串 */
|
/** 姓名,没有时回退为指定文案(默认「未指定」) */
|
||||||
contact: string
|
|
||||||
/** 姓名 + 联系方式,列表里直接展示 */
|
|
||||||
text: string
|
text: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConsignmentContactLike =
|
type ConsignmentContactLike =
|
||||||
| {
|
| {
|
||||||
contactSupporterName?: string | null
|
contactSupporterName?: string | null
|
||||||
contactSupporterPhone?: string | null
|
|
||||||
contactSupporterWechat?: string | null
|
|
||||||
}
|
}
|
||||||
| null
|
| null
|
||||||
| undefined
|
| undefined
|
||||||
@@ -22,16 +18,5 @@ export function formatConsignmentContactSupporter(
|
|||||||
emptyText = '未指定',
|
emptyText = '未指定',
|
||||||
): ConsignmentContactDisplay {
|
): ConsignmentContactDisplay {
|
||||||
const name = String(source?.contactSupporterName || '').trim()
|
const name = String(source?.contactSupporterName || '').trim()
|
||||||
const phone = String(source?.contactSupporterPhone || '').trim()
|
return { name, text: name || emptyText }
|
||||||
const wechat = String(source?.contactSupporterWechat || '').trim()
|
|
||||||
|
|
||||||
const parts: string[] = []
|
|
||||||
if (phone) parts.push(`电话 ${phone}`)
|
|
||||||
if (wechat) parts.push(`微信 ${wechat}`)
|
|
||||||
const contact = parts.join(' · ')
|
|
||||||
|
|
||||||
if (!name) {
|
|
||||||
return { name: '', contact, text: contact || emptyText }
|
|
||||||
}
|
|
||||||
return { name, contact, text: contact ? `${name} · ${contact}` : name }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,14 @@ import test from 'node:test'
|
|||||||
|
|
||||||
import { formatConsignmentContactSupporter } from '../src/utils/consignment-contact.ts'
|
import { formatConsignmentContactSupporter } from '../src/utils/consignment-contact.ts'
|
||||||
|
|
||||||
test('对接客服:姓名 + 电话/微信一起展示', () => {
|
test('对接客服:展示姓名', () => {
|
||||||
const display = formatConsignmentContactSupporter({
|
const display = formatConsignmentContactSupporter({ contactSupporterName: '小张' })
|
||||||
contactSupporterName: '小张',
|
|
||||||
contactSupporterPhone: '13800001111',
|
|
||||||
contactSupporterWechat: 'wx_zhang',
|
|
||||||
})
|
|
||||||
assert.equal(display.name, '小张')
|
assert.equal(display.name, '小张')
|
||||||
assert.equal(display.contact, '电话 13800001111 · 微信 wx_zhang')
|
assert.equal(display.text, '小张')
|
||||||
assert.equal(display.text, '小张 · 电话 13800001111 · 微信 wx_zhang')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('对接客服:只有姓名时不拼联系方式', () => {
|
test('对接客服:姓名首尾空白会被清理', () => {
|
||||||
const display = formatConsignmentContactSupporter({ contactSupporterName: '小李' })
|
assert.equal(formatConsignmentContactSupporter({ contactSupporterName: ' 小李 ' }).text, '小李')
|
||||||
assert.equal(display.text, '小李')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('对接客服:历史数据没有姓名时回退为未指定', () => {
|
test('对接客服:历史数据没有姓名时回退为未指定', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user