Commit f087a40d authored by hj's avatar hj

更新提交

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