diff --git a/Server/application/common/model/TrafficPool.php b/Server/application/common/model/TrafficPool.php new file mode 100644 index 00000000..c7ce2450 --- /dev/null +++ b/Server/application/common/model/TrafficPool.php @@ -0,0 +1,19 @@ +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 json([ + 'code' => 200, + 'msg' => '获取成功', + 'data' => [ + 'list' => $this->makeReturnedValue($list)->items(), + 'total' => $list->total(), + 'page' => $list->currentPage(), + 'limit' => $list->listRows() + ] + ]); + } +} \ No newline at end of file