111 lines
4.2 KiB
PHP
111 lines
4.2 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\FinancialDepartmentIncomeSettlement;
|
||
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
||
use app\common\model\marketing\MarketingContract;
|
||
|
||
|
||
/**
|
||
* 财务管理--部门收入结算列表
|
||
* Class FinancialDepartmentIncomeSettlementLists
|
||
* @package app\adminapi\listsfinancial
|
||
*/
|
||
class FinancialDepartmentIncomeSettlementLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/03/27 09:46
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['budget_doc_id'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--部门收入结算列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/03/27 09:46
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
if (!empty($params['contract_id'])) {
|
||
$budget_doc_ids = FinancialBudgetDoc::where('contract_id', $params['contract_id'])->column('id');
|
||
$where[] = ['budget_doc_id', 'in', $budget_doc_ids];
|
||
}
|
||
if (!empty($params['create_time'])) {
|
||
$date = explode(',', $params['create_time']);
|
||
$where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||
}
|
||
return FinancialDepartmentIncomeSettlement::where($this->searchWhere)->where($where)
|
||
->field(['id', 'budget_doc_id', 'create_time'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$budget_doc = FinancialBudgetDoc::field('contract_id,code,name,issue_date')->where('id', $data['budget_doc_id'])->findOrEmpty();
|
||
$contract = MarketingContract::field('contract_name,signed_amount')->where('id', $budget_doc['contract_id'])->findOrEmpty();
|
||
$data['budget_doc_code'] = $budget_doc['code'];
|
||
$data['budget_doc_name'] = $budget_doc['name'];
|
||
$data['contract_name'] = $contract['contract_name'];
|
||
$data['contract_money'] = $contract['signed_amount'];
|
||
$data['issue_date'] = $budget_doc['issue_date'];
|
||
$data['amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', $data['id'])->sum('amount');
|
||
$data['settlement_amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', $data['id'])->sum('settlement_amount');
|
||
unset($data['budget_doc_id']);
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--部门收入结算数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/03/27 09:46
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
if (!empty($params['contract_id'])) {
|
||
$budget_doc_ids = FinancialBudgetDoc::where('contract_id', $params['contract_id'])->column('id');
|
||
$where[] = ['budget_doc_id', 'in', $budget_doc_ids];
|
||
}
|
||
if (!empty($params['create_time'])) {
|
||
$date = explode(',', $params['create_time']);
|
||
$where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||
}
|
||
return FinancialDepartmentIncomeSettlement::where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
} |