私域操盘手 - 流量池数据统计

This commit is contained in:
柳清爽
2025-05-13 16:11:58 +08:00
parent fa9e5c4897
commit e9f33309a0
5 changed files with 124 additions and 19 deletions

View File

@@ -44,6 +44,7 @@ Route::group('v1/', function () {
Route::get('', 'app\cunkebao\controller\traffic\GetPotentialListWithInCompanyV1Controller@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');
});
// 工作台相关

View File

@@ -0,0 +1,70 @@
<?php
namespace app\cunkebao\controller\traffic;
use app\common\model\TrafficSource as TrafficSourceModel;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
/**
* 流量池控制器
*/
class GetPoolStatisticsV1Controller extends BaseController
{
/**
* 获取今日转化数量
*
* @return int
*/
protected function getTodayAddedCount(): int
{
return TrafficSourceModel::where(
[
'companyId' => $this->getUserInfo('companyId'),
'status' => TrafficSourceModel::STATUS_PASSED,
]
)
->whereBetween('updateTime',
[
strtotime(date('Y-m-d 00:00:00')),
strtotime(date('Y-m-d 23:59:59'))
]
)
->count('*');
}
/**
* 获取流量池总数
*
* @return int
* @throws \Exception
*/
protected function getTotalCount(): int
{
return TrafficSourceModel::where(
[
'companyId' => $this->getUserInfo('companyId')
]
)
->count('*');
}
/**
* 获取流量池数据统计
*
* @return \think\response\Json
*/
public function index()
{
try {
return ResponseHelper::success(
[
'totalCount' => $this->getTotalCount(),
'todayAddCount' => $this->getTodayAddedCount(),
]
);
} catch (\Exception $e) {
return ResponseHelper::error($e->getMessage(), $e->getCode());
}
}
}

View File

@@ -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;
@@ -21,23 +22,23 @@ class GetPotentialTypeSectionV1Controller extends BaseController
{
return [
[
'id' => 1,
'id' => TrafficSourceModel::STATUS_PENDING,
'name' => '待处理'
],
[
'id' => 2,
'id' => TrafficSourceModel::STATUS_WORKING,
'name' => '处理中'
],
[
'id' => 4,
'id' => TrafficSourceModel::STATUS_REFUSED,
'name' => '已拒绝'
],
[
'id' => 5,
'id' => TrafficSourceModel::STATUS_EXPIRED,
'name' => '已过期'
],
[
'id' => 6,
'id' => TrafficSourceModel::STATUS_CANCELED,
'name' => '已取消'
]
];