103 lines
3.9 KiB
PHP
103 lines
3.9 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\FinancialExpenseReimbursement;
|
||
use app\common\model\financial\FinancialExpenseReimbursementDetail;
|
||
use app\common\model\financial\FinancialFeeApplication;
|
||
use app\common\model\marketing\MarketingContract;
|
||
|
||
|
||
/**
|
||
* 财务管理--费用报销单列表
|
||
* Class FinancialExpenseReimbursementLists
|
||
* @package app\adminapi\listsfinancial
|
||
*/
|
||
class FinancialExpenseReimbursementLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/03/28 09:26
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['contract_id', 'fee_application_id', 'pay_type'],
|
||
'%like%' => ['theme', 'code', 'create_user'],
|
||
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--费用报销单列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/03/28 09:26
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
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 FinancialExpenseReimbursement::withoutField('update_time,delete_time')->where($this->searchWhere)->where($where)
|
||
->field(['id', 'contract_id', 'fee_application_id', 'theme', 'code', 'bill_num', 'pay_type', 'content', 'create_user', 'create_time'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$contract = MarketingContract::field('contract_name,contract_type')->where('id', $data['contract_id'])->findOrEmpty();
|
||
$fee_application = FinancialFeeApplication::field('theme')->where('id', $data['fee_application_id'])->findOrEmpty();
|
||
$data['contract_name'] = !$contract->isEmpty() ? $contract['contract_name'] : '';
|
||
$data['contract_type'] = !$contract->isEmpty() ? $contract['contract_type'] : 0;
|
||
$data['contract_type_text'] = !$contract->isEmpty() ? $contract->contract_type_text : '';
|
||
$data['fee_application_theme'] = !$fee_application->isEmpty() ? $fee_application['theme'] : '';
|
||
$data['pay_type_text'] = $data->pay_type_text;
|
||
$data['total_amount'] = FinancialExpenseReimbursementDetail::where('expense_reimbursement_id', $data['id'])->sum('amount');
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--费用报销单数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/03/28 09:26
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
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 FinancialExpenseReimbursement::where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
} |