Commit 934ad8ed by 杨树贤

测试导出

parent 54ef12e0
......@@ -18,6 +18,7 @@ use App\Model\StandardBrandModel;
use App\Model\SupplierAccountModel;
use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Model\UserInfoModel;
use Carbon\Carbon;
use GuzzleHttp\Client;
......@@ -442,7 +443,8 @@ class DataService
}
function syncDaigouSuppliersToErp(){
function syncDaigouSuppliersToErp()
{
$supplierIdList = SupplierChannelModel::whereIn('supplier_name', config('field.SkipChangeSupplierTypeNames'))->pluck('supplier_id')->toArray();
foreach ($supplierIdList as $supplierId) {
......@@ -450,4 +452,43 @@ class DataService
}
}
function exportContact()
{
$contacts = SupplierContactModel::where('can_check_uids', '10096')->get()->toArray();
Excel::create('供应商导出', function ($excel) use ($contacts) {
$header = [
'供应商编码',
'供应商名字',
'联系人',
'联系邮箱',
'联系手机',
'座机',
'职位',
'采购员',
];
$excelData = [];
foreach ($contacts as $contact) {
$supplierId = $contact['supplier_id'];
$supplier = SupplierChannelModel::select(['supplier_id', 'supplier_code', 'supplier_name'])->where('supplier_id', $supplierId)
->first()->toArray();
$excelData[] = [
$supplier['supplier_code'],
$supplier['supplier_name'],
$contact['supplier_consignee'],
$contact['supplier_email'],
$contact['supplier_mobile'],
$contact['supplier_telephone'],
$contact['supplier_position'],
"陈欢",
];
}
array_unshift($excelData, $header);
$excel->sheet('sheet1', function ($sheet) use ($excelData) {
$sheet->fromArray($excelData);
});
})->export('xlsx');
}
}
......@@ -82,9 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
//(new \App\Http\Services\StatisticsSkuUploadService())->statisticBrandSkuNum();
//(new \App\Http\Services\DataService())->exportSupplierDataForLevel();
\App\Model\SupplierChannelModel::where('supplier_code', 'L0016240')->update([
'supplier_name' => 'RUID (HONG KONG) ELECTRONICS CO., LIMITED'
]);
(new \App\Http\Services\DataService())->exportContact();
});
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