Commit df506d22 authored by hangjun83's avatar hangjun83

乐妍

parent 36bc976e
......@@ -151,4 +151,15 @@ class BhuaProductRepositoryEloquent extends BaseRepository implements BhuaProduc
}
return null;
}
public function getProductCasByBidToGroupByCas($bId)
{
$productsModel = BhuaProducts::query()->select('chemicals.c_cas');
$productsModel = $productsModel->join('chemicals','chemicals.c_id','products.c_id');
$product = $productsModel->where('products.b_id',$bId)->groupBy('chemicals.c_cas')->get();
if($product){
return $product->toArray();
}
return null;
}
}
......@@ -13,6 +13,7 @@ namespace App\Rhawn\Services;
use App\Rhawn\Repositories\Contracts\RhawnProductRepository;
use App\Rhawn\Repositories\Eloquent\BhuaBrandsRepositoryEloquent;
use App\Rhawn\Repositories\Eloquent\BhuaProductRepositoryEloquent;
use App\Rhawn\Repositories\Eloquent\RhawnCustomerRepositoryEloquent;
use App\Rhawn\Repositories\Eloquent\RhawnRawRepositoryEloquent;
use App\Support\Facades\SimpleLogs;
......@@ -23,6 +24,7 @@ class BhuaProductService
public function __construct()
{
$this->brandsRepository = app(BhuaBrandsRepositoryEloquent::class);
$this->productRepository = app(BhuaProductRepositoryEloquent::class);
}
/**
......@@ -40,4 +42,9 @@ class BhuaProductService
}
return null;
}
public function getProductCasByBidToGroupByCas($bId)
{
$this->productRepository->getProductCasByBidToGroupByCas($bId);
}
}
......@@ -12,6 +12,7 @@
namespace App\Services\ThirdPlatform;
use App\Repositories\Contracts\ThirdApiPlatformRepository;
use App\Rhawn\Services\BhuaProductService;
use App\Services\ThirdPlatform\Api\LeyanApiService;
use App\Support\Facades\SimpleLogs;
use App\Support\Traits\Helpers;
......@@ -26,22 +27,7 @@ class LeyanService
public function batchUpdateProducts($params = null)
{
$path = config('filesystems.disks.local.root').'/upload/'.$params;
$generator = Helpers::yieldLoadCsv($path);
// yield 循环逐行读取csv内容
while ($generator->valid()) {
$content = $generator->current();
$this->apiService->pushQueue([
'params' => ['cas' => current($content)],
'consumer' => __CLASS__,
'method' => 'batchUpdateApi'
],'bjs');
$generator->next();
}
//$generator->rewind();
app(BhuaProductService::class)->getProductCasByBidToGroupByCas(108);
}
public function updateProductByCas($params)
......@@ -53,7 +39,7 @@ class LeyanService
try{
$result = $this->storeLeyanProducts($result);
}catch(\Exception $exception){
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':batchUpdateApi', 'error');
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':updateProductByCas', 'error');
}
}
......
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