Merge branch 'master' into master-5-28
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -563,6 +563,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
try {
|
||||
$id = (int) ($params['id'] ?? 0);
|
||||
$toAssistantId = (int) ($params['assistant_id'] ?? 0);
|
||||
$isInherit = (int) ($params['is_inherit'] ?? 0) === 1 && $toAssistantId > 0 ? 1 : 0;
|
||||
if ($id <= 0) {
|
||||
self::setError('诊单不存在');
|
||||
|
||||
@@ -623,6 +624,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
'ip' => (string) ($req->ip() ?? ''),
|
||||
'related_po_creator_id' => $relatedPoCreatorId,
|
||||
'related_po_create_time' => $relatedPoCreateTime,
|
||||
'is_inherit' => $isInherit,
|
||||
'create_time' => $now,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
@@ -696,6 +698,9 @@ class DiagnosisLogic extends BaseLogic
|
||||
$r['related_po_create_time_text'] = $rpct > 0 ? date('Y-m-d H:i:s', $rpct) : '';
|
||||
$r['related_po_is_cleared_assistant_creator'] =
|
||||
($rcpId > 0 && $fromId > 0 && $rcpId === $fromId) ? 1 : 0;
|
||||
$inherit = (int) ($r['is_inherit'] ?? 0);
|
||||
$r['is_inherit'] = $inherit;
|
||||
$r['is_inherit_text'] = $inherit === 1 ? '是' : '否';
|
||||
}
|
||||
unset($r);
|
||||
|
||||
|
||||
@@ -1291,4 +1291,121 @@ class ExpressTrackingService
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提成结算 overview 等大批量场景:按订单批量从库表推导签收时间(不调用快递100)。
|
||||
* 语义与 YejiStatsLogic 物流子查询 / effectiveSignUnixFromTrackingDetail 对齐。
|
||||
*
|
||||
* @param list<array{order_id: int, tracking_number?: string}> $items
|
||||
*
|
||||
* @return array<int, int> order_id => sign unix
|
||||
*/
|
||||
public static function batchResolveSignUnixFromDbForOrders(array $items): array
|
||||
{
|
||||
if ($items === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$orderIds = [];
|
||||
$tnByOrder = [];
|
||||
$trackingNums = [];
|
||||
foreach ($items as $it) {
|
||||
if (!is_array($it)) {
|
||||
continue;
|
||||
}
|
||||
$oid = (int) ($it['order_id'] ?? 0);
|
||||
if ($oid <= 0) {
|
||||
continue;
|
||||
}
|
||||
$orderIds[$oid] = true;
|
||||
$tn = trim((string) ($it['tracking_number'] ?? ''));
|
||||
$tnByOrder[$oid] = $tn;
|
||||
if ($tn !== '') {
|
||||
$trackingNums[$tn] = true;
|
||||
}
|
||||
}
|
||||
$orderIds = array_keys($orderIds);
|
||||
if ($orderIds === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$trackingById = [];
|
||||
$orderToTrackingIds = [];
|
||||
$tnToTrackingIds = [];
|
||||
|
||||
$attachTrackingRow = static function (array $etRow) use (&$trackingById, &$orderToTrackingIds, &$tnToTrackingIds): void {
|
||||
$tid = (int) ($etRow['id'] ?? 0);
|
||||
if ($tid <= 0) {
|
||||
return;
|
||||
}
|
||||
$trackingById[$tid] = $etRow;
|
||||
$oid = (int) ($etRow['order_id'] ?? 0);
|
||||
if ($oid > 0) {
|
||||
$orderToTrackingIds[$oid][$tid] = true;
|
||||
}
|
||||
$tn = trim((string) ($etRow['tracking_number'] ?? ''));
|
||||
if ($tn !== '') {
|
||||
$tnToTrackingIds[$tn][$tid] = true;
|
||||
}
|
||||
};
|
||||
|
||||
foreach (array_chunk($orderIds, 800) as $chunk) {
|
||||
$byOrderId = ExpressTracking::with(['traces' => static function ($query): void {
|
||||
$query->order('trace_time_stamp', 'desc');
|
||||
}])
|
||||
->whereIn('order_id', $chunk)
|
||||
->whereNull('delete_time')
|
||||
->select();
|
||||
foreach ($byOrderId as $tracking) {
|
||||
$row = $tracking->toArray();
|
||||
$row['traces'] = $tracking->traces ? $tracking->traces->toArray() : [];
|
||||
$attachTrackingRow($row);
|
||||
}
|
||||
}
|
||||
|
||||
$trackingNumList = array_keys($trackingNums);
|
||||
if ($trackingNumList !== []) {
|
||||
foreach (array_chunk($trackingNumList, 400) as $chunk) {
|
||||
$byTn = ExpressTracking::with(['traces' => static function ($query): void {
|
||||
$query->order('trace_time_stamp', 'desc');
|
||||
}])
|
||||
->whereRaw('TRIM(`tracking_number`) IN (' . implode(',', array_fill(0, count($chunk), '?')) . ')', $chunk)
|
||||
->whereNull('delete_time')
|
||||
->select();
|
||||
foreach ($byTn as $tracking) {
|
||||
$row = $tracking->toArray();
|
||||
$row['traces'] = $tracking->traces ? $tracking->traces->toArray() : [];
|
||||
$attachTrackingRow($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$out = [];
|
||||
foreach ($orderIds as $oid) {
|
||||
$oid = (int) $oid;
|
||||
$candidateIds = [];
|
||||
foreach (array_keys($orderToTrackingIds[$oid] ?? []) as $tid) {
|
||||
$candidateIds[(int) $tid] = true;
|
||||
}
|
||||
$tn = $tnByOrder[$oid] ?? '';
|
||||
if ($tn !== '') {
|
||||
foreach (array_keys($tnToTrackingIds[$tn] ?? []) as $tid) {
|
||||
$candidateIds[(int) $tid] = true;
|
||||
}
|
||||
}
|
||||
$best = 0;
|
||||
foreach (array_keys($candidateIds) as $tid) {
|
||||
$detail = $trackingById[(int) $tid] ?? null;
|
||||
if (!is_array($detail)) {
|
||||
continue;
|
||||
}
|
||||
$best = max($best, self::effectiveSignUnixFromTrackingDetail($detail));
|
||||
}
|
||||
if ($best > 0) {
|
||||
$out[$oid] = $best;
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user