统一两个仓库的接口返回值
This commit is contained in:
parent
e18a3bf35d
commit
3e0b0bea6f
|
@ -131,8 +131,13 @@ class GwallWms extends BaseWms implements WmsInterface
|
|||
];
|
||||
|
||||
$result = $this->request($service, $postData);
|
||||
if (!$result['success']) {
|
||||
return $result;
|
||||
}
|
||||
$data = $result['response'][0];
|
||||
$formatData = $this->formatGoodsStockInfo($data);
|
||||
return array_merge($result, ['response' => $formatData]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品库存查询(批量)
|
||||
|
@ -145,12 +150,12 @@ class GwallWms extends BaseWms implements WmsInterface
|
|||
$data = [];
|
||||
foreach ($params as $item) {
|
||||
$result = $this->goodsStockInfoSingle($item['wms_code']);
|
||||
if (!$result['isSuccess']) {
|
||||
if (!$result['success']) {
|
||||
continue;
|
||||
}
|
||||
array_push($data, $result['body']);
|
||||
array_push($data, $result['response']);
|
||||
}
|
||||
return $data;
|
||||
return ['success' => true, 'response' => $data];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -354,8 +359,15 @@ class GwallWms extends BaseWms implements WmsInterface
|
|||
'encrypt' => $encrypt,
|
||||
'content' => $base64Content,
|
||||
];
|
||||
$response = $this->post($query);
|
||||
return \GuzzleHttp\json_decode($response, true);
|
||||
$result = $this->post($query);
|
||||
$result = \GuzzleHttp\json_decode($result, true);
|
||||
|
||||
$isSuccess = (empty($result) || !$result['isSuccess']) ? false : true;
|
||||
$response = [
|
||||
'success' => $isSuccess,
|
||||
'response' => $isSuccess ? $result['body'] : $result,
|
||||
];
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function base64Content($content, $encrypt = 0)
|
||||
|
@ -372,4 +384,17 @@ class GwallWms extends BaseWms implements WmsInterface
|
|||
{
|
||||
return strtoupper(md5($content . $this->config['session_key']));
|
||||
}
|
||||
|
||||
public function formatGoodsStockInfo($params)
|
||||
{
|
||||
$params = array_map(function ($item) {
|
||||
return array_merge($item, [
|
||||
'itemCode' => $item['sku'],
|
||||
'itemId' => $item['sku'],
|
||||
'quantity' => $item['uqty'],
|
||||
'lockQuantity' => $item['qty'] - $item['uqty'],
|
||||
]);
|
||||
}, $params);
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,9 @@ class XinyiWms extends BaseWms implements WmsInterface
|
|||
}
|
||||
|
||||
$result = $this->xmlPost($method, $postData);
|
||||
return $result;
|
||||
return $result['success']
|
||||
? array_merge($result, ['response' => $result['response']['items']['item']])
|
||||
: $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -474,6 +476,11 @@ class XinyiWms extends BaseWms implements WmsInterface
|
|||
$res = $this->createSign($method, $body);
|
||||
$result = $this->post($body, $res);
|
||||
|
||||
return $result;
|
||||
$isSuccess = (empty($result) || !is_array($result) || $result['response']['flag'] != 'success') ? false : true;
|
||||
$response = [
|
||||
'success' => $isSuccess,
|
||||
'response' => $isSuccess ? $result['response'] : $result,
|
||||
];
|
||||
return $response;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user