engineering/app/adminapi/controller/statistics/StatisticsController.php
2024-01-21 09:43:44 +08:00

54 lines
1.4 KiB
PHP

<?php
namespace app\adminapi\controller\statistics;
use app\adminapi\controller\BaseAdminController;
use app\common\model\custom\Custom;
use app\common\model\project\Project;
use app\common\model\project\ProjectInsuranceManagement;
use think\response\Json;
class StatisticsController extends BaseAdminController
{
//客户统计数据
public function customs(): Json
{
$year = $this->request->get('year');
if(empty($year)){
$year = date('Y');
}
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
$series = [
'name' => '客户数',
'data' => []
];
foreach($column as &$v){
$month = $v;
if($month < 10){
$month = '0'.$month;
}
$series['data'][] = Custom::field('id')->whereMonth('create_time', $year.'-'.$month)->count();
$v = $v.'月';
}
$custom_total = Custom::field('id')->count();
$this_year_add = Custom::field('id')->whereYear('create_time',date('Y'))->count();
$result = [
'column' => $column,
'series' => $series,
'custom_total' => $custom_total,
'this_year_add' => $this_year_add
];
return $this->success('success',$result);
}
//项目立项
public function projectInitiation(){
//立项总数
$project_total = Project::field('id')->where('status',0)->count();
//项目跟进
$project_follow_total = ProjectInsuranceManagement::field('id')->count();
//项目需求
// $project_demand_total =
}
}