82 lines
3.0 KiB
PHP
82 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\controller\marketing;
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
use app\common\model\dict\DictData;
|
|
use app\common\model\marketing\MarketingContract;
|
|
use app\common\model\marketing\MarketingCustom;
|
|
|
|
class MarketingStatisticsController extends BaseAdminController
|
|
{
|
|
public function custom(){
|
|
$year = $this->request->get('year',date('Y'));
|
|
//总客户数
|
|
$total_num = MarketingCustom::count();
|
|
//年度客户数
|
|
$year_num = MarketingCustom::whereYear('create_time',$year)->count();
|
|
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
|
|
$custom_series = [
|
|
'name' => '客户数',
|
|
'data' => []
|
|
];
|
|
foreach($column as &$v){
|
|
$custom_series['data'][] = MarketingCustom::whereMonth('create_time',$year.'-'.$v)->count();
|
|
$v = $v.'月';
|
|
}
|
|
$result = compact('total_num','year_num','column','custom_series');
|
|
return $this->success('success',$result);
|
|
}
|
|
|
|
public function contract(){
|
|
$year = $this->request->get('year',date('Y'));
|
|
//总主合同数
|
|
$total_zht = MarketingContract::where('contract_type',0)->count();
|
|
//年度主合同数
|
|
$year_zht = MarketingContract::where('contract_type',0)->whereYear('create_time',$year)->count();
|
|
//总框架协议数
|
|
$total_kjxy = MarketingContract::where('contract_type',1)->count();
|
|
//年度框架协议数
|
|
$year_kjxy = MarketingContract::where('contract_type',1)->whereYear('create_time',$year)->count();
|
|
//总补充协议数
|
|
$total_bcxy = MarketingContract::where('contract_type',2)->count();
|
|
//年度补充协议数
|
|
$year_bcxy = MarketingContract::where('contract_type',2)->whereYear('create_time',$year)->count();
|
|
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
|
|
$zht_series = [
|
|
'name' => '主合同',
|
|
'data' => []
|
|
];
|
|
$kjxy_series = [
|
|
'name' => '框架协议',
|
|
'data' => []
|
|
];
|
|
$bcxy_series = [
|
|
'name' => '补充协议',
|
|
'data' => []
|
|
];
|
|
foreach($column as &$v){
|
|
$zht_series['data'][] = MarketingContract::where('contract_type',0)->whereMonth('create_time',$year.'-'.$v)->count();
|
|
$kjxy_series['data'][] = MarketingContract::where('contract_type',1)->whereMonth('create_time',$year.'-'.$v)->count();
|
|
$bcxy_series['data'][] = MarketingContract::where('contract_type',2)->whereMonth('create_time',$year.'-'.$v)->count();
|
|
$v = $v.'月';
|
|
}
|
|
$result = compact('total_zht','year_zht','total_kjxy','year_kjxy','total_bcxy','year_bcxy',
|
|
'column','zht_series','kjxy_series','bcxy_series');
|
|
return $this->success('success',$result);
|
|
}
|
|
|
|
public function business(){
|
|
$business_nature = DictData::where('type_value','cost_consultation_business_nature')->column('name','value');
|
|
$data = [];
|
|
foreach($business_nature as $k=>$v){
|
|
$count = MarketingContract::where('business_nature',$k)->count();
|
|
$data[] = [
|
|
'name' => $v,
|
|
'value' => $count
|
|
];
|
|
}
|
|
$result['data'] = $data;
|
|
return $this->success('success',$result);
|
|
}
|
|
} |