|
|
@@ -95,18 +95,26 @@ Class LogisticService
|
|
|
$collect = collect();
|
|
|
if(count($codes) == 0) return $collect;
|
|
|
foreach ($codes as $code) {
|
|
|
- $collect->push(Cache::remember("getLogisticByCodes_{$code}", config('database.cache.expirations.rand'), function()use($code){
|
|
|
- $logistic = Logistic::query()->where('code',$code)->first();
|
|
|
- if($logistic)return $logistic;
|
|
|
- $baseCustomers = OracleBasCustomer::query()
|
|
|
- ->selectRaw('Customer_Type,CustomerID,Descr_C')
|
|
|
- ->where('Customer_Type','CA')
|
|
|
- ->where('CustomerID',$code)->first();
|
|
|
- if(!$baseCustomers)return null;
|
|
|
- return Logistic::query()->create(['name' => $baseCustomers['descr_c'], 'code' => $baseCustomers['customerid']]);
|
|
|
- }));
|
|
|
+ $collect->push($this->getLogisticByCode($code));
|
|
|
}
|
|
|
return $collect;
|
|
|
}
|
|
|
|
|
|
+ public function getLogisticByCode($code){
|
|
|
+ return Cache::remember("getLogisticByCode_{$code}", config('database.cache.expirations.rand'), function()use($code){
|
|
|
+ $logistic = Logistic::query()->where('code',$code)->first();
|
|
|
+ if($logistic)return $logistic;
|
|
|
+ $baseCustomers = app('OracleBasCustomerService')->first(['Customer_Type'=>'CA','CustomerID'=>'$code']);
|
|
|
+ if(!$baseCustomers)return null;
|
|
|
+ try {
|
|
|
+ $logistic = Logistic::query()->create(['name' => $baseCustomers['descr_c'], 'code' => $baseCustomers['customerid']]);
|
|
|
+ app('LogService')->log(__METHOD__, __FUNCTION__,'创建Logistic SUCCESS'." || ". json_encode($logistic));
|
|
|
+ return $logistic;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ app('LogService')->log(__METHOD__, __FUNCTION__,'创建Logistic ERROR'." || ". json_encode($logistic)." || ".json_encode($e->getMessage())." || ".json_encode($e->getTraceAsString()));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|