From 17a9857511a3a5295505cb1ae271849696283b84 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 13 Dec 2023 14:04:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=A2=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/lists/custom/CustomLists.php | 19 +++++++++++++++++++ .../model/custom_follow/CustomFollow.php | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/app/adminapi/lists/custom/CustomLists.php b/app/adminapi/lists/custom/CustomLists.php index 54e4c1e64..44f8aaf21 100644 --- a/app/adminapi/lists/custom/CustomLists.php +++ b/app/adminapi/lists/custom/CustomLists.php @@ -17,6 +17,7 @@ namespace app\adminapi\lists\custom; use app\adminapi\lists\BaseAdminDataLists; use app\common\model\custom\Custom; +use app\common\model\custom_follow\CustomFollow; use app\common\lists\ListsSearchInterface; @@ -66,6 +67,24 @@ class CustomLists extends BaseAdminDataLists implements ListsSearchInterface $item['other_contacts'] = $otherContactsArray; } } + $item['last_follow_date'] = '-'; + $item['next_follow_date'] = '-'; + $customFollow = CustomFollow::where('custom_id', $item['id'])->order('id', 'desc')->limit(1)->findOrEmpty(); + if (!$customFollow->isEmpty()) { + $interval = date_diff(date_create($customFollow['date']), date_create(date('Y-m-d H:i:s'))); + if ($interval->days <= 3) { + $item['last_follow_date'] = $interval->days . '天内'; + } else if ($interval->days <= 7) { + $item['last_follow_date'] = '1周内'; + } else if ($interval->days <= 30) { + $item['last_follow_date'] = '30天内'; + } else if ($interval->days <= 60) { + $item['last_follow_date'] = '60天内'; + } else { + $item['last_follow_date'] = '超过60天内'; + } + $item['next_follow_date'] = $customFollow['next_follow_date']; + } return $item; })->toArray(); } diff --git a/app/common/model/custom_follow/CustomFollow.php b/app/common/model/custom_follow/CustomFollow.php index c9f312d21..db1f171b2 100644 --- a/app/common/model/custom_follow/CustomFollow.php +++ b/app/common/model/custom_follow/CustomFollow.php @@ -35,5 +35,10 @@ class CustomFollow extends BaseModel return empty($value) ? '' : date('Y-m-d H:i:s', $value); } + public function getNextFollowDateAttr($value) + { + return empty($value) ? '' : date('Y-m-d H:i:s', $value); + } + } \ No newline at end of file