Просмотр исходного кода

修改env文件配置到config

hu hao 5 лет назад
Родитель
Сommit
a5296d3416

+ 2 - 1
app/Http/Controllers/api/thirdPart/weixin/AuthController.php

@@ -58,7 +58,8 @@ class AuthController extends Controller
                 'name' => $value['name']
             ]
         ];
-        $key =  env('JWT_SECRET');
+//        $key =  env('JWT_SECRET');
+        $key =  config('weiXin.jwt.JWT_SECRET');
         $alg = 'HS256';
         $token = JWT::encode($payload,$key,$alg);
         return $token;

+ 2 - 2
app/Http/Controllers/api/thirdPart/weixin/ProcurementController.php

@@ -64,7 +64,7 @@ class ProcurementController extends Controller
             'operator'=>$user->id,
             'supplier_id'=>$supplier->id,
             'quoted_at'=>Carbon::now()->toDateTimeString(),
-            'status'=>1,//2:已报价
+            'status'=>1,//1:已报价
         ]);
         DB::transaction(function ()use($procurement,$param,$supplier){
             if (!$procurement->supplier_id)$procurement->update([
@@ -108,7 +108,7 @@ class ProcurementController extends Controller
     public function finishProductionProcurement(Request $request): \Illuminate\Http\JsonResponse
     {
         $id=$request->input('id');
-        $procurement=Procurement::query()->find($id)->update(['status'=>5]);
+        $procurement=Procurement::query()->find($id)->update(['status'=>5]);//  5 => "待收货",
         if ($procurement) return $this->success($procurement);
     }
 

+ 2 - 1
app/Http/Middleware/ProcurementApiAuth.php

@@ -20,7 +20,8 @@ class ProcurementApiAuth
             ];
         $jwt = $request->header('token');
 
-        $key = env('JWT_SECRET');
+//        $key = env('JWT_SECRET');
+        $key =  config('weiXin.jwt.JWT_SECRET');
         try{
             $loginUser=JWT::decode($jwt,$key,$alg);
         }

+ 17 - 0
app/ProcurementDeliverie.php

@@ -3,10 +3,13 @@
 namespace App;
 
 use App\Traits\ModelTimeFormat;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Model;
 
 use App\Traits\ModelLogChanging;
 use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
 
 class ProcurementDeliverie extends Model
 {
@@ -31,4 +34,18 @@ class ProcurementDeliverie extends Model
     public function procurementCheckSheet(){
         return $this->belongsTo('App\ProcurementCheckSheet','id','procurement_delivery_id');
     }
+    protected static function booted()
+    {
+        /** @var User $user */
+        $user = Auth::user();
+        if ($user && !$user->isSuperAdmin()) {
+            /** @var \stdClass $user */
+            $ids = array_column(DB::select(DB::raw("SELECT supplier_id FROM supplier_user WHERE user_id = ?"),[$user->id]),"supplier_id");
+            if (count($ids)>0){
+                static::addGlobalScope('supplier', function (Builder $builder)use ($ids) {
+                    $builder->whereIn('supplier_id',  $ids);
+                });
+            }
+        }
+    }
 }

+ 2 - 1
app/Services/api/UserService.php

@@ -22,7 +22,8 @@ class UserService
                 "typ" => "JWT", //声明类型为jwt
                 "alg" => "HS256" //声明签名算法为SHA256
             ];
-        $key = env('JWT_SECRET');
+//        $key = env('JWT_SECRET');
+        $key =  config('weiXin.jwt.JWT_SECRET');
         return JWT::decode($jwt,$key,$alg);
     }
 }

+ 3 - 0
config/weiXin.php

@@ -13,4 +13,7 @@ return [
         "order_confirm_inform" => "fL5KbX45ETWEtY6sJ77F9xF7u0u4fJqCSIXLBLxe_B8",
         "wait_procurement_inform" => "k6QhyPbjKTPuJoQ7JxBqf-VVTWubgdmdDIA1uXqLZuE",
     ],
+    "jwt" => [
+        "JWT_SECRET" => "fRVVrkk1Htx7Bd3oae91f9Y2FgBjj1t6BWjHUza8eXqLlc0SGNDKVn1Tixz2shPW",
+    ],
 ];