133 lines
4.4 KiB
PHP
133 lines
4.4 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\ListsExcelInterface;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\custom\CustomFollow;
|
||
use app\common\model\GeoArea;
|
||
use app\common\model\GeoCity;
|
||
use app\common\model\GeoProvince;
|
||
|
||
/**
|
||
* Custom列表
|
||
* Class CustomLists
|
||
* @package app\adminapi\listscustom
|
||
*/
|
||
class CustomLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @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 Custom::field('id,name,custom_type,province,city,area,notes,master_name,master_position,master_telephone,master_phone,master_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();
|
||
$city = GeoCity::field('city_name')->where('city_code',$item['city'])->findOrEmpty();
|
||
$area = GeoArea::field('area_name')->where('area_code',$item['area'])->findOrEmpty();
|
||
$customFollow = CustomFollow::field('date,next_follow_date')->where('custom_id', $item['id'])->order('id', 'desc')->limit(1)->findOrEmpty();
|
||
$item['next_follow_date'] = $customFollow['next_follow_date'];
|
||
$item['last_follow_date'] = $customFollow['date'];
|
||
$item['follow_total'] = CustomFollow::where('custom_id', $item['id'])->count();
|
||
$item['add_user_name'] = $admin['name'];
|
||
$item['province_name'] = $province['province_name'];
|
||
$item['city_name'] = $city['city_name'];
|
||
$item['area_name'] = $area['area_name'];
|
||
unset($item['province'],$item['city'],$item['area'],$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();
|
||
}
|
||
|
||
/**
|
||
* @notes 导出文件名
|
||
* @return string
|
||
* @author 段誉
|
||
* @date 2022/11/24 16:17
|
||
*/
|
||
public function setFileName(): string
|
||
{
|
||
return '客户列表';
|
||
}
|
||
|
||
/**
|
||
* @notes 导出字段
|
||
* @return string[]
|
||
* @author 段誉
|
||
* @date 2022/11/24 16:17
|
||
*/
|
||
public function setExcelFields(): array
|
||
{
|
||
return [
|
||
'id' => 'id',
|
||
'name' => '客户名称',
|
||
'custom_type' => '客户属性',
|
||
'province_name' => '所在省',
|
||
'master_name' => '负责人姓名',
|
||
'master_position' => '负责人职务',
|
||
'master_telephone' => '负责人电话',
|
||
'master_phone' => '负责人手机',
|
||
'follow_total' => '跟进记录',
|
||
'last_follow_date' => '最后跟进',
|
||
'next_follow_date' => '下次回访日期',
|
||
'create_time' => '创建时间',
|
||
];
|
||
}
|
||
|
||
} |