Commit 0f667074 by 杨树贤

导出脚本

parent f8bca94c
Showing with 18 additions and 4 deletions
......@@ -1426,7 +1426,9 @@ class DataService
'supplier_code',
'supplier_id',
'channel_uid',
'yunxin_channel_uid'
'yunxin_channel_uid',
'create_uid',
'create_name',
])->where('is_type', 0)->whereIn('supplier_code', $supplierCodeList)
->whereRaw('supplier_name NOT LIKE "%-1"')->get()->toArray();
$excelData = [];
......@@ -1434,17 +1436,28 @@ class DataService
'供应商名称',
'最大金额采购员',
'sku采购员',
'采购员',
'创建人',
];
$intraCodeModel = new IntracodeModel();
$users = $intraCodeModel->getSampleName(true);
foreach ($suppliers as $supplier) {
$skuUserName = $skuUserNameRaw = $purchasePurchaseName = '';
$purchaseNames = $skuUserName = $skuUserNameRaw = $purchasePurchaseName = '';
if ($supplier['yunxin_channel_uid']) {
$skuUserNameRaw = array_get($users, $supplier['yunxin_channel_uid']);
$skuUserName = $skuUserNameRaw;
}
if ($supplier['create_name']) {
$createName = $supplier['create_name'];
}else if ($supplier['create_uid']) {
$createUser = (new AdminUserService())->getAdminUserInfo($supplier['create_uid']);
$createName = array_get($createUser, 'name','');
}
if ($supplier['channel_uid']) {
$purchaseCodeIdList = explode(',', $supplier['channel_uid']);
$users = (new AdminUserService())->getAdminUserListByCodeIds($purchaseCodeIdList);
$purchaseNames = array_column($users,'name');
$purchaseNames = implode(',',$purchaseNames);
$channelUids = IntracodeModel::whereIn('code_id', $purchaseCodeIdList)->pluck('admin_id')->toArray();
//去采购系统找最多金额的用户id
$purchaseAmountMap = [];
......@@ -1471,7 +1484,7 @@ class DataService
arsort($purchaseAmountMap);
if (array_values($purchaseAmountMap)[0] == 0) {
$purchasePurchaseName = '';
}else{
} else {
$maxAmountPurchaseAdminId = array_keys($purchaseAmountMap)[0];
$codeId = IntracodeModel::where('admin_id', $maxAmountPurchaseAdminId)->value('code_id');
if ($codeId) {
......@@ -1491,11 +1504,12 @@ class DataService
$supplier['supplier_name'],
$purchasePurchaseName,
$skuUserName,
$purchaseNames,
$createName,
];
$excelData[] = $itemData;
}
array_unshift($excelData, $header);
dd($excelData);
Excel::create('供应商导出', function ($excel) use ($excelData) {
$excel->sheet('sheet1', function ($sheet) use ($excelData) {
$sheet->fromArray($excelData);
......
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