统一两个仓库的接口返回值
This commit is contained in:
parent
e18a3bf35d
commit
3e0b0bea6f
|
@ -131,7 +131,12 @@ class GwallWms extends BaseWms implements WmsInterface
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $this->request($service, $postData);
|
$result = $this->request($service, $postData);
|
||||||
return $result;
|
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 = [];
|
$data = [];
|
||||||
foreach ($params as $item) {
|
foreach ($params as $item) {
|
||||||
$result = $this->goodsStockInfoSingle($item['wms_code']);
|
$result = $this->goodsStockInfoSingle($item['wms_code']);
|
||||||
if (!$result['isSuccess']) {
|
if (!$result['success']) {
|
||||||
continue;
|
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,
|
'encrypt' => $encrypt,
|
||||||
'content' => $base64Content,
|
'content' => $base64Content,
|
||||||
];
|
];
|
||||||
$response = $this->post($query);
|
$result = $this->post($query);
|
||||||
return \GuzzleHttp\json_decode($response, true);
|
$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)
|
public function base64Content($content, $encrypt = 0)
|
||||||
|
@ -372,4 +384,17 @@ class GwallWms extends BaseWms implements WmsInterface
|
||||||
{
|
{
|
||||||
return strtoupper(md5($content . $this->config['session_key']));
|
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);
|
$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);
|
$res = $this->createSign($method, $body);
|
||||||
$result = $this->post($body, $res);
|
$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