--- a/application/p/logic/Equipment.php +++ b/application/p/logic/Equipment.php @@ -543,6 +543,10 @@ } public function versionList($where, $page, $pageSize, $orderBy){ $data['row'] = $this->VersionModel->inquiry($where, $page, $pageSize, $orderBy); + foreach ($data['row'] as &$row) { + $row = $this->normalizeVersionDateTimeResponse($row); + } + unset($row); $data['total'] = $this->VersionModel->inquiryCount($where); return $data; } @@ -569,7 +573,25 @@ } public function versionRead($uuid){ $read = $this->VersionModel->read($uuid); + if (is_array($read)) { + $read = $this->normalizeVersionDateTimeResponse($read); + } return $read; + } + + /** MySQL equipment_version.create_time is DATETIME(0); preserve nonzero fractions. */ + private function normalizeVersionDateTimeResponse(array $row): array + { + if (ltrim((string)\think\Config::get('database.type'), '\\') !== \app\cores\database\Dm::class) { + return $row; + } + if (isset($row['create_time']) && is_string($row['create_time']) + && preg_match('/^((\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}))\.0{1,6}$/D', $row['create_time'], $match) + && (int)$match[2] >= 1000 && checkdate((int)$match[3], (int)$match[4], (int)$match[2]) + && (int)$match[5] <= 23 && (int)$match[6] <= 59 && (int)$match[7] <= 59) { + $row['create_time'] = $match[1]; + } + return $row; } /**