1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class WXPopulation extends Model
- {
- protected $table = 'wx_population';
- public $timestamps = false;
- protected static $unguarded = true;
- /**
- * 人群包列表
- */
- public static function populationList($advertiserIdList, $page, $pageSize) {
- $model = self::query()->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];
- }
- }
|