diff --git a/zhctproject/store/application/p/logic/GradeEstimation.php b/private/tmp/cdx-store-grade-judgment-20261010/source/application/p/logic/GradeEstimation.php index 7282dea..1c193e5 100644 --- a/zhctproject/store/application/p/logic/GradeEstimation.php +++ b/private/tmp/cdx-store-grade-judgment-20261010/source/application/p/logic/GradeEstimation.php @@ -58,7 +58,7 @@ class GradeEstimation{ //获取uuid $params['uuid'] = guid(); $params['create_time'] = date('Y-m-d H:i:s'); - $params['create_by'] = $user_uuid; + $params['create_by'] = self::normalizeCreateBy($user_uuid, ltrim((string)\think\Config::get('database.type'), '\\') === \app\cores\database\Dm::class); //模型处理 $result = $this->model->insert($params); if (!$result) { @@ -76,6 +76,12 @@ class GradeEstimation{ * @param string $uuid uuid * @return array; */ + /** Preserve this legacy VARCHAR(32) field's observed non-strict MySQL truncation. */ + private static function normalizeCreateBy(string $value, bool $isDm): string + { + return $isDm ? mb_substr($value, 0, 32, 'UTF-8') : $value; + } + public function info($uuid) { try { //查询等级评定是否存在 @@ -86,7 +92,26 @@ class GradeEstimation{ } catch (Exception $e) { return array('code' => 1, 'message' => $e->getMessage()); } - return array('code' => 0, 'message' => '查询成功', 'data' => $result); + return array('code' => 0, 'message' => '查询成功', 'data' => self::normalizeInfoCreateTime($result, ltrim((string)\think\Config::get('database.type'), '\\') === \app\cores\database\Dm::class)); + } + + /** Only this detail's MySQL DATETIME(0) field is normalized at the JSON boundary. */ + private static function normalizeInfoCreateTime(array $info, bool $isDm): array + { + $value = $info['create_time'] ?? null; + if (!$isDm || !is_string($value) + || !preg_match('/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\.\d{1,6}$/D', $value, $parts) + ) { + return $info; + } + $date = \DateTime::createFromFormat('!Y-m-d H:i:s', $parts[1]); + $errors = \DateTime::getLastErrors(); + if ($date && ($errors === false || ($errors['warning_count'] === 0 && $errors['error_count'] === 0)) + && $date->format('Y-m-d H:i:s') === $parts[1] + ) { + $info['create_time'] = $parts[1]; + } + return $info; } /** * 等级评定修改