fix: fill installation child transaction number

This commit is contained in:
chenxi 2026-08-31 19:47:51 +08:00
parent adae372f17
commit 7bf81ba286

View File

@ -60,13 +60,16 @@ class InstallationDetailMirrorRepository
return ['data' => [], 'ready' => true];
}
$transactionNo = $connection->table($dataset->targetTable())
->where('SourceGuid', $guid)
->value('OrderNum');
$rows = $connection->table($items->targetTable())
->where('guid', $guid)
->orderBy('Id')
->limit(100)
->get();
return ['data' => $rows->map(fn (object $row): array => $this->mapItem((array) $row))->all(), 'ready' => true];
return ['data' => $rows->map(fn (object $row): array => $this->mapItem((array) $row, $transactionNo))->all(), 'ready' => true];
}
private function ready($dataset, $items, string $connection): bool
@ -140,7 +143,7 @@ class InstallationDetailMirrorRepository
}
/** @param array<string,mixed> $row */
private function mapItem(array $row): array
private function mapItem(array $row, mixed $transactionNo = null): array
{
$value = static function (array $row, string ...$names): mixed {
foreach ($names as $name) {
@ -154,7 +157,7 @@ class InstallationDetailMirrorRepository
};
return [
'transaction_no' => $value($row, 'Sourceno', 'source_no', 'orderNum', 'ordernum'),
'transaction_no' => $value($row, 'Sourceno', 'source_no', 'orderNum', 'ordernum') ?? $transactionNo,
'product_id' => $value($row, 'shopproid'),
'id_owner' => $value($row, 'id_owner', 'idOwner'),
'department_owner' => $value($row, 'department_owner', 'departmentOwner'),