Commit e5ce16e7 by 杨树贤

修改导出方式

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