diff --git a/zhctproject/store/application/p/logic/JudgmentRank.php b/private/tmp/cdx-store-grade-judgment-20261010/source/application/p/logic/JudgmentRank.php index 8bf34e9..2ef23c8 100644 --- a/zhctproject/store/application/p/logic/JudgmentRank.php +++ b/private/tmp/cdx-store-grade-judgment-20261010/source/application/p/logic/JudgmentRank.php @@ -29,7 +29,7 @@ class JudgmentRank public function add($params, $createBy) { try { $params['uuid'] = guid(); - $params['create_by'] = $createBy; + $params['create_by'] = self::normalizeCreateBy($createBy, ltrim((string)\think\Config::get('database.type'), '\\') === \app\cores\database\Dm::class); $params['create_time'] = date("Y-m-d H:i:s"); $res = $this->model->add($params); if(!$res) { @@ -102,8 +102,36 @@ class JudgmentRank return ['code' => 0, 'message' => '修改成功', 'data' => []]; } + /** 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) { $info = $this->model->read($uuid); + if (is_array($info)) { + $info = self::normalizeInfoCreateTime($info, ltrim((string)\think\Config::get('database.type'), '\\') === \app\cores\database\Dm::class); + } return ['code' => 0, 'message' => '', 'data' => $info]; } -} \ No newline at end of file + + /** 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; + } +}