| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Http\Controllers\AdminApi;
- use App\Http\Controllers\AdminController;
- use App\Models\UserModels\WxSignup;
- use App\Models\UserModels\WxUser;
- class ApplyController extends AdminController
- {
- function getList(){
- $search = request()->input('search','');//搜索内容
- $name = request()->input('name','');//推广人
- $where = [];
- if ($name) $where[] = ['u.name', 'like', "%$name%"];
- $list = WxSignup::from('wx_signups as s')
- ->leftJoin('wx_users as u', 's.p_id', '=', 'u.id')
- ->where($where)
- ->where(function ($q) use ($search){
- if($search){
- $q->where('s.name','like',"%$search%");
- $q->orWhere('s.phone','like',"%$search%");
- }
- })
- ->select(['s.id','s.name','s.phone','s.industry','s.created_at','u.name as s_name'])
- ->paginate(10);
- return $this->apiResponseSuccess('获取信息成功', [
- 'list' => $list->items(),
- 'total' => $list->total(),
- 'limit' => 10
- ]);
- }
- /**
- * 获取推广者列表
- * @return \Illuminate\Http\JsonResponse
- */
- function getApplyList(){
- $search = request()->input('search','');//搜索内容
- $where = [['status',1]];
- $list = WxUser::where($where)
- ->where(function ($q) use ($search){
- if($search){
- $q->where('name','like',"%$search%");
- $q->orWhere('phone','like',"%$search%");
- }
- })
- ->select(['id','name','phone','pv','uv','created_at'])
- ->paginate(10);
- foreach ($list as $value){
- $value['count'] = WxUser::where('p_id',$value['id'])->where('status',1)->count();
- }
- return $this->apiResponseSuccess('获取信息成功', [
- 'list' => $list->items(),
- 'total' => $list->total(),
- 'limit' => 10
- ]);
- }
- /**
- * 获取下级统计
- * @return \Illuminate\Http\JsonResponse
- */
- function getTotal(){
- $m_id = request()->input('m_id','');//用户id
- if (empty($m_id)) return $this->apiResponseError( '必要参数缺失');
- $where = [['status',1], ['p_id',$m_id]];
- $list = WxUser::where($where)
- ->select(['id','name','phone','created_at'])
- ->paginate(10);
- return $this->apiResponseSuccess('获取信息成功', [
- 'list' => $list->items(),
- 'total' => $list->total(),
- 'limit' => 10
- ]);
- }
- }
|