Commit 35973847 by 杨树贤

重名供应商导出

parent 839e74cd
......@@ -635,21 +635,33 @@ class DataService
public static function exportNameInvalid()
{
$suppliers = DB::connection('web')->select('SELECT *, count(*) FROM lie_supplier_channel WHERE is_type=0 and group_code != "" GROUP BY supplier_name having count(*) > 1');
foreach ($suppliers as $supplier) {
}
$supplierNameList = array_column($suppliers, 'supplier_name');
$suppliers = SupplierChannelModel::whereIn('supplier_name', $supplierNameList)->orderBy('supplier_name', 'desc')->get()->toArray();
$transformer = new SupplierTransformer();
$suppliers = $transformer->transformList($suppliers);
Excel::create('重名供应商导出', function ($excel) use ($suppliers) {
$header = [
'供应商名字',
'供应商编码',
'集团编码',
'供应商名字',
'状态',
'供应商性质',
'采购员',
'线上采购员',
'最新上传SKU时间',
];
$excelData = [];
foreach ($suppliers as $supplier) {
$excelData[] = [
$supplier['supplier_name'],
$supplier['supplier_code'],
$supplier['group_code'],
$supplier['status_name'],
$supplier['supplier_group'],
$supplier['channel_username'],
$supplier['yunxin_channel_username'],
$supplier['last_upload_sku_time'],
];
}
array_unshift($excelData, $header);
......@@ -657,7 +669,7 @@ class DataService
$sheet->fromArray($excelData);
});
})->export('csv');
})->export('xlsx');
}
public static function getSpuAttrs()
......@@ -679,10 +691,10 @@ class DataService
continue;
}
$skuId = trim(trim($item[1]),"\t");
$oldSkuName = trim(trim($item[2],"\t"));
$newSkuName = trim(trim($item[3],"\t"));
dump($skuId,$oldSkuName,$newSkuName);
$skuId = trim(trim($item[1]), "\t");
$oldSkuName = trim(trim($item[2], "\t"));
$newSkuName = trim(trim($item[3], "\t"));
dump($skuId, $oldSkuName, $newSkuName);
//直接去修改sku的sku_name
$dbInfo = getSpuSkuDb($skuId);
......@@ -700,5 +712,4 @@ class DataService
}
}
......@@ -84,6 +84,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
\App\Http\Services\DataService::exportNameInvalid();
//$goodsId = request()->input('goods_id');
//if (empty($goodsId)) {
// return 'goods id null';
......
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