|
@@ -68,7 +68,7 @@ class FengSu extends Command
|
|
|
{
|
|
{
|
|
|
$output->writeln('开始同步订单');
|
|
$output->writeln('开始同步订单');
|
|
|
|
|
|
|
|
- $resquet = $this->getOrderList('');
|
|
|
|
|
|
|
+ $resquet = $this->getOrderList();
|
|
|
if ($resquet['code'] == 0) {
|
|
if ($resquet['code'] == 0) {
|
|
|
$fengsu = [];
|
|
$fengsu = [];
|
|
|
$fengsu = Cache::get('fengsu_'.$this->platform);
|
|
$fengsu = Cache::get('fengsu_'.$this->platform);
|
|
@@ -127,7 +127,7 @@ class FengSu extends Command
|
|
|
$output->writeln('ok');
|
|
$output->writeln('ok');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getOrderList($platform = '')
|
|
|
|
|
|
|
+ public function getOrderList()
|
|
|
{
|
|
{
|
|
|
$client = new \GuzzleHttp\Client([
|
|
$client = new \GuzzleHttp\Client([
|
|
|
'verify' => false,
|
|
'verify' => false,
|
|
@@ -139,7 +139,7 @@ class FengSu extends Command
|
|
|
'Accept' => ' application/json, text/plain, */*',
|
|
'Accept' => ' application/json, text/plain, */*',
|
|
|
'Authorization' => site_config("addonsd.authorization_token"),
|
|
'Authorization' => site_config("addonsd.authorization_token"),
|
|
|
'Host' => ' fsdy2.fengsutb.com',
|
|
'Host' => ' fsdy2.fengsutb.com',
|
|
|
- 'platform' => $platform,
|
|
|
|
|
|
|
+ 'platform' => $this->platform,
|
|
|
'Content-Type' => ' application/json'
|
|
'Content-Type' => ' application/json'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
@@ -262,6 +262,7 @@ class FengSu extends Command
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public function insertOrder($order_list)
|
|
public function insertOrder($order_list)
|
|
|
{
|
|
{
|
|
|
if (!(count($order_list) > 0)) {
|
|
if (!(count($order_list) > 0)) {
|
|
@@ -373,6 +374,89 @@ class FengSu extends Command
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public function get_fengsu_order($platform,$waybill_no){
|
|
|
|
|
+ $resquet = $this->get_fengsu_order_list($platform,$waybill_no);
|
|
|
|
|
+ return $resquet;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取指定订单号
|
|
|
|
|
+ public function get_fengsu_order_list($platform,$waybill_no){
|
|
|
|
|
+ $client = new \GuzzleHttp\Client([
|
|
|
|
|
+ 'verify' => false,
|
|
|
|
|
+ // 或指定证书路径
|
|
|
|
|
+ // 'verify' => '/path/to/cacert.pem'
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $headers = [
|
|
|
|
|
+ 'Accept' => ' application/json, text/plain, */*',
|
|
|
|
|
+ 'Authorization' => site_config("addonsd.authorization_token"),
|
|
|
|
|
+ 'Host' => ' fsdy2.fengsutb.com',
|
|
|
|
|
+ 'platform' => $platform,
|
|
|
|
|
+ 'Content-Type' => ' application/json'
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ $todayTime = date("Y-m-d");
|
|
|
|
|
+ $startTime_stamp = 0;
|
|
|
|
|
+ $endTime_stamp = strtotime($todayTime . '23:59:59');
|
|
|
|
|
+ $pageNum = 1;
|
|
|
|
|
+
|
|
|
|
|
+ $startTime = date('Y-m-d H:i:s', $startTime_stamp);
|
|
|
|
|
+ $endTime = date('Y-m-d H:i:s', $endTime_stamp);
|
|
|
|
|
+
|
|
|
|
|
+ $body = [
|
|
|
|
|
+ 'startTime' => $startTime,
|
|
|
|
|
+ 'endTime' => $endTime,
|
|
|
|
|
+ 'current' => $pageNum,
|
|
|
|
|
+ 'goodType' => 2,
|
|
|
|
|
+ 'goodsFlag' => 1,
|
|
|
|
|
+ 'orderPrefixSelect' => 'waybillNos',
|
|
|
|
|
+ 'prepareShip' => 0,
|
|
|
|
|
+ 'size' => 200,
|
|
|
|
|
+ 'sort' => 'CONSIGN_TIME',
|
|
|
|
|
+ 'sortAsc' => true,
|
|
|
|
|
+ 'timeType' => 2,
|
|
|
|
|
+ 'tradeStatus' => 2,
|
|
|
|
|
+ 'skuOuterIdExact' => false,
|
|
|
|
|
+ 'skuPropExact' => false,
|
|
|
|
|
+ 'tradeSources' => [],
|
|
|
|
|
+ 'waybillNos' => [$waybill_no]
|
|
|
|
|
+ ];
|
|
|
|
|
+ // 'waybillNos' => ['73589756512463']
|
|
|
|
|
+ $body = json_encode($body);
|
|
|
|
|
+
|
|
|
|
|
+ $request = new Request('POST', $this->url, $headers, $body);
|
|
|
|
|
+ try {
|
|
|
|
|
+ $res = $client->sendAsync($request)->wait();
|
|
|
|
|
+
|
|
|
|
|
+ $json = [];
|
|
|
|
|
+ if ($res->getStatusCode() == 200) {
|
|
|
|
|
+ $json = json_decode($res->getBody()->getContents(), true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dump($res->getStatusCode(), '接口返回结果');
|
|
|
|
|
+ }
|
|
|
|
|
+ return $json;
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ $errorStr = $e->getMessage();
|
|
|
|
|
+ // 定位response:位置
|
|
|
|
|
+ $pos = strpos($errorStr, 'response:');
|
|
|
|
|
+ if ($pos !== false) {
|
|
|
|
|
+ // 从response:后开始截取
|
|
|
|
|
+ $jsonPart = substr($errorStr, $pos + strlen('response:'));
|
|
|
|
|
+ // 清理空白字符
|
|
|
|
|
+ $jsonPart = preg_replace('/^\s+|\s+$/', '', $jsonPart);
|
|
|
|
|
+ $jsonPart = json_decode($jsonPart, true);
|
|
|
|
|
+ if (!empty($jsonPart)) {
|
|
|
|
|
+ if ($jsonPart['code'] == 401 && $jsonPart['message'] == 'token失效') {
|
|
|
|
|
+ $this->set_fengsu_Authorization($client);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ var_dump($e->getMessage());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//风速接口返回格式
|
|
//风速接口返回格式
|
|
|
// {
|
|
// {
|