93 lines
3.2 KiB
PHP
93 lines
3.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\cost_project\CostApprovedProject;
|
||
use app\common\model\financial\FinancialInvoice;
|
||
use app\common\model\financial\FinancialRefund;
|
||
|
||
|
||
/**
|
||
* 财务管理--开票台账列表
|
||
* Class FinancialInvoiceLists
|
||
* @package app\adminapi\listsfinancial
|
||
*/
|
||
class FinancialInvoiceLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/03/25 14:09
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['contract_id', 'invoice_type'],
|
||
'%like%' => ['invoice_code', 'apply_company'],
|
||
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--开票台账列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/03/25 14:09
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return FinancialInvoice::where($this->searchWhere)
|
||
->field(['id', 'contract_id', 'invoice_code', 'invoice_type', 'apply_amount', 'apply_company'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$contract = CostApprovedProject::field('contract_name,contract_type,part_a,part_b,money,create_time')->where('id', $data['contract_id'])->findOrEmpty();
|
||
$data['contract_name'] = $contract['contract_name'];
|
||
$data['contract_type'] = $contract->contract_type_text;
|
||
$data['part_a'] = $contract['part_a'];
|
||
$data['part_b'] = $contract['part_b'];
|
||
$data['sign_money'] = $contract['money'];
|
||
$data['sign_time'] = $contract['create_time'];
|
||
$data['invoice_type_text'] = $data->invoice_type_text;
|
||
$refund = FinancialRefund::where('invoice_id', $data['id'])->findOrEmpty();
|
||
$data['is_refund'] = !$refund->isEmpty() ? '已到账' : '未到账';
|
||
$data['refund_amount'] = !$refund->isEmpty() ? FinancialRefund::where('invoice_id', $data['id'])->sum('amount') : 0.00;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--开票台账数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/03/25 14:09
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return FinancialInvoice::where($this->searchWhere)->count();
|
||
}
|
||
|
||
} |