update
This commit is contained in:
parent
4686688753
commit
92ce89e2f9
@ -4,11 +4,14 @@
|
|||||||
|
|
||||||
use app\adminapi\controller\BaseAdminController;
|
use app\adminapi\controller\BaseAdminController;
|
||||||
use app\common\model\cost_project\CostProject;
|
use app\common\model\cost_project\CostProject;
|
||||||
|
use app\common\model\financial\FinancialInvoice;
|
||||||
|
use app\common\model\financial\FinancialRefund;
|
||||||
|
use app\common\model\financial\FinancialSettlement;
|
||||||
use app\common\model\marketing\MarketingContract;
|
use app\common\model\marketing\MarketingContract;
|
||||||
|
|
||||||
class CostStatisticsController extends BaseAdminController
|
class CostStatisticsController extends BaseAdminController
|
||||||
{
|
{
|
||||||
//项目统计
|
//项目立项统计
|
||||||
public function project(){
|
public function project(){
|
||||||
//待立项项目
|
//待立项项目
|
||||||
$pending_project_num = MarketingContract::field('id')->where([
|
$pending_project_num = MarketingContract::field('id')->where([
|
||||||
@ -30,4 +33,73 @@
|
|||||||
];
|
];
|
||||||
return $this->success('success',$result);
|
return $this->success('success',$result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//项目金额统计
|
||||||
|
public function amount(){
|
||||||
|
$year = $this->request->get('year',date('Y'));
|
||||||
|
//统计总签约金额
|
||||||
|
$contract_ids = CostProject::column('contract_id');
|
||||||
|
$total_signed_amount = MarketingContract::where('id','in',$contract_ids)->sum('signed_amount');
|
||||||
|
//统计总投资金额
|
||||||
|
$total_invest_amount = CostProject::sum('invest');
|
||||||
|
//统计年度签约金额
|
||||||
|
$year_signed_amount = MarketingContract::where('id','in',$contract_ids)->whereYear('create_time',$year)->sum('signed_amount');
|
||||||
|
//统计年度投资金额
|
||||||
|
$year_invest_amount = CostProject::whereYear('create_time',$year)->sum('invest');
|
||||||
|
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
|
||||||
|
$signed_series = [
|
||||||
|
'name' => '签约金额',
|
||||||
|
'data' => []
|
||||||
|
];
|
||||||
|
$invest_series = [
|
||||||
|
'name' => '投资金额',
|
||||||
|
'data' => []
|
||||||
|
];
|
||||||
|
foreach($column as &$v){
|
||||||
|
$signed_series['data'][] = MarketingContract::where('id','in',$contract_ids)->whereMonth('create_time',$year.'-'.$v)->sum('signed_amount');
|
||||||
|
$invest_series['data'][] = CostProject::whereMonth('create_time',$year.'-'.$v)->sum('invest');
|
||||||
|
$v = $v.'月';
|
||||||
|
}
|
||||||
|
$result = compact('total_signed_amount','total_invest_amount','year_signed_amount','year_invest_amount','column','signed_series','invest_series');
|
||||||
|
return $this->success('success',$result);
|
||||||
|
}
|
||||||
|
|
||||||
|
//项目开票回款统计
|
||||||
|
public function invoice(){
|
||||||
|
$year = $this->request->get('year',date('Y'));
|
||||||
|
$contract_ids = CostProject::column('contract_id');
|
||||||
|
//总开票金额
|
||||||
|
$total_invoice_amount = FinancialInvoice::where('contract_id','in',$contract_ids)->sum('apply_amount');
|
||||||
|
//年度开票金额
|
||||||
|
$year_invoice_amount = FinancialInvoice::where('contract_id','in',$contract_ids)->whereYear('create_time',$year)->sum('apply_amount');
|
||||||
|
//总到账金额
|
||||||
|
$total_refund_amount = FinancialRefund::where('contract_id','in',$contract_ids)->sum('amount');
|
||||||
|
$year_refund_amount = FinancialRefund::where('contract_id','in',$contract_ids)->whereYear('date',$year)->sum('amount');
|
||||||
|
//总结算金额
|
||||||
|
$total_settlement_amount = FinancialSettlement::where('contract_id','in',$contract_ids)->sum('amount');
|
||||||
|
//年度结算金额
|
||||||
|
$year_settlement_amount = FinancialSettlement::where('contract_id','in',$contract_ids)->whereYear('date',$year)->sum('amount');
|
||||||
|
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
|
||||||
|
$invoice_series = [
|
||||||
|
'name' => '开票金额',
|
||||||
|
'data' => []
|
||||||
|
];
|
||||||
|
$refund_series = [
|
||||||
|
'name' => '到账金额',
|
||||||
|
'data' => []
|
||||||
|
];
|
||||||
|
$settlement_series = [
|
||||||
|
'name' => '结算金额',
|
||||||
|
'data' => []
|
||||||
|
];
|
||||||
|
foreach($column as &$v){
|
||||||
|
$invoice_series['data'][] = FinancialInvoice::where('contract_id','in',$contract_ids)->whereMonth('create_time',$year.'-'.$v)->sum('apply_amount');
|
||||||
|
$refund_series['data'][] = FinancialRefund::where('contract_id','in',$contract_ids)->whereMonth('date',$year.'-'.$v)->sum('amount');
|
||||||
|
$settlement_series['data'][] = FinancialSettlement::where('contract_id','in',$contract_ids)->whereMonth('date',$year.'-'.$v)->sum('amount');
|
||||||
|
$v = $v.'月';
|
||||||
|
}
|
||||||
|
$result = compact('total_invoice_amount','year_invoice_amount','total_refund_amount','year_refund_amount','total_settlement_amount','year_settlement_amount',
|
||||||
|
'column','invoice_series','refund_series','settlement_series');
|
||||||
|
return $this->success('success',$result);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user