查询下属客户

This commit is contained in:
2025-08-08 15:52:13 +08:00
parent 8ebdb052dc
commit 859fd1cff1
5 changed files with 88 additions and 2 deletions
+51
View File
@@ -4,6 +4,7 @@ namespace app\crm\service;
use app\common\model\Corp;
use app\common\model\User;
use app\common\traits\crud\CrudServiceTrait;
use app\crm\logic\CustomerLogic;
use app\crm\model\Channel;
use app\crm\model\Country;
@@ -12,9 +13,18 @@ use app\crm\model\CustomerHis;
use app\crm\model\Follow;
use app\crm\utils\Util;
use config\constants\Constants;
use support\Request;
class CustomerService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = Customer::class;
public function list($params)
{
// $page = $request->input('page', 1);
@@ -112,6 +122,46 @@ class CustomerService
return $customer;
}
/** 分页列表 */
public function serviceList(Request $request)
{
if (method_exists($this, 'complexQuery')) {
$result = $this->complexQuery($request->get());
} else {
$config = $this->buildQueryConfig($request, 'index');
$limit = (int)$request->get('size', 15);
$page = (int)$request->get('current', 1);
$result = $this->logicList($config, $limit, $page);
}
return $this->postProcess('List', $result);
}
/**
* 构造 CrudUtil 查询配置
*/
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'index':
$config['where']['status'] = 1; // 关键字
if (isset($p['keyword']) && $p['keyword']) {
$k = '%' . $p['keyword'] . '%';
$config['where']['contacts'] = ['like', $k];
}
$config['order']['id'] = 'desc';
$config['dataLimit']['type'] = 'relation';
$config['dataLimit']['userId'] = $request->user->uid;
$config['dataLimit']['userField'] = 'user_id';
break;
}
return $config;
}
public function report($params)
{
$id = $params['id'];
@@ -187,6 +237,7 @@ class CustomerService
// $customer['last_follow'] = $last_follow;
$customer['enter_user_name'] = empty($customer['enter_user_id']) ? '' : User::where('id',$customer['enter_user_id'])->value('name');
$customer['user_name'] = empty($customer['user_id']) ? '公海' : User::where('id',$customer['user_id'])->value('name');
if ($tag) {
foreach ($customer['tags'] as &$tag) {