Ver código fonte

新增微信端区分是否绑定账号

cqpCow 1 ano atrás
pai
commit
700898bcdc
3 arquivos alterados com 23 adições e 5 exclusões
  1. 9 5
      app/Http/Middleware/CheckWx.php
  2. 8 0
      config/nocheck.php
  3. 6 0
      routes/wx.php

+ 9 - 5
app/Http/Middleware/CheckWx.php

@@ -30,10 +30,16 @@ class CheckWx
         $employee = $employee->toArray();
         if (empty($employee['mobile'])) return response()->json(['code'=> 202,'msg'=>'用户手机信息不存在!','data'=>null]);
 
-        $employee_id = $employee['employee_id'];
-        if(isset($data['checkWx'])){
-            if(empty($employee_id)) return response()->json(['code'=> 202,'msg'=>'用户未绑定账号!','data'=>null]);
+        //当前请求接口
+        $uri = $request->path();
+        //不需要校验是否绑定账号的接口
+        $url = config('nocheck');
 
+        if(in_array($uri,$url)){
+            $request->userData = new Employee();
+        }else{
+            $employee_id = $employee['employee_id'];
+            if(empty($employee_id)) return response()->json(['code'=> 202,'msg'=>'用户未绑定账号!','data'=>null]);
             //校验用户
             $service = new WxEmployeeService();
             $checkResult = $service->checkWxUser($employee_id);
@@ -61,8 +67,6 @@ class CheckWx
             $data['is_check_stock'] = true;
 
             $request->userData = $data;
-        }else{
-            $request->userData = new Employee();
         }
 
         return $next($request);

+ 8 - 0
config/nocheck.php

@@ -0,0 +1,8 @@
+<?php
+
+return [
+    "wx/saleOrderList",
+    "wx/uploadFile",
+    "wx/checkAll"
+];
+

+ 6 - 0
routes/wx.php

@@ -17,13 +17,19 @@ Route::any('wxSetMobile', 'Api\WxController@setMobile');
 Route::any('wxLogin', 'Api\WxController@login');
 
 Route::group(['middleware'=> ['checkWx']],function ($route){
+    //不需要账号登录的
     //文件上传统一方法
     $route->any('uploadFile', 'Api\FileUploadController@uploadFile');
     $route->any('saleOrderList', 'Api\WxController@saleOrderList');
     $route->any('checkAll', 'Api\CheckController@checkAll');
 
+    //需要账号登录的
     //采购单
     $route->any('purchaseOrderList', 'Api\WxController@purchaseOrderList');
+    $route->any('purchaseOrderEdit', 'Api\PurchaseOrderController@purchaseOrderEdit');
+    $route->any('purchaseOrderDetail', 'Api\PurchaseOrderController@purchaseOrderDetail');
+    $route->any('purchaseOrderAdd', 'Api\PurchaseOrderController@purchaseOrderAdd');
+    $route->any('purchaseOrderDel', 'Api\PurchaseOrderController@purchaseOrderDel');
 
     $route->any('employeeList', 'Api\EmployeeController@employeeList');
     $route->any('departList', 'Api\EmployeeController@departList');