78 lines
2.9 KiB
PHP
78 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\logic\marketing;
|
|
|
|
use app\common\logic\BaseLogic;
|
|
use app\common\model\dict\DictData;
|
|
use app\common\model\marketing\MarketingContract;
|
|
use app\common\model\marketing\MarketingCustom;
|
|
|
|
class MarketingStatisticsLogic extends BaseLogic
|
|
{
|
|
|
|
/**
|
|
* 统计
|
|
*/
|
|
public static function marketingStatistics($where, $time)
|
|
{
|
|
$data = [];
|
|
$datearr = explode('-', $time);
|
|
$time = TimeConvert(['start_time' => $datearr[0], 'end_time' => $datearr[1]]);
|
|
$marketingContract=new MarketingContract();
|
|
// //统计主合同
|
|
$total_contract_type_0=$marketingContract->ContractTypeStatistics(['contract_type'=>0],$time,'sum');
|
|
$total_contract_type_0_value=$marketingContract->ContractTypeStatistics(['contract_type'=>0],$time,'group','create_time');
|
|
$data[]=[
|
|
'title' => '主合同',
|
|
'desc' => '',
|
|
'total_money' => $total_contract_type_0,
|
|
'value' => $total_contract_type_0_value['y']??[],
|
|
'type' => 1,
|
|
];
|
|
// //统计框架协议
|
|
$total_contract_type_1=$marketingContract->ContractTypeStatistics(['contract_type'=>1],$time,'sum');
|
|
$total_contract_type_1_value=$marketingContract->ContractTypeStatistics(['contract_type'=>1],$time,'group','create_time');
|
|
$data[]=[
|
|
'title' => '框架协议',
|
|
'desc' => '',
|
|
'total_money' => $total_contract_type_1,
|
|
'value' => $total_contract_type_1_value['y']??[],
|
|
'type' => 1,
|
|
];
|
|
// //统计补充协议
|
|
$total_contract_type_2=$marketingContract->ContractTypeStatistics(['contract_type'=>2],$time,'sum');
|
|
$total_contract_type_2_value=$marketingContract->ContractTypeStatistics(['contract_type'=>2],$time,'group','create_time');
|
|
$data[]=[
|
|
'title' => '补充协议',
|
|
'desc' => '',
|
|
'total_money' => $total_contract_type_2,
|
|
'value' => $total_contract_type_2_value['y']??[],
|
|
'type' => 1,
|
|
];
|
|
//统计客户
|
|
$total_custom=MarketingCustom::count();
|
|
$data[]=[
|
|
'title' => '客户总数',
|
|
'desc' => '',
|
|
'total_money' => $total_custom,
|
|
'value' => [],
|
|
'type' => 1,
|
|
];
|
|
//业务性质
|
|
$business_nature = DictData::where('type_value', 'cost_consultation_business_nature')->column('name', 'value');
|
|
foreach($business_nature as $key=>$value){
|
|
$count=$marketingContract->ContractTypeStatistics(['business_nature'=>$key],$time,'sum');
|
|
$y_value=$marketingContract->ContractTypeStatistics(['business_nature'=>$key],$time,'group','create_time');
|
|
$data[] = [
|
|
'title' => $value,
|
|
'desc' => '',
|
|
'total_money' => $count,
|
|
'value' => $y_value['y']??[],
|
|
'type' => 1,
|
|
];
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|