fix: 客户检索分页查询
This commit is contained in:
@@ -129,4 +129,46 @@ class Customer extends Common
|
||||
return $this->sendSuccess($ret);
|
||||
}
|
||||
|
||||
// 客户检索 - 分页查询合作伙伴公司
|
||||
public function SearchPartnerCompany()
|
||||
{
|
||||
$param = request()->post();
|
||||
|
||||
$currPage = isset($param['page']) ? $param['page'] : 1;
|
||||
$pageSize = isset($param['limit']) ? $param['limit'] : 10;
|
||||
$company_name = isset($param['company_name']) ? $param['company_name'] : '';
|
||||
|
||||
// 构建查询条件
|
||||
$query = db('partner_company');
|
||||
|
||||
// 查询客户类型
|
||||
$query->whereIn('company_type', [1, 5]);
|
||||
|
||||
if (!empty($company_name)) {
|
||||
$query->where('company_name', 'like', '%' . $company_name . '%');
|
||||
}
|
||||
|
||||
// 查询列表数据
|
||||
$list = $query->page($currPage, $pageSize)
|
||||
->order('company_id desc')
|
||||
->select();
|
||||
|
||||
// 查询总记录数
|
||||
$totalQuery = db('partner_company');
|
||||
$totalQuery->whereIn('company_type', [1, 5]);
|
||||
|
||||
if (!empty($company_name)) {
|
||||
$totalQuery->where('company_name', 'like', '%' . $company_name . '%');
|
||||
}
|
||||
|
||||
$total = $totalQuery->count();
|
||||
|
||||
$result = [
|
||||
'list' => $list,
|
||||
'total' => $total
|
||||
];
|
||||
|
||||
return $this->sendSuccess($result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user