Commit 6f934c51 by 杨树贤

导出供应商

parent c96286cd
...@@ -491,4 +491,87 @@ class DataService ...@@ -491,4 +491,87 @@ class DataService
} }
function exportSupplier()
{
$keywords = [
'One Capital Place',
'18 Luard Rd',
'18 Luard Road',
'海德中心',
'卢押道',
'盧押道',
'Bright Way Tower',
'33 Mong Kok Road',
'33 Mong Kok Rd',
'凯途发展大厦',
'旺角道33号',
'凱途發展大廈',
'Lockhart Rd',
'Lockhart Road',
'Lockhart Centre',
'骆克道',
'駱克道',
'Room 803',
'Chevalier House',
'Chatham Road South',
'漆咸道南45',
'漆咸道南45',
'2-16 Fa Yuen Street',
'King Commercial Centre',
'花园街',
'花園街',
'Fayuen',
'Fa Yuen Street',
'Ho King Commercial',
'好景商业中心',
'好景商業中心',
'610 Nathan Rd',
'Hollywood Plaza',
'弥敦道610号',
'彌敦道610號',
'610 Nathan Road',
'荷李活商业中心',
'荷李活商業中心',
];
$suppliers = [];
foreach ($keywords as $keyword) {
$supplierList = SupplierChannelModel::where('supplier_address', 'like', "%{$keyword}%")->select([
'supplier_name',
'phone',
'supplier_address',
])->get()->toArray();
if ($supplierList) {
$supplierList = array_map(function ($supplier) use ($keyword) {
$supplier['keyword'] = $keyword;
return $supplier;
}, $supplierList);
$suppliers = array_merge($suppliers, $supplierList);
}
}
Excel::create('供应商导出', function ($excel) use ($suppliers) {
$header = [
'供应商名字',
'联系方式',
'命中地址',
'命中关键词',
];
$excelData = [];
foreach ($suppliers as $supplier) {
$excelData[] = [
$supplier['supplier_name'],
$supplier['phone'],
$supplier['supplier_address'],
$supplier['keyword'],
];
}
array_unshift($excelData, $header);
$excel->sheet('sheet1', function ($sheet) use ($excelData) {
$sheet->fromArray($excelData);
});
})->export('xlsx');
}
} }
...@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\SyncSupplierService())->syncSupplierToErp(12469); (new \App\Http\Services\DataService())->exportSupplier();
}); });
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