diff --git a/app/adminapi/controller/supervision_project/SupervisionStatisticsController.php b/app/adminapi/controller/supervision_project/SupervisionStatisticsController.php index 596ccbb2a..a1f4c9f70 100644 --- a/app/adminapi/controller/supervision_project/SupervisionStatisticsController.php +++ b/app/adminapi/controller/supervision_project/SupervisionStatisticsController.php @@ -4,7 +4,11 @@ use app\adminapi\controller\BaseAdminController; use app\common\model\dict\DictData; + 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\supervision_connect\SupervisionProjectMonthlyReport; use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionProblem; @@ -50,4 +54,79 @@ } //项目月报统计 + public function month_report(){ + $year = $this->request->get('year',date('Y')); + //统计总的进度 + $total_schedule = SupervisionProjectMonthlyReport::sum('this_month_progress'); + //统计年度进度 + $year_schedule = SupervisionProjectMonthlyReport::whereYear('date',$year)->sum('this_month_progress'); + //统计总的完成 + $total_complete = SupervisionProjectMonthlyReport::sum('total_amount'); + //统计年度完成 + $year_complete = SupervisionProjectMonthlyReport::whereYear('date',$year)->sum('total_amount'); + //统计总的支付 + $total_payment = SupervisionProjectMonthlyReport::sum('total_pay'); + //统计年度支付 + $year_payment = SupervisionProjectMonthlyReport::whereYear('date',$year)->sum('total_pay'); + $column = ['1','2','3','4','5','6','7','8','9','10','11','12']; + $schedule_series = [ + 'name' => '工程进度', + 'data' => [] + ]; + $complete_series = [ + 'name' => '完成总量', + 'data' => [] + ]; + $payment_series = [ + 'name' => '支付总量', + 'data' => [] + ]; + foreach($column as &$v){ + $schedule_series['data'][] = SupervisionProjectMonthlyReport::whereMonth('date',$year.'-'.$v)->sum('this_month_progress'); + $complete_series['data'][] = SupervisionProjectMonthlyReport::whereMonth('date',$year.'-'.$v)->sum('total_amount'); + $payment_series['data'][] = SupervisionProjectMonthlyReport::whereMonth('date',$year.'-'.$v)->sum('total_pay'); + $v = $v.'月'; + } + $result = compact('total_schedule','year_schedule','total_complete','year_complete','total_payment','year_payment', + 'column','schedule_series','complete_series','payment_series'); + return $this->success('success',$result); + } + + public function invoice(){ + $year = $this->request->get('year',date('Y')); + $contract_ids = SupervisionProject::column('contract'); + //总开票金额 + $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); + } } \ No newline at end of file