136 lines
4.7 KiB
PHP
136 lines
4.7 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\finance;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsExcelInterface;
|
||
use app\common\model\contract\Contract;
|
||
use app\common\model\contract\ContractNegotiation;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\finance\FinanceInvoiceApply;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\finance\FinanceReturnedRecord;
|
||
use app\common\model\project\Project;
|
||
use think\facade\Db;
|
||
|
||
/**
|
||
* FinanceInvoiceApply列表
|
||
* Class FinanceInvoiceApplyLists
|
||
* @package app\adminapi\listsfinance
|
||
*/
|
||
class FinanceInvoiceApplyLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/12/13 15:01
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['project_id', 'contract_id','invoice_type'],
|
||
'%like%' => ['invoicing_code'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/12/13 15:01
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get(['custom_id']);
|
||
$where = [];
|
||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
||
$where[] = ['project_id','in',$project_ids];
|
||
}
|
||
return FinanceInvoiceApply::where($this->searchWhere)->where($where)
|
||
->field('id,contract_id,project_id,invoicing_code,invoicing_date,period,tax_rate,invoice_type,invoicing_amount,tax_amount,amount_including_tax')
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||
$contract = Contract::field('contract_code,contract_name,amount')->where('id',$data['contract_id'])->findOrEmpty();
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['custom_name'] = $custom['name'];
|
||
$data['contract_code'] = $contract['contract_code'];
|
||
$data['contract_name'] = $contract['contract_name'];
|
||
$data['period'] = $data->period_text;
|
||
$data['tax_rate'] = $data->tax_rate_text;
|
||
$data['invoice_type'] = $data->invoice_type_text;
|
||
return $data;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/12/13 15:01
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get(['custom_id']);
|
||
$where = [];
|
||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
||
$where[] = ['project_id','in',$project_ids];
|
||
}
|
||
return FinanceInvoiceApply::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",
|
||
"custom_name" => "客户名称",
|
||
"project_code" => "项目编码",
|
||
"project_name" => "项目名称",
|
||
"invoicing_date" => "开票日期",
|
||
"period" => "期次",
|
||
"invoice_type" => "发票类型",
|
||
"invoicing_amount" => "开票金额(含税)",
|
||
"amount_including_tax" => "开票金额(非税)",
|
||
"tax_rate" => "税率(%)",
|
||
];
|
||
}
|
||
|
||
} |