From cb7d5078fe7c7d8c001ca991ef84e2e10266eb36 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 22 Aug 2025 14:31:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=9F=E8=BF=9B=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/crm/model/Follow.php | 23 +++++++++++++++++------ app/crm/service/FollowService.php | 5 ++++- app/crmAdmin/service/CustomerService.php | 3 +++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/crm/model/Follow.php b/app/crm/model/Follow.php index bc284c6..f57ef18 100644 --- a/app/crm/model/Follow.php +++ b/app/crm/model/Follow.php @@ -36,11 +36,22 @@ class Follow extends Model * * @var bool */ - public $timestamps = true; + public $timestamps = false; - protected $casts = [ - 'follow_time' => 'timestamp', // 指定序列化格式 - 'updated_at' => 'timestamp', // 指定序列化格式 - 'created_at' => 'timestamp', // 指定序列化格式 - ]; + /** + * 在保存时手动设置时间戳 + */ + protected static function boot() + { + parent::boot(); + + static::creating(function ($model) { + $model->created_at = time(); + $model->updated_at = time(); + }); + + static::updating(function ($model) { + $model->updated_at = time(); + }); + } } \ No newline at end of file diff --git a/app/crm/service/FollowService.php b/app/crm/service/FollowService.php index e300f11..e8ec322 100644 --- a/app/crm/service/FollowService.php +++ b/app/crm/service/FollowService.php @@ -60,7 +60,10 @@ class FollowService } $follow['picture_full'] = $oss_picture; - $follow = Util::formatDate($follow,['created_at','updated_at','follow_time']); +// $follow = Util::formatDate($follow,['created_at','updated_at','follow_time']); + $follow['follow_time'] = empty($follow['follow_time'])?'':date('Y-m-d H:i:s', $follow['follow_time']); + $follow['created_at'] = empty($follow['created_at'])?'':date('Y-m-d H:i:s', $follow['created_at']); + $follow['updated_at'] = empty($follow['updated_at'])?'':date('Y-m-d H:i:s', $follow['updated_at']);; // $follow = Util::formatDate($follow); return $follow; } diff --git a/app/crmAdmin/service/CustomerService.php b/app/crmAdmin/service/CustomerService.php index f8589de..20f4137 100644 --- a/app/crmAdmin/service/CustomerService.php +++ b/app/crmAdmin/service/CustomerService.php @@ -470,6 +470,9 @@ class CustomerService $ossservice = new OssService(); foreach ($follow as $item) { $item = Util::formatDate($item,['created_at','updated_at','follow_time']); + $item['follow_time'] = empty($item['follow_time'])?'':date('Y-m-d H:i:s', $item['follow_time']); + $item['created_at'] = empty($item['created_at'])?'':date('Y-m-d H:i:s', $item['created_at']); + $item['updated_at'] = empty($item['updated_at'])?'':date('Y-m-d H:i:s', $item['updated_at']);; $item['picture_full'] = empty($item->picture)?'':$ossservice->generatePrivateUrl($item->picture); }