Commit ddb46597 authored by hj's avatar hj

更新提交

parent 7553b9c9
...@@ -44,19 +44,52 @@ class WuxiApiNewService extends PlatformAbstractService ...@@ -44,19 +44,52 @@ class WuxiApiNewService extends PlatformAbstractService
* @param $token * @param $token
* @return false|mixed|void * @return false|mixed|void
*/ */
public function pushBatchUpdatePackages($packages,$token) public function pushBatchUpdatePackages($updateData,$token)
{ {
return $this->postApi('/api/v2/syncProductPackageStatus', $packages, $token); $packageList = [];
foreach($updateData as $packageCode => $data){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
$tempData['productId'] = $data['r_code'];
$tempData['status'] = $data['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';
$tempData['packageUnitDescription'] = $packageCode;
$packageList[] = $tempData;
} }
return $this->postApi('/api/v2/syncProductPackageStatus', $packageList, $token);
public function pushBatchUpdatePrice($prices,$token)
{
return $this->postApi('/api/v2/syncPackagePrice', $prices, $token);
} }
public function pushBatchUpdateStock($stock,$token) public function pushBatchUpdatePrice($updateData,$token)
{
$updateProductPrice = [];
foreach($updateData as $product){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
$tempData['productId'] = $product['r_code'];
$tempData['packageUnitDescription'] = $product['p_code'];
$tempData['minPackageUnitDescription'] = '';
$tempData['price'] = bcmul($product['p_price'], 0.5, 2);
$tempData['discount'] = '0.5';
$tempData['inCostCurrency'] = 'RMB';
$tempData['status'] = $product['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';;
$updateProductPrice[] = $tempData;
}
return $this->postApi('/api/v2/syncPackagePrice', $updateProductPrice, $token);
}
public function pushBatchUpdateStock($updateData,$token)
{ {
return $this->postApi('/api/v2/syncRealTimeInventory', $stock, $token); $updateProductStock = [];
foreach($updateData as $product){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
$tempData['productId'] = $product['r_code'];
$tempData['packageUnitDescription'] = $product['p_code'];
$tempData['packageStockQuantity'] = $product['p_stock'];
$tempData['packageStockLocation'] = 'CN-SH';
$tempData['stockStatus'] = $product['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';;
$updateProductStock[] = $tempData;
}
return $this->postApi('/api/v2/syncRealTimeInventory', $updateProductStock, $token);
} }
/** /**
......
...@@ -178,47 +178,14 @@ class WuxiLabNewService ...@@ -178,47 +178,14 @@ class WuxiLabNewService
return false; return false;
} }
try{ try{
$packageList = []; $result = $this->apiService->pushBatchUpdatePackages($updateData['packageList'], $this->getToken());
foreach($updateData['packageList'] as $packageCode => $data){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
$tempData['productId'] = $data['r_code'];
$tempData['status'] = $data['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';
$tempData['packageUnitDescription'] = $packageCode;
$packageList[] = $tempData;
}
$result = $this->apiService->pushBatchUpdatePackages($packageList, $this->getToken());
$this->processApiResponse($result); $this->processApiResponse($result);
$updateProductStock = [];
foreach($updateData['packageList'] as $product){ $result = $this->apiService->pushBatchUpdateStock($updateData['packageList'], $this->getToken());
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
$tempData['productId'] = $product['r_code'];
$tempData['packageUnitDescription'] = $product['p_code'];
$tempData['packageStockQuantity'] = $product['p_stock'];
$tempData['packageStockLocation'] = 'CN-SH';
$tempData['stockStatus'] = $product['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';;
$updateProductStock[] = $tempData;
}
$result = $this->apiService->pushBatchUpdateStock($updateProductStock, $this->getToken());
$this->processApiResponse($result); $this->processApiResponse($result);
$updateProductPrice = []; $result = $this->apiService->pushBatchUpdatePrice($updateData['packageList'], $this->getToken());
foreach($updateData['packageList'] as $product){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
$tempData['productId'] = $product['r_code'];
$tempData['packageUnitDescription'] = $product['p_code'];
$tempData['minPackageUnitDescription'] = '';
$tempData['price'] = bcmul($product['p_price'], 0.5, 2);
$tempData['discount'] = '0.5';
$tempData['inCostCurrency'] = 'RMB';
$tempData['status'] = $product['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';;
$updateProductPrice[] = $tempData;
}
$result = $this->apiService->pushBatchUpdatePrice($updateProductPrice, $this->getToken());
$this->processApiResponse($result); $this->processApiResponse($result);
}catch(\Throwable $exception){ }catch(\Throwable $exception){
...@@ -232,17 +199,7 @@ class WuxiLabNewService ...@@ -232,17 +199,7 @@ class WuxiLabNewService
return false; return false;
} }
try{ try{
$packageList = []; $result = $this->apiService->pushBatchUpdatePackages($updateData['packageList'], $this->getToken());
foreach($updateData['packageList'] as $packageCode => $data){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
$tempData['productId'] = $data['r_code'];
$tempData['status'] = $data['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';
$tempData['packageUnitDescription'] = $packageCode;
$packageList[] = $tempData;
}
$result = $this->apiService->pushBatchUpdatePackages($packageList, $this->getToken());
$this->processApiResponse($result); $this->processApiResponse($result);
}catch(\Throwable $exception){ }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