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

OwnerService.php 修改方法【getOwnerByCodes】
添加方法【getOwnerByCodes】

ajun 5 лет назад
Родитель
Сommit
44e8a133ee
1 измененных файлов с 11 добавлено и 7 удалено
  1. 11 7
      app/Services/OwnerService.php

+ 11 - 7
app/Services/OwnerService.php

@@ -222,14 +222,18 @@ Class OwnerService
         $collect = collect();
         if(count($codes) == 0)return $collect;
         foreach ($codes as $code) {
-            $collect->push(Cache::remember("getOwnerByCodes_{$code}", config('database.cache.expirations.rand'), function ()use($code){
-                $owner = Owner::query()->where('code',$code)->first();
-                if($owner) return $owner;
-                $basCustomer = OracleBasCustomer::query()->where('Customer_Type','OW')->where('CustomerID', $code)->first();
-                if(!$basCustomer)return null;
-                return Owner::query()->create(['name'=>$basCustomer['descr_c'],'code'=>$basCustomer['customerid']]);
-            }));
+            $collect->push($this->getOwnerByCode($code));
         }
         return $collect;
     }
+
+    public function getOwnerByCode($code){
+        return Cache::remember("getOwnerByCode_{$code}", config('database.cache.expirations.rand'), function ()use($code){
+            $owner = Owner::query()->where('code',$code)->first();
+            if($owner) return $owner;
+            $basCustomer = app('OracleBasCustomerService')->first(['Customer_Type'=>'OW','CustomerID'=>$code]);
+            if(!$basCustomer)return null;
+            return Owner::query()->create(['name'=>$basCustomer['descr_c'],'code'=>$basCustomer['customerid']]);
+        });
+    }
 }