DESKTOP-2STQMTS\Administrator 3 жил өмнө
parent
commit
70084489fb

+ 91 - 0
app/Http/Controllers/AdminApi/ApplyController.php

@@ -0,0 +1,91 @@
+<?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
+        ]);
+    }
+}

+ 12 - 0
routes/adminApi/apply.php

@@ -0,0 +1,12 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+
+Route::group(['domain' => env('APP_HOST'), 'prefix' => 'adminApi/apply'],function (){
+    Route::match(['get','post'],'list', 'ApplyController@getList')->name('adminApi.apply.list');//报名列表
+    Route::match(['get','post'],'apply', 'ApplyController@getApplyList')->name('adminApi.apply.apply');//获取推广者列表
+    Route::match(['get','post'],'total', 'ApplyController@getTotal')->name('adminApi.apply.total');//获取下级统计
+
+});