96 lines
3.5 KiB
PHP
96 lines
3.5 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\marketing;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\dept\Dept;
|
||
use app\common\model\GeoCity;
|
||
use app\common\model\GeoProvince;
|
||
use app\common\model\marketing\MarketingContract;
|
||
use app\common\model\marketing\MarketingCustom;
|
||
|
||
|
||
/**
|
||
* 市场经营--客户信息列表
|
||
* Class MarketingCustomLists
|
||
* @package app\adminapi\listsmarketing
|
||
*/
|
||
class MarketingCustomLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/04/01 14:26
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['important_level', 'dept_id', 'category', 'province', 'city'],
|
||
'%like%' => ['name', '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/04/01 14:26
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return MarketingCustom::withoutField('update_time,delete_time')->where($this->searchWhere)
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty();
|
||
$province = GeoProvince::field('province_name')->where('province_code', $data['province'])->findOrEmpty();
|
||
$city = GeoCity::field('city_name')->where('city_code', $data['city'])->findOrEmpty();
|
||
$data['dept_name'] = $dept['name'];
|
||
$data['province_name'] = !$province->isEmpty() ? $province['province_name'] : '';
|
||
$data['city_name'] = !$city->isEmpty() ? $city['city_name'] : '';
|
||
$data['important_level_text'] = $data->important_level_text;
|
||
$data['category_text'] = $data->category_text;
|
||
$data['total_contract_num'] = MarketingContract::where('part_a', $data['id'])->where('status', 1)->count();
|
||
$data['total_contract_amount'] = MarketingContract::where('part_a', $data['id'])->where('status', 1)->sum('signed_amount');
|
||
$data['is_deal'] = $data['total_contract_num'] <= 0 ? '否' : '是';
|
||
$admin = Admin::field('name')->where('id', $data['invoice_contact'])->findOrEmpty();
|
||
$data['invoice_contact_name'] = $admin?->name;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取市场经营--客户信息数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/04/01 14:26
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return MarketingCustom::where($this->searchWhere)->count();
|
||
}
|
||
|
||
} |