私域操盘手 - 动态获取流量来源的selection 选择器列表数据

This commit is contained in:
柳清爽
2025-05-13 15:06:24 +08:00
parent 55ea2bf7e3
commit e359661ac4
4 changed files with 95 additions and 10 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace app\cunkebao\controller\traffic;
use app\common\model\TrafficSource as TrafficSourceModel;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
/**
* 流量池控制器
*/
class GetTrafficSourceSectionV1Controller extends BaseController
{
/**
* 动态获取流量来源的selection 选择器列表数据
*
* @return array
* @throws \Exception
*/
protected function getSourceSectionCols(): array
{
return (array)TrafficSourceModel::where(
[
'companyId' => $this->getUserInfo('companyId')
]
)
->field('fromd name,id')->group('fromd')->select()->toArray();
}
/**
* 获取流量来源筛选列表
*
* @return \think\response\Json
*/
public function index()
{
try {
return ResponseHelper::success(
$this->getSourceSectionCols()
);
} catch (\Exception $e) {
return ResponseHelper::error($e->getMessage(), $e->getCode());
}
}
}