From 90c3ed5dc418d18acffd1b07e9fb92ce64131c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Tue, 13 May 2025 17:21:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=93=8D=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E6=B5=81=E9=87=8F=E6=B1=A0=E5=88=97=E8=A1=A8=E5=B7=B2?= =?UTF-8?q?=E8=BD=AC=E5=8C=96=E7=9A=84=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/application/cunkebao/config/route.php | 1 + ...ConvertedListWithInCompanyV1Controller.php | 92 +++++++++++++++++++ ...PotentialListWithInCompanyV1Controller.php | 8 ++ 3 files changed, 101 insertions(+) create mode 100644 Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php diff --git a/Server/application/cunkebao/config/route.php b/Server/application/cunkebao/config/route.php index 883bd509..4f983ec5 100644 --- a/Server/application/cunkebao/config/route.php +++ b/Server/application/cunkebao/config/route.php @@ -42,6 +42,7 @@ Route::group('v1/', function () { // 流量池相关 Route::group('traffic/pool', function () { Route::get('', 'app\cunkebao\controller\traffic\GetPotentialListWithInCompanyV1Controller@index'); + Route::get('converted', 'app\cunkebao\controller\traffic\GetConvertedListWithInCompanyV1Controller@index'); Route::get('types', 'app\cunkebao\controller\traffic\GetPotentialTypeSectionV1Controller@index'); Route::get('sources', 'app\cunkebao\controller\traffic\GetTrafficSourceSectionV1Controller@index'); Route::get('statistics', 'app\cunkebao\controller\traffic\GetPoolStatisticsV1Controller@index'); diff --git a/Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php b/Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php new file mode 100644 index 00000000..be66704a --- /dev/null +++ b/Server/application/cunkebao/controller/traffic/GetConvertedListWithInCompanyV1Controller.php @@ -0,0 +1,92 @@ +request->param('keyword'))) { + $where[] = ['exp', "w.alias LIKE '%{$keyword}%' OR w.nickname LIKE '%{$keyword}%'"]; + } + + // 来源的筛选 + if ($fromd = $this->request->param('fromd')) { + $where['s.fromd'] = $fromd; + } + + $where['s.companyId'] = $this->getUserInfo('companyId'); + $where['s.status'] = TrafficSourceModel::STATUS_PASSED; + + return array_merge($where, $params); + } + + /** + * 获取流量池列表 + * + * @param array $where + * @return \think\Paginator + */ + protected function getPoolListByCompanyId(array $where): \think\Paginator + { + $query = TrafficSourceModel::alias('s') + ->field( + [ + 'w.id', 'w.nickname', 'w.avatar', 'w.wechatId', + 's.fromd', + 'f.tags', 'f.createTime', TrafficSourceModel::STATUS_PASSED . ' status' + ] + ) + ->join('traffic_pool p', 'p.identifier=s.identifier') + ->join('wechat_account w', 'p.wechatId=w.wechatId') + ->join('wechat_friendship f', 'w.wechatId=f.wechatId and f.deleteTime=0') + ->order('s.id desc'); + + foreach ($where as $key => $value) { + if (is_numeric($key) && is_array($value) && isset($value[0]) && $value[0] === 'exp') { + $query->whereExp('', $value[1]); + continue; + } + + $query->where($key, $value); + } + + return $query->paginate($this->request->param('limit/d', 10), false, ['page' => $this->request->param('page/d', 1)]); + } + + /** + * 获取流量池列表 + * + * @return \think\response\Json + */ + public function index() + { + try { + $result = $this->getPoolListByCompanyId( $this->makeWhere() ); + + return ResponseHelper::success( + [ + 'list' => $result->items(), + 'total' => $result->total(), + ] + ); + } catch (\Exception $e) { + return ResponseHelper::error($e->getMessage(), $e->getCode()); + } + } +} \ No newline at end of file diff --git a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php index 945c75c1..09442050 100644 --- a/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php +++ b/Server/application/cunkebao/controller/traffic/GetPotentialListWithInCompanyV1Controller.php @@ -3,6 +3,7 @@ namespace app\cunkebao\controller\traffic; use app\common\model\TrafficPool as TrafficPoolModel; +use app\common\model\TrafficSource as TrafficSourceModel; use app\common\model\WechatFriendShip as WechatFriendShipModel; use app\cunkebao\controller\BaseController; use library\ResponseHelper; @@ -27,6 +28,8 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController // 状态筛选 if ($status = $this->request->param('status')) { $where['s.status'] = $status; + } else { + $where['s.status'] = array('<>', TrafficSourceModel::STATUS_PASSED); } // 来源的筛选 @@ -63,6 +66,11 @@ class GetPotentialListWithInCompanyV1Controller extends BaseController continue; } + if (is_array($value)) { + $query->where($key, ...$value); + continue; + } + $query->where($key, $value); }