|
@@ -0,0 +1,89 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Admin\Exports\Content;
|
|
|
+
|
|
|
+use App\Admin\Exports\ViewExport;
|
|
|
+use App\Models\TalentHouse;
|
|
|
+use App\Models\TalentHouseApply;
|
|
|
+use Illuminate\Contracts\View\View;
|
|
|
+use Illuminate\Support\Collection;
|
|
|
+
|
|
|
+class HouseBlacklistExport extends ViewExport
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 设置文件名
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getFilename(): string
|
|
|
+ {
|
|
|
+ return "house_black_list.xlsx";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 渲染对应的视图
|
|
|
+ * @param Collection $data 导出的数据
|
|
|
+ * @return View
|
|
|
+ */
|
|
|
+ public function getView(Collection $data): View
|
|
|
+ {
|
|
|
+ //获取用户id
|
|
|
+ $user_ids = [];
|
|
|
+ foreach ($data as $v) {
|
|
|
+ $user_ids[] = $v['user_id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取用户信息
|
|
|
+ $apply = TalentHouseApply::whereIn('user_id', $user_ids)->where('status', 2)->get()->toArray();
|
|
|
+ $apply_list = [];
|
|
|
+ $house_ids = [];
|
|
|
+ foreach ($apply as $v) {
|
|
|
+ $house_ids[] = $v['house_id'];
|
|
|
+ $apply_list[$v['user_id']][] = $v;
|
|
|
+ }
|
|
|
+ //获取项目信息
|
|
|
+ $house = TalentHouse::whereIn('id', array_unique($house_ids))->get()->toArray();
|
|
|
+ $house_list = [];
|
|
|
+ foreach ($house as $v) {
|
|
|
+ $house_list[$v['id']] = $v['name'];
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理数据
|
|
|
+ $no = 1;
|
|
|
+ $res = [];
|
|
|
+ foreach ($data as $v) {
|
|
|
+ if (empty($apply_list[$v['user_id']])) {
|
|
|
+ //用户未报名
|
|
|
+ $res[] = [
|
|
|
+ 'no' => $no,
|
|
|
+ 'name' => $v['realname'],
|
|
|
+ 'id_card' => $v['id_card'],
|
|
|
+ 'talent_level' => '',
|
|
|
+ 'comment' => $v['comment'],
|
|
|
+ 'house_name' => '',
|
|
|
+ 'end_time' => $v['end_time'],
|
|
|
+ 'company' => '',
|
|
|
+ 'talent_card_validity' => '',
|
|
|
+ ];
|
|
|
+ $no++;
|
|
|
+ } else {
|
|
|
+ //用户已报名
|
|
|
+ foreach ($apply_list[$v['user_id']] as $item) {
|
|
|
+ $res[] = [
|
|
|
+ 'no' => $no,
|
|
|
+ 'name' => $v['realname'],
|
|
|
+ 'id_card' => $v['id_card'],
|
|
|
+ 'talent_level' => $item['talent_level'],
|
|
|
+ 'comment' => $v['comment'],
|
|
|
+ 'house_name' => $house_list[$item['house_id']],
|
|
|
+ 'end_time' => $v['end_time'],
|
|
|
+ 'company' => $item['company'],
|
|
|
+ 'talent_card_validity' => $item['talent_card_validity'],
|
|
|
+ ];
|
|
|
+ $no++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return view('admin.content.export_house_blacklist', ['data' => $res]);
|
|
|
+ }
|
|
|
+}
|