104 lines
3.9 KiB
PHP
104 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\auth\Admin;
|
||
use app\common\model\financial\FinancialCollectionPlan;
|
||
use app\common\model\marketing\MarketingContract;
|
||
|
||
|
||
/**
|
||
* 财务管理--合同收款计划列表
|
||
* Class FinancialCollectionPlanLists
|
||
* @package app\adminapi\listsfinancial
|
||
*/
|
||
class FinancialCollectionPlanLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/04/13 13:46
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['contract_id'],
|
||
'%like%' => ['collection_user'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--合同收款计划列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/04/13 13:46
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
if (!empty($params['collection_date'])) {
|
||
$date = explode(',', $params['collection_date']);
|
||
$where[] = ['collection_date', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||
}
|
||
return FinancialCollectionPlan::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where)
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$contract = MarketingContract::field('contract_name,contract_type,business_nature,part_a,signed_amount,create_time')->where('id', $data['contract_id'])->findOrEmpty();
|
||
$data['contract_name'] = !$contract->isEmpty() ? $contract['contract_name'] : '';
|
||
$data['contract_type'] = !$contract->isEmpty() ? $contract->contract_type_text : '';
|
||
$data['business_nature'] = !$contract->isEmpty() ? $contract->business_nature_text : '';
|
||
$data['signed_amount'] = !$contract->isEmpty() ? $contract['signed_amount'] : '';
|
||
$data['signed_date'] = !$contract->isEmpty() ? $contract['signed_date'] : '';
|
||
$admin = Admin::field('name')->where('id', $data['collection_user'])->findOrEmpty();
|
||
$data['collection_user_name'] = !$admin->isEmpty() ? $admin['name'] : '';
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取财务管理--合同收款计划数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/04/13 13:46
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get();
|
||
$where = [];
|
||
if (!empty($params['contract_name'])) {
|
||
$contract_ids = MarketingContract::where('contract_name', 'like', '%' . $params['contract_name'] . '%')->column('id');
|
||
$where[] = ['contract_id', 'in', $contract_ids];
|
||
}
|
||
if (!empty($params['collection_date'])) {
|
||
$date = explode(',', $params['collection_date']);
|
||
$where[] = ['collection_date', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||
}
|
||
return FinancialCollectionPlan::where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
} |