106 lines
3.6 KiB
PHP
106 lines
3.6 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\auth\Admin;
|
||
use app\common\model\financial\FinancialBorrowMoney;
|
||
use app\common\model\financial\FinancialRepayment;
|
||
|
||
|
||
/**
|
||
* 财务管理--还款单列表
|
||
* Class FinancialRepaymentLists
|
||
* @package app\adminapi\listsfinancial
|
||
*/
|
||
class FinancialRepaymentLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/03/29 11:15
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['borrow_money_id'],
|
||
'%like%' => ['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/29 11:15
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
if (!empty($params['payer_name'])) {
|
||
$admin_ids = Admin::where('name', 'like', '%' . $params['payer_name'] . '%')->column('id');
|
||
$where[] = ['payer', 'in', $admin_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 FinancialRepayment::where($this->searchWhere)->where($where)
|
||
->field(['id', 'borrow_money_id', 'code', 'payer', 'amount', 'desc', 'create_user', 'create_time'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$borrow_money = FinancialBorrowMoney::field('code,amount')->where('id', $data['borrow_money_id'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id', $data['payer'])->findOrEmpty();
|
||
$data['borrow_code'] = $borrow_money['code'];
|
||
$data['borrow_amount'] = $borrow_money['amount'];
|
||
$data['payer_name'] = $admin['name'];
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--还款单数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/03/29 11:15
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
if (!empty($params['payer_name'])) {
|
||
$admin_ids = Admin::where('name', 'like', '%' . $params['payer_name'] . '%')->column('id');
|
||
$where[] = ['payer', 'in', $admin_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 FinancialRepayment::where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
} |