123 lines
4.7 KiB
PHP
123 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\custom;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\GeoProvince;
|
||
|
||
/**
|
||
* Custom列表
|
||
* Class CustomLists
|
||
* @package app\adminapi\listscustom
|
||
*/
|
||
class CustomLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/11/11 22:10
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['custom_type', 'phone', 'province'],
|
||
'%like%' => ['name','master_name']
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/11/11 22:10
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
// return Db::name('Custom')->alias('c')
|
||
// ->where($this->searchWhere)
|
||
// ->whereNull('c.delete_time')
|
||
// ->leftJoin('orgs o','o.id = c.org_id')
|
||
// ->leftJoin('dept d','d.id = c.dept_id')
|
||
// ->field('c.*, d.name as dept_name, o.name as org_name')
|
||
// ->limit($this->limitOffset, $this->limitLength)
|
||
// ->order(['c.id' => 'desc'])
|
||
// ->select()->each(function($item, $key){
|
||
// //关联数据后续添加
|
||
// if (!empty($item['other_contacts'])) {
|
||
// $otherContactsArray = json_decode($item['other_contacts'], true);
|
||
// if (is_array($otherContactsArray)) {
|
||
// $item['other_contacts'] = $otherContactsArray;
|
||
// }
|
||
// }
|
||
// $item['last_follow_date'] = '-';
|
||
// $item['next_follow_date'] = '-';
|
||
// $customFollow = CustomFollow::where('custom_id', $item['id'])->order('id', 'desc')->limit(1)->findOrEmpty();
|
||
// if (!$customFollow->isEmpty()) {
|
||
// $interval = date_diff(date_create($customFollow['date']), date_create(date('Y-m-d H:i:s')));
|
||
// if ($interval->days <= 3) {
|
||
// $item['last_follow_date'] = $interval->days . '天内';
|
||
// } else if ($interval->days <= 7) {
|
||
// $item['last_follow_date'] = '1周内';
|
||
// } else if ($interval->days <= 30) {
|
||
// $item['last_follow_date'] = '30天内';
|
||
// } else if ($interval->days <= 60) {
|
||
// $item['last_follow_date'] = '60天内';
|
||
// } else {
|
||
// $item['last_follow_date'] = '超过60天内';
|
||
// }
|
||
// $item['next_follow_date'] = $customFollow['next_follow_date'];
|
||
// }
|
||
// return $item;
|
||
// })
|
||
// ->toArray();
|
||
return Custom::field('id,name,custom_type,province,master_name,master_position,master_telephone,master_phone,notes,add_user,create_time')
|
||
->where($this->searchWhere)->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($item){
|
||
$item['custom_type_text'] = $item->custom_type_text;
|
||
$admin = Admin::field('id,name')->where('id',$item['add_user'])->findOrEmpty();
|
||
$province = GeoProvince::field('province_name')->where('province_code',$item['province'])->findOrEmpty();
|
||
$item['add_user_name'] = $admin['name'];
|
||
$item['province_name'] = $province['province_name'];
|
||
unset($item['province'],$item['add_user']);
|
||
return $item;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/11/11 22:10
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return Custom::where($this->searchWhere)->count();
|
||
}
|
||
|
||
} |