whereIn('advertiser_id', $advertiserIdList)->where('enable', 1); $countModel = clone $model; $count = $countModel->count(); $data = $model->selectRaw('id, advertiser_id, orientation_id, orientation_name')->offset(($page - 1) * $pageSize) ->limit($pageSize)->get(); return [$data, $count]; } public static function populationListTest($advertiserIdList, $page, $pageSize) { $data = [ [ 'id' => 1, 'advertiser_id' => 50277633, 'orientation_id' => 162018525, 'orientation_name' => '美团APP已安装' ], [ 'id' => 2, 'advertiser_id' => 50277633, 'orientation_id' => 161633748, 'orientation_name' => '百补' ] ]; return [$data, 2]; } /** * 人群包列表 * */ public static function getPopulationList($advertiserId, $orientationId, $orientationName, $page, $pageSize) { $queryModel = self::query(); # 按广告账户搜索 if($advertiserId) $queryModel->where('advertiser_id', 'like', '%'.$advertiserId.'%'); # 按人群包id搜索 if($orientationId) $queryModel->where('orientation_id', 'like', '%'.$orientationId.'%'); # 按人群包名称搜索 if($orientationName) $queryModel->where('orientation_name', 'like', '%'.$orientationName.'%'); $count = $queryModel->count(); $list = $queryModel->select('id', 'advertiser_id', 'orientation_id', 'orientation_name', 'enable')->offset(($page - 1) * $pageSize) ->limit($pageSize)->orderBy('id', 'desc') ->get(); return [$list, $count]; } }