--- a/app/terminal/model/UploadFile.php +++ b/app/terminal/model/UploadFile.php @@ -62,12 +62,12 @@ * 获取全部记录 * @param array $param * @param array $where - * @return \think\Collection + * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function getAll(array $param = []): \think\Collection + public function getAll(array $param = []): array { // 商品列表获取条件 $params = $this->setQueryDefaultValue($param, [ --- a/app/common/model/SignAction.php +++ b/app/common/model/SignAction.php @@ -24,6 +24,28 @@ // 定义主键 protected $pk = 'id'; + public function getStartTimeAttr($value) + { + return $this->formatSignDateTime($value); + } + + public function getEndTimeAttr($value) + { + return $this->formatSignDateTime($value); + } + + private function formatSignDateTime($value) + { + if (!is_string($value) + || !preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})\.0{1,6}$/D', $value, $parts) + || !checkdate((int)$parts[2], (int)$parts[3], (int)$parts[1]) + || (int)$parts[4] > 23 || (int)$parts[5] > 59 || (int)$parts[6] > 59 + || !($this->db()->getConnection() instanceof \app\common\database\Dm)) { + return $value; + } + return substr($value, 0, 19); + } + /** * 活动详情 * @param int $siginId 活动ID @@ -52,4 +74,4 @@ { return $this->hasMany("SignAddress", 'action_id')->where(['is_delete' => 0]); } -} \ No newline at end of file +}