diff --git a/src/DataService.php b/src/DataService.php index c8bb5b4..5021f8f 100644 --- a/src/DataService.php +++ b/src/DataService.php @@ -544,7 +544,51 @@ private function formatRowData(array $rowData): string // Если не удалось распарсить - возвращаем как есть return $date; } + // ✅ ДОБАВЬТЕ ЭТИ ДВА МЕТОДА СЮДА: + + private function isNumericType(string $dataType): bool + { + $numericTypes = [ + 'int', 'tinyint', 'smallint', 'mediumint', 'bigint', + 'decimal', 'float', 'double', 'numeric', 'real' + ]; + + $dataType = strtolower($dataType); + + foreach ($numericTypes as $type) { + if (str_contains($dataType, $type)) { + return true; + } + } + + return false; + } + private function convertNumericFormat($value) + { + if ($value === null || $value === '') { + return null; + } + + $value = trim((string)$value); + $value = str_replace(' ', '', $value); + + if (strpos($value, ',') === false) { + return is_numeric($value) ? $value : null; + } + + $lastCommaPos = strrpos($value, ','); + $lastDotPos = strrpos($value, '.'); + + if ($lastCommaPos > $lastDotPos) { + $value = str_replace('.', '', $value); + $value = str_replace(',', '.', $value); + } else { + $value = str_replace(',', '', $value); + } + + return is_numeric($value) ? $value : null; + } public function exportCSV( string $schema, string $table,