Commit f087a40d authored by hj's avatar hj

更新提交

parent 198d3121
......@@ -82,7 +82,6 @@ class WuxiLabNewService
if(!empty($rawList)){
$this->apiService->pushQueue($queueParams,'wuxilab_api');
}
break;
$page ++;
}
}
......@@ -95,76 +94,81 @@ class WuxiLabNewService
*/
public function batchUpdateProductPrice()
{
$status = $this->apiService->checkPlatformStatus();
if($status){
$dbConnect = DB::connection('rhawn_mysql');
$startime = date('Y-m-d', strtotime('-1 day')).' 00:00:00';
$endtime = date('Y-m-d', time()).' 00:00:00';
$product = $dbConnect->table('prochange')
->whereRaw("updatetime >=".strtotime($startime)." and updatetime <=".strtotime($endtime))
->where('type', '2')
->get()->toArray();
if(count($product) > 0){
$productIds = array_unique(array_column($product, 'p_id'));
$productList = $this->rhawnChemicalsService->getProductsListThroughPids($productIds);
$updateProductPrice = [];
foreach($productList as $product){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
list($pCode, $packCode) = explode('-', $product->p_code);
$tempData['productId'] = $pCode;
$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;
try{
$status = $this->apiService->checkPlatformStatus();
if($status){
$dbConnect = DB::connection('rhawn_mysql');
$startime = date('Y-m-d', strtotime('-1 day')).' 00:00:00';
$endtime = date('Y-m-d', time()).' 00:00:00';
$product = $dbConnect->table('prochange')
->whereRaw("updatetime >=".strtotime($startime)." and updatetime <=".strtotime($endtime))
->where('type', '2')
->get()->toArray();
if(count($product) > 0){
$productIds = array_unique(array_column($product, 'p_id'));
$productList = $this->rhawnChemicalsService->getProductsListThroughPids($productIds);
$updateProductPrice = [];
foreach($productList as $product){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
list($pCode, $packCode) = explode('-', $product->p_code);
$tempData['productId'] = $pCode;
$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);
}
$result = $this->apiService->pushBatchUpdatePrice($updateProductPrice, $this->getToken());
$this->processApiResponse($result);
}
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':batchUpdateToWuxiLab', 'error');
}
}
public function batchUpdateProductStock()
{
$status = $this->apiService->checkPlatformStatus();
if($status){
$dbConnect = DB::connection('rhawn_mysql');
$startime = date('Y-m-d', strtotime('-1 day')).' 00:00:00';
$endtime = date('Y-m-d', time()).' 00:00:00';
$product = $dbConnect->table('prochange')
->whereRaw("updatetime >=".strtotime($startime)." and updatetime <=".strtotime($endtime))
->where('type', '1')
->get()->toArray();
if(count($product) > 0){
$productIds = array_unique(array_column($product, 'p_id'));
$productList = $this->rhawnChemicalsService->getProductsListThroughPids($productIds);
$updateProductStock = [];
foreach($productList as $product){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
list($pCode, $packCode) = explode('-', $product->p_code);
$tempData['productId'] = $pCode;
$tempData['packageUnitDescription'] = $product->p_code;
$tempData['packageStockQuantity'] = $product->p_stock;
$tempData['packageStockLocation'] = 'CN-SH';
$tempData['stockStatus'] = $product->p_status == '1' ? 'ACTIVE' : 'INACTIVE';;
$updateProductStock[] = $tempData;
break;
try{
$status = $this->apiService->checkPlatformStatus();
if($status){
$dbConnect = DB::connection('rhawn_mysql');
$startime = date('Y-m-d', strtotime('-1 day')).' 00:00:00';
$endtime = date('Y-m-d', time()).' 00:00:00';
$product = $dbConnect->table('prochange')
->whereRaw("updatetime >=".strtotime($startime)." and updatetime <=".strtotime($endtime))
->where('type', '1')
->get()->toArray();
if(count($product) > 0){
$productIds = array_unique(array_column($product, 'p_id'));
$productList = $this->rhawnChemicalsService->getProductsListThroughPids($productIds);
$updateProductStock = [];
foreach($productList as $product){
$tempData = [];
$tempData['product_division'] = 'CHEMICAL';
list($pCode, $packCode) = explode('-', $product->p_code);
$tempData['productId'] = $pCode;
$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);
}
$result = $this->apiService->pushBatchUpdateStock($updateProductStock, $this->getToken());
$this->processApiResponse($result);
}
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':batchUpdateToWuxiLab', 'error');
}
}
......@@ -197,7 +201,6 @@ class WuxiLabNewService
$tempData['packageStockLocation'] = 'CN-SH';
$tempData['stockStatus'] = $product['p_status'] == '1' ? 'ACTIVE' : 'INACTIVE';;
$updateProductStock[] = $tempData;
break;
}
$result = $this->apiService->pushBatchUpdateStock($updateProductStock, $this->getToken());
$this->processApiResponse($result);
......@@ -220,7 +223,6 @@ class WuxiLabNewService
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':batchUpdateToWuxiLab', 'error');
var_dump($exception->getMessage());
}
}
......@@ -245,7 +247,6 @@ class WuxiLabNewService
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':batchUpdateToWuxiLab', 'error');
var_dump($exception->getMessage());
}
}
......@@ -283,7 +284,6 @@ class WuxiLabNewService
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':batchUpdateToWuxiLab', 'error');
var_dump($exception->getMessage());
}
}
......
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