Commit ecf9a879 by 杨树贤

导出代码

parent 5cdd493c
......@@ -12,6 +12,8 @@ use App\Model\StandardBrandModel;
use App\Model\SupplierAttachmentModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Model\UserDepartmentModel;
use App\Model\UserInfoModel;
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\Log;
......@@ -446,6 +448,80 @@ class DataService
var_dump($exception);
}
}
//导出无效联系人的供应商(采购员离职)
public function exportInvalidContactSupplier()
{
//直接去联系人循环遍历,去判断
$contactList = SupplierContactModel::select(['supplier_id', 'can_check_uids'])->get();
$exportData = [];
foreach ($contactList as $contact) {
//获取到的can_check_uids是内部编码,根据这个联表去查出是否离职
$adminUserService = new AdminUserService();
$isResigned = $adminUserService->checkIsResignedByCodeId($contact['can_check_uids']);
//如果是离职的,构建需要导出的数据
if (!$isResigned) {
continue;
}
$supplier = SupplierChannelModel::where('supplier_id', $contact['supplier_id'])
->where('is_type', 0)->whereIn('status', [
SupplierChannelModel::STATUS_NEED_REVIEW,
SupplierChannelModel::STATUS_PENDING,
SupplierChannelModel::STATUS_IN_REVIEW,
SupplierChannelModel::STATUS_PASSED,
])->select([
'supplier_name',
'supplier_code',
'status',
])->first();
if (empty($supplier)) {
continue;
}
$supplier = $supplier->toArray();
$channelUser = $adminUserService->getAdminUserInfoByCodeId($contact['can_check_uids']);
$departmentId = $channelUser['department_id'];
//通过部门id找出上级部门的id,然后通过这个去user_info找一个人出来就行,这个人就是部长了
$parentDepartmentId = UserDepartmentModel::where('department_id', $departmentId)->value('parent_id');
if (empty($parentDepartmentId)) {
//主管名字
$parentDepartmentUserInfo = UserInfoModel::where('department_id',
$departmentId)->select(['department_name', 'name'])->first()
->toArray();
} else {
$parentDepartmentUserInfo = UserInfoModel::where('department_id',
$parentDepartmentId)->select(['department_name', 'name'])->first()
->toArray();
}
$parentDepartmentUserName = $parentDepartmentUserInfo['name'];
$parentDepartmentName = $parentDepartmentUserInfo['department_name'];
$channelUserName = array_get($channelUser, 'name', ' ');
$data = [
$supplier['supplier_name'],
$supplier['supplier_code'],
array_get(config('fixed.SupplierStatus'), $supplier['status'], '未知状态'),
$channelUserName,
$parentDepartmentUserName,
$parentDepartmentName,
];
$exportData[] = $data;
}
Excel::create('invalidContactSupplier', function ($excel) use ($exportData) {
$excel->sheet('Sheetname', function ($sheet) use ($exportData) {
array_unshift($exportData, [
'供应商名称',
'供应商编码',
'状态',
'采购员姓名',
'采购组',
'主管姓名',
]);
$sheet->setAutoSize(true);
$sheet->fromArray($exportData);
});
})->download('xlsx');
}
}
......@@ -46,8 +46,9 @@ Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService();
// $service->pushSupplierSKu();
// $service->makeSupplierSystemTag();
$service->importSupplierLevel();
// $service->importSupplierLevel();
// $service->transferFileData();
$service->exportInvalidContactSupplier();
// $service->changeSupplierIsTypeByCheckChannelUidOrPurchaseUid();
// $service->replaceStandardBrandId();
});
File mode changed
File mode changed
No preview for this file type
File mode changed
File mode changed
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