--- a/application/p/logic/BillingRecord.php +++ b/application/p/logic/BillingRecord.php @@ -208,7 +208,15 @@ ->where('store_id', $this->getStoreId()) ->order(['id' => 'asc']) ->select(); - return $this->rowsToArray($rows); + $rows = $this->rowsToArray($rows); + $isDm = ltrim((string)\think\Config::get('database.type'), '\\') === \app\cores\database\Dm::class; + foreach ($rows as &$row) { + if (array_key_exists('create_time', $row)) { + $row['create_time'] = self::normalizeTimePrecision($row['create_time'], $isDm); + } + } + unset($row); + return $rows; } public function adjustAmount($billId, array $meals, $reason, $operator) @@ -1133,12 +1141,25 @@ private function formatNullableTime($time) { + $time = self::normalizeTimePrecision($time, ltrim((string)\think\Config::get('database.type'), '\\') === \app\cores\database\Dm::class); if (empty($time) || $time === self::EMPTY_TIME || $time === '2000-01-01') { return '--'; } return $time; } + private static function normalizeTimePrecision($time, bool $isDm) + { + if (!$isDm || !is_string($time) || !preg_match('/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\.\d{1,6}$/', $time, $parts)) { + return $time; + } + $date = \DateTime::createFromFormat('!Y-m-d H:i:s', $parts[1]); + if (!$date || substr($parts[1], 0, 4) === '0000' || $date->format('Y-m-d H:i:s') !== $parts[1]) { + return $time; + } + return $parts[1]; + } + private function maskMobile($mobile) { $mobile = trim((string)$mobile);