Commit 04a284ba authored by hangjun83's avatar hangjun83

openapi 震坤行

parent 4cfaac69
......@@ -47,4 +47,12 @@ class PlatformDataEntriesRepositoryEloquent extends BaseRepository implements Pl
],$entries);
}
public function removeEntries($platformId, $key)
{
return $this->deleteWhere([
'platform_id' => $platformId,
'data_key' => $key
]);
}
}
......@@ -34,4 +34,9 @@ class PlatformDataEntriesService
{
return $this->entiresRepository->getEntriesValues($platformId,$key);
}
public function removeEntriesValues($platformId, $key)
{
return $this->entiresRepository->removeEntries($platformId, $key);
}
}
......@@ -350,6 +350,10 @@ class ZhenkhApiService extends PlatformAbstractService
if($decodeResponse){
if($decodeResponse['code'] == '200' && $decodeResponse['isSuccess'] == true){
return $decodeResponse['data'] == NULL ? true : $decodeResponse;
}elseif($decodeResponse['code'] == '403' && $decodeResponse['msg'] == 'token 已经失效'){
//删除当前token
$this->removePlatformDataEntries('zkh_api_token');
return ['reset' => true];
}
}
return false;
......
......@@ -109,4 +109,9 @@ abstract class PlatformAbstractService
{
return $this->dataEntriesService->storeEntries($this->getPlatformInfo('id'),$dataKey,$dataValues);
}
public function removePlatformDataEntries($dataKey)
{
return $this->dataEntriesService->removeEntriesValues($dataKey);
}
}
......@@ -54,18 +54,28 @@ class ZhenKhService
try{
$product = $this->rhawnService->getRawProductsThroughPid($goods['zg_r_pid']);
if($product){
$this->apiService->updateReportProductPrice([
while(true){
$result = $this->apiService->updateReportProductPrice([
'price' => round(bcmul($product->p_price,0.5,2),1),
'price_unit' => $goods['zg_unit'],
'sku' => $goods['zg_sku']
],$this->getToken());
if(!$result['reset'] || $result['reset'] != true){
break;
}
}
$this->apiService->updateReportProductStock([
while(true){
$result = $this->apiService->updateReportProductStock([
'warehouse' => '上海货仓',
'address' => ['0' => $goods['zg_addr']],
'qty' => $product->p_stock,
'sku' => $goods['zg_sku']
],$this->getToken());
if(!$result['reset'] || $result['reset'] != true){
break;
}
}
}
$this->rhawnService->updateSyncRunTime($goods);
......@@ -91,7 +101,12 @@ class ZhenKhService
$sendContent = [];
while(true){
$pageSize = $this->apiService->getPlatformInfo()['platform_params']['page_size'];
while(true){
$goodsList = $this->apiService->getUpdateGoods($page,$pageSize,$this->getToken());
if(!isset($goodsList['reset']) || $goodsList['reset'] != true){
break;
}
}
if($goodsList && count($goodsList['list']) > 0){
$sendContent = [
'params' => ['goods' => $goodsList['list']],
......@@ -137,7 +152,12 @@ class ZhenKhService
$pageSize = $this->apiService->getPlatformInfo()['platform_params']['page_size'];
$postParams['page_size'] = $pageSize;
$postParams['page_no'] = $page;
while(true){
$orderList = $this->apiService->getUpdateOrders($postParams,$this->getToken());
if(!isset($orderList['reset']) || $orderList['reset'] != true){
break;
}
}
if($orderList && count($orderList['list']) > 0){
foreach($orderList['list']['data'] as $order){
if($order['orderStatus'] == 0){
......@@ -215,7 +235,12 @@ class ZhenKhService
$order = $params['orders'];
try {
if($order['orderStatus'] == 0){
while(true){
$orderDetail = $this->apiService->getUpdateOrdersDetail($order['purchaseOrderId'],$this->getToken());
if(!isset($orderDetail['reset']) || $orderDetail['reset'] != true){
break;
}
}
if($orderDetail){
$result = $this->rhawnOrderService->updateZhenkhOrders($order,$orderDetail);
}
......@@ -242,7 +267,12 @@ class ZhenKhService
if($orderDelivery){
$expressArray = $this->apiService->getPlatformDataEntries('zkh_order_express','data_values');
if(empty($expressArray)){
while(true){
$expressList = $this->apiService->expressLogistics($this->getToken());
if(!isset($expressList['reset']) || $expressList['reset'] != true){
break;
}
}
if($expressList){
//$sysDefault = ['JD', 'SF', 'ZT', 'YD', 'ZJS', 'DBL', 'YTO', 'YZPY', 'AN', 'STO', 'HHTT', 'WL', 'ziti'];
foreach($expressList as $express){
......@@ -265,7 +295,12 @@ class ZhenKhService
}
}
$orderNo = current($orderDelivery)->so_cus_po;
while(true){
$deliveryOrderDetail = $this->apiService->sendDeliveryOrder($orderNo,$this->getToken());
if(!isset($deliveryOrderDetail['reset']) || $deliveryOrderDetail['reset'] != true){
break;
}
}
$deliveryDetail = [];
if($deliveryOrderDetail){
foreach($deliveryOrderDetail['lines'] as $order){
......@@ -312,8 +347,13 @@ class ZhenKhService
}
}
$deliveryPost['itemList'] = $resetItemList;
while(true){
//确认发货
$deliveryResult = $this->apiService->ackDeliveryOrder($deliveryPost,$this->getToken());
if(!isset($deliveryResult['reset']) || $deliveryResult['reset'] != true){
break;
}
}
if($deliveryResult){
$this->apiService->storePlatformDataEntries('zkh_delivery_code_'.$deliveryCode,['code' => $deliveryResult['data']]);
}
......@@ -338,7 +378,12 @@ class ZhenKhService
SimpleLogs::writeLog($deliveryCode.'送货单无法匹配', __CLASS__.':getDeliveryOrderPdf', 'error');
return false;
}
while(true){
$deliveryInfo = $this->apiService->getDeliveryOrderDetailForPDF($zkhDeliveryCode['code']['deliveryCode'],$this->getToken());
if(!isset($result['reset']) || $result['reset'] != true){
break;
}
}
if($deliveryInfo){
$this->apiService->storePlatformDataEntries('zkh_order_delivery_pdf_'.$deliveryCode,['pdf' => $deliveryInfo]);
return $deliveryInfo;
......@@ -360,7 +405,12 @@ class ZhenKhService
try{
$orderDetail = $this->rhawnOrderService->getSorderDetail($orderNo);
if($orderDetail){
return $this->apiService->orderConfirm(current($orderDetail)['so_cus_po'], $this->getToken());
while(true){
$result = $this->apiService->orderConfirm(current($orderDetail)['so_cus_po'], $this->getToken());
if(!isset($result['reset']) || $result['reset'] != true){
break;
}
}
}
return false;
}catch(\Throwable $exception){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment