|
@@ -209,7 +209,7 @@ class Agent extends Commission
|
|
|
{
|
|
|
$params = $this->request->param();
|
|
|
|
|
|
- // 使用验证器验证分页参数:page, page_size, time_filter, start_date, end_date
|
|
|
+ // 使用验证器验证分页参数:page, page_size, time_filter, start_date, end_date, search_keyword
|
|
|
$validate = new \app\api\validate\Agent();
|
|
|
if (!$validate->scene('team')->check($params)) {
|
|
|
$this->error($validate->getError());
|
|
@@ -222,6 +222,7 @@ class Agent extends Commission
|
|
|
$timeFilter = isset($params['time_filter']) ? $params['time_filter'] : 'all';
|
|
|
$startDate = isset($params['start_date']) ? $params['start_date'] : '';
|
|
|
$endDate = isset($params['end_date']) ? $params['end_date'] : '';
|
|
|
+ $searchKeyword = isset($params['search_keyword']) ? trim($params['search_keyword']) : '';
|
|
|
|
|
|
// 构建查询条件数组
|
|
|
$whereConditions = [
|
|
@@ -239,7 +240,20 @@ class Agent extends Commission
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $data = UserModel::where($whereConditions)->field('id,username,nickname,avatar,mobile,bind_time,commission,order_count,total_consume,status,parent_user_id')
|
|
|
+
|
|
|
+ // 构建查询对象
|
|
|
+ $query = UserModel::where($whereConditions);
|
|
|
+
|
|
|
+ // 添加搜索条件(按姓名和手机号搜索)
|
|
|
+ if (!empty($searchKeyword)) {
|
|
|
+ $query->where(function ($q) use ($searchKeyword) {
|
|
|
+ $q->whereLike('nickname', '%' . $searchKeyword . '%')
|
|
|
+ ->whereOr('username', 'like', '%' . $searchKeyword . '%')
|
|
|
+ ->whereOr('mobile', 'like', '%' . $searchKeyword . '%');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = $query->field('id,username,nickname,avatar,mobile,bind_time,commission,order_count,total_consume,status,parent_user_id')
|
|
|
->with(['agent' => function ($query) {
|
|
|
return $query->with('level_info')->field('user_id,agent_type,child_user_count_all,child_order_money_all');
|
|
|
}])
|