This commit is contained in:
weiz 2024-01-22 11:21:52 +08:00
parent 9ffb41b376
commit ab2c41fa76
2 changed files with 47 additions and 4 deletions

View File

@ -10,6 +10,8 @@
use app\common\model\bid\BidSecurityRefund;
use app\common\model\contract\Contract;
use app\common\model\contract\ContractNegotiation;
use app\common\model\contract\ProcurementContract;
use app\common\model\contract\ProcurementContractDetail;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomerDemand;
use app\common\model\custom\CustomerDemandSolution;
@ -207,7 +209,48 @@
}
//采购合同
public function procurementContract(){
public function procurementContract(): Json
{
$year = $this->request->get('year');
if(empty($year)){
$year = date('Y');
}
$column = ['1','2','3','4','5','6','7','8','9','10','11','12'];
//总合同数
$total_num = ProcurementContract::field('id')->count();
//总合同金额
$total_amount = ProcurementContractDetail::sum('amount_including_tax');
//年度合同数
$year_total_num = ProcurementContract::field('id')->whereYear('signing_date',$year)->count();
//年度合同金额
$year_procurement_contract_ids = ProcurementContract::whereYear('signing_date',$year)->column('id');
$year_total_amount = ProcurementContractDetail::field('id')->where('contract_id','in',$year_procurement_contract_ids)->sum('amount_including_tax');
$series = [
'name' => '合同金额',
'data' => []
];
foreach($column as &$v){
$month = $v;
if($month < 10){
$month = '0'.$month;
}
$month_procurement_contract_ids = ProcurementContract::whereMonth('signing_date',$year.'-'.$month)->column('id');
$series['data'][] = ProcurementContractDetail::field('id')->where('contract_id','in',$month_procurement_contract_ids)->sum('amount_including_tax');
$v = $v.'月';
}
$result = [
'total_num' => $total_num,
'total_amount' => $total_amount,
'year_total_num' => $year_total_num,
'year_total_amount' => $year_total_amount,
'column' => $column,
'series' => $series,
];
return $this->success('success',$result);
}
//分包合同
public function subcontractingContract() {
$year = $this->request->get('year');
if(empty($year)){
$year = date('Y');

View File

@ -42,17 +42,17 @@ class SubcontractingContract extends BaseModel
public function getContractTypeTextAttr($value,$data){
$dict = DictData::where('type_value','divide_contract_type')->column('name','value');
return $dict[$data['contract_type']];
return !empty($data['contract_type']) ? $dict[$data['contract_type']] : '';
}
public function getPayTypeTextAttr($value,$data){
$dict = DictData::where('type_value','pay_type')->column('name','value');
return $dict[$data['pay_type']];
return !empty($data['pay_type']) ? $dict[$data['pay_type']] : '';
}
public function getAccountPeriodTextAttr($value,$data){
$dict = DictData::where('type_value','account_period')->column('name','value');
return $dict[$data['account_period']];
return !empty($data['account_period']) ? $dict[$data['account_period']] : '';
}
}