Commit 4e9cfcf8 by mushishixian

fix

parent 7ad79a80
......@@ -31,6 +31,6 @@ class SetSupplierFollowUp extends Command
public function handle()
{
$service = new DataService();
$service->importSupplierLevel();
$service->importMainBrandData();
}
}
......@@ -8,6 +8,7 @@ use App\Http\Transformers\SupplierTransformer;
use App\Model\IntracodeModel;
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\StandardBrandModel;
use App\Model\SupplierAttachmentModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
......@@ -297,8 +298,6 @@ class DataService
{
$filePath = public_path('data') . DIRECTORY_SEPARATOR . 'supplier_level.xls';
try {
// $excelData = Excel::load($filePath)->getSheet(0)->toArray();
// dd($excelData);
Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) {
$supplierChannelModel = new SupplierChannelModel();
$reader->sheet('供应商清单', function ($sheet) use ($reader, $supplierChannelModel) {
......@@ -331,7 +330,45 @@ class DataService
} catch (\Exception $exception) {
var_dump($exception);
}
}
//导入主营品牌数据
public function importMainBrandData()
{
$filePath = public_path('data') . DIRECTORY_SEPARATOR . 'supplier_main_brand.xlsx';
try {
Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) {
$reader->sheet('产出', function () use ($reader) {
$supplierMainBrandData = [];
$standardBrandModel = new StandardBrandModel();
foreach ($reader->all()->toArray() as $key => $item) {
$supplierName = trim($item[0]);
$brandName = $item[1];
$brandId = $standardBrandModel->where('brand_name',
trim($brandName))->value('standard_brand_id');
if (empty($brandId)) {
continue;
}
if (!isset($supplierMainBrandData[$supplierName])) {
$supplierMainBrandData[$supplierName][] = $brandId;
} else {
$supplierMainBrandData[$supplierName][] = $brandId;
}
}
$supplierModel = new SupplierChannelModel();
foreach ($supplierMainBrandData as $supplierName => $mainBrandIds) {
$result = $supplierModel->where('supplier_name', $supplierName)->update([
'main_brands' => implode(',', $mainBrandIds),
]);
if ($result) {
var_dump('更新供应商主营品牌成功,供应商 : '.$supplierName);
}
}
});
});
} catch (\Exception $exception) {
var_dump($exception);
}
}
}
......
......@@ -46,7 +46,7 @@ Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService();
// $service->pushSupplierSKu();
// $service->makeSupplierSystemTag();
$service->importSupplierLevel();
$service->importMainBrandData();
// $service->transferFileData();
// $service->changeSupplierIsTypeByCheckChannelUidOrPurchaseUid();
// $service->replaceStandardBrandId();
......
......@@ -82,7 +82,7 @@ return [
7 => '原厂直供',
2 => '猎芯仓库',
4 => '现货寄售',
5 => '猎芯期货',
5 => '云芯商家',
],
'SupplierPayType' => [
......
No preview for this file type
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 sign in to comment