param('building_name'); $start_time = request()->param('start_time'); //时间戳 $end_time = request()->param('end_time'); //时间戳 if (empty($building_name)) { return $this->buildFailed('缺少物业名称'); } $map = []; $data = []; // foreach ($building_name as $key=>$value) { // unset($map); // if (!empty($start_time)) { // $map[] = ['create_time', '>', $start_time]; // } // if (!empty($end_time)) { // $map[] = ['create_time', '<', $end_time]; // } // $map[] = ['property_name', 'like', $value.'%']; // $eva_unit_price = $this->getSearch($map); // $data[] = ['building_name'=>$value, 'eva_unit_price'=>$eva_unit_price]; // } if (!empty($start_time)) { $map[] = ['create_time', '>', $start_time]; } if (!empty($end_time)) { $map[] = ['create_time', '<', $end_time]; } $map[] = ['property_name', 'like', $building_name.'%']; $eva_unit_price = $this->getSearch($map); $data[] = ['building_name'=>$building_name, 'eva_unit_price'=>$eva_unit_price]; return $this->buildSuccess(['estate_list'=>$data]); } public function getSearch($where) { $eva_unit_price = Db::name('return_price') ->where($where) ->order('create_time', 'desc') ->field('eva_unit_price') ->find(); if ($eva_unit_price) { return $eva_unit_price['eva_unit_price']; } else { return 0; } } }