diff --git a/zhctproject/store/application/p/logic/SportEducation.php b/private/tmp/cdx-store-sport-archive-20261010/source/application/p/logic/SportEducation.php index a0243b1..a98bfe7 100644 --- a/zhctproject/store/application/p/logic/SportEducation.php +++ b/private/tmp/cdx-store-sport-archive-20261010/source/application/p/logic/SportEducation.php @@ -58,7 +58,7 @@ class SportEducation{ //获取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) { @@ -69,6 +69,12 @@ class SportEducation{ } return array('code' => 0, 'message' => '添加成功'); } + /** 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; + } + /** * 身运教关系单条记录 * @name 张晓龙 @@ -86,7 +92,26 @@ class SportEducation{ } 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; } /** * 运教关系修改