92 lines
3.1 KiB
PHP
92 lines
3.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\financial;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\financial\FinancialBudgetDoc;
|
||
use app\common\model\financial\FinancialBudgetDocDetail;
|
||
use app\common\model\marketing\MarketingContract;
|
||
use app\common\model\marketing\MarketingCustom;
|
||
|
||
|
||
/**
|
||
* 财务管理--项目预算书列表
|
||
* Class FinancialBudgetDocLists
|
||
* @package app\adminapi\listsfinancial
|
||
*/
|
||
class FinancialBudgetDocLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/03/26 13:54
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['contract_id'],
|
||
'%like%' => ['code', 'name'],
|
||
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--项目预算书列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/03/26 13:54
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return FinancialBudgetDoc::where($this->searchWhere)
|
||
->field(['id', 'contract_id', 'code', 'name', 'issue_date'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$contract = MarketingContract::field('contract_name,part_a,create_time,signed_amount,contract_type')->where('id', $data['contract_id'])->findOrEmpty();
|
||
$custom = MarketingCustom::field('name')->where('id', 'part_a')->findOrEmpty();
|
||
$data['contract_name'] = $contract['contract_name'];
|
||
$data['part_a'] = $custom['name'];
|
||
$data['create_date'] = $contract['create_time'];
|
||
$data['money'] = $contract['signed_amount'];
|
||
$data['contract_type'] = $contract['contract_type'];
|
||
$data['contract_type_text'] = !$contract->isEmpty() ? $contract->contract_type_text : '';
|
||
$data['total_amount'] = FinancialBudgetDocDetail::where('budget_doc_id', $data['id'])->sum('amount');
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--项目预算书数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/03/26 13:54
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return FinancialBudgetDoc::where($this->searchWhere)->count();
|
||
}
|
||
|
||
} |