Commit b384ad5f by 杨树贤

导出采购员脚本

parent 8f4aaeda
......@@ -35,6 +35,11 @@ class AdminUserService
return $codeId;
}
public function getAdminIdByUserName($userName)
{
return UserInfoModel::where('name', $userName)->value('userId');
}
public function getCodeIdsByUserIds($userIds)
{
$intraCodeModel = new IntracodeModel();
......
......@@ -764,7 +764,7 @@ class DataService
'supplier_type' => SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY
]);
}
}else {
} else {
if ($isUpdate) {
SupplierChannelModel::where('supplier_id', $supplier['supplier_id'])->update([
'level' => '',
......@@ -773,5 +773,38 @@ class DataService
}
}
}
//导出某个人创建的供应商在采购系统里面是哪个采购做了单
public function exportSupplierChannelUser($createName)
{
$adminId = (new AdminUserService())->getAdminIdByUserName($createName);
$contacts = SupplierContactModel::where('admin_id', $adminId)->get()->toArray();
$csvData = [];
foreach ($contacts as $contact) {
$supplier = SupplierChannelModel::where('supplier_id', $contact['supplier_id'])
->first();
if (empty($supplier)) {
continue;
}
$supplier = $supplier->toArray();
$canCheckChannelUser = (new AdminUserService())->getAdminUserInfoByCodeId($contact['can_check_uids']);
$csvData[] = [
$supplier['supplier_code'],
$supplier['supplier_name'],
$canCheckChannelUser['name'],
];
}
$header = [
'供应商编码',
'供应商名称',
'采购员名字',
];
array_unshift($csvData, $header);
Excel::create('供应商采购员导出', function ($excel) use ($csvData) {
$excel->sheet('sheet1', function ($sheet) use ($csvData) {
$sheet->fromArray($csvData);
});
})->export('csv');
}
}
......@@ -62,5 +62,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->repairLevelESupplierData(false);
(new \App\Http\Services\DataService())->exportSupplierChannelUser('admin');
});
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