This commit is contained in:
weiz 2024-01-21 17:58:46 +08:00
parent 8953757e41
commit e7713e7194

View File

@ -7,9 +7,15 @@
use app\common\model\bid\BidBuyBiddingDocument;
use app\common\model\bid\BidDocumentExamination;
use app\common\model\bid\BidResult;
use app\common\model\bid\BidSecurityRefund;
use app\common\model\contract\Contract;
use app\common\model\contract\ContractNegotiation;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomerDemand;
use app\common\model\custom\CustomerDemandSolution;
use app\common\model\finance\FinanceInvoiceApply;
use app\common\model\finance\FinanceReturnedMoney;
use app\common\model\finance\FinanceReturnedRecord;
use app\common\model\project\Competitor;
use app\common\model\project\Project;
use app\common\model\project\ProjectEstimate;
@ -94,6 +100,107 @@
$bidding_rate = number_format($successful / $decision,2);
//总的投标保证金金额
$total_margin_amount = BidBiddingDecision::where('is_margin',1)->sum('margin_amount');
halt($bidding_rate,$total_margin_amount);
//已退保证金金额
$return_margin_amount = BidSecurityRefund::sum('refund_amount');
//未退保证金金额
$not_return_margin_amount = ($total_margin_amount - $return_margin_amount) > 0 ? $total_margin_amount - $return_margin_amount : 0;
//返回
return $this->success('success',compact('decision','document','examination','successful','bidding_rate','not_return_margin_amount'));
}
//项目合同
public function contracts(): Json
{
$year = $this->request->get('year');
if(empty($year)){
$year = date('Y');
}
//合同总数
$total_num = Contract::field('id')->count();
//签约总金额
$sign_total_amount = Contract::sum('amount');
//洽商金额
$total_negotiate_amount = ContractNegotiation::sum('negotiation_amount');
//年度合同总数
$year_total_num = Contract::field('id')->whereYear('contract_date',$year)->count();
//年度签约合同总金额
$year_total_sign_amount = Contract::whereYear('contract_date',$year)->sum('amount');
//年度签约合同id
$year_sign_contract_ids = Contract::field('id')->whereYear('contract_date',$year)->column('id');
//年度洽商金额
$year_total_negotiate_amount = ContractNegotiation::where('contract_id','in',$year_sign_contract_ids)->sum('negotiation_amount');
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
$series = [
'name' => '合同金额',
'data' => []
];
foreach($column as &$v){
$month = $v;
if($month < 10){
$month = '0'.$month;
}
$sign_amount = Contract::whereMonth('contract_date', $year.'-'.$month)->sum('amount');
$contract_ids = Contract::whereMonth('contract_date', $year.'-'.$month)->column('id');
$negotiate_amount = ContractNegotiation::where('contract_id','in',$contract_ids)->sum('negotiation_amount');
$series['data'][] = $sign_amount + $negotiate_amount;
$v = $v.'月';
}
$result = [
'total_num' => $total_num,
'total_amount' => $sign_total_amount + $total_negotiate_amount,
'total_negotiate_amount' => $total_negotiate_amount,
'year_total_num' => $year_total_num,
'year_total_amount' => $year_total_sign_amount + $year_total_negotiate_amount,
'column' => $column,
'series' => $series
];
return $this->success('success',$result);
}
//项目回款
public function projectRefund(){
$year = $this->request->get('year');
if(empty($year)){
$year = date('Y');
}
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
//年度开票金额
$year_invoicing_amount = FinanceInvoiceApply::whereYear('invoicing_date',$year)->sum('invoicing_amount');
//年度回款计划金额
$year_refund_plan_amount = FinanceReturnedMoney::whereYear('return_date',$year)->sum('amount');
//年度回款金额
$year_refund_amount = FinanceReturnedRecord::whereYear('return_date',$year)->sum('amount');
$invoice_series = [
'name' => '开票金额',
'data' => []
];
$refund_plan_series = [
'name' => '回款计划金额',
'data' => []
];
$refund_series = [
'name' => '回款金额',
'data' => []
];
foreach($column as &$v){
$month = $v;
if($month < 10){
$month = '0'.$month;
}
$invoice_series['data'][] = FinanceInvoiceApply::whereMonth('invoicing_date',$year.'-'.$month)->sum('invoicing_amount');
$refund_plan_series['data'][] = FinanceReturnedMoney::whereMonth('return_date',$year.'-'.$month)->sum('amount');
$refund_series['data'][] = FinanceReturnedRecord::whereMonth('return_date',$year.'-'.$month)->sum('amount');
$v = $v.'月';
}
$result = [
'year_invoicing_amount' => $year_invoicing_amount,
'year_refund_plan_amount' => $year_refund_plan_amount,
'year_refund_amount' => $year_refund_amount,
'invoice_series' => $invoice_series,
'refund_plan_series' => $refund_plan_series,
'refund_series' => $refund_series,
'column' => $column,
];
return $this->success('success',$result);
}
}