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(): Json { //立项总数 $project_total = Project::field('id')->count(); //项目跟进 $follow_total = ProjectFollowUp::field('id')->count(); //项目需求 $demand_total = CustomerDemand::field('id')->count(); //项目方案 $solution_total = CustomerDemandSolution::field('id')->count(); //项目概算 $estimate_total = ProjectEstimate::field('id')->count(); //竞争对手 $competitor_total = Competitor::field('id')->count(); //获取项目类型 $project_type = ProjectTypeSet::field('id,name')->select()->toArray(); $data = []; foreach($project_type as $v){ $count = Project::field('id')->where('project_type',$v['id'])->count(); $data[] = [ 'name' => $v['name'], 'value' => $count ]; } $result = compact('project_total','follow_total','demand_total','solution_total','estimate_total','competitor_total'); $result['data'] = $data; return $this->success('success',$result); } //投标统计 public function bidding() { } }