更新: 重构代码并优化财务统计逻辑中的统计功能

This commit is contained in:
mkm 2024-07-09 11:26:11 +08:00
parent 04993bdf33
commit f845ce949e

View File

@ -17,6 +17,7 @@ namespace app\adminapi\logic\cost_project;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\cost_project\CostProject; use app\common\model\cost_project\CostProject;
use app\common\model\dict\DictData;
use app\common\model\financial\FinancialInvoice; use app\common\model\financial\FinancialInvoice;
use app\common\model\financial\FinancialRefund; use app\common\model\financial\FinancialRefund;
use app\common\model\financial\FinancialSettlement; use app\common\model\financial\FinancialSettlement;
@ -44,9 +45,17 @@ class CostProjectStatisticsLogic extends BaseLogic
$where1=[ $where1=[
['review_status','=', 1], ['review_status','=', 1],
['contract_type','=',0], ['contract_type','=',0],
['business_nature','=',4],
['status','=',0] ['status','=',0]
]; ];
$where2=[
['review_status','=', 1],
['status','=',1]
];
$data=DictData::where('type_value','cost_project')->column('value');
if($data){
$where1[]=['business_nature','in',$data];
$where2[]=['business_nature','in',$data];
}
$total_apply_amount = $marketingContract->statistics_count($where1, $time, 'sum', ''); $total_apply_amount = $marketingContract->statistics_count($where1, $time, 'sum', '');
$apply_amount_value = $marketingContract->statistics_count($where1, $time, 'group', 'create_time'); $apply_amount_value = $marketingContract->statistics_count($where1, $time, 'group', 'create_time');
$data[] = [ $data[] = [
@ -77,11 +86,6 @@ class CostProjectStatisticsLogic extends BaseLogic
'type' => 1, 'type' => 1,
]; ];
//签约金额 //签约金额
$where2=[
['review_status','=', 1],
['business_nature','=',4],
['status','=',1]
];
$total_apply_amount = $marketingContract->statistics($where2, $time, 'sum', '', 'signed_amount'); $total_apply_amount = $marketingContract->statistics($where2, $time, 'sum', '', 'signed_amount');
$apply_amount_value = $marketingContract->statistics($where2, $time, 'group', 'create_time', 'signed_amount'); $apply_amount_value = $marketingContract->statistics($where2, $time, 'group', 'create_time', 'signed_amount');
$data[] = [ $data[] = [