|
|
@@ -31,8 +31,8 @@ class ShopService
|
|
|
}
|
|
|
|
|
|
public function getByWmsOrders($orderHeaders)
|
|
|
- { //issuepartyname
|
|
|
- $maps = [];
|
|
|
+ {
|
|
|
+ $maps = []; //issuepartyname
|
|
|
foreach ($orderHeaders as $orderHeader) {
|
|
|
$value = ['owner_code'=>$orderHeader->customerid,'issuepartyname'=>$orderHeader->issuepartyname];
|
|
|
if(!in_array($value,$maps))
|
|
|
@@ -46,10 +46,10 @@ class ShopService
|
|
|
})->whereIn('name',$issuepartynames)->get();
|
|
|
if($shops->count() < count($issuepartynames)){
|
|
|
$shops_code = data_get($shops,'*.name');
|
|
|
- $issuepartynames = array_diff($issuepartynames,$shops_code);
|
|
|
+ $names = array_diff($issuepartynames,$shops_code);
|
|
|
$params = [];
|
|
|
foreach ($maps as $item){
|
|
|
- if(in_array($item['issuepartyname'],$issuepartynames))
|
|
|
+ if(in_array($item['issuepartyname'],$names))
|
|
|
$params[] = $item;
|
|
|
}
|
|
|
$shops_list = $this->createByNameAndOwnerCode($params);
|
|
|
@@ -59,9 +59,7 @@ class ShopService
|
|
|
}
|
|
|
|
|
|
public function createByNameAndOwnerCode(array $params){
|
|
|
- $owners = Owner::query()
|
|
|
- ->whereIn('code',data_get($params,'*.owner_code'))
|
|
|
- ->get();
|
|
|
+ $owners = Owner::query()->whereIn('code',data_get($params,'*.owner_code'))->get();
|
|
|
$owners_map = [];
|
|
|
foreach ($owners as $owner) {
|
|
|
$owners_map[$owner->code] = $owner;
|
|
|
@@ -82,11 +80,9 @@ class ShopService
|
|
|
app('LogService')->log(__METHOD__, __FUNCTION__, '批量创建 shop ' . count($insert_params) . json_encode($insert_params));
|
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
|
- app('LogService')->log(__METHOD__, __FUNCTION__, '批量创建 shop ' . json_encode($insert_params) .'||'.$e->getMessage().'||'.$e->getTraceAsString());
|
|
|
+ app('LogService')->log(__METHOD__, 'Error '.__FUNCTION__, '批量创建 shop Error' . json_encode($insert_params) .'||'.$e->getMessage().'||'.$e->getTraceAsString());
|
|
|
} finally {
|
|
|
- return Shop::query()
|
|
|
- ->whereIn('name',data_get($params,'*.issuepartyname'))
|
|
|
- ->get();
|
|
|
+ return Shop::query()->whereIn('name',data_get($params,'*.issuepartyname'))->get();
|
|
|
}
|
|
|
}
|
|
|
|