147 lines
5.6 KiB
PHP
147 lines
5.6 KiB
PHP
<?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\lists\contract;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsExcelInterface;
|
||
use app\common\model\contract\SubcontractingContract;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\contract\SubcontractingContractDetail;
|
||
use app\common\model\contract\SubcontractingContractNegotiation;
|
||
use app\common\model\finance\FinancePaymentApply;
|
||
use app\common\model\finance\FinanceReceiptRecord;
|
||
use app\common\model\finance\FinanceRefundRecord;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\supplier\Supplier;
|
||
|
||
|
||
/**
|
||
* SubcontractingContract列表
|
||
* Class SubcontractingContractLists
|
||
* @package app\adminapi\listscontract
|
||
*/
|
||
class SubcontractingContractLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/12/12 17:15
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['supplier_id', 'project_id'],
|
||
'%like%' => ['contract_no']
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @notes 获取列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/12/12 17:15
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return SubcontractingContract::where($this->searchWhere)
|
||
->field('id,project_id,supplier_id,contract_no,contract_name,contract_type,signing_date')
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||
$supplier = Supplier::field('supplier_name,supplier_code')->where('id',$data['supplier_id'])->findOrEmpty();
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['supplier_name'] = $supplier['supplier_name'];
|
||
$data['supplier_code'] = $supplier['supplier_code'];
|
||
$data['contract_type'] = $data->contract_type_text;
|
||
$data['contract_amount'] = SubcontractingContractDetail::where('contract_id',$data['id'])->sum('amount_including_tax');
|
||
//洽商金额
|
||
$data['negotiation_amount'] = SubcontractingContractNegotiation::where('subcontracting_contract_id',$data['id'])->sum('negotiation_amount');
|
||
//实际合同金额
|
||
$data['reality_contract_amount'] = $data['contract_amount'] + $data['negotiation_amount'];
|
||
//不含税金额
|
||
$data['excluding_tax_amount'] = SubcontractingContractDetail::where('contract_id',$data['id'])->sum('amount_excluding_tax');
|
||
//已付款金额
|
||
$data['has_pay_amount'] = FinancePaymentApply::where('contract_id',$data['id'])->where('contract_type',2)->sum('amount');;
|
||
//未付款金额
|
||
$data['not_pay_amount'] = $data['contract_amount'] - $data['has_pay_amount'];
|
||
//已开票金额
|
||
$data['has_invoice_amount'] = FinanceReceiptRecord::where('contract_id',$data['id'])->where('contract_type',2)->sum('invoice_amount');
|
||
//未开票金额
|
||
$data['not_invoice_amount'] = $data['contract_amount'] - $data['has_invoice_amount'];
|
||
//退款金额
|
||
$data['refund_amount'] = FinanceRefundRecord::where('contract_id',$data['id'])->where('contract_type',2)->sum('refund_amount');;
|
||
//结算差异
|
||
$data['settlement_difference'] = 0;
|
||
return $data;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/12/12 17:15
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return SubcontractingContract::where($this->searchWhere)->count();
|
||
}
|
||
|
||
public function setFileName(): string
|
||
{
|
||
return '分包合同列表';
|
||
}
|
||
|
||
/**
|
||
* @notes 导出字段
|
||
* @return string[]
|
||
* @author 段誉
|
||
* @date 2022/11/24 16:17
|
||
*/
|
||
public function setExcelFields(): array
|
||
{
|
||
return [
|
||
"id" => "id",
|
||
"project_name" => "项目名称",
|
||
"contract_no" => "合同编号",
|
||
"contract_name" => "合同名称",
|
||
"supplier_name" => "供应商名称",
|
||
"signing_date" => "签订日期",
|
||
"contract_type" => "合同类型",
|
||
"contract_amount" => "合同金额",
|
||
"negotiation_amount" => "洽商金额",
|
||
"excluding_tax_amount" => "不含税金额",
|
||
"reality_contract_amount" => "实际合同金额",
|
||
"has_pay_amount" => "已付款金额",
|
||
"not_pay_amount" => "未付款金额",
|
||
"invoice_amount" => "已开票金额",
|
||
"not_invoice_amount" => "未开票金额",
|
||
"refund_amount" => "已退款金额",
|
||
"settlement_difference" => "结算差异",
|
||
];
|
||
}
|
||
|
||
} |