199 lines
8.1 KiB
PHP
199 lines
8.1 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\cost_project;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsExcelInterface;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\cost_project\CostProject;
|
||
use app\common\model\dept\Dept;
|
||
use app\common\model\GeoCity;
|
||
use app\common\model\GeoProvince;
|
||
use app\common\model\marketing\MarketingContract;
|
||
use app\common\model\marketing\MarketingCustom;
|
||
use app\common\model\ProjectCommission;
|
||
use app\common\model\zjzx_finance\ZjzxInvoice;
|
||
use app\common\model\zjzx_finance\ZjzxRefund;
|
||
|
||
/**
|
||
* 造价项目台账列表
|
||
* Class CostProjectLists
|
||
* @package app\adminapi\listscost_project
|
||
*/
|
||
class CostProjectLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/02/21 09:23
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['cost_project_id', 'types', 'industry'],
|
||
'%like%' => ['project_num', 'project_name'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取造价项目台账列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/02/21 09:23
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$task_allocation = $this->request->param('task_allocation', 0);
|
||
// 筛选出关联了任务类别的项目
|
||
if ($task_allocation == 1) {
|
||
return CostProject::alias('p')
|
||
->join('task_type t', 'p.id=t.cost_project_id')
|
||
->where($this->searchWhere)
|
||
->field('p.*')
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()
|
||
->each(function ($res) {
|
||
$contract = MarketingContract::field('contract_name,contract_type,part_a,part_b,signed_amount,create_time')->where('id', $res['contract_id'])->findOrEmpty();
|
||
$province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty();
|
||
$city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty();
|
||
$dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id', $res['principal'])->findOrEmpty();
|
||
$custom = MarketingCustom::field('name')->where('id', $res['aunit'])->findOrEmpty();
|
||
$part_a = MarketingCustom::field('name')->where('id', $contract['part_a'])->findOrEmpty();
|
||
$res['contract_name'] = $contract?->contract_name;
|
||
$res['contract_type_text'] = $contract?->contract_type_text;
|
||
$res['part_a_name'] = $part_a?->name;
|
||
$res['part_b'] = $contract?->part_b;
|
||
$res['signed_amount'] = $contract?->signed_amount;
|
||
$res['signed_date'] = $contract?->create_time;
|
||
$res['types_text'] = $res->types_text;
|
||
$res['industry_text'] = $res->industry_text;
|
||
$res['province_name'] = $province?->province_name;
|
||
$res['city_name'] = $city?->city_name;
|
||
$res['dept_name'] = $dept?->name;
|
||
$res['principal_name'] = $admin?->name;
|
||
$res['person_text'] = $res->person_text;
|
||
$res['aunit_name'] = $custom?->name;
|
||
$res['total_invoice_amount'] = ZjzxInvoice::where('project_id', $res['id'])->sum('apply_amount');
|
||
$res['total_refund_amount'] = ZjzxRefund::where('project_id', $res['id'])->sum('amount');
|
||
$res['total_pay_amount'] = ProjectCommission::where('project_id', $res['id'])->sum('bczfze');
|
||
})
|
||
->toArray();
|
||
}
|
||
return CostProject::where($this->searchWhere)
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()
|
||
->each(function ($res) {
|
||
$contract = MarketingContract::field('contract_name,contract_type,part_a,part_b,signed_amount,create_time')->where('id', $res['contract_id'])->findOrEmpty();
|
||
$province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty();
|
||
$city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty();
|
||
$dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id', $res['principal'])->findOrEmpty();
|
||
$custom = MarketingCustom::field('name')->where('id', $res['aunit'])->findOrEmpty();
|
||
$part_a = MarketingCustom::field('name')->where('id', $contract['part_a'])->findOrEmpty();
|
||
$res['contract_name'] = !$contract->isEmpty() ? $contract['contract_name'] : '';
|
||
$res['contract_type_text'] = !$contract->isEmpty() ? $contract->contract_type_text : '';
|
||
$res['part_a_name'] = !$part_a->isEmpty() ? $part_a['name'] : '';
|
||
$res['part_b'] = !$contract->isEmpty() ? $contract['part_b'] : '';
|
||
$res['signed_amount'] = !$contract->isEmpty() ? $contract['signed_amount'] : '';
|
||
$res['signed_date'] = !$contract->isEmpty() ? $contract['create_time'] : '';
|
||
$res['types_text'] = $res->types_text;
|
||
$res['industry_text'] = $res->industry_text;
|
||
$res['province_name'] = !$province->isEmpty() ? $province['province_name'] : '';
|
||
$res['city_name'] = !$city->isEmpty() ? $city['city_name'] : '';
|
||
$res['dept_name'] = !$dept->isEmpty() ? $dept['name'] : '';
|
||
$res['principal_name'] = !$admin->isEmpty() ? $admin['name'] : '';
|
||
$res['person_text'] = $res->person_text;
|
||
$res['aunit_name'] = !$custom->isEmpty() ? $custom['name'] : '';
|
||
$res['total_invoice_amount'] = ZjzxInvoice::where('project_id', $res['id'])->sum('apply_amount');
|
||
$res['total_refund_amount'] = ZjzxRefund::where('project_id', $res['id'])->sum('amount');
|
||
$res['total_pay_amount'] = ProjectCommission::where('project_id', $res['id'])->sum('bczfze');
|
||
})
|
||
->toArray();
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取造价项目台账数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/02/21 09:23
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$task_allocation = $this->request->param('task_allocation', 0);
|
||
// 筛选出关联了任务类别的项目
|
||
if ($task_allocation == 1) {
|
||
return CostProject::alias('p')->join('task_type t', 'p.id=t.cost_project_id')->where($this->searchWhere)->count();
|
||
}
|
||
return CostProject::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_num' => '项目编号',
|
||
'project_name' => '项目名称',
|
||
'contract_id' => '关联合同',
|
||
'types' => '咨询类型',
|
||
'industry' => '行业',
|
||
'province' => '所在省份',
|
||
'city' => '所在市区',
|
||
'address' => '具体地址',
|
||
'starting' => '计划开始日期',
|
||
'endtime' => '计划结束日期',
|
||
'jhgq' => '计划工期(天)',
|
||
'org_id' => '组织id',
|
||
'depar' => '项目所属部门',
|
||
'principal' => '项目负责人',
|
||
'person' => '项目相关人员',
|
||
'invest' => '项目总投资(万元)',
|
||
'budget' => '预算造价(万元)',
|
||
'cost' => '送审造价(万元)',
|
||
'approval' => '审定造价(万元)',
|
||
'aunit' => '委托单位',
|
||
'Acontact' => '委托方联系人',
|
||
'acontactnum' => '联系电话',
|
||
'generalize' => '登记日期',
|
||
'note' => '项目规模及概括',
|
||
'remark' => '注意事项'
|
||
];
|
||
}
|
||
|
||
} |