Commit 044ea405 authored by hj's avatar hj

更新提交

parent bbb50c62
This diff is collapsed.
<?php <?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Services\ThirdPlatform; namespace App\Services\ThirdPlatform;
use App\ImportExport\WuxiLab\WuxiLabExport; use App\ImportExport\WuxiLab\WuxiLabExport;
use App\Repositories\Contracts\ThirdApiPlatformRepository; use App\Repositories\Contracts\ThirdApiPlatformRepository;
use App\Rhawn\Services\RhawnProductService; use App\Rhawn\Services\RhawnProductService;
use App\Services\ThirdPlatform\Api\WuxiApiService; use App\Services\ThirdPlatform\Api\WuxiApiNewService;
use App\Support\Facades\SimpleLogs; use App\Support\Facades\SimpleLogs;
class WuxiLabNewService class WuxiLabNewService
...@@ -22,7 +13,7 @@ class WuxiLabNewService ...@@ -22,7 +13,7 @@ class WuxiLabNewService
public function __construct() public function __construct()
{ {
$this->apiService = (new WuxiApiService(app(ThirdApiPlatformRepository::class))); $this->apiService = (new WuxiApiNewService(app(ThirdApiPlatformRepository::class)));
$this->rhawnChemicalsService = app(RhawnProductService::class); $this->rhawnChemicalsService = app(RhawnProductService::class);
} }
...@@ -67,7 +58,7 @@ class WuxiLabNewService ...@@ -67,7 +58,7 @@ class WuxiLabNewService
$this->apiService->pushQueue([ $this->apiService->pushQueue([
'params' => ['rawList' => $rawList,'packageList' => $newPackages], 'params' => ['rawList' => $rawList,'packageList' => $newPackages],
'consumer' => __CLASS__, 'consumer' => __CLASS__,
'method' => 'batchUpdateToWuxiLab' 'method' => 'batchUpdateTo'
],'wuxilab'); ],'wuxilab');
} }
...@@ -122,50 +113,6 @@ class WuxiLabNewService ...@@ -122,50 +113,6 @@ class WuxiLabNewService
} }
} }
public function test($rawCode)
{
try{
$rawsList = $this->rhawnChemicalsService->getChemicalRawThroughtCode($rawCode);
if($rawsList){
foreach ($rawsList as $raw) {
$rawIdList[] = $raw['r_id'];
}
$packages = $this->rhawnChemicalsService->getChemicalPackage($rawIdList);
$newPackages = [];
if($packages){
foreach($packages as $pack){
$newPackages[$pack['r_code']] = $pack;
}
}
/*$path = app(WuxiLabExport::class)->saveExcel(
['rawList' => $rawsList,'packageList' => $newPackages],
'package'
);
if($path){
list($file,$expend) = explode('.',$path);
$newPath = $file.'.'.strtolower($expend);
$cmd = 'mv '.storage_path('app/'.$path).' '.storage_path('app/'.$newPath);
trim(shell_exec("$cmd 2>&1"));
$filePathList = explode('/',$file);
$fileName = $filePathList[count($filePathList) - 1];
$result = $this->apiService->pushBatchUploadFile('package',$fileName, $this->apiService->backgroundLogin());
if($result){
$cmd = 'rm -rf '.storage_path('app/'.$newPath);
trim(shell_exec("$cmd 2>&1"));
SimpleLogs::writeLog('文件名为:'.$fileName.'路径:'.$newPath.'药明康德后台上传完成', __CLASS__.':processNotExistProductsUpdate');
}
}*/
$result = $this->apiService->pushBatchUpdateProduct(['rawList' => $rawsList,'packageList' => $newPackages]);
var_dump($result);
}
}catch(\Throwable $exception){
var_dump($exception->getMessage());
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':processNotExistProductsUpdate', 'error');
}
}
/** /**
* 批量更新新的商品 * 批量更新新的商品
*/ */
...@@ -399,19 +346,19 @@ class WuxiLabNewService ...@@ -399,19 +346,19 @@ class WuxiLabNewService
* @批量更新商品 * @批量更新商品
* @param $updateData * @param $updateData
*/ */
public function batchUpdateToWuxiLab($updateData) public function batchUpdateTo($updateData)
{ {
if(!isset($updateData['rawList']) || empty($updateData['rawList'])){ if(empty($updateData['rawList'])){
return false; return false;
} }
if(!isset($updateData['packageList']) || empty($updateData['packageList'])){ if(empty($updateData['packageList'])){
return false; return false;
} }
try{ try{
$result = $this->apiService->pushBatchUpdateProduct($updateData); $result = $this->apiService->pushBatchUpdateProduct($updateData);
if($result){ if($result){
//处理更新不成功的商品 //处理更新不成功的商品
if(isset($result['errorProduct']) && !empty($result['errorProduct'])){ if(!empty($result['errorProduct'])){
$storeEntries = $this->apiService->getPlatformDataEntries('wuxiLab_not_exist_products','data_values'); $storeEntries = $this->apiService->getPlatformDataEntries('wuxiLab_not_exist_products','data_values');
if(isset($storeEntries) && !empty($storeEntries)){ if(isset($storeEntries) && !empty($storeEntries)){
if(count($storeEntries['products']) >= $this->apiService->getPlatformInfo('platform_params')['excelCreateLimit']){ if(count($storeEntries['products']) >= $this->apiService->getPlatformInfo('platform_params')['excelCreateLimit']){
......
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