98 lines
3.6 KiB
PHP
98 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\logic\manage_basic;
|
|
|
|
|
|
|
|
use app\common\logic\BaseLogic;
|
|
use app\common\model\consult_basic\ConsultProject;
|
|
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;
|
|
|
|
/**
|
|
* 项目管理--统计
|
|
* Class ManageStatisticsLogic
|
|
* @package app\adminapi\logic\manage_basic
|
|
*/
|
|
class ManageStatisticsLogic extends BaseLogic
|
|
{
|
|
|
|
public static function ManageStatistics($where, $time)
|
|
{
|
|
$data = [];
|
|
$datearr = explode('-', $time);
|
|
$time = TimeConvert(['start_time' => $datearr[0], 'end_time' => $datearr[1]]);
|
|
$marketingContract = new MarketingContract();
|
|
$consultProject = new ConsultProject();
|
|
|
|
$financialInvoice = new FinancialInvoice();
|
|
$financialRefund = new FinancialRefund();
|
|
$financialSettlement = new FinancialSettlement();
|
|
|
|
$where1=[
|
|
['review_status', '=', 1],
|
|
['contract_type', '=', 0],
|
|
['status', '=', 0]
|
|
];
|
|
$DictData=DictData::where('type_value','management')->column('value');
|
|
if($DictData){
|
|
$where1[]=['business_nature','in',$DictData];
|
|
}
|
|
$total_apply_amount = $marketingContract->statistics_count($where1, $time, 'sum', '');
|
|
$apply_amount_value = $marketingContract->statistics_count($where1, $time, 'group', 'create_time');
|
|
$data[] = [
|
|
'title' => '待立项项目',
|
|
'desc' => '',
|
|
'total_money' => $total_apply_amount,
|
|
'value' => $apply_amount_value['y'] ?? 0,
|
|
'type' => 1,
|
|
];
|
|
$total_apply_amount = $consultProject->statistics_count([], $time, 'sum', '');
|
|
$apply_amount_value = $consultProject->statistics_count([], $time, 'group', 'create_time');
|
|
$data[] = [
|
|
'title' => '已立项项目',
|
|
'desc' => '',
|
|
'total_money' => $total_apply_amount,
|
|
'value' => $apply_amount_value['y'] ?? 0,
|
|
'type' => 1,
|
|
];
|
|
|
|
$contract_ids = $consultProject->whereBetweenTime('create_time', strtotime($time['start_time']), strtotime($time['end_time']))->group('contract')->column('contract');
|
|
//开票金额
|
|
$where[]=['contract_id','in',$contract_ids];
|
|
$total_apply_amount = $financialInvoice->ContractFinancialMoney($where, $time, 'sum', '', 'apply_amount');
|
|
$apply_amount_value = $financialInvoice->ContractFinancialMoney($where, $time, 'group', 'create_time', 'apply_amount');
|
|
$data[] = [
|
|
'title' => '开票金额',
|
|
'desc' => '',
|
|
'total_money' => $total_apply_amount,
|
|
'value' => $apply_amount_value['y'] ?? 0,
|
|
'type' => 1,
|
|
];
|
|
//回款金额
|
|
$total_amount = $financialRefund->statistics($where, $time, 'sum', '', 'amount');
|
|
$amount_value = $financialRefund->statistics($where, $time, 'group', 'create_time', 'amount');
|
|
$data[] = [
|
|
'title' => '回款金额',
|
|
'desc' => '',
|
|
'total_money' => $total_amount,
|
|
'value' => $amount_value['y'] ?? 0,
|
|
'type' => 1,
|
|
];
|
|
//结算金额
|
|
$total_amount = $financialSettlement->statistics($where, $time, 'sum', '', 'amount');
|
|
$amount_value = $financialSettlement->statistics($where, $time, 'group', 'create_time', 'amount');
|
|
$data[] = [
|
|
'title' => '结算金额',
|
|
'desc' => '',
|
|
'total_money' => $total_amount,
|
|
'value' => $amount_value['y'] ?? 0,
|
|
'type' => 1,
|
|
];
|
|
return $data;
|
|
}
|
|
}
|