Commit e5ce16e7 by 杨树贤

修改导出方式

parent f257d8b6
Showing with 34 additions and 16 deletions
...@@ -488,7 +488,8 @@ class DataService ...@@ -488,7 +488,8 @@ class DataService
$users = $intraCodeModel->getSampleName(true); $users = $intraCodeModel->getSampleName(true);
foreach ($suppliers as $supplier) { foreach ($suppliers as $supplier) {
$mainBrands = (new SupplierTransformer())->getMainBrandNames($supplier['main_brands']); $mainBrands = (new SupplierTransformer())->getMainBrandNames($supplier['main_brands']);
$attachmentsField = SupplierAttachmentsModel::where('supplier_id', $supplier['supplier_id'])->pluck('field_name')->toArray(); $attachmentsField = SupplierAttachmentsModel::where('supplier_id',
$supplier['supplier_id'])->pluck('field_name')->toArray();
$hasPinzhi = $hasHezuo = '否'; $hasPinzhi = $hasHezuo = '否';
if (in_array('quality_assurance_agreement', $attachmentsField)) { if (in_array('quality_assurance_agreement', $attachmentsField)) {
$hasPinzhi = '是'; $hasPinzhi = '是';
...@@ -498,7 +499,7 @@ class DataService ...@@ -498,7 +499,7 @@ class DataService
} }
$isYunxin = '否'; $isYunxin = '否';
if ($supplier['stockup_type']) { if ($supplier['stockup_type']) {
if (strpos($supplier['stockup_type'],"5") !== false) { if (strpos($supplier['stockup_type'], "5") !== false) {
dump("是云芯"); dump("是云芯");
$isYunxin = '是'; $isYunxin = '是';
} }
...@@ -507,18 +508,19 @@ class DataService ...@@ -507,18 +508,19 @@ class DataService
$skuUserName = $skuUserNameRaw = ''; $skuUserName = $skuUserNameRaw = '';
if ($supplier['yunxin_channel_uid']) { if ($supplier['yunxin_channel_uid']) {
$skuUserNameRaw = array_get($users, $supplier['yunxin_channel_uid']); $skuUserNameRaw = array_get($users, $supplier['yunxin_channel_uid']);
$skuUserName = $skuUserNameRaw.'(供应商系统设置)'; $skuUserName = $skuUserNameRaw . '(供应商系统设置)';
}else{ } else {
//去采购系统找最多单的用户id //去采购系统找最多单的用户id
$mostPurchaseOrderUser = PurchaseOrderModel::selectRaw('purchase_uid,supplier_id,COUNT(*) AS purchase_order_num') $mostPurchaseOrderUser = PurchaseOrderModel::selectRaw('purchase_uid,supplier_id,COUNT(*) AS purchase_order_num')
->where('supplier_id',$supplier['supplier_id']) ->where('supplier_id', $supplier['supplier_id'])
->groupBy('purchase_uid')->orderBy('purchase_order_num','DESC')->first(); ->groupBy('purchase_uid')->orderBy('purchase_order_num', 'DESC')->first();
if (!empty($mostPurchaseOrderUser)) { if (!empty($mostPurchaseOrderUser)) {
$mostPurchaseOrderUser = $mostPurchaseOrderUser->toArray(); $mostPurchaseOrderUser = $mostPurchaseOrderUser->toArray();
$codeId = IntracodeModel::where('admin_id',$mostPurchaseOrderUser['purchase_uid'])->value('code_id'); $codeId = IntracodeModel::where('admin_id',
$mostPurchaseOrderUser['purchase_uid'])->value('code_id');
if ($codeId) { if ($codeId) {
$skuUserNameRaw = array_get($users, $codeId); $skuUserNameRaw = array_get($users, $codeId);
$skuUserName = $skuUserNameRaw.'(采购系统下单最多)'; $skuUserName = $skuUserNameRaw . '(采购系统下单最多)';
} }
} }
} }
...@@ -866,7 +868,7 @@ class DataService ...@@ -866,7 +868,7 @@ class DataService
if ($topDepartmentId == 72) { if ($topDepartmentId == 72) {
$append = '联营二部'; $append = '联营二部';
} }
Excel::create('采购供应商数据导出_'.$append, function ($excel) use ($topDepartmentId) { Excel::create('采购供应商数据导出_' . $append, function ($excel) use ($topDepartmentId) {
$departmentIds = DepartmentModel::where('parent_id', $topDepartmentId)->pluck('department_id')->toArray(); $departmentIds = DepartmentModel::where('parent_id', $topDepartmentId)->pluck('department_id')->toArray();
$userIds = UserInfoModel::whereIn('department_id', $departmentIds)->pluck('userId')->toArray(); $userIds = UserInfoModel::whereIn('department_id', $departmentIds)->pluck('userId')->toArray();
$suppliers2022 = $suppliersZhangQi2022 = $suppliersAll = $suppliersZhangQi = []; $suppliers2022 = $suppliersZhangQi2022 = $suppliersAll = $suppliersZhangQi = [];
...@@ -876,7 +878,7 @@ class DataService ...@@ -876,7 +878,7 @@ class DataService
foreach ($suppliersAll as $supplier) { foreach ($suppliersAll as $supplier) {
$createTime = date('Y-m-d H:i:s', $supplier['create_time']); $createTime = date('Y-m-d H:i:s', $supplier['create_time']);
$creatName = UserInfoModel::where('userId', $supplier['create_uid'])->value('name'); $creatName = UserInfoModel::where('userId', $supplier['create_uid'])->value('name');
$supplierGroup = array_get(config('fixed.SupplierGroup'),$supplier['supplier_group']); $supplierGroup = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group']);
$data = [ $data = [
$creatName, $creatName,
$supplier['supplier_name'], $supplier['supplier_name'],
...@@ -895,7 +897,7 @@ class DataService ...@@ -895,7 +897,7 @@ class DataService
} }
$suppliersAllList[] = $data; $suppliersAllList[] = $data;
} }
$header = ['创建人', '供应商名称','供应商性质', '创建时间']; $header = ['创建人', '供应商名称', '供应商性质', '创建时间'];
// dd($suppliersZhangQi,$header); // dd($suppliersZhangQi,$header);
// $excel->sheet('2022年创建的供应商', function ($sheet) use ($header, $suppliers2022) { // $excel->sheet('2022年创建的供应商', function ($sheet) use ($header, $suppliers2022) {
// array_unshift($suppliers2022, $header); // array_unshift($suppliers2022, $header);
...@@ -934,22 +936,38 @@ class DataService ...@@ -934,22 +936,38 @@ class DataService
'创建时间', '创建时间',
'首次上传sku时间', '首次上传sku时间',
]; ];
$users = (new IntracodeModel())->getSampleEncode(true);
$map = [ $map = [
'source_type' => 'all', 'source_type' => 'all',
'uploaded_sku' => 1, 'uploaded_sku' => 1,
'is_export' => 1, 'is_export' => 1,
'is_type' => 0, 'is_type' => 0,
]; ];
$suppliers = (new SupplierService())->getSupplierList($map); $suppliers = SupplierChannelModel::where('uploaded_sku', 1)->where('is_type',
$transformer = new SupplierTransformer(); 0)->whereRaw('supplier_name NOT LIKE "%-1"')->get()->toArray();
$suppliers = $transformer->transformList($suppliers); //获取最近修改信息
$logModel = new LogModel();
$firstUploadSkuTimes = SkuService::getUploadTimeBySupplierCodes(array_column($suppliers, 'supplier_code'),
'first');
foreach ($suppliers as $supplier) { foreach ($suppliers as $supplier) {
$log = $logModel->where('supplier_id', $supplier['supplier_id'])
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
$supplier['last_update_name'] = $log['admin_name'] ?: '无';
if (empty($supplier['create_name'])) {
$userInfo = (new AdminUserService())->getAdminUserInfo($supplier['create_uid']);
$supplier['create_name'] = array_get($userInfo, 'name');
}
$supplier['create_time'] = $supplier['create_time'] ? date('Y-m-d H:i:s', $supplier['create_time']) : '';
$supplier['first_upload_sku_time'] = array_get($firstUploadSkuTimes,
$supplier['supplier_code']) ? date('Y-m-d H:i:s',
$firstUploadSkuTimes[$supplier['supplier_code']]) : '';
$supplier['supplier_group'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置');
$itemData = [ $itemData = [
$supplier['supplier_code'], $supplier['supplier_code'],
$supplier['supplier_name'], $supplier['supplier_name'],
$supplier['supplier_group'], $supplier['supplier_group'],
$supplier['channel_username'], (new SupplierTransformer())->getChannelUserNames($supplier['channel_uid']),
$supplier['yunxin_channel_username'], array_get($users, $supplier['yunxin_channel_uid']),
$supplier['last_update_name'], $supplier['last_update_name'],
$supplier['create_name'], $supplier['create_name'],
$supplier['create_time'], $supplier['create_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