增强工单游戏资料搜索
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
-- 031_work_order_search.sql —— 扩展接单工单搜索字段并建立模糊检索索引。
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_work_orders_search_text_trgm
|
||||
ON work_orders USING gin (
|
||||
LOWER(
|
||||
COALESCE(work_order_no, '') || ' ' ||
|
||||
COALESCE(platform_order_id, '') || ' ' ||
|
||||
COALESCE(product_name, '') || ' ' ||
|
||||
COALESCE(material_json->'collect'->'fields'->>'gameId', '') || ' ' ||
|
||||
COALESCE(material_json->'collect'->'fields'->>'gameNickname', '') || ' ' ||
|
||||
COALESCE(material_json->'collect'->'fields'->>'gameAccount', '') || ' ' ||
|
||||
COALESCE(material_json->'collect'->'fields'->>'roleName', '') || ' ' ||
|
||||
COALESCE(material_json->'fields'->>'gameId', '') || ' ' ||
|
||||
COALESCE(material_json->'fields'->>'gameNickname', '') || ' ' ||
|
||||
COALESCE(material_json->>'gameId', '') || ' ' ||
|
||||
COALESCE(material_json->>'gameNickname', '')
|
||||
) gin_trgm_ops
|
||||
);
|
||||
|
||||
COMMENT ON INDEX idx_work_orders_search_text_trgm IS '接单工单模糊搜索:订单号、商品名、游戏 ID/昵称及历史字段';
|
||||
@@ -65,6 +65,23 @@ type WorkOrderStatisticsRow = {
|
||||
refund_amount: number | string
|
||||
}
|
||||
|
||||
/** 工单统一搜索字段,兼容当前资料结构和历史资料字段。 */
|
||||
function workOrderSearchExpression(alias = 'wo') {
|
||||
return `LOWER(
|
||||
COALESCE(${alias}.work_order_no, '') || ' ' ||
|
||||
COALESCE(${alias}.platform_order_id, '') || ' ' ||
|
||||
COALESCE(${alias}.product_name, '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->'collect'->'fields'->>'gameId', '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->'collect'->'fields'->>'gameNickname', '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->'collect'->'fields'->>'gameAccount', '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->'collect'->'fields'->>'roleName', '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->'fields'->>'gameId', '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->'fields'->>'gameNickname', '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->>'gameId', '') || ' ' ||
|
||||
COALESCE(${alias}.material_json->>'gameNickname', '')
|
||||
)`
|
||||
}
|
||||
|
||||
export async function listWorkOrderShares(
|
||||
workOrderId: number | string,
|
||||
): Promise<WorkOrderShareRow[]> {
|
||||
@@ -2821,9 +2838,7 @@ function buildWorkOrderWhere({
|
||||
}
|
||||
if (keyword) {
|
||||
params.push(`%${keyword}%`)
|
||||
filters.push(
|
||||
`(wo.work_order_no ILIKE $${params.length} OR wo.platform_order_id ILIKE $${params.length} OR wo.product_name ILIKE $${params.length})`,
|
||||
)
|
||||
filters.push(`${workOrderSearchExpression()} LIKE LOWER($${params.length})`)
|
||||
}
|
||||
if (workerId) {
|
||||
params.push(workerId)
|
||||
|
||||
@@ -912,7 +912,7 @@ export default function WorkOrdersPanel() {
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="订单号或商品名"
|
||||
placeholder="订单号 / 商品名 / 游戏ID / 游戏昵称"
|
||||
style={{ width: 280 }}
|
||||
onChange={(event) => setKeywordInput(event.target.value)}
|
||||
onPressEnter={searchOrders}
|
||||
|
||||
@@ -327,7 +327,7 @@ export default function WorkerHallPage() {
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="搜索商品 / 订单号"
|
||||
placeholder="搜索商品 / 订单号 / 游戏ID / 游戏昵称"
|
||||
prefix={<SearchOutlined />}
|
||||
className="worker-hall-mobile-search-input"
|
||||
onChange={(event) => {
|
||||
@@ -524,7 +524,7 @@ export default function WorkerHallPage() {
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="搜索商品名称 / 订单号"
|
||||
placeholder="搜索商品名称 / 订单号 / 游戏ID / 游戏昵称"
|
||||
prefix={<SearchOutlined />}
|
||||
onChange={(event) => {
|
||||
const nextKeyword = event.target.value
|
||||
|
||||
@@ -659,7 +659,7 @@ export default function WorkerOrdersPage() {
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="搜索订单号 / 商品名"
|
||||
placeholder="搜索订单号 / 商品名 / 游戏ID / 游戏昵称"
|
||||
prefix={<SearchOutlined />}
|
||||
className="worker-orders-mobile-search-input"
|
||||
onChange={(event) => {
|
||||
@@ -986,7 +986,7 @@ export default function WorkerOrdersPage() {
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="搜索订单号 / 商品名"
|
||||
placeholder="搜索订单号 / 商品名 / 游戏ID / 游戏昵称"
|
||||
prefix={<SearchOutlined />}
|
||||
onChange={(event) => {
|
||||
const nextValue = event.target.value
|
||||
|
||||
Reference in New Issue
Block a user