['custom_type', 'phone', 'province'], '%like%' => ['name','master_name'] ]; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/11/11 22:10 */ public function lists(): array { return Custom::field('id,name,custom_type,province,city,area,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(); $city = GeoCity::field('city_name')->where('city_code',$item['city'])->findOrEmpty(); $area = GeoArea::field('area_name')->where('area_code',$item['area'])->findOrEmpty(); $customFollow = CustomFollow::field('date,next_follow_date')->where('custom_id', $item['id'])->order('id', 'desc')->limit(1)->findOrEmpty(); $item['next_follow_date'] = $customFollow['next_follow_date']; $item['last_follow_date'] = $customFollow['date']; $item['follow_total'] = CustomFollow::where('custom_id', $item['id'])->count(); $item['add_user_name'] = $admin['name']; $item['province_name'] = $province['province_name']; $item['city_name'] = $city['city_name']; $item['area_name'] = $area['area_name']; unset($item['province'],$item['city'],$item['area'],$item['add_user']); return $item; }) ->toArray(); } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2023/11/11 22:10 */ public function count(): int { return Custom::where($this->searchWhere)->count(); } }