fix(worker-platform): 支持寄售筛选叠加接单人员
This commit is contained in:
@@ -1526,12 +1526,9 @@ export function buildWorkOrderWhere({
|
|||||||
if (acceptanceMode) {
|
if (acceptanceMode) {
|
||||||
const rawMode = String(acceptanceMode).trim()
|
const rawMode = String(acceptanceMode).trim()
|
||||||
if (rawMode === 'internal_consignment') {
|
if (rawMode === 'internal_consignment') {
|
||||||
filters.push(`(
|
// 「寄售来源」与是否已经匹配打手是两个正交条件。
|
||||||
wo.material_json->'consignment'->>'inventoryId' IS NOT NULL
|
// 这里不能内置“必须未指派”,否则再接 workerId 筛选会恒为空。
|
||||||
AND (wo.material_json->'consignment'->>'fulfillmentType' IS NULL OR wo.material_json->'consignment'->>'fulfillmentType' != 'worker_deposit')
|
filters.push(`wo.material_json->'consignment'->>'inventoryId' IS NOT NULL`)
|
||||||
AND (wo.material_json->'consignment'->>'workerId' IS NULL OR wo.material_json->'consignment'->>'workerId' = '0')
|
|
||||||
AND (wo.assigned_worker_id IS NULL OR wo.assigned_worker_id = 0)
|
|
||||||
)`)
|
|
||||||
} else if (rawMode === WORK_ORDER_ACCEPTANCE_MODE.FRIEND_GIFT) {
|
} else if (rawMode === WORK_ORDER_ACCEPTANCE_MODE.FRIEND_GIFT) {
|
||||||
filters.push(`(
|
filters.push(`(
|
||||||
wo.acceptance_mode = 'friend_gift'
|
wo.acceptance_mode = 'friend_gift'
|
||||||
|
|||||||
@@ -1970,15 +1970,22 @@ test('好友赠送待打手提交资料筛选排除待抢单订单', () => {
|
|||||||
assert.match(whereClause, /wo\.status IN \('in_progress', 'problem'\)/)
|
assert.match(whereClause, /wo\.status IN \('in_progress', 'problem'\)/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('工单筛选支持内部寄售匹配与打手好友赠送隔离,且赠送冷却中排除已验收已取消工单', () => {
|
test('工单筛选支持内部寄售来源叠加人员条件,并保持好友赠送与冷却筛选', () => {
|
||||||
const internalQuery = buildWorkOrderWhere({ acceptanceMode: 'internal_consignment' })
|
const internalQuery = buildWorkOrderWhere({ acceptanceMode: 'internal_consignment' })
|
||||||
assert.match(
|
assert.match(
|
||||||
internalQuery.whereClause,
|
internalQuery.whereClause,
|
||||||
/wo\.material_json->'consignment'->>'inventoryId' IS NOT NULL/,
|
/wo\.material_json->'consignment'->>'inventoryId' IS NOT NULL/,
|
||||||
)
|
)
|
||||||
|
assert.doesNotMatch(internalQuery.whereClause, /wo\.assigned_worker_id IS NULL/)
|
||||||
|
|
||||||
|
const workerScopedInternalQuery = buildWorkOrderWhere({
|
||||||
|
acceptanceMode: 'internal_consignment',
|
||||||
|
workerSharingId: 25,
|
||||||
|
})
|
||||||
|
assert.match(workerScopedInternalQuery.joins, /worker_visible\.work_order_id = wo\.id/)
|
||||||
assert.match(
|
assert.match(
|
||||||
internalQuery.whereClause,
|
workerScopedInternalQuery.whereClause,
|
||||||
/wo\.assigned_worker_id IS NULL OR wo\.assigned_worker_id = 0/,
|
/wo\.material_json->'consignment'->>'inventoryId' IS NOT NULL/,
|
||||||
)
|
)
|
||||||
|
|
||||||
const friendGiftQuery = buildWorkOrderWhere({ acceptanceMode: 'friend_gift' })
|
const friendGiftQuery = buildWorkOrderWhere({ acceptanceMode: 'friend_gift' })
|
||||||
|
|||||||
@@ -34,11 +34,10 @@ export type ConsignmentWorkerDisplayInfo = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内部现货履约单:由客服/内部仓代交付,工单上没有接单打手。
|
* 尚未匹配打手的内部现货履约单:由客服/内部仓代交付,工单上没有接单打手。
|
||||||
*
|
*
|
||||||
* 口径必须与后端「内部寄售匹配」筛选(work-order-query-repo 的 internal_consignment 分支)一致:
|
* 这是操作能力判断,不用于「内部寄售」来源筛选;来源筛选允许匹配前后,
|
||||||
* `material.consignment.inventoryId` 有值、`fulfillmentType ≠ worker_deposit`、
|
* 因此可以和接单人员条件叠加。
|
||||||
* `consignment.workerId` 缺失或为 0(后端按字符串 '0' 也视为无打手)、且工单未指派打手。
|
|
||||||
*/
|
*/
|
||||||
export function isInternalConsignmentOrder(row: { material?: unknown; worker?: unknown }): boolean {
|
export function isInternalConsignmentOrder(row: { material?: unknown; worker?: unknown }): boolean {
|
||||||
const consignment = asRecord(asRecord(row.material).consignment)
|
const consignment = asRecord(asRecord(row.material).consignment)
|
||||||
|
|||||||
Reference in New Issue
Block a user