From 46620b3dcac6a3f755c4840cd10b2aa2f4cb86c2 Mon Sep 17 00:00:00 2001 From: weiz Date: Tue, 2 Jan 2024 16:23:53 +0800 Subject: [PATCH] update --- app/adminapi/lists/custom/CustomLists.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/adminapi/lists/custom/CustomLists.php b/app/adminapi/lists/custom/CustomLists.php index d426246bb..a95d6949a 100644 --- a/app/adminapi/lists/custom/CustomLists.php +++ b/app/adminapi/lists/custom/CustomLists.php @@ -19,6 +19,7 @@ use app\adminapi\lists\BaseAdminDataLists; use app\common\lists\ListsSearchInterface; use app\common\model\auth\Admin; use app\common\model\custom\Custom; +use app\common\model\custom\CustomFollow; use app\common\model\GeoProvince; /** @@ -93,13 +94,33 @@ class CustomLists extends BaseAdminDataLists implements ListsSearchInterface // return $item; // }) // ->toArray(); - return Custom::field('id,name,custom_type,province,master_name,master_position,master_telephone,master_phone,notes,add_user,create_time') + return Custom::field('id,name,custom_type,province,notes,master_name,master_position,master_telephone,master_phone,master_notes,add_user,create_time') ->where($this->searchWhere)->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $item['custom_type_text'] = $item->custom_type_text; $admin = Admin::field('id,name')->where('id',$item['add_user'])->findOrEmpty(); $province = GeoProvince::field('province_name')->where('province_code',$item['province'])->findOrEmpty(); + $item['last_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 <= 0) { + $item['last_follow_date'] = '今天'; + }else 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']; + } + $item['follow_total'] = CustomFollow::where('custom_id', $item['id'])->count(); $item['add_user_name'] = $admin['name']; $item['province_name'] = $province['province_name']; unset($item['province'],$item['add_user']);