私域操盘手 - 流量池列表已转化的列表数据
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 流量池控制器
|
||||
*/
|
||||
class GetConvertedListWithInCompanyV1Controller extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构建查询条件
|
||||
*
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
protected function makeWhere(array $params = []): array
|
||||
{
|
||||
if (!empty($keyword = $this->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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user