Kaynağa Gözat

OwnerService方法修回

LD 5 yıl önce
ebeveyn
işleme
d3e13f8ff7
1 değiştirilmiş dosya ile 7 ekleme ve 1 silme
  1. 7 1
      app/Services/OwnerService.php

+ 7 - 1
app/Services/OwnerService.php

@@ -122,7 +122,7 @@ Class OwnerService
         $customerIds = array_diff($customerIds,[null,'','*']);
         $owners = Owner::query()->whereIn('code',$customerIds)->get();
 
-         if($owners->count() < count($customerIds)){
+        if($owners->count() < count($customerIds)){
             $customerIds = array_diff($customerIds,data_get($owners,'*.code'));
             $owner_list = $this->createByWmsCustomerIds($customerIds);
             $owners=$owners->concat($owner_list);
@@ -237,4 +237,10 @@ Class OwnerService
             return Owner::query()->create(['name'=>$basCustomer['descr_c'],'code'=>$basCustomer['customerid']]);
         });
     }
+    public function codeGetOwner($code)
+    {
+        return app(CacheService::class)->getOrExecute("owner_".$code,function ()use($code){
+            return Owner::query()->firstOrCreate(["code"=>$code],["code"=>$code,"name"=>$code]);
+        });
+    }
 }