157 lines
7.0 KiB
PHP
157 lines
7.0 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\project;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsExcelInterface;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectTravelReimbursement;
|
||
use app\common\model\project\ProjectTravelReimbursementInvoiceDetail;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\project\ProjectTripApply;
|
||
|
||
|
||
/**
|
||
* 发票明细列表
|
||
* Class ProjectTravelReimbursementInvoiceDetailLists
|
||
* @package app\adminapi\listsproject
|
||
*/
|
||
class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/01/18 13:57
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['travel_reimbursement_id', 'invoice_type', 'invoice_form'],
|
||
'%like%' => ['invoice_sn']
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取发票明细列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/01/18 13:57
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
|
||
$where = [];
|
||
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
|
||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
|
||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||
}
|
||
if(isset($params['project_code']) && $params['project_code']){
|
||
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
|
||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
|
||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||
}
|
||
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
|
||
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
|
||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
|
||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||
}
|
||
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->where($where)
|
||
->field(['id', 'travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'tax_rate', 'invoice_form', 'invoice_amount', 'tax_amount', 'remark'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code,trip_apply_id,project_id,apply_user,apply_date')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
|
||
$trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$travel_reimbursement['trip_apply_id'])->findOrEmpty();
|
||
$project = Project::field('name,project_code')->where('id',$travel_reimbursement['project_id'])->findOrEmpty();
|
||
$data['trip_apply_code'] = $trip_apply['trip_apply_code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
|
||
$data['apply_user'] = $travel_reimbursement['apply_user'];
|
||
$data['apply_date'] = $travel_reimbursement['apply_date'];
|
||
$data['invoice_type_text'] = $data->invoice_type_text;
|
||
$data['tax_rate_text'] = $data->tax_rate_text;
|
||
$data['invoice_form_text'] = $data->invoice_form_text;
|
||
$data['invoice_type'] = (string)$data['invoice_type'];
|
||
$data['tax_rate'] = (string)$data['tax_rate'];
|
||
$data['invoice_form'] = (string)$data['invoice_form'];
|
||
return $data;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取发票明细数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/01/18 13:57
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
|
||
$where = [];
|
||
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
|
||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
|
||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||
}
|
||
if(isset($params['project_code']) && $params['project_code']){
|
||
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
|
||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
|
||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||
}
|
||
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
|
||
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
|
||
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
|
||
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
|
||
}
|
||
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
public function setFileName(): string
|
||
{
|
||
return '差旅报销发票明细列表';
|
||
}
|
||
|
||
/**
|
||
* @notes 导出字段
|
||
* @return string[]
|
||
* @author 段誉
|
||
* @date 2022/11/24 16:17
|
||
*/
|
||
public function setExcelFields(): array
|
||
{
|
||
return [
|
||
"id" => "id",
|
||
"trip_reimbursement_code" => "差旅报销单号",
|
||
"invoice_type_text" => "发票类型",
|
||
"invoice_sn" => "发票号",
|
||
"tax_rate_text" => "发票税率(%)",
|
||
"invoice_form_text" => "发票形式",
|
||
"invoice_amount" => "发票金额",
|
||
"tax_amount" => "发票税额",
|
||
"remark" => "发票备注",
|
||
];
|
||
}
|
||
|
||
} |