Commit 83b6b826 by 杨树贤

导出特定供应商

parent 431d41b4
...@@ -1157,4 +1157,37 @@ class DataService ...@@ -1157,4 +1157,37 @@ class DataService
echo json_encode($supplierList); echo json_encode($supplierList);
} }
//获取上传了平台合作协议的供应商
public function exportHasCooperationAgreementSupplierList()
{
$header = [
'供应商编码',
'供应商名称',
'供应商性质',
'sku采购员',
'组别',
];
$intraCodeModel = new IntracodeModel();
$users = $intraCodeModel->getSampleName(true);
$excelData = [];
$attachments = SupplierAttachmentsModel::where('field_name', 'cooperation_agreement')->groupBy('supplier_id')->get()->toArray();
foreach ($attachments as $attachment) {
$supplier = SupplierChannelModel::where('supplier_id', $attachment['supplier_id'])->first()->toArray();
$skuUserNameRaw = array_get($users, $supplier['yunxin_channel_uid']);
$departmentName = (new DepartmentService())->getDepartmentNameByUserName($skuUserNameRaw);
$excelData[] = [
$supplier['supplier_code'],
$supplier['supplier_name'],
array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置'),
$departmentName
];
}
array_unshift($excelData, $header);
Excel::create('上传了“平台合作协议”的供应商', function ($excel) use ($excelData) {
$excel->sheet('sheet1', function ($sheet) use ($excelData) {
$sheet->fromArray($excelData);
});
})->export('csv');
}
} }
\ No newline at end of file
...@@ -67,7 +67,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -67,7 +67,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->getOffShelfSupplierList(); (new \App\Http\Services\DataService())->exportHasCooperationAgreementSupplierList();
// \App\Model\SupplierChannelModel::where('supplier_name', '深圳市金开盛电子有限公司')->update([ // \App\Model\SupplierChannelModel::where('supplier_name', '深圳市金开盛电子有限公司')->update([
// 'status' => 2, // 'status' => 2,
// 'update_time' => time(), // 'update_time' => time(),
......
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