优化角色显示和订单查询
This commit is contained in:
@@ -450,7 +450,9 @@ export async function listAdminCloudtentaclesDeliveryRecords(
|
||||
});
|
||||
const enrichedItems = recordItems
|
||||
.map((record) => {
|
||||
const localMatch = findBestLocalTaskForRecord(record, localTasks);
|
||||
const localMatch = platformOrderId
|
||||
? findStrictLocalTaskForOrderRecord(record, localTasks)
|
||||
: findBestLocalTaskForRecord(record, localTasks);
|
||||
return {
|
||||
...record,
|
||||
...(skuImageByName.get(normalizeSkuName(record.name)) || {
|
||||
@@ -781,6 +783,44 @@ function findBestLocalTaskForRecord(
|
||||
return best && best.score >= 35 ? best : null;
|
||||
}
|
||||
|
||||
function findStrictLocalTaskForOrderRecord(
|
||||
record: JsonObject,
|
||||
tasks: LocalCloudtentaclesTask[] = []
|
||||
) {
|
||||
let best: { task: LocalCloudtentaclesTask; score: number; confidence: string } | null = null;
|
||||
|
||||
for (const task of tasks) {
|
||||
if (!isSameDispatchedResource(record, task)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const score = scoreLocalTaskRecordMatch(record, task);
|
||||
if (score <= 0 || (best && score <= best.score)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
best = {
|
||||
task,
|
||||
score,
|
||||
confidence: score >= 80 ? "high" : "medium",
|
||||
};
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
function isSameDispatchedResource(record: JsonObject, task: LocalCloudtentaclesTask) {
|
||||
const recordVnId = normalizeNumber(record.virtualNumberId);
|
||||
const recordPhone = normalizePhone(record.phone);
|
||||
const taskPhone = normalizePhone(task.vnPhone);
|
||||
|
||||
if (recordVnId > 0 && task.vnId > 0 && recordVnId === task.vnId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Boolean(recordPhone && taskPhone && recordPhone === taskPhone);
|
||||
}
|
||||
|
||||
function scoreLocalTaskRecordMatch(record: JsonObject, task: LocalCloudtentaclesTask) {
|
||||
let score = 0;
|
||||
const recordVnId = normalizeNumber(record.virtualNumberId);
|
||||
|
||||
Reference in New Issue
Block a user