each(function ($item) { $item->gender = $this->formatGender($item->gender); $item->addTime = $this->formatDate($item->addTime); $item->tags = $this->handlTags($item->tags); }); return $list; } /** * 构建查询. * * @return TrafficPoolModel|\think\Paginator */ protected function gePoolList(): \think\Paginator { $query = TrafficPoolModel::alias('tp') ->field([ 'ts.id', 'tp.wechatId', 'ts.createTime as addTime', 'ts.fromd as source', 'c.name as projectName', 'wa.avatar', 'wa.gender', 'wa.nickname', 'wa.region', 'wt.tags' ]) ->join('traffic_source ts', 'tp.identifier = ts.identifier', 'RIGHT') ->join('company c', 'ts.companyId = c.companyId', 'LEFT') ->join('wechat_account wa', 'tp.wechatId = wa.wechatId', 'LEFT') ->join('wechat_tag wt', 'wa.wechatId = wt.wechatId', 'LEFT'); return $query->paginate($this->request->param('limit/d', 10), false, ['page' => $this->request->param('page/d', 1)]); } /** * 获取客户池列表 * * @return \think\response\Json */ public function index() { $list = $this->gePoolList(); return ResponseHelper::success( [ 'list' => $this->makeReturnedValue($list)->items(), 'total' => $list->total(), 'page' => $list->currentPage(), 'limit' => $list->listRows() ] ); } }