engineering/app/adminapi/logic/cost_project/CostProjectStatisticsLogic.php

133 lines
5.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\cost_project;
use app\common\logic\BaseLogic;
use app\common\model\cost_project\CostProject;
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 CostProjectStatisticsLogic
* @package app\adminapi\logic\cost_project
*/
class CostProjectStatisticsLogic extends BaseLogic
{
public static function CostProjecStatistics($where, $time)
{
$data = [];
$datearr = explode('-', $time);
$time = TimeConvert(['start_time' => $datearr[0], 'end_time' => $datearr[1]]);
$marketingContract = new MarketingContract();
$CostProject = new CostProject();
$financialInvoice = new FinancialInvoice();
$financialRefund = new FinancialRefund();
$financialSettlement = new FinancialSettlement();
$where1=[
['review_status','=', 1],
['contract_type','=',0],
['status','=',0]
];
$where2=[
['review_status','=', 1],
['status','=',1]
];
$DictData=DictData::where('type_value','cost_project')->column('value');
if($DictData){
$where1[]=['business_nature','in',$DictData];
$where2[]=['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 = $CostProject->statistics_count([], $time, 'sum', '');
$apply_amount_value = $CostProject->statistics_count([], $time, 'group', 'create_time');
$data[] = [
'title' => '已立项项目',
'desc' => '',
'total_money' => $total_apply_amount,
'value' => $apply_amount_value['y'] ?? 0,
'type' => 1,
];
//投资金额
$total_apply_amount = $CostProject->statistics([], $time, 'sum', '', 'invest');
$apply_amount_value = $CostProject->statistics([], $time, 'group', 'create_time', 'invest');
$data[] = [
'title' => '投资金额',
'desc' => '',
'total_money' => $total_apply_amount,
'value' => $apply_amount_value['y'] ?? 0,
'type' => 1,
];
//签约金额
$total_apply_amount = $marketingContract->statistics($where2, $time, 'sum', '', 'signed_amount');
$apply_amount_value = $marketingContract->statistics($where2, $time, 'group', 'create_time', 'signed_amount');
$data[] = [
'title' => '签约金额',
'desc' => '',
'total_money' => $total_apply_amount,
'value' => $apply_amount_value['y'] ?? 0,
'type' => 1,
];
$contract_ids = $CostProject->whereBetweenTime('create_time', strtotime($time['start_time']), strtotime($time['end_time']))->group('contract_id')->column('contract_id');
$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;
}
}