root 4 жил өмнө
commit
ddc4156424
100 өөрчлөгдсөн 32801 нэмэгдсэн , 0 устгасан
  1. 47 0
      app/Admin/Controllers/Admin/AuthController.php
  2. 299 0
      app/Admin/Controllers/Admin/PermissionController.php
  3. 203 0
      app/Admin/Controllers/Admin/RoleController.php
  4. 47 0
      app/Admin/Controllers/AixSchedulingController.php
  5. 157 0
      app/Admin/Controllers/Company/AjaxController.php
  6. 226 0
      app/Admin/Controllers/Company/BusienssIncrementController.php
  7. 1437 0
      app/Admin/Controllers/Company/CompanyController.php
  8. 163 0
      app/Admin/Controllers/Company/CompanyDownResumeController.php
  9. 351 0
      app/Admin/Controllers/Company/CompanyImgController.php
  10. 161 0
      app/Admin/Controllers/Company/CompanyInterViewController.php
  11. 437 0
      app/Admin/Controllers/Company/CompanySetController.php
  12. 282 0
      app/Admin/Controllers/Company/CompanyTemplateController.php
  13. 161 0
      app/Admin/Controllers/Company/CompanyTplController.php
  14. 440 0
      app/Admin/Controllers/Company/ConsultantController.php
  15. 267 0
      app/Admin/Controllers/Company/HomeTemplateController.php
  16. 143 0
      app/Admin/Controllers/Company/InvoiceCategoryController.php
  17. 377 0
      app/Admin/Controllers/Company/InvoiceController.php
  18. 972 0
      app/Admin/Controllers/Company/JobsController.php
  19. 223 0
      app/Admin/Controllers/Company/MembersPointController.php
  20. 360 0
      app/Admin/Controllers/Company/MembersSetmealController.php
  21. 317 0
      app/Admin/Controllers/Company/OrderController.php
  22. 246 0
      app/Admin/Controllers/Company/PersonTemplateController.php
  23. 155 0
      app/Admin/Controllers/Company/PersonalJobsApplyController.php
  24. 312 0
      app/Admin/Controllers/Company/PromotionController.php
  25. 1 0
      app/Admin/Controllers/Company/README.md
  26. 252 0
      app/Admin/Controllers/Company/SetmealController.php
  27. 195 0
      app/Admin/Controllers/Company/SetmealIncrementController.php
  28. 257 0
      app/Admin/Controllers/Company/TaskController.php
  29. 119 0
      app/Admin/Controllers/ConfigController.php
  30. 462 0
      app/Admin/Controllers/Content/AdCategoryController.php
  31. 1060 0
      app/Admin/Controllers/Content/AdController.php
  32. 352 0
      app/Admin/Controllers/Content/AppealController.php
  33. 300 0
      app/Admin/Controllers/Content/ArticleCategoryController.php
  34. 564 0
      app/Admin/Controllers/Content/ArticleController.php
  35. 190 0
      app/Admin/Controllers/Content/ArticlePropertyController.php
  36. 230 0
      app/Admin/Controllers/Content/ComplaintAdviserController.php
  37. 190 0
      app/Admin/Controllers/Content/ExplainCategoryController.php
  38. 418 0
      app/Admin/Controllers/Content/ExplainController.php
  39. 345 0
      app/Admin/Controllers/Content/FeatureController.php
  40. 223 0
      app/Admin/Controllers/Content/FeatureSortController.php
  41. 301 0
      app/Admin/Controllers/Content/FeedbackController.php
  42. 227 0
      app/Admin/Controllers/Content/HelpCategoryController.php
  43. 257 0
      app/Admin/Controllers/Content/HelpController.php
  44. 208 0
      app/Admin/Controllers/Content/HrtoolsCategoryController.php
  45. 322 0
      app/Admin/Controllers/Content/HrtoolsController.php
  46. 143 0
      app/Admin/Controllers/Content/InnovatorCategoryController.php
  47. 200 0
      app/Admin/Controllers/Content/LinkCategoryController.php
  48. 434 0
      app/Admin/Controllers/Content/LinkControllser.php
  49. 199 0
      app/Admin/Controllers/Content/NoticeCategoryController.php
  50. 409 0
      app/Admin/Controllers/Content/NoticeController.php
  51. 218 0
      app/Admin/Controllers/Content/PolicyCategoryController.php
  52. 354 0
      app/Admin/Controllers/Content/PolicyController.php
  53. 147 0
      app/Admin/Controllers/Content/PolicyPropertyController.php
  54. 1 0
      app/Admin/Controllers/Content/README.md
  55. 140 0
      app/Admin/Controllers/Content/RcstfwltController.php
  56. 301 0
      app/Admin/Controllers/Content/RecuperateApplyController.php
  57. 100 0
      app/Admin/Controllers/Content/RecuperateCategoryController.php
  58. 339 0
      app/Admin/Controllers/Content/RecuperateController.php
  59. 93 0
      app/Admin/Controllers/Content/RecuperateLogController.php
  60. 134 0
      app/Admin/Controllers/Content/RecuperateTimeController.php
  61. 460 0
      app/Admin/Controllers/Content/ReportController.php
  62. 595 0
      app/Admin/Controllers/Content/SysMessageController.php
  63. 181 0
      app/Admin/Controllers/Content/TreatController.php
  64. 292 0
      app/Admin/Controllers/Content/innovatorController.php
  65. 124 0
      app/Admin/Controllers/ExampleController.php
  66. 197 0
      app/Admin/Controllers/FindJobsController.php
  67. 317 0
      app/Admin/Controllers/HomeController.php
  68. 215 0
      app/Admin/Controllers/Jobfair/FloorplanController.php
  69. 329 0
      app/Admin/Controllers/Jobfair/JobfairBlacklistController.php
  70. 810 0
      app/Admin/Controllers/Jobfair/JobfairCompanyController.php
  71. 1110 0
      app/Admin/Controllers/Jobfair/JobfairController.php
  72. 239 0
      app/Admin/Controllers/Jobfair/JobfairDishonestyController.php
  73. 879 0
      app/Admin/Controllers/Jobfair/JobfairJobController.php
  74. 195 0
      app/Admin/Controllers/Jobfair/JobfairManagementController.php
  75. 94 0
      app/Admin/Controllers/Jobfair/JobfairPersonSignedsController.php
  76. 396 0
      app/Admin/Controllers/Jobfair/JobfairPutJobsController.php
  77. 803 0
      app/Admin/Controllers/Jobfairout/JobfairJobController.php
  78. 576 0
      app/Admin/Controllers/Jobfairout/JobfairoutCompanyController.php
  79. 690 0
      app/Admin/Controllers/Jobfairout/JobfairoutController.php
  80. 394 0
      app/Admin/Controllers/Jobfairout/JobfairoutPutJobsController.php
  81. 186 0
      app/Admin/Controllers/Jobfairout/JobfairoutSchoolController.php
  82. 202 0
      app/Admin/Controllers/Lottery/PrizeController.php
  83. 90 0
      app/Admin/Controllers/Lottery/WinController.php
  84. 150 0
      app/Admin/Controllers/Person/HrBindController.php
  85. 198 0
      app/Admin/Controllers/Person/JobSubscribeController.php
  86. 525 0
      app/Admin/Controllers/Person/JobsApplyController.php
  87. 1010 0
      app/Admin/Controllers/Person/MemberController.php
  88. 158 0
      app/Admin/Controllers/Person/MembersProjectController.php
  89. 327 0
      app/Admin/Controllers/Person/PersonInterviewController.php
  90. 263 0
      app/Admin/Controllers/Person/PersonalPointsController.php
  91. 254 0
      app/Admin/Controllers/Person/PersonalServiceStickController.php
  92. 296 0
      app/Admin/Controllers/Person/PersonalServiceStickLogController.php
  93. 198 0
      app/Admin/Controllers/Person/PersonalServiceTagController.php
  94. 290 0
      app/Admin/Controllers/Person/PersonalServiceTagLogController.php
  95. 1 0
      app/Admin/Controllers/Person/README.md
  96. 839 0
      app/Admin/Controllers/Person/ResumeController.php
  97. 305 0
      app/Admin/Controllers/Person/ResumeImgController.php
  98. 430 0
      app/Admin/Controllers/Person/ResumePhotoController.php
  99. 538 0
      app/Admin/Controllers/PersonalTalents/PersonalTalentsController.php
  100. 177 0
      app/Admin/Controllers/PersonalTalents/PersonalTalentsLogController.php

+ 47 - 0
app/Admin/Controllers/Admin/AuthController.php

@@ -0,0 +1,47 @@
+<?php
+namespace App\Admin\Controllers\Admin;
+
+use Illuminate\Routing\Controller;
+use Illuminate\Support\Facades\Auth;
+
+class AuthController extends Controller
+{
+    /**
+     * Show the login page.
+     *
+     * @return \Illuminate\Contracts\View\Factory|Redirect|\Illuminate\View\View
+     */
+    public function getLogin()
+    {
+        if ($this->guard()->check()) {
+            return redirect($this->redirectPath());
+        }
+
+        return view('admin.login');
+    }
+
+    /**
+     * Get the post login redirect path.
+     *
+     * @return string
+     */
+    protected function redirectPath()
+    {
+        if (method_exists($this, 'redirectTo')) {
+            return $this->redirectTo();
+        }
+
+        return property_exists($this, 'redirectTo') ? $this->redirectTo : config('admin.route.prefix');
+    }
+
+
+    /**
+     * Get the guard to be used during authentication.
+     *
+     * @return \Illuminate\Contracts\Auth\StatefulGuard
+     */
+    protected function guard()
+    {
+        return Auth::guard('admin');
+    }
+}

+ 299 - 0
app/Admin/Controllers/Admin/PermissionController.php

@@ -0,0 +1,299 @@
+<?php
+
+namespace App\Admin\Controllers\Admin;
+
+use App\Models\Admin\AdminMenu;
+use App\Models\Admin\AdminPermission;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Layout\Row;
+use Encore\Admin\Show;
+use Encore\Admin\Tree;
+use Illuminate\Routing\Controller;
+use Illuminate\Support\Str;
+
+class PermissionController extends Controller
+{
+    use HasResourceActions;
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     *
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+//        return $content
+//        ->header(trans('admin.menu'))
+//        ->description(trans('admin.list'))
+//        ->row(function (Row $row) {
+//            $row->column(6, $this->treeView()->render());
+//
+//        });
+        if (request()->has('_expand_')) {
+            $permission=AdminPermission::find(request()->get('_expand_'));
+            if (!$permission || $permission->children->isEmpty()) {
+                $data['has_children'] =0;
+                return response()->json($data);
+            }
+            $data['has_children'] =1;
+            $data['html']=view(
+                'admin.grid.permission_expand',
+                [
+                    'parent_group'=>implode(" ", explode(",", request()->get('parent_group'))),
+                    'key'=>request()->get('_expand_'),
+                    'list'=>$permission->children,
+                    'level'=>request()->get('level')+1,
+                    'menu_array'=>AdminMenu::menuArr()
+                ]
+            )->render();
+            return response()->json($data);
+        }
+        return $content
+            ->header(trans('admin.permissions'))
+            ->description(trans('admin.list'))
+            ->body($this->grid()->render());
+    }
+
+    /**
+     * @return \Encore\Admin\Tree
+     */
+    protected function treeView()
+    {
+
+        return AdminPermission::tree(function (Tree $tree) {
+            $tree->disableCreate();
+            $menu_array=AdminMenu::menuArr();
+            $tree->branch(function ($branch) use ($menu_array) {
+                $payload = "&nbsp;<strong>{$branch['name']}</strong>------{$branch['slug']}";
+                if (isset($menu_array[$branch['menu_id']])) {
+                    $payload.="------<code>{$menu_array[$branch['menu_id']]}</code>";
+                }
+                return $payload;
+            });
+        });
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed   $id
+     * @param Content $content
+     *
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header(trans('admin.permissions'))
+            ->description(trans('admin.detail'))
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param $id
+     * @param Content $content
+     *
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header(trans('admin.permissions'))
+            ->description(trans('admin.edit'))
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     *
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header(trans('admin.permissions'))
+            ->description(trans('admin.create'))
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new AdminPermission());
+        $grid->model()->where('parent_id', 0);
+        $grid->model()->orderBy('listorder');
+        if (Admin::user()->isAdministrator()) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->actions(function (Grid\Displayers\Actions $actions) {
+            if (Admin::user()->isAdministrator()) {
+                $actions->disableDelete(false);
+                $actions->disableEdit(false);
+            }
+        });
+
+//        $grid->tools(function (Grid\Tools $tools) {
+//            $tools->batch(function (Grid\Tools\BatchActions $batch) {
+//                if (Admin::user()->isAdministrator()) {
+//                    $batch->disableDelete(false);
+//                }
+//            });
+//        });
+
+        // 添加默认查询条件
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereIn('subsite_id', [-1, get_subsite_id()]);
+        })->where('parent_id', 0);
+        $grid->model()->orderBy('listorder');
+        $grid->filter(function (Grid\Filter $filter) {
+            // 在这里添加字段过滤器
+            $filter->like('name', '名称');
+            $filter->like('slug', '标识');
+        });
+
+        $grid->id('ID')->sortable()->fixedWidth(80);
+
+        $grid->name(trans('admin.name'))->fixedWidth(250)->ajaxExpand();
+        $grid->slug(trans('admin.slug'))->fixedWidth(330)->label();
+
+        $grid->menu("菜单")->display(function ($menu) {
+            if (isset($menu)) {
+                return "<div style='margin-bottom: 5px;'><code>{$menu['title']}</code></div>";
+            }
+            return "";
+        })->fixedWidth(250);
+        if (get_subsite_open()) {
+            $subsite_array = Subsite::pluck('sitename', 'id')->toArray();
+            $subsite_array=[0 => '总站'] + $subsite_array;
+            $grid->subsite_id("权限所属")->display(function ($subsite_id) use ($subsite_array) {
+                if ($subsite_id == -1) {
+                    return "通用权限";
+                }
+
+                if (isset($subsite_array[$subsite_id])) {
+                    return $subsite_array[$subsite_id];
+                }
+                return "";
+            })->fixedWidth(80)->label('primary');
+        }
+
+        return $grid;
+    }
+
+
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $menu_array=AdminMenu::menuArr();
+        $show = new Show(AdminPermission::findOrFail($id));
+
+        $show->id('ID');
+        $show->name(trans('admin.name'));
+        $show->slug(trans('admin.slug'));
+        if (get_subsite_open()) {
+            $option_array=[-1 => '通用权限'];
+            $option_array=$option_array + array_column(get_all_subsite(), 'sitename', 'id');
+            $show->subsite_id("权限所属")->as(function ($subsite_id) use ($option_array) {
+                return $option_array[$subsite_id];
+            })->label('primary');
+        }
+
+        $show->http_path(trans('admin.route'))->unescape()->as(function ($path) {
+            return collect(explode("\r\n", $path))->map(function ($path) {
+                if (!$path) {
+                    return "";
+                }
+                $method = $this->http_method ?: ['ANY'];
+
+                if (Str::contains($path, ':')) {
+                    list($method, $path) = explode(':', $path);
+                    $method = explode(',', $method);
+                }
+
+                $method = collect($method)->map(function ($name) {
+                    return strtoupper($name);
+                })->map(function ($name) {
+                    return "<span class='label label-primary'>{$name}</span>";
+                })->implode('&nbsp;');
+
+                if (!empty(config('admin.route.prefix'))) {
+                    $path = '/'.trim(config('admin.route.prefix'), '/').$path;
+                }
+
+                return "<div style='margin-bottom: 5px;'>$method<code>$path</code></div>";
+            })->implode('');
+        });
+
+        $show->menuIds("菜单")->unescape()->as(function ($menus) use ($menu_array) {
+            return collect($menus)->map(function ($menu) use ($menu_array) {
+                return "<div style='margin-bottom: 5px;'><code>{$menu_array[$menu['menu_id']]}</code></div>";
+            })->implode("");
+        });
+        return $show;
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    public function form()
+    {
+        $form = new Form(new AdminPermission());
+        $form->text('name', trans('admin.name'))->rules('required');
+        $form->text('slug', trans('admin.slug'))->rules('required');
+        if (get_subsite_open()) {
+            $option_array=[-1 => '通用权限'];
+            $option_array=$option_array + array_column(get_all_subsite(), 'sitename', 'id');
+            $form->radio('subsite_id', '权限所属')->options($option_array)->default(-1);
+        }
+        $menu_array = [0 => '无'];
+        $menu_array=$menu_array+AdminMenu::menuArr();
+        $form->select('menu_id', '菜单')->options($menu_array);
+
+        $permission_array = [0 => '顶级'];
+        $permission_array=$permission_array+AdminPermission::permissionArr();
+        $form->select('parent_id', "父级")->options($permission_array);
+
+        $form->number('listorder', "排序")->min(0)->default(0);
+        $form->multipleSelect('http_method', trans('admin.http.method'))
+            ->options($this->getHttpMethodsOptions())
+            ->help(trans('admin.all_methods_if_empty'));
+        $form->textarea('http_path', trans('admin.http.path'));
+        return $form;
+    }
+
+    /**
+     * Get options of HTTP methods select field.
+     *
+     * @return array
+     */
+    protected function getHttpMethodsOptions()
+    {
+        $permissionModel = config('admin.database.permissions_model');
+
+        return array_combine($permissionModel::$httpMethods, $permissionModel::$httpMethods);
+    }
+}

+ 203 - 0
app/Admin/Controllers/Admin/RoleController.php

@@ -0,0 +1,203 @@
+<?php
+
+namespace App\Admin\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\Admin\AdminPermission;
+use App\Models\Admin\AdminRole;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class RoleController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('角色')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('角色')
+            ->description('详细')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('角色')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('角色')
+            ->description('创建')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new AdminRole());
+
+        if (Admin::user()->isAdministrator()) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->actions(function (Grid\Displayers\Actions $actions) {
+            if (Admin::user()->isAdministrator()) {
+                $actions->disableDelete(false);
+                $actions->disableEdit(false);
+            }
+        });
+
+//        $grid->tools(function (Grid\Tools $tools) {
+//            $tools->batch(function (Grid\Tools\BatchActions $batch) {
+//                if (Admin::user()->isAdministrator()) {
+//                    $batch->disableDelete(false);
+//                }
+//            });
+//        });
+
+        // 添加默认查询条件
+        $grid->model()->when(get_subsite_id() > 0, function ($query) {
+            $query->whereIn('subsite_id', [-1, get_subsite_id()]);
+        });
+        $grid->model()->orderBy('is_admin', 'desc');
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            // 在这里添加字段过滤器
+            $filter->like('name', '名称');
+        });
+
+        $grid->id('ID')->sortable();
+        $grid->name('名称')->width(250);
+        $grid->slug('标识')->width(250);
+        if (get_subsite_open()) {
+            $subsite_array = Subsite::pluck('sitename', 'id')->toArray();
+            $subsite_array=[0 => '总站'] + $subsite_array;
+            $grid->subsite_id("角色所属")->display(function ($subsite_id) use ($subsite_array) {
+                if ($subsite_id == -1) {
+                    return "通用角色";
+                }
+
+                if (isset($subsite_array[$subsite_id])) {
+                    return $subsite_array[$subsite_id];
+                }
+                return "";
+            })->label('primary');
+        }
+        $permission_array=AdminPermission::permissionArr();
+        $grid->permissions('权限')->display(function ($permissions) use ($permission_array) {
+            $str = collect($permissions)->take(5)->map(function ($permission) use ($permission_array) {
+                return "<div style='margin-bottom: 5px;'><span class='label label-success'>{$permission_array[$permission['id']]}</span></div>";
+            })->implode("");
+            if (count($permissions) > 5) {
+                $str = $str . "<div style='margin-bottom: 5px;'><span class='label label-success'>...</span></div>";
+            }
+            return $str;
+        });
+        $grid->actions(function (Grid\Displayers\Actions $actions) {
+            if ($actions->row->is_admin == 1) {
+                $actions->disableEdit();
+                $actions->disableDelete();
+            }
+        });
+        $grid->created_at('添加时间');
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(AdminRole::findOrFail($id));
+
+        $show->id('ID');
+        $show->name(trans('admin.name'));
+        $show->slug('标识');
+        $show->permissions('权限')->unescape()->as(function ($permissions) {
+            $str = collect($permissions)->map(function ($permission) {
+                return "<div style='margin-bottom: 5px;'><span class='label label-success'>{$permission['name']}</span></div>";
+            })->implode("");
+            return $str;
+        });
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new AdminRole());
+
+        if (str_contains(request()->getRequestUri(), 'edit')) {
+            $form->display('id', 'ID');
+        }
+        $form->text('name', '名称')->rules('required');
+        $form->text('slug', '标识')->rules('required');
+        if (get_subsite_open()) {
+            $option_array=[-1 => '通用角色'];
+            $option_array=$option_array + array_column(get_all_subsite(), 'sitename', 'id');
+            $form->radio('subsite_id', '角色所属')->options($option_array)->default(-1);
+        }
+        $form->listbox('permissions', '权限')->options(AdminPermission::permissionArr())->attribute('hight', '200px');
+        if (str_contains(request()->getRequestUri(), 'edit')) {
+            $form->display('created_at', '添加时间');
+        }
+        return $form;
+    }
+
+}

+ 47 - 0
app/Admin/Controllers/AixSchedulingController.php

@@ -0,0 +1,47 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: wuzhenke
+ * Date: 2019/2/13
+ * Time: 16:52
+ */
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Scheduling\Scheduling;
+use Illuminate\Http\Request;
+
+class AixSchedulingController
+{
+    public function index()
+    {
+        return Admin::content(function (Content $content) {
+            $content->header('Task scheduling');
+
+            $scheduling = new Scheduling();
+            $events = $scheduling->getTasks();
+            $content->body(view('admin.schedling.index', [
+                'events' => $events,
+            ]));
+        });
+    }
+
+    /**
+     * @param Request $request
+     *
+     * @return array
+     */
+    public function runEvent(Request $request)
+    {
+        $scheduling = new Scheduling();
+        $scheduling->runTask($request->get('id'));
+
+        return [
+            'status'    => true,
+            'message'   => 'success',
+            'data'      => '已提交至队列任务中',
+        ];
+    }
+}

+ 157 - 0
app/Admin/Controllers/Company/AjaxController.php

@@ -0,0 +1,157 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2018/10/17
+ * Time: 15:07
+ */
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Company;
+use App\Models\Jobs;
+use App\Models\Member;
+use App\Models\Pms;
+use App\Models\Resume;
+use App\Models\SmsRule;
+use App\Repositories\SmsTemplateRepository;
+use App\Services\Common\EmailService;
+use App\Services\Common\SmsService;
+use Encore\Admin\Facades\Admin;
+use Illuminate\Http\Request;
+
+class AjaxController extends Controller
+{
+    protected $smsService;
+    protected $smsTemplateRepository;
+    protected $emailService;
+
+    /**
+     * AjaxController constructor.
+     * @param $smsService
+     * @param $smsTemplateRepository
+     */
+    public function __construct(SmsService $smsService, SmsTemplateRepository $smsTemplateRepository, EmailService $emailService)
+    {
+        $this->smsService = $smsService;
+        $this->smsTemplateRepository = $smsTemplateRepository;
+        $this->emailService = $emailService;
+    }
+
+    public function getInfo(Request $request)
+    {
+        if ($request->utype == 1) {
+            $data['info'] = Company::findOrFail($request->id);
+            $data['utype'] =1;
+        } else {
+            $data['info'] = Member::findOrFail($request->id);
+            $data['utype'] = 2;
+        }
+        return view('admin.ajax.getInfo')->with('info', $data);
+    }
+
+    public function getPromotion(Request $request)
+    {
+        $where = [];
+        if ($request->id) {
+            $where[] =['id', '=', $request->id];
+        }
+        if ($request->jobs_name) {
+            $where[] =['jobs_name', 'like', "%$request->jobs_name%"];
+        }
+        if ($request->company_id) {
+            $where[] =['company_id', '=', $request->company_id];
+        }
+        if ($request->company_name) {
+            $where[] =['company_name', 'like', "%$request->company_name%"];
+        }
+        if ($where) {
+            $where['valid'] = 1;
+            $where['audit'] = 1;
+            $where['display'] = 1;
+            $where['subsite_id'] = get_subsite_id();
+            $data = Jobs::select('id', 'company_id', 'jobs_name', 'company_name', 'deadline', 'created_at', 'refresh_time')->where($where)->get();
+            if (!$data->isEmpty()) {
+                return  json_encode(['data'=>$data, 'code'=>1]);
+            }
+        }
+
+        return  json_encode(['msg'=>'<tr><td colspan="5">暂无数据</td></tr>', 'code'=>0]);
+    }
+    public function getResume(Request $request)
+    {
+        $where = [];
+        if ($request->id) {
+            $where[] =['id', '=', $request->id];
+        }
+        if ($request->fullname) {
+            $where[] =['fullname', 'like', "%$request->fullname%"];
+        }
+        if ($request->uid) {
+            $where[] =['uid', '=', $request->uid];
+        }
+        if ($where) {
+            $where[] = ['audit','=',2];
+            $where[] = ['subsite_id', '=',get_subsite_id()];
+            $data = Resume::select('id', 'uid', 'fullname', 'created_at', 'updated_at')->where($where)->get()->toArray();
+        }
+        if (!empty($data)) {
+            return json_encode(['data'=>$data, 'code'=>1]);
+        }
+        return json_encode(['msg'=>'<tr><td colspan="5">暂无数据</td></tr>', 'code'=>0]);
+    }
+
+    /**发送站内信
+     * @param Request $request
+     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     */
+    public function sendSys(Request $request)
+    {
+        $psm = new Pms();
+        $data = $request->except(['_token']);
+
+        $company = Company::where('id', $data['uid'])->first();
+        $psm->utype = 1;
+        $psm->msgtype = 1;
+        $psm->msgfromuid = Admin::user()->id;
+        $psm->msgfrom = Admin::user()->username;
+        $psm->msgtoname = $company->username;
+        $psm->msgtouid = $company->id;
+        $psm->message = $data['body'];
+        if ($psm->save()) {
+             admin_toastr('站内信发送成功', 'success');
+             return redirect(route("company.index"));
+        }
+        admin_toastr('站内信发送失败', 'error');
+        return back();
+    }
+
+    public function sendEmail(Request $request)
+    {
+        $email = $request->email;
+        $title = $request->title;
+        $body = $request->body;
+        $this->emailService->sendMail($email, EmailService::TEMPLATE_SEND_CONTENT, ['title'=>$title], ['content'=>$body]);
+            admin_toastr('邮件发送成功', 'success');
+            return back();
+    }
+
+    public function sendSms(Request $request)
+    {
+        $mobile = $request->mobile;
+        $body = $request->body;
+        $sms_id = $request->sms_id;
+//        $sms_alias = $this->smsTemplateRepository->findWhere(['id'=>$sms_id], ['alias']);
+
+        $SmsRule = SmsRule::where('alias', $sms_id)->first();
+        if (isset($SmsRule->status) && !empty($SmsRule->status)) {
+            $this->smsService->sendSms($mobile, $sms_id, ['content'=>$body]);
+            admin_toastr('短信发送成功', 'success');
+        } else {
+            admin_toastr('请先开启短信-短信规则配置!', 'error');
+        }
+        return back();
+    }
+
+}

+ 226 - 0
app/Admin/Controllers/Company/BusienssIncrementController.php

@@ -0,0 +1,226 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Order;
+use App\Models\Subsite;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class BusienssIncrementController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('增值服务')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('增值服务')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('增值服务')
+            ->description('修改')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('增值服务')
+            ->description('新增')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('increment_manager_index');
+        $grid = new Grid(new Order);
+        $grid->model()->where('utype', 1)->whereNotIn( 'order_type', [1,2])->when(get_subsite_id()>0, function ($querys) {
+            $querys->whereHas('companys', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        });
+        $grid->service_name('服务内容');
+        $grid->column('companys.companyname', '企业名称');
+        $grid->column('companys.username', '申请会员');
+        $grid->amount('金额');
+        $grid->created_at('申请时间');
+        $grid->filter(function ($filter) {
+                //在这里添加字段过滤器
+                $filter->equal('uid', '企业ID');
+                $filter->like('companys.username', '会员名称');
+            $subsite = Subsite::where('effective', 1)->select('id', 'sitename')->get();
+            $subsiteArr=[];
+            if ($subsite) {
+                $subsiteArr = $subsite->toArray();
+                $subsiteArr = array_column($subsiteArr, 'sitename', 'id');
+            }
+            $subsiteArr[0] = "总站";
+            ksort($subsiteArr);
+            if (get_subsite_id()== 0) {
+                $filter->equal('companys.subsite_id', '所属分站')->select($subsiteArr);
+            }
+                //$filter->like('companys.companyname','企业名称');
+                 $filter->equal('order_type', '订单类型')->select(
+                     [
+                                1=>'套餐升级',
+                                2=>'充值积分',
+                                3=>'简历置顶',
+                                4=>'醒目标签',
+                                5=>'简历模板',
+                                6=>'简历包',
+                                7=>'短信包',
+                                8=>'职位置顶',
+                                9=>'职位紧急',
+                                10=>'企业模板',
+                                11=>'职位刷新',
+                                12=>'简历下载'
+                     ]
+                 );
+                $filter->between('created_at', '注册时间')->datetime();
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));
+        $show->oid('订单ID');
+        $show->companys()->companyname('企业名称')->as(function ($companys) {
+            return $companys->companyname;
+        });
+        $show->is_pay()->as(function ($is_pay) {
+            switch ($is_pay) {
+                case 1:
+                    return "待付款";
+                    break;
+                case 2:
+                    return "已付款";
+                    break;
+                case 3:
+                    return "已取消";
+                    break;
+            }
+        });
+        $show->amount('订单金额');
+        $show->pay_amount('现金支付金额');
+        $show->pay_points('积分支付');
+        $show->service_name('订单描述');
+        $show->pay_type('订单金额')->as(function ($pay_type) {
+            switch ($pay_type) {
+                case 1:
+                    return '现金';
+                    break;
+                case 2:
+                    return '积分';
+                    break;
+                case 3:
+                    return '现金+积分';
+                    break;
+            }
+        });
+        $show->payment_time('支付时间')->as(function ($payment_time) {
+            if ($payment_time) {
+                return date('Y-m-d H:i:s', $payment_time);
+            }
+            return '';
+        });
+        $show->notes('备注');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Order);
+        $form->display('id');
+        $form->display('companys.username', '申请会员');
+        $form->radio('is_pay', '支付状态')->options([1=>'待付款',2=>'已付款',3=>'已取消']);
+        $form->display('amount', '订单金额');
+        $form->display('pay_amount', '现金支付金额');
+        $form->display('pay_points', '积分支付');
+        $form->display('service_name', '订单描述');
+        $form->display('pay_type', '支付方式')->with(function ($pay_type) {
+            switch ($pay_type) {
+                case 1:
+                    return '现金';
+                    break;
+                case 2:
+                    return '积分';
+                    break;
+                case 3:
+                    return '现金+积分';
+                    break;
+            }
+        });
+        $form->display('oid', '订单号');
+        $form->display('created_at', '申请时间');
+        $form->display('payment_time', '支付时间')->with(function ($payment_time) {
+            if ($payment_time) {
+                return date('Y-m-d H:i:s', $payment_time);
+            }
+            return '';
+        });
+        $form->text('notes', '添加备注');
+        return $form;
+    }
+}

+ 1437 - 0
app/Admin/Controllers/Company/CompanyController.php

@@ -0,0 +1,1437 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use Aix\Sms\Contracts\Smser;
+use App\Admin\Exports\Company\CompanyExport;
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Admin\Extensions\Tools\DialogTool;
+use App\Http\Controllers\Controller;
+use App\Models\Admin\AdminRole;
+use App\Models\AuditReason;
+use App\Models\Category;
+use App\Models\CategoryDistrict;
+use App\Models\Company;
+use App\Models\CompanyConsultant;
+use App\Models\CompanyImg;
+use App\Models\Consultant;
+use App\Models\Jobs;
+use App\Models\MembersChargeLog;
+use App\Models\MembersPoint;
+use App\Models\MembersSetmeal;
+use App\Models\Setmeal;
+use App\Models\Subsite;
+use App\Models\SubsiteJob;
+use App\Repositories\CompanyRepository;
+use App\Repositories\JobsContactRepository;
+use App\Repositories\JobsRepository;
+use App\Repositories\MemberPointRepository;
+use App\Repositories\MembersChargeLogRepository;
+use App\Repositories\MemberSetmealRepository;
+use App\Repositories\SubsiteJobRepository;
+use App\Repositories\SubsiteRepository;
+use App\Repositories\TplRepository;
+use App\Repositories\Jobfair\JobfairCompanyRepository;
+use App\Repositories\Jobfair\JobfairJobRepository;
+use App\Repositories\Jobfair\JobfairJobsContactRepository;
+use App\Repositories\Jobfair\JobfairPutJobRepository;
+use App\Services\Common\PmsService;
+use App\Services\Common\SmsService;
+use App\Services\Common\TaskService;
+use App\Services\Company\ServiceService;
+use App\Services\SubsiteService;
+use App\Validators\Rules\MobileRule;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Encore\Admin\Widgets\Table;
+use function foo\func;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Validation\Rule;
+use Illuminate\Support\Facades\Validator;
+
+
+class CompanyController extends Controller
+{
+    use HasResourceActions;
+
+    public $taskService;
+    public $companyRepository;
+    public $pmsService;
+    public $subsiteService;
+    public $jobsRepository;
+    public $subsiteJobRepository;
+    public $membersChargeLogRepository;
+    public $memberSetmealRepository;
+    public $jobsContactRepository;
+    public $memberPointRepository;
+    public $tplRepository;
+    public $jobfairCompanyRepository;
+    public $jobfairJobRepository;
+    public $jobfairJobsContactRepository;
+    public $jobfairPutJobRepository;
+    /**
+     * CompanyController constructor.
+     * @param $companyRepository
+     * @param $pmsService
+     * @param $subsiteService
+     * @param $jobsRepository
+     * @param $subsiteJobRepository
+     * @param $taskService
+     * @param $membersChargeLogRepository
+     * @param $memberSetmealRepository
+     * @param $jobsContactRepository
+     * @param $subsiteRepository
+     * @param $memberPointRepository
+     * @param $jobfairCompanyRepository
+     * @param $jobfairJobRepository
+     * @param $jobfairJobsContactRepository
+     * @param $jobfairPutJobRepository
+     * @param $smsService
+     * @param $tplRepository
+     */
+    public function __construct(
+        TaskService $taskService,
+        MemberPointRepository $memberPointRepository,
+        SmsService $smsService,
+        SubsiteRepository $subsiteRepository,
+        JobsContactRepository $jobsContactRepository,
+        MemberSetmealRepository $memberSetmealRepository,
+        MembersChargeLogRepository $membersChargeLogRepository,
+        JobsRepository $jobsRepository,
+        SubsiteJobRepository $subsiteJobRepository,
+        SubsiteService $subsiteService,
+        CompanyRepository $companyRepository,
+        PmsService $pmsService,
+        TplRepository $tplRepository,
+        JobfairCompanyRepository $jobfairCompanyRepository,
+        JobfairJobRepository $jobfairJobRepository,
+        JobfairJobsContactRepository $jobfairJobsContactRepository,
+        JobfairPutJobRepository $jobfairPutJobRepository
+    )
+    {
+        $this->taskService = $taskService;
+        $this->companyRepository = $companyRepository;
+        $this->pmsService = $pmsService;
+        $this->subsiteService = $subsiteService;
+        $this->jobsRepository = $jobsRepository;
+        $this->subsiteJobRepository = $subsiteJobRepository;
+        $this->membersChargeLogRepository = $membersChargeLogRepository;
+        $this->memberSetmealRepository = $memberSetmealRepository;
+        $this->jobsContactRepository = $jobsContactRepository;
+        $this->subsiteRepository = $subsiteRepository;
+        $this->smsService = $smsService;
+        $this->memberPointRepository = $memberPointRepository;
+        $this->tplRepository = $tplRepository;
+        $this->jobfairCompanyRepository = $jobfairCompanyRepository;
+        $this->jobfairJobRepository = $jobfairJobRepository;
+        $this->jobfairJobsContactRepository = $jobfairJobsContactRepository;
+        $this->jobfairPutJobRepository = $jobfairPutJobRepository;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        $grid=$this->grid()->render();
+        return $content
+            ->header('企业会员')
+            ->description('列表')
+            ->body(view('admin.company.index')->with('grid', $grid));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('企业会员')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('企业会员')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        Permission::check('company_manager_create');
+        return $content
+            ->header('企业会员')
+            ->description('新增')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Company);
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+        })->when(Admin::user()->isRole(AdminRole::$consultantSlug), function ($query) {
+            $query->whereHas('companyConsultant', function ($query) {
+                $query->where('consultant_id', isset(Admin::user()->consultant->id) ? Admin::user()->consultant->id : -1);
+            });
+            $query->whereHas("membersSetmeal", function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+
+
+        })->orderByRaw("field(audit,2,1,3,0)")->orderBy('id', 'desc');
+
+        $grid->id('ID');
+        $grid->companyname('公司名称')->display(function ($companyname) {
+            $html='';
+            if ($this->logo) {
+                $html.='<span style="padding-left:5px;color: #3c8dbc;" class="vtip" title="<img src=\''.upload_asset($this->logo).'\' width=120 height=120>"><i class="fa fa-file-image-o"></i></span>';
+            }
+            $html .= "<a href=". route(url_rewrite('AIX_companyshow'), ['id'=>$this->id])." target='_blank'>".$companyname."</a>";
+            return $html;
+        })->width(200);
+        $grid->certificate_img('营业执照')->display(function ($certificate_img) {
+            if ($certificate_img) {
+                return '<span style="padding-left:5px;color: #3c8dbc;" class="show-img"><img src=\''.upload_asset($certificate_img).'\' width=22 height=26></span>';
+            } else {
+                return "未上传";
+            }
+        });
+        $grid->audit('企业认证')->display(function ($audit) {
+            switch ($audit) {
+                case 1:
+                    return '<span style="color: green">认证通过<a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a></span>';
+                    break;
+                case 2:
+                    return '<span style="color: red">待认证</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+                    break;
+                case 3:
+                    return '<span style="color: black">认证未通过</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+                    break;
+                case 0:
+                    return '<span style="color: gray">未认证</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+                    break;
+            }
+        });
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+                if ($subsite_id == 0) {
+                    return "总站";
+                } else {
+                    $subsite = Subsite::findOrFail($subsite_id);
+                    return $subsite->sitename;
+                }
+            });
+        }
+    
+        $result = Consultant::get()->toArray();
+      
+        if($result){
+            $consultant =  Consultant::pluck('name','id')->toArray();
+            $grid->column('companyConsultant.consultant_id', '所属顾问')->display(function ($consultant_id) use($consultant) {
+                if (!isset($consultant_id)) {
+                    return "未分配";
+                }
+                return isset($consultant[$consultant_id]) ? $consultant[$consultant_id] : '未分配';
+            });
+        }
+
+        $grid->address('公司地址');
+        $grid->created_at('注册时间');
+        $grid->refresh_time('刷新时间')->display(function ($refresh_time) {
+            return date('Y-m-d H:i:s', $refresh_time);
+        });
+
+        $grid->column('membersSetmeal.endtime','到期时间')->display(function ($endtime){
+            return $endtime;
+        });
+
+
+        $grid->column('membersSetmeal.setmeal_name', '套餐名称')->display(function ($setmeal_name) {
+            if (!$setmeal_name) {
+                return "--";
+            } else {
+                $setmeal_name=$setmeal_name=="年度会员" ?  "年度会员vip" : $setmeal_name;
+                return $setmeal_name."<a class=\"setmealrecord\" data-id='{$this->id}'><i class=\"fa fa-eye\"></i></a>";
+            }
+        });
+
+
+        if (Admin::user()->can('company_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new CompanyExport()); //传入自己在第1步创建的导出类
+        }
+        $grid->filter(function ($filter) {
+            $filter->column(1/2, function ($filter) {
+                // 在这里添加字段过滤器
+                $filter->like('companyname', '企业名称');
+                $filter->equal('id', '企业ID');
+                $filter->like('username', '会员名称');
+                $filter->like('mobile', '手机');
+                $filter->like('address', '地址');
+
+                $filter->where(function ($query) {
+                    $member_day=$this->input;
+
+                    $query->whereHas('membersSetmeal', function ($query) use ($member_day) {
+                        if($member_day==-1){
+                            $query->whereRaw("members_setmeals.`endtime`<UNIX_TIMESTAMP(NOW())")
+                                ->where('utype','=','1')
+                                ->where('members_setmeals.endtime','!=','0');
+                        }else{
+                            $query->whereRaw("DATEDIFF(DATE_FORMAT(FROM_UNIXTIME(`members_setmeals`.`endtime`),'%Y-%m-%d'),NOW()) BETWEEN 0 AND  {$member_day}")
+                                ->where('expire','=','0')
+                                ->where('utype','=','1');
+                        }
+
+                    });
+
+                }, '套餐到期')->select(['3'=>"三天内",'7'=>'一周内','15'=>'半个月内','-1'=>'已经到期']);
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('membersSetmeal.setmeal_id', '套餐类型')->select(Setmeal::get()->pluck('setmeal_name', 'id'));
+                $filter->equal('audit', '企业认证')->select(['1' => '认证通过', '2' => '待认证', '3' => '认证未通过','0'=>"未认证"]);
+                $subsite = Subsite::where('effective', 1)->select('id', 'sitename')->get();
+                $subsiteArr=[];
+                if ($subsite) {
+                    $subsiteArr = $subsite->toArray();
+                    $subsiteArr = array_column($subsiteArr, 'sitename', 'id');
+                }
+                $subsiteArr[0] = "总站";
+                ksort($subsiteArr);
+                if (get_subsite_id()== 0 && get_subsite_open()) {
+                    $filter->equal('subsite_id', '所属分站')->select($subsiteArr);
+                }
+                $filter->like('email','邮箱');
+//                $filter->equal('certificate_img_audit', '营业执照认证')->select(['1' => '已认证', '2' => '待认证', '3' => '认证未通过', '0' => '未认证']);
+                $filter->between('created_at', '注册时间')->datetime();
+                $result = Consultant::get()->toArray();
+                if($result){
+                    if(get_subsite_id()==0){
+                        $arr_con = Consultant::pluck('name','id');
+                    }else{
+                        $arr_con = Consultant::where('subsite_id', get_subsite_id())->pluck('name','id');
+                    }
+                    $filter->equal('companyConsultant.consultant_id','顾问')->select($arr_con);
+                }
+            });
+        });
+        if (Admin::user()->can('company_manager_create')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('company_manager_bussiness')) {
+                $actions->append("<button class='btn btn-primary btn-xs business' id=".$actions->row['id'].">业务</button>");
+            }
+            if (Admin::user()->can('company_manager_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+            if (Admin::user()->can('company_manager_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('company_manager_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        $grid->tools(function (Grid\Tools $tools) {
+            $but = <<<EOT
+            <div class="btn-group" data-toggle="buttons">
+                <label class="btn btn-google btn-sm" id="update_password" title="重置密码">
+                    <i class="fa fa-audio-description"></i>
+                    <input type="radio" class="user-gender">重置密码
+                </label>
+            </div>
+EOT;
+            if (Admin::user()->can('company_reset_password')) {
+                $tools->append($but);
+            }
+            if (Admin::user()->can('company_manager_delete')) {
+                $tools->batch(function (Grid\Tools\BatchActions $batch) {
+                    $batch->disableDelete(false);
+                });
+            }
+
+            if (Admin::user()->can('company_manager_refresh')) {
+                $tools->append('<a class=\'btn btn-sm btn-primary btn-refresh\'><i class=\'fa fa-refresh\'></i>企业刷新排名</a>');
+            }
+
+            if (Admin::user()->can('company_manager_audit')) {
+                $form = new \Encore\Admin\Widgets\Form();
+                $form->action(route('company.audit'));
+
+                $form->radio('audit1', '审核状态')->options([1=>'审核通过', 3=>'审核未通过'])->default(1);
+                $states = [
+                    'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+                    'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+                ];
+
+                $form->textarea('reason', '备注');
+                $form->html("<input type='checkbox' name='is_send' checked value='1'/>站内信通知");
+                $config = array(
+                    'button' => "企业审核",//添加的按钮文字
+                    'title' => "将所选企业",//弹窗标题
+                    'dialog_cancel' => "取消",//取消文字
+                    'dialog_ok' => "确认",//确认文字
+                    'is_batch' => true//是否批量操作,如果是批量操作则提交表单时会带上ids参数
+                );
+                $tools->append(new DialogTool($form, $config));
+            }
+    
+            $consultant = <<<EOT
+            <div class="btn-group" data-toggle="buttons">
+                <label class="btn btn-google btn-sm" id="consultant" title="设置顾问">
+                    <i class="fa fa-audio-description"></i>
+                    <input type="radio" class="user-gender">设置顾问
+                </label>
+            </div>
+EOT;
+            $result = Consultant::get()->toArray();
+            if($result){
+                if (Admin::user()->can('company_manager_consultant')) {
+                    $tools->append($consultant);
+                }
+            }
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Company::findOrFail($id));
+        $show->id('ID');
+        $show->username('用户名');
+        $show->mobile('联系电话');
+        $show->landline_tel('固定电话')->as(function ($landline_tel) {
+            if ($landline_tel == '--' || $landline_tel == '---') {
+                return  '';
+            } else {
+                return $landline_tel;
+            }
+        });
+        $show->email('电子邮箱');
+        $show->contact('企业联系人');
+        $show->subsite_id('分站')->as(function ($subsite_id) {
+            if ($subsite_id == 0) {
+                return '总站';
+            } else {
+                $subsite_name = Subsite::findOrFail($subsite_id);
+                return $subsite_name->sitename;
+            }
+        });
+        $show->companyname('公司名称');
+        $show->short_name('公司简称');
+        $show->audit('审核状态')->as(function ($audit) {
+            switch ($audit) {
+                case 1:
+                    return '审核通过';
+                    break;
+                case 2:
+                    return '待审核';
+                    break;
+                case 3:
+                    return '审核未通过';
+                    break;
+            }
+        });
+        $show->nature('企业性质')->as(function ($nature) {
+            return get_category($nature);
+        });
+        $show->trade('企业行业')->as(function ($trade) {
+            return get_category($trade);
+        });
+        $show->district('所在地区')->as(function ($district) {
+            return get_district_cn($district);
+        });
+        $show->scale('企业规模')->as(function ($scale) {
+            return get_category($scale);
+        });
+        $show->registered('注册资金');
+        $show->currency('资金形式');
+        $show->tag('企业福利')->as(function ($tag) {
+            foreach ($tag as $key => $val) {
+                $tag_cn[] = get_tag_cn($val);
+            }
+            return implode('+', $tag_cn);
+        });
+
+        $show->website('企业网站');
+        $show->address('企业地址');
+        $show->contents('企业详情');
+        $show->logo('企业Logo')->image();
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function createForm()
+    {
+        Permission::check('company_manager_create');
+        $form = new ValidateForm(new Company);
+
+        $form->tab('用户信息', function ($form) {
+            $form->text('username', '用户名')->rules('required|between:6,31|regex:/^[a-zA-Z][a-zA-Z0-9]{5,16}+$/|unique:companys', [
+                'required' => '请填写会员名',
+                'between' => '会员名长度为6~30个字符',
+                'regex' => '会员名为字母或字母+数字',
+                'unique' => '会员名已存在'
+            ])->setWidth(3)->setMustMark();
+            $form->mobile('mobile', '手机号码')->rules('required|unique:companys', [
+                'required'=>'请填写手机号',
+                'unique'=>'手机号已经存在'
+            ])->setWidth(3)->setMustMark();
+            $form->radio('mobile_audit','手机认证')->options([1=>'认证通过',0=>'未认证'])->default(0);
+            $form->text('landline_tel', '固定号码')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)');
+            $form->text('email', 'email')->rules('required|regex:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/|unique:companys', [
+                'required' => 'email为必填信息',
+                'regex' => 'email格式不正确',
+                'unique' => 'email已存在'
+            ])->setWidth(3)->setMustMark();
+            $form->radio('email_audit','邮箱认证')->options([1=>'认证通过',0=>'未认证'])->default(0);
+            $form->text('contact', '企业联系人')->rules('required', [
+                'required'=>'请填写企业联系人'
+            ])->setWidth(3)->setMustMark();
+
+            $form->password('password', '密码')->rules('required|confirmed|between:6,16', [
+                'required' => '密码为必填信息',
+                'between' => '密码长度要求为6~16'
+            ])->setWidth(3)->setMustMark();
+
+            $form->password('password_confirmation', '确认密码')->rules('required|between:6,16')->setWidth(3)->default(function ($form) {
+                return $form->model()->password;
+            })->setMustMark();
+            $form->ignore('password_confirmation');
+
+            if ($this->subsiteService->getSiteId() == 0 && get_subsite_open()) {
+                $subsiteArr = $this->subsiteService->getAllSubsite();
+                $subData = array_column($subsiteArr, 'sitename', 'id');
+                $form->radio('subsite_id', '分站')->options($subData)->default($this->subsiteService->getSiteId());
+            }
+            $form->switch('user_status', '账号状态')->default(1);
+        })->tab('企业信息', function ($form) {
+
+            $form->text('companyname', '企业名称')->rules('required|unique:companys', ['required'=>'请填写企业名称','unique' => '企业名称已经存在'])->setWidth(3)->setMustMark();
+            $form->text('short_name', '企业简称')->rules(
+                [
+                    'required',
+                ],
+                [
+                    'required' => '企业简称必填',
+                ]
+            )->setWidth(3)->setMustMark()->attribute(['maxlength'=>25])->help('请填写25个字符以内');
+            $form->text('organization_code', '社会统一信用码')->rules(
+                [
+                    'required','unique:companys','alpha_num','between:15,18'
+                ],
+                [
+                    'required'=>'请填写企业社会统一信用码',
+                    'unique'=>'企业社会统一信用码已存在',
+                    'alpha_num'=>'企业社会统一信用码必须是字母或数字',
+                    'between'=>'企业社会统一信用码长度是15-18位',
+                ]
+            )->setWidth(3)->setMustMark();
+            //企业性质给定数组
+            $com_type = Category::categoryType('AIX_company_type');
+            $form->radio('nature', '企业性质')->options($com_type)->default(key($com_type))->setMustMark();
+            $form->select('trade', '所属行业')->options(Category::categoryType('AIX_trade'))->setWidth(3)->rules('required', ['required'=>'请选择相应的企业所属行业'])->setMustMark();
+            $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',  admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属省份'])->setMustMark();
+            $form->select('city', '所属城市')->setWidth(3)->load('area',  admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属城市'])->setMustMark();
+            //$form->select('area', '所属县区')->setWidth(3)->rules('required', ['required'=>'请选择相应的企业所属县区'])->setMustMark();
+            $form->select('scale', '公司规模')->options(Category::categoryType('AIX_scale'))->setWidth(3)->rules('required', ['required'=>'请选择相应的企业公司规模'])->setMustMark();
+            $form->number('registered', '注册资金')->setWidth(3)->min(0);
+            $form->radio('currency', '资金类型')->options(['万人民币' => '万人民币', '万美元' => '万美元'])->default('万人民币');
+            $form->multipleSelect('tag', '企业福利')->options(Category::categoryType('AIX_jobtag'));
+            $form->url('website', '公司网站')->setWidth(3);
+            $form->text('address', '公司地址')->setWidth(6);
+            $form->text('legal', '公司法人姓名')->setWidth(6);
+            $form->text('legal_idcard', '公司法人身份证')->setWidth(6);
+            $form->textarea('contents', '公司介绍')->rows(10)->attribute(['maxlength'=>2000])->setMustMark();
+        })->tab('证照信息', function ($form) {
+            $form->image('logo', '企业logo')->uniqueName()->setWidth(3);
+            $form->image('certificate_img', '营业执照')->setWidth(3);
+        })->tab('套餐信息', function ($form) {
+            $form->radio('regpoints', '赠送积分')->options([0=>'不赠送', 1=>'赠送' ])->default('0');
+            $form->number('points', '赠送数量')->min(0);
+            $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
+            $form->radio('setmeal_id', '会员套餐')->options($setmeal)->default(config('aix.companyset.setmeal_com.setmeal_com_set.reg_service'));
+            $form->switch('is_money', '是否收费');
+            $form->number('amount', '收费金额')->min(0);
+        });
+        return $form;
+    }
+
+    public function store(Request $request)
+    {
+        $data = $this->createForm()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
+        if($data['legal_idcard'] && !isCreditNo($data['legal_idcard'])){
+            admin_toastr('法人代表身份证格式不正确', 'error');
+            return back();
+        }
+        $res1= [];
+        $res = [];
+        $res2 = [];
+        foreach ($data as $key => $val) {
+            if ($key == 'regpoints') {
+                $res1['regpoints'] = $val;
+            } else if ($key == 'points') {
+                $res1['points'] = $val;
+            } else if ($key == 'setmeal_id') {
+                $res2['setmeal_id'] = $val;
+            } else if ($key == "is_money") {
+                $res2['is_money'] = $val;
+            } else if ($key == 'amount') {
+                $res2['amount'] = $val;
+            } else {
+                if ($key == 'password') {
+                    $res[$key] = bcrypt($val);
+                } else if ($key == 'tag') {
+                    $res[$key] =  $val;
+                } elseif ($key == 'province') {
+                    $res['district'] = $val;
+                } elseif ($key == 'city') {
+                    $res['district'] = $res['district'].".".$val;
+                } elseif ($key == 'area') {
+                    $res['district'] = $res['district'].".".$val;
+                } elseif ($key =='logo') {
+                    $res[$key] =  $val;
+                } elseif ($key == 'certificate_img') {
+                    $res[$key] =  'company/certificate/'.$val;
+                } else {
+                    $res[$key] = $val;
+                }
+            }
+        }
+        if (isset($res['certificate_img'])) {
+            $res['audit'] = 2;
+        }
+        $res['district_cn'] =get_district_cn($res['district']);
+        $res['subsite_id'] = $this->subsiteService->getSiteId();
+        DB::beginTransaction();
+        try {
+            $res['reg_time'] = time();
+            $res['refresh_time'] = time();
+            $res['reg_ip'] = ip2long($request->getClientIp());
+            $res['last_login_ip'] = ip2long($request->getClientIp());
+            $res['last_login_time'] = time();
+            $res['reg_address'] = getAddressByIp($request->getClientIp());
+            $res['setmeal_id'] = $res2['setmeal_id'];
+            $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
+            $res['setmeal_name'] = $setmeal[$res2['setmeal_id']];
+            $getDefaultTpl =$this->tplRepository->getDefaultTpl(['tpl_type'=>1,'display'=>1,'default'=>1]);
+            if($getDefaultTpl){
+                if($getDefaultTpl->blade_name){
+                    $res['tpl'] = $getDefaultTpl->blade_name;
+                }
+            }
+            if (!$uid = $this->companyRepository->create($res)) {
+                throw new \Exception('新增失败');
+            }
+            $role_id = $uid->id;
+            $taskdata = $this->taskService->doTask(17, $role_id, 1);
+            if ($res1['regpoints']) {
+                $pointData['uid'] = $role_id;
+                $pointData['utype'] = 1;
+                $pointData['points'] = $res1['points'];
+                if (!$ids = MembersPoint::insert($pointData)) {
+                    throw new \Exception('企业增加积分失败');
+                }
+            }
+
+            $set_data = Setmeal::select('id', 'setmeal_name', 'days', 'expense', 'jobs_meanwhile', 'jobfair_num', 'refresh_jobs_free', 'download_resume', 'download_resume_max', 'added', 'setmeal_img', 'show_apply_contact', 'is_free', 'discount_download_resume', 'discount_sms', 'discount_stick', 'discount_emergency', 'discount_tpl', 'discount_auto_refresh_jobs')->findOrFail($res2['setmeal_id'])->toArray();
+            $createData = $set_data;
+            $createData['uid'] = $role_id;
+            $createData['utype'] = 1;
+            $createData['setmeal_id'] = $set_data['id'];
+            $createData['starttime'] = time();
+            unset($createData['id']);
+            if (!MembersSetmeal::insert($createData)) {
+                throw new \Exception('企业增加套餐失败');
+            }
+            $amount = 0;
+            if ($res2['is_money']) {
+                $amount = $res2['amount'];
+            }
+
+            $logData['log_uid'] = $role_id;
+            $logData['log_utype'] = 1;
+            $logData['log_username'] = $res['username'];
+            $logData['log_value'] = "操作人:".Admin::user()->username.",说明:创建会员:{$res['username']},(+{$taskdata['data']['points']})积分,收到{$amount}元。";
+            $logData['log_amount'] = $amount;
+            $logData['log_ismoney'] = $res2['is_money'];
+            $logData['log_type'] = 2;
+            $logData['log_mode'] = 1;
+            $logData['created_at'] = date('Y-m-d H:i:s', time());
+            $logData['updated_at'] = date('Y-m-d H:i:s', time());
+            if (!$this->membersChargeLogRepository->create($logData)) {
+                throw new \Exception('企业增加记录失败');
+            }
+            $this->smsService->sendSms($res['mobile'], Smser::TEMPLATE_SMS_QUICK_REGISTER, ['username'=>$data['username'],'password'=>$data['password']]);
+            DB::commit();
+             admin_toastr('企业新增成功', 'success');
+
+        } catch (\Exception $e) {
+            DB::rollback();
+             admin_toastr($e->getMessage(), 'error');
+        }
+        return redirect(route("company.index"));
+    }
+
+    protected function editForm($id)
+    {
+        Permission::check('company_manager_edit');
+        $form = new ValidateForm(new Company);
+        $form->display('id')->setWidth(3);
+        $district = $this->companyRepository->find($id)->toArray();
+        if ($district) {
+            $districtArr = string_to_array('.', $district['district']);
+        }
+
+        $form->tab('用户信息', function ($form) use ($id,$district) {
+            $form->text('username', '用户名')
+                ->rules(
+                    [
+                        'required',
+                        'between:6,31|regex:/^[a-zA-Z][a-zA-Z0-9]{5,16}+$/',
+                        Rule::unique('companys')->ignore($id),
+                    ],
+                    [
+                        'required' => '会员名为必填信息',
+                        'between' => '会员名长度为6~30个字符',
+                        'regex' => '会员名为字母或字母+数字',
+                        'unique' => '会员名已存在'
+                    ]
+                )->setWidth(3)->setMustMark();
+            $form->mobile('mobile', '手机号码')->help('手机、固话二选一')->setWidth(3);
+            $form->radio('mobile_audit','手机认证')->options([1=>'认证通过',0=>'未认证'])->default($district['mobile_audit']);
+            $form->text('landline_tel', '固定号码')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)');
+            $form->email('email', 'email')
+                ->rules(
+                    [
+                        'required',
+                        'regex:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
+                        Rule::unique('companys')->ignore($id),
+                    ],
+                    [
+                        'required' => 'email为必填信息',
+                        'regex' => 'email格式不正确',
+                        'unique' => 'email已存在',
+                    ]
+                )->setWidth(3);
+            $form->radio('email_audit','邮箱认证')->options([1=>'认证通过',0=>'未认证'])->default($district['email_audit']);
+            $form->text('contact', '企业联系人')->setWidth(3)->setMustMark();
+            if ($this->subsiteService->getSiteId() == 0 && get_subsite_open()) {
+                $subsiteArr = $this->subsiteService->getAllSubsite();
+                $subData = array_column($subsiteArr, 'sitename', 'id');
+                $form->radio('subsite_id', '分站')->options($subData);
+            }
+            $form->switch('user_status', '账号状态');
+        })->tab('企业信息', function ($form) use ($id, $districtArr) {
+            if (config('aix.companyset.comset.other_set.company_repeat') == 1) {
+                $form->text('companyname', '企业名称')->rules(
+                    [
+                        'required',
+                    ],
+                    [
+                        'required' => '企业名称必填',
+                    ]
+                )->setWidth(3)->setMustMark();
+            } else {
+                $form->text('companyname', '企业名称')->rules(
+                    [
+                        'required',
+                        Rule::unique('companys')->ignore($id),
+                    ],
+                    [
+                        'required' => '企业名称必填',
+                        'unique' => '公司名已经存在',
+                    ]
+                )->setWidth(3)->setMustMark();
+            }
+
+            $form->text('short_name', '企业简称')->rules(
+                [
+                    'required',
+                ],
+                [
+                    'required' => '企业简称必填',
+                ]
+            )->setWidth(3)->setMustMark()->attribute(['maxlength'=>25])->help('请填写25个字符以内');
+            $form->text('organization_code', '社会统一信用码')->setWidth(3)->rules(
+                [
+                    'required',
+                    Rule::unique('companys')->ignore($id),
+                    'alpha_num','between:15,18'
+                ],
+                [
+                    'required' => '请填写社会统一信用码',
+                    'unique' => '社会统一信用码已经存在',
+                    'alpha_num'=>'企业社会统一信用码必须是字母或数字',
+                    'between'=>'企业社会统一信用码长度是15-18位',
+                ]
+            )->setMustMark();
+            //企业性质给定数组
+            $nature = Category::categoryType('AIX_company_type');
+            $form->radio('nature', '企业性质')->options($nature)->default(key($nature))->rules(['required'], ['required'=>'请选择相应的企业性质'])->setMustMark();
+            $form->select('trade', '所属行业')->options(Category::categoryType('AIX_trade'))->setWidth(3)->rules('required', ['required'=>'请选择相应的企业所属行业'])->setMustMark();
+            //单位性质
+//            $unit_character = Category::categoryType('AIX_company_type');
+//            $form->select('unit_character', '单位性质')->options($unit_character)->setWidth(3)->rules('required', ['required'=>'请选择相应的单位性质'])->setMustMark();
+//            //产业类别
+//            $industry = Category::categoryType('AIX_cylb');
+//            $form->select('industry', '产业类别')->options($industry)->setWidth(3)->rules('required', ['required'=>'请选择相应的产业类别'])->setMustMark();
+//            //经济类型
+//            $economy = Category::categoryType('AIX_jjlx');
+//            $form->select('economy', '经济类型')->options($economy)->setWidth(3)->rules('required', ['required'=>'请选择相应的经济类型'])->setMustMark();
+
+            if (!empty($districtArr)) {
+                $form->select('province', '所属省份')->default(isset($districtArr[0])?$districtArr[0]:0)->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',  admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属省份'])->setMustMark();
+                $form->select('city', '所属城市')->default(isset($districtArr[1])?$districtArr[1]:0)->options(CategoryDistrict::categoryDis(isset($districtArr[0])?$districtArr[0]:0))->setWidth(3)->load('area',  admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属城市'])->setMustMark();
+                //$form->select('area', '所属县区')->default(isset($districtArr[2])?$districtArr[2]:0)->options(CategoryDistrict::categoryDis(isset($districtArr[1])?$districtArr[1]:0))->setWidth(3)->setMustMark();
+            } else {
+                $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',  admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属省份'])->setMustMark();
+                $form->select('city', '所属城市')->setWidth(3)->load('area',admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属城市'])->setMustMark();
+                //$form->select('area', '所属县区')->default(0)->setWidth(3)->setMustMark();
+            }
+
+            $form->select('scale', '公司规模')->options(Category::categoryType('AIX_scale'))->setWidth(3)->setMustMark();
+            $form->number('registered', '注册资金')->setWidth(3);
+            $form->radio('currency', '资金类型')->options(['万人民币' => '万人民币', '万美元' => '万美元'])->default('万人民币');
+            $form->multipleSelect('tag', '企业福利')->options(Category::categoryType('AIX_jobtag'))->setWidth(3);
+            $form->url('website', '公司网站')->setWidth(3);
+            $form->text('address', '公司地址')->setWidth(4);
+            $form->text('legal', '公司法人姓名')->setWidth(6);
+            $form->text('legal_idcard', '公司法人身份证')->setWidth(6);
+            $form->textarea('contents', '公司介绍')->attribute(['maxlength'=>2000])->setMustMark()->setWidth(4)->help('请输入2000字以内公司介绍');
+        })->tab('证照信息', function ($form) {
+            $form->image('logo', '企业logo')->uniqueName()->setWidth(3);
+            $form->image('certificate_img', '营业执照')->setWidth(3);
+        });
+
+        $form->hidden('regpoints', '管理积分')->options([0=>'减少', 1=>'增加' ])->default('1');
+        $form->hidden('points', '赠送数量')->default(0);
+
+        $form->hidden('is_money', '是否收费');
+        $form->hidden('amount', '收费金额');
+        $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
+
+        empty(\request('setmeal_id')) ? request()->offsetSet('setmeal_id', key($setmeal)) : "" ;
+        $form->hidden("setmeal_id");
+
+
+        return $form;
+    }
+
+    public function update($id,ServiceService $serviceService,CompanyRepository $companyRepository)
+    {
+        if (request()->has(Form\Field::FILE_DELETE_FLAG)) {
+            return $this->editForm($id)->update($id);
+        }
+        $data = $this->editForm($id)->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
+
+        if($data['legal_idcard'] && !isCreditNo($data['legal_idcard'])){
+            admin_toastr('法人代表身份证格式不正确', 'error');
+            return back();
+        }
+        if(!empty(request("mobile")) || !empty(request("landline_tel"))){
+
+            if (!empty(request("mobile"))){
+                $validator = Validator::make(\request()->all(),
+                    ['mobile'     => ['required',new MobileRule(),Rule::unique('companys')->ignore($id)]],
+                    ['mobile.required'=>"请填写手机号!",'mobile.unique'=>"手机号已经存在!",]
+                );
+            }
+            if (!empty(request("landline_tel"))){
+                if (request('landline_tel')=="--" || request('landline_tel')=="-"){
+
+                    request()->offsetSet("landline_tel","");
+
+                    if (empty(request("mobile"))){
+                        admin_toastr("手机、固话二选一",'error');
+                        return back();
+                    }
+                }else{
+                    $last_tel=substr(request('landline_tel'),-1);
+                    if ($last_tel=="-"){
+                        $new_tel = substr(request('landline_tel'),0,strlen(request('landline_tel'))-1);
+                        request()->offsetSet("landline_tel",$new_tel);
+                        $data['landline_tel']=$new_tel;
+                    }
+
+                    $validator = Validator::make(\request()->all(),
+                        ['landline_tel'     => ['required','regex: /^(([0\+]\d{1,9}-)?(\d{2,6})-)(\d{1,12})(-(\d{1,8}))?$/']
+                        ],
+                        ['landline_tel.required'=>"请填写固话!",'landline_tel.regex'=>"固话格式不对"]
+                    );
+                }
+
+            }
+
+            if (isset($validator) && $validator->fails()) {
+                admin_toastr($validator->errors()->first(), 'error');
+                return back();
+            }
+        }else{
+            admin_toastr("手机、固话二选一",'error');
+            return back();
+        }
+
+
+        $res= [];
+        $res1= [];
+        $res2= [];
+        foreach ($data as $key => $val) {
+            if ($key == 'regpoints') {
+                $res1['regpoints'] = $val;
+            } else if ($key == 'points') {
+                $res1['points'] = $val;
+            } else if ($key == 'setmeal_id') {
+                $res2['setmeal_id'] = $val;
+            } else if ($key == "is_money") {
+                $res2['is_money'] = $val;
+            } else if ($key == 'amount') {
+                $res2['amount'] = $val;
+            } else {
+                if ($key == 'tag') {
+                    $res[$key] =  implode(',', $val);
+                } elseif ($key == 'province') {
+                    $res['district'] = $val;
+                } elseif ($key == 'city') {
+                    $res['district'] = $res['district'].".".$val;
+                } elseif ($key == 'area') {
+                    $res['district'] = $res['district'].".".$val;
+                } else {
+                    $res[$key] = $val;
+                }
+            }
+        }
+        $res['district_cn'] =get_district_cn($res['district']);
+        $comInfo = $this->companyRepository->find($id);
+        //设置当前分站
+        if (!isset($res['subsite_id'])){
+
+            $comInfo->subsite_id=get_subsite_id();
+            $res['subsite_id']=get_subsite_id();
+
+        }
+        DB::beginTransaction();
+        try {
+            $res['setmeal_id'] = $res2['setmeal_id'];
+            $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
+            $res['setmeal_name'] = $setmeal[$res2['setmeal_id']];
+            if (!Company::where('id', $id)->update($res)) {
+                throw new \Exception('修改失败');
+            }
+
+            $updateJob['company_name'] = $res['companyname'];
+            $jid = $this->jobsRepository->findWhere(['company_id'=>$id], ['id']);
+            if ($jid) {
+                $jids = array_column($jid->toArray(), 'id');
+                if ($this->jobsRepository->modifyCom($jids, $updateJob)) {
+                    $condition1 = [['whereIn','id', $jids]];
+                    event_search_update(Jobs::class, $condition1, 'update');
+                }
+            }
+            if (get_subsite_open() && $comInfo->subsite_id != $res['subsite_id']) {
+                $this->modifySubsite($id, $res['subsite_id']);
+                CompanyImg::where('company_id', $id)->update(['subsite_id'=>$res['subsite_id']]);//修改企业风采中的分站id;
+            }
+//
+            event_search_update(Company::class, (string)$id, 'update');
+            DB::commit();
+            admin_toastr('企业修改成功', 'success');
+        } catch (\Exception $e) {
+            DB::rollback();
+            admin_toastr($e->getMessage(), 'error');
+        }
+        return redirect(route("company.index"));
+    }
+
+    protected function modifySubsite($company_id, $subsite_id)
+    {
+        $jobsList = $this->jobsRepository->findWhere(['company_id'=>$company_id], ['id','subsite_id']);
+        if ($jobsList->isNotEmpty()) {
+            $jobsArr = $jobsList->toArray();
+            $jid = array_column($jobsArr, 'id');
+            if (is_array($jid)) {
+                $this->jobsRepository->updateSubsite($jid, $subsite_id);
+                event_search_update(Jobs::class, implode(',', $jid), 'update');
+                $subjobData = SubsiteJob::whereIn('jobs_id', $jid)->where('subsite_id', $subsite_id)->select('id')->get()->toArray();
+                if ($subjobData) {
+                        SubsiteJob::destroy(array_column($subjobData, 'id'));
+                }
+                SubsiteJob::whereIn('jobs_id', $jid)->where('subsite_id', $jobsArr[0]['subsite_id'])->update(['subsite_id'=>$subsite_id]);
+
+            }
+        }
+    }
+
+    public function destroy($id)
+    {
+        Permission::check('company_manager_delete');
+        $ids = explode(',', $id);
+        if (Company::destroy($ids)) {
+            // 删除企业下面所有职位
+            $jobs = $this->jobsRepository->findWhereIn('company_id', $ids, ['id']);
+            if ($jobs) {
+                $jids = array_column($jobs->toArray(), 'id');
+                $this->jobsRepository->delJobs($jids);
+                $this->jobsContactRepository->delJobsContact($jids);
+                $condition1 = [['whereIn','id', $jids]];
+                event_search_update(Jobs::class, $condition1, 'delete');
+            }
+            //删除招聘会职位,参展记录
+            $fairjobs = $this->jobfairJobRepository->findWhereIn('company_id', $ids, ['id']);
+            $this->jobfairCompanyRepository->delJobs('company_id',$ids);
+            $this->jobfairJobRepository->delJobs('company_id',$ids);
+            if($fairjobs){
+                $this->jobfairJobsContactRepository->deleteJobContact($fairjobs);
+                $this->jobfairPutJobRepository->delJobIds($fairjobs);
+            }
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+            $condition = [['whereIn','id', $ids]];
+            event_search_update(Company::class, $condition, 'delete');
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+
+        return response()->json($data);
+    }
+
+    public function companyAudit(Request $request)
+    {
+        $ids = $request->ids;
+        if (!$ids) {
+            return admin_toastr('请选择要审核的企业', 'error');
+        }
+        $id = explode(',', $ids);
+        $reason = $request->reason;
+        $data = ['audit'=>$request->audit1];
+
+        if (Company::companyAudit($id, $data)) {
+            $jid = $this->jobsRepository->findWhereIn('company_id', $id, ['id']);
+            if ($jid) {
+                $jids = array_column($jid->toArray(), 'id');
+                //修改职位中企业状态字段
+                if ($this->jobsRepository->modifyCom($jids, ['company_audit'=>$request->audit1])) {
+                    $condition1 = [['whereIn','id', $jids]];
+                    event_search_update(Jobs::class, $condition1, 'update');
+                    $condition2 = [['whereIn','id', $id]];
+                    event_search_update(Company::class, $condition2, 'update');
+                }
+            }
+            //如果认证状态为通过(1)完成营业招聘审核
+            if ($request->audit1 == 1) {
+                foreach ($id as $key => $val) {
+                    $this->taskService->doTask(30, $val, 1);
+                }
+            }
+            switch ($request->audit1) {
+                case 1:
+                    $html = "企业通过审核";
+                    $alias =Smser::TEMPLATE_SMS_LICENSEALLOW;
+                    break;
+                case 3:
+                    $html = "企业未通过审核";
+                    $alias=Smser::TEMPLATE_SMS_LICENSENOTALLOW;
+                    break;
+            }
+            foreach ($id as $key => $val) {
+                $companyInfo = $this->companyRepository->find($val, ['mobile']);
+                if ($companyInfo->mobile) {
+                    $this->smsService->sendSms($companyInfo->mobile, $alias, ['sitename'=>config('aix.system.site.site.site_name'),'sitedomain'=>config('aix.system.site.site.site_domain')]);
+                }
+            }
+
+
+            $auditData= [];
+            $auditData['ids'] = $id;
+            $auditData['status'] = $request->audit1;
+            $auditData['type'] = 8;
+            $auditData['reason'] = $reason;
+            AuditReason::addData($auditData);
+            if ($request->is_send) {
+                //站内信
+                switch ($request->audit1) {
+                    case 1:
+                        $html = "企业通过审核";
+                        break;
+                    case 3:
+                        $html = "企业未通过审核";
+                        break;
+                }
+                foreach ($id as $key => $val) {
+                    $com = $this->companyRepository->findWhere(['id'=>$val], ['*']);
+                    $insert_data[$key] = array(
+                        'utype'      => 1,
+                        'msgtype'    => 1,
+                        'msgfromuid' => admin::user()->id,
+                        'msgfrom'     => admin::user()->username,
+                        'msgtoname'   =>$com[0]->username,
+                        'msgtouid'    => $val,
+                        'message'     => $html.'【备注】'.$reason,
+                        'new'          => 1,
+                        'created_at' =>date('Y-m-d H:i:s', time()),
+                        'updated_at' =>date('Y-m-d H:i:s', time()),
+                    );
+                }
+                $this->pmsService->addBatchPms($insert_data);
+            }
+
+            return admin_toastr('企业审核成功', 'success');
+        } else {
+            return admin_toastr('企业审核失败!', 'error');
+        }
+    }
+
+    public function companyRefresh(Request $request)
+    {
+        $ids = $request->ids;
+        if (!$ids) {
+            return admin_toastr('请选择要刷新的企业', 'error');
+        }
+        $id = explode(',', $ids);
+        $data = ['refresh_time'=>time(),'last_login_time'=>time()];
+        if (Company::companyAudit($id, $data)) {
+            return admin_toastr('企业刷新成功', 'success');
+        } else {
+            return admin_toastr('企业刷新失败!', 'error');
+        }
+    }
+
+    public function manager($id = 0)
+    {
+        if (!$id) {
+            return false;
+        }
+        $company = Company::findOrFail($id);
+        if (!$company) {
+            return false;
+        }
+        $key=uniqid();
+        Cache::put($key, $company, 1);
+        $url=route('auth.thirdlogin.background', ['ticket' => $key])."?redirect_url=".urlencode(route('com.index'));
+        return redirect($url);
+    }
+
+
+
+    /**
+     * 发送短信
+     * return json
+     */
+    public function sms(Request $request)
+    {
+        $mobile = $request->mobile;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('company.ajax.sendsms'));
+        $form->disableReset();
+        $form->html('
+            <strong style="color:#FF6600">
+                <span>您当前配置的短信接口是【阿里大鱼】。</span>
+            </strong>
+        ');
+        $form->mobile('mobile', '接受手机')->default($mobile);
+        $form->textarea('body', '发送内容')->help('内容超过70个字符将自动截取');
+        $form->hidden('sms_id')->default('sms_custom');
+        return json_encode(['html'=>$form->render(),'detail'=>'发送短信']);
+    }
+
+    /**
+     * 发送Email.
+     * return json
+     */
+    public function email(Request $request)
+    {
+        $email = $request->email;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('company.ajax.sendemail'));
+        $form->disableReset();
+        $form->email('email', '收件地址')->default($email);
+        $form->text('title', '邮件标题');
+        $form->textarea('body', '邮件内容');
+        return json_encode(['html'=>$form->render(),'detail'=>'发送邮件']);
+    }
+
+    /**
+     * 发送站内信
+     * return json
+     */
+    public function sys(Request $request)
+    {
+        $uid = $request->uid;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('company.ajax.sendsys'));
+        $form->disableReset();
+        $form->hidden('uid')->default($uid);
+        $form->textarea('body', '发送内容');
+        return json_encode(['html'=>$form->render(),'detail'=>'发送站内信']);
+    }
+
+    /**
+     * 重置密码
+     *  return json
+     */
+    public function auditPassword(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('audit.pass'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->html('<div>重置的新密码为123456,是否重置?</div>');
+        return json_encode(['html'=>$form->render(),'detail'=>'重置密码']);
+    }
+
+    public function auditPass(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $result = Company::whereIn('id', $arr)->update(['password'=>\Hash::make(123456)]);
+        if ($result) {
+            admin_toastr('重置成功', 'success');
+            foreach ($arr as $key => $val) {
+                $company = Company::findOrFail($val);
+                if ($company->mobile) {
+                    $this->smsService->sendSms($company->mobile, Smser::TEMPLATE_SMS_EDITPWD, ['sitename'=>config('aix.system.site.site.site_name'),'newpassword'=>'123456']);
+                }
+            }
+        } else {
+            admin_toastr('重置失败', 'error');
+        }
+        return back();
+    }
+
+    /**
+     * 单个企业审核
+     */
+    public function auditOne(Request $request)
+    {
+        $ids = $request->ids;
+        $company = Company::findOrFail($ids);
+        if (!$ids) {
+            return admin_toastr('请选择要审核的企业', 'error');
+        }
+        $id = explode(',', $ids);
+        $reason = $request->reason;
+        $data = ['audit'=>$request->audit1];
+
+        if (true == Company::companyAudit($id, $data)) {
+//            event_search_update(Company::class, (string)$id, 'update');
+            $jid = $this->jobsRepository->findWhereIn('company_id', $id, ['id']);
+            if ($jid) {
+                $jids = array_column($jid->toArray(), 'id');
+                //修改职位中企业状态字段
+                if ($this->jobsRepository->modifyCom($jids, ['company_audit'=>$request->audit1])) {
+                    $condition1 = [['whereIn','id', $jids]];
+//                    event_search_update(Jobs::class, $condition1, 'update');
+                }
+            }
+            //如果认证状态为通过(1)完成营业执照审核
+            if ($request->audit1 == 1) {
+                foreach ($id as $key => $val) {
+                    $this->taskService->doTask(30, $val, 1);
+                }
+            }
+            switch ($request->audit1) {
+                case 1:
+                    $html = "企业通过审核";
+                    $alias =Smser::TEMPLATE_SMS_LICENSEALLOW;
+                    break;
+                case 3:
+                    $html = "企业未通过审核";
+                    $alias=Smser::TEMPLATE_SMS_LICENSENOTALLOW;
+                    break;
+            }
+            if ($company->mobile) {
+                $this->smsService->sendSms($company->mobile, $alias, ['sitename'=>config('aix.system.site.site.site_name'),'sitedomain'=>config('aix.system.site.site.site_domain')]);
+            }
+
+
+            $auditData= [];
+            $auditData['ids'] = $id;
+            $auditData['status'] = $request->audit1;
+            $auditData['type'] = 8;
+            $auditData['reason'] = $reason;
+            AuditReason::addData($auditData);
+            if ($request->is_send) {
+                //站内信
+                foreach ($id as $key => $val) {
+                    $com = $this->companyRepository->findWhere(['id'=>$val], ['*']);
+                    $insert_data[$key] = array(
+                        'utype'      => 1,
+                        'msgtype'    => 1,
+                        'msgfromuid' => admin::user()->id,
+                        'msgfrom'     => admin::user()->username,
+                        'msgtoname'   =>$com[0]->username,
+                        'msgtouid'    => $val,
+                        'message'     => $html.'【备注】'.$reason,
+                        'new'          => 1,
+                        'created_at' =>date('Y-m-d H:i:s', time()),
+                        'updated_at' =>date('Y-m-d H:i:s', time()),
+                    );
+                }
+                $this->pmsService->addBatchPms($insert_data);
+            }
+            admin_toastr('企业审核成功', 'success');
+            return redirect(route("company.index"));
+        } else {
+            admin_toastr('企业审核失败!', 'error');
+            return redirect(route("company.index"));
+        }
+    }
+
+
+    public function companyLog(Request $request)
+    {
+
+        $id = $request->id;
+        $type = $request->type;
+        $headers = ['status'=>'审核状态', 'tim'=>'审核时间', 'sec'=>'描述'];
+        $data = [];
+        $res = AuditReason::where(['type_id'=>$id,'type'=>$type])->orderBy('id', 'desc')->get();
+        if (!$res) {
+            $rows = $data;
+        } else {
+            foreach ($res as $k => $v) {
+                if ($v['status']==3) {
+                    $data[$k]['status'] = '审核失败';
+                } elseif ($v['status']==1) {
+                    $data[$k]['status'] = '审核通过';
+                } else {
+                    $data[$k]['status'] = '待审核';
+                }
+                $data[$k]['tim'] = $v['created_at'];
+                $data[$k]['sec'] = $v['audit_man'].'--'.($v['reason']?$v['reason']:"无");
+            }
+            $rows = $data;
+        }
+
+        $table = new Table($headers, $rows);
+        return ['html'=>$table->render(),'detail'=>'审核日志'];
+    }
+    
+    public function consultantSet(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('consultant.set.update'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        if(Admin::user()->isAdministrator()){
+            $form->select('consultant_id', '顾问名称')->options(
+                Consultant::pluck('name','id')
+            )->rules([
+                'required',
+            ])->setMustMark();
+        }else{
+            $form->select('consultant_id', '顾问名称')->options(
+                Consultant::where('subsite_id', get_subsite_id())->pluck('name','id')
+            )->rules([
+                'required',
+            ])->setMustMark();
+        }
+        return json_encode(['html'=>$form->render(),'detail'=>'设置顾问']);
+    }
+    
+    public function consultantSetUpdate(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('请勾选需要设置顾问的会员', 'error');
+            return back();
+        }
+        $consultant_id = $request->consultant_id;
+        if(empty($consultant_id)){
+            admin_toastr('设置顾问不能为空', 'error');
+            return back();
+        }
+        $Consultant = Consultant::find($consultant_id);
+        $exit_company = Company::whereHas('companyConsultant')->whereIn('id', $arr)->pluck('id')->toArray();
+        $no_company = array_diff($arr, $exit_company);
+        \DB::beginTransaction();
+        try {
+            if($exit_company){
+                CompanyConsultant::whereIn('company_id',$exit_company)->update(['consultant_id'=>$consultant_id,'admin_users_id'=>$Consultant->admin_users_id,'consultant_name'=>$Consultant->name]);
+            }
+            if($no_company){
+                $needArr=[];
+                foreach ($no_company as $key=>$val){
+                    $needArr[$key]['consultant_id'] = $consultant_id;
+                    $needArr[$key]['company_id'] = $val;
+                    $needArr[$key]['admin_users_id'] = $Consultant->admin_users_id;
+                    $needArr[$key]['consultant_name'] = $Consultant->name;
+                    $needArr[$key]['created_at'] = date('Y-m-d H:i:s');
+                    $needArr[$key]['updated_at'] = date('Y-m-d H:i:s');
+                }
+                 CompanyConsultant::insert($needArr);
+            }
+            \DB::commit();
+            admin_toastr('设置成功', 'success');
+            return back();
+        } catch (\Exception $e) {
+            \DB::rollback();
+            admin_toastr('设置失败', 'error');
+            return back();
+        }
+    }
+    
+    
+}

+ 163 - 0
app/Admin/Controllers/Company/CompanyDownResumeController.php

@@ -0,0 +1,163 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\CompanyDownResume;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class CompanyDownResumeController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('简历下载')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('下载的简历')
+            ->description('下载的简历')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new CompanyDownResume);
+        $grid->model()->whereHas('resumes');
+        $grid->id('ID');
+        $grid->column('resumes.fullname', '姓名');
+        $grid->column('resumes.birthdate', '年龄')->display(function ($birthdate) {
+            return date('Y')-$birthdate;
+        });
+        $grid->column('resumes.sex_cn', '性别');
+        $grid->column('resumes.education_cn', '学历');
+        $grid->column('resumes.experience_cn', '工作经验');
+        $grid->column('resumes.wage_cn', '期望薪资');
+        $grid->down_addtime('下载时间')->display(function ($down_addtime) {
+            return date('Y-m-d H:i:s', $down_addtime);
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('company_uid', '企业ID');
+                $filter->like('company_name', '企业名称');
+                $filter->between('created_at', '添加时间')->datetime();
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('resumes.resume_name', '简历名');
+                $filter->like('resumes.resume_id', '简历ID');
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(CompanyDownResume::findOrFail($id));
+        $show->resumes()->fullname('姓名')->as(function ($resumes) {
+            return $resumes->fullname;
+        });
+        $show->resumes()->birthdate('年龄')->as(function ($resumes) {
+            return date('Y')-$resumes->birthdate;
+        });
+
+        $show->resumes()->sex_cn('性别')->as(function ($resumes) {
+            return $resumes->sex_cn;
+        });
+        $show->resumes()->education_cn('学历')->as(function ($resumes) {
+            return $resumes->education_cn;
+        });
+        $show->resumes()->experience_cn('工作经验')->as(function ($resumes) {
+            return $resumes->experience_cn;
+        });
+        $show->resumes()->wage_cn('期望薪资')->as(function ($resumes) {
+            return $resumes->wage_cn;
+        });
+
+        $show->down_addtime('下载时间')->as(function ($down_addtime) {
+            return date('Y-m-d H:i:s', $down_addtime);
+        });
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new CompanyDownResume);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 351 - 0
app/Admin/Controllers/Company/CompanyImgController.php

@@ -0,0 +1,351 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Admin\Extensions\Tools\DialogTool;
+use App\Admin\Extensions\Tools\GridView;
+use App\Http\Controllers\Controller;
+use App\Models\Admin\AdminRole;
+use App\Models\AuditReason;
+use App\Models\Company;
+use App\Models\CompanyImg;
+use App\Models\Subsite;
+use App\Repositories\CompanyImgRepository;
+use App\Services\Common\PmsService;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\Request;
+
+class CompanyImgController extends Controller
+{
+    use HasResourceActions;
+
+    protected $companyImgRepository;
+    protected $pmsService;
+    /**
+     * CompanyImgController constructor.
+     * @param $companyImgRepository
+     * @param $pmsService
+     */
+    public function __construct(CompanyImgRepository $companyImgRepository, PmsService $pmsService)
+    {
+        $this->companyImgRepository = $companyImgRepository;
+        $this->pmsService = $pmsService;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        Permission::check('companyImg_manager');
+        return $content
+            ->header('企业风采')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('企业风采')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        Permission::check('companyImg_manager_edit');
+        return $content
+            ->header('企业风采')
+            ->description('编辑')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('企业风采')
+            ->description('新增')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new CompanyImg);
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+        })->whereHas('companys')->when(Admin::user()->isRole(AdminRole::$consultantSlug), function ($query) {
+            $query->whereHas('companyConsultant',function ($query){
+                $query->where('consultant_id', isset(Admin::user()->consultant->id) ? Admin::user()->consultant->id : -1);
+            });
+        })->orderByRaw('field(audit,0,2,1,3)')->orderBy('created_at', 'desc');
+        $grid->id('ID');
+        $grid->image()->image();
+        $grid->company_id('企业名称')->display(function ($company_id) {
+            $companyname = Company::where('id', $company_id)->select(['companyname'])->first();
+            return $companyname['companyname'];
+        })->width(200);
+        $grid->audit('审核状态')->display(function ($audit) {
+            switch ($audit) {
+                case 1:
+                    return '<span style="color:#009900">审核通过</span>';
+                    break;
+                case 2:
+                    return '<span style="color:#FF6600">审核中</span>';
+                    break;
+                case 3:
+                    return '<span style="color:#FF0000">审核未通过</span>';
+                    break;
+                case 0:
+                    return '<span style="color:#FF6600">未审核</span>';
+                    break;
+            }
+        });
+        $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+            if ($subsite_id == 0) {
+                return "总站";
+            } else {
+                $subsite = Subsite::findOrFail($subsite_id);
+                return $subsite->sitename;
+            }
+        });
+        $grid->created_at('添加时间');
+        $grid->tools(function (Grid\Tools $tools) {
+
+            if (Admin::user()->can('companyImg_manager_audit')) {
+                $form = new \Encore\Admin\Widgets\Form();
+                $form->action(route('companyimg.audit'));
+                $form->radio('audit1', '审核状态')->options([1=>'审核通过', 2=>'审核中', 3=>'审核未通过'])->default(1);
+                $states = [
+                    'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+                    'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+                ];
+                $form->textarea('reason', '备注');
+                $form->html("<input type='checkbox' name='is_send' checked value='1'/>站内信通知");
+                $config = array(
+                    'button' => "审核",//添加的按钮文字
+                    'title' => "将所选企业",//弹窗标题
+                    'dialog_cancel' => "取消",//取消文字
+                    'dialog_ok' => "确认",//确认文字
+                    'is_batch' => true//是否批量操作,如果是批量操作则提交表单时会带上ids参数
+                );
+                $tools->append(new DialogTool($form, $config));
+            }
+
+            $tools->append(new GridView());
+        });
+        if (Request::get('view') !== 'table') {
+            $grid->setView('admin.grid.card');
+        }
+        $grid->actions(function (Grid\Displayers\Actions $actions) {
+            if(Request::get('view') !== 'table') {
+                if (Admin::user()->can('companyImg_manager_audit')) {
+                    $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+                }
+            }
+            if (Admin::user()->can('companyImg_manager_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('companyImg_manager_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        $grid->filter(function ($filter) {
+            $filter->where(function ($query) {
+                $query->whereHas('companys', function ($query) {
+                    $query->where('companyname', 'like', "%{$this->input}%");
+                });
+            }, '公司名称');
+            $filter->equal('company_id', '企业ID');
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('audit', '审核状态')->select([0=>'未审核',1=>'审核通过',2=>'审核中',3=>'审核未通过']);
+            });
+            $filter->column(1/2, function ($filter) {
+                $subsite = Subsite::where('effective', 1)->select('id', 'sitename')->get();
+                $subsiteArr=[];
+                if ($subsite) {
+                    $subsiteArr = $subsite->toArray();
+                    $subsiteArr = array_column($subsiteArr, 'sitename', 'id');
+                }
+                $subsiteArr[0] = "总站";
+                ksort($subsiteArr);
+                if (get_subsite_id()== 0) {
+                    $filter->equal('subsite_id', '所属分站')->select($subsiteArr);
+                }
+                $filter->between('created_at', '添加时间')->datetime();
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(CompanyImg::findOrFail($id));
+        $show->id('ID');
+        $show->title('标题');
+        $show->image('图片')->image();
+        $show->audit('审核状态')->as(function ($audit) {
+            switch ($audit) {
+                case 0:
+                    return '未审核';
+                    break;
+                case 1:
+                    return '审核通过';
+                    break;
+                case 2:
+                    return '审核中';
+                    break;
+                case 3:
+                    return '审核未通过';
+                    break;
+            }
+        });
+
+        $show->created_at('创建时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new CompanyImg);
+
+        $form->display('id');
+        $form->text('title', '标题');
+        $form->image('image', '图片')->rules('required');
+        $form->radio('audit', '审核状态')->options([0=>'未审核',1=>'审核通过',2=>'审核中',3=>'审核未通过',]);
+        $form->display('created_at', '上传时间');
+        return $form;
+    }
+
+    public function editForm()
+    {
+        $form = new Form(new CompanyImg);
+
+        $form->display('id');
+        $form->text('title', '标题');
+        $form->image('image', '图片')->rules('required');
+        $form->radio('audit', '审核状态')->options([0=>'未审核',1=>'审核通过',2=>'审核中',3=>'审核未通过',]);
+        $form->display('created_at', '上传时间');
+        return $form;
+    }
+
+    public function update($id)
+    {
+        if (request()->has(Form\Field::FILE_DELETE_FLAG)) {
+            return $this->editForm($id)->update($id);
+        }
+        return $this->editForm($id)->update($id);
+    }
+
+
+    public function companyImgAudit(Req $request)
+    {
+        $ids = $request->ids;
+        if (!$ids) {
+            return admin_toastr('请选择要审核的企业', 'error');
+        }
+        $id = explode(',', $ids);
+        $img_com_ids =$this->companyImgRepository->findWhereIn('id', $id, ['company_id','id'])->toArray();
+        $reason = $request->reason;
+        $data = ['audit'=>$request->audit1];
+        if (CompanyImg::whereIn('id', $id)->update($data)) {
+            //审核日志$reason
+            $auditData= [];
+            $auditData['ids'] = $id;
+            $auditData['status'] = $request->audit1;
+            $auditData['type'] = 9;
+            $auditData['reason'] = $reason;
+            AuditReason::addData($auditData);
+            if ($request->is_send) {
+                //站内信
+                $insertData = [];
+                switch ($request->audit1) {
+                    case 1:
+                        $html = "通过审核";
+                        break;
+                    case 2:
+                        $html = "审核中";
+                        break;
+                    case 3:
+                        $html = "未通过审核";
+                        break;
+                }
+                foreach ($img_com_ids as $key => $val) {
+                    $insertData[$key] = array(
+                        'utype'      => 1,
+                        'msgtype'    => 1,
+                        'msgfromuid' => admin::user()->id,
+                        'msgfrom'     => admin::user()->username,
+                        'msgtoname'   =>getComUserName($val['company_id']),
+                        'msgtouid'    => $val['company_id'],
+                        'message'     => '企业风采'.$val['id'].$html.'【备注】'.$reason,
+                        'new'          => 1,
+                        'created_at' =>date('Y-m-d H:i:s', time()),
+                        'updated_at' =>date('Y-m-d H:i:s', time()),
+                    );
+                }
+                $this->pmsService->addBatchPms($insertData);
+            }
+            if($request->type) {
+                admin_toastr('企业风采审核成功', 'success');
+                return back();
+            } else{
+                return admin_toastr('企业风采审核成功', 'success');
+            }
+        } else {
+            if($request->type) {
+                admin_toastr('企业风采审核失败', 'error');
+                return back();
+            } else{
+                return admin_toastr('企业风采审核失败', 'error');
+            }
+        }
+    }
+}

+ 161 - 0
app/Admin/Controllers/Company/CompanyInterViewController.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\CompanyInterView;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use function foo\func;
+
+class CompanyInterViewController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('面试邀请')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('面试邀请')
+            ->description('面试邀请')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new CompanyInterView);
+        $grid->model()->whereHas('resumes');
+        $grid->id('ID');
+        $grid->column('resumes.fullname', '姓名');
+        $grid->column('resumes.birthdate', '年龄')->display(function ($birthdate) {
+            return date('Y')-$birthdate;
+        });
+        $grid->column('resumes.sex_cn', '性别');
+        $grid->column('resumes.education_cn', '学历');
+        $grid->column('resumes.experience_cn', '工作经验');
+        $grid->column('resumes.wage_cn', '期望薪资');
+        $grid->column('interview_time', '面试时间')->display(function ($interview_time) {
+            return date('Y-m-d H:i:s', $interview_time);
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('company_id', '企业ID');
+                $filter->like('company_name', '企业名称');
+                $filter->between('created_at', '添加时间')->datetime();
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('jobs_id', '职位ID');
+                $filter->like('jobs_name', '职位名称');
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(CompanyInterView::findOrFail($id));
+
+        $show->resumes('姓名')->as(function ($resumes) {
+            return $resumes->fullname;
+        });
+        $show->resumes()->birthdate('年龄')->as(function ($resumes) {
+            return $resumes->birthdate;
+        });
+        $show->resumes()->sex_cn('性别')->as(function ($resumes) {
+            return $resumes->sex_cn;
+        });
+        $show->resumes()->fullname('学历')->as(function ($resumes) {
+            return $resumes->education_cn;
+        });
+        $show->resumes()->fullname('工作经验')->as(function ($resumes) {
+            return $resumes->experience_cn;
+        });
+        $show->resumes()->wage_cn('期望薪资')->as(function ($resumes) {
+            return $resumes->wage_cn;
+        });
+        $show->interview_time('面试时间')->as(function ($interview_time) {
+            return date('Y-m-d H:i:s', $interview_time);
+        });
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new CompanyInterView);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 437 - 0
app/Admin/Controllers/Company/CompanySetController.php

@@ -0,0 +1,437 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Admin\Extensions\Form\ValueForm;
+use App\Http\Controllers\Controller;
+use App\Models\Company;
+use App\Models\CompanyDownResume;
+use App\Models\CompanyImg;
+use App\Models\CompanyInterView;
+use App\Models\MembersChargeLog;
+use App\Models\MembersPoint;
+use App\Models\MembersSetmeal;
+use App\Models\Order;
+use App\Models\PersonalJobsApply;
+use App\Models\Setmeal;
+use App\Models\Subsite;
+use App\Repositories\MemberPointRepository;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Widgets\Tab;
+use Illuminate\Http\Request;
+use Encore\Admin\Form;
+
+
+class CompanySetController extends Controller
+{
+    //企业相关内容
+    public function comBusiness(Content $content, Request $request, $id, $type = 'points')
+    {
+        if (!intval($id)) {
+           admin_toastr('参数错误');
+           return back();
+        }
+        $tab = new Tab();
+        $types = [
+            'points'=>'积分管理',
+            'setmeal'=>'套餐管理',
+            'order'=>'充值/订单',
+            'increment'=>'增值服务',
+            'down_resume'=>'下载的简历',
+            'apply'=>'收到的简历',
+            'interview'=>'面试邀请',
+            'companyimg'=>'企业风采管理',
+        ];
+        /**
+         * 直接在case里头判断的话,case 完了的代码会产生css影响
+         */
+        if (!Admin::user()->can('company_comBusiness_points')) {
+            unset($types["points"]);
+        }
+        if (!Admin::user()->can('company_comBusiness_setmeal')) {
+            unset($types["setmeal"]);
+        }
+
+        foreach ($types as $key => $val) {
+            $form=null;
+            $memberSetform=null;
+            switch ($key) {
+                case 'points':
+
+                    $grid = new Grid(new MembersPoint());
+
+                    $grid->model()->where('uid', $id)->where('utype', 1)->when(get_subsite_id()>0, function ($querys) {
+                        $querys->whereHas('companys', function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->whereHas('companys')->orderBy('created_at', 'desc');
+                    $grid->column('companys.companyname', '企业名称');
+                    $grid->points('积分');
+                    $grid->column('companys.username', '用户名称');
+                    $grid->column('companys.created_at', '注册时间');
+                    $grid->disableActions();
+                    $grid->disableTools();
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+
+                    $form=$this->PointeditForm()->edit($id);
+
+                    $form->setAction(admin_base_path("firm/comBusiness/update/{$id}"));
+
+
+                    $form->setTitle("修改");
+
+                    break;
+                case 'setmeal':
+
+                    $grid = new Grid(new MembersSetmeal);
+                    $grid->model()->where('uid', $id)->where('utype', 1)->whereHas('companys')->when(get_subsite_id()>0, function ($querys) {
+                        $querys->whereHas('companys', function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->orderBy('id', 'desc');
+                    $grid->id('id');
+                    $grid->setmeal_name('套餐名称');
+                    $grid->column('companys.companyname', '公司名称');
+                    $grid->column('companys.username', '用户名称');
+                    $grid->starttime('开始时间')->display(function ($starttime) {
+                        return date('Y-m-d H:i:s', $starttime);
+                    });
+                    $grid->endtime('结束时间')->display(function ($endtime) {
+                        if ($endtime) {
+                            return $endtime;
+                        }
+                        return "永久";
+                    });
+                    $grid->disableActions();
+                    $grid->disableTools();
+                    $grid->setName($key);
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+
+                    $memberSetmealInfo=MembersSetmeal::where(['uid'=>$id])->first();
+
+
+                    //套餐修改的form表单
+                    $memberSetform=$this->eidtMemberSetForm()->edit($memberSetmealInfo->id);
+
+                    $memberSetform->setAction(admin_base_path("firm/companysetmeal/index/{$memberSetmealInfo->id}"));
+                    $memberSetform->setTitle("套餐更换");
+
+                    //修改套餐内容的Form 表单
+                    $form=$this->eidtForm()->edit($memberSetmealInfo->id);
+                    $form->setTitle("套餐修改");
+                    $form->setAction(admin_base_path("firm/companysetmeal/index/{$memberSetmealInfo->id}"));
+
+                    break;
+                case "order":
+                    $utype = 1;
+                    $grid = new Grid(new Order);
+                    $grid ->model()->where('uid', $id)->where('utype', $utype)->when(get_subsite_id()>0, function ($querys) {
+                        $relations = 'companys';
+                        $querys->whereHas($relations, function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->orderBy('created_at', 'desc')->orderBy("is_pay", 'asc');
+                    $grid->id('ID');
+                    $grid->is_pay('支付状态')->display(function ($is_pay) {
+                        if ($is_pay == 1) {
+                            return '待付款';
+                        } elseif ($is_pay == 2) {
+                            return "已付款";
+                        } else {
+                            return '已取消';
+                        }
+                    });
+                    $grid->amount('金额')->width(150);
+                    $grid->column('companys.companyname', '企业名称')->width(200);
+                    $grid->service_name('说明')->width(150);
+                    $grid->column('companys.username', '企业会员')->width(200);
+                    $grid->oid('订单号')->width(200);
+                    $grid->created_at('申请时间');
+                    $grid->payment_cn('支付方式')->width(150);
+                    $grid->disableActions();
+                    $grid->disableTools();
+                    $grid->setName($key);
+//                    $tab_content[$key] = $grid;
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+                    break;
+                case 'increment':
+                    $grid = new Grid(new Order);
+                    $grid->model()->where('uid', $id)->where('uid', $id)->where('utype', 1)->when(get_subsite_id()>0, function ($querys) {
+                        $querys->whereHas('companys', function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    });
+                    $grid->id('ID');
+                    $grid->service_name('服务内容');
+                    $grid->column('companys.companyname', '企业名称');
+                    $grid->column('companys.username', '申请会员');
+                    $grid->amount('金额');
+                    $grid->created_at('申请时间');
+                    $grid->disableActions();
+                    $grid->disableTools();
+                    $grid->setName($key);
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+//                    $tab_content[$key] = $grid;
+                    break;
+                case 'down_resume':
+                    $grid = new Grid(new CompanyDownResume);
+                    $grid->model()->where('company_uid', $id)->whereHas('resumes');
+                    $grid->id('ID');
+                    $grid->column('resumes.fullname', '姓名');
+                    $grid->column('resumes.birthdate', '年龄')->display(function ($birthdate) {
+                        return date('Y')-$birthdate;
+                    });
+                    $grid->column('resumes.sex_cn', '性别');
+                    $grid->column('resumes.education_cn', '学历');
+                    $grid->column('resumes.experience_cn', '工作经验');
+                    $grid->column('resumes.wage_cn', '期望薪资');
+                    $grid->down_addtime('下载时间')->display(function ($down_addtime) {
+                        return date('Y-m-d H:i:s', $down_addtime);
+                    });
+                    $grid->disableActions();
+                    $grid->disableTools();
+                    $grid->setName($key);
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+//                    $tab_content[$key] = $grid;
+                    break;
+                case "apply":
+                    $grid = new Grid(new PersonalJobsApply);
+                    $grid->model()->where('company_id', $id)->whereHas('resumes');
+                    $grid->id('ID');
+                    $grid->column('resumes.fullname', '姓名');
+                    $grid->column('resumes.birthdate', '年龄')->display(function ($birthdate) {
+                        return date('Y')-$birthdate;
+                    });
+                    $grid->column('resumes.sex_cn', '性别');
+                    $grid->column('resumes.education_cn', '学历');
+                    $grid->column('resumes.experience_cn', '工作经验');
+                    $grid->column('jobs_name', '应聘职位');
+                    $grid->column('created_at', '投递时间');
+                    $grid->disableActions();
+                    $grid->disableTools();
+                    $grid->setName($key);
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+                    //$grid->model()->eloquent()->withPath('aaa');
+//                    $tab_content[$key] = $grid;
+                    break;
+                case "interview":
+                    $grid = new Grid(new CompanyInterView);
+                    $grid->model()->where('company_id', $id)->whereHas('resumes');
+                    $grid->id('ID');
+                    $grid->column('resumes.fullname', '姓名');
+                    $grid->column('resumes.birthdate', '年龄')->display(function ($birthdate) {
+                        return date('Y')-$birthdate;
+                    });
+                    $grid->column('resumes.sex_cn', '性别');
+                    $grid->column('resumes.education_cn', '学历');
+                    $grid->column('resumes.experience_cn', '工作经验');
+                    $grid->column('resumes.wage_cn', '期望薪资');
+                    $grid->column('interview_time', '面试时间')->display(function ($interview_time) {
+                        return date('Y-m-d H:i:s', $interview_time);
+                    });
+                    $grid->disableActions();
+                    $grid->disableTools();
+//                    $tab_content[$key] = $grid;
+                     $grid->setName($key);
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+                    break;
+                case 'companyimg':
+                    $grid = new Grid(new CompanyImg);
+                    $grid->model()->where('company_id', $id)->when(get_subsite_id()>0, function ($query) {
+                        $query->where('subsite_id', get_subsite_id());
+                    })->whereHas('companys')->orderByRaw('field(audit,0,2,1,3)')->orderBy('created_at', 'desc');
+                    $grid->id('ID');
+                    $grid->image()->image();
+                    $grid->company_id('企业名称')->display(function ($company_id) {
+                        $companyname = Company::where('id', $company_id)->select(['companyname'])->first();
+                        return $companyname['companyname'];
+                    })->width(200);
+                    $grid->audit('审核状态')->display(function ($audit) {
+                        switch ($audit) {
+                            case 1:
+                                return '<span style="color:#009900">审核通过</span>';
+                                break;
+                            case 2:
+                                return '<span style="color:#FF6600">审核中</span>';
+                                break;
+                            case 3:
+                                return '<span style="color:#FF0000">审核未通过</span>';
+                                break;
+                            case 0:
+                                return '<span style="color:#FF6600">未审核</span>';
+                                break;
+                        }
+                    });
+                    $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+                        if ($subsite_id == 0) {
+                            return "总站";
+                        } else {
+                            $subsite = Subsite::findOrFail($subsite_id);
+                            return $subsite->sitename;
+                        }
+                    });
+                    $grid->created_at('添加时间');
+                    $grid->disableActions();
+                    $grid->disableTools();
+                    $grid->setName($key);
+                    $grid->setPaginatorBaseUrl($key);
+                    $grid->disableRowSelector();
+                    break;
+            }
+
+            if (!empty($grid)){
+                $tab->add($val, view('admin.company.content')->with(['contents'=>$grid,'form'=>$form,'memberSetform'=>$memberSetform] ), $type == $key);
+            }
+
+
+        }
+
+        return $content
+            ->header('企业信息')
+            ->description('列表')
+            ->body($tab->render());
+    }
+
+    public function update($id,MemberPointRepository $memberPointRepository){
+
+        $data = $this->PointeditForm($id)->getValidateInput();
+
+        if($data['points']){
+            if ($data['regpoints'] == 1) {
+                //增加积分
+                $pointData['points'] = $data['points'];
+                if (false == $memberPointRepository->reportDeal($id, 1, 1, $data['points'])) {
+
+                      admin_toastr('企业增加积分失败', 'error');
+                }
+
+            } else {
+                //减少积分
+                if (false == $memberPointRepository->reportDeal($id, 1, 2, $data['points'])) {
+
+                      admin_toastr('企业增加积分失败', 'error');
+                }
+            }
+        }
+
+        $amount = 0;
+        if ($data['is_money']) {
+            $amount = $data['amount'];
+
+            $company=Company::find($id);
+
+            $logData['log_uid'] = $id;
+            $logData['log_utype'] = 1;
+            $logData['log_username'] = $company->username;
+            $logData['log_value'] = "操作人:".Admin::user()->username.",说明:修改会员:{$company->username},(+{$data['points']})积分,收到".$amount."元。";
+            $logData['log_amount'] = $amount;
+            $logData['log_ismoney'] = $data['is_money'];
+            $logData['log_type'] = 2;
+            $logData['log_mode'] = 1;
+            if (!MembersChargeLog::create($logData)) {
+                admin_toastr('企业增加记录失败', 'error');
+            }
+        }
+
+
+
+        admin_toastr('积分修改成功', 'success');
+        return back();
+
+
+
+    }
+
+    //积分表单
+    public function PointeditForm(){
+        Permission::check('company_comBusiness_points');
+        $form = new ValidateForm(new Company);
+
+
+        $form->radio('regpoints', '管理积分')->options([0=>'减少', 1=>'增加' ])->default('1');
+        $form->number('points', '赠送数量')->min(0);
+
+
+        $form->switch('is_money', '是否收费');
+        $form->number('amount', '收费金额')->min(0);
+        return $form;
+    }
+
+    //套餐内容表单
+    public function eidtForm()
+    {
+
+        Permission::check('company_comBusiness_setmeal');
+
+        $form= new Form(new MembersSetmeal);
+
+
+
+            $form->display('id');
+            $form->display('companys.companyname', '企业名称');
+            $form->display('setmeal_name', '套餐名称');
+            $form->display('setmealtime', '服务时间')->with(function () {
+                return '起:'.date('Y-m-d H:i:s', $this->starttime).' ~ 止:'.($this->endtime ==0?"无限制":$this->endtime);
+            });
+            $form->datetime('endtime', '到期时间');
+//
+            $form->text('dayes', '服务天数')->help("默认为空表示不做修改,0为不限制,如填写3则延长3天,-3则减少3天");
+            $form->hidden('days', "服务天数");
+            $form->number('jobs_meanwhile', '在招职位数')->min(0);
+            $form->number('jobfair_num', '招聘会场次')->min(0);
+            $form->number('refresh_jobs_free', '职位免费刷新数')->min(0);
+            $form->number('download_resume', '下载简历数')->min(0);
+            $form->number('download_resume_max', '下载简历数上限')->min(0);
+            $form->number('companys.sms_num', '短信数')->min(0);
+            $form->radio('show_apply_contact', '收到简历的联系方式')->options([0=>'需下载',1=>'免费查看']);
+
+            $form->text('added', '其他说明');
+
+            $form->hidden('uid');
+            $form->hidden('utype');
+            $form->hidden('companys.username');
+            $form->hidden('starttime');
+
+
+            $form->hidden('setmeal')->default(2);
+
+
+        return $form;
+    }
+
+    //改变套餐的表单
+    public function eidtMemberSetForm()
+    {
+
+        Permission::check('company_comBusiness_setmeal');
+
+        $form= new Form(new MembersSetmeal);
+
+        $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
+
+        empty(\request('setmeal_id')) ? request()->offsetSet('setmeal_id', key($setmeal)) : "" ;
+
+        $form->radio('setmeal_id', '会员套餐')->options($setmeal)->default(key($setmeal))->rules(['required'], ['required'=>'请选择相应的会员套餐'])->setMustMark();
+
+        $form->switch('is_money', '是否已收费');
+        $form->text('amount', '收费金额');
+        $form->hidden('setmeal')->default(1);
+
+
+
+        return $form;
+    }
+
+}

+ 282 - 0
app/Admin/Controllers/Company/CompanyTemplateController.php

@@ -0,0 +1,282 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Company;
+use App\Models\Tpl;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Storage;
+
+class CompanyTemplateController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content  $content)
+    {
+        return $content
+            ->header('企业模板')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('企业模板')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('企业模板')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+
+        return $content
+            ->header('企业模板')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Tpl);
+        $grid->model()->where('tpl_type', 1)->orderBy('id', 'desc');
+        $grid->id('ID');
+        $grid->images('模板缩略图')->image('', '150', '150');
+        $grid->name('模板名称')->width(200);
+        
+        $states = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'primary'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'default'],
+        ];
+        $grid->display('是否显示')->switch($states);
+        $grid->price('价格')->display(function ($display) {
+            return $display.'积分';
+        });
+
+        $grid->blade_name('压缩包名称');
+
+        $grid->created_at('创建时间')->sortable();
+
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('template_company_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('template_company_delete')) {
+                $actions->disableDelete(false);
+            }
+            $actions->disableView(true);
+        });
+
+        if (Admin::user()->can('template_company_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        if (Admin::user()->can('template_company_create')) {
+            $grid->disableCreateButton(false);
+        }
+
+        $grid->disableFilter();
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new Tpl);
+        
+        $form->text('name', '模板名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+        
+        $form->radio('display', '是否显示')->options([0=>'否',1=>'是'])->default(1);
+        $form->number('price','价格')->default(0)->min(0)->help('企业会员使用此模板需要支付的积分,0为免费');
+        $form->image('images','模板缩略图')->setWidth(8)->setMustMark()->options(['layoutTemplates' => ['actionDelete'=>'']]);
+
+        $form->file('blade_name','模板压缩包')->help('上传相同的ZIP压缩包会覆盖之前的文件!')->uniqueName()->setWidth(8)->setMustMark()->options(['layoutTemplates' => ['actionDelete'=>'']]);
+        
+        $form->saving(function (Form $form) use($id) {
+            $form->old_blade_name = Tpl::find($id)->blade_name;
+            if ($form->display=='on') {
+                $form->display=1;
+            } elseif ($form->display=='off') {
+                $form->display=0;
+            }
+        });
+
+        $form->saved(function (Form $form) {
+            if($form->blade_name!=null && $form->blade_name!='_file_del_'){
+                Storage::disk('public')->deleteDirectory('template/company/'.$form->old_blade_name);
+                $model = $form->model();
+                $new_blade = $model->blade_name;
+                $zip = new \Chumper\Zipper\Zipper();
+                $zip->zip(Storage::disk('public')->path($new_blade))->extractTo(Storage::disk('public')->path('template/company/'.$form->old_blade_name));
+                $zip->close();
+                $model->blade_name = $form->old_blade_name;
+                $model->save();
+                Storage::disk('public')->delete($new_blade);
+            }
+        });
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new Tpl);
+
+        $form->text('name', '模板名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+       
+        $form->radio('display', '是否显示')->options([0=>'否',1=>'是'])->default(1);
+        $form->number('price','价格')->default(0)->min(0)->help('企业会员使用此模板需要支付的积分,0为免费');
+        $form->image('images','模板缩略图')->setWidth(8)->setMustMark()->rules([
+            'required',
+        ]);
+        $form->file('blade_name','模板压缩包')->help('上传相同的ZIP压缩包会覆盖之前的文件!')->rules('mimes:zip')->uniqueName()
+            ->setWidth(8)->setMustMark()->rules([
+                'required',
+            ]);
+        
+        $form->saved(function (Form $form) {
+            $model = $form->model();
+            $new_blade = $model->blade_name;
+            $template_dir=uniqid();
+            $zip = new \Chumper\Zipper\Zipper();
+            $zip->zip(Storage::disk('public')->path($new_blade))->extractTo(Storage::disk('public')->path('template/company/'.$template_dir));
+            $zip->close();
+            $model->blade_name = $template_dir;
+            $model->save();
+            Storage::disk('public')->delete($new_blade);
+        });
+
+        return $form;
+    }
+
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Tpl);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+    
+    public function destroy($id)
+    {
+        if (!$id) {
+            $data = [
+                'status'  => false,
+                'message' => '模板不存在!!',
+            ];
+            return response()->json($data);
+        }
+        $id_arr =  explode(',', $id);
+        $blade_name = Tpl::whereIn('id', $id_arr)->pluck('blade_name')->toArray();
+        \DB::beginTransaction();
+        try {
+           Tpl::whereIn('id', $id_arr)->delete();
+           
+           if ($blade_name){
+               Company::whereIn('tpl', $blade_name)->update(['tpl'=>'default']);
+           }
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+    
+
+}

+ 161 - 0
app/Admin/Controllers/Company/CompanyTplController.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\CompanyTpl;
+use App\Models\Tpl;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class CompanyTplController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('企业模版')
+            ->description('列表')
+//            ->body($this->grid());
+            ->body(view('admin.companytpl.index')->with('grid', $this->grid()));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+
+            ->header('企业模版')
+            ->description('编辑')
+//            ->body($this->form()->edit($id));
+            ->body(view('admin.companytpl.edit')->with('form', $this->editForm()->edit($id)->render()));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new CompanyTpl);
+        $grid->id('ID');
+        $grid->column('companys.companyname', '企业名称');
+        $grid->column('companys.username', '用户名称');
+        $grid->column('tpls.images', '缩略图')->image();
+        $grid->created_at('添加时间');
+
+        $grid->actions(function ($actions) {
+            $actions->disableView();
+        });
+        $grid->filter(function ($filter) {
+            $filter->equal('uid', '企业ID');
+            $filter->equal('tplid', '模版ID');
+            $filter->like('companys.companyname', '企业名称');
+            $filter->like('companys.username', '用户名称');
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(CompanyTpl::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new CompanyTpl);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+
+    protected function editForm()
+    {
+
+        $form = new Form(new CompanyTpl);
+
+        $form->display('companys.username', '用户名');
+        $form->display('uid', '用户ID');
+        $form->display('tplid', '模版ID');
+        $form->file('tpls.images', '缩略图')->disable();
+
+        $form->tools(function ($tools) {
+            $tools->disableView();
+        });
+        $form->builder(function (Form $form) {
+            $form = new Form(new Tpl);
+            dd($form);
+        });
+        return $form;
+    }
+
+
+}

+ 440 - 0
app/Admin/Controllers/Company/ConsultantController.php

@@ -0,0 +1,440 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Admin\AdminRole;
+use App\Models\Admin\AdminUser;
+use App\Models\CompanyConsultant;
+use App\Models\Consultant;
+use App\Models\Subsite;
+use App\Validators\Rules\ChineseUsernameRule;
+use App\Validators\Rules\MobileRule;
+use App\Validators\Rules\QqRule;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Hash;
+
+class ConsultantController extends Controller
+{
+    use HasResourceActions;
+    
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @param $type_id
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('顾问管理')
+            ->description('列表')
+            ->body(view('admin.company.consultant')->with(['gird'=>$this->grid()->render()]));
+    }
+    
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('顾问管理')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+    
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('顾问管理')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+    
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('顾问管理')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+    
+    /**
+     * Make a grid builder.
+     *
+     * @param $type_id
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Consultant);
+        
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+            $query->whereHas('subsite',function ($query){
+                $query->where('effective', 1);
+            });
+        })->orderBy('id', 'desc');
+    
+        $grid->id('ID');
+        
+        $grid->name('顾问姓名')->width(200);
+        
+        $grid->mobile('顾问手机')->width(200);
+        
+        $grid->qq('顾问QQ')->width(200);
+
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            })->width(150);
+        }
+
+        $grid->created_at('创建时间')->sortable();
+    
+        $grid->updated_at('更新时间')->sortable();
+        
+    
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('company_consultant_set')) {
+                $url=route("consultant.list",['id'=>$actions->row['id']]);
+                $actions->prepend("<button class='btn btn-xs'><a target='_blank' href='{$url}'  >关联企业</a></button>");
+            }
+            if (Admin::user()->can('company_consultant_list_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('company_consultant_list_delete')) {
+                $actions->disableDelete(false);
+            }
+            $actions->disableView(true);
+        });
+    
+        if (Admin::user()->can('company_consultant_list_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+    
+        if (Admin::user()->can('company_consultant_list_create')) {
+            $grid->disableCreateButton(false);
+        }
+    
+        $grid->disableFilter();
+        return $grid;
+    }
+    
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new Consultant);
+        $Con = Consultant::whereHas('adminUser')->find($id);
+        $form->text('name', '姓名')->rules([
+            'required', new ChineseUsernameRule()
+        ])->setWidth(3)->setMustMark();
+    
+        $form->mobile('mobile', '手机')->rules([
+            'required', new MobileRule()
+        ])->setWidth(4)->setMustMark();
+    
+        $form->text('telephone', '电话')->setWidth(3);
+    
+        $form->text('qq', 'QQ')->rules([
+            'required', new QqRule()
+        ])->setWidth(3)->setMustMark();
+        $no_user = AdminUser::whereDoesntHave('consultant')->pluck('username','id')->toArray();
+        $default = 0;
+        if($Con){
+            $no_user[$Con->adminUser->id] = $Con->adminUser->username;
+            $default = $Con->adminUser->id;
+        }
+      
+        $form->select('admin_users_id','绑定用户')->options($no_user)->default($default)->setWidth(3);
+        
+        $form->image('avatar', '照片')->setWidth(3);
+    
+        $form->saving(function (Form $form){
+            if(!$form->admin_users_id){
+                $form->admin_users_id=0;
+            }
+        });
+        
+        if (get_subsite_open()) {
+            if (get_subsite_id() == 0) {
+                //添加所属分站
+                $form->radio('subsite_id', '所属分站')
+                    ->options(array_column(get_all_subsite(), 'sitename', 'id'))
+                    ->default(0)->setWidth(6);
+            }
+        }
+        
+        return $form;
+    }
+    
+    protected function createForm()
+    {
+        $form = new Form(new Consultant);
+        
+        $form->text('name', '姓名')->rules([
+            'required', new ChineseUsernameRule()
+        ])->setWidth(3)->setMustMark();
+        
+        $form->mobile('mobile', '手机')->rules([
+            'required', new MobileRule()
+        ])->setWidth(4)->setMustMark();
+        
+        $form->text('telephone', '电话')->setWidth(3);
+        
+        $form->text('qq', 'QQ')->rules([
+            'required', new QqRule()
+        ])->setWidth(3)->setMustMark();
+        
+        $form->select('admin_users_id','绑定用户')->options(AdminUser::whereDoesntHave('consultant')->pluck('username','id'))->setWidth(3);
+        
+        $form->image('avatar', '照片')->setWidth(3);
+        
+        $form->saving(function (Form $form){
+            if(!$form->admin_users_id){
+                $form->admin_users_id=0;
+            }
+        });
+        
+        if (get_subsite_open()) {
+            if (get_subsite_id() == 0) {
+                //添加所属分站
+                $form->radio('subsite_id', '所属分站')->options(array_column(get_all_subsite(), 'sitename', 'id'))->default(0)->setWidth(6);
+            }else{
+                $form->hidden('subsite_id')->default(get_subsite_id());
+            }
+        }
+        
+        return $form;
+    }
+    
+    
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    
+    
+    public function destroy($id)
+    {
+        if (!$id) {
+            $data = [
+                'status'  => false,
+                'message' => '顾问不存在!!',
+            ];
+            return response()->json($data);
+        }
+        $id_arr =  explode(',', $id);
+        
+        \DB::beginTransaction();
+        try {
+            Consultant::destroy($id_arr);
+            CompanyConsultant::whereIn('consultant_id', $id_arr)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+    
+    
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Consultant::findOrFail($id));
+        
+        return $show;
+    }
+    
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Consultant);
+        
+        $form->display('ID');
+        $form->switch('status');
+        $form->text('points', '积分');
+        $form->text('times', '每天赠送积分上限');
+        $form->display('Created at');
+        $form->display('Updated at');
+        
+        return $form;
+    }
+    
+    public function consultantList(Content $content)
+    {
+        $username = '';
+        $qq = '';
+        $id = request()->id;
+        if(empty($id)){
+            admin_toastr('顾问不存在!', 'error');
+            return back();
+        }
+        $grid = new Grid(new CompanyConsultant);
+        
+        $grid->model()->whereHas('companys')->whereHas('consultants')->where('consultant_id', $id)->orderBy('id', 'desc');
+        
+        $grid->column('companys.username','用户名')->display(function ($username){
+            return $username ? $username : '未填写';
+        });
+    
+        $grid->column('companys.companyname','企业信息')->display(function ($companyname){
+            if($companyname){
+                return '<a href="/content/jobs/company?id='.$this->company_id.'" target="_blank">'.$companyname.'</a>';
+            }else{
+               return '未填写';
+            }
+        });
+    
+        $grid->column('companys.audit','审核状态')->display(function ($audit){
+            if ($audit==3) {
+                return'<span style="color:#666666">审核未通过</span>';
+            } elseif ($audit==1) {
+                return'<span style="color: #009900">审核通过</span>';
+            } else {
+                return'<span style="color:#FF6600">等待审核</span>';
+            }
+        });
+        
+        $grid->column('companys.mobile','手机')->display(function ($mobile){
+             return $mobile ? $mobile : '未填写';
+        });
+        
+        $grid->column('companys.email','邮箱')->display(function ($email){
+            return $email ? $email : '未填写';
+        });
+    
+        $grid->column('companys.reg_time','注册时间')->display(function ($reg_time){
+            return $reg_time ? date('Y-m-d H:i:s', $reg_time) : '';
+        })->sortable();
+        
+        $grid->column('companys.last_login_time','最后登录时间')->display(function ($last_login_time){
+            return $last_login_time ? date('Y-m-d H:i:s', $last_login_time) : '';
+        })->sortable();
+        $Consultant = Consultant::find($id);
+        if($Consultant){
+          $username = $Consultant->name;
+          $qq = $Consultant->qq;
+        }
+        
+        $grid->filter(function ($filter) {
+        
+            $filter->column(1/2, function ($filter) {
+                $filter->like('companys.username', '用户名');
+                $filter->like('companys.companyname', '企业信息');
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('companys.mobile', '手机');
+                $filter->like('companys.email', '邮箱');
+            });
+        });
+        
+        
+        $grid->actions(function ($actions){
+            $actions->disableView();
+            if (Admin::user()->can('company_consultant_reset')) {
+                $actions->append("<button class='btn btn-xs btn-primary consultant_reset' ls='".$actions->row['id']."'>重置</button>");
+            }
+        });
+    
+        $grid->tools(function ($tools){
+            if (Admin::user()->can('company_consultant_reset')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="consultant_reset_list" title="重置顾问">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">重置顾问
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+        return $content
+            ->header('顾问列表')
+            ->description('顾问姓名:'.$username.',顾问QQ:'.$qq)
+            ->body(view('admin.company.consultant_list')->with(['gird'=>$grid->render()]));
+    }
+    
+    public function consultantReset(Request $request)
+    {
+        $id = $request->id;
+        $arr_id = array_filter(explode(',', $id));
+        if(empty($arr_id)){
+            return response()->json(['code'=>0,'info'=>'请勾选需要重置的会员']);
+        }
+        $result = CompanyConsultant::destroy($arr_id);
+        if($result){
+            return response()->json(['code'=>1,'info'=>'重置成功!']);
+        }else{
+            return response()->json(['code'=>0,'info'=>'重置失败!']);
+        }
+    }
+    
+    
+}

+ 267 - 0
app/Admin/Controllers/Company/HomeTemplateController.php

@@ -0,0 +1,267 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Subsite;
+use App\Models\Tpl;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Storage;
+
+class HomeTemplateController extends Controller
+{
+    use HasResourceActions;
+    
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content  $content)
+    {
+        return $content
+            ->header('首页模板')
+            ->description('列表')
+            ->body($this->grid());
+    }
+    
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('首页模板')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+    
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('首页模板')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+    
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        
+        return $content
+            ->header('首页模板')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+    
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Tpl);
+        $grid->model()->where('tpl_type', 4)->orderBy('id', 'desc');
+        $grid->id('ID');
+        $grid->images('模板缩略图')->image('', '150', '150');
+        $grid->name('模板名称')->width(200);
+        
+        $grid->blade_name('压缩包名称');
+        
+        $grid->created_at('创建时间')->sortable();
+        
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('template_home_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('template_home_delete')) {
+                $actions->disableDelete(false);
+            }
+            $actions->disableView(true);
+        });
+        
+        if (Admin::user()->can('template_home_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+        
+        if (Admin::user()->can('template_home_create')) {
+            $grid->disableCreateButton(false);
+        }
+        
+        $grid->disableFilter();
+        return $grid;
+    }
+    
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+    
+    }
+    
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new Tpl);
+        
+        $form->text('name', '模板名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+        
+        $form->image('images','模板缩略图')->setWidth(8)->setMustMark()->options(['layoutTemplates' => ['actionDelete'=>'']]);
+        
+        $form->file('blade_name','模板压缩包')->help('上传相同的ZIP压缩包会覆盖之前的文件!')->uniqueName()->setWidth(8)->setMustMark()->options(['layoutTemplates' => ['actionDelete'=>'']]);
+        
+        $form->saving(function (Form $form) use($id) {
+            $form->old_blade_name = Tpl::find($id)->blade_name;
+        });
+        
+        $form->saved(function (Form $form) {
+            if($form->blade_name!=null && $form->blade_name!='_file_del_'){
+                Storage::disk('public')->deleteDirectory('template/home/'.$form->old_blade_name);
+                $model = $form->model();
+                $new_blade = $model->blade_name;
+                $zip = new \Chumper\Zipper\Zipper();
+                $zip->zip(Storage::disk('public')->path($new_blade))->extractTo(Storage::disk('public')->path('template/home/'.$form->old_blade_name));
+                $zip->close();
+                $model->blade_name = $form->old_blade_name;
+                $model->save();
+                Storage::disk('public')->delete($new_blade);
+            }
+        });
+        return $form;
+    }
+    
+    protected function createForm()
+    {
+        $form = new Form(new Tpl);
+        
+        $form->text('name', '模板名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+        
+        $form->image('images','模板缩略图')->setWidth(8)->setMustMark()->rules([
+            'required',
+        ]);
+        $form->file('blade_name','模板压缩包')->help('上传相同的ZIP压缩包会覆盖之前的文件!')->rules('mimes:zip')->uniqueName()
+            ->setWidth(8)->setMustMark()->rules([
+                'required',
+            ]);
+        $form->hidden('tpl_type')->default(4);
+    
+        $form->hidden('display')->default(1);
+        $form->hidden('price')->default(0);
+        
+        $form->saved(function (Form $form) {
+            $model = $form->model();
+            $new_blade = $model->blade_name;
+            $template_dir=uniqid();
+            $zip = new \Chumper\Zipper\Zipper();
+            $zip->zip(Storage::disk('public')->path($new_blade))->extractTo(Storage::disk('public')->path('template/home/'.$template_dir));
+            $zip->close();
+            $model->blade_name = $template_dir;
+            $model->save();
+            Storage::disk('public')->delete($new_blade);
+        });
+        
+        return $form;
+    }
+    
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    
+    
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Tpl);
+        
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+        
+        return $form;
+    }
+    
+    public function destroy($id)
+    {
+        if (!$id) {
+            $data = [
+                'status'  => false,
+                'message' => '模板不存在!!',
+            ];
+            return response()->json($data);
+        }
+        $id_arr =  explode(',', $id);
+        
+        \DB::beginTransaction();
+        try {
+            Tpl::whereIn('id', $id_arr)->delete();
+            
+            Subsite::whereIn('tpl', $id_arr)->update(['tpl'=>0]);
+            
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+    
+    
+}

+ 143 - 0
app/Admin/Controllers/Company/InvoiceCategoryController.php

@@ -0,0 +1,143 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\InvoiceCategory;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class InvoiceCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        Permission::check('invoice_manager_category');
+        return $content
+            ->header('发票分类')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('发票分类')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('发票分类')
+            ->description('新增')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('invoice_manager_category');
+        $grid = new Grid(new InvoiceCategory);
+        $grid->model()->orderby('id', 'asc');
+        $grid->categoryname('分类名称')->editable();
+        $grid->admin_set('类型')->display(function ($admin_set) {
+            if ($admin_set == 1) {
+                return '系统设置';
+            }
+        });
+        $grid->category_order('分类排序')->editable();
+        $grid->created_at('添加时间');
+
+        $grid->disableFilter();
+        if (Admin::user()->can('invoice_manager_category_add')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('invoice_manager_category_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(InvoiceCategory::findOrFail($id));
+
+        $show->admin_set('类型')->as(function ($admin_set) {
+            if ($admin_set == 1) {
+                return '系统设置';
+            }
+        });
+        $show->category_order('分类排序')->editable();
+        $show->created_at('添加时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new InvoiceCategory);
+
+        $form->text('categoryname', '分类名称');
+        $form->text('category_order', '分类排序');
+        return $form;
+    }
+}

+ 377 - 0
app/Admin/Controllers/Company/InvoiceController.php

@@ -0,0 +1,377 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Invoice;
+use App\Models\InvoiceCategory;
+use App\Models\Order;
+use App\Services\Common\PmsService;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class InvoiceController extends Controller
+{
+    use HasResourceActions;
+
+    protected $pmsService;
+    /**
+     * InvoiceController constructor.
+     * @param $pmsService
+     */
+    public function __construct(PmsService $pmsService)
+    {
+        $this->pmsService = $pmsService;
+    }
+
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('发票列表')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('修改')
+            ->description('description')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('invoice_manager_index');
+        $grid = new Grid(new Invoice);
+        $grid->model()->when(get_subsite_id()>0, function ($querys) {
+            $querys->whereHas('companys', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->orderByRaw('audit asc, created_at desc');
+        $grid->cid('服务名称')->display(function ($cid) {
+            $list = InvoiceCategory::list()->pluck('categoryname', 'id');
+            foreach ($list as $key => $value) {
+                if ($cid == $key) {
+                    return $value;
+                }
+            }
+        });
+        $grid->audit('处理状态')->display(function ($audit) {
+            switch ($audit) {
+                case 0:
+                    return "<span style='color:green'>未开票</span>";
+                    break;
+                case 1:
+                    return "<span style='color:#55acee'>已开票</span>";
+                    break;
+                case 2:
+                    return "<span style='color:red'>取消</span>";
+                    break;
+            }
+        });
+        $grid->title('发票抬头')->display(function ($title) {
+            switch ($title) {
+                case 1:
+                    return "企业";
+                    break;
+                case 2:
+                    return "个人";
+                    break;
+            }
+        });
+        $grid->oid('订单号');
+        $grid->order_num('金额')->display(function ($order_num){
+            return Order::where('id',$order_num)->value('amount');
+        });
+        $grid->organization('单位名称');
+        $grid->addressee('收件人');
+        $grid->mobile('收件人电话');
+        $grid->address('邮寄地址');
+        $grid->postcode('邮编');
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('invoice_manager_index_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('invoice_manager_index_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        $grid->filter(function ($filter) {
+            $filter->column(1/2, function ($filter) {
+                $filter->where(function ($query) {
+                    $query->whereHas('companys', function ($query) {
+                        $query->where('companyname', 'like', "%{$this->input}%");
+                    });
+                }, '公司名称');
+                $filter->like('addressee', '收件人');
+                $filter->equal('uid', '会员ID');
+                $filter->between('created_at', '添加时间')->datetime();
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('audit', '处理状态')->select([0=>'未开票',1=>'已开票',2=>'取消']);
+                $filter->equal('title', '发票抬头')->select(['1'=>'企业','2'=>'个人']);
+
+                $filter->equal('cid', '发票内容')->select(
+                    InvoiceCategory::list()->pluck('categoryname', 'id')
+                );
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Invoice::findOrFail($id));
+
+        $show->cid('服务名称')->as(function ($cid) {
+            $list = InvoiceCategory::list()->pluck('categoryname', 'id');
+            foreach ($list as $key => $value) {
+                if ($cid == $key) {
+                    return $value;
+                }
+            }
+        });
+
+        $show->audit('处理状态')->as(function ($audit) {
+            switch ($audit) {
+                case 0:
+                    return "未开票";
+                    break;
+                case 1:
+                    return "已开票";
+                    break;
+                case 2:
+                    return "取消";
+                    break;
+            }
+        });
+        $show->title('发票抬头')->as(function ($title) {
+            switch ($title) {
+                case 1:
+                    return "企业";
+                    break;
+                case 2:
+                    return "个人";
+                    break;
+            }
+        });
+        $show->organization('单位名称');
+        $show->addressee('收件人');
+        $show->deposit_bank('开户行');
+        $show->account('开户账号');
+        $show->mobile('收件人电话');
+        $show->address('邮寄地址');
+        $show->postcode('邮编');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Invoice);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+    protected function editForm()
+    {
+        Permission::check('invoice_manager_index_edit');
+        $form = new Form(new Invoice);
+        $form->html("<h4>订单信息</h4>");
+        $form->display('orders.is_pay', '支付状态')->with(function ($is_pay) {
+            switch ($is_pay) {
+                case 3:
+                    return "已取消";
+                    break;
+                case 1:
+                    return '待支付';
+                    break;
+                case 2:
+                    return '已支付';
+                    break;
+            }
+        });
+        $form->display('orders.uid', '申请充值会员');
+        $form->display('orders.amount', '订单金额');
+        $form->display('orders.pay_amount', '现金支付金额');
+        $form->display('orders.pay_points', '积分支付额');
+        $form->display('orders.order_type', '订单类型')->with(function ($order_type) {
+            $arr = [
+                1=>"套餐升级",
+                2=>"充值积分",
+                3=>"简历置顶",
+                4=>"醒目标签",
+                5=>"简历模板",
+                6=>"简历包",
+                7=>"短信包",
+                8=>"职位置顶",
+                9=>"职位紧急",
+                10=>"企业模板",
+                12=>"预约刷新职位",
+                13=>"职位刷新",
+                14=>"简历下载"
+            ];
+            foreach ($arr as $key => $val) {
+                if ($key == $order_type) {
+                    return $val;
+                }
+            }
+        });
+        $form->display('orders.payment_cn', '支付方式');
+        $form->display('orders.oid', '订单号');
+        $form->display('orders.created_at', '申请时间');
+        $form->display('orders.payment_time', '支付时间')->with(function ($payment_time) {
+            return date('Y-m-d H:i:s', $payment_time);
+        });
+        $form->display('orders.notes', '备注');
+        $form->html("<h4>发票信息</h4>");
+
+        $form->display('cid', '发票内容')->with(function ($cid) {
+            $list = InvoiceCategory::list()->pluck('categoryname', 'id');
+            foreach ($list as $key => $value) {
+                if ($cid == $key) {
+                    return $value;
+                }
+            }
+        });
+        $form->display('organization', '发票抬头');
+        $form->display('addressee', '收件人');
+        $form->display('deposit_bank', '开户行');
+        $form->display('account', '开户账号');
+        $form->display('tax_number', '信用代码证号');
+        $form->display('mobile', '手机号');
+        $form->display('address', '邮寄地址');
+        $form->display('postcode', '邮寄地址');
+        $form->radio('audit', '审核状态')->options([1=>'已开票', 2=>'取消', 0=>'未开票'])->attribute('class', 'audit');
+        $form->text('reason', '取消原因')->attribute('id', 'reason');
+        $js = <<<EOT
+        $('.audit').on('ifCreated',function(){
+            if(true == $(this).is(':checked')){
+                var audit = $(this).val();
+                if(audit == 2){
+                    $('#reason').closest(".form-group").css('display','block');
+                }else{
+                    $('#reason').closest(".form-group").css('display','none');
+                }
+            }
+        });
+        
+        $('.audit').on('ifChecked', function(){
+            var audit = $(this).val();
+            if(audit == 2){
+                $('#reason').closest(".form-group").css('display','block');
+            }else{
+                $('#reason').closest(".form-group").css('display','none');
+            }
+        });
+EOT;
+        Admin::script($js);
+        $form->saved(function (Form $form) {
+            $audit = $form->audit;
+            $reason = $form->reason?$form->reason:'无';
+            $html = '发票状态为:';
+            switch ($audit) {
+                case 1:
+                    $html .= "已开票";
+                    break;
+                case 2:
+                    $html .= "取消";
+                    break;
+                case 0:
+                    $html .= "未开票";
+                    break;
+            }
+
+            $insert_data = array(
+                'utype'      => 1,
+                'msgtype'    => 1,
+                'msgfromuid' => admin::user()->id,
+                'msgfrom'     => admin::user()->username,
+                'msgtoname'   =>getCompanyName($form->model()->orders->uid)->companyname,
+                'msgtouid'    => $form->model()->orders->uid,
+                'message'     => $html.',【备注】'.$reason,
+                'new'          => 1,
+                'created_at' =>date('Y-m-d H:i:s', time()),
+                'updated_at' =>date('Y-m-d H:i:s', time()),
+            );
+            $this->pmsService->addBatchPms($insert_data);
+        });
+
+        return $form;
+    }
+
+    public function update($id)
+    {
+        Permission::check('invoice_manager_index_edit');
+        return $this->editForm()->update($id);
+    }
+}

+ 972 - 0
app/Admin/Controllers/Company/JobsController.php

@@ -0,0 +1,972 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use Aix\Sms\Contracts\Smser;
+use App\Admin\Exports\Company\JobsExport;
+use App\Admin\Extensions\Tools\DialogTool;
+use App\Http\Controllers\Controller;
+use App\Models\Admin\AdminRole;
+use App\Models\AuditReason;
+use App\Models\Category;
+use App\Models\CategoryDistrict;
+use App\Models\CategoryJobs;
+use App\Models\Company;
+use App\Models\Jobs;
+use App\Models\JobsContact;
+use App\Models\Subsite;
+use App\Models\SubsiteJob;
+use App\Models\ViewJob;
+use App\Repositories\JobsRepository;
+use App\Services\Common\EmailService;
+use App\Services\Common\PmsService;
+use App\Services\Common\SmsService;
+use App\Services\Common\WechatService;
+use App\Services\SubsiteService;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Grid\Filter\TimestampBetween;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Encore\Admin\Widgets\Table;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Input;
+use Illuminate\Support\MessageBag;
+
+class JobsController extends Controller
+{
+
+    use HasResourceActions;
+
+    protected $jobsRepository;
+    protected $pmsService;
+    protected $subsiteService;
+    protected $smsService;
+    protected $wechatService;
+    protected $emailService;
+
+    /**
+     * JobsController constructor.
+     * @param JobsRepository $jobsRepository.
+     * @param SubsiteService $subsiteService.
+     * @param PmsService $pmsService.
+     */
+    public function __construct(JobsRepository $jobsRepository, PmsService $pmsService, SubsiteService $subsiteService, SmsService $smsService, WechatService $wechatService,EmailService $emailService)
+    {
+        $this->jobsRepository = $jobsRepository;
+        $this->pmsService = $pmsService;
+        $this->subsiteService = $subsiteService;
+        $this->smsService = $smsService;
+        $this->wechatService = $wechatService;
+        $this->emailService = $emailService;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content  $content)
+    {
+        $grid=$this->grid()->render();
+        return $content
+            ->header('职位管理')
+            ->description('列表')
+            ->body(view('admin.jobs.index')->with('grid', $grid));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('职位管理')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        $js = <<<ETO
+        $(document).ready(function() {
+             $('.radio-inline,.iCheck-helper').click(function() {
+                var val = $(this).closest(".radio-inline").find("input:radio").val();
+                 if (val == '0') {
+                    $("input[name=wage]").parents('.form-group').hide();
+                 }
+                 else if (val == '1') {
+                    $("input[name=wage]").parents('.form-group').show();
+                 }
+            });
+            if($("input:radio[name='negotiable']:checked").val() == '0')
+            {    
+                
+                $("input[name=wage]").parents('.form-group').hide();
+            } else {
+                $("input[name=wage]").parents('.form-group').show();
+            }
+        });
+ETO;
+        Admin::script($js);
+        return $content
+            ->header('职位管理')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('职位管理')
+            ->description('新增')
+            ->body($this->form($id = 0));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('jobs_manager');
+        $grid = new Grid(new Jobs);
+        $grid->model()->with(['jobsContact','company'])->when(get_subsite_id()>0, function ($query) {
+           $query->where('subsite_id', get_subsite_id());
+        })->when(Admin::user()->isRole(AdminRole::$consultantSlug), function ($query) {
+            $query->whereHas('companyConsultant',function ($query){
+                $query->where('consultant_id', isset(Admin::user()->consultant->id) ? Admin::user()->consultant->id : -1);
+            });
+        })->orderByRaw('field(audit,0,2,1,3)')->orderBy('created_at', 'desc');
+        $grid->id('id');
+        $grid->jobs_name('职位名称')->display(function ($jobs_name) {
+            return "<a href=".route(url_rewrite('AIX_jobsshow'), ['id'=>$this->id])." target='_blank' title='".$jobs_name."' style='display:inline-block;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;max-width:180px'>".$jobs_name."</a>";
+        })->width(200);
+        $grid->column('promition', '推广类型')->display(function ($promition) {
+            $stick = '';
+            $emergency = '';
+            if ($this->stick == 0 && $this->emergency == 0) {
+                return "<span>无推广</span>";
+            } else {
+                if ($this->stick == 1) {
+                    $stick = "<span>已置顶</span>";
+                }
+                if ($this->emergency == 1) {
+                    $emergency ='<span>已紧急</span>';
+                }
+                return $stick.$emergency;
+            }
+        });
+        $grid->company_name('公司名称')->display(function ($company_name) {
+            return "<a href=". route(url_rewrite('AIX_companyshow'), ['id'=>$this->company_id])." title='".$company_name."' target='_blank' style='display:inline-block;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;max-width:200px'>".$company_name."</a>";
+        })->width(200);
+        $grid->audit('审核状态')->display(function ($audit) {
+            switch ($audit) {
+                case 0:
+//                    return '未审核<a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+                    break;
+                case 1:
+                    return '<span style="color: green">审核通过</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+                    break;
+                case 2:
+                    return '<span style="color: red">审核中<a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a></span>';
+                    break;
+                case 3:
+                    return '<span style="color: black">审核未通过</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+                    break;
+            }
+        });
+        if(get_subsite_open()) {
+            $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+                if ($subsite_id == 0) {
+                    return "总站";
+                } else {
+                    try{
+                        $subsite = Subsite::findOrFail($subsite_id);
+                        return $subsite->sitename;
+                    }catch (\Exception $exception){
+                        return "--";
+                    }
+
+
+                }
+            });
+        }
+        $grid->refresh_time('刷新时间')->display(function ($refresh_time) {
+            return date('Y-m-d H:i:s', $refresh_time);
+        });
+        $grid->created_at('发布时间');
+
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('jobs_manager_refresh')) {
+                $tools->append("<a class='btn btn-sm btn-primary btn-refresh'><i class='fa fa-refresh'></i>职位刷新</a>");
+            }
+        });
+        $grid->click('点击量');
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('jobs_manager_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('company_manager_bussiness')) {
+                $actions->append("<button class='btn btn-primary btn-xs business' id=".$actions->row['company_id'].">业务</button>");
+            }
+            if (Admin::user()->can('jobs_manager_delete')) {
+                $actions->disableDelete(false);
+            }
+            if (Admin::user()->can('jobs_manager_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+        });
+        if (Admin::user()->can('jobs_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new JobsExport()); //传入自己在第1步创建的导出类
+        }
+
+        $grid->filter(function ($filter) {
+            // 在这里添加字段过滤器
+            $filter->column(1/2, function ($filter) {
+                $filter->like('jobs_name', '职位名称');
+                $filter->equal('company_id', '企业id');
+                $filter->equal('audit', '职位审核')->select(['1' => '审核通过', '2' => '审核中', '3' => '审核未通过']);
+                $filter->where(function ($query) {
+                    if ($this->input == '1') {
+                        $query->where(['stick'=>0,'emergency'=>0]);
+                    } elseif ($this->input==2) {
+                        $query->where(['stick'=>1]);
+                    } elseif ($this->input==3) {
+                        $query->where(['emergency'=>1]);
+                    }
+                }, '推广类型', 'promotion')->select([0 => '不限', 1 => '未推广', 2 => '置顶', 3 => '紧急'])->default('0');
+                $filter->equal('valid', '有效状态')->select(['0'=>'无效职位', '1'=>'有效职位']);
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('id', '职位ID');
+                $filter->like('company_name', '企业名称');
+               if(get_subsite_open()) {
+                   $subsite = Subsite::where('effective', 1)->select('id', 'sitename')->get();
+                   $subsiteArr = [];
+                   if ($subsite) {
+                       $subsiteArr = $subsite->toArray();
+                       $subsiteArr = array_column($subsiteArr, 'sitename', 'id');
+                   }
+                   $subsiteArr[0] = "总站";
+                   ksort($subsiteArr);
+                   if (get_subsite_id() == 0) {
+                       $filter->equal('subsite_id', '所属分站')->select($subsiteArr);
+                   }
+               }
+                $filter->between('created_at', '发布时间')->datetime();
+                $filter->use(new TimestampBetween('refresh_time', '刷新时间'))->datetime();
+            });
+        });
+        //审核模态框
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('jobs_manager_delete')) {
+                $tools->batch(function (Grid\Tools\BatchActions $batch) {
+                    $batch->disableDelete(false);
+                });
+            }
+            if (Admin::user()->can('jobs_manager_audit')) {
+                $form = new \Encore\Admin\Widgets\Form();
+                $form->action(route('jobs.audit'));
+                $form->radio('audit1', '审核状态')->options([1=>'审核通过', 3=>'审核未通过'])->default(1);
+                $states = [
+                    'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+                    'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+                ];
+                $form->textarea('reason', '备注');
+                $form->html("<input type='checkbox' name='is_send' checked value='1'/>站内信通知");
+                $config = array(
+                    'button' => "审核",//添加的按钮文字
+                    'title' => "将所选职位",//弹窗标题
+                    'dialog_cancel' => "取消",//取消文字
+                    'dialog_ok' => "确认",//确认文字
+                    'is_batch' => true//是否批量操作,如果是批量操作则提交表单时会带上ids参数
+                );
+                $tools->append(new DialogTool($form, $config));
+            }
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Jobs::findOrFail($id));
+        $jobs = Jobs::findOrFail($id);
+        $show->id('ID');
+        $show->jobs_name('职位名称');
+        $show->valid('在招状态')->as(function ($valid) {
+            switch ($valid) {
+                case 1:
+                    return "在招";
+                    break;
+                case 0:
+                    return '关闭';
+                    break;
+            }
+        });
+        $show->audit('审核状态')->as(function ($audit) {
+            switch ($audit) {
+                case 1:
+                    return "审核通过";
+                    break;
+                case 2:
+                    return "审核中";
+                    break;
+                case 3:
+                    return "审核未通过";
+                    break;
+                case 0:
+
+                    break;
+            }
+        });
+        $show->nature('职位性质')->as(function ($nature) {
+            if (!$nature) {
+                return '不限';
+            } else {
+                return get_category($nature);
+            }
+        });
+        $show->ygxs('用工形式')->as(function ($ygxs){
+            if (isset(Category::categoryType('AIX_ygxs')[$ygxs])){
+                return Category::categoryType('AIX_ygxs')[$ygxs];
+            }else{
+                return "";
+            }
+
+        });
+        $show->techlevel('技能等级')->as(function ($techlevel){
+            if (isset(Category::categoryType('AIX_techlevel')[$techlevel])){
+                return Category::categoryType('AIX_techlevel')[$techlevel];
+            }else{
+                return "";
+            }
+        });
+
+        if ($jobs->ygxs!=363){ //不等于小时工显示
+            $show->syq('试用期时间')->as(function ($syq){
+                if (isset(Category::categoryType('zs_syq')[$syq])){
+                    return Category::categoryType('zs_syq')[$syq];
+                }else{
+                    return "";
+                }
+
+            });
+            if ($jobs->syq!=367){ //试用期无不显示
+                $show->syqxz_min('试用期薪资');
+            }
+
+        }else{
+            $show->wage_min('小时工薪资')->as(function ($wage_min){
+
+                    return $wage_min."元/小时";
+
+            });
+        }
+
+        /**
+         * 比较坑的Show 关联,必须要全小写,如果你关联的和你获取名字一样那直接不显示....
+         **/
+
+        $show->jobscontact()->contact('联系人')->as(function ($contact) {
+            return $contact->contact;
+        });
+        $show->jobscontact()->contact_show('联系人是否公开')->as(function ($contact) {
+            return $contact->contact_show ? "公开" : "不公开";
+        });
+        $show->jobscontact()->telephone('电话')->as(function ($contact) {
+            return $contact->telephone;
+        });
+        $show->jobscontact()->telephone_show('电话是否公开')->as(function ($contact) {
+            return $contact->telephone_show ? "公开" : "不公开";
+        });
+        $show->jobscontact()->email('邮箱')->as(function ($contact) {
+            return $contact->email;
+        });
+        $show->jobscontact()->email_show('邮箱是否公开')->as(function ($contact) {
+            return $contact->email_show ? "公开" : "不公开";
+        });
+
+
+        $show->category('职位分类')->as(function ($category) {
+            return get_job_category_cn($this->topclass.'.'.$category.'.'.$this->subclass);
+        });
+        $show->subsite_id('所属分站')->as(function ($subsite_id) {
+            if ($subsite_id == 0) {
+                return "总站";
+            } else {
+                $subsite = Subsite::findOrFail($subsite_id);
+                return $subsite->sitename;
+            }
+        });
+        $show->district('工作地区')->as(function ($district) {
+            return get_district_cn($district);
+        });
+        $show->negotiable('是否面议')->as(function ($negotiable) {
+            if ($negotiable) {
+                return '是';
+            } else {
+                return '否';
+            }
+        });
+        if ($jobs->wage == -1) {
+            $show->wage_cn('薪资待遇')->as(function () {
+                return $this->wage_min.'~'.$this->wage_max.'/月';
+            });
+        } elseif ($jobs->wage == 0) {
+            $show->wage_cn('薪资待遇')->as(function () {
+                return "面议";
+            });
+        } else {
+            $show->wage_cn('薪资待遇')->as(function () {
+                return get_category($this->wage);
+            });
+        }
+        $show->department('所属部门');
+        $show->education('学历要求')->as(function ($education) {
+            if ($education) {
+                return get_category($education);
+            } else {
+                return '不限';
+            }
+        });
+        $show->experience('工作经验')->as(function ($experience) {
+            if ($experience) {
+                 return get_category($experience);
+            } else {
+                return '不限';
+            }
+        });
+
+        $show->sex('性别要求')->as(function ($sex) {
+            if (!$sex) {
+                return '不限';
+            } else {
+                return $sex==1?"男":"女";
+            }
+        });
+        $show->amount('招聘人数');
+        $show->tag('职位亮点')->as(function ($tag) {
+            $tagid = implode(',', $tag);
+            if ($tagid) {
+                return get_tag_cn($tagid);
+            } else {
+                return '';
+            }
+        });
+        $show->jobs_content('职位描述');
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        Permission::check('jobs_manager_edit');
+        $form = new Form(new Jobs);
+            $form->tab('职位信息', function (Form $form) use ($id) {
+                $jobsData = Jobs::where('id', $id)->select('audit','negotiable', 'age', 'topclass', 'category', 'subclass', 'district', 'wage', 'wage_min', 'wage_max')->first()->toArray();
+                session(["jobsData"=>$jobsData]);
+
+                if ($jobsData['district']) {
+                    $district = string_to_array('.', $jobsData['district']);
+                }
+                $form->display('id');
+                $form->text('jobs_name', '职位名称')->rules(['required'], ['required'=>'请填写职位名称'])->setMustMark();
+                $form->display('company_name', '公司名称');
+                $form->radio('display', '在招状态')->options([1=>'在招',2=>'关闭']);
+                $form->radio('audit', '审核状态')->options([1=>'审核通过',2=>'审核中',3=>'审核未通过']);
+                $jobsNature = Category::categoryType('AIX_jobs_nature');
+                $jobsNature[0] ='不限';
+                $form->radio('nature', '职位性质')->options($jobsNature);
+//                if (get_subsite_id()==0 && get_subsite_open()) {
+//                    $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+//                    if ($subsites) {
+//                        $relations = SubsiteJob::where(['jobs_id'=>$id])->get()->pluck('subsite_id')->toArray();
+//                        $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+//
+//                    }
+//                } else {
+//                    $form->hidden('relate_subsites');
+//                }
+//                $form->hidden('subsite_id')->value(get_subsite_id());
+
+//                $form->select('ygxs', '用工形式')->options(Category::categoryType('AIX_ygxs'))->setMustMark();
+//                $form->select('techlevel', '技能等级')->options(Category::categoryType('AIX_techlevel'))->setMustMark();
+
+
+                $form->select('topclass', '职位大类')->options(CategoryJobs::List()->pluck('name', 'id'))->load('category',admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位大类'))->setMustMark();
+                $form->select('category', '职位中类')->options(CategoryJobs::category($jobsData['topclass']))->load('subclass',admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位中类'))->setMustMark();
+                $form->select('subclass', '职位小类')->options(CategoryJobs::category($jobsData['category']))->rules('required', array('required'=>'请选择职位小类'))->setMustMark();
+                if (!empty($district)) {
+                    if (!isset($district[1])){$district[1]=""; $district[2]="";}//没有的话给默认值
+                    $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path('sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default($district[0])->setMustMark();
+                    $form->select('city', '所属城市')->options(CategoryDistrict::categoryDis($district[0]))->setWidth(3)->load('area', admin_base_path('sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default($district[1])->setMustMark();
+                    //$form->select('area', '所属县区')->default(0)->setWidth(3)->setMustMark();
+
+                } else {
+                    $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path('sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default(0)->setMustMark();
+                    $form->select('city', '所属城市')->setWidth(3)->load('area', admin_base_path('sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default(0)->setMustMark();
+                    //$form->select('area', '所属县区')->setWidth(3)->default(0)->setMustMark();
+
+                }
+
+
+//                $form->select('syq', '试用期时间')->options(Category::categoryType('zs_syq'))->rules('required', array('required'=>'请选择试用期时间'))->setMustMark();
+//                $form->number('syqxz_min', '试用期薪资')->min(config('aix.companyset.comset.com_set.wage_min'));
+
+                if ($jobsData['wage'] == 0) {
+                    $form->hidden('wage');
+                    $form->number('wage_min', '最低薪资')->min(config('aix.companyset.comset.com_set.wage_min'))->help("请填写大于".config('aix.companyset.comset.com_set.wage_min')."的10的倍数");
+                    $form->number('wage_max', '最高薪资')->help("请填写大于最低薪资的10的倍数");
+                } else {
+                    $option = Category::categoryType('AIX_wage');
+                    $option[-1] ='面议';
+                    $form->select('wage', '薪资待遇')->options($option)->default($jobsData['wage']);
+                    $form->hidden('wage_min');
+                    $form->hidden('wage_max');
+                }
+
+                $education = Category::categoryType('AIX_education');
+                $education['0']='不限';
+                $form->radio('education', '学历要求')->options($education);
+                $experience = Category::categoryType('AIX_experience');
+                $experience['0']="不限";
+                $form->radio('experience', '工作经验')->options($experience);
+                $form->radio('sex', '性别要求')->options([0=>'不限',1=>'男',2=>'女']);
+
+                $form->number('min_age', '最低年龄')->default(isset($jobsData['age'][0])?$jobsData['age'][0]:'')->min(16)->max(65)->help('最低年龄不能低于国家规定用工年龄');
+                $form->number('max_age', '最高年龄')->default(isset($jobsData['age'][1])?$jobsData['age'][1]:'')->min(16)->max(65)->help('最高年龄不能高于65周岁');
+
+                $form->number('amount', '招聘人数')->min(1)->max(99)->rules(['required'], ['required'=>'请输入招聘人数'])->help('请填写招聘人数1~99')->setMustMark();
+                $form->multipleSelect('tag', '职位亮点')->options(Category::categoryType('AIX_jobtag'));
+                $form->textarea('jobs_content', '职位描述')->attribute(['maxlength'=>2000])->rules(['required'], ['required'=>"请填写职位描述"])->setMustMark();
+            })->tab('联系人', function (Form $form) {
+                $form->text("contact.contact", '联系人')->setWidth(3);
+                $form->radio('contact.contact_show', '联系人是否公开')->options([0=>'不公开',1=>'公开']);
+
+                $form->text('contact.telephone', '联系电话')->setWidth(3);
+                $form->radio('contact.telephone_show', '联系电话是否公开')->options([0=>'不公开',1=>'公开']);
+
+//                $form->text('contact.landline_tel', '固定电话')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)');  //这个字段引起问题
+//                $form->radio('contact.landline_tel_show', '固定电话是否公开')->options([0=>'不公开',1=>'公开']);
+
+                $form->text('contact.email', 'Email')->setWidth(3);
+                $form->radio('contact.email_show', 'Email是否公开')->options([0=>'不公开',1=>'公开']);
+
+                $form->text('contact.address', '联系地址')->setWidth(3);
+            });
+
+
+
+                $form->disableEditingCheck();
+                $form->disableCreatingCheck();
+                $form->disableViewCheck();
+                $form->disableReset();
+                $form->tools(function ($tools) {
+                    $tools->disableView();
+                    $tools->disableDelete();
+                });
+
+                $form->ignore('province');
+                $form->ignore('city');
+                $form->ignore('area');
+                $form->ignore('min_age');
+                $form->ignore('max_age');
+                $form->ignore(['relate_subsites']);
+                $form->saving(function (Form $form) {
+                    $minage = Input::get('min_age');
+                    $maxage = Input::get('max_age');
+                    if ($maxage && $minage) {
+                        if ($maxage <=$minage) {
+                            $error = new MessageBag([
+                                'title' => '提示',
+                                'message' => '最高年龄不能小最低年龄',
+                            ]);
+                            return back()->with(compact('error'));
+                        }
+                    }
+                    if ($form->wage == -1) {
+                        $form->wage_min = 0;
+                        $form->wage_max = 0;
+                    } else {
+                        if ($form->wage!=0) {
+                            $wage = explode('~', format_wage(get_category($form->wage)));
+                            if (isset($wage[1])) {
+                                $form->wage_max = $wage[1];
+                            }
+                            $form->wage_min = $wage[0];
+                        } else {
+                            if ($form->wage_min < config('aix.companyset.comset.com_set.wage_min')) {
+                                $error = new MessageBag([
+                                    'title'   => '提示',
+                                    'message' => '最低薪资请填写大于'.config('aix.companyset.comset.com_set.wage_min'),
+                                ]);
+                                return back()->with(compact('error'));
+                            }
+                            if ($form->wage_min%10 != 0) {
+                                $error = new MessageBag([
+                                    'title'   => '提示',
+                                    'message' => '薪资请填写10的倍数',
+                                ]);
+
+                                return back()->with(compact('error'));
+                            }
+                            if ($form->wage_max%10 != 0) {
+                                $error = new MessageBag([
+                                    'title'   => '提示',
+                                    'message' => '薪资请填写10的倍数',
+                                ]);
+
+                                return back()->with(compact('error'));
+                            }
+                            if (isset($form->wage_max) && $form->wage_max && $form->wage_max < $form->wage_min) {
+                                $error = new MessageBag([
+                                    'title' => '提示',
+                                    'message' => '最高薪资不能低于最低薪资',
+                                ]);
+
+                                return back()->with(compact('error'));
+                            }
+                        }
+                    }
+                    if (($form->min_age && !$form->max_age) || ($form->max_age && !$form->min_age)) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '请同时填写最高和最低年龄',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->min_age && $form->min_age < 16) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '最低年龄不能小于16岁',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->max_age && $form->min_age > 65) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '最高年龄不能大于65岁',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+
+
+                  if ($form->syqxz_min && $form->syqxz_min < $form->wage_min*0.8 ) {
+                      $error = new MessageBag([
+                          'title'   => '提示',
+                          'message' => '试用期薪资不得低于正式工资的80%',
+                      ]);
+
+                      return back()->with(compact('error'));
+
+                  }
+                  if($form->syq==367){//无试用期 就把工资清0
+                      $form->syqxz_min=null;
+                  }
+
+
+                });
+                $form->saved(function (Form $form) use ($id) {
+                    $province = \Illuminate\Support\Facades\Request::input('province');
+                    $city = \Illuminate\Support\Facades\Request::input('city');
+                    $area = \Illuminate\Support\Facades\Request::input('area');
+                    $district = $province.'.'.$city.'.'.$area;
+                    $age[] = \Illuminate\Support\Facades\Request::input('min_age');
+                    $age[] = \Illuminate\Support\Facades\Request::input('max_age');
+
+                    $age = implode('-', $age);
+
+                    $jobsData=session('jobsData');//记录修改前的数据
+
+                    if (!empty($jobsData)){
+                        if ($jobsData['audit'] != $form->model()->audit){//修改了审核状态
+                            //审核日志$reason
+                            $auditData= [];
+                            $auditData['ids'] = $id;
+                            $auditData['status'] = $form->model()->audit;
+                            $auditData['type'] = 3;
+                            $auditData['reason'] = "";
+                            AuditReason::addData($auditData);
+                        }
+                    }
+
+                    Jobs::where('id', $id)->update(['district'=>$district,'age'=>$age]);
+
+
+                    $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+                    if ($subsites) {
+                        $subsites = array_merge(array(get_subsite_id()), $subsites);
+                        SubsiteJob::where('jobs_id', $form->model()->id)->delete();
+                        $set_data = array();
+                        foreach ($subsites as $k => $v) {
+                            if ($v !== null) {
+                                $set_data[] = array(
+                                    'jobs_id' => $form->model()->id,
+                                    'subsite_id'=> $v,
+                                    'created_at'=> date('Y-m-d H:i:s'),
+                                    'updated_at'=> date('Y-m-d H:i:s'),
+                                );
+                            }
+                        }
+                        SubsiteJob::insert($set_data);
+                    }
+                });
+        return $form;
+    }
+    public function update($id)
+    {
+
+        $result = $this->editForm($id)->update($id);
+        event_search_update(Jobs::class, (string)$id, 'update');
+
+
+
+        $cids = Jobs::where('id', $id)->pluck('company_id')->toArray();
+        $company_condition = [['whereIn','id', $cids]];
+        event_search_update(Company::class, $company_condition, 'update');
+
+        return $result;
+    }
+
+    public function jobsAudit(Request $request)
+    {
+        $ids = $request->ids;
+        if (!$ids) {
+            return admin_toastr('请选择要审核的职位', 'error');
+        }
+        $id = explode(',', $ids);
+        $job_com_ids =$this->jobsRepository->findWhereIn('id', $id, ['company_id','id','jobs_name'])->toArray();
+
+        $reason = $request->reason;
+        $audit = $request->audit1;
+        $data = ['audit'=>$audit];
+        if (Jobs::jobsUpdate($id, $data)) {
+            event_search_update(Jobs::class, implode(',', $id), 'update');
+
+            if ($job_com_ids) {
+                $company_ids = [];
+                foreach ($company_ids as $k => $c) {
+                    $company_ids[] = $c['company_id'];
+                }
+                $company_condition = [['whereIn','id', $company_ids]];
+                event_search_update(Company::class, $company_condition, 'update');
+            }
+            switch ($request->audit1) {
+                case 1:
+                    $html = "通过审核";
+                    $alias=Smser::TEMPLATE_SMS_JOBSALLOW;
+                    break;
+                case 3:
+                    $html = "未通过审核";
+                    $alias=Smser::TEMPLATE_SMS_JOBSNOTALLOW;
+
+                    break;
+            }
+
+//            if ($job_com_ids) {
+//                $company_ids = [];
+//                foreach ($job_com_ids as $k => $c) {
+//                    $company_ids[] = $c['company_id'];
+//                    $company = Company::find($c['company_id']);
+//                    $this->wechatService->sendTemplateMessage($company, 'set_jobsallow',[
+//                        'keyword1'=>[$c['jobs_name'],'#0000ff'],
+//                        'keyword2'=>[$html,$css],
+//                        'keyword3'=>[$reason,'#0000ff'],
+//                    ],route('mobile.firm.jobs.list'));
+//
+//                    if($company->email){
+//                        $this->emailService->sendMail($company->email, $email, ['jobsname'=>$c['jobs_name']], ['jobsname'=>$c['jobs_name'],'sitedomain'=>route('com.index')]);
+//                    }
+//
+//                }
+//                $company_condition = [['whereIn','id', $company_ids]];
+//                event_search_update(Company::class, $company_condition, 'update');
+//            }
+            $mobile = [];
+            foreach ($id as $key => $val) {
+                $jobsInfo = Jobs::with('jobsContact')->find($val);
+                if ($jobsInfo->jobsContact && $jobsInfo->jobsContact->telephone) {
+                    if(!in_array($jobsInfo->jobsContact->telephone, $mobile)){
+                        $mobile[] = $jobsInfo->jobsContact->telephone;
+                        $this->smsService->sendSms($jobsInfo->jobsContact->telephone, $alias, ['sitename'=>config('aix.system.site.site.site_name'),'jobsname'=>$jobsInfo->jobs_name,'sitedomain'=>config('aix.system.site.site.site_domain')]);
+                    }
+                }
+            }
+
+            //审核日志$reason
+            $auditData= [];
+            $auditData['ids'] = $id;
+            $auditData['status'] = $audit;
+            $auditData['type'] = 3;
+            $auditData['reason'] = $reason;
+            AuditReason::addData($auditData);
+            if ($request->is_send) {
+                // 站内信
+                $insertData = [];
+
+                foreach ($job_com_ids as $key => $val) {
+                    $insertData[$key] = array(
+                        'utype'      => 1,
+                        'msgtype'    => 1,
+                        'msgfromuid' => admin::user()->id,
+                        'msgfrom'     => admin::user()->username,
+                        'msgtoname'   =>getComUserName($val['company_id']),
+                        'msgtouid'    => $val['company_id'],
+                        'message'     => '职位ID:'.$val['id'].',职位名称:'.$val['jobs_name'].','.$html.',【备注】'.$reason,
+                        'new'          => 1,
+                        'created_at' =>date('Y-m-d H:i:s', time()),
+                        'updated_at' =>date('Y-m-d H:i:s', time()),
+                    );
+                }
+                $this->pmsService->addBatchPms($insertData);
+            }
+            if($request->type) {
+                admin_toastr('职位审核成功', 'success');
+                return back();
+            } else{
+                return admin_toastr('职位审核成功', 'success');
+            }
+        } else {
+            if($request->type) {
+                admin_toastr('职位审核失败', 'error');
+                return back();
+            } else {
+                return admin_toastr('职位审核失败', 'error');
+            }
+        }
+    }
+
+    public function jobsbusiness(Content $content)
+    {
+        return $content->body(view(admin_base_path().'/jobsbusiness/jobs_business'));
+    }
+
+    public function jobsrefresh(Request $request)
+    {
+        $ids = $request->ids;
+        if (!$ids) {
+            return admin_toastr('请选择要刷新的职位', 'error');
+        }
+        $id = explode(',', $ids);
+        $data = ['refresh_time' => time()];
+
+        if (Jobs::jobsUpdate($id, $data)) {
+            event_search_update(Jobs::class, implode(',', $id), 'update');
+
+            $com_ids =$this->jobsRepository->findWhereIn('id', $id, ['company_id'])->toArray();
+            $company_condition = [['whereIn','id', $com_ids]];
+            event_search_update(Company::class, $company_condition, 'update');
+
+            return admin_toastr('职位刷新成功', 'success');
+        } else {
+            return admin_toastr('职位刷新失败', 'error!');
+        }
+    }
+
+    //删除职位
+    public function destroy($id)
+    {
+        $ids = explode(',', $id);
+
+        $company_id = Jobs::select('company_id')->whereIn('id', $ids)->get()->toArray();
+        $cids = array();
+        if ($company_id) {
+            foreach ($company_id as $k => $v) {
+                $cids[] = $v['company_id'];
+            }
+        }
+
+        DB::beginTransaction();//检查数据库事务
+        try {
+            if (false === Jobs::destroy($ids)) {
+                throw  new \Exception('删除职位失败!');
+            }
+
+            if (false === JobsContact::whereIn('job_id', $ids)->delete()) {
+                throw  new \Exception('职位联系人删除失败,删除职位失败!');
+            }
+
+            if (false === ViewJob::whereIn('job_id', $ids)->delete()) {
+                throw  new \Exception('职位被浏览信息删除失败,删除职位失败!');
+            }
+            $condition = [['whereIn','id',$ids]];
+            event_search_update(Jobs::class, $condition, 'delete');
+            $company_condition = [['whereIn','id', $cids]];
+            event_search_update(Company::class, $company_condition, 'update');
+            DB::commit();
+        } catch (\Exception $e) {
+            DB::rollback();
+            return admin_toastr($e->getMessage(), 'error');
+        }
+        return admin_toastr('职位删除成功', 'success');
+    }
+
+    public function auditLog(Request $request)
+    {
+        $id = $request->id;
+        $type = $request->type;
+        $headers = ['status'=>'审核状态', 'tim'=>'审核时间', 'sec'=>'描述'];
+        $data = [];
+        $res = AuditReason::where(['type_id'=>$id,'type'=>$type])->orderBy('id', 'desc')->get();
+        if (!$res) {
+            $rows = $data;
+        } else {
+            foreach ($res as $k => $v) {
+                if ($v['status']==3) {
+                    $data[$k]['status'] = '审核失败';
+                } elseif ($v['status']==1) {
+                    $data[$k]['status'] = '审核通过';
+                } else {
+                    $data[$k]['status'] = '待审核';
+                }
+                $data[$k]['tim'] = $v['created_at'];
+                $data[$k]['sec'] = $v['audit_man'].'--'.$v['reason'];
+            }
+            $rows = $data;
+        }
+
+        $table = new Table($headers, $rows);
+        return ['html'=>$table->render(),'detail'=>'审核日志'];
+    }
+}

+ 223 - 0
app/Admin/Controllers/Company/MembersPointController.php

@@ -0,0 +1,223 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\MembersChargeLog;
+use App\Models\MembersPoint;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Input;
+
+class MembersPointController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('企业积分')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('企业积分')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('企业积分')
+            ->description('编辑')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new MembersPoint);
+        $grid->model()->where('utype', 1)->when(get_subsite_id()>0, function ($querys) {
+            $querys->whereHas('companys', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->whereHas('companys')->orderBy('created_at', 'desc');
+        $grid->id('id');
+        $grid->column('companys.companyname', '企业名称');
+        $grid->points('积分');
+        $grid->column('companys.username', '用户名称');
+        $grid->column('companys.created_at', '注册时间');
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('points_manager_company_edit')) {
+                $actions->disableEdit(false);
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('uid', '企业ID');
+                $filter->between('companys.created_at', '注册时间')->datetime();
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('companys.companyname', '企业名称');
+                $filter->like('companys.username', '用户名称');
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(MembersPoint::findOrFail($id));
+        $show->id('id');
+        $show->points('积分数');
+
+        $show->companys('企业信息', function ($companys) {
+            $companys->companyname('企业名称');
+            $companys->username('会员名称');
+            $companys->panel()->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableList();
+                $tools->disableDelete();
+            });
+        });
+
+        $show->getMembersHandsel('收支明细', function ($getMembersHandsel) {
+            $getMembersHandsel->created_at('操作时间');
+            $getMembersHandsel->points('积分数')->display(function ($points) {
+                if ($this->operate == 1) {
+                    return "+".$points;
+                } else {
+                    return "-".$points;
+                }
+            });
+            $getMembersHandsel->disableRowSelector();
+            $getMembersHandsel->disableFilter();
+            $getMembersHandsel->tools(function ($tools) {
+                $tools->disableRefreshButton();
+            });
+            $getMembersHandsel->disableActions();
+            $getMembersHandsel->disableExport();
+            $getMembersHandsel->disableCreateButton();
+        });
+
+        $show->created_at('创建时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new MembersPoint);
+
+
+
+        return $form;
+    }
+    protected function editForm()
+    {
+        $form = new Form(new MembersPoint);
+
+        $form->display('id');
+        $form->hidden('uid', '会员UID');
+        $form->hidden('utype', '会员类型');
+        $form->display('companys.username', '用户名称');
+        $form->hidden('companys.username');
+        $form->display('companys.companyname', '企业名称');
+        $form->radio('act', '操作')->options([1=>'增加',2=>'减少'])->default(1);
+        $form->hidden('points');
+        $form->number('point', '增减')->min(0);
+        $form->text('log_value', '操作说明');
+        $form->radio('log_ismoney', '是否收费')->options([1=>'是',0=>'否'])->default(1);
+        $form->number('log_amount', '收费金额');
+
+        return $form;
+    }
+
+    public function update($id)
+    {
+        $data = Input::except('_token', 'method');
+
+        if ($data['act'] == 1) {
+            $data['point'] = $data['point'];
+            $act = "+";
+        } else {
+            $data['point'] = "-".$data['point'];
+            $act = "-";
+        }
+        $data1['points'] =$data['points']+$data['point'];
+        $arr['log_uid'] = $data['uid'];
+        $arr['log_username'] = $data['companys']['username'];
+        $arr['log_utype'] = $data['utype'];
+        $arr['log_value'] = "操作人:".Admin::user()->username.",说明:修改会员:{$arr['log_username']},({$act}{$data['point']})积分,收到".$data['log_amount']."元。备注:".$data['log_value'];
+        $arr['log_amount'] = $data['log_amount'];
+        $arr['log_ismoney'] = $data['log_ismoney'] == 'on'?1:0;
+        $arr['log_type'] = 2;
+        $arr['log_mode'] = 1;
+
+        $memberChargeLog = new MembersChargeLog();
+        $memberChargeLog->create($arr);
+        return $this->editForm()->update($id, $data1);
+    }
+
+
+}

+ 360 - 0
app/Admin/Controllers/Company/MembersSetmealController.php

@@ -0,0 +1,360 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Jobs\Cron\ClearExpiredSetmealJob;
+use App\Models\MembersChargeLog;
+use App\Models\MembersSetmeal;
+use App\Models\MembersSetmealsRecord;
+use App\Models\Setmeal;
+use App\Repositories\CompanyRepository;
+use App\Repositories\MemberLogRepository;
+use App\Services\Company\ServiceService;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Encore\Admin\Widgets\Table;
+use function foo\func;
+use Illuminate\Support\Facades\Input;
+use Illuminate\Http\Request;
+use Illuminate\Support\MessageBag;
+use function Matrix\trace;
+
+class MembersSetmealController extends Controller
+{
+    use HasResourceActions;
+
+    public $companyRepository;
+    public $memberLogRepository;
+    /**
+     * MembersSetmealController constructor.
+     * @param $companyRepository
+     */
+    public function __construct(CompanyRepository $companyRepository,MemberLogRepository $memberLogRepository)
+    {
+        $this->companyRepository = $companyRepository;
+        $this->memberLogRepository=$memberLogRepository;
+    }
+
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('企业套餐')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    public function detail($id)
+    {
+        $show = new Show(MembersSetmeal::findOrFail($id));
+
+        $show->setmeal_name('套餐名称');
+        $show->companys()->companyname('公司名称')->as(function ($companys) {
+            return $companys->companyname;
+        });
+        $show->companys()->username('用户名称')->as(function ($companys) {
+            return $companys->username;
+        });
+        $show->starttime('开始时间')->as(function ($starttime) {
+            return date('Y-m-d H:i:s', $starttime);
+        });
+        $show->endtime('结束时间')->as(function ($endtime) {
+            if ($endtime!=0) {
+                return  $endtime;
+            }
+            return "永久";
+        });
+
+        $show->days('服务天数');
+        $show->jobs_meanwhile('在招职位数');
+        $show->jobfair_num('招聘会场次');
+        $show->refresh_jobs_free('职位免费刷新数');
+        $show->download_resume('下载简历数');
+        $show->download_resume_max('下载简历数上限');
+        $show->companys()->sms_num('短信数')->as(function ($companys) {
+            return $companys->sms_num;
+        });
+        $show->show_apply_contact('收到简历的联系方式')->as(function ($show_apply_contact) {
+            switch ($show_apply_contact) {
+                case 0:
+                    return "需下载";
+                    break;
+                case 1:
+                    return "免费查看";
+                    break;
+            }
+        });
+        $show->expense('收费金额');
+        $show->added('其他说明');
+        return $show;
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        Permission::check('setmeal_manager');
+        return $content
+            ->header('企业套餐')
+            ->description('修改')
+            ->body($this->eidtForm()->edit($id));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('setmeal_manager_companysetmeal_index');
+        $grid = new Grid(new MembersSetmeal);
+        $grid->model()->where('utype', 1)->whereHas('companys')->when(get_subsite_id()>0, function ($querys) {
+            $querys->whereHas('companys', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->orderBy('id', 'desc');
+        $grid->setmeal_name('套餐名称');
+        $grid->column('companys.companyname', '公司名称');
+        $grid->column('companys.username', '用户名称');
+        $grid->starttime('开始时间')->display(function ($starttime) {
+            return date('Y-m-d H:i:s', $starttime);
+        });
+        $grid->endtime('结束时间')->display(function ($endtime) {
+            if ($endtime) {
+                return $endtime;
+            }
+            return "永久";
+        });
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('setmeal_manager_index_edit')) {
+                $actions->disableEdit(false);
+            }
+        });
+        $grid->filter(function ($filter) {
+            $filter->equal('uid', '企业ID');
+            $filter->like('companys.companyname', '企业名称');
+            $filter->like('companys.username', '用户名称');
+            $filter->equal('setmeal_id', '企业套餐')->select(Setmeal::get()->pluck('setmeal_name', 'id'));
+            $filter->between('starttime', '开始时间')->datetime();
+            $filter->between('endtime', '结束时间')->datetime();
+        });
+        return $grid;
+    }
+    public function eidtForm($setmeal_manager_index_edit=true)
+    {
+        //有在业务中的套餐修改用了,就不验证权限了
+        if ($setmeal_manager_index_edit){
+            Permission::check('setmeal_manager_index_edit');
+        }
+
+        $form = new Form(new MembersSetmeal);
+        $form->display('id');
+        $form->display('companys.companyname', '企业名称');
+        $form->display('setmeal_name', '套餐名称');
+        $form->display('setmealtime', '服务时间')->with(function () {
+            return '起:'.date('Y-m-d H:i:s', $this->starttime).' ~ 止:'.($this->endtime ==0?"无限制":$this->endtime);
+        });
+        $form->datetime('endtime', '到期时间');
+
+        $form->text('dayes', '服务天数')->help("默认为空表示不做修改,0为不限制,如填写3则延长3天,-3则减少3天");
+        $form->hidden('days', "服务天数");
+        $form->number('jobs_meanwhile', '在招职位数')->min(0);
+        $form->number('jobfair_num', '招聘会场次')->min(0);
+        $form->number('refresh_jobs_free', '职位免费刷新数')->min(0);
+        $form->number('download_resume', '下载简历数')->min(0);
+        $form->number('download_resume_max', '下载简历数上限')->min(0);
+        $form->number('companys.sms_num', '短信数')->min(0);
+        $form->radio('show_apply_contact', '收到简历的联系方式')->options([0=>'需下载',1=>'免费查看']);
+
+        $form->switch('is_money', '是否已收费');
+        $form->text('expense', '收费金额');
+        $form->text('added', '其他说明');
+
+        $form->hidden('uid');
+        $form->hidden('utype');
+        $form->hidden('companys.username');
+        $form->hidden('setmeal_id');
+        $form->hidden('setmeal_name');
+        $form->hidden('is_money');
+        $form->hidden('amount');
+        $form->hidden('starttime');
+
+
+        return $form;
+    }
+    public function store()
+    {
+        return $this->form()->store();
+    }
+
+    /**
+     * @param $id
+     * @param ServiceService $serviceService
+     * @param CompanyRepository $companyRepository
+     * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
+     * @throws \Prettus\Validator\Exceptions\ValidatorException
+     * 注意改动此方法会影响到企业管理-业务-套餐管理的功能
+     */
+    public function update($id,ServiceService $serviceService,CompanyRepository $companyRepository)
+    {
+        $data1 = Input::except('_token', '_method');
+
+        //是否验证企业-套餐管理-修改 这个权限
+        $setmeal_manager_index_edit=false;
+        //在业务套餐修改中复用了此处并加上了更换套餐
+        if (isset($data1['setmeal']) && $data1['setmeal']==1){ //只更换套餐 ,为1就是返回和修改套餐
+            $data['setmeal_id'] = $data1['setmeal_id'];
+            $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
+
+            $data['setmeal_name'] =$setmeal[$data['setmeal_id']];
+
+        }else{
+            $setmeal_manager_index_edit=true;
+            Permission::check('setmeal_manager_index_edit');
+            $data['jobs_meanwhile'] = $data1['jobs_meanwhile'];
+            $data['jobfair_num'] = $data1['jobfair_num'];//招聘会场次
+            $data['refresh_jobs_free'] = $data1['refresh_jobs_free'];
+            $data['download_resume'] = $data1['download_resume'];
+            $data['download_resume_max'] = $data1['download_resume_max'];
+            $data['show_apply_contact'] = $data1['show_apply_contact'];
+            $data['added'] = $data1['added'];
+
+            if ($data1['endtime'] != '' && $data1['endtime'] != 0) {
+                $data['endtime'] = strtotime($data1['endtime']);
+            } else {
+                $data['endtime'] = 0;
+            }
+
+            if ($data1['dayes'] <> '') {
+                if ($data1['dayes'] <> 0) {
+                    $oldtime = strtotime($data1['endtime']);
+                    $data['days'] = abs($data1['dayes']);
+                    $data['endtime'] = strtotime(''.$data1['dayes'].' days', $oldtime==''?time():$oldtime);
+                } else {
+                    $data['endtime'] = 0;
+                }
+            }
+            if ($data1['dayes'] < 0) {
+                $act = "-";
+
+                if($data["endtime"]<=$data1["starttime"]){
+                    $error = new MessageBag([
+                        'title' => '提示',
+                        'message' => "到期日期不得小于等于开始日期",
+                    ]);
+                    return back()->with(compact('error'));
+
+                }
+
+            } else if ($data1['dayes'] > 0) {
+                $act = "+";
+            } else {
+                $act = '';
+            }
+
+
+            $this->companyRepository->save(['sms_num'=>$data1['companys']['sms_num']], $data1['uid']);
+
+
+            unset($data['dayes']);
+
+
+        }
+
+        $updateInfo=$this->eidtForm($setmeal_manager_index_edit)->update($id, $data);
+
+        //更新完在去跑定时任务
+        dispatch(new ClearExpiredSetmealJob()); //清理过期的会员套餐
+        if (isset($data1['setmeal']) && $data1['setmeal']==1){
+            $membersSetmeal=MembersSetmeal::find($id);
+            $user = $companyRepository->getCompanyInfo(['id'=>$membersSetmeal->uid]);
+
+            //直接调用公共的就OK了
+            $serviceService->setMembersSetmeal($user,$data1['setmeal_id']);
+
+
+            $amount = 0;
+            if ($data1['is_money']) {
+                $amount = $data1['amount'];
+            }
+            $logData['log_uid'] = $id;
+            $logData['log_utype'] = 1;
+            $logData['log_username'] = $user->username;
+            $logData['log_value'] = "操作人:".Admin::user()->username.",说明:修改会员:{$user->username}套餐,(+收费".$amount."元)";
+            $logData['log_amount'] = $amount;
+            $logData['log_ismoney'] = $data1['is_money'];
+            $logData['log_type'] = 2;
+            $logData['log_mode'] = 1;
+            if (!MembersChargeLog::create($logData)) {
+                throw new \Exception('企业增加记录失败');
+            }
+        }
+
+        if (isset($data1['setmeal']))
+        {
+            return back();
+        }
+
+
+        return $updateInfo;
+    }
+
+    public function SetmealRecord(Request $request,$Api=false)
+    {
+
+        $id = $request->id;
+        $headers = ['setmeal_name'=>"套餐名称", 'starttime'=>'开始时间', 'endtime'=>'到期时间'];
+        $data = [];
+
+        $data=MembersSetmealsRecord::where(['uid'=>$id])->select('setmeal_name','starttime','endtime')->orderBy('id', 'desc')->get()->toArray();
+
+        for ($i=0;$i<count($data);$i++){
+            if ($i==count($data)-1){
+                break;
+            }
+            $data[$i+1]['endtime']=$data[$i]['starttime'];  //第一个的开始时间就是第二个的结束时间
+        }
+        if ($Api){
+            return $data;
+        }
+
+
+        $table = new Table($headers, $data);
+        return ['html'=>$table->render(),'detail'=>'套餐购买记录'];
+    }
+
+}

+ 317 - 0
app/Admin/Controllers/Company/OrderController.php

@@ -0,0 +1,317 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\Order;
+use App\Services\Common\OrderService;
+use App\Services\Common\PayService;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Route;
+
+class OrderController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        $name = Route::currentRouteName();
+
+        $arr = explode('.', $name);
+
+        if ($arr[1] == 'company') {
+            $type_id = 1;
+        } else {
+            $type_id = 2;
+        }
+        return $content
+            ->header('订单管理')
+            ->description('列表')
+            ->body($this->grid($type_id));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('订单管理')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    public function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));
+
+        $show->oid('订单ID');
+        $show->order_type('订单类型')->as(function ($order_type) {
+            $arr = [
+                1=>"套餐升级",
+                2=>"充值积分",
+                3=>"简历置顶",
+                4=>"醒目标签",
+                5=>"简历模板",
+                6=>"简历包",
+                7=>"短信包",
+                8=>"职位置顶",
+                9=>"职位紧急",
+                10=>"企业模板",
+                12=>"预约刷新职位",
+                13=>"职位刷新",
+                14=>"简历下载",
+                15=>"职位包",
+                16=>"招聘会包",
+            ];
+            return $arr[$order_type];
+        });
+        $show->pay_type('支付类型')->as(function ($pay_type) {
+            switch ($pay_type) {
+                case 1:
+                    return '积分';
+                    break;
+                case 2:
+                    return '现金';
+                    break;
+                case 3:
+                    return '现金+积分';
+                    break;
+            }
+        });
+        $show->is_pay('支付状态')->as(function ($is_pay) {
+            switch ($is_pay) {
+                case 1:
+                    return '待支付';
+                    break;
+                case 2:
+                    return '已支付';
+                    break;
+                case 3:
+                    return '已取消';
+                    break;
+            }
+        });
+        $show->amount('总金额');
+        $show->pay_amount('现金支付金额');
+        $show->pay_points('支付积分');
+        $show->payment_cn('支付方式');
+        $show->description('订单描述');
+        $show->service_name('购买服务名称');
+        $show->payment_time('支付时间')->as(function ($payment_time) {
+            if ($payment_time) {
+                return date('Y-m-d H:i:s', $payment_time);
+            }
+        });
+        return $show;
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        $name = Route::currentRouteName();
+        $arr = explode('.', $name);
+        if ($arr[1] == 'company') {
+            $type_id = 1;
+        } else {
+            $type_id = 2;
+        }
+        return $content
+            ->header('订单管理')
+            ->description('编辑')
+            ->body($this->form($type_id)->edit($id));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid($type)
+    {
+        $grid = new Grid(new Order);
+        $grid ->model()->where('utype', $type)->when(get_subsite_id()>0, function ($querys) use ($type) {
+            if ($type ==1) {
+                $relations = 'companys';
+            } else {
+                $relations = 'members';
+            }
+            $querys->whereHas($relations, function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->orderBy('created_at', 'desc')->orderBy("is_pay", 'asc');
+        $grid->is_pay('支付状态')->display(function ($is_pay) {
+            if ($is_pay == 1) {
+                return '<span style="color: #FF3300">待付款</span>';
+            } elseif ($is_pay == 2) {
+                return '<span style="color: #009900">已付款</span>';
+            } else {
+                return '已取消';
+            }
+        });
+        $grid->amount('金额')->width(150);
+        if ($type == 1) {
+            $grid->column('companys.companyname', '企业名称')->width(200);
+        } else {
+            $grid->column('members.username', '会员名称')->width(200);
+        }
+
+        $grid->service_name('说明')->width(150);
+        if ($type == 1) {
+            $grid->column('companys.username', '企业会员')->width(200);
+        } else {
+            $grid->column('members.username', '个人会员')->width(200);
+        }
+        $grid->oid('订单号')->width(200);
+        $grid->created_at('申请时间');
+        $grid->payment_cn('支付方式')->width(150)->display(function ($payment_cn) {
+                 if ($payment_cn=="积分"){
+                     return "积分支付";
+                 } else{
+                     return $payment_cn;
+                 }
+        });
+        $grid->filter(function ($filter) use ($type) {
+            $filter->column(1/2, function ($filter) use ($type) {
+                $filter->equal('uid', '企业ID');
+                if ($type == 1) {
+                    $filter->like('companys.username', '会员名称');
+                    $filter->like('companys.companyname', '企业名称');
+                } else {
+                    $filter->like('members.username', '会员名称');
+                }
+
+                $filter->equal('is_pay', '支付状态')->select([1=>'待付款',2=>'已付款',3=>'已取消']);
+                $filter->equal('payment', '支付方式')->select(['offline'=>'线下转帐','alipay'=>'支付宝','wechat'=>'微信','points'=>"积分支付"]);
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('oid', '订单号');
+                $filter->equal('order_type', '订单类型')->select(
+                    [
+                        1=>'套餐升级',
+                        2=>'充值积分',
+                        3=>'简历置顶',
+                        4=>'醒目标签',
+                        5=>'简历模板',
+                        6=>'简历包',
+                        7=>'短信包',
+                        8=>'职位置顶',
+                        9=>'职位紧急',
+                        10=>'企业模板',
+                        11=>'职位刷新',
+                        12=>'简历下载'
+                    ]
+                );
+                $filter->between('created_at', '注册时间')->datetime();
+            });
+        });
+
+        $grid->actions(function ($actions) use ($type) {
+            if ($type == 1) {
+                if (Admin::user()->can('order_manager_edit')) {
+                    $actions->disableEdit(false);
+                }
+            } else {
+                if (Admin::user()->can('person_order_edit')) {
+                    $actions->disableEdit(false);
+                }
+            }
+//            if ($type == 1) {
+//                if (Admin::user()->can('order_manager_delete')) {
+//                    $actions->disableDelete(false);
+//                }
+//            } else {
+//                if (Admin::user()->can('person_order_delete')) {
+//                    $actions->disableDelete(false);
+//                }
+//            }
+        });
+        return $grid;
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form($type)
+    {
+        $form = new ValidateForm(new Order);
+        $form->display('id')->setWidth(2);
+        if ($type == 1) {
+            $form->display('companys.username', '企业会员')->setWidth(2);
+        } else {
+            $form->display('members.username', '个人会员')->setWidth(2);
+        }
+
+        $form->radio('is_pay', '支付状态')->options([1=>'待付款',2=>'已付款',3=>'已取消']);
+        $form->display('amount', '订单金额')->setWidth(2);
+        $form->display('pay_amount', '现金支付金额')->setWidth(2);
+        $form->display('pay_points', '积分支付')->setWidth(2);
+        $form->display('payment_cn', "支付方式")->setWidth(2);
+        $form->display('created_at', '申请时间')->setWidth(2);
+        $form->display('payment_time', '支付时间')->setWidth(2)->with(function ($payment_time) {
+            if ($payment_time) {
+                return date('Y-m-d H:i:s', $payment_time);
+            }
+        });
+        $form->display('oid', '订单号')->setWidth(2);
+        $form->display('service_name', '订单描述')->setWidth(8);
+        $form->text('notes', '添加备注')->setWidth(8);
+        return $form;
+    }
+    public function update(PayService $payService, Request $request, $id,OrderService $orderService)
+    {
+        $order = Order::where('id', $id)->first();
+        if ($order->payment != "offline") {
+            admin_error('只有线下转帐的订单可以修改支付状态!');
+            return back();
+        }
+        if ($order->is_pay != 1) {
+            admin_error('只有线下转帐且状态为未付款订单可以修改支付状态!');
+            return back();
+        }
+        $data = $this->form($id)->getValidateInput();
+        $up_data['is_pay'] = $data['is_pay'];
+        if ($data['is_pay'] == 2) {
+            $up_data['out_trade_no'] = $order->oid;
+            $up_data['notes'] = $data['notes'];
+            $up_data['admin_id'] = Admin::user()->id;
+            $up_data['operate_time'] = date('Y-m-d H:i:s', time());
+
+            if (!$payService->offlineHook($up_data)) {
+                admin_toastr('订单修改失败', 'error');
+            }
+        }else{//加个已取消
+            Order::where('id', $id)->update(['is_pay'=>3]);
+        }
+
+        admin_toastr('订单修改成功', 'success');
+        return redirect(route('order.company.index'));
+    }
+
+}

+ 246 - 0
app/Admin/Controllers/Company/PersonTemplateController.php

@@ -0,0 +1,246 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Tpl;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Storage;
+
+class PersonTemplateController extends Controller
+{
+    use HasResourceActions;
+    
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content  $content)
+    {
+        return $content
+            ->header('个人模板')
+            ->description('列表')
+            ->body($this->grid());
+    }
+    
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('个人模板')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+    
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('个人模板')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+    
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        
+        return $content
+            ->header('个人模板')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+    
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Tpl);
+        $grid->model()->where('tpl_type', 2)->orderBy('id', 'desc');
+        $grid->id('ID');
+        $grid->images('模板缩略图')->image('', '150', '150');
+        $grid->name('模板名称')->width(200);
+        
+        $states = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'primary'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'default'],
+        ];
+       
+        $grid->display('是否显示')->switch($states);
+        $grid->price('价格')->display(function ($display) {
+            return $display.'积分';
+        });
+        
+        $grid->blade_name('压缩包名称');
+        
+        $grid->created_at('创建时间')->sortable();
+        
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('template_person_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('template_person_delete')) {
+                $actions->disableDelete(false);
+            }
+            $actions->disableView(true);
+        });
+        
+        if (Admin::user()->can('template_person_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+        
+        if (Admin::user()->can('template_person_create')) {
+            $grid->disableCreateButton(false);
+        }
+        
+        $grid->disableFilter();
+        return $grid;
+    }
+    
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+    
+    }
+    
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new Tpl);
+        $form->text('name', '模板名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+        
+        $form->radio('display', '是否显示')->options([0=>'否',1=>'是'])->default(1);
+        $form->number('price','价格')->default(0)->min(0)->help('企业会员使用此模板需要支付的积分,0为免费');
+        $form->image('images','模板缩略图')->setWidth(8)->setMustMark()->options(['layoutTemplates' => ['actionDelete'=>'']]);
+        $form->file('blade_name','模板压缩包')->help('上传相同的ZIP压缩包会覆盖之前的文件!')->uniqueName()->setWidth(8)->setMustMark()->options(['layoutTemplates' => ['actionDelete'=>'']]);
+        
+        $form->saving(function (Form $form) use($id) {
+            $form->old_blade_name = Tpl::find($id)->blade_name;
+            if ($form->display=='on') {
+                $form->display=1;
+            } elseif ($form->display=='off') {
+                $form->display=0;
+            }
+        });
+        
+        $form->saved(function (Form $form) {
+            if($form->blade_name!=null && $form->blade_name!='_file_del_'){
+                Storage::disk('public')->deleteDirectory('template/person/'.$form->old_blade_name);
+                $model = $form->model();
+                $new_blade = $model->blade_name;
+                $zip = new \Chumper\Zipper\Zipper();
+                $zip->zip(Storage::disk('public')->path($new_blade))->extractTo(Storage::disk('public')->path('template/person/'.$form->old_blade_name));
+                $zip->close();
+                $model->blade_name = $form->old_blade_name;
+                $model->save();
+                Storage::disk('public')->delete($new_blade);
+            }
+        });
+        return $form;
+    }
+    
+    protected function createForm()
+    {
+        $form = new Form(new Tpl);
+        
+        $form->text('name', '模板名称')->rules([
+            'required',
+        ])->setWidth(3)->setMustMark();
+      
+        $form->radio('display', '是否显示')->options([0=>'否',1=>'是'])->default(1);
+        $form->number('price','价格')->default(0)->min(0)->help('企业会员使用此模板需要支付的积分,0为免费');
+        $form->image('images','模板缩略图')->setWidth(8)->setMustMark()->rules([
+            'required',
+        ]);
+        $form->file('blade_name','模板压缩包')->help('上传相同的ZIP压缩包会覆盖之前的文件!')->rules('mimes:zip')->uniqueName()
+            ->setWidth(8)->setMustMark()->rules([
+                'required',
+            ]);
+        $form->hidden('tpl_type')->default(2);
+        
+        $form->saved(function (Form $form) {
+            $model = $form->model();
+            $new_blade = $model->blade_name;
+            $template_dir=uniqid();
+            $zip = new \Chumper\Zipper\Zipper();
+            $zip->zip(Storage::disk('public')->path($new_blade))->extractTo(Storage::disk('public')->path('template/person/'.$template_dir));
+            $zip->close();
+            $model->blade_name = $template_dir;
+            $model->save();
+            Storage::disk('public')->delete($new_blade);
+        });
+        
+        return $form;
+    }
+    
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    
+    
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Tpl);
+        
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+        
+        return $form;
+    }
+    
+}

+ 155 - 0
app/Admin/Controllers/Company/PersonalJobsApplyController.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\PersonalJobsApply;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class PersonalJobsApplyController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('接收简历')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('收到的简历')
+            ->description('收到的简历')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonalJobsApply);
+        $grid->model()->whereHas('resumes');
+        $grid->id('ID');
+        $grid->column('resumes.fullname', '姓名');
+        $grid->column('resumes.birthdate', '年龄')->display(function ($birthdate) {
+            return date('Y')-$birthdate;
+        });
+        $grid->column('resumes.sex_cn', '性别');
+        $grid->column('resumes.education_cn', '学历');
+        $grid->column('resumes.experience_cn', '工作经验');
+        $grid->column('jobs_name', '应聘职位');
+        $grid->column('created_at', '投递时间');
+
+        $grid->filter(function ($filter) {
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('company_id', '企业ID');
+                $filter->like('company_name', '企业名称');
+                $filter->between('created_at', '添加时间')->datetime();
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('jobs_id', '职位ID');
+                $filter->like('jobs_name', '职位名称');
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonalJobsApply::findOrFail($id));
+        $show->resumes()->fullname('姓名')->as(function ($resumes) {
+            return $resumes->fullname;
+        });
+        $show->resumes()->birthdate('年龄')->as(function ($resumes) {
+            return date('Y')-$resumes->birthdate;
+        });
+        $show->resumes()->sex_cn('性别')->as(function ($resumes) {
+            return $resumes->sex_cn;
+        });
+        $show->resumes()->education_cn('学历')->as(function ($resumes) {
+            return $resumes->education_cn;
+        });
+        $show->resumes()->experience_cn('工作经验')->as(function ($resumes) {
+            return $resumes->experience_cn;
+        });
+        $show->jobs_name('应聘职位');
+        $show->created_at('投递时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonalJobsApply);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 312 - 0
app/Admin/Controllers/Company/PromotionController.php

@@ -0,0 +1,312 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Company;
+use App\Models\Jobs;
+use App\Models\Promotion;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Input;
+
+class PromotionController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('企业推广')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('企业推广')
+            ->description('修改')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('企业推广')
+            ->description('添加')
+            ->body(view('admin.promotion.add')->with('grid', $this->jobGrid()->render()));
+    }
+
+    protected function jobGrid()
+    {
+
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->text('id', '职位ID');
+        $form->text('jobs_name', '职位名称');
+        $form->text('company_name', '企业名称');
+        $form->text('company_id', '企业ID');
+        $form->disableReset();
+        $form->disableSubmit();
+        return $form;
+    }
+
+    public function adds(Request $request)
+    {
+        $jid = $request->jid;
+        $type = $request->ptype;
+        $cid = $request->cid;
+        $days = $request->days;
+        $where = [
+            ['jobid',$jid],
+            ['ptype',$type]
+        ];
+        if (Promotion::get($where)) {
+            admin_toastr('该职位推广已存在', 'error');
+            return back();
+        }
+        if (!$jid || !$cid) {
+            admin_toastr('请选择要推广的企业的职位', 'error');
+            return back();
+        }
+        if (!$days) {
+            admin_toastr('请填写推广天数', 'error');
+            return back();
+        }
+        switch ($type) {
+            case 1:
+                $flied = 'stick';
+                break;
+            case 2:
+                $flied = 'emergency';
+        }
+        $data['companyid'] = $cid;
+        $data['jobid'] = $jid;
+        $data['days'] = $days;
+        $data['ptype'] = $type;
+        $data['starttime'] = time();
+        $data['endtime'] = time()+$days*86400;
+        if (!Promotion::create($data)) {
+            admin_toastr('保存失败', 'error');
+        }
+        $set_data = [$flied=>1];
+        if ($type==1) {
+            $set_data['stime']=$data['endtime'];
+        }
+        Jobs::where('id', $jid)->update($set_data);
+        event_search_update(Jobs::class, $jid, 'update');
+        admin_toastr('保存成功', 'success');
+        return redirect(route('promotion.index'));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('promotion_manager');
+        $grid = new Grid(new Promotion);
+        $grid->model()->when(get_subsite_id()>0, function ($querys) {
+            $querys->whereHas('job', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->whereHas('company')->whereHas('job')->orderBy('id', 'desc');
+        $grid->column('job.jobs_name', '推广职位');
+        $grid->column('company.companyname', '企业名称')->width(200);
+        $grid->ptype('推广类型')->display(function ($ptype) {
+            return $ptype==1?"置顶":"紧急";
+        });
+        $grid->starttime('开始时间')->display(function ($starttime) {
+            return date('Y-m-d', $starttime);
+        });
+        $grid->endtime('结束时间')->display(function ($endtime) {
+            return date('Y-m-d', $endtime);
+        });
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('promotion_manager_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('promotion_manager_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('promotion_manager_add')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->filter(function ($filter) {
+            $filter->like('company.companyname', '企业名称');
+            $filter->like('company.id', '企业ID');
+            $filter->like('job.jobs_name', '职位名称');
+            $filter->like('job.id', '职位ID');
+            $filter->equal('ptype', '推广类型')->select([1=>'置顶', 2=>'紧急']);
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Promotion::findOrFail($id));
+        $show->companyid('企业名称')->as(function ($companyid) {
+            $comInfo = Company::select('companyname')->find($companyid);
+            if ($comInfo) {
+                return $comInfo->companyname;
+            }
+            return '';
+        });
+        $show->ptype('推广类型')->as(function ($ptype) {
+            switch ($ptype) {
+                case 1:
+                    return '职位置顶';
+                    break;
+                case 2:
+                    return '职位紧急';
+                    break;
+            }
+        });
+        $show->jobid('职位名称')->as(function ($jobid) {
+            $jobInfo = Jobs::select('jobs_name')->find($jobid);
+            if ($jobInfo) {
+                return $jobInfo->jobs_name;
+            }
+            return '';
+        });
+        $show->days('推广天数');
+        $show->starttime('开始时间')->as(function ($starttime) {
+            return date('Y-m-d H:i:s', $starttime);
+        });
+        $show->endtime('开始时间')->as(function ($endtime) {
+            return date('Y-m-d H:i:s', $endtime);
+        });
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm()
+    {
+        Permission::check('promotion_manager_edit');
+        $form = new Form(new Promotion);
+        $form->display('id');
+        $form->display('company.companyname', '企业名称');
+        $form->display('job.jobs_name', '职位名称');
+        $form->display('ptype', '推广方案')->with(function ($ptype) {
+            return $ptype==1?'置顶':'紧急';
+        });
+        $form->display('days', '推广天数');
+        $form->display('dead_line', '推广期限');
+        $form->hidden('endtime', '结束时间');
+        $form->text('day', '延迟推广天数')->rules('required', ['required'=>'请输入延迟推广天数']);
+
+        return $form;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Promotion);
+
+
+        return $form;
+    }
+
+    /**
+     * @param $id推广ID
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        if (!Input::get('day')) {
+            admin_toastr('请输入延迟推广天数!', 'error');
+            return back();
+        }
+        $data = [
+            'endtime' =>Input::get('endtime')+Input::get('day')*86400,
+            'days' =>Input::get('day'),
+        ];
+        return $this->editForm()->update($id, $data);
+    }
+
+    public function destroy($id)
+    {
+        Permission::check('promotion_manager_delete');
+        $model = Promotion::where('id', $id)->first();
+        switch ($model->ptype) {
+            case 1:
+                $type = 'stick';
+                $html = "置顶";
+                $data['stime'] = 0;
+                break;
+            case 2:
+                $type = 'emergency';
+                $html = "紧急";
+                break;
+        }
+        if (Promotion::destroy($id)) {
+            if (Jobs::where('id', $model->jobid)->first()) {
+                $data[$type] = 0;
+                Jobs::where('id', $model->jobid)->update($data);
+            }
+            return admin_toastr('职位'.$html.'删除成功', 'success');
+        }
+        return admin_toastr('职位'.$html.'删除失败', 'error');
+    }
+
+}

+ 1 - 0
app/Admin/Controllers/Company/README.md

@@ -0,0 +1 @@
+后台企业管理模块

+ 252 - 0
app/Admin/Controllers/Company/SetmealController.php

@@ -0,0 +1,252 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Setmeal;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Validation\Rule;
+
+class SetmealController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        Permission::check('setmeal_manager_category');
+        return $content
+            ->header('套餐分类')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('会员套餐')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('套餐分类')
+            ->description('编辑')
+            ->body($this->editform($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('套餐分类')
+            ->description('新增')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('setmeal_manager_category');
+        $grid = new Grid(new Setmeal);
+        $grid->id('ID');
+        $grid->setmeal_name('名称');
+        $grid->display('会员显示')->display(function ($display) {
+            return $display==1?"显示":'不显示';
+        });
+        $grid->apply('允许申请')->display(function ($apply) {
+            return $apply==1?"允许":'不允许';
+        });
+        $grid->expense('服务价')->display(function ($expense) {
+            return $expense==0?"免费":$expense;
+        });
+        $grid->days('期限')->display(function ($days) {
+            return $days==0?"不限制":$days;
+        });
+        if (Admin::user()->can('setmeal_manager_category_add')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->show_order('排序');
+        $grid->disableFilter();
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('setmeal_manager_category_edit')) {
+                $actions->disableEdit(false);
+            }
+            if ($actions->row['id'] != 1) {
+                if (Admin::user()->can('setmeal_manager_category_delete')) {
+                    $actions->disableDelete(false);
+                }
+            }
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Setmeal::findOrFail($id));
+
+        $show->setmeal_name('名称');
+        $show->display('会员显示')->as(function ($display) {
+            return $display==1?"显示":'不显示';
+        });
+        $show->apply('会员显示')->as(function ($apply) {
+            return $apply==1?"允许":'不允许';
+        });
+        $show->expense('服务价')->as(function ($expense) {
+            return $expense==0?"免费":$expense;
+        });
+        $show->days('期限')->as(function ($days) {
+            return $days==0?"不限制":$days;
+        });
+        $show->jobs_meanwhile('职位最大并发数');
+        $show->refresh_jobs_free('每天免费刷新职位次数');
+        $show->download_resume('下载简历');
+        $show->jobfair_num('招聘会场次');
+        $show->download_resume_max('每天下载简历数上限');
+        $show->discount_download_resume('下载简历增值包折扣');
+        $show->discount_sms('短信增值包折扣');
+        $show->discount_stick('职位置顶折扣');
+        $show->discount_emergency('职位紧急折扣');
+        $show->discount_tpl('企业模板折扣');
+        $show->discount_auto_refresh_jobs('职位预约刷新折扣');
+        $show->show_order('显示顺序');
+        $show->set_sms('赠送短信条数');
+        $show->set_points('赠送积分');
+        $show->show_apply_contact('收到简历的联系方式免费查看');
+        $show->apply('允许会员申请此服务');
+        $show->setmeal_img('修改套餐图标(png格式)')->image();
+        $show->added('其他说明)');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        Permission::check('setmeal_manager_category_add');
+        $form = new Form(new Setmeal);
+        $form->display('id');
+        $form->text('setmeal_name', '套餐名称')->rules(['required','unique:setmeals'], ['required'=>'请填写套餐名称','unique' => '套餐名称已经存在']);
+        $form->number('days', '有效时间')->min(0)->rules('required', ['required'=>'请填写有效时间']);
+        $form->number('expense', '价格')->min(0)->rules('required', ['required'=>'请填写套餐价格']);
+        $form->number('jobs_meanwhile', '职位最大发布数')->min(0)->rules('required', ['required'=>'请填写职位最大发布数']);
+        $form->number('refresh_jobs_free', '每天免费刷新职位次数')->min(0)->rules('required', ['required'=>'请填写每天免费刷新职位数']);
+        $form->number('download_resume', '下载简历')->min(0)->rules('required', ['required'=>'请填写下载简历数']);
+        $form->number('jobfair_num', '招聘会场次')->min(0)->rules('required', ['required'=>'请填写招聘会场次']);
+        $form->number('download_resume_max', '每天下载简历数上限')->min(0)->rules('required', ['required'=>'请填写每天下载简历数上限']);
+        $form->number('discount_download_resume', '下载简历增值包折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写下载简历增值包折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_sms', '短信增值包折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写短信增值包折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_stick', '职位置顶折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写职位置顶折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_emergency', '职位紧急折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写职位紧急折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_tpl', '企业模板折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写企业模板折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_auto_refresh_jobs', '职位预约刷新折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写职位预约刷新折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('show_order', '显示顺序');
+        $form->number('set_sms', '赠送短信条数')->rules('required', ['required'=>'请填写赠送短信条数']);
+        $form->number('set_points', '赠送积分')->rules('required', ['required'=>'请填写赠送积分']);
+        $form->switch('show_apply_contact', '收到简历的联系方式免费查看');
+        $form->switch('apply', '允许会员申请此服务');
+        $form->switch('display', '是否显示');
+        $form->image('setmeal_img', '修改套餐图标(png格式)')->removable()->rules('required', ['required'=>'请上传图标'])->setMustMark();
+        $form->text('added', '其他说明)');
+        return $form;
+    }
+
+    protected function editform($id)
+    {
+        Permission::check('setmeal_manager_category_edit');
+        $form = new Form(new Setmeal);
+        $form->display('id');
+        $form->text('setmeal_name', '套餐名称')->rules(['required',Rule::unique('setmeals')->ignore($id)], ['required'=>'请填写套餐名称','unique' => '套餐名称已经存在']);
+
+        //2019.7.1 杨亚倩  更改免费也有到期时间
+        $form->number('days', '有效时间')->min(0)->rules('required', ['required' => '请填写有效时间'])->help('0表示无限制');
+
+        $form->number('expense', '价格')->min(0)->rules('required', ['required'=>'请填写套餐价格']);
+        $form->number('jobs_meanwhile', '职位最大发布数')->min(0)->rules('required', ['required'=>'请填写职位最大发布数']);
+        $form->number('refresh_jobs_free', '每天免费刷新职位次数')->min(0)->rules('required', ['required'=>'请填写每天免费刷新职位数']);
+        $form->number('download_resume', '下载简历')->min(0)->rules('required', ['required'=>'请填写下载简历数']);
+        $form->number('jobfair_num', '招聘会场次')->min(0)->rules('required', ['required'=>'请填写招聘会场次']);
+        $form->number('download_resume_max', '每天下载简历数上限')->min(0)->rules('required', ['required'=>'请填写每天下载简历数上限']);
+        $form->number('discount_download_resume', '下载简历增值包折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写下载简历增值包折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_sms', '短信增值包折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写短信增值包折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_stick', '职位置顶折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写职位置顶折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_emergency', '职位紧急折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写职位紧急折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_tpl', '企业模板折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写企业模板折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('discount_auto_refresh_jobs', '职位预约刷新折扣')->min(0)->max(9)->rules('required', ['required'=>'请填写职位预约刷新折扣'])->help('请填写0~9之间的数字,0表示无折扣');
+        $form->number('show_order', '显示顺序');
+        $form->number('set_sms', '赠送短信条数')->rules('required', ['required'=>'请填写赠送短信条数']);
+        $form->number('set_points', '赠送积分')->rules('required', ['required'=>'请填写赠送积分']);
+        $form->switch('show_apply_contact', '收到简历的联系方式免费查看');
+        $form->switch('apply', '允许会员申请此服务');
+        $form->switch('display', '是否显示');
+        $form->image('setmeal_img', '修改套餐图标(png格式)')->removable()->rules('required', ['required'=>'请上传图标'])->setMustMark();
+        $form->text('added', '其他说明)');
+
+       
+        $form->saved(function (){
+            $redis = Cache::getRedis();
+            $keys = $redis->keys("*aix_cache:setmeals*");
+
+            foreach ($keys as $key) {
+                $redis->del($key);
+            }
+        });
+        return $form;
+    }
+
+    public function update($id)
+    {
+        if (request()->has(Form\Field::FILE_DELETE_FLAG)) {
+
+            return $this->editForm($id)->update($id);
+        }
+        return $this->editform($id)->update($id);
+    }
+}

+ 195 - 0
app/Admin/Controllers/Company/SetmealIncrementController.php

@@ -0,0 +1,195 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\SetmealIncrement;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class SetmealIncrementController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        Permission::check('increment_manager_setcompany');
+        return $content
+            ->header('增值分类')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('详情')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('增值分类')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('增值分类')
+            ->description('新增')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        Permission::check('increment_manager_setcompany');
+        $grid = new Grid(new SetmealIncrement);
+        $grid->id('id');
+        $grid->name('名称');
+        $grid->cat('类型')->display(function ($cat) {
+            switch ($cat) {
+                case 'download_resume':
+                    return '简历增值包';
+                    break;
+                case 'sms':
+                    return '短信增值包';
+                    break;
+                case 'jobs':
+                    return '职位增值包';
+                    break;
+                case 'jobfair_num':
+                    return '招聘会场次增值包';
+                    break;
+                case 'stick':
+                    return '职位置顶';
+                    break;
+                case 'emergency':
+                    return '职位紧急';
+                    break;
+                case 'auto_refresh_jobs':
+                    return '职位智能刷新';
+                    break;
+            }
+        });
+        $grid->value('服务条数');
+        $grid->price('服务价格');
+        $grid->sort('排序')->editable();
+
+        $grid->disableFilter();
+        if (Admin::user()->can('increment_manager_setcompany_increment_add')) {
+            $grid->disableCreateButton(false);
+        }
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('increment_manager_setcompany_increment_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('increment_manager_setcompany_increment_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SetmealIncrement::findOrFail($id));
+
+        $show->name('名称');
+        $show->cat('名称')->as(function ($cat) {
+            switch ($cat) {
+                case 'download_resume':
+                    return '简历增值包';
+                    break;
+                case 'sms':
+                    return '短信增值包';
+                    break;
+                case 'jobs':
+                    return '职位增值包';
+                    break;
+                case 'jobfair_num':
+                    return '招聘会场次增值包';
+                    break;
+                case 'stick':
+                    return '职位置顶';
+                    break;
+                case 'emergency':
+                    return '职位紧急';
+                    break;
+                case 'auto_refresh_jobs':
+                    return '职位智能刷新';
+                    break;
+            }
+        });
+        $show->value('服务条数');
+        $show->price('服务价格');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        Permission::check('increment_manager_setcompany_increment_edit');
+        $form = new Form(new SetmealIncrement);
+        $form->display('id');
+        $form->text('name', '名称');
+        $options =[
+            'download_resume' => '简历增值包', 'sms' => '短信增值包','jobs'=>'职位增值包','jobfair_num'=>'招聘会场次增值包', 'stick' => '职位置顶', 'emergency' => '职位紧急', 'auto_refresh_jobs' => '职位智能刷新'
+        ];
+        $form->radio('cat', '类型')->options($options);
+        $form->number('value', '服务条数')->min(0)->max(1000);
+        $form->number('price', '服务价格')->min(0)->max(1000);
+        $form->number('sort', '排序')->min(0);
+        return $form;
+    }
+}

+ 257 - 0
app/Admin/Controllers/Company/TaskController.php

@@ -0,0 +1,257 @@
+<?php
+
+namespace App\Admin\Controllers\Company;
+
+use App\Http\Controllers\Controller;
+use App\Models\Task;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Route;
+
+class TaskController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @param $type_id
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        $name = Route::currentRouteName();
+        $arr = explode('.', $name);
+        $header = '企业任务';
+        if ($arr[0] == 'task') {  //路由参数变化导致。 
+            $type_id =1;
+            Permission::check('companytask_manager');
+        } else {
+            $type_id =2;
+            $header = '个人任务';
+            Permission::check('person_task');
+        }
+        return $content
+            ->header($header)
+            ->description('列表')
+            ->body($this->grid($type_id));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('企业任务')
+            ->description('任务详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @param $type_id
+     * @return Grid
+     */
+    protected function grid($type_id)
+    {
+        if ($type_id == 1) {
+            Permission::check('task_manager_company');
+        } else {
+            Permission::check('person_task');
+        }
+        $grid = new Grid(new Task);
+        $grid->model()->where('utype', $type_id);
+        $grid->title('任务名称')->width(200);
+
+        if ($type_id == 1) {
+            if (Admin::user()->can('task_manager_company_edit')) {
+                $grid->status('是否启用')->switch()->display(function ($status) {
+                    if ($this->title == '每日签到') {
+                        return '不允许关闭';
+                    }
+                    return $status;
+                });
+            } else {
+                $grid->status('是否启用')->display(function ($status) {
+                    if ($this->title == '每日签到') {
+                        return '不允许关闭';
+                    }
+                    if ($status =0) {
+                        return "关闭";
+                    }
+                    return "开启";
+                });
+            }
+        } else {
+            if (Admin::user()->can('person_task_edit')) {
+                $grid->status('是否启用')->switch()->display(function ($status) {
+                    if ($this->title == '每日签到') {
+                        return '不允许关闭';
+                    }
+                    return $status;
+                });
+            } else {
+                $grid->status('是否启用')->display(function ($status) {
+                    if ($this->title == '每日签到') {
+                        return '不允许关闭';
+                    }
+                    if ($status =0) {
+                        return "关闭";
+                    }
+                    return "开启";
+                });
+            }
+        }
+        if ($type_id == 1) {
+            if (Admin::user()->can('task_manager_company_edit')) {
+                $grid->points('增加(积分)')->editable();
+            } else {
+                $grid->points('增加(积分)');
+            }
+        } else {
+            if (Admin::user()->can('person_task_edit')) {
+                $grid->points('增加(积分)')->editable();
+            } else {
+                $grid->points('增加(积分)');
+            }
+        }
+        if ($type_id == 1) {
+            if (Admin::user()->can('task_manager_company_edit')) {
+                $grid->times('每天赠送积分上限')->editable()->display(function ($times) {
+                    if ($this->once == 0 && $this->times != -1 && $this->dayly == 0) {
+                        return $times . "/次";
+                    } else {
+                        return "--";
+                    }
+                });
+            } else {
+                $grid->times('每天赠送积分上限')->display(function ($times) {
+                    if ($this->once == 0 && $this->times != -1 && $this->dayly == 0) {
+                        return $times . "/次";
+                    } else {
+                        return "--";
+                    }
+                });
+            }
+        } else {
+            if (Admin::user()->can('person_task_edit')) {
+                $grid->times('每天赠送积分上限')->editable()->display(function ($times) {
+                    if ($this->once == 0 && $this->times != -1 && $this->dayly == 0) {
+                        return $times . "/次";
+                    } else {
+                        return "--";
+                    }
+                });
+            } else {
+                $grid->times('每天赠送积分上限')->display(function ($times) {
+                    if ($this->once == 0 && $this->times != -1 && $this->dayly == 0) {
+                        return $times . "/次";
+                    } else {
+                        return "--";
+                    }
+                });
+            }
+        }
+        $grid->disableFilter();
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Task::findOrFail($id));
+
+        $show->id('ID');
+        $show->title('任务名称');
+        $show->status('是否启用')->as(function ($status) {
+            if ($status == 1) {
+                return "启用";
+            } else {
+                return "关闭";
+            }
+        });
+        $show->points('增加(积分)');
+        $show->once('是否一次性任务')->as(function ($once) {
+            switch ($once) {
+                case 1:
+                    return "是";
+                    break;
+                case 0:
+                    return '否';
+                    break;
+            }
+        });
+        $show->times('每天赠送积分上限')->as(function ($times) {
+            if ($this->once == 0 && $this->times != -1 && $this->dayly == 0) {
+                return $this->times;
+            }
+        });
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Task);
+
+        $form->display('ID');
+        $form->switch('status');
+        $form->text('points', '积分');
+        $form->text('times', '每天赠送积分上限');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 119 - 0
app/Admin/Controllers/ConfigController.php

@@ -0,0 +1,119 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Extensions\Form\ValueForm;
+use App\Http\Controllers\Controller;
+use App\Models\CategoryDistrict;
+use App\Models\ConfigType;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Widgets\Tab;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Artisan;
+
+class ConfigController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @param int $type_id
+     * @param int $tab_id
+     * @return Content
+     * @throws \Throwable
+     */
+    public function index(Content $content, int $type_id, int $tab_id = 0)
+    {
+        $tab = new Tab();
+        $firstType=ConfigType::findOrFail($type_id);
+        foreach ($firstType->subTypes as $secondType) {
+            $tab_content=[];
+            foreach ($secondType->subTypes as $thirdType) {
+                $tab_content[$thirdType->alias]['type']=$thirdType;
+                $form= new ValueForm();
+                $form->disableReset();
+                $form->action(admin_base_path()."/config/".$thirdType->id);
+                foreach ($thirdType->configs as $config) {
+                    $input_type=$config->input_type;
+                    $field=$form->$input_type($config->alias, $config->name);
+                    if ($input_type=='password') {
+                        $field->value("***********")
+                            ->default($config->value?"***********":$config->default_value);
+                    } else {
+                        $field->value($config->value)
+                            ->default($config->value?$config->value:$config->default_value);
+                    }
+                    if (!empty($config->tips)) {
+                        $field->help($config->tips);
+                    }
+                    if (!empty($config->placeholder)) {
+                        $field->placeholder($config->placeholder);
+                    }
+                    if (!empty($config->option_values)) {
+                        if (is_array($config->option_values)) {
+                            $field->options($config->option_values);
+                        } elseif ($input_type == 'select') {
+                            $field->options($config->option_values);
+                        }
+                    }
+                }
+                $tab_content[$thirdType->alias]['form']=$form;
+            }
+            $tab->add($secondType->name, view('admin.config.config_tab_content')
+                ->with('contents', $tab_content)->with('type', $secondType)->render(), $tab_id==$secondType->id);
+        }
+
+        return $content
+            ->header($firstType->name)
+            ->description($firstType->tips)
+            ->body($tab->render());
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param Request $request
+     * @param int $type_id
+     * @return mixed
+     */
+    public function store(Request $request, int $type_id)
+    {
+        $configType=ConfigType::findOrFail($type_id);
+        foreach ($configType->configs as $config) {
+            if (!empty($config->rules)) {
+                $request->validate([$config->alias=>$config->rules], $config->rule_messages);
+            }
+            if (in_array($config->input_type, ['image', 'file'])) {
+                if ($request->hasFile($config->alias)) {
+                    $file=$config->alias;
+                    $config->value=$request->$file
+                        ->store(config('admin.upload.directory.'.$config->input_type), config('admin.upload.disk'));
+                    $config->save();
+                    Artisan::call('aix:config');
+                }
+            } else {
+                if ($config->input_type == 'switch') {
+                    $submitValue = $request->get($config->alias) == 'on'?1:0;
+                } elseif ($config->input_type == 'password') {
+                    if ($request->get($config->alias) == '***********') {
+                        continue;
+                    }
+                    $submitValue = $request->get($config->alias, $config->default_value);
+                } else {
+                    $submitValue = $request->get($config->alias, $config->default_value);
+                }
+                if ($config->value != $submitValue) {
+                    $config->value=$submitValue;
+                    $config->save();
+                }
+            }
+        }
+        Artisan::call('aix:config');
+        admin_toastr('修改成功', 'success');
+        return redirect(admin_base_path().'/config/'.$configType->parentType->parent.'/'.$configType->parent);
+    }
+
+}

+ 462 - 0
app/Admin/Controllers/Content/AdCategoryController.php

@@ -0,0 +1,462 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\AdCategory;
+use Encore\Admin\Admin;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Input;
+
+class AdCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('广告位管理')
+            ->description('系统内置广告位不能删除 ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('广告位')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('广告位')
+            ->description(' ')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('广告位')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new AdCategory);
+
+        $grid->model()->orderBy('id', 'desc');
+
+        $grid->category_name('广告位名称')->width(300);
+        $grid->alias('调用名称')->width(200);
+        $grid->ad_num('广告数量');
+        $grid->type_id('属性')->display(function () {
+            $type = "";
+            if ($this->type_id=='1') {
+                $type = '文字';
+            } elseif ($this->type_id=='2') {
+                $type = '图片';
+            } elseif ($this->type_id=='3') {
+                $type = '代码';
+            } elseif ($this->type_id=='4') {
+                $type = 'FLASH';
+            } elseif ($this->type_id=='5') {
+                $type = '图片';
+            }
+            return $type;
+        });
+        $grid->admin_set('类型')->display(function () {
+            return $this->admin_set?'系统内置':'自定义广告位';
+        });
+        $grid->created_at('添加时间');
+        /*$grid->updated_at('更新时间');*/
+
+        //新增按钮
+        if (userAdmin::user()->can('content_ad_category_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (userAdmin::user()->can('content_ad_category_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        $grid->actions(function ($actions) {
+            if (userAdmin::user()->can('content_ad_category_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (userAdmin::user()->can('content_ad_category_delete') && $actions->row['admin_set']!=1) {
+                $actions->disableDelete(false);
+            }
+        });
+        /*$grid->tools(function (Grid\Tools $tools) {
+            $tools->disableRefreshButton();
+            $tools->disableFilterButton();
+        });*/
+
+        /*$grid->filter(function ($filter) {
+            $filter->disableIdFilter(); //删除ID过滤
+            $subsites = array(''=>'不限','0'=>'总站', '1' => '定海', '2' => '普陀');
+            $filter->equal('subsite_id', '所属分站')->radio($subsites);
+        });*/
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(AdCategory::findOrFail($id));
+        $cate_info = AdCategory::findOrFail($id);
+
+        $show->id('ID');
+        $show->category_name('广告位名称');
+        $show->alias('调用名称');
+        $show->type_id('所属类型')->as(function ($type_id) {
+            $type = '图片';
+            switch ($type_id) {
+                case '1':
+                    $type = '文字';
+                    break;
+                case '2':
+                    $type = '图片';
+                    break;
+                case '3':
+                    $type = '代码';
+                    break;
+                case '4':
+                    $type = 'FLASH';
+                    break;
+                case '5':
+                    $type = '视频';
+                    break;
+                default:
+                    $type = '图片';
+                    break;
+            }
+            return $type;
+        });
+        $show->is_float('是否浮动')->as(function ($is_float) {
+            return $is_float?'是':'否';
+        });
+        if ($cate_info->is_float=='1') {
+            $show->float_left('左边距')->as(function ($flaot_left) {
+                return $flaot_left.' px';
+            });
+            $show->float_right('右边距')->as(function ($flaot_right) {
+                return $flaot_right.' px';
+            });
+            $show->float_top('顶边距')->as(function ($flaot_top) {
+                return $flaot_top.' px';
+            });
+        }
+        $show->width('宽度')->as(function ($width) {
+            return $width.' px';
+        });
+        $show->height('高度')->as(function ($height) {
+            return $height.' px';
+        });
+        $show->ad_num('广告数量')->as(function ($ad_num) {
+            return $ad_num;
+        });
+
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+       /* $show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+            });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new AdCategory);
+
+        $form->text('category_name', '广告位名称')->rules('required|max:25', array('required'=>'广告位名称不能为空。','max'=>'广告位名称长度不能大于25。'))->setWidth(4)->setMustMark();
+        $form->text('alias', '调用名称')->rules('required|max:25', array('required'=>'调用名称不能为空。','max'=>'调用名称长度不能大于25。'))->setWidth(4)->help('(自定义广告位调用名称不可以以 “AIX_”开头)')->setMustMark();
+        $type_option = array('1'=>'文字','2'=>'图片','3'=>'代码','4'=>'FLASH','5'=>'视频');
+        $form->radio('type_id', '所属类型')->options($type_option)->default(2)->rules('required', array('required'=>'请选择所属类型。'))->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_float', '是否浮动')->states($display_option)->default('0')->attribute('id', "is_float_switch")->setMustMark();
+        $form->text('float_left', '左距(选填)')
+             ->default(0)
+             ->setWidth(4)
+             ->append('px')
+             ->help('(左距与右距选填一个,如设置为100,则将在距离浏览器左侧100像素处浮动。)')
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('float_right', '右距(选填)')->default(0)->setWidth(4)->append('px')
+             ->help('(左距与右距选填一个,如设置为100,则将在距离浏览器右侧100像素处浮动。)')
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('float_top', '顶距(选填)')->default(0)->setWidth(4)->append('px')
+             ->help('(浮动距离浏览器顶端的距离,如有多个浮动,请设置不同的顶距,以免被遮盖。)')
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+
+        $form->text('width', '宽度')
+             ->default(0)
+             ->append('px')
+             ->setWidth(4)
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('height', '高度')
+             ->default(0)
+             ->append('px')
+             ->setWidth(4)
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+
+        $form->text('ad_num', '广告数量')->default(0)->setWidth(4)
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+
+        $form->hidden('admin_set')->default(0);
+
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+
+        $script = <<<EOT
+        $('input[name="float_left"]').parent().parent().parent().attr('id','float_left_div');
+        $('input[name="float_right"]').parent().parent().parent().attr('id','float_right_div');
+        $('input[name="float_top"]').parent().parent().parent().attr('id','float_top_div');
+        $('#float_left_div,#float_right_div,#float_top_div').css('display','none');
+        $(document).ready(function(){
+            $('#is_float_switch').on('switchChange.bootstrapSwitch', function(event, state) {
+                if(state==true){
+                    $('#float_left_div,#float_right_div,#float_top_div').css('display','block');
+                }else{
+                    $('#float_left_div,#float_right_div,#float_top_div').css('display','none');
+                    $('input[name="float_left"],input[name="float_right"],input[name="float_top"]').val(0);
+                }
+           });
+        }); 
+
+
+EOT;
+        Admin::script($script);
+        return $form;
+    }
+    public function editForm()
+    {
+        $form = new Form(new AdCategory);
+
+        $form->text('category_name', '广告位名称')->rules('required|max:25', array('required'=>'广告位名称不能为空。','max'=>'广告位名称长度不能大于25。'))->setWidth(4)->setMustMark();
+        $form->text('alias', '调用名称')->rules('required|max:25', array('required'=>'调用名称不能为空。','max'=>'调用名称长度不能大于25。'))
+              ->help('(自定义广告位调用名不可以以 “AIX_”开头)')
+              ->setWidth(4)->setMustMark();
+        $type_option = array('1'=>'文字','2'=>'图片','3'=>'代码','4'=>'FLASH','5'=>'视频');
+        $form->radio('type_id', '所属类型')->options($type_option)->rules('required', array('required'=>'请选择所属类型。'))->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_float', '是否浮动')->states($display_option)->attribute('id', 'is_float_switch')->setMustMark();
+        $form->text('float_left', '左距(选填)')->setWidth(4)->append('px')
+             ->help('(左距与右距选填一个,如设置为100,则将在距离浏览器左侧100像素处浮动。)')
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('float_right', '右距(选填)')->setWidth(4)->append('px')
+             ->help('(左距与右距选填一个,如设置为100,则将在距离浏览器右侧100像素处浮动。)')
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('float_top', '顶距(选填)')->setWidth(4)->append('px')
+             ->help('(浮动距离浏览器顶端的距离,如有多个浮动,请设置不同的顶距,以免被遮盖。)')
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('width', '宽度')->append('px')->setWidth(4)
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('height', '高度')->append('px')->setWidth(4)
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('ad_num', '广告数量')
+             ->setWidth(4)->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->saving(function (Form $form) {
+            $form->float_left = $form->float_left?$form->float_left:0;
+            $form->float_right = $form->float_right?$form->float_right:0;
+            $form->float_top = $form->float_top?$form->float_top:0;
+            $form->width = $form->width?$form->width:0;
+            $form->height = $form->height?$form->height:0;
+            $form->ad_num = $form->ad_num?$form->ad_num:0;
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        $script = <<<EOT
+        $('input[name="float_left"]').parent().parent().parent().attr('id','float_left_div');
+        $('input[name="float_right"]').parent().parent().parent().attr('id','float_right_div');
+        $('input[name="float_top"]').parent().parent().parent().attr('id','float_top_div');
+        if($('input[name="is_float"]').val()=='off'){
+            $('#float_left_div,#float_right_div,#float_top_div').css('display','none');
+        }
+        $(document).ready(function(){
+            $('#is_float_switch').on('switchChange.bootstrapSwitch', function(event, state) {
+                if(state==true){
+                    $('#float_left_div,#float_right_div,#float_top_div').css('display','block');
+                }else{
+                    $('#float_left_div,#float_right_div,#float_top_div').css('display','none');
+                    $('input[name="float_left"],input[name="float_right"],input[name="float_top"]').val(0);
+                }
+           });
+        }); 
+
+
+EOT;
+        Admin::script($script);
+
+        return $form;
+    }
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+
+    public function stores()
+    {
+        $data = Input::all();
+        if ($validationMessages = $this->form()->validationMessages($data)) {
+            return back()->withInput()->withErrors($validationMessages);
+        }
+        $is_float = $data['is_float'];
+        if ($is_float=='on') {
+            $is_float = 1;
+        } else {
+            $is_float = 0;
+        }
+        $subsite_ids = $data['subsite_id'];
+        $time = date('Y-m-d H:i:s', time());
+
+        $insert_data = array();
+        $form_data = array(
+            'category_name' => $data['category_name'],
+            'theme'          => 'default',
+            'org'            => 'Home',
+            'alias'          => $data['alias'],
+            'type_id'        => $data['type_id'],
+            'is_float'       => $is_float,
+            'float_left'     => $data['float_left']?$data['float_left']:0,
+            'float_right'    => $data['float_right']?$data['float_right']:0,
+            'float_top'      => $data['float_top']?$data['float_top']:0,
+            'width'           => $data['width']?$data['width']:0,
+            'height'          => $data['height']?$data['height']:0,
+            'admin_set'       => $data['admin_set'],
+            'ad_num'          => $data['ad_num']?$data['ad_num']:0,
+            'created_at'      => $time,
+            'updated_at'      => $time
+        );
+        if ($subsite_ids) {
+            foreach ($subsite_ids as $k => $v) {
+                if ($v !==null) {
+                    $form_data['subsite_id'] = $v;
+                    $insert_data[] = $form_data;
+                }
+            }
+        } else {
+            $form_data['subsite_id'] = 0;
+            $insert_data[] = $form_data;
+        }
+        if (AdCategory::insert($insert_data)) {
+            admin_toastr(trans('admin.save_succeeded'));
+            return redirect(admin_base_path('/content/ad/category'));
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+    public function destroy($id)
+    {
+        $id_arr =  explode(',', $id);
+        $admin_set_cates = AdCategory::where(array('admin_set'=>'1'))->select('id')->get()->pluck('id')->toArray();
+        foreach ($id_arr as $k => $v) {
+            if (in_array($v, $admin_set_cates)) {
+                unset($id_arr[$k]);
+            }
+        }
+        $filter_id = implode(',', $id_arr);
+        if ($filter_id) {
+            if ($this->form()->destroy($filter_id)) {
+                $data = [
+                    'status'  => true,
+                    'message' => trans('admin.delete_succeeded'),
+                ];
+            } else {
+                $data = [
+                    'status'  => false,
+                    'message' => trans('admin.delete_failed'),
+                ];
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => '系统内置广告位不能删除!',
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 1060 - 0
app/Admin/Controllers/Content/AdController.php

@@ -0,0 +1,1060 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Field\Template;
+use App\Admin\Extensions\Form\ValueForm;
+use App\Http\Controllers\Controller;
+use App\Models\Ad;
+use App\Models\AdCategory;
+use App\Models\Subsite;
+use App\Models\SubsiteAd;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Grid\Filter;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+
+//use Encore\Admin\Grid;
+
+class AdController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('广告列表')
+            ->description(' ')
+            ->body(view('admin.content.ad_list')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('广告列表')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        $info = Ad::find($id);
+        $form= new ValueForm();
+        $ad_info = Ad::findOrFail($id);
+        //$form->action('/admin/content/ads/update');
+        $form->action(route('admin.ad.update'));
+        $form->attribute('enctype', 'multipart/form-data');
+        $form->disablePjax();
+        $form->text('title', '广告标题')->default($ad_info->title)->help('(区分不同广告条目,并不在广告中显示)')->setWidth(4)->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '显示状态')->states($display_option)->default($ad_info->is_display)->setMustMark();
+        if ($info->subsite_id==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', $info->subsite_id)))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty() && $info->subsite_id==0) {
+            $relations = SubsiteAd::where(array('ad_id'=>$id))->get()->pluck('subsite_id')->toArray();
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+
+        $cate_option = AdCategory::all()->pluck('category_name', 'id');
+
+        $form->select('category_id', '广告位')->options($cate_option)->default($ad_info->category_id)->setWidth(4)->attribute(['id' => 'sub_category'])->setMustMark();
+        $form->number('list_order', '显示顺序')->default($ad_info->list_order)->min(0)->help('(数字越大越靠前)')->setMustMark();
+        $form->date('started_at', '开始日期')
+            ->format('YYYY-MM-DD')
+            ->default($ad_info->started_at)
+            ->rules('required|date', array('required'=>'开始日期不能为空。', 'date'=>'开始日期格式不正确。'))
+            ->help('(设置广告起始日期,格式yyyy-mm-dd,留空为不限制起始日期)');
+        $form->date('ended_at', '结束日期')
+            ->format('YYYY-MM-DD')
+            ->default($ad_info->ended_at)
+            ->rules('required|date', array('required'=>'结束日期不能为空。', 'date'=>'结束日期格式不正确。'))
+            ->help('(设置广告结束日期,格式yyyy-mm-dd,留空为不限制结束日期)');
+        $form->textarea('note', '备注')->default($ad_info->note);
+
+        $form->html("<div id='change_field'></div>")->plain();
+        $form->hidden('alias')->value($ad_info->alias)->attribute('id', 'alias');
+        $form->hidden('theme')->value($ad_info->theme);
+        $form->hidden('type_id')->value($ad_info->type_id)->attribute('id', 'type_id');
+        $form->hidden('id')->value($ad_info->id);
+
+        $template=new Template();
+        $template->setTemplatesId("text_div");
+        if ($ad_info->type_id == '1') {
+            $template->text('content', '文字内容')->default($ad_info->content)->help('(文字广告的显示内容)')->setMustMark();
+            $template->url('url', '文字链接')->default($ad_info->url)->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com)');
+            $template->color('text_color', '文字颜色')->default($ad_info->text_color)->setMustMark();
+        } else {
+            $template->text('content', '文字内容')->help('(文字广告的显示内容)')->setMustMark();
+            $template->url('url', '文字链接')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com)');
+            $template->color('text_color', '文字颜色')->setMustMark();
+        }
+
+        $template->setTemplatesId("image_div");
+        if ($ad_info->type_id == '2') {
+            $img_file = null;
+            $img_url = null;
+            if (preg_match('/^http/', $ad_info->content)) {
+                $img_url = $ad_info->content;
+            } else {
+                $img_file = $ad_info->content;
+            }
+            $template->image('img_file', '本地上传')->uniqueName()->help('(允许格式为gif/jpg/bmp/png,文件大小1000KB)')->value($img_file)->setMustMark()->options(['layoutTemplates' => ['actionDelete'    => '']]);
+            $template->text('img_url', '或图片地址')->default($img_url)->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com/img/baidu_logo.gif)');
+            $template->url('url', '图片链接')->default($ad_info->url)->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com)');
+            $template->text('explain', '图片说明文字')->default($ad_info->explain);
+            $template->number('uid', '会员UID')->default($ad_info->uid)->min(0)->help('(设置会员UID后,当鼠标移动到图片上将会显示相关的职位和企业信息)');
+        } else {
+            $template->image('img_file', '本地上传')->uniqueName()->setWidth(3)->help('(允许格式为gif/jpg/bmp/png,文件大小1000KB)')->setMustMark()->options(['layoutTemplates' => ['actionDelete'    => '']]);
+            $template->text('img_url', '或图片地址')->help('(请输入包含http://或https://的完整链接,如http://www.baidu.com/img/baidu_logo.gif)');
+            $template->url('url', '图片链接')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com)');
+            $template->text('explain', '图片说明文字');
+            $template->number('uid', '会员UID')->min(0)->help('(设置会员UID后,当鼠标移动到图片上将会显示相关的职位和企业信息)');
+        }
+
+        $template->setTemplatesId("code_div");
+        if ($ad_info->type_id == '3') {
+            $template->textarea('content', '代码')->default($ad_info->content)->rows(1)->help('(请直接输入需要展现的广告代码)')->setMustMark();
+        } else {
+            $template->textarea('content', '代码')->rows(1)->help('(请直接输入需要展现的广告代码)')->setMustMark();
+        }
+
+        $template->setTemplatesId("flash_div");
+        if ($ad_info->type_id == '4') {
+            $flash_file = null;
+            $flash_url = null;
+            if (preg_match('/^images\//', $ad_info->content)) {
+                $flash_file = $ad_info->content;
+            } else {
+                $flash_url = $ad_info->content;
+            }
+            $template->image('content', '本地上传')->default($flash_file)->uniqueName()->setWidth(3)->help('(允许格式为:swf,文件大小:1000KB)')->setMustMark()->options(['layoutTemplates' => ['actionDelete'    => '']]);
+            $template->url('url', '或者Flash地址')->default($flash_url)->help('(请输入包含http://或https://的完整链接,如: http://www.baidu.com/123.swf)');
+
+        } else {
+            $template->file('content', '本地上传')->uniqueName()->setWidth(3)->help('(允许格式为:swf,文件大小:1000KB)')->setMustMark()->options(['layoutTemplates' => ['actionDelete'    => '']]);
+            $template->url('url', '或者Flash地址')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com/123.swf)');
+
+        }
+
+        $template->setTemplatesId("vedio_div");
+        if ($ad_info->type_id == '5') {
+            $vedio_file = null;
+            $vedio_url = null;
+            if (preg_match('/^images\//', $ad_info->content)) {
+                $vedio_file = $ad_info->content;
+            } else {
+                $vedio_url = $ad_info->content;
+            }
+            $template->file('content', '本地上传')->default($vedio_file)->uniqueName()->setWidth(3)->help('(允许格式为swf/flv/f4v,文件大小5000KB,大文件FTP上传)')->setMustMark()->options(['layoutTemplates' => ['actionDelete'    => '']]);
+            $template->url('url', '或者视频地址')->default($vedio_url)->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com/123.swf)');
+        } else {
+            $template->file('content', '本地上传')->uniqueName()->setWidth(3)->help('(允许格式为swf/flv/f4v,文件大小5000KB,大文件FTP上传)')->setMustMark()->options(['layoutTemplates' => ['actionDelete'    => '']]);
+            $template->url('url', '或者视频地址')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com/123.swf)');
+        }
+        $form->disableReset();
+        $data['custom_form']=$form->render();
+        $data['temp']=$template->render();
+        $data['ad_info'] = $ad_info;
+        return $content
+                ->header('广告')
+                ->description(' ')
+                ->body(view('admin.content.ad_edit')->with($data));
+    }
+    public function update(Request $request)
+    {
+        $ad=Ad::findOrFail($request->input('id'));
+        $rules = array(
+            'title'        => 'required|max:50',
+            'is_display'  => 'required',
+            'category_id' => 'required',
+            'list_order'  => 'required|max:10',
+            'note'         => 'max:80'
+        );
+        $message = array(
+            'title.required'       => '广告标题不能为空。',
+            'title.max'             => '广告标题长度不能超过50。',
+            'is_display.required'  => '请选择显示状态。',
+            'category_id.required' => '请选择广告位。',
+            'list_order.required'  => '显示顺序不能为空。',
+            'list_order.max'        => '显示顺序长度不能大于10。',
+            'note.max'                => '备注长度不能超过80。'
+        );
+        if ($request->input('started_at')) {
+            $rules['started_at'] = 'date';
+            $message['started_at.date'] = '开始日期格式不正确。';
+        }
+        if ($request->input('ended_at')) {
+            $rules['ended_at'] = 'date|after_or_equal:started_at';
+            $message['ended_at.date'] = '结束日期格式不正确。';
+            $message['ended_at.after_or_equal'] = '结束日期不能早于开始日期。';
+        }
+        $type_id = $request->input('type_id');
+        if ($type_id=='1') {
+            $rules['content'] = 'required';
+            $rules['text_color'] = 'required';
+            $message['content.required'] = '文字内容不能为空。';
+            $message['text_color.required'] = '文字颜色不能为空。';
+        } else if ($type_id=='2') {
+            $rules['img_file'] = 'mimes:gif,jpeg,bmp,png|max:1024';
+            $rules['explain']  = 'max:80';
+            $rules['uid']      = 'nullable|numeric';
+            $message['img_file.mimes']              = '本地上传格式不正确。';
+            $message['img_file.max']                = '本地上传文件大小不能超过1M。';
+            $message['explain.max']                  = '图片说明文字长度不能大于80。';
+            /*$message['uid.required']                 = 'UID不能为空。';*/
+            $message['uid.numeric']                  = 'UID只能填写数字。';
+        } else if ($type_id=='3') {
+            $rules['content'] = 'required';
+            $message['content.required'] = '代码不能为空。';
+        } else if ($type_id=='4') {
+            $rules['content'] = 'mimes:swf';
+            $message['content.mimes']              = '本地上传格式不正确。';
+        } else if ($type_id=='5') {
+            $rules['content'] = 'mimes:swf,flv,f4v';
+            $message['content.mimes']             = '本地上传格式不正确。';
+        }
+        $request->validate($rules, $message);
+
+
+        $time = date('Y-m-d H:i:s', time());
+        $is_display =$request->input('is_display')=='on'?1:0;
+        $started_at = $request->input('started_at')?strtotime($request->input('started_at')):0;
+        $ended_at = $request->input('ended_at')?strtotime($request->input('ended_at')):0;
+        $type_id = $request->input('type_id');
+        $theme = $request->input('theme')?$request->input('theme'):'default';
+        $note = $request->input('note')?$request->input('note'):'';
+
+        $ad->theme         = $theme;
+        $ad->alias         = $request->input('alias');
+        $ad->is_display   = $request->input('is_display')=='on'?1:0;
+        $ad->category_id  = $request->input('category_id');
+        $ad->type_id      = $type_id;
+        $ad->title        = $request->input('title');
+        $ad->note         = $request->input('note')?$request->input('note'):'';
+        $ad->list_order  = $request->input('list_order');
+        $ad->started_at  = $request->input('started_at')?strtotime($request->input('started_at')):0;
+        $ad->ended_at    = $request->input('ended_at')?strtotime($request->input('ended_at')):0;
+        $ad->updated_at    = $time;
+
+        if ($type_id=='1') {   //文字广告
+            $ad->content     = $request->input('content');
+            $ad->url          = $request->input('url')?$request->input('url'):'';
+            $ad->text_color  = $request->input('text_color')?$request->input('text_color'): '#000000';
+            $ad->uid          = 0;
+
+        } else if ($type_id=='2') {  //图片广告
+            $img_file = $request->input('img_file');
+            $img_url = $request->input('img_url');
+            $url = $request->input('url')?$request->input('url'):'';
+            $explain = $request->input('explain');
+            $uid = $request->input('uid');
+            $up_file = null;
+            if ($request->hasFile('img_file')) {
+                $file = 'img_file';
+                $up_file=$request->$file->store(config('admin.upload.directory.image'), config('admin.upload.disk'));
+            }
+            $content = $up_file?$up_file:$img_url;
+            if ($content) {
+                $ad->content    = $content;
+            }
+            $ad->url         = $url;
+            $ad->text_color = '#000000';
+            $ad->uid         = $uid?$uid:0;
+            $ad->explain    = $explain;
+
+        } else if ($type_id=='3') {    //代码广告
+            $content = $request->input('content')?$request->input('content'):0;
+            if ($content) {
+                $ad->content    = $content;
+            }
+            $ad->uid         = 0;
+            $ad->text_color = '#000000';
+            $ad->url         = '';
+
+        } else if ($type_id=='4' || $type_id=='5') {  //flash广告 、视频广告
+            $url = $request->input('url')?$request->input('url'):'';
+            $up_file = null;
+            if ($request->hasFile('content')) {
+                $file = 'content';
+                $up_file=$request->$file->store(config('admin.upload.directory.file'), config('admin.upload.disk'));
+            }
+            $content = $up_file?$up_file:$url;
+            if ($content) {
+                $ad->content    = $content;
+            }
+            $ad->url         = '';
+            $ad->uid         = 0;
+            $ad->text_color = '#000000';
+        }
+        $set_data = array();
+        $subsites = $request->input('relate_subsites');
+        if (empty($subsites)) {
+            $subsites = [];
+        }
+        $subsites = array_merge(array($ad->subsite_id), $subsites);
+        foreach ($subsites as $k => $v) {
+            if ($v !== null) {
+                $set_data[] = array(
+                    'ad_id' => $ad->id,
+                    'subsite_id'=> $v
+                );
+            }
+        }
+
+        if ($ad->save()) {
+            if ($set_data) {
+                SubsiteAd::where('ad_id', $ad->id)->delete();
+                SubsiteAd::insert($set_data);
+            }
+            admin_toastr(trans('admin.save_succeeded'), 'success');
+            return redirect(admin_base_path().'/content/ad/index');
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+    public function updates(Request $request)
+    {
+        $rules = array(
+            'title'        => 'required|max:50',
+            'is_display'  => 'required',
+            'category_id' => 'required',
+            'list_order'  => 'required|max:10',
+            'note'         => 'max:80'
+        );
+        $message = array(
+            'title.required'       => '广告标题不能为空。',
+            'title.max'             => '广告标题长度不能超过50。',
+            'is_display.required'  => '请选择显示状态。',
+            'category_id.required' => '请选择广告位。',
+            'list_order.required'  => '显示顺序不能为空。',
+            'list_order.max'        => '显示顺序长度不能大于10。',
+            'note.max'                => '备注长度不能超过80。'
+        );
+        if ($request->input('started_at')) {
+            $rules['started_at'] = 'date';
+            $message['started_at.date'] = '开始日期格式不正确。';
+        }
+        if ($request->input('ended_at')) {
+            $rules['ended_at'] = 'date|after_or_equal:started_at';
+            $message['ended_at.date'] = '结束日期格式不正确。';
+            $message['ended_at.after_or_equal'] = '结束日期不能早于开始日期。';
+        }
+        $type_id = $request->input('type_id');
+        if ($type_id=='1') {
+            $rules['content'] = 'required';
+            $rules['text_color'] = 'required';
+            $message['content.required'] = '文字内容不能为空。';
+            $message['text_color.required'] = '文字颜色不能为空。';
+        } else if ($type_id=='2') {
+            $rules['img_file'] = 'required_without:img_url|mimes:gif,jpeg,bmp,png';
+            $rules['img_url']  = 'required_without:img_file';
+            $rules['explain']  = 'max:80';
+            $rules['uid']      = 'required|numeric';
+            $message['img_file.required_without'] = '本地上传或者图片地址填写一项。';
+            $message['img_file.mimes']              = '本地上传格式不正确。';
+            $message['img_url.required_without']   = '本地上传或者图片地址填写一项。';
+            $message['explain.max']                  = '图片说明文字长度不能大于80。';
+            $message['uid.required']                 = 'UID不能为空。';
+            $message['uid.numeric']                  = 'UID只能填写数字。';
+        } else if ($type_id=='3') {
+            $rules['content'] = 'required';
+            $message['content.required'] = '代码不能为空。';
+        } else if ($type_id=='4') {
+            $rules['content'] = 'required_without:url|mimes:swf';
+            $rules['url']      = 'required_without:content';
+            $message['content.required_without'] = '本地上传或者Flash地址填写一项。';
+            $message['content.mimes']              = '本地上传格式不正确。';
+            $message['url.required_without']      = '本地上传或者Flash地址填写一项。';
+        } else if ($type_id=='5') {
+            $rules['content'] = 'required_without:url|mimes:swf,flv,f4v';
+            $rules['url']     = 'required_without:content';
+            $message['content.required_without'] = '本地上传或者填写视频地址填写一项。';
+            $message['content.mimes']             = '本地上传格式不正确。';
+            $message['url.required_without']     = '本地上传或者填写视频地址填写一项。';
+        }
+        $request->validate($rules, $message);
+        $is_display =$request->input('is_display')=='on'?1:0;
+        $time = date('Y-m-d H:i:s', time());
+        $started_at = $request->input('started_at')?strtotime($request->input('started_at')):0;
+        $ended_at = $request->input('ended_at')?strtotime($request->input('ended_at')):0;
+        $type_id = $request->input('type_id');
+        $theme = $request->input('theme')?$request->input('theme'):'default';
+        $note = $request->input('note')?$request->input('note'):'';
+
+        $form_data = array(
+            'theme'        => $theme,
+            'alias'        => $request->input('alias'),
+            'is_display'  => $is_display,
+            'category_id' => $request->input('category_id'),
+            'type_id'      => $type_id,
+            'title'        => $request->input('title'),
+            'note'         => $note,
+            'list_order'  => $request->input('list_order'),
+            'started_at'  => $started_at,
+            'ended_at'    => $ended_at,
+            'updated_at'  => $time
+        );
+        if ($type_id=='1') {
+            //文字广告
+            $form_data['content']    = $request->input('content');
+            $form_data['url']         = $request->input('url');
+            $form_data['text_color'] = $request->input('text_color')?$request->input('text_color'): '#000000';
+            $form_data['uid']         = 0;
+
+        } else if ($type_id=='2') {
+            //图片广告
+            $img_file = $request->input('img_file');
+            $img_url = $request->input('img_url');
+            $url = $request->input('url');
+            $explain = $request->input('explain');
+            $uid = $request->input('uid');
+            $up_file = null;
+            if ($request->hasFile('img_file')) {
+                $file = 'img_file';
+                $up_file=$request->$file->store(config('admin.upload.directory.image'), config('admin.upload.disk'));
+            }
+            $content = $up_file?$up_file:$img_url;
+            $form_data['content']    = $content;
+            $form_data['url']         = $url;
+            $form_data['text_color'] = '#000000';
+            $form_data['uid']         = $uid;
+            $form_data['explain']     = $explain;
+
+
+        } else if ($type_id=='3') {
+            //代码广告
+            $content = $request->input('content')?$request->input('content'):0;
+            $form_data['content']    = $content;
+            $form_data['uid']         = 0;
+            $form_data['text_color'] = '#000000';
+            $form_data['url']         = '';
+
+        } else if ($type_id=='4' || $type_id=='5') {
+            //flash广告 、视频广告
+            $url = $request->input('url')?$request->input('url'):'';
+            $up_file = null;
+            if ($request->hasFile('content')) {
+                $file = 'content';
+                $up_file=$request->$file->store(config('admin.upload.directory.file'), config('admin.upload.disk'));
+            }
+            $content = $up_file?$up_file:$url;
+            $form_data['content']    = $content;
+            $form_data['url']         = '';
+            $form_data['uid']         = 0;
+            $form_data['text_color'] = '#000000';
+        }
+
+        if (Ad::where(array('id'=>$request->input('id')))->update($form_data)) {
+            admin_toastr(trans('admin.save_succeeded'), 'success');
+            return redirect(admin_base_path().'/content/ad/index');
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        $form= new ValueForm();
+        $form->action(route('ad.index'));
+        $form->text('title', '广告标题')->help('(区分不同广告条目,并不在广告中显示)')->setWidth(4)->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '显示状态')->states($display_option)->default('1')->setMustMark();
+
+        if (get_subsite_id()==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty() && get_subsite_id()==0) {
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+        $form->hidden('subsite_id')->value(get_subsite_id());
+
+        $cate_option = AdCategory::all()->pluck('category_name', 'id');
+        $form->select('category_id', '广告位')->options($cate_option)
+             ->rules('required', array('required'=>'请选择广告位。'))
+             ->setWidth(4)->attribute(['id' => 'sub_category'])->setMustMark();
+
+        $form->number('list_order', '显示顺序')->min(0)->default(0)->help('(数字越大越靠前)')->setMustMark();
+        $form->date('started_at', '开始日期')
+            ->format('YYYY-MM-DD')
+            ->rules('required|date', array('required'=>'开始日期不能为空。', 'date'=>'开始日期格式不正确。'))
+            ->help('(设置广告起始日期,格式yyyy-mm-dd,留空为不限制起始日期)');
+        $form->date('ended_at', '结束日期')
+            ->format('YYYY-MM-DD')
+            ->rules('required|date', array('required'=>'结束日期不能为空。', 'date'=>'结束日期格式不正确。'))
+            ->help('(设置广告结束日期,格式yyyy-mm-dd,留空为不限制结束日期)');
+        $form->textarea('note', '备注');
+
+        $form->html("<div id='change_field'></div>")->plain();
+        $form->hidden('alias')->attribute('id', 'alias');
+        $form->hidden('theme')->value('default');
+        $form->hidden('type_id')->attribute('id', 'type_id');
+
+        $template=new Template();
+
+        $template->setTemplatesId("text_div");
+        $template->text('content', '文字内容')->help('(文字广告的显示内容)')->setMustMark();
+        $template->url('url', '文字链接')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com)');
+        $template->color('text_color', '文字颜色')->default('#000000')->setMustMark();
+
+        $template->setTemplatesId("image_div");
+        $template->image('img_file', '本地上传')->uniqueName()->setWidth(3)->help('(允许格式为gif/jpg/bmp/png,文件大小1000KB)')->setMustMark();
+        $template->text('img_url', '或图片地址')->help('(如/images/logo.gif 或 http://www.baidu.com/img/baidu_logo.gif)');
+        $template->url('url', '图片链接')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com)');
+        $template->text('explain', '图片说明文字');
+        $template->number('uid', '会员UID')->min(0)->default(0)
+                 ->help('(设置会员UID后,当鼠标移动到图片上将会显示相关的职位和企业信息)')
+                 ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+
+        $template->setTemplatesId("code_div");
+        $template->textarea('content', '代码')->rows(1)->help('(请直接输入需要展现的广告代码)')->setMustMark();
+
+        $template->setTemplatesId("flash_div");
+        $template->image('content', '本地上传')->uniqueName()->setWidth(3)->help('(允许格式为:swf,文件大小:1000KB)')->setMustMark();
+        $template->url('url', '或者Flash地址')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com/123.swf)');
+
+        $template->setTemplatesId("vedio_div");
+        $template->image('content', '本地上传')->uniqueName()->setWidth(3)->help('(允许格式为swf/flv/f4v,文件大小5000KB,大文件FTP上传)')->setMustMark();
+        $template->url('url', '或者视频地址')->help('(请输入包含http://或https://的完整链接,如:http://www.baidu.com/123.swf)');
+
+        $form->disableReset();
+        $data['custom_form']=$form->render();
+        $data['temp']=$template->render();
+        return $content
+            ->header('广告')
+            ->description(' ')
+            ->body(view('admin.content.ad')->with($data));
+    }
+    public function changeCategory(Request $request)
+    {
+        $cate_option = AdCategory::all()->toArray();
+        return response()->json(array('data'=>$cate_option,'status'=>'1'));
+    }
+    public function store(Request $request)
+    {
+        $rules = array(
+            'title'        => 'required|max:50',
+            'is_display'  => 'required',
+            'category_id' => 'required',
+            'list_order'  => 'required|max:10',
+            'note'         => 'max:80'
+        );
+        $message = array(
+            'title.required'       => '广告标题不能为空。',
+            'title.max'             => '广告标题长度不能超过50。',
+            'is_display.required'  => '请选择显示状态。',
+            'category_id.required' => '请选择广告位。',
+            'list_order.required'  => '显示顺序不能为空。',
+            'list_order.max'        => '显示顺序长度不能大于10。',
+            'note.max'                => '备注长度不能超过80。'
+        );
+        if ($request->input('started_at')) {
+            $rules['started_at'] = 'date';
+            $message['started_at.date'] = '开始日期格式不正确。';
+        }
+        if ($request->input('ended_at')) {
+            $rules['ended_at'] = 'date|after_or_equal:started_at';
+            $message['ended_at.date'] = '结束日期格式不正确。';
+            $message['ended_at.after_or_equal'] = '结束日期不能早于开始日期。';
+        }
+        $type_id = $request->input('type_id');
+        if ($type_id=='1') {
+            $rules['content'] = 'required';
+            $rules['text_color'] = 'required';
+            $message['content.required'] = '文字内容不能为空。';
+            $message['text_color.required'] = '文字颜色不能为空。';
+        } else if ($type_id=='2') {
+            $rules['img_file'] = 'required_without:img_url|mimes:gif,jpeg,bmp,png|max:1024';
+            $rules['img_url']  = 'required_without:img_file';
+            $rules['explain']  = 'max:80';
+            $rules['uid']      = 'nullable|numeric';
+            $message['img_file.required_without'] = '本地上传或者图片地址填写一项。';
+            $message['img_file.mimes']              = '本地上传格式不正确。';
+            $message['img_file.max']              = '本地上传文件大小不能超过1M。';
+            $message['img_url.required_without']   = '本地上传或者图片地址填写一项。';
+            $message['explain.max']                  = '图片说明文字长度不能大于80。';
+            //$message['uid.required']                 = 'UID不能为空。';
+            $message['uid.numeric']                  = 'UID只能填写数字。';
+        } else if ($type_id=='3') {
+            $rules['content'] = 'required';
+            $message['content.required'] = '代码不能为空。';
+        } else if ($type_id=='4') {
+            $rules['content'] = 'required_without:url|mimes:swf';
+            $rules['url']      = 'required_without:content';
+            $message['content.required_without'] = '本地上传或者Flash地址填写一项。';
+            $message['content.mimes']              = '本地上传格式不正确。';
+            $message['url.required_without']      = '本地上传或者Flash地址填写一项。';
+        } else if ($type_id=='5') {
+            $rules['content'] = 'required_without:url|mimes:swf,flv,f4v';
+            $rules['url']     = 'required_without:content';
+            $message['content.required_without'] = '本地上传或者填写视频地址填写一项。';
+            $message['content.mimes']             = '本地上传格式不正确。';
+            $message['url.required_without']     = '本地上传或者填写视频地址填写一项。';
+        }
+
+        $request->validate($rules, $message);
+        $is_display = $request->input('is_display')=='on'?1:0;
+        $time = date('Y-m-d H:i:s', time());
+        $started_at = $request->input('started_at')?strtotime($request->input('started_at')):0;
+        $ended_at = $request->input('ended_at')?strtotime($request->input('ended_at')):0;
+
+        $subsite_id = $request->input('subsite_id');
+        $theme = $request->input('theme')?$request->input('theme'):'default';
+        $note = $request->input('note')?$request->input('note'):'';
+
+        $form_data = array(
+            'theme'        => $theme,
+            'alias'        => $request->input('alias'),
+            'is_display'  => $is_display,
+            'category_id' => $request->input('category_id'),
+            'type_id'      => $type_id,
+            'title'        => $request->input('title'),
+            'note'         => $note,
+            'list_order'  => $request->input('list_order'),
+            'started_at'  => $started_at,
+            'ended_at'    => $ended_at,
+            'subsite_id'  => $subsite_id,
+            'created_at'  => $time,
+            'updated_at'  => $time
+        );
+        if ($type_id=='1') {
+            //文字广告
+            $form_data['content']    = $request->input('content');
+            $form_data['url']         = $request->input('url')?$request->input('url'):'';
+            $form_data['text_color'] = $request->input('text_color')?$request->input('text_color'): '#000000';
+            $form_data['uid']         = 0;
+
+        } else if ($type_id=='2') {
+            //图片广告
+            $img_file = $request->input('img_file');
+            $img_url = $request->input('img_url');
+            $url = $request->input('url')?$request->input('url'):'';
+            $explain = $request->input('explain');
+            $uid = $request->input('uid', 0);
+            $up_file = null;
+            if ($request->hasFile('img_file')) {
+                $file = 'img_file';
+                $up_file=$request->$file->store(config('admin.upload.directory.image'), config('admin.upload.disk'));
+            }
+            $content = $up_file?$up_file:$img_url;
+            $form_data['content']    = $content;
+            $form_data['url']         = $url;
+            $form_data['text_color'] = '#000000';
+            $form_data['uid']         = $uid?$uid:0;
+            $form_data['explain']     = $explain;
+
+
+        } else if ($type_id=='3') {
+            //代码广告
+            $content = $request->input('content')?$request->input('content'):0;
+            $form_data['content']    = $content;
+            $form_data['uid']         = 0;
+            $form_data['text_color'] = '#000000';
+            $form_data['url']         = '';
+
+        } else if ($type_id=='4' || $type_id=='5') {
+            //flash广告 、视频广告
+            $url = $request->input('url')?$request->input('url'):'';
+            $up_file = null;
+            if ($request->hasFile('content')) {
+                $file = 'content';
+                $up_file=$request->$file->store(config('admin.upload.directory.file'), config('admin.upload.disk'));
+            }
+            $content = $up_file?$up_file:$url;
+            $form_data['content']    = $content;
+            $form_data['url']         = '';
+            $form_data['uid']         = 0;
+            $form_data['text_color'] = '#000000';
+        }
+        $subsites = $request->input('relate_subsites');
+        if(empty($subsites)){
+            $subsites = [];
+        }
+        if ($ad = Ad::create($form_data)) {
+            $set_data = array();
+            $set_data[] = array(
+                'ad_id'      => $ad->id,
+                'subsite_id' => get_subsite_id()
+            );
+            if ($subsites) {
+                foreach ($subsites as $k => $v) {
+                    if ($v) {
+                        $set_data[] = array(
+                            'ad_id'      => $ad->id,
+                            'subsite_id' => $v
+                        );
+                    }
+                }
+            }
+            if ($set_data) {
+                SubsiteAd::insert($set_data);
+            }
+
+            admin_toastr(trans('admin.save_succeeded'), 'success');
+            return redirect(admin_base_path().'/content/ad/index');
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Ad);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+        })->orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC');
+
+
+        $grid->title('广告标题')->display(function () {
+            $logo_html = '';
+            if ($this->type_id == '2') {
+                //判断图片中是否包含http
+                if (preg_match('/^http/', $this->content)) {
+                    $logo_html = '<span class="vtip" title="<img src=\''.$this->content.'\'  height=120>">
+                            <img class="avatar small" src="'.$this->content.'" align="absmiddle" style="width: 22px;height: 22px;">
+                        </span>';
+                } else {
+                    $logo_html = '<span class="vtip" title="<img src=\''.upload_asset($this->content).'\'  height=120>">
+                            <img class="avatar small" src="'.upload_asset($this->content).'" align="absmiddle" style="width: 22px;height: 22px;">
+                        </span>';
+                }
+            }
+            return $logo_html.$this->title;
+        })->width(250);
+        $grid->show_category()->category_name('所属广告位')->width(200);
+        $grid->type_id('广告类型')->display(function () {
+            if ($this->type_id == '1') {
+                return '文字';
+            } else if ($this->type_id == '2') {
+                return '图片';
+            } else if ($this->type_id == '3') {
+                return '代码';
+            } else if ($this->type_id == '4') {
+                return 'Flash';
+            } else if ($this->type_id == '5') {
+                return '视频';
+            }
+        });
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+
+        $grid->started_at('开始日期')->display(function () {
+            if (!$this->started_at) {
+                return date('Y-m-d', strtotime($this->created_at));
+            } else {
+                return $this->started_at;
+            }
+
+        });
+        $grid->ended_at('到期日期')->display(function () {
+            if ($this->ended_at>0 && strtotime($this->ended_at) <= strtotime(date('Y-m-d'))) {
+                return '<span style="color:#FF6600">已经到期</span>';
+            } else {
+                return $this->ended_at?$this->ended_at:'无限制';
+            }
+        });
+        $grid->is_display('状态')->display(function () {
+            return $this->is_display?'正常':'暂停';
+        });
+        $grid->list_order('排序');
+
+        //新增按钮
+        if (Admin::user()->can('content_ad_list_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('content_ad_list_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_ad_list_edit')) {
+                if ($actions->row['subsite_id']== get_subsite_id() || get_subsite_id()==0) {
+                    $actions->disableEdit(false);
+                }
+            }
+            if (Admin::user()->can('content_ad_list_delete')) {
+                if ($actions->row['subsite_id']== get_subsite_id() || get_subsite_id()==0) {
+                    $actions->disableDelete(false);
+                }
+            }
+        });
+
+        $grid->filter(function (Filter $filter) {
+            $filter->disableIdFilter();
+            $filter->column(2/3, function ($filter) {
+                $display_option = array(''=>'不限','1'=>'正常','0'=>'暂停');
+                $filter->equal('is_display', '显示状态')->radio($display_option);
+
+                $date1 = strtotime(date('Y-m-d', strtotime("+1 day")-1))-1;
+                $date3 = strtotime(date('Y-m-d', strtotime("+4 day")-1))-1;
+                $date7 = strtotime(date('Y-m-d', strtotime("+8 day")-1))-1;
+
+                $date_option = array(
+                    '' => '不限',
+                    $date1 => '已经到期',
+                    $date3 => '三天内',
+                    $date7 => '一周内'
+                );
+                $filter->where(function ($query) {
+                    $ended_at = "{$this->input}";
+                    $start = strtotime(date('Y-m-d', strtotime("+1 day")-1))-1;
+                    $start_time = 0;
+                    if ($ended_at > $start) {
+                        $start_time = strtotime(date('Y-m-d', time()))-1;
+                    }
+                    $query->whereRaw('ended_at > '.$start_time.' and ended_at < '."{$this->input}");
+                }, '到期时间', 'ended_at')->radio($date_option);
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                if ($subsites) {
+                    $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                    $filter->equal('subsite_id', '所属分站')->select($subsites);
+                }
+                $cates = AdCategory::get(['id', 'category_name'])->toArray();
+                $pre_arr = array('id'=>'','category_name'=>'不限');
+                array_unshift($cates, $pre_arr);
+                $cates = collect($cates)->pluck('category_name', 'id');
+                $filter->equal('category_id', '广告位')->select($cates);
+                $filter->like('title', '广告标题');
+            });
+        });
+
+        return $grid;
+    }
+    public function getCategory(Request $request)
+    {
+        $subsite_id = $request->input('q');
+        $where = array();
+        if ($subsite_id === null) {
+            $where = array();
+        } else {
+            $where = array('subsite_id'=>$subsite_id);
+        }
+        $cates = AdCategory::where($where)->get(['id', 'category_name'])->toArray();
+        $pre_arr = array('id'=>'','category_name'=>'不限');
+        array_unshift($cates, $pre_arr);
+        return collect($cates);
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Ad::findOrFail($id));
+        $ad_info = Ad::findOrFail($id);
+
+        $show->id('ID');
+        $show->title('广告标题');
+        $show->is_display('显示状态')->as(function ($is_display) {
+            return $is_display?'正常':'暂停';
+        });
+        if(get_subsite_open()){
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+
+        $show->category_id('广告位')->as(function ($category_id) {
+            $cate_info = AdCategory::where(array('id'=>$category_id))->first();
+            if ($cate_info) {
+                return $cate_info->category_name;
+            } else {
+                return '&nbsp';
+            }
+        });
+        $show->list_order('显示顺序');
+        $show->started_at('开始日期')->as(function ($started_at) {
+            return $started_at?$started_at:'无限制';
+        });
+        $show->ended_at('结束日期')->as(function ($ended_at) {
+            return $ended_at?$ended_at:'无限制';
+        });
+        $show->note('备注')->as(function ($note) {
+            return $note?$note:'&nbsp';
+        })->setEscape(false);
+
+        if ($ad_info->type_id=='1') {
+            $show->content('文字内容');
+            $show->url('文字链接')->as(function ($url) {
+                return $url?$url:'&nbsp';
+            })->setEscape(false);
+            $show->text_color('文字颜色')->as(function ($text_color) {
+                $html = '<i style="background-color: '.$text_color.';padding: 5px 15px;"></i>';
+                return $html;
+            })->setEscape(false);
+
+        } else if ($ad_info->type_id=='2') {
+            $show->content('图片')->image();
+            $show->url('图片链接')->as(function ($url) {
+                return $url?$url:'&nbsp';
+            })->setEscape(false);
+            $show->explain('图片说明文字')->as(function ($explain) {
+                return $explain?$explain:'&nbsp';
+            })->setEscape(false);
+            $show->uid('会员UID');
+        } else if ($ad_info->type_id=='3') {
+            $show->content('代码');
+        } else if ($ad_info->type_id=='4') {
+            $show->content('Flash地址')->image();
+        } else if ($ad_info->type_id=='5') {
+            $show->content('视频地址')->image();
+        }
+
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Ad);
+
+        $form->text('title', '广告标题')->help('(区分不同广告条目,并不在广告中显示)');
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '显示状态')->states($display_option)->default('1');
+
+        $subsites = array_merge(array('0'=>'总站'), array( '1' => '定海', '2' => '普陀'));
+        $form->checkbox('subsite_id', '所属分站')->options($subsites)->default('0');
+
+
+        $cate_option = AdCategory::all()->pluck('category_name', 'id');
+        $form->select('category_id', '广告位')->options($cate_option)->setWidth(3);
+
+        $form->number('list_order', '显示顺序')->help('(数字越大越靠前)');
+        $form->date('started_at', '开始日期')
+             ->format('YYYY-MM-DD')
+             ->rules('required|date', array('required'=>'开始日期不能为空。', 'date'=>'开始日期格式不正确。'))
+             ->help('(设置广告起始日期,格式yyyy-mm-dd,留空为不限制起始日期)');
+        $form->date('ended_at', '结束日期')
+             ->format('YYYY-MM-DD')
+             ->rules('required|date', array('required'=>'结束日期不能为空。', 'date'=>'结束日期格式不正确。'))
+             ->help('(设置广告结束日期,格式yyyy-mm-dd,留空为不限制结束日期)');
+        $form->textarea('note', '备注');
+        return $form;
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (get_subsite_id() == 0) {
+            $filter_id = $id;
+        } else {
+            $seletctors = Ad::where(array('subsite_id'=>get_subsite_id()))->whereIn('id', $ids)->get()->pluck('id')->toarray();
+            if ($seletctors) {
+                $filter_id = implode(',', $seletctors);
+            } else {
+                $filter_id = '';
+            }
+        }
+
+        if ($filter_id) {
+            if ($this->form()->destroy($filter_id)) {
+                $data = [
+                    'status'  => true,
+                    'message' => trans('admin.delete_succeeded'),
+                ];
+            } else {
+                $data = [
+                    'status'  => false,
+                    'message' => trans('admin.delete_failed'),
+                ];
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => '不能删除其它分站数据!',
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 352 - 0
app/Admin/Controllers/Content/AppealController.php

@@ -0,0 +1,352 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Tools\DialogTool;
+use App\Http\Controllers\Controller;
+use App\Models\Appeal;
+use App\Models\AuditReason;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Grid\Filter;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+use App\Services\Common\EmailService;
+
+class AppealController extends Controller
+{
+    use HasResourceActions;
+    protected $emailService;
+
+    /**
+     * AppealController constructor.
+     * @param $emailService
+     */
+    public function __construct(EmailService $emailService)
+    {
+        $this->emailService = $emailService;
+    }
+
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('账号申诉')
+            ->description(' ')
+            ->body(view('admin.content.appeal')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Appeal);
+        if (get_subsite_id() != 0) {
+            $where['subsite_id'] = get_subsite_id();
+            $grid->model()->where($where)->orderBy('status', 'asc')->orderBy('created_at', 'desc');
+        } else {
+            $grid->model()->orderBy('status', 'asc')->orderBy('created_at', 'desc');
+        }
+
+        $grid->real_name('真实姓名');
+        $grid->status('处理状态')->display(function () {
+            return $this->status?'已处理':'<span style="color:#ff0000;">未处理</span>';
+        });
+        $grid->description('申诉描述')->display(function () {
+            return '<span class="vtip" title="'.$this->description.'">'.cut_str($this->description, 35, 0, "...").'</span>';
+        })->width(300);
+        $grid->mobile('手机号码');
+        $grid->email('联系邮箱')->width(300);
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+
+        $grid->created_at('申诉时间');
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_appeal_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">处理</button>");
+            }
+            if ($actions->row->status == 0 && Admin::user()->can('content_appeal_sendemail')) {
+                $actions->append("<button class='btn btn-primary btn-xs send_email' data-code=".$actions->row['id']." data-email=".$actions->row['email']."><i class='fa fa-envelope-o'></i> 发送邮件</button>");
+            }
+            if (Admin::user()->can('content_appeal_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        if (Admin::user()->can('content_appeal_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+        if (!Admin::user()->can('content_appeal_delete') && !Admin::user()->can('content_appeal_audit')) {
+            $grid->disableRowSelector();
+        }
+        $grid->filter(function (Filter $filter) {
+            $filter->disableIdFilter();
+            $filter->column(2/3, function ($filter) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                if ($subsites) {
+                    $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                    $filter->equal('subsite_id', '所属分站')->select($subsites);
+                }
+
+                if (get_subsite_id() == 0) {
+                    $nums = Appeal::where(array('status'=>'0'))->get()->count();
+                } else {
+                    $nums = Appeal::where(array('status'=>'0', 'subsite_id'=>get_subsite_id()))->get()->count();
+                }
+                $num_html ='';
+                if ($nums>0) {
+                    //$num_html = '<span style="color:#ff0000;">('.$nums.')</span>';
+                    $num_html = '('.$nums.')';
+                }
+                $status_option = array('0'=>'未处理'.$num_html,'1'=>'已处理');
+                $status_option = array(''=>'不限')+$status_option;
+                $filter->equal('status', '处理状态')->radio($status_option);
+                $date3   = date('Y-m-d', strtotime("-3 day"));
+                $date7   = date('Y-m-d', strtotime("-7 day"));
+                $date30  = date("Y-m-d", strtotime("-1 month"));
+                $date180 = date("Y-m-d", strtotime("-6 month"));
+                $date360 = date("Y-m-d", strtotime("-1 year"));
+                $date_option = array(
+                    ''    => '不限',
+                    $date3   => '三天内',
+                    $date7   => '一周内',
+                    $date30  => '一月内',
+                    $date180 => '半年内',
+                    $date360 => '一年内',
+                );
+                $filter->where(function ($query) {
+                    $query->where('created_at', '>=', "{$this->input}");
+                }, '申诉时间', 'created_at')->radio($date_option);
+            });
+        });
+
+        //审核功能
+        if (Admin::user()->can('content_appeal_audit')) {
+            $grid->tools(function ($tools) {
+                $form = new \Encore\Admin\Widgets\Form();
+                $form->action(route('appeal.audit'));
+                $status_option = array('0'=>'未处理','1'=>'已处理');
+                $form->radio('status', '将所选账号申诉设置为:')->options($status_option)->default(1)->setWidth(8, 4);
+                $form->hidden('ids');
+                $form->json('val');
+                $config = array('title'=>'处理账号申诉','button'=>'处理','dialog_cancel' => "取消", 'dialog_ok' => "确认", 'is_batch' => true);
+                $tools->append(new DialogTool($form, $config));
+            });
+        }
+
+        /*$grid->tools(function (Grid\Tools $tools) {
+            $tools->disableRefreshButton();
+        });*/
+
+        return $grid;
+    }
+
+    public function audit(Request $request)
+    {
+        $rst = $request->validate(['status'=>'required'], array('status.required'=>'请选择处理状态'));
+
+        $ids = $request->input('ids');
+        if (empty($ids)) {
+            if($request->type) {
+                admin_toastr('请选择需要处理的数据', 'error');
+                return back();
+            }else{
+                return admin_toastr('请选择需要处理的数据', 'error');
+            }
+        }
+        $id_arr = explode(',', $ids);
+
+        $update_data = array(
+            'status'      => $request->input('status'),
+            'updated_at' => date('Y-m-d H:i:s', time())
+        );
+        if (Appeal::whereIn('id', $id_arr)->update($update_data) === false) {
+            if($request->type) {
+                admin_toastr('处理失败', 'error');
+                return back();
+            }else{
+                return admin_toastr('处理失败', 'error');
+            }
+        } else {
+            //添加审核日志
+            $reason_data = array('ids'=>$id_arr,'status'=>$request->input('status'),'type'=>'7');
+            if ($request->input('audit')=='1') {
+                $reason_data['reason'] = '将所选账号申诉设置为已处理';
+            } else {
+                $reason_data['reason'] = '将所选账号申诉设置为未处理';
+            }
+            AuditReason::addData($reason_data);
+            if($request->type) {
+                admin_toastr('处理成功', 'success');
+                return back();
+            }else{
+                return admin_toastr('处理成功', 'success');
+            }
+        }
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Appeal::findOrFail($id));
+
+        $show->id('ID');
+        $show->real_name('真实姓名');
+        $show->mobile('手机号码');
+        $show->email('联系邮箱');
+        $show->description('描述');
+        if(get_subsite_open()){
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+        $show->status('处理状态')->as(function ($status) {
+            if ($status) {
+                return '已处理';
+            }
+            return '未处理';
+        });
+        $show->created_at('申诉时间');
+        $show->updated_at('处理时间');
+
+        /*$show->panel()->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+        });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Appeal);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+    //发送邮件
+    public function sendEmail(Request $request)
+    {
+        $username = $request->input('username', '');
+        $password = $request->input('pwd', '');
+        $email    = $request->input('email', '');
+        $id       = $request->input('ids', '');
+        if (!$username) {
+            admin_toastr('请输入登录用户名!', 'error');
+            return back();
+        }
+        if (!$password) {
+            admin_toastr('请输入登录密码!', 'error');
+            return back();
+        }
+
+        if (!$id || !$email) {
+            admin_toastr('发送失败,参数错误!', 'error');
+            return back();
+        }
+        if (!fieldRegex($email, 'email')) {
+            admin_toastr('发送失败,邮箱格式错误!', 'error');
+            return back();
+        }
+        $body = '您好,您的帐号申诉已被受理!您的登录账号是:'.$username.',登录密码是:'.$password.'。';
+        $title = '账号申诉回执邮件';
+
+        $this->emailService->sendMail($email, EmailService::TEMPLATE_SEND_CONTENT, ['title'=>$title], ['content'=>$body]);
+
+        //修改处理字段
+        $update_data = array(
+            'status'      => 1,
+            'updated_at' => date('Y-m-d H:i:s', time())
+        );
+        $id_arr = explode(',', $id);
+        Appeal::whereIn('id', $id_arr)->update($update_data);
+        admin_toastr('回执邮件发送成功!', 'success');
+        return back();
+    }
+}

+ 300 - 0
app/Admin/Controllers/Content/ArticleCategoryController.php

@@ -0,0 +1,300 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\ArticleCategory;
+use App\Models\ArticleCategoryRole;
+use App\Models\Role;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Column;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Layout\Row;
+use Encore\Admin\Show;
+use Encore\Admin\Tree;
+use Encore\Admin\Widgets\Box;
+
+//use Encore\Admin\Facades\Admin;
+class ArticleCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header(trans('新闻分类'))
+            ->description(trans('系统默认分类不能删除!删除顶级级分类将会自动删除此分类下的子分类。'))
+            ->row(function (Row $row) {
+                if (userAdmin::user()->can('content_article_category_create')) {
+                    $row->column(6, $this->treeView()->render());
+                    $row->column(6, function (Column $column) {
+                        $form = new \Encore\Admin\Widgets\Form();
+                        $form->action(route('article.category.index'));
+                        $form->text('category_name', '名称')->setMustMark();
+                        $cate_option = ArticleCategory::where(array('parent_id'=>0))->OrderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->pluck('category_name', 'id');
+                        $cate_option = $cate_option->toArray();
+                        $cate_option = array('0'=>'顶级分类')+$cate_option;
+                        $form->select('parent_id', '所属分类')->options($cate_option)->default(0)->setMustMark();
+                        $form->number('list_order', '排序')->min(0)->default(0)->help('(数字越大越靠前)')->setMustMark();
+                        $form->multipleSelect('roles', trans('admin.roles'))->options(Role::all()->pluck('name', 'id'));
+                        $form->text('title', 'Title')->help('(不填则为分类名称)');
+                        $form->text('keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名');
+                        $form->textarea('description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名');
+                        $form->hidden('admin_set')->value(0);
+                        $form->hidden('_token')->default(csrf_token());
+                        $form->disableReset();
+                        $column->append((new Box(trans('admin.new'), $form))->style('success'));
+                    });
+                } else {
+                    $row->column(12, $this->treeView()->render());
+                }
+            });
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('新闻分类')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('新闻分类')
+            ->description(' ')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('新闻分类')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ArticleCategory);
+
+        $grid->id('ID');
+        $grid->created_at('添加时间');
+        $grid->updated_at('更新时间');
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ArticleCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->category_name('名称');
+        $show->parent_id('所属分类')->as(function ($parent_id) {
+            $category_name = '顶级分类';
+            if ($parent_id) {
+                $cate_info = ArticleCategory::where('id', $parent_id)->first();
+                if ($cate_info) {
+                    $category_name = $cate_info->category_name;
+                } else {
+                    $category_name = '';
+                }
+            }
+            return $category_name;
+        });
+        $show->list_order('排序');
+
+        $show->roles(trans('admin.roles'))->as(function ($role) {
+            return $role->pluck('name');
+        })->label();
+
+        $show->title('Title');
+        $show->keywords('Keywords');
+        $show->description('Description');
+        $show->admin_set('系统分类')->as(function ($admin_set) {
+            return $admin_set?'是':'否';
+        });
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new ArticleCategory);
+        $form->text('category_name', '名称')->rules('required|max:15', array('required'=>'名称不能为空。', 'max'=>'名称长度不能超过15。'))->setWidth(4)->setMustMark();
+        $cate_option = ArticleCategory::where(array('parent_id'=>0))->OrderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->get()->pluck('category_name', 'id');
+        $cate_option = $cate_option->toArray();
+        $cate_option = array('0'=>'顶级分类')+$cate_option;
+        $form->select('parent_id', '所属分类')->options($cate_option)->default(0)->rules('required', array('required'=>'请选择所属分类。'))->setWidth(4)->setMustMark();
+        $form->number('list_order', '排序')
+             ->min(0)->default(0)
+             ->rules('required', array('required'=>'排序不能为空。'))
+             ->help('(数字越大越靠前)')
+             ->setMustMark();
+        $form->multipleSelect('roles', trans('admin.roles'))->options(Role::all()->pluck('name', 'id'));
+        $form->text('title', 'Title')->help('(不填则为分类名称)')->rules('max:25', array('max'=>'Title长度不能大于25。'))->setWidth(4);
+        $form->text('keywords', 'Keywords')
+             ->placeholder('合理设置Keywords有利于搜索引擎排名')
+             ->rules('max:25', array('max'=>'Keywords长度不能大于25。'));
+        $form->textarea('description', 'Description')
+             ->rules('max:25', array('max'=>'Description长度不能大于25。'))
+             ->placeholder('合理设置Description有利于搜索引擎排名');
+        $form->hidden('admin_set');
+        $form->saving(function (Form $form) {
+            $form->admin_set = $form->admin_set?$form->admin_set:0;
+        });
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+
+    public function stores()
+    {
+        $data=$this->form()->getValidateInput();
+        $cate = new ArticleCategory();
+        $cate->category_name = $data['category_name'];
+        $cate->parent_id     = $data['parent_id'];
+        $cate->list_order    = $data['list_order'];
+        $cate->title          = $data['title'];
+        $cate->keywords       = $data['keywords'];
+        $cate->description    = $data['description'];
+        $cate->admin_set      = $data['admin_set']?$data['admin_set']:'0';
+
+        if ($cate->save()) {
+            $cate_id = $cate->id;
+            $roles = $data['roles'];
+            $time = date('Y-m-d H:i:s', time());
+            $role_data = array();
+            if ($roles) {
+                foreach ($roles as $k => $v) {
+                    $role_data[] = array(
+                        'role_id'=> $v,
+                        'article_category_id' => $cate_id,
+                        'created_at' => $time,
+                        'updated_at' => $time
+                    );
+                }
+                ArticleCategoryRole::insert($role_data);
+            }
+            admin_toastr(trans('admin.save_succeeded'));
+            return redirect(admin_base_path('/content/article/category'));
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Tree
+     */
+    protected function treeView()
+    {
+        return ArticleCategory::tree(function (Tree $tree) {
+            $tree->disableRefresh();
+            $tree->disableSave();
+
+            $tree->branch(function ($branch) {
+                return "{$branch['category_name']} (id:{$branch['id']})";
+            });
+            $tree->setView(array(
+                'tree'   => 'admin::tree',
+                'branch' => 'admin.content.article_branch'
+            ));
+            $tree->query(function ($model) {
+                $not_ids = ArticleCategory::categoryIds();
+                if ($not_ids) {
+                    return $model->whereNotIn('id', $not_ids)->OrderBy('list_order', 'DESC')->orderBy('created_at', 'DESC');
+                } else {
+                    return $model->OrderBy('list_order', 'DESC')->orderBy('created_at', 'DESC');
+                }
+            });
+        });
+    }
+    public function destroy($id)
+    {
+        $id_arr =  explode(',', $id);
+        $children_ids = ArticleCategory::whereIn('parent_id', $id_arr)->select('id')->get()->pluck('id')->toArray();
+        if ($children_ids) {
+            $children_ids = implode(',', $children_ids);
+        } else {
+            $children_ids = '';
+        }
+        if ($this->form()->destroy($id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+            //删除分类与角色的对应关系
+            if ($children_ids) {
+                $where = array();
+                $ids = explode(',', $children_ids);
+                ArticleCategoryRole::whereIn('article_category_id', $ids)->delete();
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 564 - 0
app/Admin/Controllers/Content/ArticleController.php

@@ -0,0 +1,564 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\Article;
+use App\Models\ArticleCategory;
+use App\Models\ArticleProperty;
+use App\Models\Subsite;
+use App\Models\SubsiteArticle;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+
+class ArticleController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('新闻列表')
+            ->description(' ')
+            ->body(view('admin.content.article')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+
+        return $content
+            ->header('新闻')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('新闻')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('新闻')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Article);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+        })->orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC');
+
+        $grid->column('新闻标题')->display(function () {
+            $style="color:".$this->tit_color.';';
+            if ($this->tit_b=='1') {
+                $style .='font-weight:bold;';
+            }
+            $cate = ArticleCategory::where(array('id'=>$this->type_id))->first();
+            if ($this->parent_id=='0') {
+                $params = '?type_id=&parent_id='.$this->type_id;
+            } else {
+                $params = '?type_id='.$this->type_id.'&parent_id='.$this->parent_id;
+            }
+            $title_url = url(admin_base_path().'/content/article/index'.$params);
+            if ($cate) {
+                return '<a href='.$title_url.' style="color: #006699;">['.$cate->category_name.']</a> <span style="'.$style.'">'.$this->title.'</span>';
+            } else {
+                return '<span style="'.$style.'">'.$this->title.'</span>';
+            }
+        })->width(200);
+        $grid->small_img('缩略图')->display(function () {
+            if ($this->small_img) {
+                return '<span class="vtip" title="<img src=\''.upload_asset($this->small_img).'\'  height=120>">
+                            <img class="avatar small" src="'.upload_asset($this->small_img).'" align="absmiddle" style="width: 22px;height: 22px;">
+                        </span>';
+            } else {
+                return '';
+            }
+        });
+
+        $grid->robot('添加方式');
+        $grid->show_property()->category_name('新闻属性');
+        if (get_subsite_open()) {
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+
+        $grid->list_order('排序');
+        $grid->click('点击量');
+        $grid->created_at('添加时间');
+        //新增按钮
+        if (userAdmin::user()->can('content_article_list_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (userAdmin::user()->can('content_article_list_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+
+        $grid->actions(function ($actions) {
+            if (userAdmin::user()->can('content_article_list_delete')) {
+                if ($actions->row['subsite_id']== get_subsite_id() || get_subsite_id()==0) {
+                    $actions->disableEdit(false);
+                }
+            }
+            if (userAdmin::user()->can('content_article_list_edit')) {
+                if ($actions->row['subsite_id']== get_subsite_id() || get_subsite_id()==0) {
+                    $actions->disableDelete(false);
+                }
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->equal('ID', '新闻ID');
+            $filter->like('title', '新闻标题');
+            $not_ids = ArticleCategory::categoryIds();
+            if ($not_ids) {
+                $cate_option = ArticleCategory::where('parent_id', '0')->WhereNotIn('id', $not_ids)->get()->pluck('category_name', 'id');
+            } else {
+                $cate_option = ArticleCategory::where('parent_id', '0')->get()->pluck('category_name', 'id');
+            }
+
+            /*$filter->where(function ($query) {
+
+                $query->where('parent_id', '=', "{$this->input}")->orWhere('type_id', '=', "{$this->input}");
+            }, '新闻分类', 'parent_id')->select($cate_option)->load('type_id', 'get_category', 'id', 'category_name');
+
+            $pid = \Illuminate\Support\Facades\Request::input('parent_id');
+            if ($pid) {
+                $child_cates = ArticleCategory::where(array('parent_id'=>$pid))->get(['id', 'category_name'])->toArray();
+            } else {
+                $child_cates = array();
+            }
+            $pre_arr = array('id'=>'','category_name'=>'不限');
+            array_unshift($child_cates, $pre_arr);
+            $filter->equal('type_id', '新闻子分类')->select(collect($child_cates)->pluck('category_name', 'id'));*/
+
+            /*$menuModel = config('admin.database.menu_model');
+            $form->select('parent_id', trans('admin.parent_id'))->options($menuModel::selectOptions());*/
+
+            $article_cates = ArticleCategory::selectOptions(function ($query) {
+                return $query->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
+            });
+            if (array_has($article_cates, '0')) {
+                unset($article_cates[0]);
+            }
+            $filter->where(function ($query) {
+                $query->where('parent_id', '=', "{$this->input}")->orWhere('type_id', '=', "{$this->input}");
+            }, '新闻分类', 'parent_id')->select($article_cates);
+
+            $property_option = ArticleProperty::orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->pluck('category_name', 'id');
+            $filter->equal('property_id', '新闻属性')->select($property_option)->default('');
+
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            if ($subsites) {
+                $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                $filter->equal('subsite_id', '所属分站')->select($subsites);
+            }
+
+            $date3   = date('Y-m-d', strtotime("-3 day"));
+            $date7   = date('Y-m-d', strtotime("-7 day"));
+            $date30  = date("Y-m-d", strtotime("-1 month"));
+            $date180 = date("Y-m-d", strtotime("-6 month"));
+            $date360 = date("Y-m-d", strtotime("-1 year"));
+            $date_option = array(
+                ''    => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            );
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+        });
+        return $grid;
+    }
+    public function getCategory(Request $request)
+    {
+        $parent_id = $request->input('q');
+        $where = array('parent_id'=>$parent_id);
+        $not_ids = ArticleCategory::categoryIds();
+        if ($not_ids) {
+            $cates = ArticleCategory::where($where)->WhereNotIn('id', $not_ids)->get(['id', 'category_name'])->toArray();
+        } else {
+            $cates = ArticleCategory::where($where)->get(['id', 'category_name'])->toArray();
+        }
+
+        $pre_arr = array('id'=>'','category_name'=>'不限');
+        array_unshift($cates, $pre_arr);
+        return collect($cates);
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Article::findOrFail($id));
+
+        $show->id('ID');
+        $show->title('标题');
+        $show->tit_color('标题颜色')->as(function ($tit_color) {
+            $html = '<i style="background-color: '.$tit_color.';padding: 5px 15px;"></i>';
+            return $html;
+        })->setEscape(false);
+        $show->show_category("新闻分类")->as(function ($show_category) {
+            return $show_category->category_name;
+        });
+        $show->small_img('缩略图')->image();
+        if (get_subsite_open()) {
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+
+        $show->content('内容')->setEscape(false);
+        $show->is_display('是否显示')->as(function ($is_display) {
+            return $is_display?'是':'否';
+        });
+        $show->tit_b('标题加粗')->as(function ($tit_b) {
+            return $tit_b?'是':'否';
+        });
+        $show->released_at('发布日期');
+        $show->list_order('新闻排序');
+        $show->author('作者')->as(function ($author) {
+            return $author?$author:'&nbsp';
+        })->setEscape(false);
+        $show->source('来源')->as(function ($source) {
+            return $source?$source:'&nbsp';
+        })->setEscape(false);
+        $show->show_property("新闻属性")->as(function ($show_property) {
+            return $show_property->category_name;
+        });
+        $show->is_url('外部链接')->as(function ($is_url) {
+            return $is_url?$is_url:'&nbsp';
+        })->setEscape(false);
+        $show->seo_keywords('Keywords')->as(function ($seo_keywords) {
+            return $seo_keywords?$seo_keywords:'&nbsp';
+        })->setEscape(false);
+        $show->seo_description('Description')->as(function ($seo_description) {
+            return $seo_description?$seo_description:'&nbsp';
+        })->setEscape(false);
+        $show->click('点击量');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new Article);
+        $form->text('title', '新闻标题')->rules('required|max:100', array('required'=>'新闻标题不能为空。','max'=>'新闻标题长度不能大于100。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', array('required'=>'标题颜色不能为空。','regex'=>'标题颜色格式不正确。'))->default('#000000');
+
+        //$cate_option = ArticleCategory::selectOptions();
+        $cate_option = ArticleCategory::selectOptions(function ($query) {
+            return $query->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
+        });
+        unset($cate_option[0]);
+        $form->select('type_id', '新闻分类')->options($cate_option)->default(key($cate_option))->rules('required', array('required'=>'请选择新闻分类。'))->setWidth(4)->setMustMark();
+        $form->image('small_img', '缩略图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', array('image'=>'缩略图请选择图片文件。','mimes'=>'请选择jpeg,bmp,png格式的缩略图上传。'))->setWidth(3);
+        if (get_subsite_id()==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty() && get_subsite_id()==0) {
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+        $form->hidden('subsite_id')->value(get_subsite_id());
+        $form->hidden('parent_id')->value(0);
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->default('1')->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->default(0)->setMustMark();
+        $form->date('released_at', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'))->default(date('Y-m-d', time()));
+        $form->number('list_order', '新闻排序')->min(0)->default(255)->rules('required', array('required'=>'新闻排序不能为空。'))->help('(数字越大越靠前)');
+        $form->text('author', '作者')->rules('max:20', array('max'=>'作者长度不能大于20。'))->setWidth(4);
+        $form->text('source', '来源')->rules('max:20', array('max'=>'来源长度不能大于20。'))->setWidth(4);
+
+        $cate_option = ArticleProperty::orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->pluck('category_name', 'id');
+        $form->select('property_id', '新闻属性')
+            ->options($cate_option)
+            ->default(key($cate_option->toArray()))
+            ->rules('required', array('required'=>'请选择新闻属性。'))
+            ->setWidth(4)
+            ->setMustMark();
+
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+
+        $form->saving(function (Form $form) {
+            $form->released_at = strtotime($form->released_at);
+            $author = $form->author?$form->author:'';
+            $source = $form->source?$form->source:'';
+            $is_url = $form->is_url?$form->is_url:'';
+            $seo_keywords = $form->seo_keywords?$form->seo_keywords:'';
+            $seo_description = $form->seo_description?$form->seo_description:'';
+            $form->author = $author;
+            $form->source = $source;
+            $form->is_url = $is_url;
+            $form->seo_keywords = $seo_keywords;
+            $form->seo_description = $seo_description;
+
+            $type_info = ArticleCategory::find($form->type_id);
+            $parent_id = $type_info->parent_id;
+            $form->parent_id = $parent_id;
+        });
+        $form->saved(function (Form $form) {
+            $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+            if (empty($subsites)) {
+                $subsites = [];
+            }
+            $subsites = array_merge(array(get_subsite_id()), $subsites);
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'article_id' => $form->model()->id,
+                        'subsite_id'=> $v
+                    );
+                }
+                Cache::forget('article_index_list_home_'.$v);    //清除缓存
+            }
+            SubsiteArticle::insert($set_data);
+        });
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        return $form;
+    }
+    protected function editForm($id)
+    {
+        $info = Article::find($id);
+
+        $form = new ValidateForm(new Article);
+        $form->text('title', '新闻标题')->rules('required|max:100', array('required'=>'新闻标题不能为空。','max'=>'新闻标题长度不能大于100。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->default('#000000')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', array('required'=>'标题颜色不能为空。','regex'=>'标题颜色格式不正确。'));
+
+        //$cate_option = ArticleCategory::all()->pluck('category_name', 'id');
+        //$cate_option = ArticleCategory::selectOptions();
+        $cate_option = ArticleCategory::selectOptions(function ($query) {
+            return $query->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
+        });
+        unset($cate_option[0]);
+        $form->select('type_id', '新闻分类')->options($cate_option)->default(key($cate_option))->rules('required', array('required'=>'请选择新闻分类。'))->setWidth(4)->setMustMark();
+        $form->image('small_img', '缩略图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', array('image'=>'缩略图请选择图片文件。','mimes'=>'请选择jpeg,bmp,png格式的缩略图上传。'))->setWidth(3);
+        if ($info->subsite_id==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', $info->subsite_id)))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty() && $info->subsite_id==0) {
+            $relations = SubsiteArticle::where(array('article_id'=>$id))->get()->pluck('subsite_id')->toArray();
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+        $form->hidden('subsite_id')->value(get_subsite_id());
+        $form->hidden('parent_id');
+
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->setMustMark();
+        $form->date('released_at', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'));
+        $form->number('list_order', '新闻排序')->min(0)->default(0)->rules('required', array('required'=>'新闻排序不能为空。'))->help('(数字越大越靠前)');
+        $form->text('author', '作者')->rules('max:20', array('max'=>'作者长度不能大于20。'))->setWidth(3);
+        $form->text('source', '来源')->rules('max:20', array('max'=>'来源长度不能大于20。'))->setWidth(3);
+        $cate_option = ArticleProperty::orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->pluck('category_name', 'id');
+        $form->select('property_id', '新闻属性')->options($cate_option)->default(key($cate_option->toArray()))->rules('required', array('required'=>'请选择新闻属性。'))->setWidth(3)->setMustMark();
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->saving(function (Form $form) {
+            if (!request()->has(Form\Field::FILE_DELETE_FLAG)) {
+                $form->released_at = strtotime($form->released_at);
+                $author = $form->author?$form->author:'';
+                $source = $form->source?$form->source:'';
+                $is_url = $form->is_url?$form->is_url:'';
+                $seo_keywords = $form->seo_keywords?$form->seo_keywords:'';
+                $seo_description = $form->seo_description?$form->seo_description:'';
+                $form->author = $author;
+                $form->source = $source;
+                $form->is_url = $is_url;
+                $form->seo_keywords = $seo_keywords;
+                $form->seo_description = $seo_description;
+                $type_info = ArticleCategory::find($form->type_id);
+                $parent_id = $type_info->parent_id;
+                $form->parent_id = $parent_id;
+            }
+        });
+
+        $form->saved(function (Form $form) {
+            if (!request()->has(Form\Field::FILE_DELETE_FLAG)) {
+                $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+                if (empty($subsites)) {
+                    $subsites = [];
+                }
+                $subsites = array_merge(array($form->model()->subsite_id), $subsites);
+                SubsiteArticle::where('article_id', $form->model()->id)->delete();
+                $set_data = array();
+                foreach ($subsites as $k => $v) {
+                    if ($v !== null) {
+                        $set_data[] = array(
+                            'article_id' => $form->model()->id,
+                            'subsite_id'=> $v
+                        );
+                    }
+                    Cache::forget('article_index_list_home_'.$v);    //清除缓存
+                }
+                SubsiteArticle::insert($set_data);
+            }
+        });
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (get_subsite_id() == 0) {
+            $filter_id = $id;
+        } else {
+            $seletctors = Article::where(array('subsite_id'=>get_subsite_id()))->whereIn('id', $ids)->get()->pluck('id')->toarray();
+            if ($seletctors) {
+                $filter_id = implode(',', $seletctors);
+            } else {
+                $filter_id = '';
+            }
+        }
+        //获取所有分站信息
+        $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+        if ($subsites) {
+            foreach ($subsites as $key => $val) {
+                Cache::forget('article_index_list_home_'.$key);
+            }
+        }
+        if ($filter_id) {
+            if ($this->form()->destroy($filter_id)) {
+                $data = [
+                    'status'  => true,
+                    'message' => trans('admin.delete_succeeded'),
+                ];
+            } else {
+                $data = [
+                    'status'  => false,
+                    'message' => trans('admin.delete_failed'),
+                ];
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => '不能删除其它分站数据!',
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 190 - 0
app/Admin/Controllers/Content/ArticlePropertyController.php

@@ -0,0 +1,190 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\ArticleProperty;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class ArticlePropertyController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('新闻属性')
+            ->description('系统默认属性不能删除!')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('新闻属性')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('新闻属性')
+            ->description(' ')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('新闻属性')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ArticleProperty);
+
+        $grid->model()->orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC');
+
+        $grid->category_name('属性名称');
+        $grid->admin_set('系统属性')->display(function ($admin_set) {
+            return $admin_set?"是":"否";
+        });
+        $grid->list_order('排序');
+        $grid->created_at('添加时间');
+        $grid->actions(function ($actions) {
+            //行操作
+            if (Admin::user()->can('content_article_property_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_article_property_delete') && $actions->row['admin_set']!=1) {
+                $actions->disableDelete(false);
+            }
+        });
+        $grid->disableFilter();
+
+        //新增按钮
+        if (Admin::user()->can('content_article_property_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('content_article_property_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ArticleProperty::findOrFail($id));
+
+        $show->id('ID');
+        $show->category_name('属性名称');
+        $show->admin_set('系统分类')->as(function ($admin_set) {
+            return $admin_set?'是':'否';
+        });
+        $show->list_order('排序');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ArticleProperty);
+        $form->text('category_name', '属性名称')->rules('required|max:25', array('required'=>'属性名称不能为空。','max'=>'属性名称长度不能大于25个字符。'))->setWidth(4)->setMustMark();
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required', array('required'=>'排序不能为空。'))->help('(数字越大越靠前)')->setMustMark();
+        $form->hidden('admin_set')->value(0);
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+    public function destroy($id)
+    {
+        $id_arr =  explode(',', $id);
+        $admin_set_cates = ArticleProperty::where(array('admin_set'=>'1'))->select('id')->get()->pluck('id')->toArray();
+        foreach ($id_arr as $k => $v) {
+            if (in_array($v, $admin_set_cates)) {
+                unset($id_arr[$k]);
+            }
+        }
+        $filter_id = implode(',', $id_arr);
+        if ($this->form()->destroy($filter_id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 230 - 0
app/Admin/Controllers/Content/ComplaintAdviserController.php

@@ -0,0 +1,230 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\ComplaintConsultant;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+
+class ComplaintAdviserController extends Controller
+{
+    use HasResourceActions;
+    
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('投诉顾问')
+            ->description('列表')
+            ->body(view('admin.content.complaint_adviser')->with(['gird'=>$this->grid()->render()]));
+    }
+    
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('投诉顾问')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+    
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('投诉顾问')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+    
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('投诉顾问')
+            ->description('创建')
+            ->body($this->form());
+    }
+    
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ComplaintConsultant);
+        $grid->model()->whereHas('consultant')->whereHas('company')->orderByRaw('status asc,created_at desc');
+
+        $grid->column('consultant.name','被投诉顾问')->width(100);
+        $grid->status('处理情况')->display(function ($status) {
+            if($status==0){
+                return '<span style="color:#FF6600">未处理</span>';
+            }elseif ($status==1){
+                return '属实';
+            }else{
+                return '不属实';
+            }
+        });
+        $grid->notes('投诉内容')->display(function ($notes){
+            return '<span title="'.$notes.'">'.$notes.'</span>';
+        })->width(200);
+        
+        $grid->column('company.username','投诉者')->width(100);
+        
+        $grid->created_at('投诉时间');
+        
+        $grid->actions(function ($actions) {
+            $actions->disableView();
+            if (Admin::user()->can('company_consultant_complaint_adviser')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+            if (Admin::user()->can('company_consultant_complaint_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+    
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('company_consultant_complaint_adviser')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="audit_adviser" title="审核">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">审核
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+        
+        //批量删除
+        if (Admin::user()->can('company_consultant_complaint_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+    
+        $grid->filter(function ($filter) {
+            $filter->column(1/2, function ($filter) {
+                $filter->like('consultant.name','被投诉顾问');
+                $filter->equal('status', '处理情况')->select([
+                    0=>'未处理',
+                    1=>'属实',
+                    2=>'不属实',
+                ]);
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('company.username', '投诉者');
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '投诉时间', 'created_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+            });
+        });
+        
+        
+        return $grid;
+    }
+    
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ComplaintConsultant::findOrFail($id));
+        
+        return $show;
+    }
+    
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ComplaintConsultant);
+       
+        return $form;
+    }
+    
+    public function auditAdviser(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.complaint.auditAdviserR'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('status', '处理情况')->options([1=>'属实',2=>'不属实'])->default(1);
+        return json_encode(['html'=>$form->render(),'detail'=>'审核投诉']);
+    }
+    
+    public function auditAdviserR(Request $request)
+    {
+        $id = $request->id;
+        $status = $request->status;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('请选择投诉对象', 'error');
+            return back();
+        }
+        $result = ComplaintConsultant::whereIn('id', $arr)->update(['status'=>$status]);
+        if($result){
+            admin_toastr('处理成功!', 'success');
+        }else{
+            admin_toastr('处理失败!', 'error');
+        }
+        return back();
+    }
+    
+}

+ 190 - 0
app/Admin/Controllers/Content/ExplainCategoryController.php

@@ -0,0 +1,190 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\ExplainCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class ExplainCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('说明页分类')
+            ->description('系统分类不能删除')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('说明页分类')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('说明页分类')
+            ->description(' ')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('说明页分类')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ExplainCategory);
+
+        $grid->model()->orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC');
+
+        $grid->category_name('分类名称');
+        $grid->admin_set('类型')->display(function ($admin_set) {
+            return $admin_set? "系统分类":"自定义分类";
+        });
+        $grid->list_order('排序');
+        $grid->created_at('添加时间');
+
+        $grid->tools(function (Grid\Tools $tools) {
+            if (Admin::user()->can('content_explain_category_delete')) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            }
+        });
+        if (Admin::user()->can('content_explain_category_create')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_explain_category_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_explain_category_delete') && $actions->row['admin_set']!=1) {
+                $actions->disableDelete(false);
+            }
+        });
+        $grid->disableFilter();
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ExplainCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->category_name('分类名称');
+        $show->admin_set('是否系统分类');
+        $show->list_order('排序');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ExplainCategory);
+
+        $form->text('category_name', '分类名称')->rules('required|max:10', array('required'=>'分类名称不能为空。','max'=>'分类名称长度不能大于25个字符。'))->setWidth(4)->setMustMark();
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required|min:0', array('required'=>'排序不能为空。','min'=>'排序不能小于0'))->help('(数字越大越靠前)');
+        $form->hidden('admin_set')->value(0);
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+
+    /*
+     *  重写批量删除方法
+     */
+    public function destroy($id)
+    {
+        $id_arr =  explode(',', $id);
+        $admin_set_cates = ExplainCategory::where(array('admin_set'=>'1'))->select('id')->get()->pluck('id')->toArray();
+        foreach ($id_arr as $k => $v) {
+            if (in_array($v, $admin_set_cates)) {
+                unset($id_arr[$k]);
+            }
+        }
+        $filter_id = implode(',', $id_arr);
+        if ($this->form()->destroy($filter_id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+
+        return response()->json($data);
+    }
+
+}

+ 418 - 0
app/Admin/Controllers/Content/ExplainController.php

@@ -0,0 +1,418 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\Explain;
+use App\Models\ExplainCategory;
+use App\Models\Subsite;
+use App\Models\SubsiteExplain;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Cache;
+
+//use Encore\Admin\Grid;
+
+class ExplainController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('说明页列表')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('说明页')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('说明页')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('说明页')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Explain);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+        })->orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC');
+
+        $grid->column('页面名称')->display(function () {
+            return '<a href="'.route(url_rewrite('AIX_explainshow'), ['id'=>$this->id]).'" target="_blank">'.$this->title.'</a>';
+        })->width(250);
+        $grid->show_category()->category_name('所属分类')->width(250);
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+
+        $grid->list_order('排序');
+        $grid->click('点击');
+        $grid->created_at('添加时间');
+
+        if (Admin::user()->can('content_explain_list_create')) {
+            $grid->disableCreateButton(false);
+        }
+        if (Admin::user()->can('content_explain_list_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_explain_list_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_explain_list_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->column(2/3, function ($filter) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                if ($subsites) {
+                    $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                    $filter->equal('subsite_id', '所属分站')->select($subsites)->default('');
+                }
+                $cate_option = ExplainCategory::orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->pluck('category_name', 'id');
+                $cate_option = $cate_option->toArray();
+                $cate_option = array('' => '不限') + $cate_option;
+                $filter->equal('type_id', '所属分类')->select($cate_option)->default('');
+                $filter->like('title', '标题');
+
+                $date3 = date('Y-m-d', strtotime("-3 day"));
+                $date7 = date('Y-m-d', strtotime("-7 day"));
+                $date30 = date("Y-m-d", strtotime("-1 month"));
+                $date180 = date("Y-m-d", strtotime("-6 month"));
+                $date360 = date("Y-m-d", strtotime("-1 year"));
+                $date_option = array(
+                    '' => '不限',
+                    $date3 => '三天内',
+                    $date7 => '一周内',
+                    $date30 => '一月内',
+                    $date180 => '半年内',
+                    $date360 => '一年内',
+                );
+                $filter->where(function ($query) {$query->where('created_at', '>=', "{$this->input}");}, '添加时间', 'created_at')
+                    ->radio($date_option);
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Explain::findOrFail($id));
+
+        $show->id('ID');
+        $show->title('标题')->as(function ($title) {
+            return $title;
+        });
+        $show->tit_color('标题颜色')->as(function ($tit_color) {
+            $html = '<i style="background-color: '.$tit_color.';padding: 5px 15px;"></i>';
+            return $html;
+        })->setEscape(false);
+        $show->show_category("所属分类")->as(function ($show_category) {
+            //return $show_category->category_name;
+            return $show_category?$show_category->category_name:'';
+        });
+        if(get_subsite_open()){
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                $subsites = array_merge(array('0'=>'总站'), array( '1' => '定海', '2' => '普陀'));
+                return $subsites[$subsite_id];
+            });
+        }
+        $show->content('内容')->setEscape(false);
+        $show->is_display('是否显示')->as(function ($is_display) {
+            return $is_display?'是':'否';
+        });
+        $show->tit_b('是否加粗')->as(function ($tit_b) {
+            return $tit_b?'是':'否';
+        });
+        $show->list_order('排序');
+        $show->is_url('外部链接')->as(function ($is_url) {
+            return $is_url?$is_url:'&nbsp;';
+        });
+        $show->seo_keywords('Keywords')->as(function ($seo_keywords) {
+            return $seo_keywords?$seo_keywords:'&nbsp;';
+        });
+        $show->seo_description('Description')->as(function ($seo_description) {
+            return $seo_description?$seo_description:'&nbsp;';
+        });
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Explain);
+        $form->text('title', '页面名称')
+            ->rules('required|max:25', array('required'=>'页面名称不能为空。', 'max'=>'页面名称长度不能大于25个字符。'))
+            ->setWidth(4)
+            ->setMustMark();
+        $form->color('tit_color', '标题颜色')
+            ->default('#000000')
+            ->rules('required|regex:/^\#[0-9a-fA-F]{6}$/', array('required'=>'标题颜色不能为空。','regex'=>'标题颜色不正确,请重新选择。'));
+
+        $cate_option = ExplainCategory::orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->pluck('category_name', 'id');
+        $form->select('type_id', '所属分类')
+            ->options($cate_option)
+            ->rules('required', array('required'=>'请选择所属分类。'))
+            ->setWidth(4)
+            ->setMustMark();
+
+        if (get_subsite_id()==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites && get_subsite_id()==0 &&get_subsite_open()) {
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->hidden('subsite_id')->value(get_subsite_id());
+
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->default('1')->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->default(0)->setMustMark();
+
+        $form->number('list_order', '排序')
+            ->min(0)->default(0)
+            ->rules('required', array('required'=>'排序不能为空。'))
+            ->help('(数字越大越靠前)')
+            ->setMustMark();
+        $form->url('is_url', '外部链接')->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+
+        $form->ignore(['relate_subsites']);
+        $form->saved(function (Form $form) {
+            $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+            if (empty($subsites)) {
+                $subsites = [];
+            }
+            $subsites = array_merge(array(get_subsite_id()), $subsites);
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'explain_id' => $form->model()->id,
+                        'subsite_id'=> $v
+                    );
+                }
+            }
+            SubsiteExplain::insert($set_data);
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        return $form;
+    }
+    protected function editForm($id)
+    {
+        $info = Explain::find($id);
+
+        $form = new Form(new Explain);
+        $form->text('title', '页面名称')->rules('required|max:25', array('required'=>'页面名称不能为空。', 'max'=>'页面名称长度不能大于25个字符。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->rules('required|regex:/^\#[0-9a-fA-F]{6}$/', array('required'=>'标题颜色不能为空。','regex'=>'标题颜色不正确,请重新选择。'));
+
+        $cate_option = ExplainCategory::orderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->pluck('category_name', 'id');
+        $form->select('type_id', '所属分类')
+            ->options($cate_option)
+            ->rules('required', array('required'=>'请选择所属分类。'))
+            ->setWidth(4)
+            ->setMustMark();
+
+        if ($info->subsite_id==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', $info->subsite_id)))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites && get_subsite_id()==0 && get_subsite_open()) {
+            $relations = SubsiteExplain::where(array('explain_id'=>$id))->get()->pluck('subsite_id')->toArray();
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->hidden('subsite_id')->value(get_subsite_id());
+
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->setMustMark();
+
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required', array('required'=>'排序不能为空。'))->help('(数字越大越靠前)')->setMustMark();
+        $form->url('is_url','外部链接')->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+
+        $form->ignore(['relate_subsites']);
+        $form->saved(function (Form $form) {
+            $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+            if (empty($subsites)) {
+                $subsites = [];
+            }
+            $subsites = array_merge(array($form->model()->subsite_id), $subsites);
+            SubsiteExplain::where('explain_id', $form->model()->id)->delete();
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'explain_id' => $form->model()->id,
+                        'subsite_id'=> $v
+                    );
+                }
+            }
+            SubsiteExplain::insert($set_data);
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (get_subsite_id() == 0) {
+            $filter_id = $id;
+        } else {
+            $seletctors = Explain::where(array('subsite_id'=>get_subsite_id()))->whereIn('id', $ids)->get()->pluck('id')->toarray();
+            if ($seletctors) {
+                $filter_id = implode(',', $seletctors);
+            } else {
+                $filter_id = '';
+            }
+        }
+        if ($filter_id) {
+            if ($this->form()->destroy($filter_id)) {
+                $data = [
+                    'status'  => true,
+                    'message' => trans('admin.delete_succeeded'),
+                ];
+            } else {
+                $data = [
+                    'status'  => false,
+                    'message' => trans('admin.delete_failed'),
+                ];
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => '不能删除其它分站数据!',
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 345 - 0
app/Admin/Controllers/Content/FeatureController.php

@@ -0,0 +1,345 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\Category;
+use App\Models\CategoryDistrict;
+use App\Models\Feature;
+use App\Http\Controllers\Controller;
+use App\Models\FeatureSort;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+
+class FeatureController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content,Request $request)
+    {
+        return $content
+            ->header('人才展示')
+            ->description(' ')
+            ->body(view('admin.content.photo')->with(['grid'=>$this->grid($request)]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('人才展示')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('人才展示')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('人才展示')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Feature);
+        $grid->id('ID');
+        $grid->column('photo', '特色人才信息')->display(function ($images) {
+
+            $pbstr='';
+            if($this->is_display==0){
+                $pbstr= '<span style="color:#039990">&nbsp;&nbsp;&nbsp;&nbsp;' .$this->name.'</span><span style="color:#999999">&nbsp;&nbsp;&nbsp;&nbsp;[已屏蔽]</span>';
+            }else{
+                $pbstr= '<span style="color:#039990">&nbsp;&nbsp;&nbsp;&nbsp;' .$this->name.'</span>';
+            }
+
+            $params = '?rc_show='.$this->rc_show;
+            $title_url = url(admin_base_path().'/content/feature'.$params);
+            $title_url1 = url('content/features/show?id='.$this->id);
+
+            if ($images) {
+                return '<span class="vtip" title="<img src='.upload_asset($images).' width=120 height=120>">
+                            <img class="avatar small" src="'.upload_asset($images).'" align="absmiddle" style="width: 36px;height: 36px;">
+                        </span>&nbsp;&nbsp;&nbsp;'. '<a href='.$title_url.' style="color: #b67647;">[' .get_category($this->rc_show).']</a><a target="_blank"  href='.$title_url1.'><span>'.$this->title.'</span></a>'.$pbstr;
+            } else {
+                return '<a href='.$title_url.' style="color: #b67647;">['.get_category($this->rc_show).']</a><span class="vtip" ></span>&nbsp;&nbsp;&nbsp;'. '<a target="_blank"  href='.$title_url1.'><span >'.$this->title.'</span></a>'.$pbstr;
+            }
+        })->width(300);
+        $grid->district('所属地区')->display(function ($district) {
+            if($district!=0 && $district!=''){
+
+                return get_district_cn($district);
+            }else{
+                return '未作选择';
+            }
+        })->width(150);
+        $grid->occupation('职位')->display(function ($occupation) {
+            if($occupation!=''){
+                return $occupation;
+            }else{
+                return '未评职称';
+            }
+        })->width(150);
+
+        $grid->type_id('行业')->display(function ($type_id) {
+            if($type_id!=0 && $type_id!=''){
+                $category = \App\Models\FeatureSort::where('id', $type_id)->select(['categoryname'])->first();
+                return $category?$category['categoryname']:null;
+            }else{
+                return '未选行业';
+            }
+        })->width(150);
+
+        $grid->personal('人才类别')->display(function ($personal) {
+            if($personal!=0 && $personal!=''){
+                $category =get_category($personal);
+                return $category?$category:null;
+            }else{
+                return '未作分类';
+            }
+        })->width(150);
+        $grid->read('阅读');
+        $grid->tools(function ($tools) {
+            $tools->batch(function ($batch) {
+                $batch->disableDelete(false);
+            });
+        });
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->filter(function ($filter) {
+            $filter->equal('id', 'ID');
+            $filter->like('title', '标题');
+            $filter->like('name', '名称');
+            $filter->equal('parentid', '行业分类')->select(FeatureSort::where('parent_id','0')->pluck('categoryname', 'id'));
+            $filter->equal('rc_show', '人才展示')->select(Category::where('alias', 'RC_show')->pluck('demand', 'id'));
+            $filter->equal('personal', '人才分类')->select(Category::where('alias', 'RC_category')->pluck('demand', 'id'));
+            $filter->equal('district', '所属地区')->select(CategoryDistrict::where('parent_id', 623)->pluck('name', 'id'));
+
+
+        });
+
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Feature::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Feature);
+
+        $form->text('name', '姓名')->rules('required|max:100', array('required'=>'姓名不能为空。','max'=>'姓名长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->text('occupation', '职称')->rules('required|max:200', array('required'=>'职称不能为空。','max'=>'职称长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->text('title', '主题')->rules('required|max:300', array('required'=>'主题不能为空。','max'=>'主题长度不能大于300。'))->setWidth(6)->setMustMark();
+
+        $district= CategoryDistrict::where('parent_id', 623)->pluck('name', 'id');
+        $district['0'] = '请选择';
+        $form->select('district', '所属乡镇')->options($district)->default('0')->setWidth(6);
+
+        $trade= FeatureSort::select()->pluck('categoryname', 'id');
+        $trade['0'] = '请选择';
+        $form->select('type_id', '所属行业')->options($trade)->default('0')->setWidth(6);
+
+        $personal= Category::where('alias', 'RC_category')->pluck('demand', 'id');
+        $personal['0'] = '请选择';
+        $form->select('personal', '所属五类人才')->options($personal)->default('0')->setWidth(6);
+
+        $rc_show= Category::where('alias', 'RC_show')->pluck('demand', 'id');
+        $rc_show['0'] = '请选择';
+        $form->select('rc_show', '文章类型')->options($rc_show)->default('0')->setWidth(6);
+
+        $form->image('photo', '人才照片')->help('(建议尺寸240*70)')->setWidth(6);
+
+        $form->textarea('summary', '人物简介')->rules('max:80', array('max'=>'Description不能大于80个字符。'))->setWidth(6);
+        $form->editor('content', '履历介绍')->rules('required', array('required'=>'业绩介绍不能为空。'))->setWidth(6)->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->default(1)->states($display_option)->setMustMark();
+//        $form->date('created_at', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'));
+        $form->number('article_order', '排序')->min(0)->default(255)->rules('required', array('required'=>'排序不能为空。'))->help('(数字越大越靠前)');
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->hidden('addtime');//添加时间
+        $form->hidden('parentid');//行业大类
+
+        $form->saving(function (Form $form){
+            //设置添加时间
+            $form->addtime=time();
+
+            if($form->type_id!=0){
+                // 设置行业大类
+                $featureSort= FeatureSort::where(['id'=>$form->type_id])->first();
+                if($featureSort->parent_id==0){
+                    $form->parentid=$form->type_id;
+                }else{
+                    $form->parentid=$featureSort->parent_id;
+                }
+            }else{
+                $form->parentid=0;
+            }
+        });
+        return $form;
+    }
+
+
+
+
+
+    protected function editForm($id)
+    {
+        $form = new Form(new Feature);
+        $form->text('name', '姓名')->rules('required|max:100', array('required'=>'姓名不能为空。','max'=>'姓名长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->text('occupation', '职称')->rules('required|max:200', array('required'=>'职称不能为空。','max'=>'职称长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->text('title', '主题')->rules('required|max:300', array('required'=>'主题不能为空。','max'=>'主题长度不能大于300。'))->setWidth(6)->setMustMark();
+
+        $district= CategoryDistrict::where('parent_id', 623)->pluck('name', 'id');
+        $district['0'] = '请选择';
+        $form->select('district', '所属乡镇')->options($district)->default('0')->setWidth(6);
+
+        $trade= FeatureSort::select()->pluck('categoryname', 'id');
+        $trade['0'] = '请选择';
+        $form->select('type_id', '所属行业')->options($trade)->default('0')->setWidth(6);
+
+        $personal= Category::where('alias', 'RC_category')->pluck('demand', 'id');
+        $personal['0'] = '请选择';
+        $form->select('personal', '所属五类人才')->options($personal)->default('0')->setWidth(6);
+
+        $rc_show= Category::where('alias', 'RC_show')->pluck('demand', 'id');
+        $rc_show['0'] = '请选择';
+        $form->select('rc_show', '文章类型')->options($rc_show)->default('0')->setWidth(6);
+
+        $form->image('photo', '人才照片')->help('(建议尺寸240*70)')->setWidth(6);
+
+        $form->textarea('summary', '人物简介')->rules('max:80', array('max'=>'Description不能大于80个字符。'))->setWidth(6);
+        $form->editor('content', '履历介绍')->rules('required', array('required'=>'业绩介绍不能为空。'))->setWidth(6)->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->setMustMark();
+//        $form->date('created_at', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'));
+        $form->number('article_order', '排序')->min(0)->default(0)->rules('required', array('required'=>'排序不能为空。'))->help('(数字越大越靠前)');
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->hidden('addtime');//添加时间
+        $form->hidden('parentid');//行业大类
+
+        $form->saving(function (Form $form){
+
+
+            if($form->type_id!=0){
+                // 设置行业大类
+                $featureSort= FeatureSort::where(['id'=>$form->type_id])->first();
+                if($featureSort->parent_id==0){
+                    $form->parentid=$form->type_id;
+                }else{
+                    $form->parentid=$featureSort->parent_id;
+                }
+            }else{
+                $form->parentid=0;
+            }
+        });
+
+        return $form;
+    }
+
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的人才展示', 'error');
+        }
+        \DB::beginTransaction();
+        try {
+            Feature::whereIn('id', $ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 223 - 0
app/Admin/Controllers/Content/FeatureSortController.php

@@ -0,0 +1,223 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\FeatureSort;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class FeatureSortController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+
+        if (request()->has('_expand_')) {
+            $FeatureSort=FeatureSort::find(request()->get('_expand_'));
+            if (!$FeatureSort || $FeatureSort->children->isEmpty()) {
+                $data['has_children'] =0;
+                return response()->json($data);
+            }
+            $data['has_children'] =1;
+            $data['html']=view(
+                'admin.grid.policy_category_expand',
+                [
+                    'parent_group'=>implode(" ", explode(",", request()->get('parent_group'))),
+                    'key'=>request()->get('_expand_'),
+                    'list'=>$FeatureSort->children,
+                    'level'=>request()->get('level')+1,
+                ]
+            )->render();
+            return response()->json($data);
+        }
+        return $content
+            ->header('行业分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('行业分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('行业分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('行业分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new FeatureSort);
+        $grid->model()->where('parent_id',0)->orderBy('category_order', 'desc');
+        $grid->id('id');
+        $grid->categoryname('名称')->ajaxExpand();
+        $grid->admin_set('类型')->display(function ($admin_set) {
+            if ($admin_set == 1) {
+                return '系统分类';
+            }else{
+                return '自定义分类 ';
+            }
+        });
+        $grid->category_order('排序');
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->filter(function ($filter) {
+            $filter->like('categoryname', '名称');
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(FeatureSort::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new FeatureSort);
+
+        $array = $this->featureSortArr(FeatureSort::all()->toArray(),0);
+        $array = array_pluck($array,'categoryname','id');
+        $option = ['0'=>'顶级'] +$array;
+        $form->select('parent_id', '所属上级')->options($option)->setMustMark();
+        $form->text('categoryname', '名称');
+        $form->text('title', 'Title');
+        $form->text('description', 'Description');
+        $form->number('category_order', '排序')->default(0)->min(0);
+        $form->hidden('admin_set')->value(0);
+        return $form;
+    }
+
+    protected function editForm()
+    {
+        $form = new Form(new FeatureSort);
+
+        $array = $this->featureSortArr(FeatureSort::all()->toArray(),0);
+        $array = array_pluck($array,'categoryname','id');
+        $option = ['0'=>'顶级'] +$array;
+        $form->select('parent_id', '所属上级')->options($option)->setMustMark();
+        $form->text('categoryname', '名称');
+        $form->text('title', 'Title');
+        $form->text('description', 'Description');
+        $form->number('category_order', '排序')->default(0)->min(0);
+        return $form;
+    }
+
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+
+
+    //递归查询
+    protected function featureSortArr($data,$pid,$level=''){
+        static $arr=array();
+        foreach($data as $k => $v){
+            //如果该分类pid=0
+            if($v['parent_id']==$pid){
+                $v['categoryname']= $level.$v['categoryname'];
+                $arr[]=$v;
+                self::featureSortArr($data,$v['id'],$level.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
+            }
+        }
+        return $arr;
+    }
+
+
+    public function destroy($id)
+    {
+        \DB::beginTransaction();
+        try {
+            $res = FeatureSort::all()->toArray();
+            $list = $this->featureSortArr($res,$id);
+            $ids = array_pluck($list,'id');
+            FeatureSort::where('id',$id)->delete();
+            FeatureSort::whereIn('id',$ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 301 - 0
app/Admin/Controllers/Content/FeedbackController.php

@@ -0,0 +1,301 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Tools\DialogTool;
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Feedback;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Grid\Filter;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+
+class FeedbackController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('意见建议')
+            ->description(' ')
+            //->body($this->grid());
+            ->body(view('admin.content.feedback')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Feedback);
+        if (get_subsite_id() != 0) {
+            $where['subsite_id'] = get_subsite_id();
+            $grid->model()->where($where)->orderBy('audit', 'asc')->orderBy('created_at', 'desc');
+        } else {
+            $grid->model()->orderBy('audit', 'asc')->orderBy('created_at', 'desc');
+        }
+        $grid->type('类型');
+        $grid->audit('处理状态')->display(function () {
+            $audit_html = '';
+            if ($this->audit) {
+                $audit_html = '已处理';
+            } else {
+                $audit_html = '<span style="color:#ff0000;">未处理</span>';
+            }
+            return $audit_html;
+        });
+        $grid->content('内容')->display(function () {
+            return '<span class="vtip" title="'.$this->content.'">'.cut_str($this->content, 40, 0, "...").'</span>';
+        })->width(400);
+        $grid->contact('联系方式');
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+        $grid->created_at('添加时间');
+
+        /*$grid->tools(function (Grid\Tools $tools) {
+            $tools->disableRefreshButton();
+        });*/
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_appeal_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">处理</button>");
+            }
+        });
+        if (Admin::user()->can('content_feedback_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+
+        if (!Admin::user()->can('content_feedback_audit') && !Admin::user()->can('content_feedback_delete')) {
+            $grid->disableRowSelector();
+        }
+
+        $grid->filter(function (Filter $filter) {
+            $filter->disableIdFilter();
+            $filter->column(2/3, function ($filter) {
+                /*if (get_subsite_id() == 0) {
+                    $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                    if ($subsites) {
+                        $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                        $filter->equal('subsite_id', '所属分站')->radio($subsites);
+                    }
+                }*/
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                if ($subsites) {
+                    $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                    $filter->equal('subsite_id', '所属分站')->select($subsites);
+                }
+
+                $cate_option = array(''=>'不限','1'=>'建议', '2' => '意见', '3' => '求助', '4' => '投诉');
+                $filter->equal('type', '所属分类')->radio($cate_option)->default('');
+
+                $where['audit'] = 0;
+                if (get_subsite_id() > 0) {
+                    $where['subsite_id'] = get_subsite_id();
+                }
+                $nums = Feedback::where($where)->get()->count();
+                $num_html ='';
+                if ($nums>0) {
+                    $num_html = '('.$nums.')';
+                }
+                $status_option = array('0'=>'未处理'.$num_html,'1'=>'已处理');
+                $status_option = array(''=>'不限')+$status_option;
+                $filter->equal('audit', '处理状态')->radio($status_option);
+
+                $date3   = date('Y-m-d', strtotime("-3 day"));
+                $date7   = date('Y-m-d', strtotime("-7 day"));
+                $date30  = date("Y-m-d", strtotime("-1 month"));
+                $date180 = date("Y-m-d", strtotime("-6 month"));
+                $date360 = date("Y-m-d", strtotime("-1 year"));
+                $date_option = array(
+                    ''    => '不限',
+                    $date3   => '三天内',
+                    $date7   => '一周内',
+                    $date30  => '一月内',
+                    $date180 => '半年内',
+                    $date360 => '一年内',
+                );
+                $filter->where(function ($query) {
+                    $query->where('created_at', '>=', "{$this->input}");
+                }, '添加时间', 'created_at')->radio($date_option);
+            });
+        });
+
+        //审核功能
+        if (Admin::user()->can('content_feedback_audit')) {
+            $grid->tools(function ($tools) {
+                $form = new \Encore\Admin\Widgets\Form();
+                $form->action(route('feedback.audit'));
+                $audit_option = array('0'=>'未处理','1'=>'已处理');
+                $form->radio('audit', '将所选意见建议设置为:')->options($audit_option)->default(1)->setWidth(8, 4);
+                $form->json('val');
+                $config = array('title'=>'处理意见建议','button'=>'处理','dialog_cancel' => "取消", 'dialog_ok' => "确认", 'is_batch' => true);
+                $tools->append(new DialogTool($form, $config));
+            });
+        }
+
+        return $grid;
+    }
+    public function audit(Request $request)
+    {
+        $rst = $request->validate(['audit'=>'required'], array('audit.required'=>'请选择处理状态'));
+        $ids = $request->input('ids');
+        if (empty($ids)) {
+            if($request->type){
+                admin_toastr('请选择需要处理的数据', 'error');
+                return back();
+            }else{
+                return admin_toastr('请选择需要处理的数据', 'error');
+            }
+        }
+        $id_arr = explode(',', $ids);
+        $update_data = array(
+            'audit' =>  $request->input('audit'),
+            'updated_at' =>date('Y-m-d H:i:s', time())
+        );
+        if (Feedback::whereIn('id', $id_arr)->update($update_data) === false) {
+            if($request->type){
+                admin_toastr('处理失败', 'error');
+                return back();
+            }else{
+                return admin_toastr('处理失败', 'error');
+            }
+        } else {
+            //添加审核日志
+            $reason_data = array('ids'=>$id_arr,'status'=>$request->input('audit'),'type'=>'5');
+            if ($request->input('audit')=='1') {
+                $reason_data['reason'] = '将所选意见建议设置为已处理';
+            } else {
+                $reason_data['reason'] = '将所选意见建议设置为未处理';
+            }
+            AuditReason::addData($reason_data);
+            if($request->type){
+                admin_toastr('处理成功', 'success');
+                return back();
+            }else{
+                return admin_toastr('处理成功', 'success');
+            }
+        }
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Feedback::findOrFail($id));
+        $show->id('ID');
+        $show->type('类型');
+        $show->content('内容');
+        $show->contact('联系方式');
+        $show->audit('处理状态')->as(function ($audit) {
+            if ($audit) {
+                return '已处理';
+            }
+            return '未处理';
+        });
+        if(get_subsite_open()){
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+        $show->created_at('添加时间');
+        $show->updated_at('处理时间');
+
+        $show->panel()->tools(function ($tools) {
+            $tools->disableEdit();
+            $tools->disableDelete();
+        });
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Feedback);
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+        return $form;
+    }
+}

+ 227 - 0
app/Admin/Controllers/Content/HelpCategoryController.php

@@ -0,0 +1,227 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\HelpCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as SysAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Column;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Layout\Row;
+use Encore\Admin\Show;
+use Encore\Admin\Tree;
+use Encore\Admin\Widgets\Box;
+
+//use Encore\Admin\Grid;
+
+class HelpCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header(trans('帮助分类'))
+            ->description(trans('删除顶级分类将会自动删除此分类下的子分类。'))
+            ->row(function (Row $row) {
+                if (SysAdmin::user()->can('content_help_category_create')) {
+                    $row->column(6, $this->tree()->render());
+                    $row->column(6, function (Column $column) {
+                        $form = new \Encore\Admin\Widgets\Form();
+                        $form->action(route('help.category.index'));
+                        $cate_option = HelpCategory::where(array('parent_id'=>0))->orderBy('list_order', 'desc')->orderBy('created_at', 'desc')->get()->pluck('category_name', 'id');
+                        $cate_option = $cate_option->toArray();
+                        $cate_option = array('0'=>'顶级分类')+$cate_option;
+                        $form->select('parent_id', '所属分类')->options($cate_option)->default(0)->setMustMark();
+                        $form->text('category_name', '分类名称')->attribute('maxlength', '25')->setMustMark();
+                        $form->number('list_order', '排序')->min(0)->default(0)->help('(数字越大越靠前)')->attribute('maxlength', '10')->setMustMark();
+                        $form->hidden('_token')->default(csrf_token());
+                        $form->disableReset();
+                        $column->append((new Box(trans('admin.new'), $form))->style('success'));
+                    });
+                } else {
+                    $row->column(12, $this->tree()->render());
+                }
+            });
+    }
+    protected function tree()
+    {
+        return HelpCategory::tree(function (Tree $tree) {
+            $tree->branch(function ($branch) {
+                return "{$branch['category_name']} (id:{$branch['id']})";
+            });
+
+            $tree->setView(array(
+                'tree'   => 'admin::tree',
+                'branch' => 'admin.content.tree_branch'
+            ));
+            $tree->query(function ($model) {
+                return $model->OrderBy('list_order', 'desc')->OrderBy('created_at', 'desc');
+            });
+        });
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('帮助分类')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('帮助分类')
+            ->description(' ')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('帮助分类')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new HelpCategory);
+        $grid->model()->orderBy('parent_id', 'asc')->orderBy('list_order', 'DESC');
+
+        $grid->id('ID');
+        $grid->category_name('分类名称');
+        $grid->parent()->category_name('上级分类');
+        $grid->list_order('排序');
+        $grid->created_at('添加时间');
+        $grid->updated_at('更新时间');
+
+        $grid->disableFilter();
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(HelpCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->category_name('分类名称');
+        $show->parent()->category_name('上级分类');
+        $show->list_order('排序');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new HelpCategory);
+        $cate_option = HelpCategory::where(array('parent_id'=>0))->get()->pluck('category_name', 'id');
+        $cate_option = HelpCategory::selectOptions();
+        $cate_option[0] ='顶级分类';
+        $form->select('parent_id', '所属分类')->options($cate_option)->rules('required', array('required'=>'请选择所属分类。'));
+        $form->text('category_name', '分类名称')->rules('required', array('required'=>'分类名称不能为空。'));
+        $form->number('list_order', '排序')->min(0)->default(0)
+             ->attribute('maxlength', '10')->rules('required', array('required'=>'排序不能为空。'))->help('(数字越大越靠前)');
+
+        return $form;
+    }
+    protected function editForm()
+    {
+        $form = new Form(new HelpCategory);
+        $cate_option = HelpCategory::where(array('parent_id'=>0))->OrderBy('list_order', 'DESC')->orderBy('created_at', 'DESC')->get()->pluck('category_name', 'id');
+        $cate_option = $cate_option->toArray();
+        $cate_option = array('0'=>'顶级分类')+$cate_option;
+        $form->select('parent_id', '所属分类')->options($cate_option)->rules('required', array('required'=>'请选择所属分类。'))->setWidth(4)->setMustMark();
+        $form->text('category_name', '分类名称')->rules('required', array('required'=>'分类名称不能为空。'))->attribute('maxlength', '25')->setWidth(4)->setMustMark();
+        $form->number('list_order', '排序')->min(0)->default(0)->attribute('maxlength', '10')
+             ->rules('required', array('required'=>'排序不能为空。'))->help('(数字越大越靠前)')->setMustMark();
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+
+        return $form;
+    }
+
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+
+    public function destroys($id)
+    {
+        $id_arr =  explode(',', $id);
+        $children_ids = HelpCategory::whereIn('parent_id', $id_arr)->select('id')->get()->pluck('id')->toArray();
+        if ($children_ids) {
+            $id_arr = array_merge($id_arr, $children_ids);
+        }
+        $filter_id = implode(',', $id_arr);
+        if ($this->form()->destroy($filter_id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 257 - 0
app/Admin/Controllers/Content/HelpController.php

@@ -0,0 +1,257 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\Help;
+use App\Models\HelpCategory;
+use Encore\Admin\Admin;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+
+class HelpController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('帮助中心')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('帮助中心')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('帮助中心')
+            ->description(' ')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('帮助中心')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Help);
+
+        $grid->model()->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
+
+        $grid->title('标题')->display(function () {
+            $cate = HelpCategory::where(array('id'=>$this->type_id))->first();
+            if ($this->parent_id=='0') {
+                $params = '?type_id=&parent_id='.$this->type_id;
+            } else {
+                $params = '?type_id='.$this->type_id.'&parent_id='.$this->parent_id;
+            }
+            $title_url = url(admin_base_path().'/content/help/index'.$params);
+            return '<a href='.$title_url.' style="color: #006699;">['.$cate->category_name.']</a>'.' '.$this->title;
+        })->width(450);
+        $grid->list_order('排序');
+        $grid->click('点击量');
+        $grid->created_at('添加时间');
+
+        $grid->tools(function (Grid\Tools $tools) {
+            $tools->disableRefreshButton();
+        });
+        //新增按钮
+        if (userAdmin::user()->can('content_help_list_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (userAdmin::user()->can('content_help_list_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        $grid->actions(function ($actions) {
+            if (userAdmin::user()->can('content_help_list_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (userAdmin::user()->can('content_help_list_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        $this->script = <<<EOT
+            $('select[name="type_id"]').parent().parent().attr('id','type_div');
+            $('select[name="parent_id"]').change(function(){
+                if($('select[name="parent_id"]').val()){
+                    $('#type_div').css('display','block');
+                }else{
+                    $('#type_div').css('display','none');
+                    $('#type_div select[name="type_id"]').val('');
+                }
+            });            
+            $(document).ready(function(){
+                //判断是否显示子分类
+                var \$children = $('select[name="parent_id"]').val();
+                if(\$children){
+                    $('#type_div').css('display','block');
+                }else{
+                    $('#type_div').css('display','none');
+                }
+            });
+EOT;
+        Admin::script($this->script);
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->equal('ID', 'ID');
+            $filter->like('title', '标题');
+            $cate_option = HelpCategory::where(array('parent_id'=>0))->OrderBy('list_order', 'desc')->OrderBy('created_at', 'desc')->get()->pluck('category_name', 'id');
+            $cate_option = $cate_option->toArray();
+            $cate_option = array(''=>'不限')+$cate_option;
+            $filter->where(function ($query) {
+                $query->where('parent_id', '=', "{$this->input}")->orWhere('type_id', '=', "{$this->input}");
+            }, '帮助分类', 'parent_id')->select($cate_option)->load('type_id', 'childCategory', 'id', 'category_name');
+            $pid = \Illuminate\Support\Facades\Request::input('parent_id');
+            if ($pid) {
+                $child_option = HelpCategory::where(array('parent_id'=>$pid))->OrderBy('list_order', 'desc')->OrderBy('created_at', 'desc')->get()->pluck('category_name', 'id')->toArray();
+                $child_option = array(''=>'不限')+$child_option ;
+            } else {
+                $child_option = array(''=>'不限');
+            }
+            $filter ->equal('type_id', '子分类')->select($child_option);
+        });
+        return $grid;
+    }
+
+    public function childCategorys(Request $request)
+    {
+        $parent_id = $request->get('q');
+        $rst = HelpCategory::where('parent_id', $parent_id)->get(['id', 'category_name'])->toArray();
+        $pre_arr = array('id'=>'','category_name'=>'不限');
+        array_unshift($rst, $pre_arr);
+        return collect($rst);
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Help::findOrFail($id));
+
+        $show->id('ID');
+        $show->title('标题');
+        /*$show->show_category()->category_name('所属分类');*/
+        $show->show_category("所属分类")->as(function ($show_category) {
+            return $show_category->category_name;
+        });
+        $show->content('内容')->as(function ($content) {
+            return $content?$content:'&nbsp;';
+        })->setEscape(false);
+        $show->list_order('排序');
+        $show->click('点击量');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        /*$show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+            });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Help);
+
+        $form->text('title', '标题')->rules('required|max:50', array('required'=>'标题不能为空。','max'=>'标题长度不能超过50。'))->setWidth(4)->setMustMark();
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required', array('required'=>'排序不能为空。'))
+             ->attribute('maxlength', '10')->help('数字越大越靠前')->setMustMark();
+        $cate_option = HelpCategory::selectOptions(function ($query) {
+            return $query->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
+        });
+        unset($cate_option[0]);
+        $form->select('type_id', '帮助分类')->options($cate_option)
+             ->default(key($cate_option))->rules('required', array('required'=>'请选择帮助分类。'))
+             ->setWidth(4)->setMustMark();
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+        $form->hidden('parent_id');
+        $form->hidden('click');
+        $form->saving(function (Form $form) {
+            if (!$id = $form->model()->id) {
+                $form->click = 0;
+            }
+            $type_info = HelpCategory::find($form->type_id);
+            $form->parent_id = $type_info->parent_id;
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+}

+ 208 - 0
app/Admin/Controllers/Content/HrtoolsCategoryController.php

@@ -0,0 +1,208 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\HrtoolsCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class HrtoolsCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('HR工具箱分类')
+            ->description('系统分类不能删除')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('HR工具箱分类')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('HR工具箱分类')
+            ->description(' ')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('HR工具箱分类')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new HrtoolsCategory);
+
+        $grid->model()->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
+
+        $grid->id('ID');
+        $grid->category_name('分类名称')->display(function () {
+            return $this->category_name.' [id:'.$this->id.']';
+        });
+        $grid->admin_set('类型')->display(function () {
+            return $this->admin_set?'系统分类':'自定义分类';
+        });
+        $grid->list_order('排序');
+        $grid->created_at('添加时间');
+        /*
+         $grid->updated_at('更新时间');
+        $grid->tools(function (Grid\Tools $tools) {
+            $tools->disableRefreshButton();
+        });
+        */
+        $grid->disableFilter();
+        //新增按钮
+        if (Admin::user()->can('content_hrtools_category_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('content_hrtools_category_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_hrtools_category_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_hrtools_category_delete') && $actions->row['admin_set']!=1) {
+                $actions->disableDelete(false);
+            }
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(HrtoolsCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->category_name('分类名称');
+        $show->category_img('缩略图')->image();
+        $show->content('描述')->setEscape(false);
+        $show->list_order('排序');
+        $show->admin_set('系统分类')->as(function ($admin_set) {
+            return $admin_set?'是':'否';
+        });
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        /*$show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+            });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new HrtoolsCategory);
+        $form->text('category_name', '分类名称')->rules('required|max:30', array('分类名称不能为空!','max'=>'分类名称长度不能大于30。'))->setWidth(4)->setMustMark();
+        $form->image('category_img', '缩略图')->uniqueName()->rules('image|mimes:gif,jpeg,bmp,png', array('image'=>'缩略图必须是图片文件。','mimes'=>'缩略图文件格式不正确。'))->setWidth(4);
+        $form->textarea('content', '描述')->rules('max:100', array('max'=>'描述长度不能大于100。'));
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required|max:10', array('required'=>'排序不能为空。','max'=>'排序长度不能大于10。'))->help('(数字越大越靠前)')->setMustMark();
+        $form->hidden('admin_set')->value(0);
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+
+    public function destroy($id)
+    {
+        $id_arr =  explode(',', $id);
+        $admin_set_cates = HrtoolsCategory::where(array('admin_set'=>'1'))->select('id')->get()->pluck('id')->toArray();
+        foreach ($id_arr as $k => $v) {
+            if (in_array($v, $admin_set_cates)) {
+                unset($id_arr[$k]);
+            }
+        }
+        $filter_id = implode(',', $id_arr);
+        if ($this->form()->destroy($filter_id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 322 - 0
app/Admin/Controllers/Content/HrtoolsController.php

@@ -0,0 +1,322 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\Hrtools;
+use App\Models\HrtoolsCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class HrtoolsController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('HR工具箱')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('HR工具箱')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('HR工具箱')
+            ->description(' ')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('HR工具箱')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Hrtools);
+
+        $grid->model()->orderBy('list_order', 'desc')->orderBy('created_at', 'DESC');
+        $grid->id('ID');
+        $grid->title('名称')->display(function () {
+            $style="color:".$this->tit_color.';';
+            if ($this->tit_b=='1') {
+                $style .='font-weight:bold;';
+            }
+            return '<span style="'.$style.'">'.$this->title.'</span>';
+        })->width(250);
+        $grid->column('文件路径')->display(function () {
+            if (preg_match('/^files\//', $this->file_url)) {
+                $filepath = public_path('uploads').'/'.$this->file_url;
+                if (file_exists($filepath)) {
+                    return '<a href="download/'.$this->file_url.'">'.$this->file_url.'</a>';
+                } else {
+                    return '';
+                }
+            } else {
+                return '<a href="'.$this->file_url.'">'.$this->file_url.'</a>';
+            }
+        })->width(250);
+        $grid->show_category()->category_name('所属分类');
+        $grid->list_order('排序');
+
+        $grid->created_at('添加时间');
+        //新增按钮
+        if (Admin::user()->can('content_hrtools_list_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('content_hrtools_list_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_hrtools_list_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_hrtools_list_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->like('title', '名称');
+            $cate_option = HrtoolsCategory::orderBy('list_order', 'desc')->orderBy('created_at', 'desc')->pluck('category_name', 'id');
+            if ($cate_option) {
+                $cate_option = $cate_option->toArray();
+                $cate_option = array(''=>'不限') + $cate_option;
+            } else {
+                $cate_option = array(''=>'不限');
+            }
+            $filter->equal('type_id', '所属分类')->select($cate_option);
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Hrtools::findOrFail($id));
+
+        $show->id('ID');
+        $show->title('名称');
+        $show->tit_color('标题颜色')->as(function ($tit_color) {
+            $html = '<i style="background-color: '.$tit_color.';padding: 5px 15px;"></i>';
+            return $html;
+        })->setEscape(false);
+        $show->tit_b('标题加粗')->as(function ($tit_b) {
+            return $tit_b?'是':'否';
+        });
+        $show->file_url('文件路径');
+        /*$show->show_category()->category_name('所属分类');*/
+        $show->show_category("所属分类")->as(function ($show_category) {
+            return $show_category->category_name;
+        });
+        $show->list_order('排序');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+       /* $show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+            });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new Hrtools);
+
+        $form->text('title', '名称')->rules('required|max:25', array('required'=>'名称不能为空。', 'max'=>'名称长度不能大于25个字符。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '名称颜色')->default('#000000');
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('tit_b', '名称加粗')->states($display_option)->default(0)->setMustMark();
+        $cate_option = HrtoolsCategory::orderBy('list_order', 'desc')->orderBy('created_at', 'desc')->pluck('category_name', 'id');
+        $form->select('type_id', '所属分类')->options($cate_option)->rules('required', array('required'=>'请选择所属分类。'))->setWidth(4)->setMustMark();
+
+        $form->file('up_file', '上传文件')->uniqueName()
+             ->rules('required_without:url|mimes:doc,docx,ppt,xls,rtf', array('required_without'=>'上传文件或者文件路径填写一项。','mimes'=>'上传文件格式不正确。'))
+             ->help('(只能上传doc/ppt/xls/rtf文件)')
+             ->setMustMark()
+             ->setWidth(4);
+        $form->url('url', '或填写文件路径')
+             ->rules('required_without:up_file', array('required_without'=>'上传文件或者文件路径填写一项。'))
+             ->help('(请输入完整文件路径,如:http://www.91caiqing.com/123.doc)')
+             ->setWidth(4);
+        $form->number('list_order', '排序')->min(0)->default(0)
+             ->rules('required', array('required'=>'排序不能为空。'))
+             ->attribute('maxlength', '10')->help('(数字越大越靠前)')->setMustMark();
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        return $form;
+    }
+    protected function editForm()
+    {
+        $form = new ValidateForm(new Hrtools);
+
+        $form->text('title', '名称')->rules('required|max:25', array('required'=>'名称不能为空。', 'max'=>'名称长度不能大于25个字符。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '名称颜色')->default('#000000');
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('tit_b', '名称加粗')->states($display_option)->default(0)->setMustMark();
+        $cate_option = HrtoolsCategory::orderBy('list_order', 'desc')->orderBy('created_at', 'desc')->pluck('category_name', 'id');
+        $form->select('type_id', '所属分类')->options($cate_option)->rules('required', array('required'=>'请选择所属分类。'))->setWidth(4)->setMustMark();
+        $form->file('up_file', '上传文件')->uniqueName()->rules('mimes:doc,docx,ppt,xls,rtf', array('mimes'=>'上传文件格式不正确。'))->help('(只能上传doc/ppt/xls/rtf文件)')->setWidth(4)->setMustMark()->options(['layoutTemplates' => ['actionDelete'    => '']]);
+        $form->url('url', '或填写文件路径')->help('(请输入完整文件路径,如:http://www.baidu.com/123.doc)')->setWidth(4);
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required', array('required'=>'排序不能为空。'))->attribute('maxlength', '10')->help('(数字越大越靠前)')->setMustMark();
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+    public function update($id)
+    {
+        $data=$this->editForm()->getValidateInput();
+        $time = date('Y-m-d H:i:s', time());
+        $up_file = null;
+        $url = $data['url'];
+        if (array_key_exists('up_file', $data)) {
+            $up_file = $data['up_file'];
+        }
+        $file_url = $up_file?$up_file:$url;
+        $form_data = array(
+            'title'           => $data['title'],
+            'type_id'         => $data['type_id'],
+            'tit_color'       => $data['tit_color']?$data['tit_color']:'#000000',
+            'tit_b'           => $data['tit_b'],
+            'list_order'      => $data['list_order'],
+            'updated_at'      => $time
+        );
+        if ($file_url) {
+            $form_data['file_url'] = $file_url;
+        }
+        if (Hrtools::where(array('id'=>$id))->update($form_data)) {
+            admin_toastr(trans('admin.save_succeeded'));
+            return redirect(admin_base_path('/content/hrtools/index'));
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+    public function store()
+    {
+        $data=$this->form()->getValidateInput();
+        $time = date('Y-m-d H:i:s', time());
+        $up_file = null;
+        if (array_key_exists('up_file', $data)) {
+            $up_file = $data['up_file'];
+        }
+        $url = $data['url'];
+        $file_url = $up_file?$up_file:$url;
+        $form_data = array(
+            'title'           => $data['title'],
+            'type_id'         => $data['type_id'],
+            'tit_color'       => $data['tit_color']?$data['tit_color']:'#000000',
+            'tit_b'           => $data['tit_b'],
+            'file_url'        => $file_url,
+            'list_order'      => $data['list_order'],
+            'created_at'      => $time,
+            'updated_at'      => $time
+        );
+        if (Hrtools::insert($form_data)) {
+            admin_toastr(trans('admin.save_succeeded'));
+            return redirect(admin_base_path('/content/hrtools/index'));
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+    public function download($type, $filename)
+    {
+        $filepath = public_path('uploads').'/'.$type . '/' . $filename;
+        $file = fopen($filepath, "r");
+        Header("Content-type: application/octet-stream");
+        Header("Accept-Ranges: bytes");
+        Header("Accept-Length: " . filesize($filepath));
+        Header("Content-Disposition: attachment; filename=" . $filename);
+        fclose($file);
+    }
+}

+ 143 - 0
app/Admin/Controllers/Content/InnovatorCategoryController.php

@@ -0,0 +1,143 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\InnovatorCategory;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class InnovatorCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new InnovatorCategory);
+
+        $grid->id('ID');
+        $grid->categoryname('名称');
+        $grid->admin_set('类型')->display(function ($admin_set) {
+            if ($admin_set == 1) {
+                return '系统分类';
+            }else{
+                return '自定义分类 ';
+            }
+        });
+        $grid->category_order('排序');
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->filter(function ($filter) {
+            $filter->like('categoryname', '名称');
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(InnovatorCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new InnovatorCategory);
+
+        $form->text('categoryname', '名称');
+        $form->number('category_order', '排序')->default(0)->min(0);
+//        $form->text('title', '标题')->placeholder('不填默认为分类名称');
+        $form->text('keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->hidden('parentid')->value(0);
+        $form->hidden('admin_set')->value(0);
+
+        return $form;
+    }
+
+
+}

+ 200 - 0
app/Admin/Controllers/Content/LinkCategoryController.php

@@ -0,0 +1,200 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\LinkCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class LinkCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('链接分类')
+            ->description('通过友情链接分类可以在多个页面调用不同的友情链接!')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('链接分类')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('链接分类')
+            ->description(' ')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('链接分类')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new LinkCategory);
+
+
+        $grid->category_name('分类名称');
+        $grid->alias('调用名称');
+        $grid->admin_set('类型')->display(function () {
+            return $this->admin_set?'系统分类':'自定义分类';
+        });
+        $grid->created_at('添加时间');
+        /*$grid->updated_at('更新时间');
+
+        $grid->tools(function (Grid\Tools $tools) {
+            $tools->disableRefreshButton();
+        });*/
+        $grid->disableFilter();
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_link_category_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_link_category_delete') && $actions->row['admin_set']!=1) {
+                $actions->disableDelete(false);
+            }
+        });
+        //新增按钮
+        if (Admin::user()->can('content_link_category_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('content_link_category_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(LinkCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->category_name('分类名称');
+        $show->alias('调用名称');
+        $show->admin_set('系统分类')->as(function ($admin_set) {
+            return $admin_set?'是':'否';
+        });
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        /*$show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+        });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new LinkCategory);
+
+        $form->text('category_name', '分类名称')->rules('required|max:25', array('required'=>'分类名称不能为空。','max'=>'分类名称长度不能大于25。'))->setWidth(4)->setMustMark();
+        $form->text('alias', '调用名称')->rules('required|max:25', array('required'=>'调用名称不能为空。','max'=>'调用名称长度不能大于25。'))->setWidth(4)->help('(自定义链接分类调用名不可以以“AIX_”开头)')->setMustMark();
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+
+    public function destroy($id)
+    {
+        $id_arr =  explode(',', $id);
+        $admin_set_cates = LinkCategory::where(array('admin_set'=>'1'))->select('id')->get()->pluck('id')->toArray();
+        foreach ($id_arr as $k => $v) {
+            if (in_array($v, $admin_set_cates)) {
+                unset($id_arr[$k]);
+            }
+        }
+        $filter_id = implode(',', $id_arr);
+        if ($this->form()->destroy($filter_id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 434 - 0
app/Admin/Controllers/Content/LinkControllser.php

@@ -0,0 +1,434 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\Link;
+use App\Models\LinkCategory;
+use App\Models\Subsite;
+use App\Models\SubsiteLink;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Grid\Filter;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Cache;
+
+class LinkControllser extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('友情链接')
+            ->description(' ')
+            ->body(view('admin.content.link')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('友情链接')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('友情链接')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('友情链接')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Link);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+        })->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
+
+
+        $grid->link_title('链接标题')->display(function () {
+            $link_url = $this->link_url;
+            $note     = $this->note;
+            $link_logo = $this->link_logo;
+            $note_html = '';
+            if ($note) {
+                $note_html = '<span title='.str_replace(PHP_EOL, '', $note).'><i class="fa-commenting-o fa" style="color: #3c8dbc;"></i></span>';
+            }
+            $logo_html = '';
+            if ($link_logo) {
+                //判断是否是图片
+                if (preg_match('/^http/', $this->link_logo)) {
+                    $logo_html = '<span style="padding-left:5px;color: #3c8dbc;" class="vtip" title="<img src=\''.$this->link_logo.'\' height=120>"><i class="fa fa-file-image-o"></i></span>';
+                } else {
+                    $logo_html = '<span style="padding-left:5px;color: #3c8dbc;" class="vtip" title="<img src=\''.upload_asset($this->link_logo).'\' height=120>"><i class="fa fa-file-image-o"></i></span>';
+                }
+            }
+            $html = '<a href='.$link_url.' style="color: #0066CC;"  target="_blank">'.$this->link_title.'</a>'.' '.$note_html.$logo_html;
+            return $html;
+        })->width(200);
+        $grid->link_url('链接地址')->display(function () {
+            return '<a href='.$this->link_url.' style="color:#000000;">'.$this->link_url.'</a>';
+        })->width(300);
+        $states = [
+            '1' => ['text' => '是'],
+            '0' => ['text' => '否'],
+        ];
+        $grid->is_display('是否显示')->switch($states);
+        $grid->list_order('顺序');
+        $grid->show_category()->category_name('位置');
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+
+        $grid->created_at('添加时间');
+        //新增按钮
+        if (userAdmin::user()->can('content_link_list_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (userAdmin::user()->can('content_link_list_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+
+        $grid->actions(function ($actions) {
+            if (userAdmin::user()->can('content_link_list_edit')) {
+                if ($actions->row['subsite_id']== get_subsite_id() || get_subsite_id()==0) {
+                    $actions->disableEdit(false);
+                }
+            }
+            if (userAdmin::user()->can('content_link_list_delete')) {
+                if ($actions->row['subsite_id']== get_subsite_id() || get_subsite_id()==0) {
+                    $actions->disableDelete(false);
+                }
+            }
+        });
+
+        $grid->filter(function (Filter $filter) {
+            $filter->disableIdFilter();
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            if ($subsites) {
+                $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                $filter->equal('subsite_id', '所属分站')->select($subsites);
+            }
+            $cate_option = LinkCategory::all()->pluck('category_name', 'id');
+            $filter->equal('type_id', '链接位置')->select($cate_option);
+            $filter->like('link_title', '链接标题');
+            $filter->like('link_url', '链接地址');
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Link::findOrFail($id));
+
+        $show->id('ID');
+        $show->is_display('是否显示')->as(function ($is_display) {
+            return $is_display?'是':'否';
+        });
+        $show->link_title('链接名称');
+        $show->link_url('链接地址');
+        $show->type_id('链接分类')->as(function ($type_id) {
+            $cate_info = LinkCategory::where(array('id'=>$type_id))->first();
+            return $cate_info?$cate_info->category_name:' ';
+        });
+        $show->list_order('显示顺序');
+        $show->link_logo('链接LOGO')->image();
+        if(get_subsite_open()){
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+
+        $show->note('备注信息');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new Link);
+
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->default('1')->setMustMark();
+        $form->text('link_title', '链接名称')->rules('required|max:50', array('required'=>'链接名称不能为空。','max'=>'链接名称长度不能大于50。'))->setWidth(4)->setMustMark();
+        $form->url('link_url', '链接地址')->rules('required|max:250', array('required'=>'链接地址不能为空。','max'=>'链接地址长度不能大于250。'))->setWidth(4)->help('(请输入包含http://或https://的完整链接)')->setMustMark();
+        $cate_option = LinkCategory::all()->pluck('category_name', 'id');
+        $form->select('type_id', '链接分类')->options($cate_option)->rules('required', array('required'=>'请选择链接分类。'))->setWidth(4)->setMustMark();
+        $form->number('list_order', '显示顺序')->min(0)->default(0)->rules('required', array('required'=>'显示顺序不能为空。'))->attribute('maxlength', '10')->help('(数字越大越靠前)')->setMustMark();
+        $form->image('link_logo', '链接LOGO')->uniqueName()->setWidth(4)
+            ->rules('mimes:gif,jpeg,bmp,png', array('mimes'=>'链接LOGO文件格式不正确。'))
+            ->help('(允许格式为gif/jpg/bmp/png)');
+        $form->url('logo_url', '或LOGO地址')->help('(请输入包含http://或https://的完整链接,上传链接LOGO或者填写LOGO地址满足一项即可)');
+
+        /*if (get_subsite_id()==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+            if ($subsites) {
+                $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+            }
+        } else {
+            $form->hidden('relate_subsites');
+        }*/
+        if (get_subsite_id()==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty() && get_subsite_id()==0) {
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+        $form->hidden('subsite_id')->value(get_subsite_id());
+        //$form->ignore(['up_file']);
+        $form->ignore(['logo_url']);
+
+        $form->textarea('note', '备注信息')->rows(3)->help('(备注不在前台显示,只作为管理员的备忘标记)');
+        $form->saved(function (Form $form) {
+            //如果没有上传logo,判断是否
+            $logo_url = \Illuminate\Support\Facades\Request::input('logo_url');
+            if (!$form->model()->link_logo && $logo_url) {
+                $form->model()->link_logo = $logo_url;
+                $form->model()->save();
+            }
+            $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+            if (empty($subsites)) {
+                $subsites = [];
+            }
+            $subsites = array_merge(array(get_subsite_id()), $subsites);
+            /*if (get_subsite_id() == 0) {
+                $subsites = array_merge(array(get_subsite_id()), $subsites);
+            } else {
+                $subsites = array(get_subsite_id());
+            }*/
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'link_id' => $form->model()->id,
+                        'subsite_id'=> $v
+                    );
+                }
+            }
+            SubsiteLink::insert($set_data);
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        return $form;
+    }
+    protected function editForm($id)
+    {
+        $form = new ValidateForm(new Link);
+
+        //获取友情链接详情
+        $info = Link::find($id);
+
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->setMustMark();
+        $form->text('link_title', '链接名称')->rules('required|max:50', array('required'=>'链接名称不能为空。','max'=>'链接名称长度不能大于50。'))->setWidth(4)->setMustMark();
+        $form->url('link_url', '链接地址')->rules('required|max:250', array('required'=>'链接地址不能为空。','max'=>'链接地址长度不能大于250。'))->setWidth(4)->help('(请输入包含http://或https://的完整链接)')->setMustMark();
+        $cate_option = LinkCategory::all()->pluck('category_name', 'id');
+        $form->select('type_id', '链接分类')->options($cate_option)->rules('required', array('required'=>'请选择链接分类。'))->setWidth(4)->setMustMark();
+        $form->number('list_order', '显示顺序')->min(0)->default(0)->rules('required', array('required'=>'显示顺序不能为空。'))->attribute('maxlength', '10')->help('(数字越大越靠前)')->setMustMark();
+        $form->image('link_logo', '链接LOGO')->uniqueName()->setWidth(4)->rules('mimes:gif,jpeg,bmp,png', array('mimes'=>'链接LOGO文件格式不正确。'))->help('(允许格式为gif/jpg/bmp/png)');;
+        $form->url('logo_url', '或LOGO地址')->help('(请输入包含http://或https://的完整链接,上传链接LOGO或者填写LOGO地址满足一项即可)');
+
+        /*if (get_subsite_id()==0 && $info->subsite_id == get_subsite_id()) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+            if ($subsites) {
+                $relations = SubsiteLink::where(array('link_id'=>$id))->get()->pluck('subsite_id')->toArray();
+                $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+            }
+        } else {
+            $form->hidden('relate_subsites');
+        }*/
+
+        if ($info->subsite_id==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', $info->subsite_id)))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty() && get_subsite_id()==0) {
+            $relations = SubsiteLink::where(array('link_id'=>$id))->get()->pluck('subsite_id')->toArray();
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+        $form->hidden('subsite_id')->value(get_subsite_id());
+        $form->ignore(['logo_url']);
+
+        $form->textarea('note', '备注信息')->rows(3)->help('(备注不在前台显示,只作为管理员的备忘标记)');
+        $form->saved(function (Form $form) {
+            $logo_url = \Illuminate\Support\Facades\Request::input('logo_url');
+            if (!$form->model()->link_logo && $logo_url) {
+                $form->model()->link_logo = $logo_url;
+                $form->model()->save();
+            }
+            $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+            if (empty($subsites)) {
+                $subsites = [];
+            }
+            $subsites = array_merge(array($form->model()->subsite_id), $subsites);
+            SubsiteLink::where('link_id', $form->model()->id)->delete();
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'link_id' => $form->model()->id,
+                        'subsite_id'=> $v
+                    );
+                }
+            }
+            SubsiteLink::insert($set_data);
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+
+        return $form;
+    }
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (get_subsite_id() == 0) {
+            $filter_id = $id;
+        } else {
+            $seletctors = Link::where(array('subsite_id'=>get_subsite_id()))->whereIn('id', $ids)->get()->pluck('id')->toarray();
+            if ($seletctors) {
+                $filter_id = implode(',', $seletctors);
+            } else {
+                $filter_id = '';
+            }
+        }
+        if ($filter_id) {
+            if ($this->form()->destroy($filter_id)) {
+                $data = [
+                    'status'  => true,
+                    'message' => trans('admin.delete_succeeded'),
+                ];
+            } else {
+                $data = [
+                    'status'  => false,
+                    'message' => trans('admin.delete_failed'),
+                ];
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => '不能删除其它分站数据!',
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 199 - 0
app/Admin/Controllers/Content/NoticeCategoryController.php

@@ -0,0 +1,199 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\NoticeCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class NoticeCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('公告分类')
+            ->description('系统分类不能删除!')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('公告分类')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('公告分类')
+            ->description(' ')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('公告分类')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new NoticeCategory);
+
+        $grid->model()->orderBy('listorder', 'ASC');
+        $grid->id('ID');
+        $grid->category_name('分类名字');
+        $grid->admin_set('系统分类')->display(function ($admin_set) {
+            return $admin_set?"是":"否";
+        });
+        $grid->listorder('排序');
+        $grid->created_at('添加时间');
+
+        if (Admin::user()->can('content_noticemanager_noticlecategory_create')) {
+            $grid->disableCreateButton(false);
+        }
+        if (Admin::user()->can('content_noticemanager_noticlecategory_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_noticemanager_noticlecategory_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_noticemanager_noticlecategory_delete') && $actions->row['admin_set']!=1) {
+                $actions->disableDelete(false);
+            }
+        });
+        $grid->disableFilter();
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(NoticeCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->category_name('分类名字');
+        $show->admin_set('是否系统默认分类')->display(function ($admin_set) {
+            return $admin_set?"是":"否";
+        });
+        $show->listorder('排序');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+       /* $show->panel()
+             ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+        });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new NoticeCategory);
+
+        $form->text('category_name', '分类名字')->rules('required|max:10', array('required'=>'分类名称不能为空。','max'=>'分类名称长度不能大于25个字符。'))->setWidth(4)->setMustMark();
+        $form->number('listorder', '排序')->min(1)->max(255)->default(255)->rules('required', array('required'=>'排序不能为空。'));
+        $form->hidden('admin_set')->value(0);
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+
+    /*
+     *  重写批量删除方法
+     */
+    public function destroy($id)
+    {
+        $id_arr =  explode(',', $id);
+        $admin_set_cates = NoticeCategory::where(array('admin_set'=>'1'))->select('id')->get()->pluck('id')->toArray();
+        foreach ($id_arr as $k => $v) {
+            if (in_array($v, $admin_set_cates)) {
+                unset($id_arr[$k]);
+            }
+        }
+        $filter_id = implode(',', $id_arr);
+        if ($this->form()->destroy($filter_id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 409 - 0
app/Admin/Controllers/Content/NoticeController.php

@@ -0,0 +1,409 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\Notice;
+use App\Models\NoticeCategory;
+use App\Models\Subsite;
+use App\Models\SubsiteNotice;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Cache;
+
+class NoticeController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('公告列表')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('公告')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('公告')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('公告')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Notice);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+        })->orderBy('sort', 'ASC')->orderBy('id', 'DESC');
+
+        $grid->id('ID');
+        $grid->column('标题')->display(function () {
+            $style="color:".$this->tit_color.';';
+            if ($this->tit_b=='1') {
+                $style .='font-weight:bold;';
+            }
+            return '<a href="'.route(url_rewrite('AIX_noticeshow'),['id'=>$this->id]).'" target="_blank"><span style="'.$style.'">'.$this->title.'</span></a>';
+        })->width(400);
+        $grid->show_category()->category_name('所属分类');
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+        $grid->sort('排序');
+        $grid->click('点击量');
+        $grid->created_at('添加时间');
+
+        if (Admin::user()->can('content_noticemanager_noticle_create')) {
+            $grid->disableCreateButton(false);
+        }
+        if (Admin::user()->can('content_noticemanager_noticle_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_noticemanager_noticle_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_noticemanager_noticle_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->column(1/3, function ($filter) {
+                $cate_option = NoticeCategory::all()->pluck('category_name', 'id');
+                $cate_option = $cate_option->toArray();
+                $cate_option = array('' => '不限') + $cate_option;
+                $filter->equal('type_id', '所属分类')->select($cate_option)->default('');
+                $filter->like('title', '标题');
+            });
+            $filter->column(2/3, function ($filter) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                if ($subsites) {
+                    $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                    $filter->equal('subsite_id', '所属分站')->select($subsites);
+                }
+                $date3 = date('Y-m-d', strtotime("-3 day"));
+                $date7 = date('Y-m-d', strtotime("-7 day"));
+                $date30 = date("Y-m-d", strtotime("-1 month"));
+                $date180 = date("Y-m-d", strtotime("-6 month"));
+                $date360 = date("Y-m-d", strtotime("-1 year"));
+                $date_option = array(
+                    '' => '不限',
+                    $date3 => '三天内',
+                    $date7 => '一周内',
+                    $date30 => '一月内',
+                    $date180 => '半年内',
+                    $date360 => '一年内',
+                );
+                $filter->where(function ($query) {
+                    $query->where('created_at', '>=', "{$this->input}");}, '添加时间', 'created_at')->radio($date_option);
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Notice::findOrFail($id));
+
+        $show->id('ID');
+        $show->title('标题')->as(function ($title) {
+            return $title;
+        });
+
+        $show->tit_color('标题颜色')->as(function ($tit_color) {
+            $html = '<i style="background-color: '.$tit_color.';padding: 5px 15px;"></i>';
+            return $html;
+        })->setEscape(false);
+        $show->show_category("所属分类")->as(function ($show_category) {
+            return $show_category->category_name;
+        });
+        if(get_subsite_open()){
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+        $show->content('内容')->setEscape(false);
+        $show->is_display('是否显示')->as(function ($is_display) {
+            return $is_display?'是':'否';
+        });
+        $show->tit_b('是否加粗')->as(function ($tit_b) {
+            return $tit_b?'是':'否';
+        });
+        $show->sort('排序');
+        $show->is_url('外部链接')->as(function ($is_url) {
+            return $is_url?$is_url:'&nbsp;';
+        });
+        $show->seo_keywords('Keywords')->as(function ($seo_keywords) {
+            return $seo_keywords?$seo_keywords:'&nbsp;';
+        });
+        $show->seo_description('Description')->as(function ($seo_description) {
+            return $seo_description?$seo_description:'&nbsp;';
+        });
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new Notice);
+
+        $form->text('title', '标题')->rules('required|max:100', array('required'=>'标题不能为空。', 'max'=>'页面名称长度不能大于100个字符。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->default('#000000');
+        $cate_option = NoticeCategory::all()->pluck('category_name', 'id');
+        $form->select('type_id', '所属分类')->options($cate_option)->default(key($cate_option->toArray()))->setWidth(4)->setMustMark();
+        if (get_subsite_open()) {
+            if (get_subsite_id()==0) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+            } else {
+                $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                $subsites['0']= '总站';
+                $subsites = collect($subsites);
+            }
+            if ($subsites->isNotEmpty()  && get_subsite_id()==0) {
+                $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+            } else {
+                $form->hidden('relate_subsites');
+            }
+        }
+        $form->hidden('subsite_id')->value(get_subsite_id());
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->default('1')->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->default(0)->setMustMark();
+
+        $form->number('sort', '排序')->min(1)->max(255)->default(255)->help('(数字越小越靠前)')->setMustMark();
+        $form->url('is_url', '外部链接')->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')
+            ->placeholder('合理设置Keywords有利于搜索引擎排名')
+            ->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')
+            ->placeholder('合理设置Description有利于搜索引擎排名')
+            ->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->ignore(['relate_subsites']);
+        $form->saved(function (Form $form) {
+            $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+            if (empty($subsites)) {
+                $subsites = [];
+            }
+            $subsites = array_merge(array(get_subsite_id()), $subsites);
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'notice_id' => $form->model()->id,
+                        'subsite_id'=> $v
+                    );
+                }
+            }
+            SubsiteNotice::insert($set_data);
+        });
+        return $form;
+    }
+    protected function editForm($id)
+    {
+        $form = new Form(new Notice);
+
+        $info = Notice::find($id);
+
+        $form->text('title', '标题')
+            ->rules('required|max:100', array('required'=>'标题不能为空。', 'max'=>'页面名称长度不能大于100个字符。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色');
+        $form->radio('type_id', '所属分类')->options(NoticeCategory::all()->pluck('category_name', 'id'))->setMustMark();
+
+        if ($info->subsite_id==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', $info->subsite_id)))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty()  && get_subsite_id()==0) {
+            $relations = SubsiteNotice::where(array('notice_id'=>$id))->get()->pluck('subsite_id')->toArray();
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+
+
+        $form->hidden('subsite_id')->value(get_subsite_id());
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->setMustMark();
+        $form->number('sort', '排序')->min(1)->max(255)->help('(数字越小越靠前)')->setMustMark();
+        $form->url('is_url', '外部链接')->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')
+            ->placeholder('合理设置Keywords有利于搜索引擎排名')
+            ->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')
+            ->placeholder('合理设置Description有利于搜索引擎排名')
+            ->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+
+        $form->ignore(['relate_subsites']);
+        $form->saved(function (Form $form) {
+            $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+            if (empty($subsites)) {
+                $subsites = [];
+            }
+            $subsites = array_merge(array($form->model()->subsite_id), $subsites);
+
+            SubsiteNotice::where('notice_id', $form->model()->id)->delete();
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'notice_id' => $form->model()->id,
+                        'subsite_id'=> $v
+                    );
+                }
+            }
+            SubsiteNotice::insert($set_data);
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (get_subsite_id() == 0) {
+            $filter_id = $id;
+        } else {
+            $seletctors = Notice::where(array('subsite_id'=>get_subsite_id()))->whereIn('id', $ids)->get()->pluck('id')->toarray();
+            if ($seletctors) {
+                $filter_id = implode(',', $seletctors);
+            } else {
+                $filter_id = '';
+            }
+        }
+        if ($filter_id) {
+            if ($this->form()->destroy($filter_id)) {
+                $data = [
+                    'status'  => true,
+                    'message' => trans('admin.delete_succeeded'),
+                ];
+            } else {
+                $data = [
+                    'status'  => false,
+                    'message' => trans('admin.delete_failed'),
+                ];
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => '不能删除其它分站数据!',
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 218 - 0
app/Admin/Controllers/Content/PolicyCategoryController.php

@@ -0,0 +1,218 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\PolicyCategory;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class PolicyCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        if (request()->has('_expand_')) {
+            $PolicyCategory=PolicyCategory::find(request()->get('_expand_'));
+            if (!$PolicyCategory || $PolicyCategory->children->isEmpty()) {
+                $data['has_children'] =0;
+                return response()->json($data);
+            }
+            $data['has_children'] =1;
+            $data['html']=view(
+                'admin.grid.policy_category_expand',
+                [
+                    'parent_group'=>implode(" ", explode(",", request()->get('parent_group'))),
+                    'key'=>request()->get('_expand_'),
+                    'list'=>$PolicyCategory->children,
+                    'level'=>request()->get('level')+1,
+                ]
+            )->render();
+            return response()->json($data);
+        }
+
+        return $content
+            ->header('政策分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('政策分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('政策分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('政策分类')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PolicyCategory);
+        $grid->model()->where('parent_id',0)->orderBy('category_order', 'desc');
+        $grid->id('id');
+        $grid->categoryname('名称')->ajaxExpand();
+        $grid->admin_set('类型')->display(function ($admin_set) {
+            if ($admin_set == 1) {
+                return '系统分类';
+            }else{
+                return '自定义分类 ';
+            }
+        });
+        $grid->category_order('排序');
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->filter(function ($filter) {
+            $filter->like('categoryname', '名称');
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PolicyCategory::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PolicyCategory);
+
+        $array = $this->policyCategoryArr(PolicyCategory::all()->toArray(),0);
+        $array = array_pluck($array,'categoryname','id');
+        $option = ['0'=>'顶级'] +$array;
+        $form->select('parent_id', '所属上级')->options($option)->setMustMark();
+        $form->text('categoryname', '名称');
+        $form->text('title', 'Title');
+        $form->text('description', 'Description');
+        $form->number('category_order', '排序')->default(0)->min(0);
+        return $form;
+    }
+
+    protected function editForm()
+    {
+        $form = new Form(new PolicyCategory);
+        $array = $this->policyCategoryArr(PolicyCategory::all()->toArray(),0);
+        $array = array_pluck($array,'categoryname','id');
+        $option = ['0'=>'顶级'] +$array;
+        $form->select('parent_id', '所属上级')->options($option)->setMustMark();
+        $form->text('categoryname', '名称');
+        $form->text('title', 'Title');
+        $form->text('description', 'Description');
+        $form->number('category_order', '排序')->default(0)->min(0);
+        return $form;
+    }
+
+    //递归查询
+    protected function policyCategoryArr($data,$pid,$level=''){
+        static $arr=array();
+        foreach($data as $k => $v){
+            //如果该分类pid=0
+            if($v['parent_id']==$pid){
+                $v['categoryname']= $level.$v['categoryname'];
+                $arr[]=$v;
+                self::policyCategoryArr($data,$v['id'],$level.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
+            }
+        }
+        return $arr;
+    }
+
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+
+    public function destroy($id)
+    {
+        \DB::beginTransaction();
+        try {
+            $res = PolicyCategory::all()->toArray();
+            $list = $this->policyCategoryArr($res,$id);
+            $ids = array_pluck($list,'id');
+            PolicyCategory::where('id',$id)->delete();
+            PolicyCategory::whereIn('id',$ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 354 - 0
app/Admin/Controllers/Content/PolicyController.php

@@ -0,0 +1,354 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\Category;
+use App\Models\Policy;
+use App\Http\Controllers\Controller;
+use App\Models\PolicyCategory;
+use App\Models\PolicyProperty;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Input;
+
+class PolicyController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('政策管理')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('政策管理')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('政策管理')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('政策管理')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Policy);
+        $grid->id('ID');
+        $grid->model()->orderBy('article_order', 'DESC')->orderBy('created_at', 'DESC');
+
+        $grid->column('文章标题')->display(function () {
+            $style="color:".$this->tit_color.';';
+            if ($this->tit_b=='1') {
+                $style .='font-weight:bold;';
+            }
+
+            $cate = PolicyCategory::where(array('id'=>$this->parentid))->first();
+            if ($this->parentid=='0') {
+                $params = '?parentid='.$this->type_id;
+            } else {
+                $params = '?parentid='.$this->parentid;
+            }
+            $title_url = url(admin_base_path().'/content/policy'.$params);
+            $pbstr='';
+            if($this->is_display==0){
+                $pbstr= '<span style="color:#999999">&nbsp;&nbsp;&nbsp;&nbsp;[已屏蔽]</span>';
+            }
+
+            $title_url1 = url('content/policys/show/'.$this->id);
+            if ($cate) {
+                return $pbstr.'<a href='.$title_url.' style="color: #006699;">['.$cate->categoryname.']</a> <a target="_blank"  href='.$title_url1.'><span style="'.$style.'">'.$this->title.'</span></a>';
+            } else {
+                return $pbstr.'<span style="'.$style.'">'.$this->title.'</span>';
+            }
+        })->width(200);
+
+        $grid->policyproperty()->categoryname('政策层次');
+        $grid->article_order('排序');
+        $grid->click('点击');
+        $grid->created_at('添加时间');
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->tools(function ($tools) {
+            $tools->batch(function ($batch) {
+                $batch->disableDelete(false);
+            });
+        });
+        $grid->filter(function ($filter) {
+            $filter->equal('id', 'ID');
+            $filter->like('title', '标题');
+
+            $policy_cates = PolicyCategory::where(['parent_id'=>0])->orderBy("id", 'asc')->get()->pluck('categoryname', 'id');
+            $filter->where(function ($query) {
+                $query->where('parentid', '=', "{$this->input}")->orWhere('type_id', '=', "{$this->input}");
+            }, '政策分类', 'parentid')->select($policy_cates);
+
+            $policy_propertys = PolicyProperty::select()->orderBy("id", 'asc')->get()->pluck('categoryname', 'id');
+            $filter->where(function ($query) {
+                $query->where('focos', '=', "{$this->input}");
+            }, '政策层次', 'focos')->select($policy_propertys);
+
+            $date3   = date('Y-m-d', strtotime("-3 day"));
+            $date7   = date('Y-m-d', strtotime("-7 day"));
+            $date30  = date("Y-m-d", strtotime("-1 month"));
+            $date180 = date("Y-m-d", strtotime("-6 month"));
+            $date360 = date("Y-m-d", strtotime("-1 year"));
+            $date_option = array(
+                ''    => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            );
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Policy::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Policy);
+        $form->text('title', '标题')->rules('required|max:100', array('required'=>'标题不能为空。','max'=>'标题长度不能大于100。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', array('required'=>'标题颜色不能为空。','regex'=>'标题颜色格式不正确。'))->default('#000000');
+
+        $cate_option = PolicyCategory::selectOptions(function ($query) {
+            return $query->orderBy('category_order', 'desc')->orderBy('created_at', 'desc');
+        });
+
+        unset($cate_option[0]);
+        $form->select('type_id', '政策分类')->options($cate_option)->default(key($cate_option))->rules('required', array('required'=>'请选择政策分类。'))->setWidth(4)->setMustMark();
+
+        $policyProperty = PolicyProperty::select()->pluck('categoryname', 'id');
+//        $policyProperty[0] ='不限';
+        $arr = array(
+            '1' => 'RC_category_fj',
+            '2' => 'RC_category_qz',
+            '7' => 'RC_category_jj',
+            '8' => 'RC_category'
+        );
+        $form->select('focos', '政策层次')->options($policyProperty)->load('level_ids', admin_base_path('/content/policys/treats/category'))->rules("required")->setMustMark();
+        $form->multipleSelect('level_ids', '面向人才')->rules(['required'], ['required'=>'请填写面向人才'])->setMustMark();
+
+        $form->image('small_img', '缩略图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', array('image'=>'缩略图请选择图片文件。','mimes'=>'请选择jpeg,bmp,png格式的缩略图上传。'))->setWidth(3);
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->default(1)->states($display_option)->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->setMustMark();
+//        $form->date('addtime', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'));
+        $form->number('article_order', '新闻排序')->min(0)->default(255)->rules('required', array('required'=>'新闻排序不能为空。'))->help('(数字越大越靠前)');
+        $form->text('author', '作者')->rules('max:20', array('max'=>'作者长度不能大于20。'))->setWidth(3);
+        $form->text('source', '来源')->rules('max:20', array('max'=>'来源长度不能大于20。'))->setWidth(3);
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->hidden('addtime');//添加时间
+        $form->hidden('parentid');//政策大类
+        $form->hidden('level_name');//面向人才
+        $form->hidden('level_id');//面向人才
+        $form->ignore(['level_ids']);
+
+        $form->saving(function (Form $form){
+            //设置添加时间
+            $form->addtime=time();
+
+//            设置政策大类
+            $policyCategory= PolicyCategory::where(['id'=>$form->type_id])->first();
+
+            if($policyCategory->parent_id==0){
+                $form->parentid=$form->type_id;
+            }else{
+                $form->parentid=$policyCategory->parent_id;
+            }
+
+            $level_id= Input::get('level_ids');
+            $level_id = array_filter($level_id);
+            $form->level_id=implode(',',$level_id);
+
+            $levels=Category::whereIn('id',$level_id)->select('demand')->get()->toArray();
+            $form->level_name=implode(",", array_column($levels, 'demand'));
+
+        });
+        return $form;
+    }
+    protected function editForm($id)
+    {
+        $form = new Form(new Policy);
+        $policyData = Policy::where('id', $id)->first()->toArray();
+        $form->text('title', '标题')->rules('required|max:100', array('required'=>'标题不能为空。','max'=>'标题长度不能大于100。'))->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', array('required'=>'标题颜色不能为空。','regex'=>'标题颜色格式不正确。'))->default('#000000');
+
+        $cate_option = PolicyCategory::selectOptions(function ($query) {
+            return $query->orderBy('category_order', 'desc')->orderBy('created_at', 'desc');
+        });
+
+        unset($cate_option[0]);
+        $form->select('type_id', '政策分类')->options($cate_option)->default(key($cate_option))->rules('required', array('required'=>'请选择政策分类。'))->setWidth(4)->setMustMark();
+
+        $policyProperty = PolicyProperty::select()->pluck('categoryname', 'id');
+//        $policyProperty[0] ='不限';
+        $arr = array(
+            '1' => 'RC_category_fj',
+            '2' => 'RC_category_qz',
+            '7' => 'RC_category_jj',
+            '8' => 'RC_category'
+        );
+        $form->select('focos', '政策层次')->options($policyProperty)->load('level_ids', admin_base_path('/content/policys/treats/category'))->rules("required")->setMustMark();
+
+        $form->multipleSelect('level_ids', '面向人才')->options(Category::categoryType($arr[$policyData['focos']]))->default(explode(",", $policyData['level_id']))->rules(['required'], ['required'=>'请填写面向人才'])->setMustMark();
+
+        $form->image('small_img', '缩略图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', array('image'=>'缩略图请选择图片文件。','mimes'=>'请选择jpeg,bmp,png格式的缩略图上传。'))->setWidth(3);
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->setMustMark();
+        $form->switch('tit_b', '标题加粗')->states($display_option)->setMustMark();
+//        $form->date('created_at', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'));
+        $form->number('article_order', '新闻排序')->min(0)->default(0)->rules('required', array('required'=>'新闻排序不能为空。'))->help('(数字越大越靠前)');
+        $form->text('author', '作者')->rules('max:20', array('max'=>'作者长度不能大于20。'))->setWidth(3);
+        $form->text('source', '来源')->rules('max:20', array('max'=>'来源长度不能大于20。'))->setWidth(3);
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('seo_keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('seo_description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->hidden('addtime');//添加时间
+        $form->hidden('parentid');//政策大类
+        $form->hidden('level_name');//面向人才
+        $form->hidden('level_id');//面向人才
+        $form->ignore(['level_ids']);
+
+        $form->saving(function (Form $form){
+
+            //设置政策大类
+            $policyCategory= PolicyCategory::where(['id'=>$form->type_id])->first();
+
+            if($policyCategory->parent_id==0){
+                $form->parentid=$form->type_id;
+            }else{
+                $form->parentid=$policyCategory->parent_id;
+            }
+
+            $level_id= Input::get('level_ids');
+            $level_id = array_filter($level_id);
+            $form->level_id=implode(',',$level_id);
+
+            $levels=Category::whereIn('id',$level_id)->select('demand')->get()->toArray();
+            $form->level_name=implode(",", array_column($levels, 'demand'));
+
+        });
+
+        return $form;
+    }
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的政策', 'error');
+        }
+        \DB::beginTransaction();
+        try {
+            Policy::whereIn('id', $ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+
+}

+ 147 - 0
app/Admin/Controllers/Content/PolicyPropertyController.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\PolicyProperty;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class PolicyPropertyController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('政策层次')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('政策层次')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('政策层次')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('政策层次')
+            ->description('分类信息谨慎修改,如需修改请提前咨询系统客服。')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PolicyProperty);
+        $grid->id('id');
+        $grid->categoryname('名称');
+        $grid->admin_set('类型')->display(function ($admin_set) {
+            if ($admin_set == 1) {
+                return '系统分类';
+            }else{
+                return '自定义分类 ';
+            }
+        });
+        $grid->category_order('排序');
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->filter(function ($filter) {
+            $filter->like('categoryname', '名称');
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PolicyProperty::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PolicyProperty);
+        $form->text('categoryname', '名称');
+        $form->number('category_order', '排序')->default(0)->min(0);
+        $form->hidden('admin_set')->value(0);
+        return $form;
+    }
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+
+    protected function editForm()
+    {
+        $form = new Form(new PolicyProperty);
+        $form->text('categoryname', '名称');
+        $form->number('category_order', '排序')->default(0)->min(0);
+        return $form;
+    }
+
+}

+ 1 - 0
app/Admin/Controllers/Content/README.md

@@ -0,0 +1 @@
+后台内容管理模块

+ 140 - 0
app/Admin/Controllers/Content/RcstfwltController.php

@@ -0,0 +1,140 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\LtApppointment;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+//use Encore\Admin\Grid;
+
+class RcstfwltController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('服务事项预约列表')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new LtApppointment);
+        $grid->model()->orderBy('id', 'DESC');
+
+        $status = \Illuminate\Support\Facades\Request::input('status', 99);
+        if ($status != 99) {
+            $grid->model()->where('status', '=', $status);
+        } else {
+            $grid->model()->where('status', '<', 2);
+        }
+
+
+        $grid->number('预约号码')->width(200);
+        $grid->username('真实姓名')->width(150);
+        $grid->phone('手机')->width(150);
+        $grid->service('服务事项')->width(300);
+        $grid->content('说明')->width(600);
+        $grid->createtime('登记时间')->width(300);
+        $grid->is_talent('是否认证人才')->width(300)->display(function () {
+            if ($this->is_talent == 0) {
+                return '<span style="color: #909399">未认证人才</span>';
+            } else if ($this->is_talent == 1) {
+                return '<span style="color: #67C23A">已认证人才</span>';
+            }
+
+            return '';
+        });
+        $grid->evaluate('评价')->display(function () {
+            if ($this->is_talent == 1) {
+                if (empty($this->evaluate)) {
+                    return '<span style="color: #E6A23C">未评价</span>';
+                } else {
+                    return '<span style="color: #67C23A">' . $this->evaluate . '</span>';
+                }
+            } else {
+                return '<span style="color: #909399">不需要评价</span>';
+            }
+            return '';
+        });
+
+        $grid->actions(function ($actions) {
+            $actions->disableView(false);
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->like('number', '预约单号');
+            $filter->like('username', '姓名');
+            $type_option = ['0' => '未认证人才', '1' => '已认证人才', '99' => '全部'];
+            $filter->where(function ($query) {
+                if ($this->input != 99) {
+                    $query->where('is_talent', '=', "{$this->input}");
+                }
+            }, '是否认证人才', 'is_talent')->radio($type_option);
+        });
+
+        return $grid;
+    }
+
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('详情')
+            ->description()
+            ->body($this->detail($id));
+    }
+
+    protected function detail($id)
+    {
+        $show = new Show(LtApppointment::findOrFail($id));
+
+        $show->number('预约号码');
+        $show->username('真实姓名');
+        $show->phone('手机');
+        $show->service('服务事项');
+        $show->content('说明');
+        $show->createtime('登记时间');
+        $show->is_talent('是否认证人才')->display(function () {
+            if ($this->is_talent == 0) {
+                return '<span style="color: #909399">未认证人才</span>';
+            } else if ($this->is_talent == 1) {
+                return '<span style="color: #67C23A">已认证人才</span>';
+            }
+
+            return '';
+        });
+        $show->evaluate('评价')->display(function () {
+            if ($this->is_talent == 1) {
+                if (empty($this->evaluate)) {
+                    return '<span style="color: #E6A23C">未评价</span>';
+                } else {
+                    return '<span style="color: #67C23A">' . $this->evaluate . '</span>';
+                }
+            } else {
+                return '<span style="color: #909399">不需要评价</span>';
+            }
+            return '';
+        });
+
+        return $show;
+    }
+
+}

+ 301 - 0
app/Admin/Controllers/Content/RecuperateApplyController.php

@@ -0,0 +1,301 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\Recuperate;
+use App\Models\RecuperateApply;
+use App\Models\RecuperateLog;
+use App\Models\RecuperateTime;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Illuminate\Http\Request;
+use Encore\Admin\Facades\Admin;
+
+class RecuperateApplyController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('报名列表')
+            ->description(' ')
+            ->body(view('admin.content.recuperate_apply')->with(['grid' => $this->grid()]));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new RecuperateApply());
+
+        $grid->model()->orderBy('created_at', 'DESC');
+
+       $grid->recuperate_id('套餐id');
+        $grid->column('套餐标题')->display(function () {
+            //套餐被删除
+            if (empty($this->recuperate)) {
+                return '<span style="color:#A0A0A0;">已被删除</span>';
+            }
+            $style = "color:" . $this->recuperate->tit_color . ';';
+            if ($this->recuperate->tit_b == '1') {
+                $style .= 'font-weight:bold;';
+            }
+
+            return '<span style="' . $style . '">' . $this->recuperate->title . '</span>';
+        })->width(200);
+        $grid->small_img('缩略图')->display(function () {
+            //套餐被删除
+            if (empty($this->recuperate)) {
+                return '';
+            }
+
+            if ($this->recuperate->small_img) {
+                return '<span class="vtip" title="<img src=\'' . upload_asset($this->recuperate->small_img) . '\'  height=120>">
+                            <img class="avatar small" src="' . upload_asset($this->recuperate->small_img) . '" align="absmiddle" style="width: 22px;height: 22px;">
+                        </span>';
+            } else {
+                return '';
+            }
+        });
+
+        $grid->price('套餐金额');
+        $grid->user_name('姓名');
+        $grid->user_idcard('身份证');
+        $grid->mobile('联系电话');
+        $grid->wechat('微信号');
+        $grid->company_name('工作单位');
+        $grid->column('人才层次')->display(function () {
+            $level_arr = [
+                '',
+                '第一层次',
+                '第二层次',
+                '第三层次',
+                '第四层次',
+                '第五层次',
+                '第六层次',
+                '第七层次',
+            ];
+            return $level_arr[$this->level];
+        });
+        $grid->condition("适用对象类型");
+        $grid->column('个税社保')->display(function () {
+            $level_arr = [
+                '',
+                '是',
+                '否',
+            ];
+            return $level_arr[$this->tax];
+        });
+        $grid->column('年薪')->display(function () {
+            $level_arr = [
+                '',
+                '是',
+                '否',
+            ];
+            return $level_arr[$this->salary];
+        });
+        $grid->created_at('报名时间');
+        $grid->column('审核状态')->display(function () {
+            $status_arr = [
+                '待审核',
+                '审核通过',
+                '审核不通过',
+                '取消活动',
+            ];
+            $reason     = $this->reason ? '<a style="margin-left: 5px;" data-reason="' . $this->reason . '" class="audit_log"><i class="fa fa-eye"></i></a>' : '';
+            return '<span style="color:#FF6600">' . $status_arr[$this->status] . $reason . '</span>';
+        });
+
+        //审核功能
+        $grid->actions(function ($actions) {
+            if ($actions->row['status'] == 0) {
+                $actions->append("<button class='btn btn-primary btn-xs applyaudit' data-code=" . $actions->row['id'] . ">审核</button>");
+            }
+
+            /*取消活动*/
+            if ($actions->row['status'] != 2 && $actions->row['status'] != 3) {
+                $actions->append("<button class='btn btn-primary btn-xs applyaudits' data-code=" . $actions->row['id'] . ">取消</button>");
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->equal('recuperate_id', '套餐id');
+
+            /*$filter->where(function($query){
+                $recuperate = Recuperate::where('title','like',"%{$this->input}%")->get();
+                $ids = $recuperate->pluck('id')->all();
+                if (empty($ids)) {
+                    $query->where('id','=',0);
+                } else {
+                    $query->whereIn('recuperate_id',$ids);
+                }
+            }, '');*/
+
+            $date3       = date('Y-m-d', strtotime("-3 day"));
+            $date7       = date('Y-m-d', strtotime("-7 day"));
+            $date30      = date("Y-m-d", strtotime("-1 month"));
+            $date180     = date("Y-m-d", strtotime("-6 month"));
+            $date360     = date("Y-m-d", strtotime("-1 year"));
+            $date_option = [
+                ''       => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            ];
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+
+            $status_option = [
+                '' => '不限',
+                0  => '待审核',
+                1  => '审核通过',
+                2  => '审核不通过',
+            ];
+            $filter->where(function ($query) {
+                if (isset($this->input)) {
+                    $query->where('status', '=', "{$this->input}");
+                }
+            }, '审核状态', 'status')->radio($status_option);
+        });
+        return $grid;
+    }
+
+    public function audit(Request $request)
+{
+    $id     = $request->id;
+    $status = $request->status;
+    $reason = $request->reason;
+    $url = empty($request->url) ? '/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply' : $request->url;
+    if (empty($id)) {
+        admin_toastr('数据异常', 'error');
+        return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply');
+    }
+    $result = RecuperateApply::where('id', '=', $id)->update(['status' => $status, 'reason' => $reason]);
+    if ($result) {
+        admin_toastr('审核成功', 'success');
+    } else {
+        admin_toastr('该信息不存在或已审核', 'error');
+    }
+
+    return redirect($url);
+}
+
+    public function audit_qx(Request $request)
+    {
+        $id     = $request->id;
+      //  $status = $request->status;
+      //  $reason = $request->reason;
+        $url = empty($request->url) ? '/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply' : $request->url;
+        if (empty($id)) {
+            admin_toastr('数据异常1', 'error');
+            return redirect('/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/apply');
+        }
+        $result = RecuperateApply::where('id', '=', $id)->update(['status' => 3]);
+       $recuperate_apply= RecuperateApply::where('id', '=', $id)->select('uid')->first();
+        $auditData = array(
+            'type' => 2,
+            'admin_id' => \Encore\Admin\Facades\Admin::user()->id,
+            'sid' => $recuperate_apply->uid,
+            'content' => "取消活动"
+        );
+        RecuperateLog::create($auditData);
+        if ($result) {
+            admin_toastr('取消成功', 'success');
+        } else {
+            admin_toastr('该信息不存在或已审核', 'error');
+        }
+
+        return redirect($url);
+    }
+
+
+    /*个人列表*/
+    public function appointinfo(Content $content, Request $request)
+    {
+
+        $uid = $request->uid;
+        $recuperateApply = RecuperateApply::where('uid',$uid);
+        $recuperateTime=RecuperateTime::where('uid',$uid)->select('id','year')->orderBy('id','desc')->get();
+        if (empty($recuperateApply)) {
+            return back();
+        }
+
+        $search_data = $request->all();
+
+        $search_data['uid']=isset($search_data['uid'])?$search_data['uid']:$uid;
+        $search_data['status']=isset($search_data['status'])?$search_data['status']:1;
+        $search_data['recuperate_time_id']=isset($search_data['recuperate_time_id'])?$search_data['recuperate_time_id']:$recuperateTime[0]->id;
+        $where = [];
+        if (isset($search_data['perpage'])) {
+            $perpage=$search_data['perpage'];
+        }else{
+            $session_data = session('search_data');
+            if(isset($session_data['perpage'])){
+                $perpage=$session_data['perpage'];
+            }else{
+                $perpage=20;
+            }
+
+        }
+
+      if (isset($search_data['uid']) || session('manage_search_data')['uid']) {
+            if (isset($search_data['page'])) {
+                if (session('search_data')) {
+                    $where = session('managewhere');
+                    unset($search_data['page']);
+                    $search_data = session('manage_search_data');
+
+                }
+            }
+
+            foreach ($search_data as $k => $v) {
+                if ($k == 'status') {
+                    $where[] = ['recuperate_apply.status', 'like', "%$v%"];
+                } elseif ($k == 'recuperate_time_id') {
+                    $where[] = ['recuperate_apply.recuperate_time_id', '=', $v];
+                }elseif ($k == 'uid') {
+                    $where[] = ['recuperate_apply.uid', '=', $v];
+                } elseif ($k != '_pjax' and $k != 'page' && $k != 'perpage') {
+                    $where[] = [$k, '=', $v];
+                }
+            }
+            session(['managewhere' => $where]);
+            session(['manage_search_data' => $search_data]);
+            session()->save();
+        }
+
+
+
+        $list = RecuperateApply::where($where)
+            ->join('recuperate', 'recuperate_apply.recuperate_id', '=', 'recuperate.id', 'left')
+            ->join('recuperate_time', 'recuperate_apply.recuperate_time_id', '=', 'recuperate_time.id', 'left')
+            ->select('recuperate_apply.*', 'recuperate.title','recuperate_time.year')
+            ->orderBy('recuperate_apply.id','desc')
+            ->paginate($perpage);
+        return $content
+            ->header('招考管理')
+            ->description('招考人员信息列表')
+            ->body(view('admin.content.recuperate_apply_personal')->with([
+                'list' => $list,
+                'search_data' => $search_data,
+                'recuperateTime' => $recuperateTime,
+            ]));
+
+    }
+}

+ 100 - 0
app/Admin/Controllers/Content/RecuperateCategoryController.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\RecuperateCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+class RecuperateCategoryController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('活动分类')
+            ->description('活动列表')
+            ->body($this->grid());
+    }
+
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('活动分类')
+            ->description('活动详情')
+            ->body($this->detail($id));
+    }
+
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('活动分类')
+            ->description('分类修改')
+            ->body($this->form()->edit($id));
+    }
+
+    public function create(Content $content)
+    {
+        return $content
+            ->header('活动分类')
+            ->description('新增分类')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new RecuperateCategory());
+        $grid->name('分类名称');
+        $grid->created_at('操作时间');
+
+        //新增按钮
+        if (Admin::user()->can('content_recuperate_list_category_create')) {
+            $grid->disableCreateButton(false);
+        }
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_recuperate_list_category_delete')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('content_recuperate_list_category_edit')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->group('搜索', function ($group) {
+                $group->where('分类名称', function ($query) {
+                    $query->where('name', 'like','%'.request()->搜索.'%');
+                });
+
+
+            })->placeholder('请输入关键字');
+
+
+
+        });
+        return $grid;
+    }
+    protected function form()
+    {
+        $form = new Form(new RecuperateCategory());
+        $form->text('name', '分类名称')->rules('required', ['required'=>'请填写分类名称'])->setMustMark();
+        return $form;
+    }
+
+}

+ 339 - 0
app/Admin/Controllers/Content/RecuperateController.php

@@ -0,0 +1,339 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Exports\Content\RecuperateExport;
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\Recuperate;
+use App\Models\RecuperateApply;
+use App\Models\RecuperateCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Illuminate\Http\Request;
+use Illuminate\Support\Collection;
+
+class RecuperateController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('人才活动列表')
+            ->description(' ')
+            ->body(view('admin.content.recuperate')->with(['grid' => $this->grid()]));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('人才活动')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('人才活动')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    public function show()
+    {
+        return redirect("/ST3IXxKlOa4eGEv0eTw0CfORI9444Mgj/content/recuperate/index");
+    }
+
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Recuperate());
+
+        $grid->model()->orderBy('created_at', 'DESC');
+
+        $grid->id('ID');
+       $grid->column('recuperate_category.name','分类');
+        $grid->column('标题')->display(function () {
+            $style = "color:" . $this->tit_color . ';';
+            if ($this->tit_b == '1') {
+                $style .= 'font-weight:bold;';
+            }
+
+            return '<span style="' . $style . '">' . $this->title . '</span>';
+        })->width(200);
+        $grid->small_img('缩略图')->display(function () {
+            if ($this->small_img) {
+                return '<span class="vtip" title="<img src=\'' . upload_asset($this->small_img) . '\'  height=120>">
+                            <img class="avatar small" src="' . upload_asset($this->small_img) . '" align="absmiddle" style="width: 22px;height: 22px;">
+                        </span>';
+            } else {
+                return '';
+            }
+        });
+
+        $grid->price('价格');
+        $grid->visit('天数');
+        $grid->place('地点');
+
+        $grid->list_order('排序');
+        $grid->click('点击量');
+        $grid->created_at('添加时间');
+        //新增按钮
+        $grid->disableCreateButton(false);
+
+        //批量删除
+        $grid->tools(function ($tools) {
+            $tools->batch(function ($batch) {
+                $batch->disableDelete(false);
+            });
+        });
+
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+            $actions->append('<a href="' . route('recuperate.export_apply', ['id' => $actions->row['id']]) . '" target="_blank"><button class="btn btn-primary btn-xs business" title="导出报名列表" >导出报名列表</button></a>');
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->like('title', '套餐标题');
+
+            $date3       = date('Y-m-d', strtotime("-3 day"));
+            $date7       = date('Y-m-d', strtotime("-7 day"));
+            $date30      = date("Y-m-d", strtotime("-1 month"));
+            $date180     = date("Y-m-d", strtotime("-6 month"));
+            $date360     = date("Y-m-d", strtotime("-1 year"));
+            $date_option = [
+                ''       => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            ];
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+
+        $form = new ValidateForm(new Recuperate());
+         $category = array_column(RecuperateCategory::where('deleted_at',null)->select('id','name')->get()->toArray(), 'name', 'id');
+         $form->select('r_c_id', '分类名称')->rules('required', ['required' => '分类名称为空。'])->options($category)->setMustMark();
+        $form->text('title', '标题')->rules('required|max:100', ['required' => '标题不能为空。', 'max' => '标题长度不能大于100。'])->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', ['required' => '标题颜色不能为空。', 'regex' => '标题颜色格式不正确。'])->default('#000000');
+        $form->switch('tit_b', '标题加粗')->states($display_option)->default(0)->setMustMark();
+        $form->textarea('describe', '描述')->rules('required|max:1024', ['required' => '描述不能为空。', 'max' => '描述长度不能大于1024。'])->setWidth(8)->setMustMark();
+        $form->number('price', '价格')->rules('required', ['required' => '价格不能为空。'])->setWidth(4)->setMustMark();
+        $form->text('visit', '天数')->rules('required', ['required' => '天数不能为空。'])->setWidth(4)->setMustMark();
+        $form->text('place', '地点')->rules('required', ['required' => '地点不能为空。'])->setWidth(4)->setMustMark();
+        $form->datetime('travel_time', '出行时间')->rules('required', ['required' => '出行时间不能为空。'])->setWidth(4)->setMustMark();
+        $form->image('small_img', '缩略图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', ['image' => '缩略图请选择图片文件。', 'mimes' => '请选择jpeg,bmp,png格式的缩略图上传。'])->setWidth(4);
+        $form->multipleFile('img_list', '轮播图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', ['image' => '轮播图请选择图片文件。', 'mimes' => '请选择jpeg,bmp,png格式的缩略图上传。'])->setWidth(4)->removable();
+        $form->editor('content', '内容')->rules('required', ['required' => '内容不能为空。'])->setMustMark();
+        $form->switch('is_display', '是否显示')->states($display_option)->default('1')->setMustMark();
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required', ['required' => '排序不能为空。'])->help('(数字越大越靠前)');
+
+        $form->saved(function (Form $form) {
+            //如果没有上传logo,判断是否
+            $small_img = \Illuminate\Support\Facades\Request::input('small_img');
+            if (!$form->model()->small_img && $small_img) {
+                $form->model()->small_img = $small_img;
+                $form->model()->save();
+            }
+
+            $img_list = \Illuminate\Support\Facades\Request::input('img_list');
+            if (!$form->model()->img_list && $img_list) {
+                $form->model()->img_list = $img_list;
+                $form->model()->save();
+            }
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        return $form;
+    }
+
+    protected function editForm($id)
+    {
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $category = array_column(RecuperateCategory::where('deleted_at',null)->select('id','name')->get()->toArray(), 'name', 'id');
+
+        $form = new ValidateForm(new Recuperate);
+        $form->select('r_c_id', '分类名称')->rules('required', ['required' => '分类名称为空。'])->options($category)->setMustMark();
+        $form->text('title', '标题')->rules('required|max:100', ['required' => '标题不能为空。', 'max' => '标题长度不能大于100。'])->setWidth(4)->setMustMark();
+        $form->color('tit_color', '标题颜色')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', ['required' => '标题颜色不能为空。', 'regex' => '标题颜色格式不正确。'])->default('#000000');
+        $form->switch('tit_b', '标题加粗')->states($display_option)->default(0)->setMustMark();
+        $form->textarea('describe', '描述')->rules('required|max:1024', ['required' => '描述不能为空。', 'max' => '描述长度不能大于1024。'])->setWidth(8)->setMustMark();
+        $form->number('price', '价格')->rules('required', ['required' => '价格不能为空。'])->setWidth(4)->setMustMark();
+        $form->text('visit', '天数')->rules('required', ['required' => '天数不能为空。'])->setWidth(4)->setMustMark();
+        $form->text('place', '地点')->rules('required', ['required' => '地点不能为空。'])->setWidth(4)->setMustMark();
+        $form->datetime('travel_time', '出行时间')->rules('required', ['required' => '出行时间不能为空。'])->setWidth(4)->setMustMark();
+        $form->image('small_img', '缩略图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', ['image' => '缩略图请选择图片文件。', 'mimes' => '请选择jpeg,bmp,png格式的缩略图上传。'])->setWidth(4);
+        $form->multipleFile('img_list', '轮播图')->uniqueName()->rules('image|mimes:jpeg,bmp,png', ['image' => '轮播图请选择图片文件。', 'mimes' => '请选择jpeg,bmp,png格式的缩略图上传。'])->setWidth(4)->removable();
+        $form->editor('content', '内容')->rules('required', ['required' => '内容不能为空。'])->setMustMark();
+        $form->switch('is_display', '是否显示')->states($display_option)->default('1')->setMustMark();
+        $form->number('list_order', '排序')->min(0)->default(0)->rules('required', ['required' => '排序不能为空。'])->help('(数字越大越靠前)');
+
+        $form->saved(function (Form $form) {
+            //如果没有上传logo,判断是否
+            $small_img = \Illuminate\Support\Facades\Request::input('small_img');
+            if (!$form->model()->small_img && $small_img) {
+                $form->model()->small_img = $small_img;
+                $form->model()->save();
+            }
+
+            $img_list = \Illuminate\Support\Facades\Request::input('img_list');
+            if (!$form->model()->img_list && $img_list) {
+                $form->model()->img_list = $img_list;
+                $form->model()->save();
+            }
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+    public function destroy($id)
+    {
+        //是否存在报名列表
+        $ids   = explode(',', $id);
+        $check = RecuperateApply::whereIn('recuperate_id', $ids)->count();
+        if ($check > 0) {
+            return response()->json([
+                'status'  => false,
+                'message' => '存在报名信息的人才活动不允许删除!',
+            ]);
+        }
+
+        if ($this->form()->destroy($id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+
+    /**
+     * 导出报名列表
+     */
+    public function exportApply(Request $request)
+    {
+        //状态列表
+        $level_arr  = [
+            '',
+            '第一层次',
+            '第二层次',
+            '第三层次',
+            '第四层次',
+            '第五层次',
+            '第六层次',
+            '第七层次',
+        ];
+        $status_arr = [
+            '待审核',
+            '审核通过',
+            '审核不通过',
+            '取消活动',
+        ];
+
+        //获取数据
+        $id   = $request->id;
+        $data = [];
+        $list = RecuperateApply::where('recuperate_id', '=', $id)->get();
+
+        //数据处理
+        foreach ($list as $key => $value) {
+            $data[$key]['user_name']    = $value->user_name;
+            $data[$key]['user_idcard']  = $value->user_idcard;
+            $data[$key]['mobile']       = $value->mobile;
+            $data[$key]['wechat']       = $value->wechat;
+            $data[$key]['company_name'] = $value->company_name;
+            $data[$key]['level']        = $level_arr[$value->level];
+            $data[$key]['condition']    = $value->condition;
+            $data[$key]['tax']          = $value->tax;
+            $data[$key]['salary']       = $value->salary;
+            $data[$key]['created_at']   = $value->created_at;
+            $data[$key]['status']       = $status_arr[$value->status];
+            $data[$key]['reason']       = $value->reason;
+        }
+
+        //导出excel
+        $info   = Recuperate::where('id', $id)->first()->toArray();
+        $export = new RecuperateExport($info['title'] . '报名列表');
+        $c      = new Collection([
+            'list'  => $data,
+            'title' => $info['title'],
+        ]);
+        $export->setCustomerData($c)->export();//这里不需要return
+    }
+}

+ 93 - 0
app/Admin/Controllers/Content/RecuperateLogController.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\RecuperateLog;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+
+class RecuperateLogController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('额度修改记录')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new RecuperateLog());
+        $grid->model()->where('type',3);
+     //   $grid->model()->orderBy('created_at', 'DESC');
+        $grid->column('admin_user.username','操作者');
+
+        $grid->column('type','状态')->display(function ($type) {
+            if($type==1){
+                return '个人取消活动';
+            }elseif ($type==2){
+                return '管理员取消活动';
+            }elseif ($type==3){
+                return '管理员后台修改额度';
+            }
+        })->width(200);
+        $grid->column('member_infos.realname','被操作者');
+        $grid->content('内容');
+        $grid->created_at('操作时间');
+
+        $grid->filter(function ($filter) {
+            $filter->group('搜索', function ($group) {
+                $group->where('操作者', function ($query) {
+                    $query->whereHas('admin_user',function ($query){
+                        $query->where('username', 'like','%'.request()->搜索.'%');
+                    });
+                });
+
+                $group->where('被操作者', function ($query) {
+                    $query->whereHas('member_infos',function ($query){
+                        $query->where('realname', 'like','%'.request()->搜索.'%');
+                    });
+                });
+
+            })->placeholder('请输入关键字');
+
+            $filter->disableIdFilter();
+            $date3       = date('Y-m-d', strtotime("-3 day"));
+            $date7       = date('Y-m-d', strtotime("-7 day"));
+            $date30      = date("Y-m-d", strtotime("-1 month"));
+            $date180     = date("Y-m-d", strtotime("-6 month"));
+            $date360     = date("Y-m-d", strtotime("-1 year"));
+            $date_option = [
+                ''       => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            ];
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+
+        });
+        return $grid;
+    }
+
+
+}

+ 134 - 0
app/Admin/Controllers/Content/RecuperateTimeController.php

@@ -0,0 +1,134 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Http\Controllers\Controller;
+use App\Models\Recuperate;
+use App\Models\RecuperateApply;
+use App\Models\RecuperateLog;
+use App\Models\RecuperateTime;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Illuminate\Http\Request;
+use Encore\Admin\Facades\Admin;
+use App\Admin\Extensions\Form\ValidateForm;
+
+class RecuperateTimeController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('会员列表')
+            ->description(' ')
+            ->body(view('admin.content.recuperate_apply')->with(['grid' => $this->grid()]));
+    }
+
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('会员列表')
+            ->description('金额修改')
+           ->body($this->editForm($id)->edit($id));
+
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new RecuperateTime());
+
+        $grid->model()->orderBy('year', 'DESC');
+        $grid->column('memberinfo.realname', '姓名')->display(function ($realname) {
+            return '<a href="'.route('recuperate.applypersonal',['uid'=>$this->uid]).'" target="_blank">'.$realname.'</a>';
+        })->width(300);
+
+/*        $grid->title('招聘会标题')->display(function ($title) {
+            return '<a href="'.route('jobfair.show.com',$this->id).'" target="_blank">'.$title.'</a>';
+        })->width(300);*/
+        $grid->column('memberinfo.id_card','身份证号');
+       $grid->column('memberinfo.phone','联系电话');
+        $grid->year('年份');
+        $grid->price('金额');
+        $grid->created_at('创建时间');
+        //审核功能
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('content_recuperate_time_list_edit')) {
+                $actions->disableEdit(false);
+            }
+
+
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->group('搜索', function ($group) {
+                $group->where('姓名', function ($query) {
+                    $query->whereHas('memberinfo',function ($query){
+                        $query->where('realname', 'like','%'.request()->搜索.'%');
+                    });
+                });
+
+                $group->where('身份证号', function ($query) {
+                    $query->whereHas('memberinfo',function ($query){
+                        $query->where('id_card', 'like','%'.request()->搜索.'%');
+                    });
+                });
+                $group->where('联系电话',function ($query){
+                    $query->whereHas('memberinfo',function ($query){
+                        $query->where('phone', 'like','%'.request()->搜索.'%');
+                    });
+                });
+
+            })->placeholder('请输入关键字');
+        });
+        return $grid;
+    }
+
+
+    protected function editForm($id)
+    {
+        $form = new ValidateForm(new RecuperateTime());
+        $form->text('memberinfo.realname', '姓名')->readonly();
+        $form->text('memberinfo.id_card', '身份证')->readonly();
+        $form->text('memberinfo.phone', '联系方式')->readonly();
+        $form->text('price', '金额')->setMustMark();
+        $form->hidden('id');
+        return $form;
+    }
+
+    public function update($id, Request $request)
+    {
+        $request->validate([
+            'price' => 'required',
+
+        ],
+            [
+                'price' => '请填写金额',
+
+            ]);
+        $res = $this->editForm($id)->update($id);
+        if ($res) {
+            $stu = RecuperateTime::where('id', $id)->select('uid')->first();
+            $auditData = array(
+                'type' => 3,
+                'admin_id' => \Encore\Admin\Facades\Admin::user()->id,
+                'sid' => $stu->uid,
+                'content' =>$request->price
+            );
+            RecuperateLog::create($auditData);
+        }
+        return $res;
+    }
+}

+ 460 - 0
app/Admin/Controllers/Content/ReportController.php

@@ -0,0 +1,460 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Tools\DialogTool;
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Company;
+use App\Models\Jobs;
+use App\Models\Member;
+use App\Models\MemberInfo;
+use App\Models\Report;
+use App\Models\Resume;
+use App\Models\Subsite;
+use App\Services\Common\PmsService;
+use App\Services\Common\TaskService;
+use Encore\Admin\Admin as js_Admin;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Grid\Filter;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+
+class ReportController extends Controller
+{
+    use HasResourceActions;
+    protected $taskService;
+    protected $pmsService;
+
+    /**
+     * ReportController constructor.
+     * @param $taskService
+     * @param $pmsService
+     */
+    public function __construct(TaskService $taskService, PmsService $pmsService)
+    {
+        $this->taskService = $taskService;
+        $this->pmsService  = $pmsService;
+    }
+
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('举报信息')
+            ->description(' ')
+            //->body($this->grid());
+            ->body(view('admin.content.report')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    public function reportTypes(Request $request)
+    {
+        $q = $request->input('q')?$request->input('q'):1;
+        $report_reasons = Report::getReportTypes($q);
+
+        $report_reasons = array(''=>'不限') + $report_reasons;
+        $reasons = array();
+        foreach ($report_reasons as $k => $v) {
+            $reasons[] = array('id'=>$k,'text'=>$v);
+        }
+        return collect($reasons);
+    }
+
+    protected function grid()
+    {
+        $grid = new Grid(new Report);
+
+        if (get_subsite_id() != 0) {
+            $where['subsite_id'] = get_subsite_id();
+            $grid->model()->where($where)->orderBy('audit', 'asc')->orderBy('created_at', 'desc');
+        } else {
+            $grid->model()->orderBy('audit', 'asc')->orderBy('created_at', 'desc');
+        }
+        /*$grid->model()->orderBy('audit', 'asc')->orderBy('created_at', 'desc');*/
+
+        /*$grid->utype_realname('投诉职位/投诉简历')->limit(20);*/
+        $grid->utype_realname('投诉职位/投诉简历')->display(function () {
+            return '<span class="vtip" title="'.$this->utype_realname.'">'.cut_str($this->utype_realname, 15, 0, "...").'</span>';
+        })->width(200);
+        $grid->utype('举报类型')->display(function () {
+            return $this->utype==1?'职位':'简历';
+        });
+        $grid->audit('核实情况')->display(function () {
+            if ($this->audit == '1') {
+                return '<span style="color:#ff0000;">未核实</span><input type="hidden" name="report_audit_status" id="report_'.$this->id.'"  value="1"/>';
+            } elseif ($this->audit=='2') {
+                return '属实<input type="hidden" name="report_audit_status" id="report_'.$this->id.'" value="2"/>';
+            } elseif ($this->audit=='3') {
+                return '不属实<input type="hidden" name="report_audit_status" id="report_'.$this->id.'" value="3"/>';
+            }
+        });
+        $grid->type_id('举报原因');
+        $grid->content('举报内容')->display(function () {
+            return '<span class="vtip" title="'.$this->content.'">'.cut_str($this->content, 30, 0, "...").'</span>';
+        })->width(250);
+        $grid->username('举报对象');
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+
+        $grid->created_at('举报时间');
+        $grid->actions(function ($actions) {
+            /*$actions->disableEdit();*/
+            if (Admin::user()->can('content_report_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+            if (Admin::user()->can('content_report_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        if (Admin::user()->can('content_report_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+        if (!Admin::user()->can('content_report_audit') && !Admin::user()->can('content_report_delete')) {
+            $grid->disableRowSelector();
+        }
+        /*$grid->tools(function (Grid\Tools $tools) {
+            $tools->disableRefreshButton();
+        });*/
+
+        $grid->filter(function (Filter $filter) {
+            $filter->disableIdFilter();
+            $filter->column(2/3, function ($filter) {
+                /*if (get_subsite_id() == 0) {
+                    $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                    if ($subsites) {
+                        $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                        $filter->equal('subsite_id', '所属分站')->radio($subsites);
+                    }
+                }*/
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                if ($subsites) {
+                    $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                    $filter->equal('subsite_id', '所属分站')->select($subsites);
+                }
+
+                $types = array( ''=>'不限','1' => '职位', '2' => '简历');
+                $filter->equal('utype', '举报类型')->select(collect($types))->load('type_id', 'report/types', 'id', 'text');
+                $utype = \Illuminate\Support\Facades\Request::input('utype');
+                $utype = $utype?$utype:'';
+                $report_reasons = array(''=>'不限') + Report::getReportTypes($utype);
+                $filter->equal('type_id', '举报原因')->select($report_reasons);
+
+                if (get_subsite_id()) {
+                    $nums = Report::where(array('audit'=>'1','subsite_id'=>get_subsite_id()))->get()->count();
+                } else {
+                    $nums = Report::where(array('audit'=>'1'))->get()->count();
+                }
+
+                $num_html ='';
+                if ($nums>0) {
+                    $num_html = '('.$nums.')';
+                }
+                $status_option = array('1'=>'未核实'.$num_html,'2'=>'属实','3'=>'不属实');
+                $status_option = array(''=>'不限')+$status_option;
+                $filter->equal('audit', '核实情况')->radio($status_option);
+
+                $date3   = date('Y-m-d', strtotime("-3 day"));
+                $date7   = date('Y-m-d', strtotime("-7 day"));
+                $date30  = date("Y-m-d", strtotime("-1 month"));
+                $date180 = date("Y-m-d", strtotime("-6 month"));
+                $date360 = date("Y-m-d", strtotime("-1 year"));
+                $date_option = array(
+                    ''    => '不限',
+                    $date3   => '三天内',
+                    $date7   => '一周内',
+                    $date30  => '一月内',
+                    $date180 => '半年内',
+                    $date360 => '一年内',
+                );
+                //$filter->gt('created_at', '举报时间')->radio($date_option);
+                $filter->where(function ($query) {
+                    $query->where('created_at', '>=', "{$this->input}");
+                }, '举报时间', 'created_at')->radio($date_option);
+            });
+        });
+
+        //审核功能
+        if (Admin::user()->can('content_report_audit')) {
+            $grid->tools(function ($tools) {
+                $form = new \Encore\Admin\Widgets\Form();
+                $form->action(route('report.audit'));
+                $audit_option = array('2'=>'属实','3'=>'不属实');
+                $form->radio('audit', '将所选举报记录设置为:')->options($audit_option)->default(2)->setWidth(8, 4);
+                $form->json('val');
+                $config = array('title'=>'审核举报','button'=>'审核','dialog_cancel' => "取消", 'dialog_ok' => "确认", 'is_batch' => true);
+                $tools->append(new DialogTool($form, $config));
+            });
+        }
+
+        $this->script = <<<EOT
+            $(document).ready(function(){
+                $('table input[type="checkbox"]').each(function(){
+                    var \$data_id = $(this).data('id');
+                    if ($('#report_'+\$data_id).val() == 2) {
+                        $(this).parent().remove();
+                    }
+                });
+            });
+EOT;
+        js_Admin::script($this->script);
+
+        return $grid;
+    }
+
+    public function audit(Request $request)
+    {
+        $rst = $request->validate(['audit'=>'required'], array('audit.required'=>'请选择处理状态'));
+        $ids = $request->input('ids');
+        if (empty($ids)) {
+            if($request->type){
+                admin_toastr('请选择需要审核的数据', 'error');
+                return back();
+            }else {
+                return admin_toastr('请选择需要审核的数据', 'error');
+            }
+        }
+        $id_arr = explode(',', $ids);
+        $update_data = array(
+            'audit'       =>  $request->input('audit'),
+            'updated_at' => date('Y-m-d H:i:s', time())
+        );
+        $result = Report::whereIn('id', $id_arr)->where(array(array('audit','<>','2')))->get();
+        if (Report::whereIn('id', $id_arr)->where(array(array('audit','<>','2')))->update($update_data) === false) {
+            if($request->type){
+                admin_toastr('审核失败', 'error');
+                return back();
+            }else {
+                return admin_toastr('审核失败', 'error');
+            }
+        } else {
+            //添加审核日志
+            $reason_data = array('ids'=>$id_arr,'status'=>$request->input('audit'),'type'=>'6');
+            if ($request->input('audit')=='2') {
+                $reason_data['reason'] = '将举报记录设置为属实';
+            } else {
+                $reason_data['reason'] = '将举报记录设置为不属实';
+            }
+            AuditReason::addData($reason_data);
+            if ($result->toArray()) {
+                foreach ($result as $key => $list) {
+                    $utype = $list->utype;
+                    $timestring = date("Y年m月d日", time());
+                    if ($utype == 1) {
+                        //职位举报
+                        $per_info = MemberInfo::where(array('uid'=>$list->uid))->first();
+                        $member_info = Member::where(array('id'=>$list->uid))->first();
+                        $per_info->utype = $member_info->utype;
+                        $per_info->username = $member_info->username;
+                        $jobsinfo = Jobs::where(array('id'=>$list->utype_id))->first();
+                        if (!$jobsinfo) {
+                            continue;
+                        }
+                        $subsite_id = 0;
+                        if (!config('aix.system.site_safety.subsite.close_subsite')) {
+                            $subsite_id = $jobsinfo->subsite_id;
+                        }
+                        $jobsurl=route(url_rewrite('AIX_jobsshow', array('id'=>$jobsinfo->id), $subsite_id), array('id'=>$jobsinfo->id));
+                        $company_info = Company::where(array('id'=>$jobsinfo->company_id))->first();
+                        $company_info->uid = $company_info->id;
+
+                        if ($request->input('audit') == 2) {
+                            $r = $this->taskService->doUserTask($per_info, 13);
+                            $msg_p = '';
+                            if (array_get($r, 'code') == 1) {
+                                $msg_p = ",奖励".$r['data']['points']."积分,感谢您对".subsite_config('aix.system.site.site.site_name', '', $member_info->subsite_id)."的支持!";
+                            }
+                            $message="您于".$timestring."举报企业【".$jobsinfo->company_name."】发布的职位:【<a href=\"{$jobsurl}\" target=\"_blank\">".$list->utype_realname."</a>】,经平台核实情况属实".$msg_p;
+                            $this->pmsService->writePmsNotice($per_info, $message);
+                            $message_c="您发布的职位:【<a href=\"{$jobsurl}\" target=\"_blank\">{$list->utype_realname}</a>】于".$timestring."被举报,经平台核实情况属实,请尽快处理,如再有此类情况发生将作封号处理!";
+                            $this->pmsService->writePmsNotice($company_info, $message_c);
+                        } else {
+                            $message="您于".$timestring."举报企业【".$jobsinfo->company_name."】发布的职位:【<a href=\"{$jobsurl}\" target=\"_blank\">{$list->utype_realname}</a>】,经平台核实情况不属实";
+                            $this->pmsService->writePmsNotice($per_info, $message);
+                        }
+                    } else {
+                        //简历举报
+                        $company_info = Company::where(array('id'=>$list->uid))->first();
+                        if (!$company_info) {
+                            continue;
+                        }
+                        $company_info->uid = $company_info->id;
+                        $resume_info = Resume::where(array('id'=>$list->utype_id))->first();
+                        if (!$resume_info) {
+                            continue;
+                        }
+                        $resumeurl = route(url_rewrite('AIX_resumeshow'), ['id'=>$list->utype_id]);
+
+                        if ($request->input('audit') == 2) {
+                            $r = $this->taskService->doUserTask($company_info, 21);     //5.1 获取举报职位所得积分信息
+                            $msg_p = '';
+                            if (array_get($r, 'code') == 1) {
+                                $msg_p = ",奖励".$r['data']['points']."积分,感谢您对".subsite_config('aix.system.site.site.site_name', '', $company_info->subsite_id)."的支持!";
+                            }
+                            $message="您于".$timestring."举报的简历:【<a href='".$resumeurl."' target='_blank'>".$list->utype_realname."</a>】,经平台核实情况属实".$msg_p;
+                            $this->pmsService->writePmsNotice($company_info, $message);
+
+                            $per_info = Member::where(array('id'=>$resume_info->uid))->first();
+                            if ($per_info) {
+                                $per_info->uid = $per_info->id;
+                                $message_c="您发布的简历【".$list->utype_realname."】于".$timestring."被举报,经平台核实情况属实,请尽快处理,如再有此类情况发生将作封号处理!";
+                                $this->pmsService->writePmsNotice($per_info, $message_c);
+                            }
+                        } else {
+                            $message="您于".$timestring."举报的简历【<a href=\"{$resumeurl}\" target=\"_blank\">{$list->utype_realname}</a>】,经平台核实情况不属实";
+                            $this->pmsService->writePmsNotice($company_info, $message);
+                        }
+                    }
+                }
+            }
+            if($request->type){
+                admin_toastr('审核成功', 'success');
+                return back();
+            }else {
+                return admin_toastr('审核成功', 'success');
+            }
+
+        }
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Report::findOrFail($id));
+        $report_info = Report::findOrFail($id);
+        $show->id('ID');
+        $show->username('举报对象');
+        if ($report_info->utype == 1) {
+            $show->utype_id('职位ID');
+            $show->utype_realname('投诉职位');
+        } else {
+            $show->utype_id('简历ID');
+            $show->utype_realname('投诉简历');
+        }
+        $show->utype('举报类型')->as(function ($utype) {
+            if ($utype == 1) {
+                return '职位';
+            }
+            return '简历';
+        });
+        $show->type_id('举报原因');
+        if ($report_info->utype == 1) {
+            $show->phone('联系电话');
+            $show->content('内容描述');
+        }
+        $show->audit('核实情况')->as(function ($audit) {
+            if ($audit == 1) {
+                return '未核实';
+            } else if ($audit == 2) {
+                return '属实';
+            } else if ($audit == 3) {
+                return '不属实';
+            }
+        });
+        if(get_subsite_open()){
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        /*$show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+            });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Report);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 595 - 0
app/Admin/Controllers/Content/SysMessageController.php

@@ -0,0 +1,595 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Admin\Extensions\Field\Template;
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\Subsite;
+use App\Models\SubsiteSysMessage;
+use App\Models\SysMessage;
+use Encore\Admin\Admin;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+
+//use Encore\Admin\Grid;
+
+class SysMessageController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('消息')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        $msg_info = SysMessage::findOrFail($id);
+        $header = '站内信';
+        if ($msg_info->news_type=='2') {
+            $header = '弹窗消息';
+        }
+        return $content
+            ->header($header)
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        $msg_info = SysMessage::findOrFail($id);
+        if ($msg_info && $msg_info->news_type=='1') {
+            return $content
+                ->header('站内信')
+                ->description(' ')
+                ->body($this->editForm($id)->edit($id));
+        } else {
+            return $content
+                ->header('弹窗消息')
+                ->description(' ')
+                ->body($this->form($id)->edit($id));
+        }
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        $form = new \Encore\Admin\Widgets\Form();
+
+        //$form->action(admin_base_path('content/sysmessage/index/addForm'));
+        $form->action(route('sysmessage.store'));
+        $user_types = array('0'=>'全部会员','1'=>'企业会员','2'=>'个人会员');
+        $form->radio('user_type', '接收会员')->options($user_types)->default(key($user_types))->setMustMark();
+
+        $news_type_option = array('1'=>'站内信','2'=>'弹窗消息');
+        $form->radio('news_type', '消息类型')->options($news_type_option)->default(key($news_type_option))->attribute("id", "news_type")->setMustMark();
+
+        /*if (get_subsite_id()==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+            if ($subsites) {
+                $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+            }
+        } else {
+            $form->hidden('relate_subsites');
+        }*/
+        if (get_subsite_id()==0) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+        } else {
+            $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            $subsites['0']= '总站';
+            $subsites = collect($subsites);
+        }
+        if ($subsites->isNotEmpty() && get_subsite_id()==0) {
+            $form->multipleSelect('relate_subsites', '同步分站')->options($subsites);
+        } else {
+            $form->hidden('relate_subsites');
+        }
+
+        $form->html("<div id='change_field'></div>")->plain();
+
+        $template=new Template();
+        $template->setTemplatesId("sys_div");
+        $types = array('1'=>'普通消息','2'=>'注册提醒');
+        $template->radio('type', '站内信类型')->options($types)->default(key($types))->setMustMark();
+        $template->textarea('content', '站内信内容')->rows(1)->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+
+        $template->setTemplatesId("pop_div");
+
+        $template->date('started_at', '开始日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'开始日期不能为空。', 'date'=>'开始日期格式不正确。'))->setMustMark();
+        $template->date('ended_at', '结束日期')->format('YYYY-MM-DD')->rules('required|date|after_or_equal:started_at', array('required'=>'结束日期不能为空。', 'date'=>'结束日期格式不正确。','after_or_equal'=>'结束日期不能小于开始日期。',))->setMustMark();
+
+        $template->editor('content', '弹窗内容')->rules('required', array('required'=>'内容不能为空。'))->setMustMark();
+
+        $form->disableReset();
+        $data['custom_form']=$form->render();
+        $data['temp']=$template->render();
+
+        return $content
+            ->header('消息')
+            ->description(' ')
+            ->body(view('admin.content.sys_message')->with($data));
+    }
+    public function store(Request $request)
+    {
+        $rule = array(
+            'user_type' => 'required',
+            'news_type' => 'required',
+            'content'   => 'required'
+        );
+        $message = array(
+            'user_type.required' => '请选择接收会员。',
+            'news_type.required' => '请选择消息类型。'
+        );
+        $subsite_id = get_subsite_id();
+        if ($request->input('news_type')=='1') {
+            $rule['type'] = 'required';
+            $message['type.required'] = '请选择站内信类型。';
+            $message['content.required'] = '站内信内容不能为空。';
+        } else {
+            $rule['started_at'] = 'required';
+            $rule['ended_at'] = 'required';
+            $message['started_at.required'] = '请选择开始日期。';
+            $message['ended_at.required'] = '请选择结束日期';
+            $message['content.required'] = '弹窗消息内容不能为空。';
+        }
+        $request->validate($rule, $message);
+        $time = date('Y-m-d H:i:s', time());
+        $type = $request->input('type')?$request->input('type'):0;
+
+        $insert_data = array();
+        $form_data = array(
+            'user_type' => (integer)$request->input('user_type'),
+            'news_type' => $request->input('news_type'),
+            'type'       => $type,
+            'content'    => $request->input('content'),
+            'started_at' => $request->input('started_at')?strtotime($request->input('started_at')):0,
+            'ended_at'   => $request->input('ended_at')?strtotime($request->input('ended_at')):0,
+            'subsite_id' => $subsite_id,
+            'created_at' => $time,
+            'updated_at' => $time
+        );
+        $subsites = $request->input('relate_subsites');
+        if (empty($subsites)) {
+            $subsites = [];
+        }
+        if ($sys = SysMessage::create($form_data)) {
+            $set_data = array();
+            $set_data[] = array(
+                'sys_message_id' => $sys->id,
+                'subsite_id'     => get_subsite_id()
+            );
+            $subsites = array_merge($subsites);
+            if ($subsites) {
+                foreach ($subsites as $k => $v) {
+                    if ($v || $v===0) {
+                        $set_data[] = array(
+                            'sys_message_id' => $sys->id,
+                            'subsite_id'     => $v
+                        );
+                    }
+                }
+            }
+            if ($set_data) {
+                SubsiteSysMessage::insert($set_data);
+            }
+            admin_toastr(trans('admin.save_succeeded'), 'success');
+            return redirect(admin_base_path().'/content/sysmessage/index');
+        } else {
+            throw new \Exception(trans('admin.save_failed'));
+        }
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SysMessage);
+
+        $news_type = \Illuminate\Support\Facades\Request::input('news_type');
+        if ($news_type) {
+            $grid->model()->where('news_type', '=', $news_type);
+            $grid->model()->when(get_subsite_id()>0, function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            })->where('news_type', '=', $news_type)->orderBy('created_at', 'DESC');
+        } else {
+            $grid->model()->when(get_subsite_id()>0, function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            })->orderBy('created_at', 'DESC');
+        }
+
+
+        $grid->content('内容')->display(function () {
+            return '<span title="'.$this->content.'">'.cut_str(strip_tags($this->content), 35, 0, "...").'</span>';
+        })->width(450);
+        $grid->user_type('接收会员')->display(function () {
+            $user_info = '';
+            if ($this->user_type =='0') {
+                $user_info = '所有会员 ';
+            } else if ($this->user_type =='1') {
+                $user_info = '企业会员 ';
+            } else if ($this->user_type =='2') {
+                $user_info = '个人会员 ';
+            }
+            return $user_info;
+        });
+        $grid->news_type('消息类型')->display(function () {
+            $news_info = '';
+            if ($this->news_type =='1') {
+                $news_info = '站内信 ';
+            } else if ($this->news_type =='2') {
+                $news_info = '弹窗消息 ';
+            }
+            return $news_info;
+        });
+        if (get_subsite_open()) {
+            $grid->subsite_id('所属分站')->display(function () {
+                $subsites = Cache::get('subsites_list');
+                if (array_has($subsites, $this->subsite_id)) {
+                    return $subsites[$this->subsite_id]['sitename'];
+                }
+                return '';
+            });
+        }
+
+        if ($news_type=='1') {
+            $grid->type('站内信类型')->display(function () {
+                $type_info = '';
+                if ($this->type =='1') {
+                    $type_info = '普通消息 ';
+                } else if ($this->type =='2') {
+                    $type_info = '注册提醒';
+                }
+                return $type_info;
+            });
+        }
+
+        $grid->started_at('显示开始日期');
+        $grid->ended_at('显示结束日期');
+        $grid->created_at('添加时间');
+
+        $this->script = <<<EOT
+            $('input[name="news_type"]').parent().parent().parent().attr('id','news_type_div');
+            $('input[name="type"]').parent().parent().parent().parent().attr('id','type_div');
+            $('input[name="news_type"]').on('ifChecked', function(event){
+                var \$news_type = $('input[name="news_type"]:checked').val();
+                if(\$news_type == '1'){
+                    $('#type_div').css('display','block');
+                }else if(\$news_type == '2'){
+                    $('#type_div').css('display','none');
+                    $('#type_div input[type="radio"][name="type"]').each(function (){
+		                if($(this).val()==''){
+		                    $(this).iCheck('check');
+		                }else{
+		                    $(this).iCheck('uncheck');
+		                }
+                    });
+                }
+                
+            });
+            
+            $(document).ready(function(){
+                //判断是否显示默认值
+                var \$default_news = $('#news_type_div input[type="radio"][name="news_type"]:checked').val();
+                if(\$default_news =='1'){
+                    $('#type_div').css('display','block');
+                }else{
+                    $('#type_div').css('display','none');
+                }
+            });
+EOT;
+        Admin::script($this->script);
+
+        if (userAdmin::user()->can('content_sysmessage_create')) {
+            $grid->disableCreateButton(false);
+        }
+        if (userAdmin::user()->can('content_sysmessage_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+
+        $grid->actions(function ($actions) {
+            if (userAdmin::user()->can('content_sysmessage_delete')) {
+                if ($actions->row['subsite_id']== get_subsite_id() || get_subsite_id()==0) {
+                    $actions->disableDelete(false);
+                }
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $news_option = array(''=>'不限', '1'=>'站内信', '2'=>'弹窗消息');
+            $filter->equal('news_type', '消息类型')->radio($news_option);
+            $news_type = \Illuminate\Support\Facades\Request::input('news_type');
+            $type_option = array('' => '不限', '1' => '普通消息', '2' => '注册提醒');
+            $filter->equal('type', '站内信类型')->radio($type_option);
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            if ($subsites) {
+                $subsites = array('' => '不限', '0' => '总站') + $subsites;
+                $filter->equal('subsite_id', '所属分站')->select($subsites);
+            }
+            $filter->like('content', '内容');
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SysMessage::findOrFail($id));
+        $msg_info = SysMessage::findOrFail($id);
+        $show->id('ID');
+        $show->user_type('接收会员')->as(function ($user_type) {
+            $user_type_info = '';
+            if ($user_type=='0') {
+                $user_type_info = '全部会员';
+            } elseif ($user_type=='1') {
+                $user_type_info = '企业会员';
+            } elseif ($user_type=='2') {
+                $user_type_info = '个人会员';
+            }
+            return $user_type_info;
+        });
+        $show->news_type('消息类型')->as(function ($news_type) {
+            return $news_type=='1'?'站内信':'弹窗消息';
+        });
+        if ($msg_info && $msg_info->news_type == '1') {
+            $show->type('站内信类型')->as(function ($type) {
+                $type_html = '';
+                if ($type=='1') {
+                    $type_html = '普通消息';
+                } else if ($type=='2') {
+                    $type_html = '注册提醒';
+                }
+                return $type_html;
+            });
+        }
+        $show->content('内容')->setEscape(false);
+        if (get_subsite_open()) {
+            $show->subsite_id('所属分站')->as(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::findOrFail($subsite_id);
+                    return $Subsite->sitename;
+                }
+                return '总站';
+            });
+        }
+
+        $show->started_at('显示开始日期');
+        $show->ended_at('显示结束日期');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        /*$show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+            });*/
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form($id)
+    {
+        $form = new ValidateForm(new SysMessage);
+
+        $info = SysMessage::find($id);
+
+        $user_types = array('0'=>'全部会员','1'=>'企业会员','2'=>'个人会员');
+        $form->radio('user_type', '接收会员')->options($user_types)->default(key($user_types));
+
+        if (get_subsite_id()==0 && $info->subsite_id == get_subsite_id() &&get_subsite_open()) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+            if ($subsites) {
+                $relations = SubsiteSysMessage::where(array('sys_message_id'=>$id))->get()->pluck('subsite_id')->toArray();
+                $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+            }
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+        $form->hidden('subsite_id')->value(get_subsite_id());
+
+        $form->date('started_at', '开始日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'开始日期不能为空。', 'date'=>'开始日期格式不正确。'));
+        $form->date('ended_at', '结束日期')->format('YYYY-MM-DD')->rules('required|date|after_or_equal:started_at', array('required'=>'结束日期不能为空。', 'date'=>'结束日期格式不正确。','after_or_equal'=>'结束日期不能小于开始日期。',));
+        $form->editor('content', '内容')->rules('required', array('required'=>'内容不能为空。'));
+        $form->hidden('news_type');
+        $form->saving(function (Form $form) {
+            $form->started_at = strtotime($form->started_at);
+            $form->ended_at = strtotime($form->ended_at);
+            $form->type = 0;
+        });
+        $form->saved(function (Form $form) {
+            if (get_subsite_id() == 0 && $form->model()->subsite_id == get_subsite_id()) {
+                $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+                $subsites = array_merge(array(get_subsite_id()), $subsites);
+                SubsiteSysMessage::where('sys_message_id', $form->model()->id)->delete();
+                $set_data = array();
+                foreach ($subsites as $k => $v) {
+                    if ($v !== null) {
+                        $set_data[] = array(
+                            'sys_message_id' => $form->model()->id,
+                            'subsite_id'=> $v
+                        );
+                    }
+                }
+                SubsiteSysMessage::insert($set_data);
+            }
+        });
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+    protected function editForm($id)
+    {
+        $form = new ValidateForm(new SysMessage);
+        $info = SysMessage::find($id);
+
+        $user_types = array('0'=>'全部会员','1'=>'企业会员','2'=>'个人会员');
+        $form->radio('user_type', '接收会员')->options($user_types)->rules('required', array('required'=>'请选择接收会员。'));
+        $types = array('1'=>'普通消息','2'=>'注册提醒');
+        $form->radio('type', '站内信类型')->options($types)->rules('required', array('required'=>'请选择站内信类型。'));
+
+        if (get_subsite_id()==0 && $info->subsite_id == get_subsite_id()) {
+            $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id');
+            if ($subsites) {
+                $relations = SubsiteSysMessage::where(array('sys_message_id'=>$id))->get()->pluck('subsite_id')->toArray();
+                $form->multipleSelect('relate_subsites', '同步分站')->options($subsites)->default($relations);
+            }
+        } else {
+            $form->hidden('relate_subsites');
+        }
+        $form->ignore(['relate_subsites']);
+        $form->hidden('subsite_id')->value(get_subsite_id());
+
+        $form->date('started_at', '开始日期')
+            ->format('YYYY-MM-DD')
+            ->rules('required|date', array('required'=>'开始日期不能为空。', 'date'=>'开始日期格式不正确。'));
+        $form->date('ended_at', '结束日期')
+            ->format('YYYY-MM-DD')
+            ->rules('required|date|after_or_equal:started_at', array('required'=>'结束日期不能为空。', 'date'=>'结束日期格式不正确。','after_or_equal'=>'结束日期不能小于开始日期。',));
+        $form->textarea('content', '站内信内容')->rows(1)->rules('required', array('required'=>'内容不能为空。'));
+        $form->hidden('news_type');
+        $form->saving(function (Form $form) {
+            $form->started_at = strtotime($form->started_at);
+            $form->ended_at = strtotime($form->ended_at);
+        });
+
+        $form->saved(function (Form $form) {
+            if (get_subsite_id() == 0 && $form->model()->subsite_id == get_subsite_id()) {
+                $subsites = \Illuminate\Support\Facades\Request::input('relate_subsites');
+                $subsites = array_merge(array(get_subsite_id()), $subsites);
+                SubsiteSysMessage::where('sys_message_id', $form->model()->id)->delete();
+                $set_data = array();
+                foreach ($subsites as $k => $v) {
+                    if ($v !== null) {
+                        $set_data[] = array(
+                            'sys_message_id' => $form->model()->id,
+                            'subsite_id'=> $v
+                        );
+                    }
+                }
+                SubsiteSysMessage::insert($set_data);
+            }
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+    public function update($id)
+    {
+        $data=$this->form($id)->getValidateInput();
+        if ($data['news_type']=='1') {
+            return $this->editForm($id)->update($id);
+        } else {
+            return $this->form($id)->update($id);
+        }
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (get_subsite_id() == 0) {
+            $filter_id = $id;
+        } else {
+            $seletctors = SysMessage::where(array('subsite_id'=>get_subsite_id()))->whereIn('id', $ids)->get()->pluck('id')->toarray();
+            if ($seletctors) {
+                $filter_id = implode(',', $seletctors);
+            } else {
+                $filter_id = '';
+            }
+        }
+        if ($filter_id) {
+            if ($this->form($id)->destroy($filter_id)) {
+                $data = [
+                    'status'  => true,
+                    'message' => trans('admin.delete_succeeded'),
+                ];
+            } else {
+                $data = [
+                    'status'  => false,
+                    'message' => trans('admin.delete_failed'),
+                ];
+            }
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => '不能删除其它分站数据!',
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 181 - 0
app/Admin/Controllers/Content/TreatController.php

@@ -0,0 +1,181 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\Category;
+use App\Models\PolicyProperty;
+use App\Models\Treat;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+
+
+class TreatController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('待遇分类')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('待遇分类')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+
+        return $content
+            ->header('待遇分类')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('待遇分类')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Treat);
+        $grid->id('id');
+        $grid->categorys()->demand('面向人才');
+        $grid->title('分类名称');
+        $grid->intro('简介');
+        $grid->policyproperty()->categoryname('政策层级');
+        $grid->sort('排序');
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->filter(function ($filter) {
+            $filter->like('categorys.demand', '面向人才');
+            $filter->like('title', '分类名称');
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Treat::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Treat);
+        $form->text('title', '待遇名称')->rules(['required'], ['required'=>'请填写待遇名称'])->setMustMark();
+        $policyProperty = PolicyProperty::select()->pluck('categoryname', 'id');
+//        $policyProperty[0] ='不限';
+        $form->select('property_id', '政策层次')->options($policyProperty)->load('c_id', admin_base_path('/content/policys/treats/category'))->rules("required")->setMustMark();
+        $form->select('c_id', '面向人才')->rules(['required'], ['required'=>'请填写面向人才'])->setMustMark();
+        $form->text('intro', '待遇简介')->rules(['required'], ['required'=>'请填写待遇简介'])->setMustMark();
+        $form->number('sort', '排序')->default(0)->min(0);
+        $form->text('content', '待遇内容')->rules(['required'], ['required'=>'请填写待遇内容'])->setMustMark();
+        return $form;
+    }
+
+    protected function editForm($id)
+    {
+        $form = new Form(new Treat);
+        $treatData = Treat::where('id', $id)->select('property_id')->first()->toArray();
+
+        $form->text('title', '待遇名称')->rules(['required'], ['required'=>'请填写待遇名称'])->setMustMark();
+        $policyProperty = PolicyProperty::select()->pluck('categoryname', 'id');
+//        $policyProperty[0] ='不限';
+        $arr = array(
+            '1' => 'RC_category_fj',
+            '2' => 'RC_category_qz',
+            '7' => '',
+            '8' => 'RC_category'
+        );
+        $form->select('property_id', '政策层次')->options($policyProperty)->load('c_id', admin_base_path('/content/policys/treats/category'))->rules("required")->setMustMark();
+        $form->select('c_id', '面向人才')->options(Category::categoryType($arr[$treatData['property_id']]))->rules(['required'], ['required'=>'请填写面向人才'])->setMustMark();
+        $form->text('intro', '待遇简介')->rules(['required'], ['required'=>'请填写待遇简介'])->setMustMark();
+        $form->number('sort', '排序')->default(0)->min(0);
+        $form->text('content', '待遇内容')->rules(['required'], ['required'=>'请填写待遇内容'])->setMustMark();
+        return $form;
+    }
+
+    public function category(Request $request)
+    {
+        $q = $request->get('q');
+        $arr = array(
+            '1' => 'RC_category_fj',
+            '2' => 'RC_category_qz',
+            '7' => 'RC_category_jj',
+            '8' => 'RC_category'
+        );
+        return Category::where('alias', $arr[$q])->get(['id',"demand as text"]);
+    }
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+}

+ 292 - 0
app/Admin/Controllers/Content/innovatorController.php

@@ -0,0 +1,292 @@
+<?php
+
+namespace App\Admin\Controllers\Content;
+
+use App\Models\Category;
+use App\Models\Innovator;
+use App\Http\Controllers\Controller;
+use App\Models\InnovatorCategory;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Input;
+
+class innovatorController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content,Request $request)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description(' ')
+            ->body(view('admin.content.photo')->with(['grid'=>$this->grid($request)]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('创业帮手')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Innovator);
+
+        $grid->model()->orderBy('display_order', 'DESC')->orderBy('created_at', 'DESC');
+        $grid->id('ID');
+        $grid->column('photo_img', '姓名')->display(function ($images) {
+
+            $pbstr='';
+            if($this->is_display==0){
+                $pbstr= '<span style="color:#999999">&nbsp;&nbsp;&nbsp;&nbsp;[已屏蔽]</span>';
+            }
+            $params = '?type_id='.$this->type_id;
+            $title_url = url(admin_base_path().'/content/innovator'.$params);
+            $title_url1 = url('content/innovators/show?id='.$this->id);
+            if ($images) {
+                return '<span class="vtip" title="<img src='.upload_asset($images).' width=120 height=120>">
+                            <img class="avatar small" src="'.upload_asset($images).'" align="absmiddle" style="width: 36px;height: 36px;">
+                        </span>&nbsp;&nbsp;&nbsp;'.'<a href='.$title_url.' style="color: #006699;">['.$this->type_name.']</a><a target="_blank"  href='.$title_url1.'><span>'.$this->name.'</span></a>'.$pbstr;
+            } else {
+                return '<a href='.$title_url.' style="color: #006699;">['.$this->type_name.']</a><span class="vtip" ></span>&nbsp;&nbsp;&nbsp;'. '<a target="_blank"  href='.$title_url1.'><span >'.$this->name.'</span></a>'.$pbstr;
+            }
+        })->width(200);
+
+        $grid->column('trade_cn', '所属行业');
+        $grid->column('duty_name', '职务名称');
+        $grid->display_order('排序');
+        $grid->created_at('添加日期');
+        $grid->disableCreateButton(false);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit(false);
+            $actions->disableDelete(false);
+        });
+        $grid->tools(function ($tools) {
+            $tools->batch(function ($batch) {
+                $batch->disableDelete(false);
+            });
+        });
+        $grid->filter(function ($filter) {
+            $filter->equal('id', 'ID');
+            $filter->like('name', '名称');
+            $innovatorcategory = InnovatorCategory::where(['parentid'=>0])->orderBy("id", 'asc')->get()->pluck('categoryname', 'id');
+            $filter->where(function ($query) {
+                $query->where('type_id', '=', "{$this->input}");
+            }, '创业分类', 'type_id')->select($innovatorcategory);
+
+            $date3   = date('Y-m-d', strtotime("-3 day"));
+            $date7   = date('Y-m-d', strtotime("-7 day"));
+            $date30  = date("Y-m-d", strtotime("-1 month"));
+            $date180 = date("Y-m-d", strtotime("-6 month"));
+            $date360 = date("Y-m-d", strtotime("-1 year"));
+            $date_option = array(
+                ''    => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            );
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+        });
+
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Innovator::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Innovator);
+
+        $form->text('name', '姓名')->rules('required|max:100', array('required'=>'姓名不能为空。','max'=>'姓名长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->image('photo_img', '头像')->help('(建议尺寸240*70)')->setWidth(6);
+        $form->select('type_id', '所属分类')->options(InnovatorCategory::select()->pluck('categoryname', 'id'))->rules('required', array('required'=>'请选择所属分类'))->setWidth(6)->setMustMark();
+        $form->text('duty_name', '职务名称')->rules('required|max:100', array('required'=>'职务名称不能为空。','max'=>'职务名称长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->select('trade_id', '所属行业')->options(Category::categoryType('AIX_trade'))->setWidth(6)->rules('required', ['required'=>'请选择相应的所属行业'])->setMustMark();
+        $form->text('points', '特长')->rules('required|max:100', array('required'=>'特长不能为空。','max'=>'特长长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->text('company_name', '单位名称')->rules('required|max:100', array('required'=>'单位名称不能为空。','max'=>'单位名称长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->mobile('mobile', '联系方式')->setWidth(6);
+        $form->radio('mobile_display', '联系方式对外公开')->options([0=>'不公开', 1=>'公开' ])->default('1');
+        $form->text('email', '联系邮箱')->setWidth(6);
+        $form->radio('email_display', '邮箱对外公开')->options([0=>'不公开', 1=>'公开' ])->default('1');
+        $form->editor('content', '业绩介绍')->rules('required', array('required'=>'业绩介绍不能为空。'))->setWidth(6)->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->default(1)->states($display_option)->setMustMark();
+//        $form->date('created_at', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'));
+        $form->number('display_order', '新闻排序')->min(0)->default(255)->rules('required', array('required'=>'新闻排序不能为空。'))->help('(数字越大越靠前)');
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->hidden('addtime');//添加时间
+        $form->hidden('parentid')->value(0);//设置为0
+        $form->hidden('trade_cn');//所属行业名称
+        $form->hidden('type_name');//所属分类名称
+
+        $form->saving(function (Form $form){
+            //设置添加时间
+            $form->addtime=time();
+
+           $type_id= Input::get('type_id');
+           $InnovatorCategory= InnovatorCategory::where(['id'=>$type_id])->first();
+           $form->type_name=$InnovatorCategory->categoryname;
+           $trade_id=  Input::get('trade_id');
+           $form->trade_cn=get_category($trade_id);
+
+        });
+        return $form;
+    }
+
+    protected function editForm($id)
+    {
+        $form = new Form(new Innovator);
+
+        $form->text('name', '姓名')->rules('required|max:100', array('required'=>'姓名不能为空。','max'=>'姓名长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->image('photo_img', '头像')->help('(建议尺寸240*70)')->setWidth(6);
+        $form->select('type_id', '所属分类')->options(InnovatorCategory::select()->pluck('categoryname', 'id'))->rules('required', array('required'=>'请选择所属分类'))->setWidth(6)->setMustMark();
+        $form->text('duty_name', '职务名称')->rules('required|max:100', array('required'=>'职务名称不能为空。','max'=>'职务名称长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->select('trade_id', '所属行业')->options(Category::categoryType('AIX_trade'))->setWidth(6)->rules('required', ['required'=>'请选择相应的所属行业'])->setMustMark();
+        $form->text('points', '特长')->rules('required|max:100', array('required'=>'特长不能为空。','max'=>'特长长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->text('company_name', '单位名称')->rules('required|max:100', array('required'=>'单位名称不能为空。','max'=>'单位名称长度不能大于100。'))->setWidth(6)->setMustMark();
+        $form->mobile('mobile', '联系方式')->setWidth(6);
+        $form->radio('mobile_display', '联系方式对外公开')->options([0=>'不公开', 1=>'公开' ])->default('1');
+        $form->text('email', '联系邮箱')->setWidth(6);
+        $form->radio('email_display', '邮箱对外公开')->options([0=>'不公开', 1=>'公开' ])->default('1');
+        $form->editor('content', '业绩介绍')->rules('required', array('required'=>'业绩介绍不能为空。'))->setWidth(6)->setMustMark();
+        $display_option = [
+            'on'  => ['value' => 1, 'text' => '是', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
+        ];
+        $form->switch('is_display', '是否显示')->states($display_option)->setMustMark();
+//        $form->date('created_at', '发布日期')->format('YYYY-MM-DD')->rules('required|date', array('required'=>'发布日期不能为空。', 'date'=>'发布日期格式不正确。'));
+        $form->number('display_order', '新闻排序')->min(0)->default(0)->rules('required', array('required'=>'新闻排序不能为空。'))->help('(数字越大越靠前)');
+        $form->url('is_url', '外部链接')->rules('max:250', array('max'=>'外部链接长度不能超过250。'))->help('(请输入包含http://或https://的完整链接)');
+        $form->text('keywords', 'Keywords')->placeholder('合理设置Keywords有利于搜索引擎排名')->rules('max:80', array('max:Keywords不能大于80个字符。'));
+        $form->textarea('description', 'Description')->placeholder('合理设置Description有利于搜索引擎排名')->rules('max:80', array('max'=>'Description不能大于80个字符。'));
+        $form->hidden('addtime');//添加时间
+        $form->hidden('parentid')->value(0);//设置为0
+        $form->hidden('trade_cn');//所属行业名称
+        $form->hidden('type_name');//所属分类名称
+
+        $form->saving(function (Form $form){
+
+            $type_id= Input::get('type_id');
+            $InnovatorCategory= InnovatorCategory::where(['id'=>$type_id])->first();
+            $form->type_name=$InnovatorCategory->categoryname;
+            $trade_id=  Input::get('trade_id');
+            $form->trade_cn=get_category($trade_id);
+
+        });
+
+        return $form;
+    }
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的创业帮手', 'error');
+        }
+        \DB::beginTransaction();
+        try {
+            Innovator::whereIn('id', $ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 124 - 0
app/Admin/Controllers/ExampleController.php

@@ -0,0 +1,124 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+//use Encore\Admin\Grid;
+
+class ExampleController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('Index')
+            ->description('description')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed   $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed   $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new YourModel);
+
+        $grid->id('ID')->sortable();
+        $grid->created_at('Created at');
+        $grid->updated_at('Updated at');
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(YourModel::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new YourModel);
+
+        $form->display('id', 'ID');
+        $form->display('created_at', 'Created At');
+        $form->display('updated_at', 'Updated At');
+
+        return $form;
+    }
+}

+ 197 - 0
app/Admin/Controllers/FindJobsController.php

@@ -0,0 +1,197 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Http\Controllers\Controller;
+use App\Models\Jobs;
+use App\Models\MemberInfo;
+use App\Models\Resume;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class FindJobsController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        $id = request()->id;
+        $uid = request()->uid;
+        $resume = Resume::where(['id'=>$id])->first();
+        $member = MemberInfo::where(['uid'=>$uid])->first();
+        return $content
+            ->header('职位匹配')
+            ->description('列表')
+            ->body(view('admin.jobs.find_jobs')->with(['grid'=>$this->grid(),'resume'=>$resume,'member'=>$member]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('职位匹配')
+            ->description('详细')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('职位匹配')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('职位匹配')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Jobs);
+
+        $grid->id('ID');
+        $grid->jobs_name('职位名称');
+        $grid->company_name('公司名称');
+        $grid->audit('审核状态')->display(function ($audit) {
+            switch ($audit) {
+                case 1:
+                    $audit = '<span style="color: #00a65a;">审核通过</span>';
+                    break;
+                case 2:
+                    $audit = '<span>审核中</span>';
+                    break;
+                case 3:
+                    $audit = '<span style="color: red;">审核未通过</span>';
+                    break;
+                default:
+                    $audit = '<span>审核中</span>';
+                    break;
+            }
+            return $audit;
+        });
+        $grid->column('categoryScale.demand', '公司规模');
+        $grid->column('categoryTrade.demand', '所属行业');
+        $grid->column('categoryEducation.demand', '职位要求');
+        $grid->column('categoryWage.demand', '薪资待遇');
+        $grid->created_at('添加时间')->sortable();
+        $grid->updated_at('更新时间')->sortable();
+        $grid->disableCreateButton();
+        $grid->disableExport();
+        $grid->actions(function ($actions) {
+            $actions->disableView();
+            $actions->disableEdit();
+        });
+
+        $grid->tools(function ($tools) {
+            $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="Apply" title="投递">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">投递
+    </label>
+</div>
+EOT;
+            $tools->append($but);
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Jobs::findOrFail($id));
+        $show->id('ID');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new Jobs);
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new Jobs);
+        return $form;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param int $id
+     *
+     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    protected function form()
+    {
+        $form = new Form(new Jobs);
+
+        $form->display('ID');
+        $form->display('添加时间');
+        $form->display('更新时间');
+
+        return $form;
+    }
+}

+ 317 - 0
app/Admin/Controllers/HomeController.php

@@ -0,0 +1,317 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Http\Controllers\Controller;
+use App\Models\Admin\AdminRole;
+use App\Models\Appeal;
+use App\Models\Category;
+use App\Models\PersonalJobsApply;
+use App\Models\RefreshLog;
+use App\Repositories\AppealRepository;
+use App\Repositories\CompanyImgRepository;
+use App\Repositories\CompanyRepository;
+use App\Repositories\FeedbackRepository;
+use App\Repositories\Jobfair\JobfairCompanyRepository;
+use App\Repositories\Jobfair\JobfairJobRepository;
+use App\Repositories\Jobfairout\JobfairoutCompanyRepository;
+use App\Repositories\JobsRepository;
+use App\Repositories\MemberInfoRepository;
+use App\Repositories\MemberRepository;
+use App\Repositories\ReportRepository;
+use App\Repositories\ResumeImgRepository;
+use App\Repositories\ResumeRepository;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Layout\Content;
+use Illuminate\Support\Facades\DB;
+
+class HomeController extends Controller
+{
+
+    protected $where = [];
+
+    public function __construct()
+    {
+        if (get_subsite_id()!=0) {
+            $this->where[] = array('subsite_id','=',get_subsite_id());
+        }
+    }
+
+    public function index(
+        Content $content,
+        CompanyRepository $companyRepository,
+        MemberRepository $memberRepository,
+        JobsRepository $jobsRepository,
+        ResumeRepository $resumeRepository,
+        ResumeImgRepository $resumeImgRepository,
+        FeedbackRepository $feedbackRepository,
+        ReportRepository $reportRepository
+    ) {
+        return $content
+            ->header('首页')
+            ->description('统计列表')
+            ->body(view('admin.home.index')->with([
+                'company'=>$this->company($companyRepository, $this->where),
+                'person'=>$this->person($memberRepository, $this->where),
+                'jobs'=>$this->jobs($jobsRepository, $this->where),
+                'resume'=>$this->resume($resumeRepository, $this->where),
+                'needAuthCompany'=>$this->needAuthCompany($companyRepository, $this->where),
+                'needAuditJobs'=>$this->needAuditJobs($jobsRepository, $this->where),
+                'needAuditResume'=>$this->needAuditResume($resumeRepository, $this->where),
+                'needAuditResumeImg'=>$this->needAuditResumeImg($resumeImgRepository, $this->where),
+                'suggestion'=>$this->suggestion($feedbackRepository, $this->where),
+                'report'=>$this->report($reportRepository, $this->where),
+            ]));
+    }
+
+
+    protected function company($companyRepository, $where)
+    {
+        return (object)['getCompanyCount'=>$companyRepository->getCompanyCount($where),'getLastCompanyCount'=>$companyRepository->getLastCompanyCount($where),'getNextCompanyCount'=>$companyRepository->getNextCompanyCount($where)];
+    }
+
+    protected function person($memberRepository, $where)
+    {
+        return (object)['getPersonCount'=>$memberRepository->getPersonCount($where),'getLastPersonCount'=>$memberRepository->getLastPersonCount($where),'getNextPersonCount'=>$memberRepository->getNextPersonCount($where)];
+    }
+
+    protected function jobs($jobsRepository, $where)
+    {
+        return (object)['getJobCount'=>$jobsRepository->getJobCount($where),'getLastJobsCount'=>$jobsRepository->getLastJobsCount($where),'getNextJobsCount'=>$jobsRepository->getNextJobsCount($where)];
+    }
+
+    protected function resume($resumeRepository, $where)
+    {
+        return (object)['getResumesCount'=>$resumeRepository->getResumesCount($where),'getLastResumeCount'=>$resumeRepository->getLastResumeCount($where),'getNextResumeCount'=>$resumeRepository->getNextResumeCount($where)];
+    }
+
+    protected function needAuthCompany($companyRepository, $where)
+    {
+        $where[] = ['audit','=',2];
+        return (object)['getAuditCount'=>$companyRepository->getAuditCount($where)];
+    }
+
+    protected function needAuditJobs($jobsRepository, $where)
+    {
+        $where[] = ['audit','=',2];
+        return (object)['getJobsCount'=>$jobsRepository->getJobCount($where)];
+    }
+
+    protected function needAuditResume($resumeRepository, $where)
+    {
+        $where[] = ['audit','=',1];
+        return (object)['getAuditCount'=>$resumeRepository->getAuditCount($where)];
+    }
+
+    protected function needAuditResumeImg($resumeImgRepository, $subsite_id)
+    {
+        $where[] = ['audit','=',1];
+        return (object)['getAuditCount'=>$resumeImgRepository->getAuditCount($where, $subsite_id)];
+    }
+
+    protected function suggestion($feedbackRepository, $where)
+    {
+        $where[] = array('audit','=',0);
+        return (object)['getCount'=>$feedbackRepository->getCount($where)];
+    }
+
+    protected function report($reportRepository, $where)
+    {
+        $where[] = array('audit','=',1);
+        return (object)['getCount'=>$reportRepository->getCount($where)];
+    }
+
+    protected function appeal($appealRepository, $where)
+    {
+        $where[] = array('status','=',0);
+        return (object)['getCount'=>$appealRepository->getCount($where)];
+    }
+
+    protected function jobfairJobs($jobfairJobRepository)
+    {
+        $where[] = array('audit','=',2);
+        $where[] = array('type','=',1);
+        return (object)['getCount'=>$jobfairJobRepository->getCount($where)];
+    }
+
+    protected function jobfairCompany($jobfairCompanyRepository, $subsite_id)
+    {
+        $where[] = array('audit','=',2);
+        return (object)['getCount'=>$jobfairCompanyRepository->getCount($where, $subsite_id)];
+    }
+
+    protected function jobfairoutJobs($jobfairJobRepository)
+    {
+        $where[] = array('audit','=',2);
+        $where[] = array('type','=',2);
+        return (object)['getCount'=>$jobfairJobRepository->getCount($where)];
+    }
+
+    protected function jobfairoutCompany($jobfairoutCompanyRepository, $subsite_id)
+    {
+        $where[] = array('audit','=',2);
+        return (object)['getCount'=>$jobfairoutCompanyRepository->getCount($where, $subsite_id)];
+    }
+
+    protected function companyImg($companyImgRepository, $subsite_id)
+    {
+        return (object)['getCount'=>$companyImgRepository->getCount($subsite_id, [0,2])];
+    }
+
+    protected function memberInfo($memberInfoRepository, $subsite_id)
+    {
+        $where[] = array('photo','=',1);
+        $where[] = array('photo_audit','=',1);
+        return (object)['getCount'=>$memberInfoRepository->getCount($where, $subsite_id)];
+    }
+
+    protected function register($table, $where)
+    {
+        $result = [];
+        $dayArr = getLastDates(30);
+        $sql = "deleted_at is null";
+        if ($where) {
+            $whereSubsite = $where[0][2] ? $where[0][2] : 0;
+            $sql.=" and subsite_id=".$whereSubsite;
+        }
+        $realArr = DB::select("select DATE_FORMAT(created_at,'%Y-%m-%d') as days,count(*) as count FROM ".$table." WHERE ".$sql." and created_at >= '".date('Y-m-d H:i:s', strtotime('-30 days'))."' AND created_at <= '".date('Y-m-d H:i:s')."' GROUP BY days");
+        foreach ($dayArr as $key => $val) {
+            if (in_array($val, array_column($realArr, 'days'))) {
+                foreach ($realArr as $key1 => $val1) {
+                    if ($val==$val1->days) {
+                        $result[] = [$val, $val1->count];
+                        break;
+                    }
+                }
+            } else {
+                $result[] = [$val, 0];
+            }
+        }
+        return $result;
+    }
+
+
+    protected function companyType($where)
+    {
+        $sql = "deleted_at is null";
+        if ($where) {
+            $whereSubsite = $where[0][2] ? $where[0][2] : 0;
+            $sql.=" and subsite_id=".$whereSubsite;
+        }
+        $result = [];
+        $category =  Category::where('alias', 'AIX_company_type')->select(['id', 'demand'])->get()->toArray();
+        $category_name = array_column($category, 'demand');
+        $company = DB::select("select nature,count(*) as count from companys WHERE ".$sql." group by nature");
+        foreach ($category as $key => $val) {
+            if (in_array($val['id'], array_column($company, 'nature'))) {
+                foreach ($company as $key1 => $val1) {
+                    if ($val['id']==$val1->nature) {
+                        $result[] = ['value'=>$val1->count, 'name'=>$val['demand']];
+                        break;
+                    }
+                }
+            } else {
+                $result[] = ['value'=>0, 'name'=>$val['demand']];
+            }
+        }
+        return ['category_name'=>$category_name,'result'=>$result];
+    }
+
+    protected function userAction()
+    {
+        $result = [];
+        $dayArr = getLastDates(14);
+        $jobsRefresh = RefreshLog::when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('companys', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->where('utype', 1)->where('type', 1006)->where('created_at', '>=', date('Y-m-d H:i:s', strtotime('-14 days')))->where('created_at', '<=', date('Y-m-d H:i:s'))->selectRaw('DATE_FORMAT(created_at,\'%Y-%m-%d\') as days,count(*) as count')->groupBy('days')->get()->toArray();
+        $jobsApply = PersonalJobsApply::when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('resumes', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->where('created_at', '>=', date('Y-m-d H:i:s', strtotime('-14 days')))->where('created_at', '<=', date('Y-m-d H:i:s'))->selectRaw('DATE_FORMAT(created_at,\'%Y-%m-%d\') as days,count(*) as count')->groupBy('days')->get()->toArray();
+        $newArray = ['jobsRefresh'=>$jobsRefresh,'jobsApply'=>$jobsApply];
+        foreach ($dayArr as $key => $val) {
+            foreach ($newArray as $key2 => $val2) {
+                if (in_array($val, array_column($val2, 'days'))) {
+                    foreach ($val2 as $key1 => $val1) {
+                        if ($val==$val1['days']) {
+                            $result[$key2][] = $val1['count'];
+                            break;
+                        }
+                    }
+                } else {
+                    $result[$key2][] = 0;
+                }
+            }
+        }
+        return ['day'=>$dayArr, 'userAction'=>$result];
+    }
+
+    public function ajax()
+    {
+        $where = $this->where;
+        $member = $this->register('members', $where);
+        $company = $this->register('companys', $where);
+        $companyType = $this->companyType($where);
+        $userAction = $this->userAction();
+        return response()->json(['member'=>$member,'company'=>$company,'companyType'=>$companyType,'userAction'=>$userAction]);
+    }
+
+    public function menuMessage(
+        CompanyRepository $companyRepository,
+        JobsRepository $jobsRepository,
+        CompanyImgRepository $companyImgRepository,
+        ResumeRepository $resumeRepository,
+        ResumeImgRepository $resumeImgRepository,
+        MemberInfoRepository $memberInfoRepository,
+        FeedbackRepository $feedbackRepository,
+        ReportRepository $reportRepository,
+        AppealRepository $appealRepository,
+        JobfairJobRepository $jobfairJobRepository,
+        JobfairCompanyRepository $jobfairCompanyRepository,
+        JobfairoutCompanyRepository $jobfairoutCompanyRepository
+    ) {
+        if (Admin::user()->isRole(AdminRole::$consultantSlug)) {
+            return response()->json([]);
+        }
+        $needAuthCompany = $this->needAuthCompany($companyRepository, $this->where)->getAuditCount;
+        $needAuditJobs = $this->needAuditJobs($jobsRepository, $this->where)->getJobsCount;
+        $companyImg =$this->companyImg($companyImgRepository, $this->where)->getCount;
+        $needAuditResume = $this->needAuditResume($resumeRepository, $this->where)->getAuditCount;
+        $needAuditResumeImg = $this->needAuditResumeImg($resumeImgRepository, $this->where)->getAuditCount;
+        $memberInfo = $this->memberInfo($memberInfoRepository, $this->where)->getCount;
+        $suggestion = $this->suggestion($feedbackRepository, $this->where)->getCount;
+        $report = $this->report($reportRepository, $this->where)->getCount;
+        $appeal = $this->appeal($appealRepository, $this->where)->getCount;
+
+        $jobfairJobs = $this->jobfairJobs($jobfairJobRepository)->getCount;
+        $jobfairCompany = $this->jobfairCompany($jobfairCompanyRepository, $this->where)->getCount;
+
+        $jobfairoutJobs = $this->jobfairoutJobs($jobfairJobRepository)->getCount;
+        $jobfairoutCompany = $this->jobfairoutCompany($jobfairoutCompanyRepository, $this->where)->getCount;
+        return response()->json([
+            ["id"=>13,"num"=>$needAuthCompany+$needAuditJobs+$companyImg, "has_child"=>true],
+            ["id"=>14,"num"=>$needAuthCompany, "has_child"=>false],
+            ["id"=>31,"num"=>$needAuditJobs, "has_child"=>false],
+            ["id"=>41,"num"=>$companyImg, "has_child"=>false],
+            ["id"=>110,"num"=>$needAuditResume+$needAuditResumeImg+$memberInfo, "has_child"=>true],
+            ["id"=>111,"num"=>$needAuditResume, "has_child"=>false],
+            ["id"=>112,"num"=>$needAuditResumeImg, "has_child"=>false],
+            ["id"=>113,"num"=>$memberInfo, "has_child"=>false],
+            ["id"=>19,"num"=>$suggestion+$report+$appeal, "has_child"=>true],
+            ["id"=>106,"num"=>$suggestion, "has_child"=>false],
+            ["id"=>47,"num"=>$report, "has_child"=>false],
+            ["id"=>50,"num"=>$appeal, "has_child"=>false],
+            ["id"=>145,"num"=>$jobfairJobs+$jobfairCompany, "has_child"=>true],
+            ["id"=>149,"num"=>$jobfairJobs, "has_child"=>false],
+            ["id"=>151,"num"=>$jobfairCompany, "has_child"=>false],
+            ["id"=>175,"num"=>$jobfairoutJobs+$jobfairoutCompany, "has_child"=>true],
+            ["id"=>177,"num"=>$jobfairoutJobs, "has_child"=>false],
+            ["id"=>179,"num"=>$jobfairoutCompany, "has_child"=>false],
+        ]);
+    }
+
+
+}

+ 215 - 0
app/Admin/Controllers/Jobfair/FloorplanController.php

@@ -0,0 +1,215 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\Jobfair\Floorplan;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+
+class FloorplanController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('展位图列表')
+            ->description('')
+            ->body(view('admin.jobfair.floorplan_index')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('展位图详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('展位图编辑')
+            ->description('')
+            ->body(view('admin.jobfair.floorplan')->with(['content'=>$this->formEdit($id)]));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('创建展位图')
+            ->description('')
+            ->body(view('admin.jobfair.floorplan'));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Floorplan);
+        $grid->model()->orderBy('id', 'desc');
+        $grid->name('展位名称')->width(200);
+        $grid->images('展位平面图')->image('', 100, 70);
+        $grid->created_at('创建时间');
+        $grid->updated_at('更新时间');
+        $grid->disableExport();
+        $grid->actions(function ($actions) use ($grid) {
+
+            if (Admin::user()->can('jobfair_floorplans_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('jobfair_floorplans_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('jobfair_floorplans_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+
+        $grid->filter(function ($filter) {
+            $filter->like('name', '展位名称');
+        });
+        if (Admin::user()->can('jobfair_floorplans_create')) {
+            $grid->disableCreateButton(false);
+        }
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Floorplan::findOrFail($id));
+
+        $show->id('ID');
+        $show->name('展位名称');
+        $show->images('展位平面图')->image('', 100, 70);
+
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+
+    public function formEdit($id)
+    {
+        return Floorplan::findOrFail($id);
+    }
+
+
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Floorplan);
+
+        $form->display('ID');
+        $form->display('创建时间');
+        $form->display('更新时间');
+
+        return $form;
+    }
+
+    public function floors(Request $request)
+    {
+        $floorplan_id = $request->floorplan_id;
+        if (!$request->imgName) {
+            admin_toastr('展位名称不能为空!', 'error');
+            return back();
+        }
+        $floor_position = json_decode($request->floor_position,true);
+        $new_equipment_array = array_column($floor_position,'equipment_id');
+        $floor = Floorplan::pluck('value')->toArray();
+        $old_equipment_array = [];
+        foreach ($floor as $value)
+        {
+            $floor_arr = json_decode($value,true);
+            foreach ($floor_arr as $val) {
+                $old_equipment_array[] = $val['equipment_id'];
+            }
+        }
+        $old_equipment_array = array_unique($old_equipment_array);
+        foreach ($new_equipment_array as $equipment_id)
+        {
+            if(in_array($equipment_id,$old_equipment_array)){
+                admin_toastr('设备ID '. $equipment_id .' 已存在!', 'error');
+                return back();
+            }
+        }
+        if ($floorplan_id) {
+            $Floorplan = Floorplan::findOrFail($floorplan_id);
+            $Floorplan->name = $request->imgName;
+            if ($request->has('uploadImg')) {
+                $Floorplan->images = $request->file('uploadImg')->store('admin/jobfair/images', 'public');
+            }
+            $Floorplan->value = $request->floor_position;
+        } else {
+            if (!$request->has('uploadImg')) {
+                admin_toastr('展位图不存在!', 'error');
+                return back();
+            }
+            $Floorplan = new Floorplan();
+            $Floorplan->name = $request->imgName;
+            $Floorplan->images = $request->file('uploadImg')->store('admin/jobfair/images', 'public');
+            $Floorplan->value = $request->floor_position;
+        }
+        if ($Floorplan->save()) {
+            admin_toastr('操作成功', 'success');
+        } else {
+            admin_toastr('操作失败', 'error');
+        }
+        return redirect(route('floorplans.index'));
+    }
+}

+ 329 - 0
app/Admin/Controllers/Jobfair/JobfairBlacklistController.php

@@ -0,0 +1,329 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\Company;
+use App\Models\Jobfair\JobfairBlacklist;
+use App\Models\Jobfair\JobfairCompany;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+
+class JobfairBlacklistController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('黑名单列表')
+            ->description('')
+            ->body(view('admin.jobfair.jobfair_blacklist')->with(['content'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('黑名单详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('黑名单编辑')
+            ->description('')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('黑名单创建')
+            ->description('')
+            ->body(view('admin.jobfair.jobfair_blacklist_add')->with(['content'=>$this->createForm()]));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairBlacklist);
+        $grid->model()->whereHas('companys');
+
+        $grid->column('companys.companyname', '公司名称')->width(200);
+        $grid->status('状态')->display(function ($status) {
+            if ($status==1) {
+                 return '<span style="color:#FF6600;">等待解除</span>';
+            } else {
+                 return '<span style="color: #009900;">已解除</span>';
+            }
+        });
+        $grid->type('类型')->display(function ($type) {
+            if ($type==1) {
+                return '系统拉黑';
+            } else {
+                return '手动拉黑';
+            }
+        });
+        $grid->details('备注');
+        $grid->add_time('拉黑时间')->display(function ($add_time) {
+            return $add_time ? date('Y-m-d H:i:s', $add_time) : '';
+        });
+        $grid->remove_time('解除时间')->display(function ($remove_time) {
+            return $remove_time ? date('Y-m-d H:i:s', $remove_time) : '';
+        });
+        $grid->operator('操作人');
+        $grid->disableExport();
+        $grid->actions(function ($actions) {
+
+            if (Admin::user()->can('jobfair_blacklist_unsealing')) {
+                if ($actions->row['status']==1) {
+                    $name = '解封';
+                    $status = 2;
+                    $actions->append('<button class="btn btn-primary btn-xs business blackList" ls="'.$status.'" ld="'.$actions->row['id'].'" title="'.$name.'" >'.$name.'</button>');
+                }
+            }
+        });
+        $grid->tools(function ($tools) use ($grid) {
+            if (Admin::user()->can('jobfair_blacklist_unsealing')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="Audit" title="批量解封">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">批量解封
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+        if (Admin::user()->can('jobfair_blacklist_unsealing')) {
+            $grid->disableRowSelector(false);
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->like('companys.companyname', '公司名称');
+            $filter->equal('status', '状态')->select([
+                1  => '等待解除',
+                2  => '已解除',
+            ]);
+            $filter->equal('type', '类型')->select([
+                1  => '系统拉黑',
+                2  => '手动拉黑',
+            ]);
+        });
+
+        if (Admin::user()->can('jobfair_blacklist_create')) {
+            $grid->disableCreateButton(false);
+        }
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairBlacklist::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->companys()->companyname('公司名称')->as(function ($companys){
+            return $companys->companyname;
+        });
+
+
+        $show->status('状态')->as(function ($status) {
+            if ($status==1) {
+                return '等待解除';
+            } else {
+                return '已解除';
+            }
+        });
+        $show->type('类型')->as(function ($type) {
+            if ($type==1) {
+                return '系统拉黑';
+            } else {
+                return '手动拉黑';
+            }
+        });
+        $show->details('备注');
+        $show->add_time('拉黑时间')->as(function ($add_time) {
+            return $add_time ? date('Y-m-d H:i:s', $add_time) : '';
+        });
+        $show->remove_time('解除时间')->as(function ($remove_time) {
+            return $remove_time ? date('Y-m-d H:i:s', $remove_time) : '';
+        });
+        $show->operator('操作人');
+
+
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new JobfairBlacklist);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new \Encore\Admin\Widgets\Form();//表单使用admin提供的表单
+        $form->action(route('blacklist.add'));
+        $JobfairCompany = JobfairCompany::select('company_id')->groupBy('company_id')->get()->toArray();
+        $companyArr = array_column($JobfairCompany, 'company_id');
+        $Company = Company::whereIn('id', $companyArr)->select('id', 'companyname')->get()->toArray();
+        $needAyy = array_column($Company, 'companyname', 'id');
+        $form->select('company_id', '企业名称')->options($needAyy)->rules([
+            'required',
+        ])->setMustMark();;
+        $form->textarea('details', '备注')->rules([
+            'required',
+        ])->setMustMark();;
+        $form->disableReset();
+        return $form->render();
+    }
+
+    public function blacklistAdd(Request $request)
+    {
+        $request->validate([
+            'company_id' => 'required',
+            'details' => 'required',
+        ]);
+        $company_id = $request->company_id;
+        $details = $request->details;
+        $JobfairBlacklist = JobfairBlacklist::where(['company_id'=>$company_id])->first();
+        if ($JobfairBlacklist) {
+            $blackCompany = JobfairBlacklist::where(['company_id'=>$company_id,'remove_time'=>0,'status'=>1])->first();
+            if ($blackCompany) {
+                admin_toastr('该参会企业已在黑名单之列!', 'error');
+                return back();
+            }
+            $result = JobfairBlacklist::where(['company_id'=>$company_id])->update(
+                ['remove_time'=>0,'status'=>1,'operator'=>admin::user()->username,'details'=>$details]
+            );
+        } else {
+            $result = JobfairBlacklist::create(
+                ['company_id'=>$company_id,'type'=>2,'details'=>$details,'add_time'=>time(),'operator'=>admin::user()->username]
+            );
+        }
+        if ($result) {
+            admin_toastr('操作成功!!', 'success');
+            return redirect(route('blacklist.index'));
+        } else {
+            admin_toastr('操作失败!', 'error');
+            return back();
+        }
+    }
+
+    public function blacklistDelete(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('blacklist.deleted'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->textarea('details', '备注');
+        return json_encode(['html'=>$form->render(),'detail'=>'参会企业解封']);
+    }
+
+    public function blacklistD(Request $request)
+    {
+        $blackArr = [];
+        $company_id = [];
+        $id = $request->id;
+        $details = $request->details;
+        $arr = array_filter(explode(',', $id));
+        if (empty($id)) {
+            admin_toastr('数据异常!', 'error');
+            return back();
+        }
+        if (empty($details)) {
+            admin_toastr('请填写备注!', 'error');
+            return back();
+        }
+        $JobfairBlacklist = JobfairBlacklist::whereIn('id', $arr)->get();
+        if ($JobfairBlacklist->isEmpty()) {
+            admin_toastr('数据异常!', 'error');
+            return back();
+        } else {
+            foreach ($JobfairBlacklist as $key => $val) {
+                if ($val->remove_time==0&&$val->status==1) {
+                    $blackArr[] = $val->id;
+                    $company_id[]=$val->company_id;
+                }
+            }
+        }
+        \DB::beginTransaction();
+        try {
+            JobfairBlacklist::whereIn('id', $blackArr)
+            ->update(['details'=>$details, 'remove_time'=>time(), 'operator'=>admin::user()->username, 'status'=>2]);
+            if ($company_id) {
+                JobfairCompany::whereIn('company_id', $company_id)
+                ->where('created_at', '<', date('Y-m-d H:i:s', time()))->update(['black_status'=>1]);
+            }
+            \DB::commit();
+            admin_toastr('操作成功!!', 'success');
+            return redirect(route('blacklist.index'));
+        } catch (\Exception $e) {
+            \DB::rollback();
+            admin_toastr('操作失败!', 'error');
+            return back();
+        }
+    }
+
+
+}

+ 810 - 0
app/Admin/Controllers/Jobfair/JobfairCompanyController.php

@@ -0,0 +1,810 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\Company;
+use App\Models\Jobfair\FloorplanStand;
+use App\Models\Jobfair\Jobfair;
+use App\Models\Jobfair\JobfairCompany;
+use App\Models\Jobfair\JobfairFloorplan;
+use App\Models\Jobfair\JobfairPutJob;
+use App\Models\MembersHandsel;
+use App\Models\MembersPoint;
+use App\Models\MembersSetmeal;
+use App\Models\Pms;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use App\Admin\Exports\Jobfair\CompanyExport;
+use App\Services\Common\SmsService;
+use Aix\Sms\Contracts\Smser;
+use App\Services\Common\EmailService;
+class JobfairCompanyController extends Controller
+{
+    use HasResourceActions;
+    protected $smsService;
+    protected $emailService;
+
+    public function __construct(SmsService $smsService,EmailService $emailService)
+    {
+        $this->smsService = $smsService;
+        $this->emailService = $emailService;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content,Request $request)
+    {
+        $is_export = $request->has('_export_');
+        $jobfair_id = isset($request['jobfair_companys']['jobfair_id']) ? $request['jobfair_companys']['jobfair_id'] : false;
+        $jobfair_id1 = isset($request->jobfair_id) ? $request->jobfair_id : false;
+        $grid=$this->grid($jobfair_id,$jobfair_id1,$is_export)->render();
+        return $content
+            ->header('参会企业')
+            ->description('')
+            ->body(view('admin.jobfair.jobfair_company')->with(['grid'=>$grid]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('参会企业详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content, Request $request)
+    {
+        return $content
+            ->header('参会企业编辑')
+            ->description('')
+            ->body($this->editForm($request, $id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('参会企业创建')
+            ->description('')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid($jobfair_id,$jobfair_id1,$is_export)
+    {
+        $grid = new Grid(new JobfairCompany);
+        if($is_export){
+            $grid->model()->when(get_subsite_id()>0, function ($query) {
+                $query->whereHas('jobfair', function ($query) {
+                    $query->where('subsite_id', get_subsite_id());
+                });
+            })->orderByRaw("FIELD(audit, 2,1,3)")->orderBy('updated_at', 'desc');
+        }elseif($jobfair_id || $jobfair_id1){
+            $grid->model()->joinFloorplanStand()->when(get_subsite_id()>0, function ($query) {
+                $query->whereHas('jobfair', function ($query) {
+                    $query->where('subsite_id', get_subsite_id());
+                });
+            })->when($jobfair_id1==true && $jobfair_id==false,function ($query) use ($jobfair_id1){
+                $query->where('jobfair_companys.jobfair_id',$jobfair_id1);
+            })
+                ->select('jobfair_companys.*','jobfair_floorplan_stands.sortindex')
+                ->orderBy("jobfair_floorplan_stands.sortindex");
+        }else{
+            $grid->model()->when(get_subsite_id()>0, function ($query) {
+                $query->whereHas('jobfair', function ($query) {
+                    $query->where('subsite_id', get_subsite_id());
+                });
+            })->orderByRaw("FIELD(audit, 2,1,3)")->orderBy('updated_at', 'desc');
+        }
+
+
+        $grid->column('companys.companyname', '参会企业')->display(function ($companyname) {
+            return '<a href="'.route('jobs.company',['id'=>$this->company_id]).'" target="_blank">'.$companyname.'</a>';
+        })->width(200);
+
+        $grid->jobs_name('企业职位')->display(function () {
+            if($this->jobfairPutJob->isEmpty()){
+                return '暂无职位';
+            }else{
+                return '<a href="'.route('jobfairPutJobs.index',['jobfair_id'=>$this->jobfair_id,'company_id'=>$this->company_id]).'">点击查看</a>';
+            }
+        });
+        $grid->column('jobfair.holddate_start', '举办时间')->display(function ($holddate_start) {
+            if($holddate_start){
+                return date('Y-m-d H:i',$holddate_start);
+            }else{
+                return '';
+            }
+
+        });
+        $grid->column('jobfair.title', '招聘会标题')->display(function ($jobfair_title) {
+            return '<a href="'.route('jobfair.show.com',$this->jobfair_id).'" target="_blank">'.$jobfair_title.'</a>';
+        })->width(200);
+        $grid->type('签到状态')->display(function ($type) {
+            if ($type==0) {
+                return '<span>未签到</span>';
+            } elseif ($type==1) {
+                return '<span style="color: #FF3300">迟到</span>';
+            } elseif ($type==2) {
+                return '<span style="color: #FF3300">早退</span>';
+            } elseif ($type==3) {
+                return '<span style="color: #FF3300">迟到/早退</span>';
+            } elseif ($type==4) {
+                return ' <span style="color: #009900">已签到</span>';
+            }
+        });
+//        $grid->column('jobfairFloorPlanStands.floorplan_id', '展位图名称')->display(function ($floorplan_id) {
+//            $JobfairFloorplan = JobfairFloorplan::find($floorplan_id);
+//            return isset($JobfairFloorplan->name) ? $JobfairFloorplan->name : '未知';
+//        })->width(200);
+        $grid->column('jobfairFloorPlanStands.name', '展位号');
+        $grid->audit('预订状态')->display(function ($audit) {
+            if ($audit==1) {
+                return ' <span style="color: #009900">预定成功</span>';
+            } elseif ($audit==2) {
+                return'<span style="color:#FF6600">等待确认</span>';
+            } else {
+                return '<span style="color: #FF3300">审核未通过</span>';
+            }
+        });
+        $grid->pay_type('支付方式')->display(function ($pay_type) {
+            if ($pay_type==1) {
+                return '<span style="color: #009900">场次</span>';
+            } elseif ($pay_type==2) {
+                return '<span style="color: #009900">积分</span>';
+            } else {
+                return '<span style="color: #009900">公益</span>';
+            }
+        });
+        $grid->etype('预订方式')->display(function ($etype) {
+            if ($etype==1) {
+                return '<span style="color: #009900">在线预订</span>';
+            } elseif ($etype==2) {
+                return '<span style="color: #009900">电话预定</span>';
+            } else {
+                return '<span style="color: #009900">现场预定</span>';
+            }
+        });
+        if(get_subsite_open()){
+            $grid->column('jobfair.subsite_id', '所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            });
+        }
+
+        $grid->created_at('创建时间');
+//        $grid->disableCreateButton();
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('company_manager_bussiness')) {
+                $actions->append("<button class='btn btn-primary btn-xs business' id=".$actions->row['company_id'].">业务</button>");
+            }
+            if (Admin::user()->can('jobfair_companys_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+            if (Admin::user()->can('jobfair_companys_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('jobfair_companys_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('jobfair_companys_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+        if (Admin::user()->can('jobfair_companys_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new CompanyExport()); //传入自己在第1步创建的导出类
+        }
+
+        if (Admin::user()->can('jobfair_companys_create')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('jobfair_companys_audit')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="Audit_Companys" title="参会状态">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">审核企业
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+
+            if (Admin::user()->can('jobfair_companys_signed')) {
+                $signed = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="signed" title="签到">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">签到
+    </label>
+</div>
+EOT;
+                $tools->append($signed);
+            }
+        });
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('companys.companyname', '参会企业');
+                $filter->equal('jobfair_companys.jobfair_id', '招聘会标题')->select(Jobfair::select('title', 'id')->when(get_subsite_id()>0,function ($query){
+                    $query->whereHas('subsites', function ($query) {
+                        $query->where('subsite_jobfairs.subsite_id', get_subsite_id())->where('subsites.effective', 1);
+                    });
+                })->pluck('title', 'id')->all());
+                $filter->equal('jobfair_companys.audit', '预订状态')->select([
+                    1=>'预定成功',
+                    2=>'等待确认',
+                    3=>'审核未通过',
+                ]);
+                $filter->equal('jobfair_companys.type', '签到状态')->select([
+                    0=>'未签到',
+                    1=>'迟到',
+                    2=>'早退',
+                    3=>'迟到/早退',
+                    4=>'已签到',
+                ]);
+                if( get_subsite_id() == 0 && get_subsite_open()){
+                    $filter->equal('jobfair.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('jobfair_companys.pay_type', '支付方式')->select([
+                    1=>'场次',
+                    2=>'积分',
+                    3=>'公益',
+                ]);
+                $filter->like('jobfair_companys.position', '预定展位');
+                $filter->equal('jobfair_companys.etype', '预订方式')->select([
+                    1=>'在线预订',
+                    2=>'电话预定',
+                    3=>'现场预定'
+                ]);
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("jobfair_companys.updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("jobfair_companys.updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("jobfair_companys.updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '更新时间', 'updated_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairCompany::findOrFail($id));
+
+        $jobfairCompany = JobfairCompany::findOrFail($id);
+
+        $show->id('ID');
+
+        $show->companys()->companyname('参会企业')->as(function ($companys){
+            return $companys->companyname;
+        });
+
+        $show->jobfair()->title('招聘会标题')->as(function ($jobfair){
+            return $jobfair->title;
+        });
+
+        $show->type('签到状态')->as(function ($type) {
+            if ($type==0) {
+                return '未签到';
+            } elseif ($type==1) {
+                return '迟到';
+            } elseif ($type==2) {
+                return '早退';
+            } elseif ($type==3) {
+                return '迟到/早退';
+            } elseif ($type==4) {
+                return '已签到';
+            }
+        });
+
+        $show->position('展位号');
+
+
+        $show->audit('预订状态')->as(function ($audit) {
+            if ($audit==1) {
+                return '预定成功';
+            } elseif ($audit==2) {
+                return '等待确认';
+            } else {
+                return '审核未通过';
+            }
+        });
+        $show->pay_type('支付方式')->as(function ($pay_type) {
+            if ($pay_type==1) {
+                return '场次';
+            } elseif ($pay_type==2) {
+                return '积分';
+            } else {
+                return '公益';
+            }
+        });
+        $show->etype('预订方式')->as(function ($etype) {
+            if ($etype==1) {
+                return '在线预订';
+            } elseif ($etype==2) {
+                return '电话预定';
+            } else {
+                return '现场预定';
+            }
+        });
+
+        $show->subsite_id('所属分站')->as(function () use ($jobfairCompany) {
+            $subsite_id = Jobfair::findOrFail($jobfairCompany->jobfair_id)->subsite_id;
+            if ($subsite_id) {
+                $Subsite = Subsite::find($subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new JobfairCompany);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+
+    protected function createForm()
+    {
+        $form = new Form(new JobfairCompany);
+        $form->select('company_id', '企业名称')->options(
+            Company::where('audit', 1)->pluck('companyname', 'id')->all()
+        )->rules([
+            'required',
+        ])->setMustMark();
+        $form->select('jobfair_id', '招聘会名称')->options(
+            Jobfair::where('display', 1)->where('predetermined_status',1)->where('holddate_end', '>', time())->pluck('title', 'id')->all()
+        )->load('position', route('floorplans.floorPlans'))->rules([
+            'required',
+        ])->setMustMark();
+        $form->select('position', '展位图名称')->load('position_id',  route('floorplans.floorPlansId'))->rules([
+            'required',
+        ])->setMustMark();
+        $form->select('position_id', '展位号')->rules([
+            'required',
+        ])->setMustMark();
+        $form->select('etype', '预定方式')->options([3=>'现场预定'])->default(3)->help('现场预定不消耗场次或积分!');
+        $form->hidden('pay_type')->default(3);
+
+        $form->saving(function (Form $form){
+            $company_id = $form->company_id;
+            $Jobfair = Jobfair::findOrFail($form->jobfair_id);
+            if ($Jobfair->more_stand==0) {
+                $count = JobfairCompany::where(['company_id'=>$company_id,'jobfair_id'=>$form->jobfair_id])->count();
+                if ($count>=1) {
+                    admin_toastr('同一家企业不可预订一场招聘会多个展位!', 'error');
+                    return redirect(route('jobfair.company.create'));
+                }
+            }
+        });
+
+        $form->saved(function (Form $form) {
+            $model = $form->model();
+            $model->audit = 1;
+            $model->position = FloorplanStand::findOrFail($form->position_id)->name;
+            $model->note = '该企业现场预定展位!';
+            $model->type = 0;
+            $model->signed_time = time();
+            $model->save();
+        });
+        return $form;
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($request, $id)
+    {
+        $form = new Form(new JobfairCompany);
+        $jonfairCompany = JobfairCompany::findOrFail($id);
+        $request->session()->put('jobfair_plan_id', $jonfairCompany->jobfair_id);
+        $form->display('companys.companyname', '企业名称')->setMustMark();
+        $form->display('jobfair.title', '招聘会名称')->setMustMark();
+        $FloorplanStand = FloorplanStand::with('jobfair_floorPlan')->where('id', $jonfairCompany->position_id)->first();
+        $stand_id = isset($FloorplanStand->jobfair_floorPlan->id) ? $FloorplanStand->jobfair_floorPlan->id : '';
+        $form->select('position_floor_plans', '展位图名称')->options(JobfairFloorplan::where('jobfair_id', $jonfairCompany->jobfair_id)->pluck('name', 'id')->all())->load('position_id', route('floorplans.floorPlansId'))->default($stand_id)->rules([
+            'required',
+        ])->setMustMark();
+        $list = $this->positionColumn($jonfairCompany->jobfair_id,$stand_id);
+        $list[$jonfairCompany->position_id] = $jonfairCompany->position;
+        $form->select('position_id', '展位号')->options($list)->default($jonfairCompany->position_id)->rules([
+            'required',
+        ])->setMustMark();
+        $form->hidden('position');
+        $form->saving(function (Form $form) {
+            $form->position = FloorplanStand::findOrFail($form->position_id)->name;
+        });
+        return $form;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param int $id
+     *
+     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
+     */
+    public function update(Request $request, $id)
+    {
+        $data = $request->all();
+        unset($data['position_floor_plans']);
+        return $this->editForm($request, $id)->update($id, $data);
+    }
+
+    public function auditCompanys(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('jobfair.company.auditr'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '审核')->options([1=>'预订成功',3=>'审核未通过'])->default(1);
+        $form->textarea('note', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核企业']);
+    }
+
+    public function auditCompanysR(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $note = $request->note;
+        $pms_notice = $request->pms_notice;
+        if($audit==3){
+            if (empty($note)) {
+                admin_toastr('参会企业审核未通过必须填写备注!', 'error');
+                return back();
+            }
+        }
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('请选择参会企业', 'error');
+            return back();
+        }
+        $arr_id = [];
+        $JobfairCompany = JobfairCompany::whereHas('jobfair',function ($query){
+            $query->where('holddate_end', '>', time());
+        })->whereIn('id', $arr)->get();
+        if($JobfairCompany->isEmpty()){
+            admin_toastr('招聘会已过期', 'error');
+            return back();
+        }
+        \DB::beginTransaction();
+        try {
+            foreach ($JobfairCompany as $key => $val) {
+                if ($audit==1) { //预订成功
+                    if ($val->audit==2) {
+                        $arr_id[] = $val->id;
+                        if($val->companys->mobile && $val->companys->mobile_audit == 1){
+                            $this->smsService->sendSms(
+                                $val->companys->mobile,
+                                Smser::TEMPLATE_JOBFAIR_APPLY_OK,
+                                [
+                                    'jobfair_name'=>$val->jobfair->title,
+                                    'jobfair_time'=>date('Y-m-d H:i',$val->jobfair->holddate_start),
+                                    'jobfair_addr'=>$val->jobfair->address,
+                                    'position'=>$val->jobfairFloorPlanStands->name,
+                                ]);
+                        }
+                        if($val->companys->email && $val->companys->email_audit == 1){
+                            $this->emailService->sendMail($val->companys->email, EmailService::TEMPLATE_JOBFAIR_APPLY_OK,
+                                ['title'=>'招聘会预订成功'],
+                                [
+                                    'jobfair_name'=>$val->jobfair->title,
+                                    'jobfair_time'=>date('Y-m-d H:i',$val->jobfair->holddate_start),
+                                    'jobfair_addr'=>$val->jobfair->address,
+                                    'position'=>$val->jobfairFloorPlanStands->name,
+                                ]
+                            );
+                        }
+                    }
+                } else { //审核未通过。
+                    if ($val->audit==2 || $val->audit==1) {
+                        $arr_id[] = $val->id;
+                        if($val->companys->mobile && $val->companys->mobile_audit == 1){
+                            $this->smsService->sendSms(
+                                $val->companys->mobile,
+                                Smser::TEMPLATE_JOBFAIR_APPLY_ERROR,
+                                [
+                                    'jobfair_name'=>$val->jobfair->title
+                                ]);
+                        }
+                        if($val->companys->email && $val->companys->email_audit == 1){
+                            $this->emailService->sendMail($val->companys->email, EmailService::TEMPLATE_JOBFAIR_APPLY_ERROR, ['title'=>'招聘会预订失败'], ['jobfair_name'=>$val->jobfair->title]);
+                        }
+                    }
+
+                    if ($val->jobfair) {
+                        if ($val->pay_type==1) {//场次
+                            MembersSetmeal::where('uid', $val->company_id)->where('utype', 1)
+                                ->increment('jobfair_num', $val->jobfair->jobsfair_num);
+                        }elseif ($val->pay_type==2) { //积分
+                            MembersPoint::where('uid', $val->company_id)->where('utype', 1)
+                                ->increment('points', $val->jobfair->predetermined_point);
+                            MembersHandsel::create([
+                                'uid'=>$val->company_id,
+                                'utype'=>1,
+                                'htype_cn'=>'返还预定招聘会的积分',
+                                'operate'=>1,
+                                'points'=>$val->jobfair->predetermined_point
+                            ]);
+                        }
+                    }
+                }
+            }
+
+            if ($arr_id) {
+                $newReult = JobfairCompany::with(['jobfair', 'companys'])->whereHas('jobfair')
+                    ->whereHas('companys')->whereIn('id', $arr_id)->get();
+                foreach ($newReult as $key => $val) {
+                    if ($val->jobfair && $val->companys) {
+                        $newDate[$key]['utype'] = $val->companys->utype;
+                        $newDate[$key]['msgtype'] = 2;
+                        $newDate[$key]['msgfromuid'] = 0;
+                        $newDate[$key]['msgfrom'] = 'admin';
+                        $newDate[$key]['msgtoname'] = $val->companys->username;
+                        $newDate[$key]['msgtouid'] = $val->companys->id;
+                        $title = strstr($val->jobfair->title, '招聘会') ? $val->jobfair->title : $val->jobfair->title . '招聘会';
+                        if ($audit == 1) {
+                            $newDate[$key]['message'] = '您申请的<a href="' . route('jobfair.show', $val->jobfair->id) . '">' . $title . '</a>' . $val->position . '展位已审核通过,请尽快提交招聘会职位。';
+                        } else {
+                            $newDate[$key]['message'] = '您申请的<a href="' . route('jobfair.show', $val->jobfair->id) . '">' . $title . '</a>' . $val->position . '展位已审核失败,请尽快查收。失败原因(' . $note . ')';
+                        }
+                        $newDate[$key]['created_at'] = date('Y-m-d H:i:s');
+                        $newDate[$key]['updated_at'] = date('Y-m-d H:i:s');
+                    }
+                }
+                if ($pms_notice && $newDate) {
+                    Pms::insert($newDate);
+                }
+                JobfairCompany::whereIn('id', $arr_id)->update(['audit' => $audit, 'note' => $note]);
+            } else {
+                admin_toastr('操作失败', 'error');
+                return back();
+            }
+
+            \DB::commit();
+            admin_toastr('操作成功', 'success');
+        } catch (\Exception $e) {
+            \DB::rollback();
+            admin_toastr('操作失败', $e->getMessage());
+        }
+        return back();
+    }
+
+
+    public function signedCompanys(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($id)) {
+            return response()->json(['code'=>0,'info'=>'数据异常!']);
+        }
+        if (empty($arr)) {
+            return response()->json(['code'=>0,'info'=>'请选择参会企业!']);
+        }
+        $need_id_n = [];
+        $need_id_p = [];
+        $JobfairCompany = JobfairCompany::with(['jobfair'=>function ($query) {
+            $query->where('holddate_start', '<=', time()+7200)->where('holddate_end', '>=', time())->orWhere('holddate_start', '<=', time());
+        }])->whereIn('id', $arr)->where('type', 0)->get();
+        foreach ($JobfairCompany as $key => $val) {
+            if ($val->jobfair) {
+                if (time()>=$val->jobfair->holddate_start && time()<=$val->jobfair->holddate_end) {
+                    $need_id_n[] = $val->id;
+                } else {
+                    if (time()<$val->jobfair->holddate_start) {
+                        if (($val->jobfair->holddate_start-time())<7200) {
+                            $need_id_p[] = $val->id;
+                        }
+                    }
+                }
+            }
+        }
+        if (!$need_id_n&&!$need_id_p) {
+            return response()->json(['code'=>0,'info'=>'该企业已签到过或招聘会已结束或签到时间不在招聘会开始时间2小时之内!']);
+        }
+        \DB::beginTransaction();
+        try {
+            if ($need_id_n) {
+                JobfairCompany::whereIn('id', $need_id_n)->update(['type'=>1,'signed_time'=>time()]);
+            }
+            if ($need_id_p) {
+                JobfairCompany::whereIn('id', $need_id_p)->update(['type'=>4,'signed_time'=>time()]);
+            }
+            \DB::commit();
+            return response()->json(['code'=>1,'info'=>'签到成功!']);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            return response()->json(['code'=>0,'info'=>'签到失败!']);
+        }
+    }
+
+    public function floorPlans(Request $request)
+    {
+        $jobfair_id = $request->get('q');
+        $request->session()->put('jobfair_plan_id', $jobfair_id);
+        return JobfairFloorplan::where('jobfair_id', $jobfair_id)->get(['id','name as text']);
+    }
+
+    public function floorPlansId(Request $request)
+    {
+        $jobfair_id = $request->session()->get('jobfair_plan_id', '');
+        $floor_plan_id = $request->get('q');
+        if ($jobfair_id) {
+            $standFreeList = $this->lastJobfairPosition($jobfair_id, $floor_plan_id);
+            return FloorplanStand::whereIN('id', $standFreeList)->get(['id','name as text']);
+        }
+        return [];
+    }
+
+    protected function lastJobfairPosition($jobfair_id, $floor_plan_id)
+    {
+        $standAudit = 0;
+        $standAuditList = [];
+        $standSuccess = 0;
+        $standSuccessList = [];
+        $standLock = 0;
+        $standLockList = [];
+        $standFreeList = [];
+        $standNum = 0;
+        $FloorplanStand = FloorplanStand::where('jobfair_id', $jobfair_id)->where('floorplan_id', $floor_plan_id)->get();
+        $JobfairCompany = JobfairCompany::where('jobfair_id', $jobfair_id)->whereIn('audit', [1,2])->get();
+        if (!$FloorplanStand->isEmpty()) {
+            foreach ($FloorplanStand as $key => $val) {
+                $standFreeList[]=$val->id;
+//                if ($val->type==2) {
+//                    $standLock++;
+//                    $standLockList[]=$val->id;
+//                }
+//                if ($val->type==1) {
+//                    $standFreeList[]=$val->id;
+//                }
+                $standNum++;
+            }
+        }
+        if (!$JobfairCompany->isEmpty()) {
+            foreach ($JobfairCompany as $key => $val) {
+                if ($val->audit==1) {
+                    $standSuccess++;
+                    $standSuccessList[]=$val->position_id;
+                } elseif ($val->audit==2) {
+                    $standAudit++;
+                    $standAuditList[]=$val->position_id;
+                }
+            }
+        }
+        return array_diff($standFreeList, array_unique(array_merge($standSuccessList, $standAuditList)));
+    }
+
+    public function positionColumn($jobfair_id, $floor_plan_id)
+    {
+        $standFreeList = $this->lastJobfairPosition($jobfair_id, $floor_plan_id);
+        return FloorplanStand::whereIN('id', $standFreeList)->pluck('name as text','id')->toArray();
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的参展职位', 'error');
+        }
+
+        \DB::beginTransaction();
+        try {
+            JobfairCompany::whereIn('id', $ids)->delete();
+            JobfairPutJob::whereIn('exid', $ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 1110 - 0
app/Admin/Controllers/Jobfair/JobfairController.php

@@ -0,0 +1,1110 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Http\Controllers\Statistics\CompanyController;
+use App\Models\Company;
+use App\Models\Jobfair\Floorplan;
+use App\Models\Jobfair\FloorplanStand;
+use App\Models\Jobfair\Jobfair;
+use App\Models\Jobfair\JobfairCompany;
+use App\Models\Jobfair\JobfairFloorplan;
+use App\Models\Jobfair\JobfairManagement;
+use App\Models\Jobfair\JobfairPersonSigned;
+use App\Models\MemberInfo;
+use App\Models\Subsite;
+use App\Models\SubsiteJobfair;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Cache;
+use App\Models\Jobfair\JobfairPutJob;
+use App\Admin\Exports\Jobfair\HaibaoExport;
+use App\Admin\Exports\Jobfair\QiandaoExport;
+use Illuminate\Support\Collection;
+class JobfairController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('招聘会列表')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('招聘会详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('招聘会编辑')
+            ->description('')
+            ->body(view('admin.jobfair.jobfair')->with(['content'=>$this->editForm($id)])->render());
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('招聘会创建')
+            ->description('带*号必填项')
+            ->body(view('admin.jobfair.jobfair')->with(['content'=>$this->createForm()])->render());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Jobfair);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id',get_subsite_id());
+        })->orderBy('id', 'desc');
+
+
+        $grid->holddate_start('举办时间')->display(function ($holddate_start) {
+            return "<span style='color:#009900'>".date('Y-m-d H:i', $holddate_start)."&nbsp;至&nbsp;".date('Y-m-d H:i', $this->holddate_end)."</span>";
+        });
+        $grid->title('招聘会标题')->display(function ($title) {
+            return '<a href="'.route('jobfair.show.com',$this->id).'" target="_blank">'.$title.'</a>';
+        })->width(300);
+
+        $grid->jobfair_type('招聘会类型')->display(function ($jobfair_type) {
+            $managements = JobfairManagement::all()->pluck('name', 'id');
+            foreach ($managements as $key=>$value){
+                if($jobfair_type == $key){
+                    return $value;
+                    break;
+                }
+            }
+        });
+
+        $grid->predetermined_status('预定状态')->display(function ($predetermined_status) {
+            if ($predetermined_status==1) {
+                if($this->predetermined_end > time()  && $this->predetermined_start < time()){
+                    return "允许预订";
+                }elseif($this->predetermined_start > time()){
+                    return "未开始";
+                }else{
+                    return "停止预订";
+                }
+            } else {
+                return "停止预订";
+            }
+        });
+        $grid->mstatus('预定情况')->display(function () {
+            $standAudit = 0;
+            $standAuditList = [];
+            $standAuditListName = [];
+            $standSuccess = 0;
+            $standSuccessList = [];
+            $standSuccessListName = [];
+            $standLock = 0;
+            $standLockListName = [];
+            $standFreeList = [];
+            $standNum = 0;
+            $FloorplanStand = FloorplanStand::where('jobfair_id', $this->id)->get();
+            $JobfairCompany = JobfairCompany::where('jobfair_id', $this->id)->whereIn('audit', [1,2])->get();
+            if (!$FloorplanStand->isEmpty()) {
+                foreach ($FloorplanStand as $key => $val) {
+                    if ($val->type==2) {
+                        $standLock++;
+                        $standLockListName[]=$val->name;
+                    }
+                    if ($val->type==1) {
+                        $standFreeList[]=$val->id;
+                    }
+                    $standNum++;
+                }
+            }
+            if (!$JobfairCompany->isEmpty()) {
+                foreach ($JobfairCompany as $key => $val) {
+                    if ($val->audit==1) {
+                        $standSuccess++;
+                        $standSuccessList[]=$val->position_id;
+                        $standSuccessListName[]=$val->position;
+                    } elseif ($val->audit==2) {
+                        $standAudit++;
+                        $standAuditList[]=$val->position_id;
+                        $standAuditListName[] = $val->position;
+                    }
+                }
+            }
+            $standFreeList = array_diff($standFreeList, array_unique(array_merge($standSuccessList, $standAuditList)));
+            $standFreeListName =  FloorplanStand::whereIN('id', $standFreeList)->pluck('name')->all();
+            return '<span class="vtip" title="空闲展位号['.implode(',', $standFreeListName).']" style="color:#000000;padding-right:10px">['.count($standFreeList).']</span>
+		            <span class="vtip" title="审核中展位号['.implode(',', $standAuditListName).']" style="color:#FFCC33;padding-right:10px">['.$standAudit.']</span>
+		            <span class="vtip" title="预定成功展位号['.implode(',', $standSuccessListName).']" style="color:#CC00CC;padding-right:10px">['.$standSuccess.']</span>       
+                    <span class="vtip" title="锁定展位号['.implode(',', $standLockListName).']" style="color:#CCCCCC;padding-right:10px">['.$standLock.']</span>
+		            <span class="vtip" title="展位总数['.$standNum.']" style="color:#3300FF;padding-right:10px">['.$standNum.']</span>';
+        });
+        $grid->showendtime('显示截止时间')->display(function ($showendtime) {
+            return $showendtime ? date('Y-m-d H:i:s', $showendtime) : '不限制';
+        });
+
+        if(get_subsite_id() == 0 && get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            });
+        }
+
+
+        $grid->created_at('创建时间');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('jobfair_manager_signed') && (get_subsite_id() == 0 || $actions->row['subsite_id']== get_subsite_id())) {
+                $actions->append('<a href="'.route('jobfair.signed',['id'=>$actions->row['id']]).'"><button class="btn btn-primary btn-xs business" title="签到" >签到</button></a>');
+            }
+            $actions->append('<a href="'.route('jobfair.export_poster',['id'=>$actions->row['id']]).'" target="_blank"><button class="btn btn-primary btn-xs business" title="导出企业海报" >导出企业海报</button></a>');
+            $actions->append('<a href="'.route('jobfair.export_signin',['id'=>$actions->row['id']]).'" target="_blank"><button class="btn btn-primary btn-xs business" title="导出企业签到" >导出企业签到</button></a>');
+            if (Admin::user()->can('jobfair_manager_edit') && (get_subsite_id() == 0 || $actions->row['subsite_id']== get_subsite_id())) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('jobfair_manager_delete') && (get_subsite_id() == 0 || $actions->row['subsite_id']== get_subsite_id())) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('jobfair_manager_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector();
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->like('title', '招聘会标题');
+
+            $filter->equal('jobfair_type', '招聘会类型')->select(JobfairManagement::all()->pluck('name', 'id'));
+
+            $filter->equal('predetermined_status', '预定状态')->select([
+                1  => '允许预订',
+                2  => '停止预订',
+            ]);
+            $filter->between('created_at', '创建时间')->datetime();
+            if(get_subsite_id() == 0 && get_subsite_open()){
+                $filter->equal('subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+            }
+        });
+        if (Admin::user()->can('jobfair_manager_create')) {
+            $grid->disableCreateButton(false);
+        }
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Jobfair::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->holddate_start('举办时间')->as(function ($holddate_start) {
+            return date('Y-m-d H:i:s', $holddate_start).'至'.date('Y-m-d H:i:s', $this->holddate_end);
+        });
+        $show->title('招聘会标题')->as(function ($title) {
+            return $title;
+        });
+        $show->jobfair_type('招聘会类型')->as(function ($jobfair_type) {
+            $managements = JobfairManagement::all()->pluck('name', 'id');
+            foreach ($managements as $key=>$value){
+                if($jobfair_type == $key){
+                    return $value;
+                    break;
+                }
+            }
+        });
+
+        $show->predetermined_status('预定状态')->as(function ($predetermined_status) {
+            if ($predetermined_status==1) {
+                if($this->predetermined_end > time()  && $this->predetermined_start < time()){
+                    return "允许预订";
+                }elseif($this->predetermined_start > time()){
+                    return "未开始";
+                }else{
+                    return "停止预订";
+                }
+            } else {
+                return "停止预订";
+            }
+        });
+
+        $show->showendtime('显示截止时间')->as(function ($showendtime) {
+            return $showendtime ? date('Y-m-d H:i:s', $showendtime) : '不限制';
+        });
+
+        $show->subsite_id('所属分站')->as(function ($subsite_id) {
+            if ($subsite_id) {
+                $Subsite = Subsite::find($subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Jobfair);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $Jobfair = Jobfair::findOrFail($id);
+        $JobfairFloorplan = JobfairFloorplan::where(['jobfair_id'=>$Jobfair->id])->get();
+        $parmArr = '';
+        foreach ($JobfairFloorplan as $key => $val) {
+            $parmName = [];
+            $FloorplanStand = FloorplanStand::where(['jobfair_id'=>$Jobfair->id,'floorplan_id'=>$val->id])->get();
+            foreach ($FloorplanStand as $key1 => $val1) {
+                $parmName[$key1]['name'] = $val1->name;
+                $parmName[$key1]['type'] = $val1->type;
+                $parmName[$key1]['left'] = $val1->left;
+                $parmName[$key1]['top'] = $val1->top;
+                $parmName[$key1]['id'] = $val1->id;
+                $parmName[$key1]['equipment_id'] = $val1->equipment_id;
+                $parmName[$key1]['sortindex'] = $val1->sortindex;
+                if ($val1->type==2) {
+                    $status = 4;
+                } else {
+                    if ($val1->id) {
+                        $JobfairCompany = JobfairCompany::where(['position_id'=>$val1->id])->get();
+                        //先给默认值没预定
+                        $status = 1;
+                        //有预定开始循环
+                        foreach ($JobfairCompany as $value){
+                            //第一次循环默认没审核
+                            static $status = 1;
+                            if ($value) {
+                                if($status == 3){
+                                    //预定成功直接返回,不做判断
+                                    continue;
+                                }elseif ($status == 2 && $value->audit == 3) {
+                                    //未审核并且其他审核未通过,不修改值
+                                    continue;
+                                }elseif($status == 1){
+                                    //第一次进入或未审核
+                                    if ($value->audit==1) {
+                                        $status = 3;
+                                    } elseif ($value->audit==2) {
+                                        $status = 2;
+                                    } else {
+                                        $status = 1;
+                                    }
+                                }
+                            }
+                        }
+                    } else {
+                        $status = 1;
+                    }
+                }
+                $parmName[$key1]['status'] = $status;
+            }
+            $parmArr.="<div class=\"jobfair-item\" data-id=".$val->id.">
+                        <div class=\"jobfair-name\" title=\"\"><input type=\"text\" name=\"jobfairName[]\"  value=".$val->name." /></div>
+                        <div class=\"imgbox\"><img src=".upload_asset($val->bg_images)." alt=\"\"></div>
+                        <strong class=\"edit\" ls=\"\" data-toggle=\"modal\" data-target=\"#myModal\">编辑</strong>";
+            $jonfair_company = JobfairCompany::where('jobfair_id',$id)->get();
+            if($jonfair_company->isEmpty()){
+                $parmArr.=" <strong class=\"delete\">删除</strong>";
+            }
+            $parmArr.= "<input type=\"hidden\" name=\"thumbnailId[]\"  value=".json_encode($parmName)." />
+                        <input type=\"hidden\" name=\"thumbnailImg[]\"  value=".$val->bg_images." />
+                        <input type=\"hidden\" name=\"Floorplan_id[]\"  value=".$val->id." />
+                    </div>";
+        }
+        $form = new Form(new Jobfair());
+        $form->hidden('id')->default($Jobfair->id);
+        $form->tab('基本信息',function ($form) use($Jobfair,$id){
+            $form->text('title', '招聘会标题')->placeholder('如:2017年5月1日(星期六)医药行业主题招聘会')->default($Jobfair->title)->setMustMark();
+            $form->text('industry', '行业主题')->default($Jobfair->industry);
+            $form->text('contact', '联系人')->default($Jobfair->contact)->setMustMark();
+            $form->text('phone', '联系电话')->default($Jobfair->phone)->help('多个号码请用英文半角“,”隔开!')->setMustMark();
+            $form->select('jobfair_type', '分类')->options(JobfairManagement::all()->pluck('name', 'id'))->default($Jobfair->jobfair_type);
+            if ($Jobfair->subsite_id==0) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            } else {
+                $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', $Jobfair->subsite_id)))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                $subsites[0] = '总站';
+            }
+            if ($subsites && get_subsite_open()) {
+                $relations = SubsiteJobfair::where(array('jobfair_id'=>$id))->get()->pluck('subsite_id')->toArray();
+                $form->multipleSelect('subsite_id', '同步分站')->options($subsites)->default($relations);
+            }
+            $form->editor('jobfair_introduction', '招聘会简介')->default($Jobfair->jobfair_introduction)->setMustMark();
+        })->tab('举办信息',function ($form) use($Jobfair,$parmArr){
+            $form->datetime('holddate_start', '举办开始时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->holddate_start ? date('Y-m-d H:i:s', $Jobfair->holddate_start) : '')->setMustMark();
+            $form->datetime('holddate_end', '举办结束时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->holddate_end ? date('Y-m-d H:i:s', $Jobfair->holddate_end) : '')->setMustMark();
+            $form->datetime('predetermined_start', '预定开始时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->predetermined_start ? date('Y-m-d H:i:s', $Jobfair->predetermined_start) : '')->setMustMark();
+            $form->datetime('predetermined_end', '预定结束时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->predetermined_end ? date('Y-m-d H:i:s', $Jobfair->predetermined_end) : '')->setMustMark();
+            $form->datetime('showendtime', '显示截止时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->showendtime ? date('Y-m-d H:i:s', $Jobfair->showendtime) : '')->help('不填不限制');
+            $form->select('areaid', '举办场地')->options(Floorplan::all()->pluck('name', 'id'))->default($Jobfair->areaid)->setMustMark();
+            $form->html("<div id='position_id'>".$parmArr."</div>");
+            $form->text('address', '举办地址')->default($Jobfair->address)->setMustMark();
+            $form->html('<div id="searchResultPanel" style="border:1px solid #C0C0C0;height:100px; display:none;"></div>');
+            $map_x = $Jobfair->map_x ? $Jobfair->map_x : subsite_config('aix.system.map.map.map_x');
+            $map_y = $Jobfair->map_y ? $Jobfair->map_y : subsite_config('aix.system.map.map.map_y');
+            $form->html(' <div class="fr">
+            <input name="map_x" type="hidden" id="x" value="'.$map_x.'">
+            <input name="map_y" type="hidden" id="y" value="'.$map_y.'">
+            <input name="map_zoom" type="hidden" id="zoom" value="'.subsite_config('aix.system.map.map.max_level').'">
+            <div class="form-control" style="height:380px;border:1px solid  #CCCCCC; cursor: pointer;" id="container"></div>
+        </div>', '地图标注')->setMustMark();
+            $form->text('bus', '乘车路线')->default($Jobfair->bus);
+        })->tab('设置',function ($form) use($Jobfair){
+            $form->radio('display', '显示状态')->options([1=>'正常',2=>'暂停'])->default($Jobfair->display);
+            $form->radio('predetermined_status', '预定状态')->options([1=>'允许预订',2=>'停止预订'])->default($Jobfair->predetermined_status);
+            $form->radio('more_stand', '预定多个展位')->options([1=>'允许',0=>'不允许'])->default($Jobfair->more_stand)->help('同一家企业允许预订一场招聘会多个展位!');
+            $form->radio('is_commonweal', '招聘会')->options([1=>'场次',2=>'积分',3=>'公益'])->default($Jobfair->is_commonweal)->help('选择公益招聘会,企业预订免费!')->attribute('class', "is_commonweal");
+            $form->number('predetermined_point', '预定消耗积分')->min(0)->default($Jobfair->predetermined_point)->help('选择积分招聘会,企业预订则抵扣积分!');
+            $form->number('jobsfair_num', '预定消耗场次')->min(0)->default($Jobfair->jobsfair_num)->help('选择场次招聘会,企业预订则抵扣场次!');
+            $form->number('nosign_point', '未签到扣减积分')->min(0)->default($Jobfair->nosign_point)->help('单位:积分');
+            $form->number('late_point', '迟到早退扣减积分')->min(0)->default($Jobfair->late_point)->help('单位:积分');
+            $form->number('ordid', '排序')->min(0)->default($Jobfair->ordid)->help('数字越大,排序越靠前');
+            $form->hidden('_method')->default('put');
+            $form->html('<template id="thumbnailTpl">
+                    <div class="jobfair-item">
+                        <div class="jobfair-name" title=""><input type="text" name="jobfairName[]"  value="" /></div>
+                        <div class="imgbox"><img src="" alt=""></div>
+                        <strong class="edit" ls="" data-toggle="modal" data-target="#myModal">编辑</strong>
+                        <strong class="delete">删除</strong>
+                        <input type="hidden" name="thumbnailId[]"  value="" />
+                        <input type="hidden" name="thumbnailImg[]"  value="" />
+                        <input type="hidden" name="Floorplan_id[]"  value="" />
+                    </div>
+                </template>');
+        });
+        $form->disableReset();
+        return $form->render();
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new Jobfair);
+        $parmArr = '';
+        if (isset(session('content')['jobfairName'])&&!empty(session('content')['jobfairName'])) {
+            foreach (session('content')['jobfairName'] as $key => $val) {
+                $parmName = [];
+                $mk = json_decode(session('content')['thumbnailId'][$key], true);
+                foreach ($mk as $key1 => $val1) {
+                    $parmName[$key1]['name'] = $val1['name'];
+                    $parmName[$key1]['type'] = $val1['type'];
+                    $parmName[$key1]['left'] = $val1['left'];
+                    $parmName[$key1]['top'] = $val1['top'];
+                    $parmName[$key1]['id'] = $val1['id'];
+                    $parmName[$key1]['equipment_id'] = $val1['equipment_id'];
+                    $parmName[$key1]['sortindex'] = $val1['sortindex'];
+                    if ($val1['type']==2) {
+                        $status = 4;
+                    } else {
+                        if ($val1['id']) {
+                            $JobfairCompany = JobfairCompany::where(['position_id'=>$val1['id']])->first();
+                            if ($JobfairCompany) {
+                                if ($JobfairCompany->audit==1) {
+                                    $status = 3;
+                                } elseif ($JobfairCompany->audit==2) {
+                                    $status = 2;
+                                } else {
+                                    $status = 1;
+                                }
+                            } else {
+                                $status = 1;
+                            }
+                        } else {
+                            $status = 1;
+                        }
+                    }
+                    $parmName[$key1]['status'] = $status;
+                }
+                $parmArr.="<div class=\"jobfair-item\" data-id=".session('content')['Floorplan_id'][$key].">
+                        <div class=\"jobfair-name\" title=\"\"><input type=\"text\" name=\"jobfairName[]\"  value=".session('content')['jobfairName'][$key]." /></div>
+                        <div class=\"imgbox\"><img src=".upload_asset(session('content')['thumbnailImg'][$key])." alt=\"\"></div>
+                        <strong class=\"edit\" ls=\"\" data-toggle=\"modal\" data-target=\"#myModal\">编辑</strong>
+                        <strong class=\"delete\">删除</strong>
+                        <input type=\"hidden\" name=\"thumbnailId[]\"  value=".json_encode($parmName)." />
+                        <input type=\"hidden\" name=\"thumbnailImg[]\"  value=".session('content')['thumbnailImg'][$key]." />
+                        <input type=\"hidden\" name=\"Floorplan_id[]\"  value=".session('content')['Floorplan_id'][$key]." />
+                    </div>";
+            }
+        }
+        $form->tab('基本信息',function ($form){
+            $form->text('title', '招聘会标题')->placeholder('如:2017年5月1日(星期六)医药行业主题招聘会')->default(session('content')['title'])->setMustMark();
+            $form->text('industry', '行业主题')->default(session('content')['industry']);
+            $form->text('contact', '联系人')->default(session('content')['contact'])->setMustMark();
+            $form->text('phone', '联系电话')->default(session('content')['phone'])->help('多个号码请用英文半角“,”隔开!')->setMustMark();
+            $form->select('jobfair_type', '分类')->options(JobfairManagement::all()->pluck('name', 'id'))->default(session('content')['jobfair_type'] ? session('content')['jobfair_type'] : 1);
+
+            if (get_subsite_id()==0) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            } else {
+                $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                $subsites[0] = '总站';
+            }
+            if ($subsites && get_subsite_open()) {
+                $form->multipleSelect('subsites', '同步分站')->options($subsites);
+            }
+            $form->hidden('subsite_id')->value(get_subsite_id());
+            $form->editor('jobfair_introduction', '招聘会简介')->default(session('content')['jobfair_introduction'])->setMustMark();
+        })->tab('举办信息',function ($form) use($parmArr){
+            $form->datetime('holddate_start', '举办开始时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['holddate_start'])->setMustMark();
+            $form->datetime('holddate_end', '举办结束时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['holddate_end'])->setMustMark();
+            $form->datetime('predetermined_start', '预定开始时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['predetermined_start'])->setMustMark();
+            $form->datetime('predetermined_end', '预定结束时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['predetermined_end'])->setMustMark();
+            $form->datetime('showendtime', '显示截止时间')->format('YYYY-MM-DD HH:mm:ss')->help('不填不限制')->default(session('content')['showendtime']);
+            $form->select('areaid', '举办场地')->options(Floorplan::all()->pluck('name', 'id'))->default(session('content')['areaid'])->setMustMark();
+            $form->html("<div id='position_id'>$parmArr</div>");
+            $form->text('address', '举办地址')->default(session('content')['address'])->setMustMark();
+            $form->html('<div id="searchResultPanel" style="border:1px solid #C0C0C0;height:100px; display:none;"></div>');
+            $form->html(' <div class="fr">
+            <input name="map_x" type="hidden" id="x" value="'.subsite_config('aix.system.map.map.map_x').'">
+            <input name="map_y" type="hidden" id="y" value="'.subsite_config('aix.system.map.map.map_y').'">
+            <input name="map_zoom" type="hidden" id="zoom" value="'.subsite_config('aix.system.map.map.max_level').'">
+            <div class="form-control" style=height:380px;border:1px solid  #CCCCCC; cursor: pointer;" id="container"></div></div>', '地图标注')->setMustMark();
+            $form->text('bus', '乘车路线')->default(session('content')['bus']);
+        })->tab('设置',function ($form){
+            $form->radio('display', '显示状态')->options([1=>'正常',2=>'暂停'])->default(1);
+            $form->radio('predetermined_status', '预定状态')->options([1=>'允许预订',2=>'停止预订'])->default(1);
+            $form->radio('more_stand', '预定多个展位')->options([1=>'允许',0=>'不允许'])->default(1)->help('同一家企业允许预订一场招聘会多个展位!');
+            $form->radio('is_commonweal', '招聘会')->options([1=>'场次',2=>'积分',3=>'公益'])->default(3)->help('选择公益招聘会,企业预订免费!')->attribute('class', "is_commonweal");
+            $form->number('predetermined_point', '预定消耗积分')->min(0)->default(100)->help('选择积分招聘会,企业预订则抵扣积分!');
+            $form->number('jobsfair_num', '预定消耗场次')->min(0)->default(1)->help('选择场次招聘会,企业预订则抵扣场次!');
+            $form->number('nosign_point', '未签到扣减积分')->min(0)->default(300)->help('单位:积分');
+            $form->number('late_point', '迟到早退扣减积分')->min(0)->default(100)->help('单位:积分');
+            $form->number('ordid', '排序')->min(0)->default(0)->help('数字越大,排序越靠前');
+            $form->html('<template id="thumbnailTpl">
+                    <div class="jobfair-item">
+                        <div class="jobfair-name" title=""><input type="text" name="jobfairName[]"  value="" /></div>
+                        <div class="imgbox"><img src="" alt=""></div>
+                        <strong class="edit" ls="" data-toggle="modal" data-target="#myModal">编辑</strong>
+                        <strong class="delete">删除</strong>
+                        <input type="hidden" name="thumbnailId[]"  value="" />
+                        <input type="hidden" name="thumbnailImg[]"  value="" />
+                        <input type="hidden" name="Floorplan_id[]"  value="" />
+                    </div>
+                </template>');
+        });
+        $form->disableReset();
+        return $form->render();
+    }
+
+
+    public function jobfairAdd(Request $request)
+    {
+        $id = $request->id;
+        if (!$id) {
+            return response()->json(['code'=>0,'info'=>'请选择举办场地!','data'=>'']);
+        }
+        $Floorplan = Floorplan::findOrfail($id)->toArray();
+        $Floorplan['unique_id'] = md5(uniqid(md5(microtime(true)), true));
+        return response()->json(['code'=>1,'info'=>'成功!','data'=>$Floorplan]);
+    }
+
+    public function store(Request $request)
+    {
+        $request->validate([
+            'title' => 'required',
+            'holddate_start' => 'required',
+            'holddate_end' => 'required',
+            'predetermined_start' => 'required',
+            'predetermined_end' => 'required',
+            'areaid' => 'required',
+            'address' => 'required', //举办地址。
+            'contact' => 'required',
+            'phone' => 'required|max:100',
+            'jobfair_introduction' => 'required',
+        ],[
+            'title.required'=>'请填写标题',
+            'holddate_start.required'=>'请填写举办开始时间',
+            'holddate_end.required'=>'请填写举办结束时间',
+            'predetermined_start.required'=>'请填写预定开始时间',
+            'predetermined_end.required'=>'请填写预定结束时间',
+            'areaid.required'=>'请填写举办场地',
+            'address.required'=>'请填写举办地址',
+            'contact.required'=>'请填写联系人',
+            'phone.required'=>'请填写联系方式',
+            'phone.max'=>'联系方式最多不超过100字',
+            'jobfair_introduction.required'=>'请填写简介',
+        ]);
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->showendtime) ) {
+            admin_toastr('举办/预定时间不能含有中文!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->phone) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->jobsfair_num) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->nosign_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->late_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->ordid) ) {
+            admin_toastr('积分/场次/联系电话不能含有中文!', 'error');
+            return  back()->with(['content'=>$request->all()]);
+        }
+        foreach (explode(',',$request->phone) as $value){
+            if(!(preg_match ('/^1[3-9]{1}[0-9]{9}$/', $value) || preg_match ('/^([0-9]{3,4}-)?[0-9]{7,8}$/', $value))){
+                admin_toastr('请输入正确的联系电话', 'error');
+                return  back()->with(['content'=>$request->all()]);
+            }
+        }
+
+        if ($request->holddate_start >= $request->holddate_end) {
+            admin_toastr('举办开始时间不能大于结束时间!!', 'error');
+            return  back()->with(['content'=>$request->all()]);
+        }
+        if ($request->predetermined_start >= $request->holddate_start) {
+            admin_toastr('预订开始时间不能大于举办开始时间!!', 'error');
+            return  back()->with(['content'=>$request->all()]);
+        }
+        if ($request->predetermined_start >= $request->predetermined_end) {
+            admin_toastr('预订开始时间不能大于结束时间!!', 'error');
+            return  back()->with(['content'=>$request->all()]);
+        }
+        if ($request->predetermined_end > $request->holddate_end) {
+            admin_toastr('预订结束时间不能大于举办结束时间!!', 'error');
+            return  back()->with(['content'=>$request->all()]);
+        }
+        $jobfair = [];
+        $jobfair['title'] = $request->title;
+        $jobfair['industry'] = $request->industry;
+        $jobfair['holddate_start'] = strtotime($request->holddate_start);
+        $jobfair['holddate_end'] = strtotime($request->holddate_end);
+        $jobfair['areaid'] = $request->areaid;
+        $jobfair['jobfair_type'] = $request->jobfair_type;
+        $jobfair['showendtime'] = strtotime($request->showendtime);
+        $jobfair['address'] = $request->address;
+        $jobfair['bus'] = $request->bus;
+        $jobfair['contact'] = $request->contact;
+        $apiAddress = $this->apiAddress($request->address);
+        if (!$apiAddress) {
+            admin_toastr('请添加地图标注!!', 'error');
+            return  back()->with(['content'=>$request->all()]);
+        }
+        $jobfair['map_x'] = $apiAddress['lng'];
+        $jobfair['map_y'] = $apiAddress['lat'];
+        $jobfair['phone'] = $request->phone;
+        $jobfair['display'] = $request->display;
+        $jobfair['is_commonweal'] = $request->is_commonweal;
+        $jobfair['predetermined_point'] = $request->predetermined_point;
+        $jobfair['jobsfair_num'] = $request->jobsfair_num;
+        $jobfair['nosign_point'] = $request->nosign_point;
+        $jobfair['late_point'] = $request->late_point;
+        $jobfair['ordid'] = $request->ordid;
+        $jobfair['more_stand'] = $request->more_stand;
+        $jobfair['jobfair_introduction'] = $request->jobfair_introduction;
+        $jobfair['subsite_id'] = get_subsite_id();
+        $jobfair['predetermined_status'] = $request->predetermined_status;
+        $jobfair['predetermined_start'] = $request->predetermined_start ? strtotime($request->predetermined_start) : $request->predetermined_start;
+        $jobfair['predetermined_end'] = $request->predetermined_end ? strtotime($request->predetermined_end) : $request->predetermined_end;
+        $jobfairName = $request->jobfairName;
+        if (empty($jobfairName)) {
+            admin_toastr('请重新分配举办场地!!', 'error');
+            return  back()->with(['content'=>$request->all()]);
+        }
+        DB::beginTransaction();
+        try {
+            $Jobfair = Jobfair::create($jobfair);
+            $subsites = \Illuminate\Support\Facades\Request::input('subsites');
+            if (get_subsite_id() == 0 && $subsites) {
+                $subsites = array_merge(array(get_subsite_id()), $subsites);
+            } else {
+                $subsites = array(get_subsite_id());
+            }
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'jobfair_id' => $Jobfair->id,
+                        'subsite_id'=> $v,
+                        'created_at'=>date('Y-m-d H:i:s'),
+                        'updated_at'=>date('Y-m-d H:i:s'),
+                    );
+                }
+            }
+            SubsiteJobfair::insert($set_data);
+            $jobfairFloorplan = [];
+            foreach ($jobfairName as $key => $val) {
+                $jobfairFloorplan['jobfair_id'] = $Jobfair->id;
+                $jobfairFloorplan['name'] = $val;
+                $jobfairFloorplan['bg_images'] = $request->thumbnailImg[$key];
+                $JobfairFloor = JobfairFloorplan::create($jobfairFloorplan);
+                $thumbnailId = json_decode($request->thumbnailId[$key], true);
+
+                $jobfairFloorplanStands = [];
+                foreach ($thumbnailId as $key1 => $val1) {
+                    $jobfairFloorplanStands[$key1]['jobfair_id'] = $Jobfair->id;
+                    $jobfairFloorplanStands[$key1]['floorplan_id'] = $JobfairFloor->id;
+                    $jobfairFloorplanStands[$key1]['name'] = $val1['name'];
+                    $jobfairFloorplanStands[$key1]['type'] = $val1['type'];
+                    $jobfairFloorplanStands[$key1]['left'] = $val1['left'];
+                    $jobfairFloorplanStands[$key1]['top'] = $val1['top'];
+                    $jobfairFloorplanStands[$key1]['sortindex'] = $val1['sortindex'] ? $val1['sortindex'] : 1000+$key1;
+                    $jobfairFloorplanStands[$key1]['equipment_id'] = $val1['equipment_id'];
+                    $jobfairFloorplanStands[$key1]['created_at'] = date('Y-m-d H:i:s');
+                    $jobfairFloorplanStands[$key1]['updated_at'] = date('Y-m-d H:i:s');
+                }
+                if ($jobfairFloorplanStands) {
+                    FloorplanStand::insert($jobfairFloorplanStands);
+                }
+            }
+            DB::commit();
+            admin_toastr('操作成功!', 'success');
+            return redirect(route('jobfair.index'));
+        } catch (\Exception $e) {
+            DB::rollback();
+            admin_toastr($e->getMessage(), 'error');
+            return back();
+        }
+    }
+
+    public function update(Request $request)
+    {
+        $request->validate([
+            'title' => 'required',
+            'holddate_start' => 'required',
+            'holddate_end' => 'required',
+            'predetermined_start' => 'required',
+            'predetermined_end' => 'required',
+            'areaid' => 'required',
+            'address' => 'required', //举办地址。
+            'contact' => 'required',
+            'phone' => 'required|max:100',
+            'jobfair_introduction' => 'required',
+        ],[
+            'title.required'=>'请填写标题',
+            'holddate_start.required'=>'请填写举办开始时间',
+            'holddate_end.required'=>'请填写举办结束时间',
+            'predetermined_start.required'=>'请填写预定开始时间',
+            'predetermined_end.required'=>'请填写预定结束时间',
+            'areaid.required'=>'请填写举办场地',
+            'address.required'=>'请填写举办地址',
+            'contact.required'=>'请填写联系人',
+            'phone.required'=>'请填写联系方式',
+            'phone.max'=>'联系方式最多不超过100字',
+            'jobfair_introduction.required'=>'请填写简介',
+        ]);
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->showendtime) ) {
+            admin_toastr('举办/预定时间不能含有中文!', 'error');
+            return back();
+        }
+
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->phone) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->jobsfair_num) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->nosign_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->late_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->ordid) ) {
+            admin_toastr('积分/场次/联系电话不能含有中文!', 'error');
+            return back();
+        }
+        foreach (explode(',',$request->phone) as $value){
+            if(!(preg_match ('/^1[3-9]{1}[0-9]{9}$/', $value) || preg_match ('/^([0-9]{3,4}-)?[0-9]{7,8}$/', $value))){
+                admin_toastr('请输入正确的联系电话', 'error');
+                return back();
+            }
+        }
+
+        $jobfair_id = $request->id;
+        if (empty($jobfair_id)) {
+            admin_toastr('招聘会不存在!', 'error');
+            return back();
+        }
+        if ($request->holddate_start >= $request->holddate_end) {
+            admin_toastr('举办开始时间不能大于结束时间!!', 'error');
+            return back();
+        }
+        if ($request->predetermined_start >= $request->predetermined_end) {
+            admin_toastr('预订开始时间不能大于结束时间!!', 'error');
+            return back();
+        }
+        if ($request->predetermined_end > $request->holddate_end) {
+            admin_toastr('预订结束时间不能大于举办结束时间!!', 'error');
+            return back();
+        }
+
+        $jobfair = [];
+        $JobfairFloorplanArr = JobfairFloorplan::where('jobfair_id', $jobfair_id)->pluck('id')->toArray();
+        $FloorplanStandArr = FloorplanStand::where('jobfair_id', $jobfair_id)->pluck('id')->toArray();
+        $jobfair['title'] = $request->title;
+        $jobfair['industry'] = $request->industry;
+        $jobfair['holddate_start'] = strtotime($request->holddate_start);
+        $jobfair['holddate_end'] = strtotime($request->holddate_end);
+        $jobfair['areaid'] = $request->areaid;
+        $jobfair['jobfair_type'] = $request->jobfair_type;
+        $jobfair['showendtime'] = strtotime($request->showendtime);
+        $jobfair['address'] = $request->address;
+        $jobfair['bus'] = $request->bus;
+        $jobfair['contact'] = $request->contact;
+
+        $apiAddress = $this->apiAddress($request->address);
+        if (!$apiAddress) {
+            admin_toastr('请添加地图标注!!', 'error');
+            return back();
+        }
+        $jobfair['map_x'] = $apiAddress['lng'];
+        $jobfair['map_y'] = $apiAddress['lat'];
+
+        $jobfair['phone'] = $request->phone;
+        $jobfair['display'] = $request->display;
+        $jobfair['is_commonweal'] = $request->is_commonweal;
+        $jobfair['predetermined_point'] = $request->predetermined_point;
+        $jobfair['jobsfair_num'] = $request->jobsfair_num;
+        $jobfair['nosign_point'] = $request->nosign_point;
+        $jobfair['late_point'] = $request->late_point;
+        $jobfair['ordid'] = $request->ordid;
+        $jobfair['jobfair_introduction'] = $request->jobfair_introduction;
+        $jobfair['more_stand'] = $request->more_stand;
+        if(is_array($request->subsite_id)){
+            $subsiteArr = $request->subsite_id;
+            $subsite_id = [];
+            foreach ($subsiteArr as $key => $val) {
+                if ($val!==null) {
+                    $subsite_id[] = $val;
+                }
+            }
+            $own_subsite_id = Jobfair::findOrFail($jobfair_id)->subsite_id;
+            $subsiteJobfair = [
+                [
+                    'jobfair_id'=>$jobfair_id,
+                    'subsite_id'=> $own_subsite_id,
+                    'created_at'=>date('Y-m-d H:i:s'),
+                    'updated_at'=>date('Y-m-d H:i:s'),
+                ]
+            ];
+            if ($subsite_id) {
+                $subsiteArr = [];
+                foreach ($subsite_id as $key => $val) {
+                    $subsiteArr[$key]['jobfair_id'] = $jobfair_id;
+                    $subsiteArr[$key]['subsite_id'] = $val;
+                    $subsiteArr[$key]['created_at'] = date('Y-m-d H:i:s');
+                    $subsiteArr[$key]['updated_at'] = date('Y-m-d H:i:s');
+                }
+                if (in_array($own_subsite_id, $subsite_id)) {
+                    $subsiteJobfair = $subsiteArr;
+                } else {
+                    $subsiteJobfair = array_merge($subsiteJobfair, $subsiteArr);
+                }
+            }
+        }
+        $jobfair['predetermined_status'] = $request->predetermined_status;
+        $jobfair['predetermined_start'] = $request->predetermined_start ? strtotime($request->predetermined_start) : $request->predetermined_start;
+        $jobfair['predetermined_end'] = $request->predetermined_end ? strtotime($request->predetermined_end) : $request->predetermined_end;
+        $Floorplan_id = $request->Floorplan_id ? $request->Floorplan_id : [];
+        DB::beginTransaction();
+        try {
+            Jobfair::where('id', $jobfair_id)->update($jobfair);
+            if(isset($subsiteJobfair)){
+                SubsiteJobfair::where('jobfair_id', $jobfair_id)->delete();
+                SubsiteJobfair::insert($subsiteJobfair);
+            }
+            $jobfairArr = [];
+            $floorStandArrId = [];
+            if ($Floorplan_id) {
+                foreach ($Floorplan_id as $key => $val) {
+                    if (in_array($val, $JobfairFloorplanArr)) {
+                        JobfairFloorplan::where('id', $val)->update(['name'=>$request->jobfairName[$key]]);
+                        $floorplan_id_new = $val;
+                    } else {
+                        $jobfairArr['name'] = $request->jobfairName[$key];
+                        $jobfairArr['bg_images'] = $request->thumbnailImg[$key];
+                        $jobfairArr['jobfair_id'] = $jobfair_id;
+                        $JobfairFloorplan = JobfairFloorplan::create($jobfairArr);
+                        $floorplan_id_new = $JobfairFloorplan->id;
+                    }
+                    $thumbnailId = json_decode($request->thumbnailId[$key], true);
+                    $jobfairFloorplanStands = [];
+                    if ($thumbnailId) {
+                        foreach ($thumbnailId as $key1 => $val1) {
+                            if ($val1['id']) {
+                                $floorStandArrId[] = $val1['id'];
+                                FloorplanStand::where('id', $val1['id'])->update(['name'=>$val1['name'],'type'=>$val1['type'],'left'=>$val1['left'],'top'=>$val1['top']]);
+                            } else {
+                                $jobfairFloorplanStands[$key1]['jobfair_id'] = $jobfair_id;
+                                $jobfairFloorplanStands[$key1]['floorplan_id'] = $floorplan_id_new;
+                                $jobfairFloorplanStands[$key1]['name'] = $val1['name'];
+                                $jobfairFloorplanStands[$key1]['type'] = $val1['type'];
+                                $jobfairFloorplanStands[$key1]['left'] = $val1['left'];
+                                $jobfairFloorplanStands[$key1]['top'] = $val1['top'];
+                                $jobfairFloorplanStands[$key1]['sortindex'] = isset($val1['sortindex']) ? $val1['sortindex'] : 1000+$key1;
+                                $jobfairFloorplanStands[$key1]['equipment_id'] = $val1['equipment_id'];
+                                $jobfairFloorplanStands[$key1]['created_at'] = date('Y-m-d H:i:s');
+                                $jobfairFloorplanStands[$key1]['updated_at'] = date('Y-m-d H:i:s');
+                            }
+                        }
+                    }
+                    if ($jobfairFloorplanStands) {
+                        FloorplanStand::insert($jobfairFloorplanStands);
+                    }
+                }
+            }
+            $floorplan_arr_id = array_diff($JobfairFloorplanArr, $Floorplan_id);
+            if (!empty($floorplan_arr_id)) {
+                JobfairFloorplan::destroy($floorplan_arr_id);
+            }
+            $floorStand_arr_id = array_diff($FloorplanStandArr, $floorStandArrId);
+            if (!empty($floorStand_arr_id)) {
+                FloorplanStand::destroy($floorStand_arr_id);
+            }
+            DB::commit();
+            admin_toastr('操作成功!', 'success');
+            return redirect(route('jobfair.index'));
+        } catch (\Exception $e) {
+            DB::rollback();
+            admin_toastr($e->getMessage(), 'error');
+            return back();
+        }
+    }
+
+    public function signed(Request $request, content $content)
+    {
+        $jobfair_id = $request->id;
+        if (!$jobfair_id) {
+            admin_toastr('招聘会不存在!', 'error');
+            return back();
+        }
+        $form = new \Encore\Admin\Widgets\Form();//表单使用admin提供的表单
+        $form->action(route('jobfair.singedupdate'));
+        $form->hidden('jobfair_id')->default($jobfair_id);
+        $form->text('hash_id', '扫码枪')->placeholder('请将输入法切为英文模式后扫码');
+        $form->disableReset();
+        return $content
+            ->header('招聘会签到')
+            ->description('')
+            ->body(view('admin.jobfair.singed')->with(['content'=>$form->render()]));
+    }
+
+    public function singedUpdate(Request $request)
+    {
+        $jobfair_id = $request->jobfair_id;
+        $hash_id = $request->hash_id;
+        $hash_array = explode('/',$hash_id);
+        $hash_id = $hash_array[count($hash_array)-1];
+        $res = hashid_decode($hash_id);
+        if(!$res){
+            admin_toastr('二维码错误!', 'error');
+            return back();
+        }
+        if (!$jobfair_id) {
+            admin_toastr('招聘会不存在!', 'error');
+            return back();
+        }
+        $Jobfair = Jobfair::findOrFail($jobfair_id);
+        if (!$Jobfair) {
+            admin_toastr('招聘会不存在!', 'error');
+            return back();
+        }
+        if (time()>=$Jobfair->holddate_end) {
+            admin_toastr('该招聘会已结束!', 'error');
+            return back();
+        }
+        if (time()<=$Jobfair->holddate_start) {
+            if (($Jobfair->holddate_start-time())>3600) {
+                admin_toastr('只能在招聘会开始之前1小时之内签到!', 'error');
+                return back();
+            }
+        }
+        if($res['utype'] == 1){
+            //企业签到
+            $JobfairCompany = JobfairCompany::where(['company_id'=>$res['id'],'jobfair_id'=>$jobfair_id,'audit'=>1])->first();
+            if (!$JobfairCompany) {
+                admin_toastr('该参会企业不存在!', 'error');
+                return back();
+            }
+            if ($JobfairCompany->type) {
+                admin_toastr('该参会企业已经签到过了!', 'error');
+                return back();
+            }
+            $date['type'] = 4;
+            $date['signed_time'] = time();
+            //允许迟到半小时
+            if ($Jobfair->holddate_start < strtotime("-30 minute")) {
+                $date['type'] = 1;
+            }
+            //修改状态
+            $result = JobfairCompany::where(['company_id'=>$res['id'],'jobfair_id'=>$jobfair_id])->update($date);
+            //在jobfair_person_signeds插入数据
+            $company = Company::find($res['id']);
+            $info['name'] = $company->companyname;
+            $info['address'] = $company->address;
+            $info['jobfairid'] = $jobfair_id;
+            $info['sign_type'] = 2;
+            $info['utype'] = 1;
+            $info['uid'] = $company->id;
+            JobfairPersonSigned::create($info);
+            Cache::put($hash_id, time(),72000);
+        }else {
+            $memberInfo = MemberInfo::where(['uid' => $res['id']])->first();
+            $info['name'] = $memberInfo->realname;
+            $info['uid'] = $memberInfo->uid;
+            $info['jobfairid'] = $jobfair_id;
+            $info['idcard'] = $memberInfo->id_card;
+            $info['sex'] = $memberInfo->sex;
+            $info['address'] = $memberInfo->householdaddress_cn;
+            $info1 = $this->subIdcard($info['idcard'] );
+            $info = array_merge($info,$info1);
+            $info['sign_type'] = 2;
+            $result = JobfairPersonSigned::create($info);
+        }
+        if ($result) {
+            admin_toastr('签到成功!', 'success');
+            return back();
+        } else {
+            admin_toastr('签到失败!', 'error');
+            return back();
+        }
+    }
+
+    protected function apiAddress($address)
+    {
+        $url='https://api.map.baidu.com/geocoder/v2/?address='.$address.'&output=json&ak='.subsite_config('aix.system.map.map.map_ak').'&s=1';
+        if ($result=file_get_contents($url)) {
+            $data = array();
+            $res= json_decode($result, true);
+            if ($res['status']==0) {
+                $results = $res['result'];
+                $data['lng'] = $results['location']['lng'];
+                $data['lat'] = $results['location']['lat'];
+            }
+            return $data;
+        }
+    }
+
+    public function exportPoster(Request $request){
+        $id = $request->id;
+        $data=array();
+        $Jobfaircompany =  JobfairCompany::where(array('audit'=>1,'jobfair_id'=>$id))->get();
+        foreach ($Jobfaircompany as $key =>$c){
+            $company = Company::where('id',$c->company_id)->first();
+            $data[$key]['company_name'] = $company->companyname;
+            $position_id = FloorplanStand::where('id',$c->position_id)->first()->toArray();
+            $data[$key]['position_id'] = $position_id['equipment_id'];
+            $jobfair_put_jobs = JobfairPutJob::where(array('jobfair_id'=>$id,'company_id'=>$c->company_id))->get();
+            $data[$key]['jobs_list']=$jobfair_put_jobs;
+            $company = Company::where('id',$c->company_id)->first();
+            $data[$key]['contact']=$company->contact;
+            if($company->mobile){
+                $data[$key]['mobile']=$company->mobile;
+            }else{
+                $data[$key]['mobile']=$company->landline_tel;
+            }
+            $data[$key]['address']=$company->address;
+        }
+        $jobfarinfo = Jobfair::where('id',$id)->first()->toArray();
+        $export = new HaibaoExport($jobfarinfo['title'].'海报');
+        $c = new Collection($data);
+        $export->setCustomerData($c)->export();//这里不需要return
+    }
+
+    public function exportSignin(Request $request){
+        $id = $request->id;
+        $info =     JobfairCompany::where('jobfair_id',$id)->get()->toArray();
+        $jobfair = Jobfair::where('id',$id)->first()->toArray();
+        $data = array();
+        foreach ($info as $key=>$i){
+            $data[$key]['position_id'] = $i['position'];
+            $companys = Company::where('id',$i['company_id'])->first();
+            if($companys){
+                $data[$key]['companyname'] = $companys->companyname;
+                switch($i['type']){
+                    case 0:
+                        $type = '未签到';
+                        break;
+                    case 1:
+                        $type = '迟到';
+                        break;
+                    case 2:
+                        $type = '早退';
+                        break;
+                    case 3:
+                        $type = '迟到/早退';
+                        break;
+                    case 4:
+                        $type = '已签到';
+                        break;
+                }
+                $data[$key]['type'] = $type;
+                $data[$key]['signed_time'] = $i['signed_time']?date('Y-m-d H:i:s',$i['signed_time']):'';
+            }else{
+                $data[$key]['position_id'] = '';
+                $data[$key]['companyname'] = '';
+                $data[$key]['type'] = '';
+                $data[$key]['signed_time'] ='';
+            }
+        }
+        array_multisort(array_column($data,'position_id'),SORT_ASC,$data);
+        $export = new QiandaoExport($jobfair['title'].'签到导出'.date('YmdHis',time()));
+        $c = new Collection($data);
+        $export->setCustomerData($c)->export();//这里不需要return
+    }
+
+    //根据身份证截取信息
+    protected function subIdcard($idcard)
+    {
+        $data = [];
+        $sexInt = (int)substr($idcard, 16, 1);
+        $data['sex'] = $sexInt % 2 == 0 ? '2' : '1';
+        $data['birthday'] = substr($idcard,6,4);
+        return $data;
+    }
+
+
+}

+ 239 - 0
app/Admin/Controllers/Jobfair/JobfairDishonestyController.php

@@ -0,0 +1,239 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\Jobfair\JobfairCompany;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class JobfairDishonestyController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('不诚信记录')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('不诚信记录详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('不诚信记录编辑')
+            ->description('')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('不诚信记录创建')
+            ->description('')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairCompany);
+        $grid->model()->with(['companys','jobfair'])->whereHas('companys')->whereHas('jobfair',function ($query) {
+            $query->where('holddate_start','<',strtotime("-30 seconds"));
+        })->where('type', '<>', 4)->where('audit',1)
+//            ->groupBy('company_id', 'jobfair_id')
+            ->orderBy('id', 'desc');
+
+        $grid->column('companys.companyname', '公司名称')->width(200);
+        $grid->column('jobfair.title', '招聘会名称')->width(200);
+        $grid->column('jobfair.holddate_start', '招聘会开始时间')->display(function ($holddate_start) {
+            return date('Y-m-d H:i:s', $holddate_start);
+        });
+        $grid->column('jobfair.holddate_end', '招聘会结束时间')->display(function ($holddate_end) {
+            return date('Y-m-d H:i:s', $holddate_end);
+        });
+        $grid->type('行为')->display(function ($type) {
+            if ($type==0) {
+                return '未签到';
+            } elseif ($type==1) {
+                return '迟到';
+            } elseif ($type==2) {
+                return '早退';
+            } elseif ($type==3) {
+                return '迟到/早退';
+            } else {
+                return '未签到';
+            }
+        });
+        $grid->signed_time('签到时间')->display(function ($signed_time) {
+            return $signed_time ? date('Y-m-d H:i:s', $signed_time) : '';
+        });
+        $grid->over_time('注销时间')->display(function ($over_time) {
+            return $over_time ? date('Y-m-d H:i:s', $over_time) : '';
+        });
+        $grid->disableCreateButton();
+        $grid->disableExport();
+
+        $grid->actions(function ($actions) use ($grid) {
+
+            if (Admin::user()->can('jobfair_dishonesty_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('jobfair_dishonesty_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->like('companys.companyname', '公司名称');
+            $filter->like('jobfair.title', '招聘会名称');
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairCompany::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->companys()->companyname('公司名称')->as(function ($companys){
+            return $companys->companyname;
+        });
+
+        $show->jobfair()->title('招聘会名称')->as(function ($jobfair){
+            return $jobfair->title;
+        });
+
+        $show->jobfair()->holddate_start('招聘会开始时间')->as(function ($jobfair) {
+            return date('Y-m-d H:i:s', $jobfair->holddate_start);
+        });
+
+        $show->jobfair()->holddate_end('招聘会结束时间')->as(function ($jobfair) {
+            return date('Y-m-d H:i:s', $jobfair->holddate_end);
+        });
+
+        $show->type('行为')->as(function ($type) {
+            if ($type==0) {
+                return '未签到';
+            } elseif ($type==1) {
+                return '迟到';
+            } elseif ($type==2) {
+                return '早退';
+            } elseif ($type==3) {
+                return '迟到/早退';
+            } else {
+                return '未签到';
+            }
+        });
+        $show->signed_time('签到时间')->as(function ($signed_time) {
+            return $signed_time ? date('Y-m-d H:i:s', $signed_time) : '';
+        });
+        $show->over_time('注销时间')->as(function ($over_time) {
+            return $over_time ? date('Y-m-d H:i:s', $over_time) : '';
+        });
+
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new JobfairCompany);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的职位', 'error');
+        }
+        \DB::beginTransaction();
+        try {
+            JobfairCompany::whereIn('id', $ids)->update(['type'=>4]);
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 879 - 0
app/Admin/Controllers/Jobfair/JobfairJobController.php

@@ -0,0 +1,879 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Category;
+use App\Models\CategoryDistrict;
+use App\Models\CategoryJobs;
+use App\Models\Jobfair\JobfairJob;
+use App\Models\Jobfair\JobfairJobsContact;
+use App\Models\Jobfair\JobfairPutJob;
+use App\Models\Jobfairout\JobfairoutPutJob;
+use App\Models\Pms;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\MessageBag;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Input;
+use Illuminate\Support\Facades\Cache;
+class JobfairJobController extends Controller
+{
+
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('招聘会职位库')
+            ->description('为了统计数据,职位库审核不再同步已结束招聘会的参会职位,请及时审核!')
+            ->body(view('admin.jobfair.jobs')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('招聘会职位详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        $js = <<<ETO
+        $(document).ready(function() {
+             $('.radio-inline,.iCheck-helper').click(function() {
+                var val = $(this).closest(".radio-inline").find("input:radio").val();
+                 if (val == '0') {
+                    $("input[name=wage]").parents('.form-group').hide();
+                 }
+                 else if (val == '1') {
+                    $("input[name=wage]").parents('.form-group').show();
+                 }
+            });
+        });
+ETO;
+        Admin::script($js);
+        return $content
+            ->header('招聘会职位编辑')
+            ->description('')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('招聘会职位创建')
+            ->description('')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairJob);
+        $grid->model()
+            ->with('company')
+            ->where('type',1)
+            ->when(get_subsite_id()>0, function ($query) {
+                $query->whereHas('company', function ($query) {
+                    $query->where('companys.subsite_id', get_subsite_id());
+                });
+            })
+            ->orderByRaw("FIELD(audit, 2,1,3)")->orderBy('updated_at', 'desc');
+        $grid->jobs_name('职位名称')->width(200);
+        $grid->company_name('发布公司')->display(function ($company_name) {
+            return '<a href="'.route('jobs.company',['id'=>$this->company_id]) .'" target="_blank">'.$company_name.'</a>';
+        })->width(200);
+        $grid->audit('审核状态')->display(function ($audit) {
+            if ($audit==1) {
+                return'<span style="color: #009900">审核通过</span>';
+            } elseif ($audit==3) {
+                return'<span style="color:#666666">审核未通过</span>';
+            } else {
+                return'<span style="color:#FF6600">等待审核</span>';
+            }
+        });
+
+        $grid->amount('人数')->display(function ($amount) {
+            return $amount ? $amount : '若干';
+        });
+        $grid->sex_cn('性别');
+        $grid->education_cn('学历')->display(function ($education_cn) {
+            return $education_cn ? $education_cn : '不限';
+        });
+        $grid->wage_cn('待遇')->width(100);
+        $grid->district_cn('工作地区');
+        if(get_subsite_open()){
+            $grid->subsite('所属分站')->display(function () {
+                if(isset($this->company->subsites)){
+                    return $this->company->subsites->sitename;
+                }else{
+                    return '总站';
+                }
+            });
+        }
+
+        $grid->created_at('创建时间');
+        $grid->updated_at('更新时间');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('jobfair_jobs_delete')) {
+                $actions->disableDelete(false);
+            }
+            if (Admin::user()->can('jobfair_jobs_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('company_manager_bussiness')) {
+                $actions->append("<button class='btn btn-primary btn-xs business' id=" . $actions->row['company_id'] . ">业务</button>");
+            }
+            if (Admin::user()->can('jobfair_jobs_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+        });
+
+        if (Admin::user()->can('jobfair_jobs_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('jobfair_jobs_audit')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="Audit_Jobs" title="审核职位">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">审核职位
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('jobs_name', '职位名称');
+                $filter->like('company_name', '公司名称');
+                $filter->equal('sex', '性别')->select([
+                    0=>'不限',
+                    1=>'男',
+                    2=>'女',
+                ]);
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('audit', '审核状态')->select([
+                    1=>'审核通过',
+                    2=>'等待审核',
+                    3=>'审核未通过',
+                ]);
+
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '刷新时间', 'updated_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairJob::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->jobs_name('职位名称');
+        $show->company_name('发布公司')->as(function ($company_name) {
+            return $company_name;
+        });
+        $show->audit('审核状态')->as(function ($audit) {
+            if ($audit==1) {
+                return '审核通过';
+            } elseif ($audit==3) {
+                return '审核未通过';
+            } else {
+                return '等待审核';
+            }
+        });
+
+        $show->display('显示状态')->as(function ($audit) {
+            if ($audit==1) {
+                return '显示';
+            } else {
+                return '关闭';
+            }
+        });
+        $show->amount('人数');
+        $show->sex_cn('性别');
+        $show->education_cn('学历');
+        $show->wage_cn('待遇');
+        $show->district_cn('工作地区');
+        $show->jobs_content('职位描述')->setEscape(false);
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+
+    protected function editForm($id)
+    {
+        $form = new Form(new JobfairJob);
+        $form->tab('职位信息', function (Form $form) use ($id) {
+            $form->display('id');
+            $jobsData = JobfairJob::where('id', $id)->select('age', 'tag', 'topclass', 'category', 'subclass', 'district', 'wage', 'wage_min', 'wage_max','syq','syqxz_min','ygxs','updated_at')->first()->toArray();
+            $age = explode('-', $jobsData['age']);
+            if ($jobsData['district']) {
+                $district = string_to_array('.', $jobsData['district']);
+            }
+            $form->text('jobs_name', '职位名称')->rules(['required'], ['required'=>'请填写职位名称'])->setMustMark();
+            $form->display('company_name', '企业名称');
+//            $form->radio('display', '在招状态')->options([1=>'在招',2=>'关闭']);
+            $form->radio('audit', '审核状态')->options([0=>'未审核',1=>'审核通过',2=>'审核中',3=>'审核未通过']);
+            $jobsNature = Category::categoryType('AIX_jobs_nature');
+            $form->radio('nature', '职位性质')->options($jobsNature);
+            $form->select('ygxs', '用工形式')->options(Category::categoryType('AIX_ygxs'))->rules(['required'], ['required' => '请填写用工形式',])->setMustMark();
+            $form->text('hour_money', '小时工薪资')->default($jobsData['wage_min'])->setMustMark();
+            $form->hidden('wage_min_value', '系统最低工资')->default(config('aix.companyset.comset.com_set.wage_min'));
+            $techlevel = Category::categoryType('AIX_techlevel');
+            $techlevel['0'] = '不限';
+            $form->select('techlevel', '技能等级')->options($techlevel)->setMustMark();
+            $form->select('topclass', '职位大类')->options(CategoryJobs::List()->pluck('name', 'id'))->load('category', admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位大类'))->setMustMark();
+            $form->select('category', '职位中类')->options(CategoryJobs::category($jobsData['topclass']))->load('subclass', admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位中类'))->setMustMark();
+            $form->select('subclass', '职位小类')->options(CategoryJobs::category($jobsData['category']))->rules('required', array('required'=>'请选择职位小类'))->setMustMark();
+            if (!empty($district)) {
+                $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default($district[0])->setMustMark();
+                $form->select('city', '所属城市')->options(CategoryDistrict::categoryDis($district[0]))->setWidth(3)->load('area', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default($district[1])->setMustMark();
+                $form->select('area', '所属县区')->default(isset($district[2])?$district[2]:0)->options(CategoryDistrict::categoryDis($district[1]))->setWidth(3)->default(isset($district[2]) ? $district[2] : '')->setMustMark();
+
+            } else {
+                $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default(0)->setMustMark();
+                $form->select('city', '所属城市')->setWidth(3)->load('area', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default(0)->setMustMark();
+                $form->select('area', '所属县区')->setWidth(3)->default(0)->setMustMark();
+
+            }
+
+            if ($jobsData['wage'] == 0) {
+                $form->hidden('wage');
+                $form->number('wage_min', '最低薪资')->min(config('aix.companyset.comset.com_set.wage_min'))->help("请填写大于".config('aix.companyset.comset.com_set.wage_min')."的10的倍数")
+                    ->rules(['required'], ['required'=>'请选择最小薪资'])->setMustMark();
+                $form->number('wage_max', '最高薪资')->help("请填写大于最低薪资的10的倍数")->rules(['required'], ['required'=>'请填写最大薪资'])->setMustMark();
+            } else {
+                $option = Category::categoryType('AIX_wage');
+                $option[-1] ='面议';
+                $form->select('wage', '薪资待遇')->options($option)->default($jobsData['wage'])->rules(['required'], ['required'=>'请选择薪资待遇'])->setMustMark();
+                $form->hidden('wage_min');
+                $form->hidden('wage_max');
+            }
+            $form->select('syq', '试用期时间')->options(Category::categoryType('zs_syq'))->default($jobsData['syq'])->rules(['required'], ['required'=>'请选择试用期时间'])->setMustMark();
+            $form->number('syqxz_min', '试用期薪资')->min(config('aix.companyset.comset.com_set.wage_min'))->default($jobsData['syqxz_min'])->help("请填写大于" . config('aix.companyset.comset.com_set.wage_min') . "的10的倍数")->setMustMark();
+            $education = Category::categoryType('AIX_education');
+            $education['0']='不限';
+            $form->radio('education', '学历要求')->options($education);
+            $experience = Category::categoryType('AIX_experience');
+            $experience['0']="不限";
+            $form->radio('experience', '工作经验')->options($experience);
+            $form->radio('sex', '性别要求')->options([0=>'不限',1=>'男',2=>'女']);
+            $form->number('min_age', '最低年龄')->default(isset($age[0])?$age[0]:'')->min(16)->max(65)->help('最低年龄不能低于国家规定用工年龄');
+            $form->number('max_age', '最高年龄')->default(isset($age[1])?$age[1]:'')->min(16)->max(65)->help('最高年龄不能高于65周岁');
+
+            $form->number('amount', '招聘人数')->min(1)->max(99)->rules(['required'], ['required'=>'请输入招聘人数'])->help('请填写招聘人数1~99')->setMustMark();
+            $form->multipleSelect('tag', '职位亮点')->options(Category::categoryType('AIX_jobtag'))->default(explode(',', $jobsData['tag']));
+            $form->textarea('jobs_content', '职位描述')->attribute(['maxlength'=>2000])->rules(['required'], ['required'=>"请填写职位描述"])->setMustMark();
+        })->tab('联系人', function (Form $form) {
+            $form->text("contact.contact", '联系人')->setWidth(3)->rules(['required'], ['required'=>"请填写联系人"])->setMustMark();
+            $form->radio('contact.contact_show', '联系人是否公开')->options([0=>'不公开',1=>'公开']);
+
+            $form->text('contact.mobile', '联系电话')->setWidth(3)->rules(['required'], ['required'=>"请填写联系电话"])->setMustMark();
+            $form->radio('contact.telephone_show', '联系电话是否公开')->options([0=>'不公开',1=>'公开']);
+
+            $form->text('contact.landline_tel', '固定电话')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)');  //这个字段引起问题
+            $form->radio('contact.landline_tel_show', '固定电话是否公开')->options([0=>'不公开',1=>'公开']);
+
+            $form->text('contact.email', 'Email')->setWidth(3)->rules(['required'], ['required'=>"请填写Email"])->setMustMark();
+            $form->radio('contact.email_show', 'Email是否公开')->options([0=>'不公开',1=>'公开']);
+
+            $form->text('contact.address', '联系地址')->setWidth(3)->rules(['required'], ['required'=>"请填写联系地址"])->setMustMark();
+        });
+
+        $form->ignore('province');
+        $form->ignore('city');
+        $form->ignore('area');
+        $form->ignore('tag');
+        $form->ignore('min_age');
+        $form->ignore('max_age');
+        $form->ignore('wage_min_value');
+        $form->saving(function ($form) {
+            $minage = Input::get('min_age');
+            $maxage = Input::get('max_age');
+            if ($maxage && $minage) {
+                if ($maxage <= $minage) {
+                    $error = new MessageBag([
+                        'title' => '提示',
+                        'message' => '最高年龄不能小最低年龄',
+                    ]);
+                    return back()->with(compact('error'));
+                }
+            }
+
+            if ($form->wage == -1) {
+                $form->wage_min = 0;
+                $form->wage_max = 0;
+                $form->wage_cn = '面议';
+            } else {
+                if ($form->wage!=0) {
+                    $wage = explode('~', format_wage(get_category($form->wage)));
+                    if (isset($wage[1])) {
+                        $form->wage_max = $wage[1];
+                        $form->wage_cn = $wage[0].'~'.$wage[1].'/月';
+                    }else{
+                        $form->wage_min = $wage[0];
+                        $form->wage_cn = $wage[0].'以上/月';
+                    }
+                } else {
+                    if ($form->wage_min == 0 || $form->wage_max == 0) {
+                        $error = new MessageBag([
+                            'title' => '提示',
+                            'message' => '最低薪资和最高薪资不能为0',
+                        ]);
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->wage_min < config('aix.companyset.comset.com_set.wage_min')) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '最低薪资请填写大于'.config('aix.companyset.comset.com_set.wage_min'),
+                        ]);
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->wage_min%10 != 0) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '薪资请填写10的倍数',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->wage_max%10 != 0) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '薪资请填写10的倍数',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    if (isset($form->wage_max) && $form->wage_max && $form->wage_max < $form->wage_min) {
+                        $error = new MessageBag([
+                            'title' => '提示',
+                            'message' => '最高薪资不能低于最低薪资',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    $form->wage_cn = $form->wage_min.'~'.$form->wage_max.'/月';
+                }
+            }
+            if ($form->min_age && $form->min_age < 16) {
+                $error = new MessageBag([
+                    'title'   => '提示',
+                    'message' => '最低年龄不能小于16岁',
+                ]);
+
+                return back()->with(compact('error'));
+            }
+            $tag = Input::get('tag');
+            $tag = array_filter($tag);
+            if(count($tag) > 6){
+                $error = new MessageBag([
+                    'title'   => '提示',
+                    'message' => '职位亮点最多可选择6个',
+                ]);
+                return back()->with(compact('error'));
+            }
+            if ($form->max_age && $form->min_age > 65) {
+                $error = new MessageBag([
+                    'title'   => '提示',
+                    'message' => '最高年龄不能大于65岁',
+                ]);
+
+                return back()->with(compact('error'));
+            }
+            $hour_money = Input::get('hour_money');
+            if (($form->ygxs == 363) && $hour_money == "") {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '请填写小时工薪资',
+                ]);
+                return back()->with(compact('error'));
+            }
+
+            if ($form->ygxs == 363 && $hour_money < 16.5) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '小时工薪资不能少于16.5元',
+                ]);
+                return back()->with(compact('error'));
+            }
+
+            if (($form->syq != 367 && $form->wage != -1)&& $form->syqxz_min == 0) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '试用期薪资不能为0',
+                ]);
+                return back()->with(compact('error'));
+            }
+            if (($form->syq != 367 && $form->wage != -1) && $form->syqxz_min % 10 != 0) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '试用期薪资请填写10的倍数',
+                ]);
+
+                return back()->with(compact('error'));
+            }
+
+            if (($form->syq != 367 && $form->wage != -1) && $form->syqxz_min < config('aix.companyset.comset.com_set.wage_min')) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '试用期薪资请填写大于' . config('aix.companyset.comset.com_set.wage_min'),
+                ]);
+                return back()->with(compact('error'));
+            }
+            if ($form->wage != 0) {
+                $wage = explode('~', format_wage(get_category($form->wage)));
+                if (isset($wage[1])) {
+                    $form->wage_max = $wage[1];
+                }
+                $form->wage_min = $wage[0];
+            }
+            if($form->wage_min > 0 && ($form->syq != 367 && $form->wage != -1) && $form->ygxs != 363){
+                if($form->syqxz_min < $form->wage_min * 0.8){
+                    $error = new MessageBag([
+                        'title' => '提示',
+                        'message' => '试用期薪资不能低于最低工资的80%('.$form->wage_min * 0.8.'元)',
+                    ]);
+                    return back()->with(compact('error'));
+                }
+            }
+            if ($form->ygxs == 363) {
+                $form->wage = 0;
+                $form->wage_max = $hour_money;
+                $form->wage_min = $hour_money;
+                $form->wage_cn = $hour_money.'/小时';
+            }
+        });
+        $form->ignore('hour_money');
+        $form->saved(function (Form $form) use ($id) {
+            $province = \Illuminate\Support\Facades\Request::input('province');
+            $city = \Illuminate\Support\Facades\Request::input('city');
+            $area = \Illuminate\Support\Facades\Request::input('area');
+            $age[] = \Illuminate\Support\Facades\Request::input('min_age');
+            $age[] = \Illuminate\Support\Facades\Request::input('max_age');
+            $age = implode('-', $age);
+            $nature_cn = get_category(\Illuminate\Support\Facades\Request::input('nature'));
+            $sex_cn = \Illuminate\Support\Facades\Request::input('sex') == 0 ? '不限' : (\Illuminate\Support\Facades\Request::input('sex') == 1 ? '男' :'女');
+            $education_cn = get_category(\Illuminate\Support\Facades\Request::input('education'));
+            $experience_cn = get_category(\Illuminate\Support\Facades\Request::input('experience'));
+            $district = $province.'.'.$city.'.'.$area;
+            JobfairJob::where('id', $id)->update([
+                'district'=>$district,
+                'age'=>$age,
+                'wage_cn'=>$form->wage_cn,
+                'nature_cn'=>$nature_cn,
+                'sex_cn'=>$sex_cn,
+                'education_cn'=>$education_cn,
+                'experience_cn'=>$experience_cn,
+            ]);
+
+            $tag = \Illuminate\Support\Facades\Request::input('tag');
+            if ($tag) {
+                $tag = array_filter($tag);
+                $tag = implode(',', $tag);
+                JobfairJob::where('id', $id)->update(['tag'=>$tag,'tag_cn'=>get_tag_cn($tag)]);
+            }
+
+            //修改参展职位(审核时同步 暂且注释)
+//            $put_jobs = JobfairPutJob::whereHas('jobfairs',function ($query){
+//                $query->where('holddate_end','>=',time());
+//            })->where(['job_id'=>$id])->get();
+//            //修改参展职位
+//            if($put_jobs->isNotEmpty()){
+//                $jobfairJob = JobfairJob::find($id);
+//                foreach ($put_jobs as $val){
+//                    $val['jobs_name'] = $jobfairJob['jobs_name'];
+//                    $val['company_id'] = $jobfairJob['company_id'];
+//                    $val['company_name'] = $jobfairJob['company_name'];
+//                    $val['company_audit'] = $jobfairJob['company_audit'];
+//                    $val['stick'] = $jobfairJob['stick'];
+//                    $val['nature'] = $jobfairJob['nature'];
+//                    $val['nature_cn'] = $jobfairJob['nature_cn'];
+//                    $val['sex'] = $jobfairJob['sex'];
+//                    $val['sex_cn'] = $jobfairJob['sex_cn'];
+//                    $val['age'] = $jobfairJob['age'];
+//                    $val['amount'] = $jobfairJob['amount'];
+//                    $val['topclass'] = $jobfairJob['topclass'];
+//                    $val['category'] = $jobfairJob['category'];
+//                    $val['subclass'] = $jobfairJob['subclass'];
+//                    $val['category_cn'] = $jobfairJob['category_cn'];
+//                    $val['trade'] = $jobfairJob['trade'];
+//                    $val['trade_cn'] = $jobfairJob['trade_cn'];
+//                    $val['scale'] = $jobfairJob['scale'];
+//                    $val['scale_cn'] = $jobfairJob['scale_cn'];
+//                    $val['district'] = $jobfairJob['district'];
+//                    $val['district_cn'] = $jobfairJob['district_cn'];
+//                    $val['tag'] = $jobfairJob['tag'];
+//                    $val['tag_cn'] = $jobfairJob['tag_cn'];
+//                    $val['education'] = $jobfairJob['education'];
+//                    $val['education_cn'] = $jobfairJob['education_cn'];
+//                    $val['experience'] = $jobfairJob['experience'];
+//                    $val['experience_cn'] = $jobfairJob['experience_cn'];
+//                    $val['wage'] = $jobfairJob['wage'];
+//                    $val['wage_min'] = $jobfairJob['wage_min'];
+//                    $val['wage_max'] = $jobfairJob['wage_max'];
+//                    $val['wage_cn'] = $jobfairJob['wage_cn'];
+//                    $val['audit'] = $jobfairJob['audit'];
+//                    $val['display'] = $jobfairJob['display'];
+//                    $val['click'] = $jobfairJob['click'];
+//                    $val['robot'] = $jobfairJob['robot'];
+//                    $val['map_x'] = $jobfairJob['map_x'];
+//                    $val['map_y'] = $jobfairJob['map_y'];
+//                    $val['map_zoom'] = $jobfairJob['map_zoom'];
+//                    $val['add_mode'] = $jobfairJob['add_mode'];
+//                    $val['is_entrust'] = $jobfairJob['is_entrust'];
+//                    $val['department'] = $jobfairJob['department'];
+//                    $val['major'] = $jobfairJob['major'];
+//                    $val['major_cn'] = $jobfairJob['major_cn'];
+//                    $val['zcid'] = $jobfairJob['zcid'];
+//                    $val['zc_cn'] = $jobfairJob['zc_cn'];
+//                    $val['zc_name'] = $jobfairJob['zc_name'];
+//                    $val->save();
+//                }
+//            }
+        });
+        //自定义时间筛选JS
+        $filter_script = <<<SCRIPT
+        let wage_min_value = $(".wage_min_value").val();
+        let ygxs_select = $("select[name='ygxs']");
+        if(ygxs_select.val()==363){
+             $("#wage_min").val(wage_min_value);
+             $("#hour_money").parent().parent().parent().show();
+             $("select[name='wage']").parent().parent().hide();
+             $("#wage_min").parent().parent().parent().hide();
+             $("#wage_max").parent().parent().parent().hide();
+             $("select[name='syq']").parent().parent().hide();
+             $("#syqxz_min").parent().parent().parent().hide();
+        }else{
+            $("#hour_money").parent().parent().parent().hide();
+            $("#wage_min").parent().parent().parent().show();
+            $("#wage_max").parent().parent().parent().show();
+            $("select[name='syq']").parent().parent().show();
+            $("#syqxz_min").parent().parent().parent().show();
+        }
+          
+        ygxs_select.on('change',function(){
+            if($(this).val() == 363){
+                $("#hour_money").parent().parent().parent().show();
+                $("select[name='wage']").parent().parent().hide();
+                $("#wage_min").parent().parent().parent().hide();
+                $("#wage_max").parent().parent().parent().hide();
+                $("select[name='syq']").parent().parent().hide();
+                $("#syqxz_min").parent().parent().parent().hide();
+                $("#hour_money").val(0);
+            }else{
+                $("#hour_money").parent().parent().parent().hide();
+                $("select[name='wage']").parent().parent().show();
+                $("#wage_min").parent().parent().parent().show();
+                $("#wage_max").parent().parent().parent().show();
+                $("select[name='syq']").parent().parent().show();
+                $("#hour_money").val(0);
+                $("#wage_min").val(wage_min_value);
+                $("#wage_max").val(0);
+            }
+        });
+        
+        let syq_select = $("select[name='syq']");
+        let wage_select = $("select[name='wage']");
+        if(syq_select.val()==367 || wage_select.val()==-1){
+        
+            $("#syqxz_min").val(wage_min_value);
+            $("#syqxz_min").parent().parent().parent().hide();
+        }else{
+            if(ygxs_select.val() != 363){
+                $("#syqxz_min").parent().parent().parent().show();
+            }
+        }   
+        syq_select.on('change',function(){
+            if($(this).val() == 367 || wage_select.val() == -1){
+                $("#syqxz_min").val(wage_min_value);
+                $("#syqxz_min").parent().parent().parent().hide();
+            }else{
+                if(ygxs_select.val() != 363){
+                    $("#syqxz_min").parent().parent().parent().show();
+                }
+            }
+        });
+         wage_select.on('change',function(){
+            if($(this).val() == -1){
+                $("#syqxz_min").val(wage_min_value);
+                $("#syqxz_min").parent().parent().parent().hide();
+            }else{
+                if(ygxs_select.val() != 363){
+                    $("#syqxz_min").parent().parent().parent().show();
+                }
+            }
+        });
+
+SCRIPT;
+        Admin::script($filter_script);
+
+        return $form;
+    }
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new JobfairJob);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+    public function auditJobs(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('jobfairjobs.auditr'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '审核')->options([1=>'审核通过',3=>'审核未通过'])->default(1);
+        $form->textarea('remark', '备注');
+        $form->html('<label style="color: grey">职位库审核不再同步已结束招聘会的参会职位,请及时审核!</label>');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核职位']);
+    }
+
+    public function auditR(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $remark = $request->remark;
+        $pms_notice = $request->pms_notice;
+        $arr = array_filter(explode(',', $id));
+        if (empty($id)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $result = JobfairJob::whereIn('id', $arr)->update(['audit'=>$audit]);
+        if($audit == 1){
+            //同步参展职位
+            $put_jobs = JobfairPutJob::whereHas('jobfairs',function ($query){
+                $query->where('holddate_end','>=',time());
+            })->whereIn('job_id',$arr)->get();
+            if($put_jobs->isNotEmpty()){
+                foreach ($put_jobs as $val){
+                    $jobfairJob = JobfairJob::find($val->job_id);
+                    $val['jobs_name'] = $jobfairJob['jobs_name'];
+                    $val['company_id'] = $jobfairJob['company_id'];
+                    $val['company_name'] = $jobfairJob['company_name'];
+                    $val['company_audit'] = $jobfairJob['company_audit'];
+                    $val['stick'] = $jobfairJob['stick'];
+                    $val['nature'] = $jobfairJob['nature'];
+                    $val['nature_cn'] = $jobfairJob['nature_cn'];
+                    $val['sex'] = $jobfairJob['sex'];
+                    $val['sex_cn'] = $jobfairJob['sex_cn'];
+                    $val['age'] = $jobfairJob['age'];
+                    $val['amount'] = $jobfairJob['amount'];
+                    $val['topclass'] = $jobfairJob['topclass'];
+                    $val['category'] = $jobfairJob['category'];
+                    $val['subclass'] = $jobfairJob['subclass'];
+                    $val['category_cn'] = $jobfairJob['category_cn'];
+                    $val['trade'] = $jobfairJob['trade'];
+                    $val['trade_cn'] = $jobfairJob['trade_cn'];
+                    $val['scale'] = $jobfairJob['scale'];
+                    $val['scale_cn'] = $jobfairJob['scale_cn'];
+                    $val['district'] = $jobfairJob['district'];
+                    $val['district_cn'] = $jobfairJob['district_cn'];
+                    $val['tag'] = $jobfairJob['tag'];
+                    $val['tag_cn'] = $jobfairJob['tag_cn'];
+                    $val['education'] = $jobfairJob['education'];
+                    $val['education_cn'] = $jobfairJob['education_cn'];
+                    $val['experience'] = $jobfairJob['experience'];
+                    $val['experience_cn'] = $jobfairJob['experience_cn'];
+                    $val['wage'] = $jobfairJob['wage'];
+                    $val['wage_min'] = $jobfairJob['wage_min'];
+                    $val['wage_max'] = $jobfairJob['wage_max'];
+                    $val['wage_cn'] = $jobfairJob['wage_cn'];
+                    $val['negotiable'] = $jobfairJob['negotiable'];
+                    $val['audit'] = $jobfairJob['audit'];
+                    $val['display'] = $jobfairJob['display'];
+                    $val['click'] = $jobfairJob['click'];
+                    $val['robot'] = $jobfairJob['robot'];
+                    $val['map_x'] = $jobfairJob['map_x'];
+                    $val['map_y'] = $jobfairJob['map_y'];
+                    $val['map_zoom'] = $jobfairJob['map_zoom'];
+                    $val['add_mode'] = $jobfairJob['add_mode'];
+                    $val['is_entrust'] = $jobfairJob['is_entrust'];
+                    $val['department'] = $jobfairJob['department'];
+                    $val['major'] = $jobfairJob['major'];
+                    $val['major_cn'] = $jobfairJob['major_cn'];
+                    $val['zcid'] = $jobfairJob['zcid'];
+                    $val['zc_cn'] = $jobfairJob['zc_cn'];
+                    $val['zc_name'] = $jobfairJob['zc_name'];
+                    $val['syq'] = $jobfairJob['syq'];
+                    $val['syqxz_min'] = $jobfairJob['syqxz_min'];
+                    $val['ygxs'] = $jobfairJob['ygxs'];
+                    $val['techlevel'] = $jobfairJob['techlevel'];
+                    $val->save();
+                }
+            }
+            $cache_jobs = JobfairPutJob::whereIn('job_id', $arr)->whereHas('jobfairs',function ($query){
+                $query->where([
+                    ['holddate_start', '<', strtotime("+60 minute")],
+                    ['holddate_end', '>', time()]
+                ]);
+            })->get();
+            foreach ($cache_jobs as $v){
+                Cache::put($v->jobfair_id.'-'.$v->company_id, time(),72000);
+            }
+
+        }
+        $data=[];
+        foreach ($arr as $k => $v) {
+            $data[$k]['type'] = 11;
+            $data[$k]['type_id'] = $v;
+            $data[$k]['status'] = $audit;
+            $data[$k]['reason'] = $remark;
+            $data[$k]['audit_man'] = Admin::user()->username;
+            $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+            $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        AuditReason::insert($data);
+        if ($pms_notice) {
+            if ($audit==3) {
+                $stat='审核不通过';
+            } elseif ($audit==1) {
+                $stat = '审核通过';
+            } else {
+                $stat='待审核';
+            }
+            $reus=JobfairJob::whereIn('id', $arr)->get();
+            $ds = [];
+            foreach ($reus as $k => $v) {
+                $ds[$k]['utype'] = 1;
+                $ds[$k]['msgtype'] = 1;
+                $ds[$k]['msgfromuid'] = Admin::user()->id;
+                $ds[$k]['msgfrom'] = Admin::user()->username;
+                $ds[$k]['msgtoname'] = $v->company_name ? $v->company_name : 'admin';
+                $ds[$k]['msgtouid'] = $v->company_id ? $v->company_id : 0;
+                $ds[$k]['message'] =  $remark ? '招聘会职位(id:'.array_values($arr)[$k].')'.$stat.'<备注:'.$remark.'>' : '招聘会职位(id:'.array_values($arr)[$k].')'.$stat;
+                $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+            }
+            Pms::insert($ds);
+        }
+        if ($result) {
+            admin_toastr('审核成功', 'success');
+        } else {
+            admin_toastr('审核失败', 'error');
+        }
+        return back();
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的职位', 'error');
+        }
+        \DB::beginTransaction();
+        try {
+            JobfairoutPutJob::whereIn('job_id', $ids)->delete();
+            JobfairPutJob::whereIn('job_id', $ids)->delete();
+            JobfairJob::whereIn('id', $ids)->delete();
+            JobfairJobsContact::whereIn('pid', $ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 195 - 0
app/Admin/Controllers/Jobfair/JobfairManagementController.php

@@ -0,0 +1,195 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\Jobfair\JobfairManagement;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class JobfairManagementController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('招聘会分类')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('招聘会分类详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('招聘会分类编辑')
+            ->description('')
+            ->body($this->editForm()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('招聘会分类创建')
+            ->description('')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairManagement);
+        $grid->model()->orderBy('id', 'desc');
+        $grid->name('名称')->width(200);
+        $grid->created_at('创建时间');
+        $grid->updated_at('更新时间');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('jobfair_type_manager_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('jobfair_type_manager_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('jobfair_type_manager_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->like('name', '分类名称');
+        });
+        if (Admin::user()->can('jobfair_type_manager_create')) {
+            $grid->disableCreateButton(false);
+        }
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairManagement::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->name('名称');
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new JobfairManagement);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm()
+    {
+        $form = new Form(new JobfairManagement);
+        $form->text('name', '名称')->rules([
+            'required',
+        ]);
+        $form->number('order_list', '排序')->min(0)->help('数字越大,越靠前!');
+
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new JobfairManagement);
+        $form->text('name', '名称')->rules([
+            'required',
+        ])->setMustMark();
+        $form->number('order_list', '排序')->min(0)->help('数字越大,越靠前!');
+        return $form;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param int $id
+     *
+     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+}

+ 94 - 0
app/Admin/Controllers/Jobfair/JobfairPersonSignedsController.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\Jobfair\JobfairPersonSigned;
+use App\Models\Jobfair\Jobfair;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class JobfairPersonSignedsController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('个人签到列表')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairPersonSigned);
+
+        $grid->id('ID');
+        $grid->column('jobfair.title', '招聘会名称')->width(200);
+        $grid->column('resumes.fullname', '签到人')->width(200);
+        $grid->type('类型')->display(function ($type) {
+            if ($type==1) {
+                return '进场';
+            } else {
+                return '出场';
+            }
+        });
+        $grid->utype('身份')->display(function ($utype) {
+            if ($utype==1) {
+                return '企业';
+            } else {
+                return '个人';
+            }
+        });
+        $grid->sign_type('签到类型')->display(function ($sign_type) {
+            switch ($sign_type){
+                case 0:
+                    return '未知';
+                case 1:
+                    return '身份证';
+                case 2:
+                    return '二维码';
+            }
+        });
+        $grid->created_at('进出时间');
+        $grid->disableRowSelector();
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('type', '类型')->select([
+                    1  => '进场',
+                    2  => '出场',
+                ]);
+                $filter->equal('jobfair_id', '招聘会')->select(Jobfair::select('title', 'id')->pluck('title', 'id')->all());
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('resumes.fullname', '	签到人');
+            });
+            $filter->equal('sign_type', '签到类型')->select([
+                0  => '未知',
+                1  => '身份证',
+                2  => '二维码',
+            ]);
+        });
+        $grid->disableActions();
+        return $grid;
+    }
+
+
+}

+ 396 - 0
app/Admin/Controllers/Jobfair/JobfairPutJobsController.php

@@ -0,0 +1,396 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfair;
+
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Company;
+use App\Models\Jobfair\Jobfair;
+use App\Models\Jobfair\JobfairJob;
+use App\Models\Jobfair\JobfairPutJob;
+use App\Models\Pms;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use App\Admin\Exports\Jobfair\PutJobsExport;
+use Illuminate\Support\Facades\Cache;
+
+class JobfairPutJobsController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content,Request $request)
+    {
+        $company_id = isset($request->company_id) ? $request->company_id : false;
+        $grid=$this->grid($company_id)->render();
+        return $content
+            ->header('参会职位')
+            ->description('')
+            ->body(view('admin.jobfair.put_jobs')->with(['grid'=>$grid]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('参会职位详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('参会职位编辑')
+            ->description('')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('参会职位创建')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid($company_id)
+    {
+        $grid = new Grid(new JobfairPutJob);
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('jobfair_company',function($query){
+                $query->whereHas('subsites', function ($query) {
+                    $query->where('subsite_id', get_subsite_id())->where('subsites.effective', 1);
+                });
+            });
+        })
+            ->when($company_id==true,function ($query) use ($company_id){
+                $query->where('company_id',$company_id);
+            })->whereHas('jobs')
+            ->orderBy('jobfair_id', 'desc')
+            ->orderBy('updated_at', 'desc');
+
+        $grid->jobs_name('职位名称')->display(function ($jobs_name) {
+            return '<a href="'.route('jobfair.show.quarters',$this->id) .'" target="_blank">'.$jobs_name.'</a>';
+        })->width(200);
+        $grid->company_name('发布公司')->display(function ($company_name) {
+            return '<a href="'. route('jobs.company',['id'=>$this->company_id]).'" target="_blank">'.$company_name.'</a>';
+        })->width(200);
+        $grid->column('jobfairs.title', '招聘会标题')->display(function ($title) {
+            return "<a href='".  route('jobfair.show.com',$this->jobfair_id)."' target='_blank'>".$title."</a>";
+        })->width(200);
+        $grid->audit('审核状态')->display(function () {
+            if ($this->jobs->audit==1) {
+                return'<span style="color: #009900">审核通过</span>';
+            } elseif ($this->jobs->audit==3) {
+                return'<span style="color:#666666">审核未通过</span>';
+            } else {
+                return'<span style="color:#FF6600">等待审核</span>';
+            }
+        });
+        $grid->amount('人数')->display(function ($amount){
+            return $amount ? $amount : '若干';
+        });
+        $grid->district_cn('工作地区')->width(150);
+        if(get_subsite_open()){
+            $grid->column('jobfairs.subsite_id', '所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            });
+        }
+        $grid->created_at('创建时间');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('jobfair_put_jobs_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('jobfair_put_jobs_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        if (Admin::user()->can('jobfair_put_jobs_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new PutJobsExport()); //传入自己在第1步创建的导出类
+        }
+
+//        $grid->tools(function ($tools) {
+//            if (Admin::user()->can('jobfair_put_jobs_audit')) {
+//                $but = <<<EOT
+//<div class="btn-group" data-toggle="buttons">
+//    <label class="btn btn-google btn-sm" id="Audit_Put_Jobs" title="审核职位">
+//        <i class="fa fa-audio-description"></i>
+//        <input type="radio" class="user-gender">审核职位
+//    </label>
+//</div>
+//EOT;
+//                $tools->append($but);
+//            }
+//        });
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('jobs_name', '职位名称');
+                $filter->equal('jobfair_id', '招聘会')->select(Jobfair::select('title', 'id')->when(get_subsite_id()>0,function ($query){
+                    $query->whereHas('subsites', function ($query) {
+                        $query->where('subsite_jobfairs.subsite_id', get_subsite_id())->where('subsites.effective', 1);
+                    });
+                })->pluck('title', 'id')->all());
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '刷新时间', 'updated_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+                if(get_subsite_id() == 0 && get_subsite_open()){
+                    $filter->equal('jobfairs.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('company_name', '公司名称');
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 1:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('audit',1);
+                            });
+                            break;
+                        case 2:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('audit',2);
+                            });
+                            break;
+                        case 3:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('audit',3);
+                            });
+                            break;
+                    }
+                }, '审核状态', 'audit')->select([
+                    1=>'审核通过',
+                    2=>'等待审核',
+                    3=>'审核未通过',
+                ]);
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 1:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('display','1')->where('audit',1);
+                            });
+                            break;
+                        case 2:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('display','2')->orWhere('audit','<>',1);
+                            });
+                            break;
+                    }
+                }, '显示状态', 'display')->select([
+                    1=>'显示',
+                    2=>'关闭',
+                ]);
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairPutJob::findOrFail($id));
+
+        $show->id('ID');
+        $show->jobs_name('职位名称')->as(function ($jobs_name) {
+            return $jobs_name;
+        });
+        $show->company_name('发布公司')->as(function ($company_name) {
+            return $company_name;
+        });
+        $show->jobfairs()->title('招聘会标题')->as(function ($jobfairs) {
+            return $jobfairs->title;
+        });
+
+        $show->audit('审核状态')->as(function () {
+            if ($this->jobs->audit==1) {
+                return '审核通过';
+            } elseif ($this->jobs->audit==3) {
+                return '审核未通过';
+            } else {
+                return '等待审核';
+            }
+        });
+
+        $show->display('显示状态')->as(function () {
+            if ($this->jobs->audit==1 && $this->jobs->display==1) {
+                return '显示';
+            } else {
+                return '关闭';
+            }
+        });
+        $show->amount('人数')->as(function ($amount) {
+            return $amount;
+        });
+        $show->district('工作地区')->as(function ($district_cn) {
+            return $district_cn;
+        });
+
+        $show->jobfairs()->subsite('所属分站')->as(function ($jobfairs) {
+            if ($jobfairs->subsite_id) {
+                $Subsite = Subsite::find($jobfairs->subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+        $show->jobs_content('职位描述')->setEscape(false);
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new JobfairPutJob);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+    public function auditPutJobs(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('jobfair.auditPutR'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '审核')->options([1=>'审核通过',3=>'审核未通过'])->default(1);
+        $form->textarea('remark', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核职位']);
+    }
+
+    public function auditPutR(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $remark = $request->remark;
+        $pms_notice = $request->pms_notice;
+        $arr = array_filter(explode(',', $id));
+        if (empty($id)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $job_ids = JobfairPutJob::whereIn('id', $arr)->pluck('job_id');
+        $result = JobfairJob::whereIn('id', $job_ids)->update(['audit'=>$audit]);
+        foreach ($arr as $k => $v){
+            $job = JobfairPutJob::where('id', $v)->first();
+            Cache::put($job->jobfair_id.'-'.$job->company_id, time(),72000);
+        }
+        $data=[];
+        foreach ($arr as $k => $v) {
+            $data[$k]['type'] = 12;
+            $data[$k]['type_id'] = $v;
+            $data[$k]['status'] = $audit;
+            $data[$k]['reason'] = $remark;
+            $data[$k]['audit_man'] = Admin::user()->username;
+            $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+            $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        AuditReason::insert($data);
+        if ($pms_notice) {
+            if ($audit==3) {
+                $stat='审核不通过';
+            } elseif ($audit==1) {
+                $stat = '审核通过';
+            } else {
+                $stat='待审核';
+            }
+            $reus=JobfairPutJob::whereIn('id', $arr)->get();
+            $ds = [];
+            foreach ($reus as $k => $v) {
+                $ds[$k]['utype'] = 1;
+                $ds[$k]['msgtype'] = 1;
+                $ds[$k]['msgfromuid'] = Admin::user()->id;
+                $ds[$k]['msgfrom'] = Admin::user()->username;
+                $ds[$k]['msgtoname'] = $v->company_name ? $v->company_name : 'admin';
+                $ds[$k]['msgtouid'] = $v->company_id ? $v->company_id : 0;
+                $ds[$k]['message'] =  $remark ? '参会职位(id:'.array_values($arr)[$k].')'.$stat.'<备注:'.$remark.'>' : '参会职位(id:'.array_values($arr)[$k].')'.$stat;
+                $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+            }
+            Pms::insert($ds);
+        }
+        if ($result) {
+            admin_toastr('审核成功', 'success');
+        } else {
+            admin_toastr('审核失败', 'error');
+        }
+        return back();
+    }
+}

+ 803 - 0
app/Admin/Controllers/Jobfairout/JobfairJobController.php

@@ -0,0 +1,803 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: ZhangHao
+ * Date: 2019/6/19
+ * Time: 14:57
+ */
+
+namespace App\Admin\Controllers\Jobfairout;
+
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Category;
+use App\Models\CategoryDistrict;
+use App\Models\CategoryJobs;
+use App\Models\CategoryMajor;
+use App\Models\Jobfair\JobfairJob;
+use App\Models\Jobfair\JobfairJobsContact;
+use App\Models\Jobfair\JobfairPutJob;
+use App\Models\Jobfairout\JobfairoutPutJob;
+use App\Models\Pms;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Support\MessageBag;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Input;
+class JobfairJobController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('招聘会职位库')
+            ->description('')
+            ->body(view('admin.jobfairout.jobs')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('招聘会职位详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        $js = <<<ETO
+        $(document).ready(function() {
+             $('.radio-inline,.iCheck-helper').click(function() {
+                var val = $(this).closest(".radio-inline").find("input:radio").val();
+                 if (val == '0') {
+                    $("input[name=wage]").parents('.form-group').hide();
+                 }
+                 else if (val == '1') {
+                    $("input[name=wage]").parents('.form-group').show();
+                 }
+            });
+        });
+ETO;
+        Admin::script($js);
+        return $content
+            ->header('招聘会职位编辑')
+            ->description('')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairJob);
+        $grid->model()
+            ->with('company')
+            ->where('type',2)
+            ->when(get_subsite_id()>0, function ($query) {
+                $query->whereHas('company', function ($query) {
+                    $query->where('companys.subsite_id', get_subsite_id());
+                });
+            })
+            ->orderByRaw("FIELD(audit, 2,1,3)")->orderBy('updated_at', 'desc');
+
+        $grid->jobs_name('职位名称')->width(200);
+        $grid->company_name('发布公司')->display(function ($company_name) {
+            return '<a href="'.route('jobs.company',['id'=>$this->company_id]).'" target="_blank">'.$company_name.'</a>';
+        })->width(200);
+        $grid->audit('审核状态')->display(function ($audit) {
+            if ($audit==1) {
+                return'<span style="color: #009900">审核通过</span>';
+            } elseif ($audit==3) {
+                return'<span style="color:#666666">审核未通过</span>';
+            } else {
+                return'<span style="color:#FF6600">等待审核</span>';
+            }
+        });
+
+        $grid->amount('人数')->display(function ($amount) {
+            return $amount ? $amount : '若干';
+        });
+        $grid->sex_cn('性别');
+        $grid->education_cn('学历')->display(function ($education_cn) {
+            return $education_cn ? $education_cn : '不限';
+        });
+        $grid->wage_cn('待遇')->width(100);
+        $grid->district_cn('工作地区');
+        if(get_subsite_open()){
+            $grid->subsite('所属分站')->display(function () {
+                if(isset($this->company->subsites)){
+                    return $this->company->subsites->sitename;
+                }else{
+                    return '总站';
+                }
+            });
+        }
+        $grid->created_at('创建时间');
+        $grid->updated_at('更新时间');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('jobfairout_jobs_delete')) {
+                $actions->disableDelete(false);
+            }
+            if (Admin::user()->can('jobfairout_jobs_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('company_manager_bussiness')) {
+                $actions->append("<button class='btn btn-primary btn-xs business' id=" . $actions->row['company_id'] . ">业务</button>");
+            }
+            if (Admin::user()->can('jobfairout_jobs_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+        });
+
+        if (Admin::user()->can('jobfairout_jobs_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('jobfairout_jobs_audit')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="Audit_Jobs" title="审核职位">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">审核职位
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('jobs_name', '职位名称');
+                $filter->like('company_name', '公司名称');
+                $filter->equal('sex', '性别')->select([
+                    0=>'不限',
+                    1=>'男',
+                    2=>'女',
+                ]);
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('audit', '审核状态')->select([
+                    1=>'审核通过',
+                    2=>'等待审核',
+                    3=>'审核未通过',
+                ]);
+
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '刷新时间', 'updated_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairJob::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->jobs_name('职位名称');
+        $show->company_name('发布公司')->as(function ($company_name) {
+            return $company_name;
+        });
+        $show->audit('审核状态')->as(function ($audit) {
+            if ($audit==1) {
+                return '审核通过';
+            } elseif ($audit==3) {
+                return '审核未通过';
+            } else {
+                return '等待审核';
+            }
+        });
+        $show->display('显示状态')->as(function ($audit) {
+            if ($audit==1) {
+                return '显示';
+            } else {
+                return '关闭';
+            }
+        });
+        $show->amount('人数');
+        $show->sex_cn('性别');
+        $show->education_cn('学历');
+        $show->wage_cn('待遇');
+        $show->district_cn('工作地区');
+        $show->jobs_content('职位描述')->setEscape(false);
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    protected function editForm($id)
+    {
+        $form = new Form(new JobfairJob);
+        $form->tab('职位信息', function (Form $form) use ($id) {
+            $form->display('id');
+            $jobsData = JobfairJob::where('id', $id)->select('major', 'age', 'tag', 'topclass', 'category', 'subclass', 'district', 'wage', 'wage_min', 'wage_max','syq','syqxz_min','ygxs','updated_at')->first()->toArray();
+            $age = explode('-', $jobsData['age']);
+            if ($jobsData['district']) {
+                $district = string_to_array('.', $jobsData['district']);
+            }
+            $form->text('jobs_name', '职位名称')->rules(['required'], ['required'=>'请填写职位名称'])->setMustMark();
+            $form->display('company_name', '企业名称');
+            $form->radio('audit', '审核状态')->options([0=>'未审核',1=>'审核通过',2=>'审核中',3=>'审核未通过']);
+            $jobsNature = Category::categoryType('AIX_jobs_nature');
+            $form->radio('nature', '职位性质')->options($jobsNature);
+
+            $form->select('ygxs', '用工形式')->options(Category::categoryType('AIX_ygxs'))->rules(['required'], ['required' => '请填写用工形式',])->setMustMark();
+            $form->text('hour_money', '小时工薪资')->default($jobsData['wage_min'])->setMustMark();
+            $form->hidden('wage_min_value', '系统最低工资')->default(config('aix.companyset.comset.com_set.wage_min'));
+            $techlevel = Category::categoryType('AIX_techlevel');
+            $techlevel['0'] = '不限';
+            $form->select('techlevel', '技能等级')->options($techlevel)->setMustMark();
+
+            $form->select('topclass', '职位大类')->options(CategoryJobs::List()->pluck('name', 'id'))->load('category', admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位大类'))->setMustMark();
+            $form->select('category', '职位中类')->options(CategoryJobs::category($jobsData['topclass']))->load('subclass', admin_base_path('/sys/categoryJobs/category'))->rules('required', array('required'=>'请选择职位中类'))->setMustMark();
+            $form->select('subclass', '职位小类')->options(CategoryJobs::category($jobsData['category']))->rules('required', array('required'=>'请选择职位小类'))->setMustMark();
+            $senior = '';
+            if($jobsData['major']){
+                $senior = CategoryMajor::where('id',$jobsData['major'])->value('parent_id');
+            }
+            $form->select('parent_major', '专业大类')->options(CategoryMajor::pluck('name', 'id')->toArray())->load('major', admin_base_path('/sys/category/categoryMaj'))->rules('required', array('required'=>'请选择专业大类'))->default($senior)->setMustMark();
+            $form->select('major', '专业小类')->options(CategoryMajor::category($senior))->rules('required', array('required'=>'请选择专业小类'))->setMustMark();
+            if (!empty($district)) {
+                $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default($district[0])->setMustMark();
+                $form->select('city', '所属城市')->options(CategoryDistrict::categoryDis($district[0]))->setWidth(3)->load('area', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default($district[1])->setMustMark();
+                $form->select('area', '所属县区')->default(isset($district[2])?$district[2]:0)->options(CategoryDistrict::categoryDis($district[1]))->setWidth(3)->default(isset($district[2]) ? $district[2] : '')->setMustMark();
+            } else {
+                $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属省份'])->default(0)->setMustMark();
+                $form->select('city', '所属城市')->setWidth(3)->load('area', admin_base_path('/sys/category/categoryDis'))->rules('required', ['required'=>'请选择相应的企业所属城市'])->default(0)->setMustMark();
+                $form->select('area', '所属县区')->setWidth(3)->default(0)->setMustMark();
+            }
+            if ($jobsData['wage'] == 0) {
+                $form->hidden('wage');
+                $form->number('wage_min', '最低薪资')->min(config('aix.companyset.comset.com_set.wage_min'))->help("请填写大于".config('aix.companyset.comset.com_set.wage_min')."的10的倍数")
+                    ->rules(['required'], ['required'=>'请选择最小薪资'])->setMustMark();
+                $form->number('wage_max', '最高薪资')->help("请填写大于最低薪资的10的倍数")->rules(['required'], ['required'=>'请填写最大薪资'])->setMustMark();
+            } else {
+                $option = Category::categoryType('AIX_wage');
+                $option[-1] ='面议';
+                $form->select('wage', '薪资待遇')->options($option)->default($jobsData['wage'])->rules(['required'], ['required'=>'请选择薪资待遇'])->setMustMark();
+                $form->hidden('wage_min');
+                $form->hidden('wage_max');
+            }
+            $form->select('syq', '试用期时间')->options(Category::categoryType('zs_syq'))->default($jobsData['syq'])->setMustMark();
+            $form->number('syqxz_min', '试用期薪资')->min(config('aix.companyset.comset.com_set.wage_min'))->default($jobsData['syqxz_min'])->help("请填写大于" . config('aix.companyset.comset.com_set.wage_min') . "的10的倍数")->setMustMark();
+            $education = Category::categoryType('AIX_education');
+            $education['0']='不限';
+            $form->radio('education', '学历要求')->options($education);
+            $experience = Category::categoryType('AIX_experience');
+            $experience['0']="不限";
+            $form->radio('experience', '工作经验')->options($experience);
+            $form->radio('sex', '性别要求')->options([0=>'不限',1=>'男',2=>'女']);
+            $zcid = Category::categoryType('AIX_zhicheng');
+            $form->radio('zcid', '职称要求')->options($zcid)->rules(['required'], ['required'=>'请选择职称要求']);
+            $form->text('zc_name', '具体职称');
+            $form->number('min_age', '最低年龄')->default(isset($age[0])?$age[0]:'')->min(16)->max(65)->help('最低年龄不能低于国家规定用工年龄');
+            $form->number('max_age', '最高年龄')->default(isset($age[1])?$age[1]:'')->min(16)->max(65)->help('最高年龄不能高于65周岁');
+            $form->number('amount', '招聘人数')->min(1)->max(99)->rules(['required'], ['required'=>'请输入招聘人数'])->help('请填写招聘人数1~99')->setMustMark();
+            $form->multipleSelect('tag', '职位亮点')->options(Category::categoryType('AIX_jobtag'))->default(explode(',', $jobsData['tag']));
+            $form->textarea('jobs_content', '职位描述')->attribute(['maxlength'=>2000])->rules(['required'], ['required'=>"请填写职位描述"])->setMustMark();
+        })->tab('联系人', function (Form $form) {
+            $form->text("contact.contact", '联系人')->setWidth(3)->rules(['required'], ['required'=>"请填写联系人"])->setMustMark();
+            $form->radio('contact.contact_show', '联系人是否公开')->options([0=>'不公开',1=>'公开']);
+            $form->text('contact.mobile', '联系电话')->setWidth(3)->rules(['required'], ['required'=>"请填写联系电话"])->setMustMark();
+            $form->radio('contact.telephone_show', '联系电话是否公开')->options([0=>'不公开',1=>'公开']);
+            $form->text('contact.landline_tel', '固定电话')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)');  //这个字段引起问题
+            $form->radio('contact.landline_tel_show', '固定电话是否公开')->options([0=>'不公开',1=>'公开']);
+            $form->text('contact.email', 'Email')->setWidth(3)->rules(['required'], ['required'=>"请填写Email"])->setMustMark();
+            $form->radio('contact.email_show', 'Email是否公开')->options([0=>'不公开',1=>'公开']);
+            $form->text('contact.address', '联系地址')->setWidth(3)->rules(['required'], ['required'=>"请填写联系地址"])->setMustMark();
+        });
+        $form->ignore('province');
+        $form->ignore('city');
+        $form->ignore('area');
+        $form->ignore('tag');
+        $form->ignore('min_age');
+        $form->ignore('max_age');
+        $form->ignore('parent_major');
+        $form->ignore('wage_min_value');
+        $form->saving(function ($form) {
+            $minage = Input::get('min_age');
+            $maxage = Input::get('max_age');
+            if ($maxage && $minage) {
+                if ($maxage <= $minage) {
+                    $error = new MessageBag([
+                        'title' => '提示',
+                        'message' => '最高年龄不能小最低年龄',
+                    ]);
+                    return back()->with(compact('error'));
+                }
+            }
+            if ($form->wage == -1) {
+                $form->wage_min = 0;
+                $form->wage_max = 0;
+                $form->wage_cn = '面议';
+            } else {
+                if ($form->wage!=0) {
+                    $wage = explode('~', format_wage(get_category($form->wage)));
+                    if (isset($wage[1])) {
+                        $form->wage_max = $wage[1];
+                        $form->wage_cn = $wage[0].'~'.$wage[1].'/月';
+                    }else{
+                        $form->wage_min = $wage[0];
+                        $form->wage_cn = $wage[0].'以上/月';
+                    }
+                } else {
+                    if ($form->wage_min == 0 || $form->wage_max == 0) {
+                        $error = new MessageBag([
+                            'title' => '提示',
+                            'message' => '最低薪资和最高薪资不能为0',
+                        ]);
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->wage_min < config('aix.companyset.comset.com_set.wage_min')) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '最低薪资请填写大于'.config('aix.companyset.comset.com_set.wage_min'),
+                        ]);
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->wage_min%10 != 0) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '薪资请填写10的倍数',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    if ($form->wage_max%10 != 0) {
+                        $error = new MessageBag([
+                            'title'   => '提示',
+                            'message' => '薪资请填写10的倍数',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    if (isset($form->wage_max) && $form->wage_max && $form->wage_max < $form->wage_min) {
+                        $error = new MessageBag([
+                            'title' => '提示',
+                            'message' => '最高薪资不能低于最低薪资',
+                        ]);
+
+                        return back()->with(compact('error'));
+                    }
+                    $form->wage_cn = $form->wage_min.'~'.$form->wage_max.'/月';
+                }
+            }
+            if ($form->min_age && $form->min_age < 16) {
+                $error = new MessageBag([
+                    'title'   => '提示',
+                    'message' => '最低年龄不能小于16岁',
+                ]);
+
+                return back()->with(compact('error'));
+            }
+            $tag = Input::get('tag');
+            $tag = array_filter($tag);
+            if(count($tag) > 6){
+                $error = new MessageBag([
+                    'title'   => '提示',
+                    'message' => '职位亮点最多可选择6个',
+                ]);
+                return back()->with(compact('error'));
+            }
+            if ($form->max_age && $form->min_age > 65) {
+                $error = new MessageBag([
+                    'title'   => '提示',
+                    'message' => '最高年龄不能大于65岁',
+                ]);
+
+                return back()->with(compact('error'));
+            }
+            $hour_money = Input::get('hour_money');
+            if (($form->ygxs == 363) && $hour_money == "") {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '请填写小时工薪资',
+                ]);
+                return back()->with(compact('error'));
+            }
+
+            if ($form->ygxs == 363 && $hour_money < 16.5) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '小时工薪资不能少于16.5元',
+                ]);
+                return back()->with(compact('error'));
+            }
+
+            if (($form->syq != 367 && $form->wage != -1)&& $form->syqxz_min == 0) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '试用期薪资不能为0',
+                ]);
+                return back()->with(compact('error'));
+            }
+            if (($form->syq != 367 && $form->wage != -1) && $form->syqxz_min % 10 != 0) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '试用期薪资请填写10的倍数',
+                ]);
+
+                return back()->with(compact('error'));
+            }
+
+            if (($form->syq != 367 && $form->wage != -1) && $form->syqxz_min < config('aix.companyset.comset.com_set.wage_min')) {
+                $error = new MessageBag([
+                    'title' => '提示',
+                    'message' => '试用期薪资请填写大于' . config('aix.companyset.comset.com_set.wage_min'),
+                ]);
+                return back()->with(compact('error'));
+            }
+            if ($form->wage != 0) {
+                $wage = explode('~', format_wage(get_category($form->wage)));
+                if (isset($wage[1])) {
+                    $form->wage_max = $wage[1];
+                }
+                $form->wage_min = $wage[0];
+            }
+            if($form->wage_min > 0 && ($form->syq != 367 && $form->wage != -1) && $form->ygxs != 363){
+                if($form->syqxz_min < $form->wage_min * 0.8){
+                    $error = new MessageBag([
+                        'title' => '提示',
+                        'message' => '试用期薪资不能低于最低工资的80%('.$form->wage_min * 0.8.'元)',
+                    ]);
+                    return back()->with(compact('error'));
+                }
+            }
+            if ($form->ygxs == 363) {
+                $form->wage = 0;
+                $form->wage_max = $hour_money;
+                $form->wage_min = $hour_money;
+                $form->wage_cn = $hour_money.'/小时';
+            }
+        });
+        $form->ignore('hour_money');
+        $form->saved(function (Form $form) use ($id) {
+            $province = \Illuminate\Support\Facades\Request::input('province');
+            $city = \Illuminate\Support\Facades\Request::input('city');
+            $area = \Illuminate\Support\Facades\Request::input('area');
+            $age[] = \Illuminate\Support\Facades\Request::input('min_age');
+            $age[] = \Illuminate\Support\Facades\Request::input('max_age');
+            $age = implode('-', $age);
+            $nature_cn = get_category(\Illuminate\Support\Facades\Request::input('nature'));
+            $sex_cn = \Illuminate\Support\Facades\Request::input('sex') == 0 ? '不限' : (\Illuminate\Support\Facades\Request::input('sex') == 1 ? '男' :'女');
+            $education_cn = get_category(\Illuminate\Support\Facades\Request::input('education'));
+            $experience_cn = get_category(\Illuminate\Support\Facades\Request::input('experience'));
+            $major_cn = get_category_major(\Illuminate\Support\Facades\Request::input('major'));
+            $district = $province.'.'.$city.'.'.$area;
+            JobfairJob::where('id', $id)->update([
+                'district'=>$district,
+                'age'=>$age,
+                'wage_cn'=>$form->wage_cn,
+                'nature_cn'=>$nature_cn,
+                'sex_cn'=>$sex_cn,
+                'education_cn'=>$education_cn,
+                'experience_cn'=>$experience_cn,
+                'major_cn'=>$major_cn,
+            ]);
+
+            $tag = \Illuminate\Support\Facades\Request::input('tag');
+            if ($tag) {
+                $tag = array_filter($tag);
+                $tag = implode(',', $tag);
+                JobfairJob::where('id', $id)->update(['tag'=>$tag,'tag_cn'=>get_tag_cn($tag)]);
+            }
+        });
+        $script = <<<EOT
+        let wage_min_value = $(".wage_min_value").val();
+        let ygxs_select = $("select[name='ygxs']");
+        if(ygxs_select.val()==363){
+             $("#wage_min").val(wage_min_value);
+             $("#hour_money").parent().parent().parent().show();
+             $("select[name='wage']").parent().parent().hide();
+             $("#wage_min").parent().parent().parent().hide();
+             $("#wage_max").parent().parent().parent().hide();
+             $("select[name='syq']").parent().parent().hide();
+             $("#syqxz_min").parent().parent().parent().hide();
+        }else{
+            $("#hour_money").parent().parent().parent().hide();
+            $("#wage_min").parent().parent().parent().show();
+            $("#wage_max").parent().parent().parent().show();
+            $("select[name='syq']").parent().parent().show();
+            $("#syqxz_min").parent().parent().parent().show();
+        }
+          
+        ygxs_select.on('change',function(){
+            if($(this).val() == 363){
+                $("#hour_money").parent().parent().parent().show();
+                $("select[name='wage']").parent().parent().hide();
+                $("#wage_min").parent().parent().parent().hide();
+                $("#wage_max").parent().parent().parent().hide();
+                $("select[name='syq']").parent().parent().hide();
+                $("#syqxz_min").parent().parent().parent().hide();
+                $("#hour_money").val(0);
+            }else{
+                $("#hour_money").parent().parent().parent().hide();
+                $("select[name='wage']").parent().parent().show();
+                $("#wage_min").parent().parent().parent().show();
+                $("#wage_max").parent().parent().parent().show();
+                $("select[name='syq']").parent().parent().show();
+                $("#hour_money").val(0);
+                $("#wage_min").val(wage_min_value);
+                $("#wage_max").val(0);
+            }
+        });
+        
+        let syq_select = $("select[name='syq']");
+        let wage_select = $("select[name='wage']");
+        if(syq_select.val()==367 || wage_select.val()==-1){
+            $("#syqxz_min").val(wage_min_value);
+            $("#syqxz_min").parent().parent().parent().hide();
+        }else{
+            if(ygxs_select.val() != 363){
+                $("#syqxz_min").parent().parent().parent().show();
+            }
+        }   
+        syq_select.on('change',function(){
+            if($(this).val() == 367 || wage_select.val() == -1){
+                $("#syqxz_min").val(wage_min_value);
+                $("#syqxz_min").parent().parent().parent().hide();
+            }else{
+                if(ygxs_select.val() != 363){
+                    $("#syqxz_min").parent().parent().parent().show();
+                }
+            }
+        });
+         wage_select.on('change',function(){
+            if($(this).val() == -1){
+                $("#syqxz_min").val(wage_min_value);
+                $("#syqxz_min").parent().parent().parent().hide();
+            }else{
+                if(ygxs_select.val() != 363){
+                    $("#syqxz_min").parent().parent().parent().show();
+                }
+            }
+        });
+       $(document).ready(function() {
+        $('.zcid').on('ifCreated', function(){
+            if(true == $(this).is(':checked')){
+                var zcid = $(this).val();
+                if(zcid == 330){
+                    $('#zc_name').closest(".form-group").css('display','none');
+                }else{
+                    $('#zc_name').closest(".form-group").css('display','block');
+                }
+            }
+        });
+        $('.zcid').on('ifChecked', function(){
+            var zcid = $(this).val();
+            if(zcid == 330){
+               $('#zc_name').closest(".form-group").css('display','none');
+            }else{
+             $('#zc_name').closest(".form-group").css('display','block');
+            }
+        });
+    });
+EOT;
+        Admin::script($script);
+        return $form;
+    }
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+    public function auditJobs(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('jobfairoutjobs.auditr'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '审核')->options([1=>'审核通过',3=>'审核未通过'])->default(1);
+        $form->textarea('remark', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核职位']);
+    }
+
+    public function auditR(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $remark = $request->remark;
+        $pms_notice = $request->pms_notice;
+        $arr = array_filter(explode(',', $id));
+        if (empty($id)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $result = JobfairJob::whereIn('id', $arr)->update(['audit'=>$audit]);
+        if($audit == 1){
+            //同步参展职位
+            $put_jobs = JobfairoutPutJob::whereHas('jobfairs',function ($query){
+                $query->where('holddate_end','>=',time());
+            })->whereIn('job_id',$arr)->get();
+            if($put_jobs->isNotEmpty()){
+                foreach ($put_jobs as $val){
+                    $jobfairJob = JobfairJob::find($val->job_id);
+                    $val['jobs_name'] = $jobfairJob['jobs_name'];
+                    $val['company_id'] = $jobfairJob['company_id'];
+                    $val['company_name'] = $jobfairJob['company_name'];
+                    $val['company_audit'] = $jobfairJob['company_audit'];
+                    $val['stick'] = $jobfairJob['stick'];
+                    $val['nature'] = $jobfairJob['nature'];
+                    $val['nature_cn'] = $jobfairJob['nature_cn'];
+                    $val['sex'] = $jobfairJob['sex'];
+                    $val['sex_cn'] = $jobfairJob['sex_cn'];
+                    $val['age'] = $jobfairJob['age'];
+                    $val['amount'] = $jobfairJob['amount'];
+                    $val['topclass'] = $jobfairJob['topclass'];
+                    $val['category'] = $jobfairJob['category'];
+                    $val['subclass'] = $jobfairJob['subclass'];
+                    $val['category_cn'] = $jobfairJob['category_cn'];
+                    $val['trade'] = $jobfairJob['trade'];
+                    $val['trade_cn'] = $jobfairJob['trade_cn'];
+                    $val['scale'] = $jobfairJob['scale'];
+                    $val['scale_cn'] = $jobfairJob['scale_cn'];
+                    $val['district'] = $jobfairJob['district'];
+                    $val['district_cn'] = $jobfairJob['district_cn'];
+                    $val['tag'] = $jobfairJob['tag'];
+                    $val['tag_cn'] = $jobfairJob['tag_cn'];
+                    $val['education'] = $jobfairJob['education'];
+                    $val['education_cn'] = $jobfairJob['education_cn'];
+                    $val['experience'] = $jobfairJob['experience'];
+                    $val['experience_cn'] = $jobfairJob['experience_cn'];
+                    $val['wage'] = $jobfairJob['wage'];
+                    $val['wage_min'] = $jobfairJob['wage_min'];
+                    $val['wage_max'] = $jobfairJob['wage_max'];
+                    $val['wage_cn'] = $jobfairJob['wage_cn'];
+                    $val['audit'] = $jobfairJob['audit'];
+                    $val['display'] = $jobfairJob['display'];
+                    $val['click'] = $jobfairJob['click'];
+                    $val['robot'] = $jobfairJob['robot'];
+                    $val['map_x'] = $jobfairJob['map_x'];
+                    $val['map_y'] = $jobfairJob['map_y'];
+                    $val['map_zoom'] = $jobfairJob['map_zoom'];
+                    $val['add_mode'] = $jobfairJob['add_mode'];
+                    $val['is_entrust'] = $jobfairJob['is_entrust'];
+                    $val['department'] = $jobfairJob['department'];
+                    $val['major'] = $jobfairJob['major'];
+                    $val['major_cn'] = $jobfairJob['major_cn'];
+                    $val['zcid'] = $jobfairJob['zcid'];
+                    $val['zc_cn'] = $jobfairJob['zc_cn'];
+                    $val['zc_name'] = $jobfairJob['zc_name'];
+                    $val['syq'] = $jobfairJob['syq'];
+                    $val['syqxz_min'] = $jobfairJob['syqxz_min'];
+                    $val['ygxs'] = $jobfairJob['ygxs'];
+                    $val['techlevel'] = $jobfairJob['techlevel'];
+                    $val->save();
+                }
+            }
+        }
+
+        $data=[];
+        foreach ($arr as $k => $v) {
+            $data[$k]['type'] = 11;
+            $data[$k]['type_id'] = $v;
+            $data[$k]['status'] = $audit;
+            $data[$k]['reason'] = $remark;
+            $data[$k]['audit_man'] = Admin::user()->username;
+            $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+            $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        AuditReason::insert($data);
+        if ($pms_notice) {
+            if ($audit==3) {
+                $stat='审核不通过';
+            } elseif ($audit==1) {
+                $stat = '审核通过';
+            } else {
+                $stat='待审核';
+            }
+            $reus=JobfairJob::whereIn('id', $arr)->get();
+            $ds = [];
+            foreach ($reus as $k => $v) {
+                $ds[$k]['utype'] = 1;
+                $ds[$k]['msgtype'] = 1;
+                $ds[$k]['msgfromuid'] = Admin::user()->id;
+                $ds[$k]['msgfrom'] = Admin::user()->username;
+                $ds[$k]['msgtoname'] = $v->company_name ? $v->company_name : 'admin';
+                $ds[$k]['msgtouid'] = $v->company_id ? $v->company_id : 0;
+                $ds[$k]['message'] =  $remark ? '招聘会职位(id:'.array_values($arr)[$k].')'.$stat.'<备注:'.$remark.'>' : '招聘会职位(id:'.array_values($arr)[$k].')'.$stat;
+                $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+            }
+            Pms::insert($ds);
+        }
+        if ($result) {
+            admin_toastr('审核成功', 'success');
+        } else {
+            admin_toastr('审核失败', 'error');
+        }
+        return back();
+    }
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的职位', 'error');
+        }
+        \DB::beginTransaction();
+        try {
+            JobfairoutPutJob::whereIn('job_id', $ids)->delete();
+            JobfairPutJob::whereIn('job_id', $ids)->delete();
+            JobfairJob::whereIn('id', $ids)->delete();
+            JobfairJobsContact::whereIn('pid', $ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 576 - 0
app/Admin/Controllers/Jobfairout/JobfairoutCompanyController.php

@@ -0,0 +1,576 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfairout;
+
+use App\Http\Controllers\Controller;
+use App\Models\Company;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use App\Models\Jobfairout\JobfairoutCompany;
+use App\Models\Jobfairout\Jobfairout;
+use App\Models\Jobfairout\JobfairoutReserve;
+use App\Models\Jobfairout\JobfairoutPutJob;
+use App\Admin\Extensions\Form\ValidateForm;
+use Illuminate\Http\Request;
+use App\Services\Common\SmsService;
+use Aix\Sms\Contracts\Smser;
+use App\Services\Common\EmailService;
+use App\Models\MembersHandsel;
+use App\Models\MembersPoint;
+use App\Models\MembersSetmeal;
+use App\Models\Pms;
+class JobfairoutCompanyController extends Controller
+{
+    use HasResourceActions;
+    protected $smsService;
+    protected $emailService;
+
+    public function __construct(SmsService $smsService,EmailService $emailService)
+    {
+        $this->smsService = $smsService;
+        $this->emailService = $emailService;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        $grid=$this->grid()->render();
+        return $content
+            ->header('参会企业')
+            ->description('')
+            ->body(view('admin.jobfairout.jobfair_company')->with(['grid'=>$grid]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('参会企业详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('参会企业编辑')
+            ->description('')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('参会企业创建')
+            ->description('带*号必填项')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairoutCompany);
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('jobfairout', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->orderByRaw("FIELD(audit, 2,1,3)")->orderBy('updated_at', 'desc');
+
+        $grid->column('companys.companyname', '参会企业')->display(function ($companyname) {
+            return '<a href="'.route('jobs.company',['id'=>$this->company_id]).'" target="_blank">'.$companyname.'</a>';
+        })->width(200);
+
+        $grid->person('参展人员信息')->display(function () {
+            if($this->persons->isEmpty()){
+                return '暂时没有';
+            }else{
+                return '<a href="'.route('jobfairout.company.person',['id'=>$this->id]).'" target="_blank">点击查看</a>';
+            }
+        });
+
+        $grid->jobs_name('企业职位')->display(function () {
+            if($this->jobfairPutJob->isEmpty()){
+                return '暂无职位';
+            }else{
+                return '<a href="'.route('jobfairoutPutJobs.index',['jobfair_id'=>$this->jobfair_id,'company_id'=>$this->company_id]).'">点击查看</a>';
+            }
+        });
+        $grid->column('jobfairout.title', '招聘会标题')->display(function ($jobfair_title) {
+            return '<a href="'.route('jobfairout.show.com',$this->jobfair_id).'" target="_blank">'.$jobfair_title.'</a>';
+        })->width(200);
+
+        $grid->column('info.is_speech', '是否演讲')->display(function ($is_speech) {
+            if($is_speech ==1)
+            {
+                return ' <span style="color: #009900">是</span>';
+            }else{
+                return ' <span style="color: #FF3300">否</span>';
+            }
+        });
+
+
+        $grid->audit('预订状态')->display(function ($audit) {
+            if ($audit==1) {
+                return ' <span style="color: #009900">预定成功</span>';
+            } elseif ($audit==2) {
+                return'<span style="color:#FF6600">等待确认</span>';
+            } else {
+                return '<span style="color: #FF3300">审核未通过</span>';
+            }
+        });
+
+        $grid->pay_type('支付方式')->display(function ($pay_type) {
+            if ($pay_type==1) {
+                return '<span style="color: #009900">场次</span>';
+            } elseif ($pay_type==2) {
+                return '<span style="color: #009900">积分</span>';
+            } else {
+                return '<span style="color: #009900">公益</span>';
+            }
+        });
+
+        $grid->etype('预订方式')->display(function ($etype) {
+            if ($etype==1) {
+                return '<span style="color: #009900">在线预订</span>';
+            } elseif ($etype==2) {
+                return '<span style="color: #009900">电话预定</span>';
+            } else {
+                return '<span style="color: #009900">现场预定</span>';
+            }
+        });
+        if(get_subsite_open()){
+            $grid->column('jobfairout.subsite_id', '所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            });
+        }
+
+        $grid->created_at('创建时间');
+        /* $grid->disableCreateButton();*/
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('company_manager_bussiness')) {
+                $actions->append("<button class='btn btn-primary btn-xs business' id=".$actions->row['company_id'].">业务</button>");
+            }
+            if (Admin::user()->can('jobfairout_company_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+            if (Admin::user()->can('jobfairout_companys_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('jobfairout_companys_delete')) {
+                $actions->disableDelete(false);
+            }
+            if (Admin::user()->can('jobfairout_company_poster')) {
+                $actions->append('<button class="btn btn-primary btn-xs poster" title="企业海报" onclick="window.open(\''.route('jobfairout.company.poster',['id'=>$actions->row['id']]).'\')" >企业海报</button>');
+            }
+        });
+
+        if (Admin::user()->can('jobfairout_company_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        if (Admin::user()->can('jobfairout_companys_create')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('jobfairout_company_audit')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="Audit_Companys" title="参会状态">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">审核企业
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('companys.companyname', '参会企业');
+                $filter->equal('jobfair_companys.jobfair_id', '招聘会标题')->select(Jobfairout::select('title', 'id')->when(get_subsite_id()>0,function ($query){
+                    $query->whereHas('subsites', function ($query) {
+                        $query->where('subsite_jobfairouts.subsite_id', get_subsite_id())->where('subsites.effective', 1);
+                    });
+                })->pluck('title', 'id')->all());
+                $filter->equal('jobfair_companys.audit', '预订状态')->select([
+                    1=>'预定成功',
+                    2=>'等待确认',
+                    3=>'审核未通过',
+                ]);
+                if( get_subsite_id() == 0 && get_subsite_open()){
+                    $filter->equal('jobfairout.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('jobfair_companys.pay_type', '支付方式')->select([
+                    1=>'场次',
+                    2=>'积分',
+                    3=>'公益',
+                ]);
+                $filter->equal('jobfair_companys.etype', '预订方式')->select([
+                    1=>'在线预订',
+                    2=>'电话预定',
+                    3=>'现场预定'
+                ]);
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("jobfair_companys.updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("jobfair_companys.updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("jobfair_companys.updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '更新时间', 'updated_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairoutCompany::findOrFail($id));
+
+        $jobfairCompany = JobfairoutCompany::findOrFail($id);
+
+        $show->id('ID');
+
+        $show->companys()->companyname('参会企业')->as(function ($companys){
+            return $companys->companyname;
+        });
+
+        $show->jobfairout()->title('招聘会标题')->as(function ($jobfair){
+            return $jobfair->title;
+        });
+
+        $show->type('签到状态')->as(function ($type) {
+            if ($type==0) {
+                return '未签到';
+            } elseif ($type==1) {
+                return '迟到';
+            } elseif ($type==2) {
+                return '早退';
+            } elseif ($type==3) {
+                return '迟到/早退';
+            } elseif ($type==4) {
+                return '已签到';
+            }
+        });
+
+
+        $show->audit('预订状态')->as(function ($audit) {
+            if ($audit==1) {
+                return '预定成功';
+            } elseif ($audit==2) {
+                return '等待确认';
+            } else {
+                return '审核未通过';
+            }
+        });
+        $show->pay_type('支付方式')->as(function ($pay_type) {
+            if ($pay_type==1) {
+                return '场次';
+            } elseif ($pay_type==2) {
+                return '积分';
+            } else {
+                return '公益';
+            }
+        });
+        $show->etype('预订方式')->as(function ($etype) {
+            if ($etype==1) {
+                return '在线预订';
+            } elseif ($etype==2) {
+                return '电话预定';
+            } else {
+                return '现场预定';
+            }
+        });
+
+        $show->subsite_id('所属分站')->as(function () use ($jobfairCompany) {
+            $subsite_id = Jobfairout::findOrFail($jobfairCompany->jobfair_id)->subsite_id;
+            if ($subsite_id) {
+                $Subsite = Subsite::find($subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new JobfairoutCompany);
+        $form->select('company_id', '企业名称')->options(
+            Company::pluck('companyname', 'id')->all()
+        )->rules([
+            'required',
+        ])->setMustMark();
+        $form->select('jobfair_id', '招聘会名称')->options(
+            Jobfairout::where('display', 1)->where('predetermined_status',1)->where('holddate_end', '>', time())->pluck('title', 'id')->all()
+        )->rules(['required',])->setMustMark();
+        $form->select('etype', '预定方式')->options([3=>'现场预定'])->default(3)->help('现场预定不消耗场次或积分!');
+        $form->hidden('pay_type')->default(3);
+        $form->saving(function (Form $form){
+            $company_id = $form->company_id;
+            $count = JobfairoutCompany::where(['company_id'=>$company_id,'jobfair_id'=>$form->jobfair_id])->count();
+            if ($count>=1) {
+                admin_toastr('该企业已预定过该招聘会!', 'error');
+                return back();
+            }
+        });
+        $form->saved(function (Form $form) {
+            $model = $form->model();
+            $model->audit = 1;
+            $model->note = '该企业现场预定展位!';
+            $model->save();
+        });
+        return $form;
+    }
+
+    public function person(Request $request)
+    {
+        $id = $request->id;
+        $reserve = JobfairoutReserve::where('exid',$id)->get();
+        return view('admin.jobfairout.jobfair_company_person',['reserve'=>$reserve]);
+    }
+
+    public function poster(Request $request)
+    {
+        $id = $request->id;
+        $poster = JobfairoutCompany::find($id);
+        return view('admin.jobfairout.jobfair_company_poster',['poster'=>$poster]);
+    }
+
+    public function auditCompanys(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('jobfairout.company.auditr'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '审核')->options([1=>'预订成功',3=>'审核未通过'])->default(1);
+        $form->textarea('note', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核企业']);
+    }
+
+    public function auditCompanysR(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $note = $request->note;
+        $pms_notice = $request->pms_notice;
+        if($audit==3){
+            if (empty($note)) {
+                admin_toastr('参会企业审核未通过必须填写备注!', 'error');
+                return back();
+            }
+        }
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('请选择参会企业', 'error');
+            return back();
+        }
+        $arr_id = [];
+        $JobfairCompany = JobfairoutCompany::whereHas('jobfairout',function ($query){
+            $query->where('holddate_end', '>', time());
+        })->whereIn('id', $arr)->get();
+        if($JobfairCompany->isEmpty()){
+            admin_toastr('招聘会已过期', 'error');
+            return back();
+        }
+        \DB::beginTransaction();
+        try {
+            foreach ($JobfairCompany as $key => $val) {
+                if ($audit==1) { //预订成功
+                    if ($val->audit==2) {
+                        $arr_id[] = $val->id;
+                        if($val->companys->mobile && $val->companys->mobile_audit == 1){
+                            $this->smsService->sendSms(
+                                $val->companys->mobile,
+                                Smser::TEMPLATE_JOBFAIR_APPLY_OK,
+                                [
+                                    'jobfair_name'=>$val->jobfairout->title,
+                                    'jobfair_time'=>date('Y-m-d H:i',$val->jobfairout->holddate_start),
+                                    'jobfair_addr'=>$val->jobfairout->address,
+                                ]);
+                        }
+                        if($val->companys->email && $val->companys->email_audit == 1){
+                            $this->emailService->sendMail($val->companys->email, EmailService::TEMPLATE_JOBFAIR_APPLY_OK,
+                                ['title'=>'赴外招聘会预订成功'],
+                                [
+                                    'jobfair_name'=>$val->jobfairout->title,
+                                    'jobfair_time'=>date('Y-m-d H:i',$val->jobfairout->holddate_start),
+                                    'jobfair_addr'=>$val->jobfairout->address,
+                                ]
+                            );
+                        }
+                    }
+                } else { //审核未通过。
+                    if ($val->audit==2 || $val->audit==1) {
+                        $arr_id[] = $val->id;
+                        if($val->companys->mobile && $val->companys->mobile_audit == 1){
+                            $this->smsService->sendSms(
+                                $val->companys->mobile,
+                                Smser::TEMPLATE_JOBFAIR_APPLY_ERROR,
+                                [
+                                    'jobfair_name'=>$val->jobfairout->title
+                                ]);
+                        }
+                        if($val->companys->email && $val->companys->email_audit == 1){
+                            $this->emailService->sendMail($val->companys->email, EmailService::TEMPLATE_JOBFAIR_APPLY_ERROR, ['title'=>'赴外招聘会预订失败'], ['jobfair_name'=>$val->jobfairout->title]);
+                        }
+                    }
+
+                    if ($val->jobfairout) {
+                        if ($val->pay_type==1) {//场次
+                            MembersSetmeal::where('uid', $val->company_id)->where('utype', 1)
+                                ->increment('jobfair_num', $val->jobfairout->jobsfair_num);
+                        }elseif ($val->pay_type==2) { //积分
+                            MembersPoint::where('uid', $val->company_id)->where('utype', 1)
+                                ->increment('points', $val->jobfairout->predetermined_point);
+                            MembersHandsel::create([
+                                'uid'=>$val->company_id,
+                                'utype'=>1,
+                                'htype_cn'=>'返还预定招聘会的积分',
+                                'operate'=>1,
+                                'points'=>$val->jobfairout->predetermined_point
+                            ]);
+                        }
+                    }
+                }
+            }
+
+            if ($arr_id) {
+                $newReult = JobfairoutCompany::with(['jobfairout', 'companys'])->whereHas('jobfairout')
+                    ->whereHas('companys')->whereIn('id', $arr_id)->get();
+                foreach ($newReult as $key => $val) {
+                    if ($val->jobfairout && $val->companys) {
+                        $newDate[$key]['utype'] = $val->companys->utype;
+                        $newDate[$key]['msgtype'] = 2;
+                        $newDate[$key]['msgfromuid'] = 0;
+                        $newDate[$key]['msgfrom'] = 'admin';
+                        $newDate[$key]['msgtoname'] = $val->companys->username;
+                        $newDate[$key]['msgtouid'] = $val->companys->id;
+                        $title = strstr($val->jobfairout->title, '赴外—招聘会') ? $val->jobfairout->title : $val->jobfairout->title . '赴外—招聘会';
+                        if ($audit == 1) {
+                            $newDate[$key]['message'] = '您申请的<a href="/content/jobfairout/show/' . $val->jobfairout->id . '">' . $title . '</a>已审核通过,请尽快提交招聘会职位。';
+                        } else {
+                            $newDate[$key]['message'] = '您申请的<a href="/content/jobfairout/show/' . $val->jobfairout->id . '">' . $title . '</a>已审核失败,请尽快查收。失败原因(' . $note . ')';
+                        }
+                        $newDate[$key]['created_at'] = date('Y-m-d H:i:s');
+                        $newDate[$key]['updated_at'] = date('Y-m-d H:i:s');
+                    }
+                }
+                if ($pms_notice&&$newDate) {
+                    Pms::insert($newDate);
+                }
+                JobfairoutCompany::whereIn('id', $arr_id)->update(['audit' => $audit, 'note' => $note]);
+            } else {
+                admin_toastr('操作失败', 'error');
+                return back();
+            }
+            \DB::commit();
+            admin_toastr('操作成功', 'success');
+        } catch (\Exception $e) {
+            \DB::rollback();
+            admin_toastr('操作失败', $e->getMessage());
+        }
+        return back();
+    }
+
+
+    public function destroy($id)
+    {
+        $ids = array();
+        if ($id) {
+            $ids = explode(',', $id);
+        }
+        if (!$ids) {
+            return admin_toastr('请勾选需要删除的参展职位', 'error');
+        }
+        \DB::beginTransaction();
+        try {
+            JobfairoutCompany::whereIn('id', $ids)->delete();
+            JobfairoutPutJob::whereIn('exid', $ids)->delete();
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+            return response()->json($data);
+        }
+    }
+}

+ 690 - 0
app/Admin/Controllers/Jobfairout/JobfairoutController.php

@@ -0,0 +1,690 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfairout;
+
+use App\Http\Controllers\Controller;
+use App\Models\Jobfairout\Jobfairout;
+use App\Models\Jobfairout\JobfairoutCompany;
+use App\Models\Jobfairout\JobfairoutFeedback;
+use App\Models\Jobfairout\JobfairoutPutJob;
+use App\Models\Jobfairout\JobfairoutReserve;
+use App\Models\Jobfairout\JobfairoutSchool;
+use App\Models\SubsiteJobfairout;
+use App\Admin\Exports\Jobfairout\PersonExport;
+use App\Admin\Exports\Jobfairout\JobsExport;
+use App\Admin\Exports\Jobfairout\FeedbackExport;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+class JobfairoutController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('赴外招聘会列表')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+//        dd(\request()->route());
+        return $content
+            ->header('招聘会详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('赴外招聘会编辑')
+            ->description('')
+            ->body(view('admin.jobfairout.jobfairout')->with(['content'=>$this->editForm($id)])->render());
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('赴外招聘会创建')
+            ->description('带*号必填项')
+            ->body(view('admin.jobfairout.jobfairout')->with(['content'=>$this->createForm()])->render());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Jobfairout);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id',get_subsite_id());
+        })->orderBy('id', 'desc');
+
+        $grid->holddate_start('举办时间')->display(function ($holddate_start) {
+            return "<span style='color:#009900'>".date('Y-m-d H:i', $holddate_start)."&nbsp;至&nbsp;".date('Y-m-d H:i', $this->holddate_end)."</span>";
+        });
+        $grid->title('招聘会标题')->display(function ($title) {
+            return "<a target='_blank' href='".route('jobfairout.show.com',$this->id)."'>".$title."</a>";
+        })->width(300);
+
+        $grid->type('赴外类型')->display(function ($type) {
+            return $type==1?'本市':'赴外';
+        });
+
+        $grid->predetermined_status('预定状态')->display(function ($predetermined_status) {
+            if ($predetermined_status==1) {
+                if($this->predetermined_end > time()  && $this->predetermined_start < time()){
+                    return "允许预订";
+                }elseif($this->predetermined_start > time()){
+                    return "未开始";
+                }else{
+                    return "停止预订";
+                }
+            } else {
+                return "停止预订";
+            }
+        });
+
+        $grid->mstatus('预定情况')->display(function () {
+            $standSuccess = JobfairoutCompany::where(['audit'=>1,'jobfair_id'=>$this->id])->count();
+            $standAudit = JobfairoutCompany::where(['audit'=>2,'jobfair_id'=>$this->id])->count();
+            $standFree = $this->number - $standSuccess - $standAudit;
+            return '<span class="vtip" title="空闲展位数" style="color:#000000;padding-right:10px">['.$standFree.']</span>
+		            <span class="vtip" title="审核中展位数" style="color:#FFCC33;padding-right:10px">['.$standAudit.']</span>
+		            <span class="vtip" title="预定成功展位数" style="color:#CC00CC;padding-right:10px">['.$standSuccess.']</span>
+		            <span class="vtip" title="展位总数" style="color:#3300FF;padding-right:10px">['.$this->number.']</span>';
+        });
+        $grid->showendtime('显示截止时间')->display(function ($showendtime) {
+            return $showendtime ? date('Y-m-d H:i:s', $showendtime) : '不限制';
+        });
+
+        if(get_subsite_id() == 0 && get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            });
+        }
+
+        $grid->created_at('创建时间');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('jobfairout_index_person')) {
+                $actions->append('<button class="btn btn-primary btn-xs poster" title="导出参会人" onclick="window.open(\''.route('jobfairout.export.person',['id'=>$actions->row['id']]).'\')" >导出参会人</button>');
+            }
+            if (Admin::user()->can('jobfairout_index_jobs')) {
+                $actions->append('<button class="btn btn-primary btn-xs jobs" title="导出职位" onclick="window.open(\''.route('jobfairout.export.jobs',['id'=>$actions->row['id']]).'\')" >导出职位</button>');
+            }
+            if (Admin::user()->can('jobfairout_index_feedback')) {
+                $actions->append('<button class="btn btn-primary btn-xs feedback" title="导出反馈表" onclick="window.open(\'' . route('jobfairout.export.feedback', ['id' => $actions->row['id']]) . '\')" >导出反馈表</button>');
+            }
+            if (Admin::user()->can('jobfairout_index_poster')) {
+                $actions->append('<button class="btn btn-primary btn-xs poster" title="查看海报" onclick="window.open(\'' . route('jobfairout.poster', ['id' => $actions->row['id']]) . '\')" >查看海报</button>');
+            }
+            if (Admin::user()->can('jobfairout_index_edit') && (get_subsite_id() == 0 || $actions->row['subsite_id']== get_subsite_id())) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('jobfairout_index_delete') && (get_subsite_id() == 0 || $actions->row['subsite_id']== get_subsite_id())) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->like('title', '招聘会标题');
+
+            $filter->equal('type', '招聘会类型')->select(['1'=>'本市','2'=>'赴外']);
+
+            $filter->equal('predetermined_status', '预定状态')->select([
+                1  => '允许预订',
+                2  => '停止预订',
+            ]);
+            $filter->between('created_at', '创建时间')->datetime();
+            if(get_subsite_id() == 0 && get_subsite_open()){
+                $filter->equal('subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+            }
+        });
+        if (Admin::user()->can('jobfairout_index_create')) {
+            $grid->disableCreateButton(false);
+        }
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Jobfairout::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->holddate_start('举办时间')->as(function ($holddate_start) {
+            return date('Y-m-d H:i:s', $holddate_start).'至'.date('Y-m-d H:i:s', $this->holddate_end);
+        });
+        $show->title('招聘会标题')->as(function ($title) {
+            return $title;
+        });
+        $show->type('招聘会类型')->as(function ($type) {
+            return $type==1?'本市':'赴外';
+        });
+
+        $show->predetermined_status('预定状态')->as(function ($predetermined_status) {
+            if ($predetermined_status==1) {
+                if($this->predetermined_end > time()  && $this->predetermined_start < time()){
+                    return "允许预订";
+                }elseif($this->predetermined_start > time()){
+                    return "未开始";
+                }else{
+                    return "停止预订";
+                }
+            } else {
+                return "停止预订";
+            }
+        });
+
+        $show->showendtime('显示截止时间')->as(function ($showendtime) {
+            return $showendtime ? date('Y-m-d H:i:s', $showendtime) : '不限制';
+        });
+
+        $show->subsite_id('所属分站')->as(function ($subsite_id) {
+            if ($subsite_id) {
+                $Subsite = Subsite::find($subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new Jobfairout);
+        $form->tab('基本信息',function ($form){
+            $form->text('title', '招聘会标题')->placeholder('如:2017年5月1日(星期六)医药行业主题招聘会')->default(session('content')['title'])->setMustMark();
+            $form->text('industry', '行业主题')->default(session('content')['industry']);
+            $form->url('url', '招聘会链接地址')->default(session('content')['url']);
+            $form->number('number', '展位数量')->min(1)->default(1)->help('展位数量');
+            $form->text('contact', '联系人')->default(session('content')['contact'])->setMustMark();
+            $form->text('phone', '联系电话')->default(session('content')['phone'])->help('多个号码请用英文半角“,”隔开!')->setMustMark();
+            $form->select('type', '赴外类型')->options(['1'=>'本市','2'=>'赴外'])->default(session('content')['type'] ? session('content')['type'] : 1);
+            if (get_subsite_id()==0) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            } else {
+                $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', get_subsite_id())))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                $subsites[0] = '总站';
+            }
+            if ($subsites && get_subsite_open()) {
+                $form->multipleSelect('subsites', '同步分站')->options($subsites);
+            }
+            $form->hidden('subsite_id')->value(get_subsite_id());
+            $form->editor('jobfair_introduction', '招聘会简介')->default(session('content')['jobfair_introduction'])->setMustMark();
+        })->tab('举办信息',function ($form){
+            $form->datetime('holddate_start', '举办开始时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['holddate_start'])->setMustMark();
+            $form->datetime('holddate_end', '举办结束时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['holddate_end'])->setMustMark();
+            $form->datetime('predetermined_start', '预定开始时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['predetermined_start'])->setMustMark();
+            $form->datetime('predetermined_end', '预定结束时间')->format('YYYY-MM-DD HH:mm:ss')->default(session('content')['predetermined_end'])->setMustMark();
+            $form->datetime('showendtime', '显示截止时间')->format('YYYY-MM-DD HH:mm:ss')->help('不填不限制')->default(session('content')['showendtime']);
+            $schools = JobfairoutSchool::pluck('name', 'id')->toArray();
+            $form->multipleSelect('school_id', '选择高校')->options($schools);
+            $form->text('address', '举办地址')->default(session('content')['address'])->setMustMark();
+            $form->html('<div id="searchResultPanel" style="border:1px solid #C0C0C0;height:100px; display:none;"></div>');
+            $form->html(' <div class="fr">
+            <input name="map_x" type="hidden" id="x" value="'.subsite_config('aix.system.map.map.map_x').'">
+            <input name="map_y" type="hidden" id="y" value="'.subsite_config('aix.system.map.map.map_y').'">
+            <input name="map_zoom" type="hidden" id="zoom" value="'.subsite_config('aix.system.map.map.max_level').'">
+            <div class="form-control" style=height:380px;border:1px solid  #CCCCCC; cursor: pointer;" id="container"></div></div>', '地图标注')->setMustMark();
+        })->tab('设置',function ($form){
+            $form->radio('display', '显示状态')->options([1=>'正常',2=>'暂停'])->default(1);
+            $form->radio('predetermined_status', '预定状态')->options([1=>'允许预订',2=>'停止预订'])->default(1);
+            $form->radio('is_commonweal', '招聘会')->options([1=>'场次',2=>'积分',3=>'公益'])->default(3)->help('选择公益招聘会,企业预订免费!')->attribute('class', "is_commonweal");
+            $form->number('predetermined_point', '预定消耗积分')->min(1)->default(100)->help('选择积分招聘会,企业预订则抵扣积分!');
+            $form->number('jobsfair_num', '预定消耗场次')->min(1)->default(1)->help('选择场次招聘会,企业预订则抵扣场次!');
+            $form->number('nosign_point', '未签到扣减积分')->min(1)->default(300)->help('单位:积分');
+            $form->number('late_point', '迟到早退扣减积分')->min(1)->default(100)->help('单位:积分');
+            $form->number('ordid', '排序')->min(0)->default(0)->help('数字越大,排序越靠前');
+        });
+        $form->disableReset();
+        return $form->render();
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $Jobfair = Jobfairout::findOrFail($id);
+        $form = new Form(new Jobfairout());
+        $form->hidden('id')->default($Jobfair->id);
+        $form->tab('基本信息',function ($form) use($Jobfair,$id){
+            $form->text('title', '招聘会标题')->placeholder('如:2017年5月1日(星期六)医药行业主题招聘会')->default($Jobfair->title)->setMustMark();
+            $form->text('industry', '行业主题')->default($Jobfair->industry);
+            $form->url('url', '招聘会链接地址')->default($Jobfair->url);
+            $form->number('number', '展位数量')->min(1)->default($Jobfair->number)->help('展位数量');
+            $form->text('contact', '联系人')->default($Jobfair->contact)->setMustMark();
+            $form->text('phone', '联系电话')->default($Jobfair->phone)->help('多个号码请用英文半角“,”隔开!')->setMustMark();
+            $form->select('type', '赴外类型')->options(['1'=>'本市','2'=>'赴外'])->default($Jobfair->type);
+            if ($Jobfair->subsite_id==0) {
+                $subsites = Subsite::where(array('effective'=>1))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+            } else {
+                $subsites = Subsite::where(array(array('effective','=',1),array('id','<>', $Jobfair->subsite_id)))->orderBy('order', 'asc')->get()->pluck('sitename', 'id')->toArray();
+                $subsites[0] = '总站';
+            }
+            if ($subsites && get_subsite_open()) {
+                $relations = SubsiteJobfairout::where(array('jobfair_id'=>$id))->get()->pluck('subsite_id')->toArray();
+                $form->multipleSelect('subsite_id', '同步分站')->options($subsites)->default($relations);
+            }
+            $form->editor('jobfair_introduction', '招聘会简介')->default($Jobfair->jobfair_introduction)->setMustMark();
+        })->tab('举办信息',function ($form) use($Jobfair){
+            $form->datetime('holddate_start', '举办开始时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->holddate_start ? date('Y-m-d H:i:s', $Jobfair->holddate_start) : '')->setMustMark();
+            $form->datetime('holddate_end', '举办结束时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->holddate_end ? date('Y-m-d H:i:s', $Jobfair->holddate_end) : '')->setMustMark();
+            $form->datetime('predetermined_start', '预定开始时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->predetermined_start ? date('Y-m-d H:i:s', $Jobfair->predetermined_start) : '')->setMustMark();
+            $form->datetime('predetermined_end', '预定结束时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->predetermined_end ? date('Y-m-d H:i:s', $Jobfair->predetermined_end) : '')->setMustMark();
+            $form->datetime('showendtime', '显示截止时间')->format('YYYY-MM-DD HH:mm:ss')->default($Jobfair->showendtime ? date('Y-m-d H:i:s', $Jobfair->showendtime) : '')->help('不填不限制');
+            $schools = JobfairoutSchool::pluck('name', 'id')->toArray();
+            $form->multipleSelect('school_id', '选择高校')->options($schools)->default(explode(',',$Jobfair->school_id));
+            $form->text('address', '举办地址')->default($Jobfair->address)->setMustMark();
+            $form->html('<div id="searchResultPanel" style="border:1px solid #C0C0C0;height:100px; display:none;"></div>');
+            $map_x = $Jobfair->map_x ? $Jobfair->map_x : subsite_config('aix.system.map.map.map_x');
+            $map_y = $Jobfair->map_y ? $Jobfair->map_y : subsite_config('aix.system.map.map.map_y');
+            $form->html(' <div class="fr">
+            <input name="map_x" type="hidden" id="x" value="'.$map_x.'">
+            <input name="map_y" type="hidden" id="y" value="'.$map_y.'">
+            <input name="map_zoom" type="hidden" id="zoom" value="'.subsite_config('aix.system.map.map.max_level').'">
+            <div class="form-control" style="height:380px;border:1px solid  #CCCCCC; cursor: pointer;" id="container"></div>
+        </div>', '地图标注')->setMustMark();
+        })->tab('设置',function ($form) use($Jobfair){
+            $form->radio('display', '显示状态')->options([1=>'正常',2=>'暂停'])->default($Jobfair->display);
+            $form->radio('predetermined_status', '预定状态')->options([1=>'允许预订',2=>'停止预订'])->default($Jobfair->predetermined_status);
+            $form->radio('is_commonweal', '招聘会')->options([1=>'场次',2=>'积分',3=>'公益'])->default($Jobfair->is_commonweal)->help('选择公益招聘会,企业预订免费!')->attribute('class', "is_commonweal");
+            $form->number('predetermined_point', '预定消耗积分')->min(1)->default($Jobfair->predetermined_point)->help('选择积分招聘会,企业预订则抵扣积分!');
+            $form->number('jobsfair_num', '预定消耗场次')->min(1)->default($Jobfair->jobsfair_num)->help('选择场次招聘会,企业预订则抵扣场次!');
+            $form->number('nosign_point', '未签到扣减积分')->min(1)->default($Jobfair->nosign_point)->help('单位:积分');
+            $form->number('late_point', '迟到早退扣减积分')->min(1)->default($Jobfair->late_point)->help('单位:积分');
+            $form->number('ordid', '排序')->min(0)->default($Jobfair->ordid)->help('数字越大,排序越靠前');
+            $form->hidden('_method')->default('put');
+        });
+        $form->disableReset();
+        return $form->render();
+    }
+
+    public function store(Request $request)
+    {
+        $request->validate([
+            'title' => 'required',
+            'number' => 'required|integer',
+            'holddate_start' => 'required',
+            'holddate_end' => 'required',
+            'predetermined_start' => 'required',
+            'predetermined_end' => 'required',
+            'address' => 'required', //举办地址。
+            'contact' => 'required',
+            'phone' => 'required|max:100',
+            'jobfair_introduction' => 'required',
+        ],[
+            'title.required'=>'请填写标题',
+            'number.required'=>'请填写展位数量',
+            'number.integer'=>'展位数量必须为数字',
+            'holddate_start.required'=>'请填写举办开始时间',
+            'holddate_end.required'=>'请填写举办结束时间',
+            'predetermined_start.required'=>'请填写预定开始时间',
+            'predetermined_end.required'=>'请填写预定结束时间',
+            'areaid.required'=>'请填写举办场地',
+            'address.required'=>'请填写举办地址',
+            'contact.required'=>'请填写联系人',
+            'phone.required'=>'请填写联系方式',
+            'phone.max'=>'联系方式最多不超过100字',
+            'jobfair_introduction.required'=>'请填写简介',
+        ]);
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->showendtime) ) {
+            admin_toastr('举办/预定时间不能含有中文!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->phone) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->jobsfair_num) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->nosign_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->late_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->ordid) ) {
+            admin_toastr('积分/场次/联系电话不能含有中文!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+        foreach (explode(',',$request->phone) as $value){
+            if(!(preg_match ('/^1[3-9]{1}[0-9]{9}$/', $value) || preg_match ('/^([0-9]{3,4}-)?[0-9]{7,8}$/', $value))){
+                admin_toastr('请输入正确的联系电话', 'error');
+                return back()->with(['content'=>$request->all()]);
+            }
+        }
+
+        if ($request->holddate_start >= $request->holddate_end) {
+            admin_toastr('举办开始时间不能大于结束时间!!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+        if ($request->predetermined_start >= $request->holddate_start) {
+            admin_toastr('预订开始时间不能大于举办开始时间!!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+        if ($request->predetermined_start >= $request->predetermined_end) {
+            admin_toastr('预订开始时间不能大于结束时间!!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+        if ($request->predetermined_end > $request->holddate_end) {
+            admin_toastr('预订结束时间不能大于举办结束时间!!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+        $jobfairout = [];
+        $jobfairout['title'] = $request->title;
+        $jobfairout['industry'] = $request->industry;
+        $jobfairout['holddate_start'] = strtotime($request->holddate_start);
+        $jobfairout['holddate_end'] = strtotime($request->holddate_end);
+        $jobfairout['type'] = $request->type;
+        $jobfairout['showendtime'] = strtotime($request->showendtime);
+        $jobfairout['address'] = $request->address;
+        $jobfairout['contact'] = $request->contact;
+        $apiAddress = $this->apiAddress($request->address);
+        if (!$apiAddress) {
+            admin_toastr('请添加地图标注!!', 'error');
+            return back()->with(['content'=>$request->all()]);
+        }
+        $jobfairout['map_x'] = $apiAddress['lng'];
+        $jobfairout['map_y'] = $apiAddress['lat'];
+        $jobfairout['phone'] = $request->phone;
+        $jobfairout['display'] = $request->display;
+        $jobfairout['is_commonweal'] = $request->is_commonweal;
+        $jobfairout['predetermined_point'] = $request->predetermined_point;
+        $jobfairout['jobsfair_num'] = $request->jobsfair_num;
+        $jobfairout['nosign_point'] = $request->nosign_point;
+        $jobfairout['late_point'] = $request->late_point;
+        $jobfairout['ordid'] = $request->ordid;
+        $jobfairout['number'] = $request->number;
+        $jobfairout['jobfair_introduction'] = $request->jobfair_introduction;
+        $jobfairout['subsite_id'] = get_subsite_id();
+        $jobfairout['predetermined_status'] = $request->predetermined_status;
+        $jobfairout['predetermined_start'] = $request->predetermined_start ? strtotime($request->predetermined_start) : $request->predetermined_start;
+        $jobfairout['predetermined_end'] = $request->predetermined_end ? strtotime($request->predetermined_end) : $request->predetermined_end;
+        $school_id = array_filter($request->school_id);
+        $jobfairout['school_id'] = implode(',',$school_id);
+        $jobfairout['url'] = $request->url;
+        DB::beginTransaction();
+        try {
+            $Jobfair = Jobfairout::create($jobfairout);
+            $subsites = \Illuminate\Support\Facades\Request::input('subsites');
+            if (get_subsite_id() == 0 && $subsites) {
+                $subsites = array_merge(array(get_subsite_id()), $subsites);
+            } else {
+                $subsites = array(get_subsite_id());
+            }
+            $set_data = array();
+            foreach ($subsites as $k => $v) {
+                if ($v !== null) {
+                    $set_data[] = array(
+                        'jobfair_id' => $Jobfair->id,
+                        'subsite_id'=> $v,
+                        'created_at'=>date('Y-m-d H:i:s'),
+                        'updated_at'=>date('Y-m-d H:i:s'),
+                    );
+                }
+            }
+            SubsiteJobfairout::insert($set_data);
+            DB::commit();
+            admin_toastr('操作成功!', 'success');
+            return redirect(route('jobfairout.index'));
+        } catch (\Exception $e) {
+            DB::rollback();
+            admin_toastr($e->getMessage(), 'error');
+            return back();
+        }
+    }
+
+    public function update(Request $request)
+    {
+        $request->validate([
+            'title' => 'required',
+            'number' => 'required|integer',
+            'holddate_start' => 'required',
+            'holddate_end' => 'required',
+            'predetermined_start' => 'required',
+            'predetermined_end' => 'required',
+            'address' => 'required', //举办地址。
+            'contact' => 'required',
+            'phone' => 'required|max:100',
+            'jobfair_introduction' => 'required',
+        ],[
+            'title.required'=>'请填写标题',
+            'number.required'=>'请填写展位数量',
+            'number.integer'=>'展位数量必须为数字',
+            'holddate_start.required'=>'请填写举办开始时间',
+            'holddate_end.required'=>'请填写举办结束时间',
+            'predetermined_start.required'=>'请填写预定开始时间',
+            'predetermined_end.required'=>'请填写预定结束时间',
+            'address.required'=>'请填写举办地址',
+            'contact.required'=>'请填写联系人',
+            'phone.required'=>'请填写联系方式',
+            'phone.max'=>'联系方式最多不超过100字',
+            'jobfair_introduction.required'=>'请填写简介',
+        ]);
+
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->holddate_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_start) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_end) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->showendtime) ) {
+            admin_toastr('举办/预定时间不能含有中文!', 'error');
+            return back();
+        }
+        if ( preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->phone) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->predetermined_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->jobsfair_num) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->nosign_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->late_point) || preg_match ("/[\x{4e00}-\x{9fa5}]/u", $request->ordid) ) {
+            admin_toastr('积分/场次/联系电话不能含有中文!', 'error');
+            return back();
+        }
+        foreach (explode(',',$request->phone) as $value){
+            if(!(preg_match ('/^1[3-9]{1}[0-9]{9}$/', $value) || preg_match ('/^([0-9]{3,4}-)?[0-9]{7,8}$/', $value))){
+                admin_toastr('请输入正确的联系电话', 'error');
+                return back();
+            }
+        }
+        $jobfairout_id = $request->id;
+        if (empty($jobfairout_id)) {
+            admin_toastr('招聘会不存在!', 'error');
+            return back();
+        }
+        if ($request->holddate_start >= $request->holddate_end) {
+            admin_toastr('举办开始时间不能大于结束时间!!', 'error');
+            return back();
+        }
+        if ($request->predetermined_start >= $request->predetermined_end) {
+            admin_toastr('预订开始时间不能大于结束时间!!', 'error');
+            return back();
+        }
+        if ($request->predetermined_end > $request->holddate_end) {
+            admin_toastr('预订结束时间不能大于举办结束时间!!', 'error');
+            return back();
+        }
+
+        $jobfairout = [];
+        $jobfairout['title'] = $request->title;
+        $jobfairout['industry'] = $request->industry;
+        $jobfairout['holddate_start'] = strtotime($request->holddate_start);
+        $jobfairout['holddate_end'] = strtotime($request->holddate_end);
+        $jobfairout['type'] = $request->type;
+        $jobfairout['type'] = $request->type;
+        $jobfairout['showendtime'] = strtotime($request->showendtime);
+        $jobfairout['address'] = $request->address;
+        $jobfairout['contact'] = $request->contact;
+        $apiAddress = $this->apiAddress($request->address);
+        if (!$apiAddress) {
+            admin_toastr('请添加地图标注!!', 'error');
+            return back();
+        }
+        $jobfairout['map_x'] = $apiAddress['lng'];
+        $jobfairout['map_y'] = $apiAddress['lat'];
+        $jobfairout['phone'] = $request->phone;
+        $jobfairout['display'] = $request->display;
+        $jobfairout['is_commonweal'] = $request->is_commonweal;
+        $jobfairout['predetermined_point'] = $request->predetermined_point;
+        $jobfairout['jobsfair_num'] = $request->jobsfair_num;
+        $jobfairout['nosign_point'] = $request->nosign_point;
+        $jobfairout['late_point'] = $request->late_point;
+        $jobfairout['ordid'] = $request->ordid;
+        $jobfairout['jobfair_introduction'] = $request->jobfair_introduction;
+        $school_id = array_filter($request->school_id);
+        $jobfairout['school_id'] = implode(',',$school_id);
+        $jobfairout['url'] = $request->url;
+        $jobfairout['number'] = $request->number;
+        if(is_array($request->subsite_id)){
+            $subsiteArr = $request->subsite_id;
+            $subsite_id = [];
+            foreach ($subsiteArr as $key => $val) {
+                if ($val!==null) {
+                    $subsite_id[] = $val;
+                }
+            }
+            $own_subsite_id = Jobfairout::findOrFail($jobfairout_id)->subsite_id;
+            $subsiteJobfair = [
+                [
+                    'jobfair_id'=>$jobfairout_id,
+                    'subsite_id'=> $own_subsite_id,
+                    'created_at'=>date('Y-m-d H:i:s'),
+                    'updated_at'=>date('Y-m-d H:i:s'),
+                ]
+            ];
+
+            if ($subsite_id) {
+                $subsiteArr = [];
+                foreach ($subsite_id as $key => $val) {
+                    $subsiteArr[$key]['jobfair_id'] = $jobfairout_id;
+                    $subsiteArr[$key]['subsite_id'] = $val;
+                    $subsiteArr[$key]['created_at'] = date('Y-m-d H:i:s');
+                    $subsiteArr[$key]['updated_at'] = date('Y-m-d H:i:s');
+                }
+                if (in_array($own_subsite_id, $subsite_id)) {
+                    $subsiteJobfair = $subsiteArr;
+                } else {
+                    $subsiteJobfair = array_merge($subsiteJobfair, $subsiteArr);
+                }
+            }
+        }
+        $jobfairout['predetermined_status'] = $request->predetermined_status;
+        $jobfairout['predetermined_start'] = $request->predetermined_start ? strtotime($request->predetermined_start) : $request->predetermined_start;
+        $jobfairout['predetermined_end'] = $request->predetermined_end ? strtotime($request->predetermined_end) : $request->predetermined_end;
+        DB::beginTransaction();
+        try {
+            Jobfairout::where('id', $jobfairout_id)->update($jobfairout);
+            if(isset($subsiteJobfair)){
+                SubsiteJobfairout::where('jobfair_id', $jobfairout_id)->delete();
+                SubsiteJobfairout::insert($subsiteJobfair);
+            }
+            DB::commit();
+            admin_toastr('操作成功!', 'success');
+            return redirect(route('jobfairout.index'));
+        } catch (\Exception $e) {
+            DB::rollback();
+            admin_toastr($e->getMessage(), 'error');
+            return back();
+        }
+    }
+
+    public function destroy($id)
+    {
+        if (Jobfairout::destroy($id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+
+    protected function apiAddress($address)
+    {
+        $url='https://api.map.baidu.com/geocoder/v2/?address='.$address.'&output=json&ak='.subsite_config('aix.system.map.map.map_ak')."&s=1";
+        if ($result=file_get_contents($url)) {
+            $data = array();
+            $res= json_decode($result, true);
+            if ($res['status']==0) {
+                $results = $res['result'];
+                $data['lng'] = $results['location']['lng'];
+                $data['lat'] = $results['location']['lat'];
+            }
+            return $data;
+        }
+    }
+
+    public function jobfairoutPoster(Request $request)
+    {
+        $id = $request->id;
+        $poster = JobfairoutCompany::where('jobfair_id',$id)->get();
+        $jonfairout_title= Jobfairout::where('id',$id)->value('title');
+        return view('admin.jobfairout.jobfair_poster',['poster'=>$poster,'jonfairout_title'=>$jonfairout_title]);
+    }
+
+    public function exportPerson(Request $request){
+        $id = $request->id;
+        $Jobfair_reserve =  JobfairoutReserve::where(array('jobfair_id'=>$id))->orderBy('company_id')->get();
+        $export = new PersonExport();
+        $export->setCustomerData($Jobfair_reserve)->export();//这里不需要return
+    }
+
+    public function exportJobs(Request $request){
+        $id = $request->id;
+        $Jobs = JobfairoutPutJob::where(['jobfair_id'=>$id,'audit'=>1])->orderBy('exid')->get();
+        $export = new JobsExport();
+        $export->setCustomerData($Jobs)->export();//这里不需要return
+    }
+
+    public function exportFeedback(Request $request){
+        $id = $request->id;
+        $feedback = JobfairoutFeedback::where(['jobfair_id'=>$id])->get();
+        foreach ($feedback as &$value)
+        {
+            $value['resumeNum'] = explode(',',$value['resumeNum']);
+            $value['agreeNum'] = explode(',',$value['agreeNum']);
+            $value['signNum'] = explode(',',$value['signNum']);
+        }
+        $export = new FeedbackExport();
+        $export->setCustomerData($feedback)->export();//这里不需要return
+
+
+    }
+}

+ 394 - 0
app/Admin/Controllers/Jobfairout/JobfairoutPutJobsController.php

@@ -0,0 +1,394 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfairout;
+
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Jobfairout\Jobfairout;
+use App\Models\Jobfair\JobfairJob;
+use App\Models\Jobfairout\JobfairoutPutJob;
+use App\Models\Pms;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use App\Admin\Exports\Jobfairout\PutJobsExport;
+use Illuminate\Support\Facades\Cache;
+
+class JobfairoutPutJobsController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content,Request $request)
+    {
+        $company_id = isset($request->company_id) ? $request->company_id : false;
+        $grid=$this->grid($company_id)->render();
+        return $content
+            ->header('参会职位')
+            ->description('')
+            ->body(view('admin.jobfairout.put_jobs')->with(['grid'=>$grid]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('参会职位详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('参会职位编辑')
+            ->description('')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('参会职位创建')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid($company_id)
+    {
+        $grid = new Grid(new JobfairoutPutJob);
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('jobfair_company',function($query){
+                $query->whereHas('subsites', function ($query) {
+                    $query->where('subsite_id', get_subsite_id())->where('subsites.effective', 1);
+                });
+            });
+        })
+            ->when($company_id==true,function ($query) use ($company_id){
+                $query->where('company_id',$company_id);
+            })->whereHas('jobs')
+            ->orderBy('jobfair_id', 'desc')
+            ->orderBy('updated_at', 'desc');
+
+
+        $grid->jobs_name('职位名称')->display(function ($jobs_name) {
+            return '<a href="/content/jobfairout/show/quarters/'.$this->id.'" target="_blank">'.$jobs_name.'</a>';
+        })->width(200);
+        $grid->company_name('发布公司')->display(function ($company_name) {
+            return '<a href="/content/jobs/company?id='.$this->company_id.'" target="_blank">'.$company_name.'</a>';
+        })->width(200);
+        $grid->column('jobfairs.title', '招聘会标题')->display(function ($title) {
+            return "<a href='/content/jobfairout/show/com/".$this->jobfair_id."' target='_blank'>".$title."</a>";
+        })->width(200);
+        $grid->audit('审核状态')->display(function () {
+            if ($this->jobs->audit==1) {
+                return'<span style="color: #009900">审核通过</span>';
+            } elseif ($this->jobs->audit==3) {
+                return'<span style="color:#666666">审核未通过</span>';
+            } else {
+                return'<span style="color:#FF6600">等待审核</span>';
+            }
+        });
+
+        $grid->amount('人数')->display(function ($amount){
+            return $amount ? $amount : '若干';
+        });
+        $grid->district_cn('工作地区')->width(150);
+        if(get_subsite_open()){
+            $grid->column('jobfairs.subsite_id', '所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            });
+        }
+        $grid->created_at('创建时间');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('jobfairout_put_jobs_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('jobfairout_put_jobs_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        if (Admin::user()->can('jobfairout_put_jobs_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new PutJobsExport()); //传入自己在第1步创建的导出类
+        }
+
+//        $grid->tools(function ($tools) {
+//
+//            if (Admin::user()->can('jobfair_put_jobs_audit')) {
+//                $but = <<<EOT
+//<div class="btn-group" data-toggle="buttons">
+//    <label class="btn btn-google btn-sm" id="Audit_Put_Jobs" title="审核职位">
+//        <i class="fa fa-audio-description"></i>
+//        <input type="radio" class="user-gender">审核职位
+//    </label>
+//</div>
+//EOT;
+//                $tools->append($but);
+//            }
+//        });
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('jobs_name', '职位名称');
+                $filter->equal('jobfair_id', '招聘会')->select(Jobfairout::select('title', 'id')->when(get_subsite_id()>0,function ($query){
+                    $query->whereHas('subsites', function ($query) {
+                        $query->where('subsite_jobfairouts.subsite_id', get_subsite_id())->where('subsites.effective', 1);
+                    });
+                })->pluck('title', 'id')->all());
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '刷新时间', 'updated_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+                if(get_subsite_id() == 0 && get_subsite_open()){
+                    $filter->equal('jobfairs.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('company_name', '公司名称');
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 1:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('audit',1);
+                            });
+                            break;
+                        case 2:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('audit',2);
+                            });
+                            break;
+                        case 3:
+                            $query->whereHas('jobs',function ($query){
+                                $query->where('audit',3);
+                            });
+                            break;
+                    }
+                }, '审核状态', 'audit')->select([
+                    1=>'审核通过',
+                    2=>'等待审核',
+                    3=>'审核未通过',
+                ]);
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 1:
+                            $query->where('display',1)->where('audit',1);
+                            break;
+                        case 2:
+                            $query->where('display',2)->orWhere('audit','<>',1);
+                            break;
+                    }
+                }, '显示状态', 'display')->select([
+                    1=>'显示',
+                    2=>'关闭',
+                ]);
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairoutPutJob::findOrFail($id));
+
+        $show->id('ID');
+        $show->jobs_name('职位名称')->as(function ($jobs_name) {
+            return $jobs_name;
+        });
+        $show->company_name('发布公司')->as(function ($company_name) {
+            return $company_name;
+        });
+        $show->jobfairs()->title('招聘会标题')->as(function ($jobfairs) {
+            return $jobfairs->title;
+        });
+
+        $show->audit('审核状态')->as(function ($audit) {
+            if ($this->jobs->audit==1) {
+                return '审核通过';
+            } elseif ($this->jobs->audit==3) {
+                return '审核未通过';
+            } else {
+                return '等待审核';
+            }
+        });
+
+        $show->display('显示状态')->as(function () {
+            if ($this->jobs->audit==1 && $this->jobs->display==1) {
+                return '显示';
+            } else {
+                return '关闭';
+            }
+        });
+        $show->amount('人数')->as(function ($amount) {
+            return $amount;
+        });
+        $show->district('工作地区')->as(function ($district_cn) {
+            return $district_cn;
+        });
+
+        $show->jobfairs()->subsite('所属分站')->as(function ($jobfairs) {
+            if ($jobfairs->subsite_id) {
+                $Subsite = Subsite::find($jobfairs->subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+        $show->jobs_content('职位描述')->setEscape(false);
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new JobfairoutPutJob);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+    public function auditPutJobs(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(admin_base_path('/jobfair/auditPutR'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '审核')->options([1=>'审核通过',3=>'审核未通过'])->default(1);
+        $form->textarea('remark', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核职位']);
+    }
+
+    public function auditPutR(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $remark = $request->remark;
+        $pms_notice = $request->pms_notice;
+        $arr = array_filter(explode(',', $id));
+        if (empty($id)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $job_ids = JobfairoutPutJob::whereIn('id', $arr)->pluck('job_id');
+        $result = JobfairJob::whereIn('id', $job_ids)->update(['audit'=>$audit]);
+        foreach ($arr as $k => $v){
+            $job = JobfairoutPutJob::where('id', $v)->first();
+            Cache::put($job->jobfair_id.'-'.$job->company_id, time(),72000);
+        }
+        $data=[];
+        foreach ($arr as $k => $v) {
+            $data[$k]['type'] = 12;
+            $data[$k]['type_id'] = $v;
+            $data[$k]['status'] = $audit;
+            $data[$k]['reason'] = $remark;
+            $data[$k]['audit_man'] = Admin::user()->username;
+            $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+            $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        AuditReason::insert($data);
+        if ($pms_notice) {
+            if ($audit==3) {
+                $stat='审核不通过';
+            } elseif ($audit==1) {
+                $stat = '审核通过';
+            } else {
+                $stat='待审核';
+            }
+            $reus=JobfairoutPutJob::whereIn('id', $arr)->get();
+            $ds = [];
+            foreach ($reus as $k => $v) {
+                $ds[$k]['utype'] = 1;
+                $ds[$k]['msgtype'] = 1;
+                $ds[$k]['msgfromuid'] = Admin::user()->id;
+                $ds[$k]['msgfrom'] = Admin::user()->username;
+                $ds[$k]['msgtoname'] = $v->company_name ? $v->company_name : 'admin';
+                $ds[$k]['msgtouid'] = $v->company_id ? $v->company_id : 0;
+                $ds[$k]['message'] =  $remark ? '参会职位(id:'.array_values($arr)[$k].')'.$stat.'<备注:'.$remark.'>' : '参会职位(id:'.array_values($arr)[$k].')'.$stat;
+                $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+            }
+            Pms::insert($ds);
+        }
+        if ($result) {
+            admin_toastr('审核成功', 'success');
+        } else {
+            admin_toastr('审核失败', 'error');
+        }
+        return back();
+    }
+}

+ 186 - 0
app/Admin/Controllers/Jobfairout/JobfairoutSchoolController.php

@@ -0,0 +1,186 @@
+<?php
+
+namespace App\Admin\Controllers\Jobfairout;
+
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use App\Models\Jobfairout\JobfairoutSchool;
+use App\Admin\Exports\Jobfairout\SchoolExport;
+use App\Admin\Extensions\Form\ValidateForm;
+class JobfairoutSchoolController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        $grid = $this->grid()->render();
+        return $content
+            ->header('学校列表')
+            ->description('')
+            ->body(view('admin.jobfairout.school')->with(['grid'=>$grid]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('招聘会详情')
+            ->description('')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('学校编辑')
+            ->description('')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('学校创建')
+            ->description('带*号必填项')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new JobfairoutSchool);
+        $grid->model()->orderBy('sort', 'desc');
+        $grid->id('ID');
+        $grid->name('校名')->width(200);
+        $grid->url('官网')->display(function ($url){
+            return "<a target='_blank' href='$url'>".$url."</a>";
+        })->width(200);
+        $grid->logo('校徽')->display(function($logo){
+            return '<span class="vtip" title="<img src=\''.upload_asset($logo).'\' height=120>">
+                            <img class="avatar small" src="'.upload_asset($logo).'" align="absmiddle" style="width: 22px;height: 22px;">
+                        </span>';
+        });
+        $grid->major('专业优势')->width(400);
+        $grid->created_at('创建时间');
+        $grid->filter(function ($filter) {
+            $filter->like('name', '校名');
+        });
+        if (Admin::user()->can('jobfairout_schools_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('jobfairout_schools_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+        if (Admin::user()->can('jobfairout_schools_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new SchoolExport()); //传入自己在第1步创建的导出类
+        }
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('jobfairout_schools_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('jobfairout_schools_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(JobfairoutSchool::findOrFail($id));
+
+        $show->id('ID');
+        $show->name('校名')->width(200);
+        $show->url('官网');
+        $show->logo('校徽')->image();
+        $show->major('专业优势');
+        $show->remarks('备注');
+        $show->introduce('简介')->setEscape(false);
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new JobfairoutSchool);
+        $form->text('name', '校名')->rules('required|max:50', array('required'=>'校名不能为空。', 'max'=>'校名长度不能大于50个字符。'))->setWidth(4)->setMustMark();
+        $form->url('url', '官网')->help('(请输入包含http://或https://的完整链接)')->setMustMark();
+        $form->image('logo', '校徽')->uniqueName()->rules('image|mimes:jpeg,bmp,png', array('image'=>'校徽请选择图片文件。','mimes'=>'请选择jpeg,bmp,png格式的校徽上传。'))->setMustMark()->setWidth(3);
+        $form->textarea('major', '优势专业')->rules('max:255', array('max'=>'优势专业不能大于255个字符。'))->setMustMark();
+        $form->textarea('remarks', '备注')->rules('max:255', array('max'=>'备注不能大于255个字符。'));
+        $form->editor('introduce', '简介')->rules('required', array('required'=>'简介不能为空。'))->setMustMark();
+        $form->number('sort', '排序')->min(1)->max(255)->default(1)->help('(数字越大越靠前)')->setMustMark();
+        return $form;
+    }
+
+    public function destroy($id)
+    {
+        if ($this->form()->destroy($id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 202 - 0
app/Admin/Controllers/Lottery/PrizeController.php

@@ -0,0 +1,202 @@
+<?php
+
+namespace App\Admin\Controllers\Lottery;
+
+use App\Admin\Extensions\Form\ValidateForm;
+use App\Http\Controllers\Controller;
+use App\Models\LotteryPrize;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+
+class PrizeController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('奖品列表')
+            ->description('请确保总概率达到100%')
+            ->body(view('admin.lottery.prize')->with(['grid'=>$this->grid()]));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('奖品设置')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('奖品设置')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new LotteryPrize);
+
+        $grid->model();
+
+        $grid->id('ID');
+        $grid->column('prize_name','奖品名称');
+        $grid->prize_image('奖品图片')->display(function () {
+            if ($this->prize_image) {
+                return '<span class="vtip" title="<img src=\'' . upload_asset($this->prize_image) . '\'  height=120>">
+                            <img class="avatar small" src="' . upload_asset($this->prize_image) . '" align="absmiddle" style="width: 22px;height: 22px;">
+                        </span>';
+            } else {
+                return '';
+            }
+        });
+        $grid->prize_odds('中奖概率')->display(function () {
+            return $this->prize_odds . '%';
+        });
+        $grid->prize_bg('奖品背景色')->display(function () {
+            if ($this->prize_bg) {
+                return '<div style="width: 22px;height: 22px;background-color:'.$this->prize_bg.'"></div>';
+            } else {
+                return '';
+            }
+        });
+        $grid->column('prize_number','奖品数量');
+        //新增按钮
+        if (userAdmin::user()->can('prize_add')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (userAdmin::user()->can('prize_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        } else {
+            $grid->disableRowSelector();
+        }
+
+        $grid->actions(function ($actions) {
+            if (userAdmin::user()->can('prize_delete')) {
+                $actions->disableEdit(false);
+            }
+            if (userAdmin::user()->can('prize_edit')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new LotteryPrize());
+        $form->text('prize_name', '奖品名称')->rules('required|max:100', ['required' => '奖品名称不能为空。', 'max' => '标题长度不能大于100。'])->setWidth(4)->setMustMark();
+        $form->image('prize_image', '奖品图片')->uniqueName()->rules('image|mimes:jpeg,bmp,png', ['image' => '缩略图请选择图片文件。', 'mimes' => '请选择jpeg,bmp,png格式的缩略图上传。'])->setWidth(4);
+        $form->number('prize_odds', '中奖概率(%)')->rules('required', ['required' => '中奖概率不能为空。'])->setWidth(4)->setMustMark();
+        $form->color('prize_bg', '背景颜色')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', ['required' => '标题颜色不能为空。', 'regex' => '标题颜色格式不正确。'])->default('#000000');
+        $form->number('prize_number', '奖品数量')->rules('required', ['required' => '奖品数量不能为空。'])->setWidth(4)->setMustMark();
+
+        $form->saved(function (Form $form) {
+            //如果没有上传logo,判断是否
+            $prize_image = \Illuminate\Support\Facades\Request::input('prize_image');
+            if (!$form->model()->prize_image && $prize_image) {
+                $form->model()->prize_image = $prize_image;
+                $form->model()->save();
+            }
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        return $form;
+    }
+
+    protected function editForm($id)
+    {
+
+        $form = new ValidateForm(new LotteryPrize);
+
+        $form->text('prize_name', '奖品名称')->rules('required|max:100', ['required' => '奖品名称不能为空。', 'max' => '标题长度不能大于100。'])->setWidth(4)->setMustMark();
+        $form->image('prize_image', '奖品图片')->uniqueName()->rules('image|mimes:jpeg,bmp,png', ['image' => '缩略图请选择图片文件。', 'mimes' => '请选择jpeg,bmp,png格式的缩略图上传。'])->setWidth(4);
+        $form->number('prize_odds', '中奖概率(%)')->rules('required', ['required' => '中奖概率不能为空。'])->setWidth(4)->setMustMark();
+        $form->color('prize_bg', '背景颜色')->rules('required|regex:/^#[a-fA-F0-9]{6}$/', ['required' => '标题颜色不能为空。', 'regex' => '标题颜色格式不正确。'])->default('#000000');
+        $form->number('prize_number', '奖品数量')->rules('required', ['required' => '奖品数量不能为空。'])->setWidth(4)->setMustMark();
+
+        $form->saved(function (Form $form) {
+            //如果没有上传logo,判断是否
+            $prize_image = \Illuminate\Support\Facades\Request::input('prize_image');
+            if (!$form->model()->prize_image && $prize_image) {
+                $form->model()->prize_image = $prize_image;
+                $form->model()->save();
+            }
+        });
+
+        $form->footer(function ($footer) {
+            $footer->disableViewCheck();
+            $footer->disableEditingCheck();
+            $footer->disableCreatingCheck();
+            $footer->disableReset();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            $tools->disableDelete();
+            $tools->disableView();
+        });
+        return $form;
+    }
+
+    public function destroy($id)
+    {
+        //是否存在报名列表
+        if ($this->form()->destroy($id)) {
+            $data = [
+                'status'  => true,
+                'message' => trans('admin.delete_succeeded'),
+            ];
+        } else {
+            $data = [
+                'status'  => false,
+                'message' => trans('admin.delete_failed'),
+            ];
+        }
+        return response()->json($data);
+    }
+}

+ 90 - 0
app/Admin/Controllers/Lottery/WinController.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Admin\Controllers\Lottery;
+
+use App\Http\Controllers\Controller;
+use App\Models\LotteryWin;
+use Encore\Admin\Facades\Admin as userAdmin;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Illuminate\Http\Request;
+
+class WinController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('中奖列表')
+            ->description('')
+            ->body(view('admin.lottery.win')->with(['grid' => $this->grid()]));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $status = ['', '未领奖', '已领奖'];
+
+        $grid = new Grid(new LotteryWin);
+        $grid->model()->orderBy('status', 'ASC')->orderBy('created_at','DESC');
+
+        $grid->model();
+
+        $grid->id('ID');
+        $grid->column('member.mobile', '手机号');
+        $grid->column('member.email', '邮箱号');
+        $grid->column('prize.prize_name', '奖品名称');
+        $grid->created_at('中奖时间');
+        $grid->out_at('核销时间');
+        $grid->status('状态')->display(function () use ($status) {
+            return $status[$this->status];
+        });
+
+        $grid->actions(function ($actions) {
+            if ($actions->row['status'] == 1) {
+                $actions->append('<button data-id="'.$actions->row['id'].'" class="btn btn-primary btn-xs write-off" title="核销" >核销</button>');
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->where(function ($query) {
+                $query->whereHas('member', function ($query) {
+                    $query->where('email', 'like', "%{$this->input}%")->orWhere('mobile', 'like', "%{$this->input}%");
+                });
+            }, '手机/邮箱');
+
+            $filter->equal('status', '状态')->select([
+                1 => '未领奖',
+                2 => '已领奖',
+            ]);
+        });
+
+        return $grid;
+    }
+
+    /**
+     *  return json
+     */
+    public function writeoff(Request $request)
+    {
+        $id = $request->input('id');
+        $info = LotteryWin::find($id);
+        $info->status = 2;
+        $info->out_at = date('Y-m-d H:i:s');
+        $info->save();
+
+        return response()->json([]);
+    }
+}

+ 150 - 0
app/Admin/Controllers/Person/HrBindController.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\HrBind;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class HrBindController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('HR列表')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new HrBind);
+
+        $grid->column('memberInfo.username', '用户名')->width(200);
+        $grid->column('companyInfo.companyname', '所在企业')->width(200);
+        $grid->column('memberInfo.mobile', '电话')->width(100);
+        $grid->column('memberInfo.email', '邮箱')->width(150);
+        $grid->status('绑定状态')->display(function () {
+            return $this->status?'绑定':'解绑';
+        });
+        $grid->binded_at('操作时间');
+
+        if (Admin::user()->can('person_hr_delete')) {
+            $grid->disableActions();
+            $grid->tools(function (Grid\Tools $tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('memberInfo.username', '用户名');
+                $filter->like('companyInfo.companyname', '企业名称');
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('memberInfo.mobile', '电话');
+                $filter->like('memberInfo.email', 'Email');
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(HrBind::findOrFail($id));
+
+        $show->id('ID');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new HrBind);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 198 - 0
app/Admin/Controllers/Person/JobSubscribeController.php

@@ -0,0 +1,198 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+/*use App\Models\JobSubscribe;*/
+
+use App\Http\Controllers\Controller;
+use App\Models\MemberInfo;
+use App\Models\PersonJobsSubscribe;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+/*use Encore\Admin\Grid;*/
+
+class JobSubscribeController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('职位订阅')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonJobsSubscribe);
+        $grid->model()->orderBy('id','desc');
+        $grid->email('接收邮箱')->width(150);
+        $grid->nature_cn('职位性质')->width(100);
+        $grid->intention_jobs('意向职位')->width(150);
+        $grid->trade_cn('意向行业')->width(150);
+        $grid->wage_cn('意向薪资')->width(100);
+        $grid->district_cn('意向地区')->width(150);
+        $grid->created_at('添加时间')->sortable();
+        $grid->disableExport();
+        $grid->disableCreateButton();
+
+        if (Admin::user()->can('person_subscribe_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('person_subscribe_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            /*$subsites = array(''=>'不限','0'=>'总站', '1' => '定海', '2' => '普陀');
+            $filter->equal('subsite_id', '所属分站')->select($subsites);*/
+            $filter->like('intention_jobs', '意向职位');
+            $filter->like('trade_cn', '意向行业');
+            $filter->like('district_cn', '意向地区');
+            $filter->like('email', '接收邮件');
+            $date3   = date('Y-m-d', strtotime("-3 day"));
+            $date7   = date('Y-m-d', strtotime("-7 day"));
+            $date30  = date("Y-m-d", strtotime("-1 month"));
+            $date180 = date("Y-m-d", strtotime("-6 month"));
+            $date360 = date("Y-m-d", strtotime("-1 year"));
+            $date_option = array(
+                ''    => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            );
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonJobsSubscribe::findOrFail($id));
+
+        $show->id('ID');
+        $show->uid('订阅用户')->as(function ($uid) {
+            $memberInfo = MemberInfo::where(['uid'=>$uid])->first();
+            if ($memberInfo) {
+                return $memberInfo->realname;
+            }
+            return '';
+        });
+        $show->title('订阅名称');
+        $show->trade_cn('行业分类');
+        $show->district_cn('工作地区');
+        $show->intention_jobs('职能分类');
+        $show->sendTime_cn('发布日期');
+        $show->experience_cn('工作经验');
+        $show->wage_cn('薪资范围');
+        $show->education_cn('学历要求');
+        $show->rate_cn('接收频率');
+        $show->send_jobs_cn('发布职位数');
+        $show->nature_cn('职位性质');
+        $show->email('接收邮箱');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+
+        $show->panel()->tools(function ($tools) {
+            $tools->disableEdit();
+            $tools->disableDelete();
+        });
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonJobsSubscribe);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 525 - 0
app/Admin/Controllers/Person/JobsApplyController.php

@@ -0,0 +1,525 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\Jobs;
+use App\Models\MemberInfo;
+use App\Models\PersonalJobsApply;
+use App\Models\Resume;
+use App\Models\Subsite;
+use App\Repositories\JobsRepository;
+use App\Repositories\PersonJobsApplyRepository;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class JobsApplyController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('申请职位')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('申请职位')
+            ->description('详细')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('申请职位')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('申请职位')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonalJobsApply);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('resumes', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->orderBy('id', 'desc');
+
+        $grid->id('ID');
+        $grid->jobs_name('职位名称')->width(200);
+
+        $grid->company_name('公司名称')->width(200);
+
+        $grid->resume_name('简历名称')->width(150);
+
+        $grid->is_reply('反馈状态')->display(function ($is_reply) {
+            switch ($is_reply) {
+                case 1:
+                    $is_reply = '企业未查看';
+                    break;
+                case 2:
+                    $is_reply = '待反馈';
+                    break;
+                case 3:
+                    $is_reply = '合适';
+                    break;
+                case 4:
+                    $is_reply = '不合适';
+                    break;
+                case 5:
+                    $is_reply = '待定';
+                    break;
+                case 6:
+                    $is_reply = '未接通';
+                    break;
+                default:
+                    $is_reply = '企业未查看';
+                    break;
+            }
+            return $is_reply;
+        });
+
+
+        $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
+            if ($subsite_id) {
+                $Subsite = Subsite::find($subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        })->width(150);
+
+        $grid->created_at('申请时间')->sortable();
+        $grid->updated_at('更新时间')->sortable();
+
+        $grid->actions(function ($actions) use ($grid) {
+
+            if (Admin::user()->can('person_apply_jobs_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('person_apply_jobs_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->where(function ($query) {
+                switch ($this->input) {
+                    case 1:
+                        $query->whereRaw(" is_reply =".$this->input);
+                        break;
+                    case 2:
+                        $query->whereRaw(" is_reply =".$this->input);
+                        break;
+                    case 3:
+                        $query->whereRaw(" is_reply =".$this->input);
+                        break;
+                    case 4:
+                        $query->whereRaw(" is_reply =".$this->input);
+                        break;
+                    case 5:
+                        $query->whereRaw(" is_reply =".$this->input);
+                        break;
+                    case 6:
+                        $query->whereRaw(" is_reply =".$this->input);
+                        break;
+                }
+            }, '申请反馈', 'inter')->select([
+                1=>'企业未查看',
+                2=>'待反馈',
+                3=>'合适',
+                4=>'不合适',
+                5=>'待定',
+                6=>'未接通',
+            ]);
+            $filter->where(function ($query) {
+                switch ($this->input) {
+                    case 3:
+                        $date = date('Y-m-d H:i:s', strtotime('-3 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 7:
+                        $date = date('Y-m-d H:i:s', strtotime('-7 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 30:
+                        $date = date('Y-m-d H:i:s', strtotime('-30 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 180:
+                        $date = date('Y-m-d H:i:s', strtotime('-180 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 365:
+                        $date = date('Y-m-d H:i:s', strtotime('-365 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                }
+            }, '申请时间', 'apply')->select([
+                3=>'三天内',
+                7=>'一周内',
+                30=>'一月内',
+                180=>'半年内',
+                365=>'一年内',
+            ]);
+            $filter->like('company_name', '公司名称');
+            $filter->like('resume_name', '简历名称 ');
+            $filter->equal('personal_uid', '个人会员ID ');
+            if(get_subsite_id()==0){
+                $filter->equal('members.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+            }
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonalJobsApply::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->jobs_name('职位名称');
+
+        $show->company_name('公司名称');
+
+        $show->resume_name('简历名称');
+
+        $show->is_reply('反馈状态')->as(function ($is_reply) {
+            switch ($is_reply) {
+                case 1:
+                    $is_reply = '企业未查看';
+                    break;
+                case 2:
+                    $is_reply = '待反馈';
+                    break;
+                case 3:
+                    $is_reply = '合适';
+                    break;
+                case 4:
+                    $is_reply = '不合适';
+                    break;
+                case 5:
+                    $is_reply = '待定';
+                    break;
+                case 6:
+                    $is_reply = '未接通';
+                    break;
+                default:
+                    $is_reply = '企业未查看';
+                    break;
+            }
+            return $is_reply;
+        });
+
+        $show->members('所属分站')->as(function ($members) {
+            if ($members->subsite_id) {
+                $Subsite = Subsite::find($members->subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonalJobsApply);
+        $form->display('id');
+        $form->display('created_at');
+        $form->display('updated_at');
+        return $form;
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new PersonalJobsApply);
+        $form->setAction(route('admin.personal.addPoints'));
+        $MembersHandsel = MembersHandsel::findOrFail($id);
+        $utype = $MembersHandsel->utype;
+        $points = MembersHandsel::find($id)->membersPoints()->where('utype', $utype)->first();
+        $form->display('points_num', '会员积分')->with(function () use ($points) {
+            return $points->points;
+        });
+        $form->radio('points_type', '操作积分')->options([1 => '增加', 2=> '减少'])->default(1);
+        $form->number('many_point', '增减积分')->default(0)->min(0);
+        $form->text('explain', '操作说明');
+        $form->switch('ismany', '是否收费?');
+        $form->number('amount', '收费金额')->default(0)->min(0);
+        $form->hidden('points_id')->default($points->id);
+        $form->footer(function ($footer) {
+            // 去掉`重置`按钮
+            $footer->disableReset();
+            // 去掉`查看`checkbox
+            $footer->disableViewCheck();
+            // 去掉`继续编辑`checkbox
+            $footer->disableEditingCheck();
+            // 去掉`继续创建`checkbox
+            $footer->disableCreatingCheck();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            // 去掉`删除`按钮
+            $tools->disableDelete();
+        });
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new PersonalJobsApply);
+        $form->display('id');
+        $form->display('created_at');
+        $form->display('updated_at');
+        return $form;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param int $id
+     *
+     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+
+    public function applyJobs(Content $content)
+    {
+        $id = request()->id;
+        $uid = request()->uid;
+        $resume = Resume::where(['id'=>$id])->first();
+        $member = MemberInfo::where(['uid'=>$uid])->first();
+        return $content
+            ->header('职位匹配')
+            ->description('列表')
+            ->body(view('admin.jobs.find_jobs')->with(['grid'=>$this->gridApply(),'resume'=>$resume,'member'=>$member]));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function gridApply()
+    {
+        $grid = new Grid(new Jobs);
+        $grid->model()->where('valid',1)->where('display',1)->whereIn('audit', getJobsStatus())->orderBy('id', 'desc');
+        $grid->id('ID');
+        $grid->jobs_name('职位名称');
+        $grid->company_name('公司名称');
+        $grid->audit('审核状态')->display(function ($audit) {
+            switch ($audit) {
+                case 1:
+                    $audit = '<span style="color: #00a65a;">审核通过</span>';
+                    break;
+                case 2:
+                    $audit = '<span>审核中</span>';
+                    break;
+                case 3:
+                    $audit = '<span style="color: red;">审核未通过</span>';
+                    break;
+                default:
+                    $audit = '<span>审核中</span>';
+                    break;
+            }
+            return $audit;
+        });
+        $grid->column('categoryScale.demand', '公司规模');
+        $grid->column('categoryTrade.demand', '所属行业');
+        $grid->column('categoryEducation.demand', '职位要求');
+        $grid->column('categoryWage.demand', '薪资待遇');
+        $grid->created_at('添加时间')->sortable();
+        $grid->updated_at('更新时间')->sortable();
+        $grid->disableCreateButton();
+        $grid->disableExport();
+        $grid->disableActions();
+        $grid->tools(function ($tools) {
+            $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="Apply" title="投递">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">投递
+    </label>
+</div>
+EOT;
+            $tools->append($but);
+        });
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('jobs_name', '职位名称');
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('company_name', '公司名称');
+            });
+        });
+        return $grid;
+    }
+
+    public function applyCompanyJobs(PersonJobsApplyRepository $personJobsApplyRepository, JobsRepository $jobsRepository)
+    {
+        $jobs_id = request()->jobs_id;
+        $resume_id = request()->resume_id;
+        $resume_name = request()->resume_name;
+        $personal_uid = request()->personal_uid;
+        if (empty($jobs_id)) {
+            return json_encode(['code'=>0,'info'=>'职位信息不存在!']);
+        }
+        $resume = Resume::find($resume_id);
+        if (!$resume) {
+            return json_encode(['code'=>0,'info'=>'简历不存在!']);
+        }
+        $resume_display = config('aix.personal_set.per_set.show_set.resume_display');
+        if ($resume_display!=2) {
+            if ($resume->audit!=2) {
+                return json_encode(['code'=>0,'info'=>'审核中或审核未通过的简历无法投递!']);
+            }
+        } else {
+            if ($resume->audit==0) {
+                return json_encode(['code'=>0,'info'=>'审核未通过的简历无法投递!']);
+            }
+        }
+        if ($resume->display!=1) {
+            return json_encode(['code'=>0,'info'=>'简历已关闭,无法投递!']);
+        }
+        $defaultPre = config('aix.personal_set.per_set.per_set.apply_job_min_percent');
+        if ($defaultPre) {
+            if ($resume->complete_percent<$defaultPre) {
+                return json_encode(['code'=>0,'info'=>'您的简历完整度小于'.$defaultPre.'%,无法投递!']);
+            }
+        }
+        $todayCount = $personJobsApplyRepository->getTodayCount($resume->uid);
+        if ($todayCount>=config('aix.personal_set.per_set.per_set.apply_jobs_max')) {
+            return json_encode(['code'=>0,'info'=>"您每天可以投递".config('aix.personal_set.per_set.per_set.apply_jobs_max')."个职位,今天已投递了{$todayCount}个"]);
+        }
+        $id = array_filter(explode(',', $jobs_id));
+        $displayJobs = $jobsRepository->getDisplayJobs($id, 2);
+
+        if (!empty($displayJobs)) {
+            $disJobs =  array_diff($id, array_column($displayJobs, 'id'));
+            if (empty($disJobs)) {
+                return json_encode(['code'=>0,'info'=>'您投递的职位已关闭!']);
+            }
+            $id = $disJobs;
+        }
+        $jobsApply = $personJobsApplyRepository->personApplyByTime(
+            $id,
+            $resume->uid,
+            config('aix.personal_set.per_set.per_set.apply_job_space')
+        );
+        if (!empty($jobsApply)) {
+            $disApply = array_diff($id, array_column($jobsApply, 'jobs_id'));
+            if (empty($disApply)) {
+                return json_encode(['code'=>0,'info'=>'您已经申请过这个职位了!']);
+            }
+            $id = $disApply;
+        }
+        $jobs = $jobsRepository->getJobs($id);
+        $arr = [];
+        foreach ($jobs as $key => $val) {
+            $arr[$key]['resume_id'] = $resume_id;
+            $arr[$key]['resume_name'] = $resume_name;
+            $arr[$key]['personal_uid'] = $personal_uid;
+            $arr[$key]['jobs_id'] = $val->id;
+            $arr[$key]['jobs_name'] = $val->jobs_name;
+            $arr[$key]['company_id'] = $val->company_id;
+            $arr[$key]['company_name'] = $val->company_name;
+            $arr[$key]['is_apply'] = 2;
+            $arr[$key]['created_at'] = date('Y-m-d H:i:s', time());
+            $arr[$key]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        $res = PersonalJobsApply::insert($arr);
+        if ($res) {
+            return json_encode(['code'=>1,'info'=>'投递成功!']);
+        } else {
+            return json_encode(['code'=>0,'info'=>'投递失败!']);
+        }
+    }
+}

+ 1010 - 0
app/Admin/Controllers/Person/MemberController.php

@@ -0,0 +1,1010 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Admin\Exports\Person\MemberExport;
+use App\Http\Controllers\Controller;
+use App\Models\CategoryMajor;
+use App\Models\CompanyInterView;
+use App\Models\Member;
+use App\Models\MemberInfo;
+use App\Models\MembersHandsel;
+use App\Models\MembersLog;
+use App\Models\Order;
+use App\Models\PersonalJobsApply;
+use App\Models\PersonalServiceStickLog;
+use App\Models\Resume;
+use App\Models\ResumeImg;
+use App\Models\SmsRule;
+use App\Models\Subsite;
+use App\Models\SubsiteResume;
+use App\Models\Category;
+use App\Models\CategoryDistrict;
+use App\Services\Common\SmsService;
+use Encore\Admin\Auth\Permission;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Encore\Admin\Widgets\Tab;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Validation\Rule;
+use App\Admin\Extensions\Form\ValidateForm;
+use Illuminate\Support\Facades\DB;
+class MemberController extends Controller
+{
+    use HasResourceActions;
+
+    protected $smsService;
+
+    public function __construct(SmsService $smsService)
+    {
+        $this->smsService = $smsService;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        Permission::check('person_member');
+        $grid=$this->grid()->render();
+        return $content
+            ->header('个人会员')
+            ->description('列表')
+            ->body(view('admin.members.index')->with('grid', $grid));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('个人会员')
+            ->description('详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        Permission::check('person_member_edit');
+        return $content
+            ->header('个人会员')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        Permission::check('person_member_add');
+        return $content
+            ->header('个人会员')
+            ->description('新增')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Member);
+
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+            $query->whereHas('subsite',function ($query){
+                $query->where('effective', 1);
+            });
+        })->orderBy('id', 'desc');
+
+
+
+        $grid->id('ID');
+        $grid->username('用户名')->width(200);;
+        $grid->mobile('手机')->width(100);
+        $grid->email('Email')->width(150);
+        if(get_subsite_open()){
+            $grid->subsite_id('所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            })->width(150);
+        }
+        $grid->reg_time('注册时间')->display(function ($reg_time) {
+            return date('Y-m-d H:i:s', $reg_time);
+        })->sortable();
+        $grid->last_login_time('最后登录时间')->display(function ($last_login_time) {
+            return $last_login_time ? date('Y-m-d H:i:s', $last_login_time) : '';
+        })->sortable();
+        if (Admin::user()->can('person_member_add')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('perosn_business')) {
+                $actions->append("&nbsp;<button class='btn btn-primary btn-xs business' id=".$actions->row['id'].">业务</button>");
+            }
+            if (Admin::user()->can('person_member_delete')) {
+                $actions->disableDelete(false);
+            }
+            if (Admin::user()->can('person_member_edit')) {
+                $actions->disableEdit(false);
+            }
+        });
+
+        $grid->tools(function ($tools) {
+
+            if (Admin::user()->can('person_member_reset_password')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="update_password" title="重置密码">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">重置密码
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+
+
+        });
+
+        if (Admin::user()->can('person_member_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new MemberExport()); //传入自己在第1步创建的导出类
+        }
+
+
+        $grid->filter(function ($filter) {
+
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('id', '会员ID');
+                $filter->like('username', '用户名');
+                $filter->like('memberInfo.id_card', '身份证');
+                $filter->between('created_at', '注册时间')->datetime();
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->like('email', 'Email');
+                $filter->like('mobile', '手机号码');
+
+                if(get_subsite_id()==0 && get_subsite_open()){
+                    $filter->equal('subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Member::findOrFail($id));
+
+        $show->username('用户名');
+        $show->mobile('mobile', '手机号');
+        $show->email('email', '邮箱');
+        $show->image('avatars', '用户头像');
+
+        $show->reg_address('注册地址');
+
+        $show->subsite_id('分站')->as(function ($subsite_id) {
+            if ($subsite_id) {
+                $Subsite = Subsite::find($subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+
+        $show->created_at('创建时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new ValidateForm(new Member);
+        $form->tab('账号资料',function ($form) {
+            $form->text('username', '用户名')->rules('required|between:6,16|regex:/^[a-zA-Z][a-zA-Z0-9]{6,16}+$/|unique:members', [
+                'required' => '会员名为必填信息',
+                'between' => '会员名长度为6~16个字符',
+                'regex' => '会员名为字母或字母+数字',
+                'unique' => '会员名已存在'
+            ])->setWidth(3)->setMustMark();
+            $form->mobile('mobile', '手机号')->rules('required|unique:members', [
+                'required' => '手机号为必填信息',
+                'unique' => '手机号已存在',
+            ])->setWidth(3)->setMustMark();
+            $form->radio('mobile_audit', '手机认证')->options([1 => '认证通过', 0 => '未认证'])->default(0);
+            $form->email('email', 'Email')->rules('required|unique:members', [
+                'required' => 'Email为必填信息',
+                'unique' => 'Email已存在'
+            ])->setWidth(3)->setMustMark();
+            $form->radio('email_audit', '邮箱认证')->options([1 => '认证通过', 0 => '未认证'])->default(0);
+            $form->password('password', '密码')->rules('required|confirmed|between:6,16', [
+                'required' => '密码为必填信息',
+                'between' => '密码长度要求为6~16'
+            ])->setWidth(3)->setMustMark();
+            $form->password('password_confirmation', '确认密码')->rules('required|between:6,16')->setWidth(3)->setMustMark();
+            $form->radio('display_images', '是否显示头像')->options([1 => '显示', 2 => '隐藏'])->default(1);
+            $form->image('avatars', '用户头像')->setWidth(4);
+        })->tab('基本资料',function ($form) {
+            $form->radio('display_name', '是否公开姓名')->setWidth(3)->options([1 => '公开', 3 => '隐藏'])->default(config('aix.personal_set.per_set.per_set.resume_display_default'))->setMustMark();
+            $form->text('realname', '姓名')->setWidth(3)->rules('required', [
+                'required' => '姓名为必填信息'
+            ])->setMustMark();
+            $form->radio('sex', '性别')->setWidth(3)->options([1 => '男', 2 => '女'])->default(1)->setMustMark();
+            $birthday = [];
+            $year = date('Y')-16;
+            for($i=1950;$i<$year;$i++){
+                $birthday[$i] = $i;
+            }
+            $form->select('birthday', '出生年份')->setWidth(3)->options($birthday)->default(1990)->setMustMark();
+//            $form->select('card_t_cn', '证件类型')->setWidth(3)->options(Category::where('alias','AIX_card_type')->pluck('demand','id'))->rules('required',[
+//                'required'=>'请选择证件类型'
+//            ])->setMustMark();
+            $form->text('id_card', '证件号')->setWidth(3)->rules('required|unique:member_infos', [
+                'required' => '证件号为必填信息',
+                'unique' => '该证件号已存在'
+            ])->setMustMark();
+            $form->select('province', '居住地省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                'required'=>'请选择居住地省份'
+            ])->setMustMark();
+            $form->select('city', '居住地城市')->setWidth(3)->load('area',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                'required'=>'请选择居住地城市'
+            ])->setMustMark();
+//            $form->select('area', '居住地县区')->setWidth(3)->rules('required', [
+//                'required'=>'请选择居住地县区'
+//            ])->setMustMark();
+            $form->select('education', '最高学历')->setWidth(3)->options(Category::where('alias','AIX_education')->pluck('demand','id'))->rules('required', [
+                'required'=>'请选择最高学历'
+            ])->setMustMark();
+            $form->select('major1', '专业方向')->options(CategoryMajor::where('parent_id',0)->pluck('name', 'id'))->setWidth(3)->load('major2',  admin_base_path("/sys/category/categoryMaj"));
+//            $form->select('major2', '详细专业')->setWidth(3);
+            $form->select('experience', '工作经验')->options(Category::where('alias','AIX_experience')->pluck('demand','id'))->setWidth(3)->rules('required', [
+                'required'=>'请选择工作经验'
+            ])->setMustMark();
+        })->tab('联系方式',function ($form) {
+            $form->select('province1', '籍贯所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city1',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                'required'=>'请选择籍贯所属省份'
+            ])->setMustMark();
+            $form->select('city1', '籍贯所属城市')->setWidth(3)->load('area1',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                'required'=>'请选择籍贯所属城市'
+            ])->setMustMark();
+//            $form->select('area1', '籍贯所属县区')->setWidth(3)->rules('required', [
+//                'required'=>'请选择相籍贯所属县区'
+//            ])->setMustMark();
+            $form->number('height', '身高')->setWidth(3);
+            $form->select('marriage', '婚姻状况')->options(['1'=>'未婚','2'=>'已婚','3'=>'保密'])->setWidth(3);
+            $form->number('qq', 'QQ')->setWidth(3);
+            $form->text('weixin', '微信')->setWidth(3);
+            $form->hidden('subsite_id', '所属分站')->default(get_subsite_id());
+        });
+        return $form;
+    }
+
+    public function store(Request $request)
+    {
+
+        $data = $this->form()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
+        if($data['password'] != $data['password_confirmation']) {
+            admin_toastr('两次密码输入不同', 'error');
+            return back();
+        }
+        $member_data = [
+            'username' => $data['username'],
+            'password' => bcrypt($data['password']),
+            'mobile' => $data['mobile'],
+            'mobile_audit' => $data['mobile_audit'],
+            'email' => $data['email'],
+            'email_audit' => $data['email_audit'],
+            'avatars' => $data['avatars'],
+            'subsite_id' => $data['subsite_id'],
+            'reg_time' => time(),
+            'reg_ip' => ip2long('127.0.0.1'),
+            'last_login_ip' => ip2long('127.0.0.1'),
+            'reg_address' => '本机地址',
+            'last_login_time' => time(),
+            'status' => 1,
+        ];
+        $member_info_data = [
+            'display_name'=>$data['display_name'],
+            'realname'=>$data['realname'],
+            'sex'=>$data['sex'],
+            'sex_cn'=>$data['sex']==1?'男':'女',
+            'birthday'=>$data['birthday'],
+            'card_t_cn'=>306,
+            'id_card'=>$data['id_card'],
+            'residence'=>$data['province'].'.'.$data['city'].'.0',
+            'education'=>$data['education'],
+            'education_cn'=>get_category($data['education']),
+            'experience'=>$data['experience'],
+            'experience_cn'=>get_category($data['experience']),
+            'phone'=>$data['mobile'],
+            'email'=>$data['email'],
+            'height'=>$data['height'],
+            'qq'=>$data['qq'],
+            'weixin'=>$data['weixin'],
+            'marriage'=>$data['marriage'],
+            'images'=>$data['avatars'],
+            'marriage_cn'=>$data['marriage']==1?'未婚':($data['marriage']==2?'已婚':'保密'),
+            'householdaddress'=>$data['province1'].'.'.$data['city1'].'.0',
+        ];
+        $member_info_data['residence_cn'] =get_district_cn($member_info_data['residence']);
+        $member_info_data['householdaddress_cn'] =get_district_cn($member_info_data['householdaddress']);
+        DB::beginTransaction();
+        try {
+            $member = Member::create($member_data);
+            if(!$member){
+                throw new \Exception('新增失败');
+            }
+            $member_info_data['uid'] = $member->id;
+            if(!MemberInfo::create($member_info_data)){
+                throw new \Exception('新增失败');
+            }
+            $this->memberSms('sms_quick_register', $data['mobile'],$data['username'], $data['password']);
+            DB::commit();
+            admin_toastr('新增成功', 'success');
+        } catch (\Exception $e) {
+            DB::rollback();
+            admin_toastr($e->getMessage(), 'error');
+            return back();
+        }
+        return redirect(route("members.index"));
+    }
+
+    protected function editForm($id)
+    {
+        $subsiteArr = [];
+        $form = new ValidateForm(new Member);
+        $user = Member::findOrFail($id);
+        $userinfo = MemberInfo::where('uid',$id)->first();
+        if(get_subsite_open()){
+            $subsiteArr = array_column(get_all_subsite(), 'sitename', 'id');
+        }
+        $form->tab('账号资料',function ($form) use($user,$id ,$subsiteArr){
+            $form->display('reg_time', '注册时间')->setWidth(2)->with(function ($reg_time) {
+                return date('Y-m-d H:i:s', $reg_time);
+            });
+            $form->display('reg_ip', '注册IP')->setWidth(2)->with(function ($reg_ip) {
+                return long2ip($reg_ip);
+            });
+            $form->display('last_login_time', '最后登录时间')->setWidth(2)->with(function ($last_login_time) {
+                return $last_login_time ? date('Y-m-d H:i:s', $last_login_time) : '';
+            });
+            $form->display('last_login_ip', '最后登录IP')->setWidth(2)->with(function ($last_login_ip) {
+                return long2ip($last_login_ip);
+            });
+            $form->display('reg_address', '注册地址')->setWidth(4);
+            $form->html('基本信息');
+            $form->text('username', '用户名')->rules(
+                [
+                    'required',
+                    'between:6,16|regex:/^[a-zA-Z][a-zA-Z0-9]{6,16}+$/',
+                    Rule::unique('members')->ignore($id),
+                ],
+                [
+                    'required' => '会员名为必填信息',
+                    'between' => '会员名长度为6~16个字符',
+                    'regex' => '会员名为字母或字母+数字',
+                    'unique' => '会员名已存在'
+                ]
+            )->setWidth(3)->setMustMark();
+            $form->mobile('mobile', '手机号')->rules(
+                [
+                    'required',
+                    Rule::unique('members')->ignore($id),
+                ],
+                [
+                    'required' => '手机号码为必填信息',
+                    'unique' => '手机号已存在',
+                ]
+            )->setWidth(4)->setMustMark();
+            $form->radio('mobile_audit','手机认证')->options([1=>'认证通过',0=>'未认证'])->default($user->mobile_audit);
+            $form->email('email', 'Email')->rules(
+                [
+                    'required',
+                    'regex:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
+                    Rule::unique('members')->ignore($id),
+                ],
+                [
+                    'required' => 'email为必填信息',
+                    'regex' => 'email格式不正确',
+                    'unique' => 'email已存在',
+                ]
+            )->setWidth(3)->setMustMark();
+            $form->radio('email_audit','邮箱认证')->options([1=>'认证通过',0=>'未认证'])->default($user->email_audit);
+            $form->switch('status', '用户状态');
+            if (get_subsite_id()==0 && get_subsite_open()) {
+                $form->radio('subsite_id', '分站')->options($subsiteArr)->default($user->subsite_id);
+            } else {
+                $form->hidden('subsite_id');
+            }
+        })->tab('基本资料',function ($form) use ($id,$userinfo){
+            $form->radio('display_name', '是否公开姓名')->setWidth(3)->options([1 => '公开', 3 => '隐藏'])->default(isset($userinfo->display_name) ? $userinfo->display_name : '')->rules('required', [
+                'required' => '请选择是否公开姓名'
+            ])->setMustMark();
+            $form->text('realname', '姓名')->setWidth(3)->default(isset($userinfo->realname) ? $userinfo->realname : '')->rules('required', [
+                'required' => '姓名为必填信息'
+            ])->setMustMark();
+            $form->radio('sex', '性别')->setWidth(3)->options([1 => '男', 2 => '女'])->default(isset($userinfo->sex) ? $userinfo->sex : '')->rules('required', [
+                'required' => '请选择性别'
+            ])->setMustMark();
+            $birthday = [];
+            $year = date('Y')-16;
+            for($i=1950;$i<$year;$i++){
+                $birthday[$i] = $i;
+            }
+            $form->select('birthday', '出生年份')->setWidth(3)->options($birthday)->default(isset($userinfo->birthday) ? $userinfo->birthday : '')->setMustMark();
+//            $form->select('card_t_cn', '证件类型')->setWidth(3)->options(Category::where('alias','AIX_card_type')->pluck('demand','id'))->rules('required',[
+//                'required'=>'请选择证件类型'
+//            ])->default(isset($userinfo->card_t_cn) ? $userinfo->card_t_cn : '')->setMustMark();
+            $form->text('id_card', '证件号')->setWidth(3)->rules(
+                [
+                    'required',
+                    Rule::unique('member_infos')->ignore($id,'uid'),
+                ],
+                [
+                    'required' => '证件号为必填信息',
+                    'unique' => '证件号已存在',
+                ]
+            )->default(isset($userinfo->id_card) ? $userinfo->id_card : '')->setMustMark();
+            if (isset($userinfo->residence)) {
+                $residenceArr = string_to_array('.', $userinfo->residence);
+            }
+            if(isset($residenceArr)) {
+                $form->select('province', '居住地省份')->setWidth(3)->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择居住地省份'
+                ])->default(isset($residenceArr[0])?$residenceArr[0]:0)->setMustMark();
+                $form->select('city', '居住地城市')->setWidth(3)->options(CategoryDistrict::categoryDis(isset($residenceArr[0])?$residenceArr[0]:0))->load('area',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择居住地城市'
+                ])->default(isset($residenceArr[1])?$residenceArr[1]:0)->setMustMark();
+//                $form->select('area', '居住地县区')->setWidth(3)->options(CategoryDistrict::categoryDis(isset($residenceArr[1])?$residenceArr[1]:0))->rules('required', [
+//                    'required'=>'请选择居住地县区'
+//                ])->default(isset($residenceArr[2])?$residenceArr[2]:0)->setMustMark();
+            } else {
+                $form->select('province', '居住地省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择居住地省份'
+                ])->setMustMark();
+                $form->select('city', '居住地城市')->setWidth(3)->load('area',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择居住地城市'
+                ])->setMustMark();
+//                $form->select('area', '居住地县区')->setWidth(3)->rules('required', [
+//                    'required'=>'请选择居住地县区'
+//                ])->setMustMark();
+            }
+            $form->select('education', '最高学历')->setWidth(3)->options(Category::where('alias','AIX_education')->pluck('demand','id'))->rules('required', [
+                'required'=>'请选择最高学历'
+            ])->default(isset($userinfo->education) ? $userinfo->education : '')->setMustMark();
+            if(isset($userinfo->major)){
+                $parent_id = CategoryMajor::where('id',$userinfo->major)->value('parent_id');
+                $form->select('major1', '专业方向')->options(CategoryMajor::where('parent_id',0)->pluck('name', 'id'))->setWidth(3)->load('major2',  admin_base_path("/sys/category/categoryMaj"))->default($parent_id);
+                //$form->select('major2', '详细专业')->setWidth(3)->options(CategoryMajor::where('parent_id',$parent_id)->pluck('name', 'id'))->default($userinfo->major);
+            } else {
+                $form->select('major1', '专业方向')->options(CategoryMajor::where('parent_id',0)->pluck('name', 'id'))->setWidth(3)->load('major2',  admin_base_path("/sys/category/categoryMaj"));
+                //$form->select('major2', '详细专业')->setWidth(3);
+            }
+            $form->select('experience', '工作经验')->options(Category::where('alias','AIX_experience')->pluck('demand','id'))->setWidth(3)->rules('required', [
+                'required'=>'请选择工作经验'
+            ])->default(isset($userinfo->experience) ? $userinfo->experience : '')->setMustMark();
+        })->tab('联系方式',function ($form) use ($userinfo){
+            if(isset($userinfo->householdaddress)) {
+                $householdaddressArr = string_to_array('.', $userinfo->householdaddress);
+            }
+            if(isset($householdaddressArr)) {
+                $form->select('province1', '籍贯所属省份')->setWidth(3)->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city1',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择籍贯所属省份'
+                ])->default(isset($householdaddressArr[0])?$householdaddressArr[0]:0)->setMustMark();
+                $form->select('city1', '籍贯所属城市')->setWidth(3)->options(CategoryDistrict::categoryDis(isset($householdaddressArr[0])?$householdaddressArr[0]:0))->load('area1',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择籍贯所属城市'
+                ])->default(isset($householdaddressArr[1])?$householdaddressArr[1]:0)->setMustMark();
+//                $form->select('area1', '籍贯所属县区')->setWidth(3)->options(CategoryDistrict::categoryDis(isset($householdaddressArr[1])?$householdaddressArr[1]:0))->rules('required', [
+//                    'required'=>'请选择相籍贯所属县区'
+//                ])->default(isset($householdaddressArr[2])?$householdaddressArr[2]:0)->setMustMark();
+            }else {
+                $form->select('province1', '籍贯所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city1',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择籍贯所属省份'
+                ])->setMustMark();
+                $form->select('city1', '籍贯所属城市')->setWidth(3)->load('area1',  admin_base_path("/sys/category/categoryDis"))->rules('required', [
+                    'required'=>'请选择籍贯所属城市'
+                ])->setMustMark();
+//                $form->select('area1', '籍贯所属县区')->setWidth(3)->rules('required', [
+//                    'required'=>'请选择相籍贯所属县区'
+//                ])->setMustMark();
+            }
+            $form->number('height', '身高')->setWidth(3)->default(isset($userinfo->height) ? $userinfo->height : '');
+            $form->select('marriage', '婚姻状况')->options(['1'=>'未婚','2'=>'已婚','3'=>'保密'])->setWidth(3)->default(isset($userinfo->marriage) ? $userinfo->marriage : '');
+            $form->number('qq', 'QQ')->setWidth(3)->default(isset($userinfo->qq) ? $userinfo->qq : '');
+            $form->text('weixin', '微信')->setWidth(3)->default(isset($userinfo->weixin) ? $userinfo->weixin : '');
+        });
+        return $form;
+    }
+
+    public function update($id)
+    {
+        $data = $this->editForm($id)->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
+        $member_data = [
+            'username' => $data['username'],
+            'mobile' => $data['mobile'],
+            'mobile_audit' => $data['mobile_audit'],
+            'email' => $data['email'],
+            'email_audit' => $data['email_audit'],
+            'subsite_id' => $data['subsite_id'],
+            'reg_time' => time(),
+            'reg_ip' => ip2long('127.0.0.1'),
+            'last_login_ip' => ip2long('127.0.0.1'),
+            'reg_address' => '本机地址',
+            'last_login_time' => time(),
+            'status' => 1,
+        ];
+        $member_info_data = [
+            'display_name'=>$data['display_name'],
+            'realname'=>$data['realname'],
+            'sex'=>$data['sex'],
+            'sex_cn'=>$data['sex']==1?'男':'女',
+            'birthday'=>$data['birthday'],
+            'card_t_cn'=>306,
+            'id_card'=>$data['id_card'],
+            'residence'=>$data['province'].'.'.$data['city'].'.0',
+            'education'=>$data['education'],
+            'education_cn'=>get_category($data['education']),
+            'experience'=>$data['experience'],
+            'experience_cn'=>get_category($data['experience']),
+            'phone'=>$data['mobile'],
+            'email'=>$data['email'],
+            'height'=>$data['height'],
+            'qq'=>$data['qq'],
+            'weixin'=>$data['weixin'],
+            'marriage'=>$data['marriage'],
+            'marriage_cn'=>$data['marriage']==1?'未婚':($data['marriage']==2?'已婚':'保密'),
+            'householdaddress'=>$data['province1'].'.'.$data['city1'].'.0',
+        ];
+
+        DB::beginTransaction();
+        try {
+            if (!Member::where('id', $id)->update($member_data)) {
+                throw new \Exception('编辑失败');
+            }
+            if(MemberInfo::where('uid', $id)->first()) {
+                if (!MemberInfo::where('uid', $id)->update($member_info_data)) {
+                    throw new \Exception('编辑失败');
+                }
+            }else {
+                $member_info_data['uid'] = $id;
+                if (!MemberInfo::create($member_info_data)) {
+                    throw new \Exception('编辑失败');
+                }
+            }
+            $subsite_id =$data['subsite_id'];
+            if ($subsite_id!==null) {
+                $resume = Resume::where('uid', $id)->select('id', 'subsite_id')->get()->toArray();
+                if (!empty($resume)) {
+                    $resume_id = array_column($resume, 'id');
+                    $subsite_id_arr = array_unique(array_column($resume, 'subsite_id'));
+                    Resume::whereIn('id', $resume_id)->update(['subsite_id'=>$subsite_id]);
+                    event_search_update(Resume::class, implode(',', $resume_id), 'update');
+                    $SubsiteResume = SubsiteResume::whereIn('resume_id', $resume_id)->where('subsite_id', $subsite_id)->select('id')->get()->toArray();
+                    if ($SubsiteResume) {
+                        SubsiteResume::destroy(array_column($SubsiteResume, 'id'));
+                    }
+                    SubsiteResume::whereIn('subsite_id', $subsite_id_arr)->whereIn('resume_id', $resume_id)->update(['subsite_id'=>$subsite_id]);
+                }
+                event_search_update(Resume::class, [['where','uid', $id]], 'update');
+            }
+            DB::commit();
+            admin_toastr('编辑成功', 'success');
+        } catch (\Exception $e) {
+            DB::rollback();
+            admin_toastr($e->getMessage(), 'error');
+            return back();
+        }
+        return redirect(route("members.index"));
+    }
+
+    public function destroy($id)
+    {
+        if (!$id) {
+            $data = [
+                'status'  => false,
+                'message' => '会员信息不存在!!',
+            ];
+            return response()->json($data);
+        }
+        $id_arr =  explode(',', $id);
+
+        \DB::beginTransaction();
+        try {
+            Member::destroy($id_arr);
+            MemberInfo::whereIn('uid', $id_arr)->delete();
+            Resume::whereIn('uid', $id_arr)->delete();
+            ResumeImg::whereIn('uid', $id_arr)->delete();
+            $data = [
+                'status'  => true,
+                'message' => '删除成功!',
+            ];
+            $condition = [['whereIn','uid', $id_arr]];
+            event_search_update(Resume::class, $condition, 'delete');
+            \DB::commit();
+            return response()->json($data);
+        } catch (\Exception $e) {
+            \DB::rollback();
+            $data = [
+                'status'  => false,
+                'message' => '删除失败!',
+            ];
+            return response()->json($data);
+        }
+    }
+
+    public function manager($id)
+    {
+        $member = Member::findOrFail($id);
+        if (!$member) {
+            return false;
+        }
+        return redirect()->route('person.resume');
+    }
+
+    public function managerInto($id)
+    {
+        $member = Member::findOrFail($id);
+        if (!$member) {
+            return false;
+        }
+        $key=uniqid();
+        Cache::put($key, $member, 1);
+        $url=route('auth.thirdlogin.background', ['ticket' => $key])."?redirect_url=".urlencode(route('person.index'));
+        return redirect($url);
+    }
+
+    /**
+     *  return json
+     */
+    public function auditPassword(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.auditPass'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->html('<div>重置的新密码为123456,是否重置?</div>');
+        return json_encode(['html'=>$form->render(),'detail'=>'重置密码']);
+    }
+
+    public function auditPass(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $result = Member::whereIn('id', $arr)->update(['password'=>\Hash::make(123456)]);
+        if ($result) {
+            admin_toastr('重置成功', 'success');
+        } else {
+            admin_toastr('重置失败', 'error');
+        }
+        return back();
+    }
+
+    public function userInfoTab(Content $content, Request $request)
+    {
+        $uid = $request->uid;
+        $utype = 2;
+        $type = $request->type;
+        if (empty($uid) ) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $tab = new Tab();
+
+        $title = [
+            'points'=>'积分管理',
+            'order'=>'充值/订单',
+            'subscribe'=>'简历推广',
+            'apply'=>'申请的职位',
+            'interview'=>'面试邀请',
+            'log'=>'会员日志',
+        ];
+
+        foreach ($title as $key => $val) {
+            switch ($key) {
+                case 'points':
+                    $grid = new Grid(new MembersHandsel);
+
+                    $grid->model()->when(get_subsite_id()>0, function ($query) {
+                        $query->whereHas('members',function ($query){
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->where(['uid'=>$uid,'utype'=>$utype])->orderBy('id', 'desc');
+
+                    $grid->id('ID');
+                    $grid->uid('会员ID');
+                    $grid->utype('会员类型')->display(function ($utype) {
+                        if ($utype==1) {
+                            return '企业';
+                        } else {
+                            return '个人';
+                        }
+                    })->width(100);
+                    $grid->points('操作积分')->display(function ($points) {
+                        if ($this->operate==1) {
+                            return "<span style='color:green;'>+".$points."</span>";
+                        } else {
+                            return "<span style='color:red;'>-".$points."</span>";
+                        }
+                    })->width(100);
+                    $grid->htype_cn('操作说明')->width(150);
+                    $grid->created_at('添加时间')->sortable();
+                    $grid->updated_at('更新时间')->sortable();
+                    $grid->disableTools();
+                    $grid->disableActions();
+                    $grid->setName($key);
+                    $grid->disableRowSelector();
+                    $grid->setPaginatorBaseUrl($key);
+                    break;
+                case 'order':
+                    $grid = new Grid(new Order);
+                    $grid ->model()->where(['uid'=>$uid,'utype'=>$utype])
+                        ->when(get_subsite_id()>0, function ($querys) use ($utype) {
+                            if ($utype ==1) {
+                                $relations = 'companys';
+                            } else {
+                                $relations = 'members';
+                            }
+                            $querys->whereHas($relations, function ($query) {
+                                $query->where('subsite_id', get_subsite_id());
+                            });
+                        })->orderBy('created_at', 'desc')->orderBy("is_pay", 'asc');
+                    $grid->id('ID');
+                    $grid->is_pay('支付状态')->display(function ($is_pay) {
+                        if ($is_pay == 1) {
+                            return '待付款';
+                        } elseif ($is_pay == 2) {
+                            return "已付款";
+                        } else {
+                            return '已取消';
+                        }
+                    });
+                    $grid->amount('金额')->width(150);
+                    if ($utype == 1) {
+                        $grid->column('companys.companyname', '企业名称')->width(200);
+                    } else {
+                        $grid->column('members.username', '会员名称')->width(200);
+                    }
+
+                    $grid->service_name('说明')->width(150);;
+                    if ($utype == 1) {
+                        $grid->column('companys.username', '企业会员')->width(200);
+                    } else {
+                        $grid->column('members.username', '个人会员')->width(200);
+                    }
+                    $grid->oid('订单号')->width(200);
+                    $grid->payment_cn('支付方式')->width(150);
+                    $grid->created_at('申请时间')->sortable();
+                    $grid->disableTools();
+                    $grid->disableActions();
+                    $grid->setName($key);
+                    $grid->disableRowSelector();
+                    $grid->setPaginatorBaseUrl($key);
+                    break;
+                case 'subscribe':
+                    $grid = new Grid(new PersonalServiceStickLog);
+                    $grid->model()->where('resume_uid',$uid)->when(get_subsite_id()>0, function ($query) {
+                        $query->whereHas('resume', function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->orderBy('created_at', 'DESC');
+
+                    $grid->column('resume.fullname', '姓名')->width(200);;
+
+                    $grid->resume_uid('会员ID');
+                    $grid->days('推广天数')->width(100);
+                    $grid->addtime('开始时间')->display(function ($addtime) {
+                        return date('Y-m-d H:i:s', $addtime);
+                    })->sortable();
+                    $grid->endtime('结束时间')->display(function ($endtime) {
+                        return date('Y-m-d H:i:s', $endtime);
+                    })->sortable();
+                    $grid->disableTools();
+                    $grid->disableActions();
+                    $grid->setName($key);
+                    $grid->disableRowSelector();
+                    $grid->setPaginatorBaseUrl($key);
+                    break;
+                case 'apply':
+                    $grid = new Grid(new PersonalJobsApply);
+                    $grid->model()->where('personal_uid',$uid)->when(get_subsite_id()>0, function ($query) {
+                        $query->whereHas('resumes', function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->orderBy('id', 'desc');
+
+                    $grid->id('ID');
+                    $grid->jobs_name('职位名称')->width(200);
+
+                    $grid->company_name('公司名称')->width(200);
+
+                    $grid->resume_name('简历名称')->width(150);
+
+                    $grid->is_reply('反馈状态')->display(function ($is_reply) {
+                        switch ($is_reply) {
+                            case 1:
+                                $is_reply = '企业未查看';
+                                break;
+                            case 2:
+                                $is_reply = '待反馈';
+                                break;
+                            case 3:
+                                $is_reply = '合适';
+                                break;
+                            case 4:
+                                $is_reply = '不合适';
+                                break;
+                            case 5:
+                                $is_reply = '待定';
+                                break;
+                            case 6:
+                                $is_reply = '未接通';
+                                break;
+                            default:
+                                $is_reply = '企业未查看';
+                                break;
+                        }
+                        return $is_reply;
+                    });
+
+                    $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
+                        if ($subsite_id) {
+                            $Subsite = Subsite::find($subsite_id);
+                            return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                        }
+                        return '总站';
+                    })->width(150);
+                    $grid->created_at('申请时间')->sortable();
+                    $grid->updated_at('更新时间')->sortable();
+                    $grid->disableTools();
+                    $grid->disableActions();
+                    $grid->setName($key);
+                    $grid->disableRowSelector();
+                    $grid->setPaginatorBaseUrl($key);
+                    break;
+                case 'interview':
+                    $grid = new Grid(new CompanyInterView);
+                    $grid->model()->where('resume_uid',$uid)->when(get_subsite_id()>0, function ($query) {
+                        $query->whereHas('resumes', function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->orderBy('id', 'desc');
+
+                    $grid->id('ID');
+                    $grid->jobs_name('职位名称')->width(200);
+
+                    $grid->company_name('公司名称')->width(200);
+
+                    $grid->resume_name('简历名称')->width(150);
+
+                    $grid->personal_look('查看状态')->display(function ($personal_look) {
+                        switch ($personal_look) {
+                            case 1:
+                                $personal_look = '未查看';
+                                break;
+                            case 2:
+                                $personal_look = '已查看';
+                                break;
+                            default:
+                                $personal_look = '未查看';
+                                break;
+                        }
+                        return $personal_look;
+                    });
+                    $grid->interview_time('邀请时间')->display(function ($interview_time) {
+                        return date('Y-m-d H:i:s', $interview_time);
+                    })->sortable();
+
+                    $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
+                        if ($subsite_id) {
+                            $Subsite = Subsite::find($subsite_id);
+                            return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                        }
+                        return '总站';
+                    })->width(150);
+                    $grid->created_at('申请时间')->sortable();
+                    $grid->updated_at('更新时间')->sortable();
+                    $grid->disableTools();
+                    $grid->disableActions();
+                    $grid->setName($key);
+                    $grid->disableRowSelector();
+                    $grid->setPaginatorBaseUrl($key);
+                    break;
+                case 'log':
+                    $grid = new Grid(new MembersLog);
+                    $grid->model()->where(['log_uid'=>$uid,'log_utype'=>$utype])->when(get_subsite_id()>0, function ($query) {
+                        $query->whereHas('members', function ($query) {
+                            $query->where('subsite_id', get_subsite_id());
+                        });
+                    })->orderBy('id', 'desc');
+                    $grid->id('ID');
+                    $grid->log_username('用户名')->width(200);
+                    $grid->log_value('日志说明')->width(300);
+                    $grid->log_ip('ip')->display(function ($log_ip){
+                        return long2ip($log_ip);
+                    })->width(150);
+                    $grid->log_address('登录地址')->width(150);
+                    $grid->log_utype('会员类型')->display(function ($log_utype) {
+                        if($log_utype==1){
+                            return '企业';
+                        }else{
+                            return '个人';
+                        }
+                    });
+                    $grid->log_source('操作途径')->width(150);
+                    $grid->created_at('申请时间')->sortable();
+                    $grid->updated_at('更新时间')->sortable();
+                    $grid->disableTools();
+                    $grid->disableActions();
+                    $grid->setName($key);
+                    $grid->disableRowSelector();
+                    $grid->setPaginatorBaseUrl($key);
+
+                    break;
+            }
+            $tab->add($val, view('admin.company.content')->with('contents', $grid), $type == $key);
+
+        }
+        return $content
+            ->header('会员信息')
+            ->description('列表')
+            ->body($tab);
+
+    }
+
+    protected function memberSms($sms_id, $mobile, $username, $password)
+    {
+        $SmsRule = SmsRule::where('alias', $sms_id)->first();
+        if (isset($SmsRule->status) && !empty($SmsRule->status)) {
+            if ($mobile) {
+                $this->smsService->sendSms($mobile, $sms_id, ['username'=>$username,'password'=>$password]);
+            }
+        }
+    }
+
+}

+ 158 - 0
app/Admin/Controllers/Person/MembersProjectController.php

@@ -0,0 +1,158 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Models\membersProject;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class MembersProjectController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('创业项目')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('Edit')
+            ->description('description')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new membersProject);
+        $grid->model()->orderBy('id', 'desc');
+        $grid->project_title('创业项目');
+        $grid->project_intro('项目介绍');
+        $grid->link_man('联系人');
+        $grid->link_phone('联系电话');
+        $grid->link_email('联系邮箱');
+        $grid->actions(function ($actions) {
+            $actions->disableDelete();//屏蔽删除按钮
+            $actions->disableEdit();//屏蔽编辑按钮
+            $actions->disableView(false);//屏蔽查看按钮
+        });
+        $grid->filter(function ($filter) {
+//            $filter->equal('id', 'ID');
+            $filter->like('project_title', '标题');
+            $filter->like('link_man', '联系人');
+            $filter->like('link_phone', '联系电话');
+            $date3   = date('Y-m-d', strtotime("-3 day"));
+            $date7   = date('Y-m-d', strtotime("-7 day"));
+            $date30  = date("Y-m-d", strtotime("-1 month"));
+            $date180 = date("Y-m-d", strtotime("-6 month"));
+            $date360 = date("Y-m-d", strtotime("-1 year"));
+            $date_option = array(
+                ''    => '不限',
+                $date3   => '三天内',
+                $date7   => '一周内',
+                $date30  => '一月内',
+                $date180 => '半年内',
+                $date360 => '一年内',
+            );
+            $filter->where(function ($query) {
+                $query->where('created_at', '>=', "{$this->input}");
+            }, '添加时间', 'created_at')->radio($date_option);
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(membersProject::findOrFail($id));
+        $show->link_man('联系人');
+        $show->link_phone('联系电话');
+        $show->link_email('联系邮箱');
+        $show->link_address('联系地址');
+        $show->project_title('创业项目');
+        $show->project_intro('项目介绍');
+        $show->project_info('创业情况');
+        $show->project_help('希望获得的帮助');
+        $show->uid('用户id');
+        $show->created_at('创建时间');
+        $show->updated_at('修改时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new membersProject);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+}

+ 327 - 0
app/Admin/Controllers/Person/PersonInterviewController.php

@@ -0,0 +1,327 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\CompanyInterView;
+use App\Models\Subsite;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class PersonInterviewController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('面试邀请')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('面试邀请')
+            ->description('详细')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('面试邀请')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('面试邀请')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new CompanyInterView);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('resumes', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->orderBy('id', 'desc');
+
+        $grid->id('ID');
+        $grid->jobs_name('职位名称')->width(200);
+
+        $grid->company_name('公司名称')->width(200);
+
+        $grid->resume_name('简历名称')->width(150);
+
+        $grid->personal_look('查看状态')->display(function ($personal_look) {
+            switch ($personal_look) {
+                case 1:
+                    $personal_look = '未查看';
+                    break;
+                case 2:
+                    $personal_look = '已查看';
+                    break;
+                default:
+                    $personal_look = '未查看';
+                    break;
+            }
+            return $personal_look;
+        });
+        $grid->interview_time('邀请时间')->display(function ($interview_time) {
+            return date('Y-m-d H:i:s', $interview_time);
+        })->sortable();
+
+        $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
+            if ($subsite_id) {
+                $Subsite = Subsite::find($subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        })->width(150);
+
+        $grid->created_at('申请时间')->sortable();
+        $grid->updated_at('更新时间')->sortable();
+        $grid->actions(function ($actions) use ($grid) {
+
+            if (Admin::user()->can('person_apply_jobs_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('person_apply_jobs_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->where(function ($query) {
+                switch ($this->input) {
+                    case 1:
+                        $query->whereRaw(" personal_look =".$this->input);
+                        break;
+                    case 2:
+                        $query->whereRaw(" personal_look =".$this->input);
+                        break;
+                }
+            }, '查看状态', 'look')->select([
+                1=>'未查看',
+                2=>'已查看',
+            ]);
+            $filter->where(function ($query) {
+                switch ($this->input) {
+                    case 3:
+                        $date = date('Y-m-d H:i:s', strtotime('-3 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 7:
+                        $date = date('Y-m-d H:i:s', strtotime('-7 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 30:
+                        $date = date('Y-m-d H:i:s', strtotime('-30 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 180:
+                        $date = date('Y-m-d H:i:s', strtotime('-180 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                    case 365:
+                        $date = date('Y-m-d H:i:s', strtotime('-365 day'));
+                        $query->whereRaw(" created_at >='".$date."'");
+                        break;
+                }
+            }, '时间范围', 'apply')->select([
+                3=>'三天内',
+                7=>'一周内',
+                30=>'一月内',
+                180=>'半年内',
+                365=>'一年内',
+            ]);
+            $filter->like('company_name', '公司名称');
+            $filter->like('resume_name', '简历名称 ');
+            $filter->equal('members.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(CompanyInterView::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->jobs_name('职位名称');
+
+        $show->company_name('公司名称');
+
+        $show->resume_name('简历名称');
+
+        $show->personal_look('查看状态')->as(function ($personal_look) {
+            switch ($personal_look) {
+                case 1:
+                    $personal_look = '未查看';
+                    break;
+                case 2:
+                    $personal_look = '已查看';
+                    break;
+                default:
+                    $personal_look = '未查看';
+                    break;
+            }
+            return $personal_look;
+        });
+        $show->interview_time('邀请时间')->as(function ($interview_time) {
+            return date('Y-m-d H:i:s', $interview_time);
+        })->sortable();
+
+        $show->members('所属分站')->as(function ($members) {
+            if ($members->subsite_id) {
+                $Subsite = Subsite::find($members->subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new CompanyInterView);
+        $form->display('id');
+        $form->display('created_at');
+        $form->display('updated_at');
+        return $form;
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new CompanyInterView);
+        $form->setAction(route('admin.personal.addPoints'));
+        $MembersHandsel = MembersHandsel::findOrFail($id);
+        $utype = $MembersHandsel->utype;
+        $points = MembersHandsel::find($id)->membersPoints()->where('utype', $utype)->first();
+        $form->display('points_num', '会员积分')->with(function () use ($points) {
+            return $points->points;
+        });
+        $form->radio('points_type', '操作积分')->options([1 => '增加', 2=> '减少'])->default(1);
+        $form->number('many_point', '增减积分')->default(0)->min(0);
+        $form->text('explain', '操作说明');
+        $form->switch('ismany', '是否收费?');
+        $form->number('amount', '收费金额')->default(0)->min(0);
+        $form->hidden('points_id')->default($points->id);
+        $form->footer(function ($footer) {
+            // 去掉`重置`按钮
+            $footer->disableReset();
+            // 去掉`查看`checkbox
+            $footer->disableViewCheck();
+            // 去掉`继续编辑`checkbox
+            $footer->disableEditingCheck();
+            // 去掉`继续创建`checkbox
+            $footer->disableCreatingCheck();
+        });
+        $form->tools(function (Form\Tools $tools) {
+            // 去掉`删除`按钮
+            $tools->disableDelete();
+        });
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new CompanyInterView);
+        $form->display('id');
+        $form->display('created_at');
+        $form->display('updated_at');
+        return $form;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param int $id
+     *
+     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+}

+ 263 - 0
app/Admin/Controllers/Person/PersonalPointsController.php

@@ -0,0 +1,263 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\MembersHandsel;
+use App\Models\MembersPoint;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+
+class PersonalPointsController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('个人积分')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('个人积分')
+            ->description('详细')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('个人积分')
+            ->description('编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('个人积分')
+            ->description('创建')
+            ->body($this->createForm());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new MembersHandsel);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('members',function ($query){
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->where('utype', 2)->orderBy('id', 'desc');
+
+
+        $grid->id('ID');
+        $grid->uid('会员ID');
+        $grid->utype('会员类型')->display(function ($utype) {
+            if ($utype==1) {
+                return '企业';
+            } else {
+                return '个人';
+            }
+        })->width(100);
+        $grid->points('操作积分')->display(function ($points) {
+            if ($this->operate==1) {
+                return "<span style='color:green;'>+".$points."</span>";
+            } else {
+                return "<span style='color:red;'>-".$points."</span>";
+            }
+        })->width(100);
+        $grid->htype_cn('操作说明')->width(150);
+        $grid->created_at('添加时间')->sortable();
+        $grid->updated_at('更新时间')->sortable();
+        $grid->disableCreateButton();
+        $grid->disableExport();
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('person_point_delete')) {
+                $actions->disableDelete(false);
+            }
+            if (Admin::user()->can('person_point_edit')) {
+                $actions->disableEdit(false);
+            }
+        });
+        if (Admin::user()->can('person_point_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->equal('uid', '会员ID');
+
+            $filter->like('htype_cn', '操作说明');
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(MembersHandsel::findOrFail($id));
+
+        $show->id('ID');
+
+        $show->uid('会员ID');
+        $show->utype('会员类型')->as(function ($utype) {
+            if ($utype==1) {
+                return '企业';
+            } else {
+                return '个人';
+            }
+        });
+        $show->points('操作积分')->as(function ($points) {
+            if ($this->operate == 1) {
+                return '+'.$points;
+            } else {
+                return '-'.$points;
+            }
+        });
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new MembersHandsel);
+        $form->display('id');
+        $form->display('created_at');
+        $form->display('updated_at');
+        return $form;
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function editForm($id)
+    {
+        $form = new Form(new MembersHandsel);
+        $form->setAction(route('admin.personal.addPoints'));
+        $MembersHandsel = MembersHandsel::findOrFail($id);
+        $utype = $MembersHandsel->utype;
+        $points = MembersHandsel::find($id)->membersPoints()->where('utype', $utype)->first();
+        $form->display('points_num', '会员积分')->setWidth(2)->with(function () use ($points) {
+            return $points->points;
+        });
+        $form->radio('points_type', '操作积分')->options([1 => '增加', 2=> '减少'])->default(1);
+        $form->switch('ismany', '是否收费?');
+        $form->number('many_point', '增减积分')->default(0)->min(0);
+        $form->number('amount', '收费金额')->default(0)->min(0);
+
+        $form->text('explain', '操作说明')->setWidth(8);
+        $form->hidden('points_id')->default($points->id);
+        return $form;
+    }
+
+    protected function createForm()
+    {
+        $form = new Form(new MembersHandsel);
+        $form->display('id');
+        $form->display('created_at');
+        $form->display('updated_at');
+        return $form;
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->createForm()->store();
+    }
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param int $id
+     *
+     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        return $this->editForm()->update($id);
+    }
+
+
+    public function addPoints()
+    {
+        $id = request()->points_id;
+        if (!$id) {
+            admin_toastr('积分ID不存在!', 'error');
+        }
+        $type = request()->points_type;
+        $points = request()->many_point;
+        if ($type==1) {
+            $res = MembersPoint::where('id', $id)->increment('points', $points);
+        } else {
+            $res = MembersPoint::where('id', $id)->decrement('points', $points);
+        }
+        if ($res) {
+            admin_toastr('操作成功!', 'success');
+        } else {
+            admin_toastr('操作失败!', 'error');
+        }
+        return back();
+    }
+}

+ 254 - 0
app/Admin/Controllers/Person/PersonalServiceStickController.php

@@ -0,0 +1,254 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\PersonalServiceStick;
+use App\Models\PersonalServiceTag;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Encore\Admin\Widgets\Tab;
+use Encore\Admin\Widgets\Table;
+use Illuminate\Validation\Rule;
+
+class PersonalServiceStickController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+
+        return $content
+            ->header('简历置顶')
+            ->description(' ')
+            ->body($this->grid());
+    }
+    public function indexs(Content $content, int $type_id, int $tab_id = 0)
+    {
+        $tab = new Tab();
+        if ($type_id=='1') {
+            $services = PersonalServiceStick::all();
+            $header = '简历置顶';
+        } else {
+            $services = PersonalServiceTag::all();
+            $header = '醒目标签';
+        }
+
+        $headers = ['Id', 'Email', 'Name', 'Company'];
+        $rows = [
+            [1, 'labore21@yahoo.com', 'Ms. Clotilde Gibson', 'Goodwin-Watsica'],
+            [2, 'omnis.in@hotmail.com', 'Allie Kuhic', 'Murphy, Koepp and Morar'],
+            [3, 'quia65@hotmail.com', 'Prof. Drew Heller', 'Kihn LLC'],
+            [4, 'xet@yahoo.com', 'William Koss', 'Becker-Raynor'],
+            [5, 'ipsa.aut@gmail.com', 'Ms. Antonietta Kozey Jr.'],
+        ];
+
+        $table = new Table($headers, $rows);
+
+        $tab->add('置顶', '置顶')->render();
+        $tab->add('醒目标签', $table)->render();
+
+        //return $tab->render();
+        //$tab->add('站内信', $this->grid()->setResource('/content/sysmessage/index')->render());
+        //$tab->add('弹窗消息', $this->grid()->setResource('/content/explain/index')->render());
+        return $content
+            ->header($header)
+            ->description(' ')
+            ->body($tab);
+
+    }
+
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('简历置顶')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('简历置顶')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('简历置顶')
+            ->description('添加简历置顶推广')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonalServiceStick);
+
+        $grid->model()->orderBy('list_order', 'desc');
+        $grid->id('ID');
+        $grid->days('服务名称')->display(function () {
+            return '置顶 '.$this->days.' 天';
+        })->width(150);
+        $grid->column('类型')->display(function () {
+            return '置顶';
+        });
+        $grid->points('服务价')->display(function () {
+            return $this->points.'积分';
+        })->width(200);
+        $grid->list_order('排序')->width(200);
+        $grid->created_at('添加时间');
+        $grid->updated_at('更新时间');
+        if (Admin::user()->can('person_resume_stick_add')) {
+            $grid->disableCreateButton(false);
+        }
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('person_resume_stick_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('person_resume_stick_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        $grid->disableFilter();
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonalServiceStick::findOrFail($id));
+
+        $show->id('ID');
+        $show->days('置顶时间')->as(function ($days) {
+            return $days.'天';
+        });
+        $show->points('所需积分')->as(function ($points) {
+            return $points.'点';
+        });
+        $show->list_order('排序');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+
+    protected function editForm($id)
+    {
+        $form = new Form(new PersonalServiceStick);
+
+        $form->text('days', '置顶时间')
+            ->rules(
+                [
+                    'required',
+                     Rule::unique('personal_service_sticks')->ignore($id),
+                ],
+                [
+                    'required' => '置顶时间不能为空',
+                    'unique' => '置顶时间已存在',
+                ]
+            )
+            ->setWidth(2)->setMustMark()
+            ->append('天')
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('points', '所需积分')
+            ->rules('required', array('required'=>'所需积分不能为空。'))
+            ->setWidth(2)->setMustMark()
+            ->append('点')
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->number('list_order', '排序')->default(0)->min(0)
+            ->rules('required|numeric', array('required'=>'排序不能为空。','numeric'=>'排序只能填写数字。'))
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"))
+            ->help('(数字越大越靠前)');
+        return $form;
+    }
+
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonalServiceStick);
+
+        $form->text('days', '置顶时间')
+            ->rules(
+                [
+                    'required',
+                     Rule::unique('personal_service_sticks')->where(function ($query){
+                         $query->where('deleted_at',null);
+                     }),
+                ],
+                [
+                    'required' => '置顶时间不能为空',
+                    'unique' => '置顶时间已存在',
+                ]
+            )
+             ->setWidth(2)->setMustMark()
+             ->append('天')
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('points', '所需积分')
+             ->rules('required', array('required'=>'所需积分不能为空。'))
+             ->setWidth(2)->setMustMark()
+             ->append('点')
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->number('list_order', '排序')->default(0)->min(0)
+             ->rules('required|numeric', array('required'=>'排序不能为空。','numeric'=>'排序只能填写数字。'))
+             ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"))
+             ->help('(数字越大越靠前)');
+        return $form;
+    }
+
+
+
+}

+ 296 - 0
app/Admin/Controllers/Person/PersonalServiceStickLogController.php

@@ -0,0 +1,296 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\MemberInfo;
+use App\Models\Resume;
+use App\Models\PersonalServiceStickLog;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Input;
+
+class PersonalServiceStickLogController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('简历置顶推广')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('简历置顶推广')
+            ->description('修改')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('简历置顶推广')
+            ->description('新增')
+            ->body(view('admin.service.sticklog')->with('createForm', $this->createForm()->render()));
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonalServiceStickLog);
+
+        $grid->model()->whereHas('member')->orderBy('created_at', 'desc');
+
+        $grid->column('memberInfo.realname', '姓名')->width(200);;
+
+        $grid->resume_uid('会员ID');
+        $grid->days('推广天数')->width(100);
+        $grid->addtime('开始时间')->display(function ($addtime) {
+            return date('Y-m-d H:i:s', $addtime);
+        });
+        $grid->endtime('结束时间')->display(function ($endtime) {
+            return date('Y-m-d H:i:s', $endtime);
+        });
+        $grid->disableExport();
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('person_promotion_stick_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('person_promotion_stick_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        //新增按钮
+        if (Admin::user()->can('person_promotion_stick_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('person_promotion_stick_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->like('memberInfo.realname', '姓名');
+            $filter->equal('resume_uid', '会员ID');
+            $filter->equal('resume_id', '简历ID');
+           // $filter->equal('tag_id', '标签')->select(Category::categoryType('AIX_personaltag'));
+        });
+
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonalServiceStickLog::findOrFail($id));
+
+        $show->id('ID');
+        $show->resume_id('简历ID');
+        $show->resume_uid('用户名')->as(function ($resume_uid) {
+            $member_info = MemberInfo::where(['uid'=>$resume_uid])->first();
+            if ($member_info) {
+                return $member_info->realname;
+            }
+            return '';
+        });
+        $show->days('置顶天数')->as(function ($days) {
+            return $days.' 天';
+        });
+        $show->points('消耗积分')->as(function ($points) {
+            return $points.' 积分';
+        });
+        $show->addtime('开始时间')->as(function ($addtime) {
+            return date('Y-m-d H:i:s', $addtime);
+        });
+        $show->endtime('结束时间')->as(function ($endtime) {
+            return date('Y-m-d H:i:s', $endtime);
+        });
+
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+
+        $show->panel()
+            ->tools(function ($tools) {
+                $tools->disableEdit();
+                $tools->disableDelete();
+            });
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonalServiceStickLog);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+    protected function editForm($id)
+    {
+        $form = new Form(new PersonalServiceStickLog);
+        $form->display('id')->setWidth(2);
+
+        $form->display('memberInfo.realname', '姓名')->setWidth(2)->with(function ($name) use ($id){
+            $res = PersonalServiceStickLog::find($id);
+            $MemberInfo = MemberInfo::where('uid',$res->resume_uid)->first();
+            return $MemberInfo ? $MemberInfo->realname : '';
+        });
+
+        $form->display('resume_uid', '会员ID')->setWidth(2);
+        $form->display('ptype', '推广方案')->setWidth(2)->with(function ($ptype) {
+            return "简历置顶";
+        });
+        $form->hidden('endtime', '结束时间');
+        $form->display('days', '推广天数')->setWidth(2);
+        $form->hidden('days');
+        $form->text('day', '延迟推广天数')->setWidth(2)->setMustMark();
+        $form->display('dead_line', '推广期限')->setWidth(3);
+        $form->saved(function (Form $form) {
+            $resume =  Resume::where(['id'=>$form->model()->resume_id])->first();
+            $resume->stime = $form->model()->endtime;
+            $resume->save();
+            event_search_update(Resume::class, $resume->id.'', 'update');
+        });
+
+        return $form;
+    }
+
+    /**
+     * @param $id
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function update($id)
+    {
+        if (!Input::get('day')) {
+            admin_toastr('请填写延迟推广天数', 'error');
+            return back();
+        }
+        $old_days = (int)Input::get('days');
+        $day = (int)Input::get('day');
+        $days = $old_days + $day;
+        $data = [
+            'endtime' =>Input::get('endtime')+Input::get('day')*86400,
+            'days' =>$days,
+        ];
+        return $this->editForm($id)->update($id, $data);
+    }
+
+    protected function createForm()
+    {
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->text('id', '简历ID')->setWidth(3);
+        $form->text('fullname', '真实姓名')->setWidth(3);
+        $form->text('uid', '会员ID')->setWidth(3);
+        $form->disableReset();
+        $form->disableSubmit();
+        return $form;
+    }
+    public function addStick(Request $request)
+    {
+        $data['resume_id'] = $request->resume_id;
+        $data['resume_uid'] = $request->resume_uid;
+        $data['days'] = $request->days;
+        $where = array(
+            array('resume_id','=',$data['resume_id']),
+            array('endtime','>=',time()),
+        );
+        if (PersonalServiceStickLog::where($where)->first()) {
+            //admin_error('error', '该简历正在执行此推广,请选择其他简历');
+            admin_toastr('该简历正在执行此推广,请选择其他简历', 'error');
+            return back();
+        }
+        if (!$data['resume_id'] || !$data['resume_uid']) {
+            //admin_error('error', '请填写置顶的简历');
+            admin_toastr('请填写置顶的简历', 'error');
+            return back();
+        }
+        if (!$data['days']) {
+            //admin_error('error', '请填写置顶的天数');
+            admin_toastr('请填写置顶的天数', 'error');
+            return back();
+        }
+        $data['points'] = 0;
+        $data['addtime'] = time();
+        $data['endtime'] = $data['addtime']+$data['days']*86400;
+        if (!PersonalServiceStickLog::create($data)) {
+            //admin_error('error', '保存失败');
+            admin_toastr('保存失败', 'error');
+            return back();
+        }
+
+        $resume =  Resume::where(['id'=>$request->resume_id])->first();
+        $resume->stick = 1;
+        $resume->stime = strtotime("+".$data['days']." day");
+        $resume->save();
+
+        event_search_update(Resume::class, $request->resume_id, 'update');
+        admin_toastr('保存成功', 'success');
+        return redirect(admin_base_path().'/personal/promotion/personalstick');
+    }
+}

+ 198 - 0
app/Admin/Controllers/Person/PersonalServiceTagController.php

@@ -0,0 +1,198 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\PersonalServiceTag;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Validation\Rule;
+
+class PersonalServiceTagController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('醒目标签')
+            ->description(' ')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('醒目标签')
+            ->description(' ')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('醒目标签')
+            ->description(' ')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('醒目标签')
+            ->description(' ')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonalServiceTag);
+
+        $grid->model()->orderBy('list_order', 'desc');
+        $grid->id('ID');
+        $grid->days('服务名称')->display(function () {
+            return '醒目标签 '.$this->days.' 天';
+        })->width(150);
+        $grid->column('类型')->display(function () {
+            return '醒目标签';
+        });
+        $grid->points('服务价')->display(function () {
+            return $this->points.'积分';
+        })->width(200);
+        $grid->list_order('排序')->width(200);
+        $grid->created_at('添加时间');
+        $grid->updated_at('更新时间');
+        if (Admin::user()->can('person_resume_tag_add')) {
+            $grid->disableCreateButton(false);
+        }
+
+        $grid->disableFilter();
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('person_resume_tag_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('person_resume_tag_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonalServiceTag::findOrFail($id));
+
+        $show->id('ID');
+        $show->days('醒目标签时间')->as(function ($days) {
+            return $days.'天';
+        });
+        $show->points('所需积分')->as(function ($points) {
+            return $points.'点';
+        });
+        $show->list_order('排序');
+        $show->created_at('添加时间');
+        $show->updated_at('更新时间');
+        return $show;
+    }
+
+    protected function editForm($id)
+    {
+        $form = new Form(new PersonalServiceTag);
+        $form->text('days', '醒目标签时间')
+            ->rules(
+                [
+                    'required',
+                     Rule::unique('personal_service_tags')->ignore($id),
+                ],
+                [
+                    'required' => '醒目标签不能为空',
+                    'unique' => '醒目标签时间已存在',
+                ]
+            )
+            ->setWidth(2)->setMustMark()
+            ->append('天')
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('points', '所需积分')
+            ->rules('required', array('required'=>'所需积分不能为空。'))
+            ->setWidth(2)->setMustMark()
+            ->append('点')
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->number('list_order', '排序')->default(0)->min(0)
+            ->rules('required|numeric', array('required'=>'排序不能为空。','numeric'=>'排序只能填写数字。'))
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"))
+            ->help('(数字越大越靠前)');
+        return $form;
+    }
+
+    public function update($id)
+    {
+        return $this->editForm($id)->update($id);
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonalServiceTag);
+        $form->text('days', '醒目标签时间')
+            ->rules('required|unique:personal_service_tags', array('required'=>'醒目标签不能为空。','unique'=>'醒目标签时间已存在。'))
+            ->setWidth(2)->setMustMark()
+            ->append('天')
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->text('points', '所需积分')
+            ->rules('required', array('required'=>'所需积分不能为空。'))
+            ->setWidth(2)->setMustMark()
+            ->append('点')
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"));
+        $form->number('list_order', '排序')->default(0)->min(0)
+            ->rules('required|numeric', array('required'=>'排序不能为空。','numeric'=>'排序只能填写数字。'))
+            ->attribute(array('maxlength'=>'10','onkeyup'=>'if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,\'\');','onbeforepaste'=>"clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))"))
+            ->help('(数字越大越靠前)');
+        return $form;
+    }
+}

+ 290 - 0
app/Admin/Controllers/Person/PersonalServiceTagLogController.php

@@ -0,0 +1,290 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\Category;
+use App\Models\MemberInfo;
+use App\Models\PersonalServiceTagLog;
+use App\Models\Resume;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Input;
+
+class PersonalServiceTagLogController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('醒目标签推广')
+            ->description('列表')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('Detail')
+            ->description('description')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('醒目标签')
+            ->description('修改')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('醒目标签')
+            ->description('添加')
+            ->body(view('admin.service.taglog')->with(['createForm'=> $this->createForm(),'personalTag'=>Category::categoryType('AIX_personaltag')]));
+    }
+
+    protected function createForm()
+    {
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->text('id', '简历ID')->setWidth(3);
+        $form->text('fullname', '真实姓名')->setWidth(3);
+        $form->text('uid', '会员ID')->setWidth(3);
+        $form->disableReset();
+        $form->disableSubmit();
+
+        return $form;
+    }
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonalServiceTagLog);
+        $grid->model()->whereHas('member')->orderBy('created_at', 'desc');
+        $grid->column('memberInfo.realname', '姓名')->width(200);
+        $grid->tag_id('标签名称')->display(function ($tag_id) {
+            $cateArr = Category::categoryType('AIX_personaltag');
+            return $cateArr[$tag_id];
+        })->width(100);
+        $grid->resume_uid('会员ID');
+        $grid->days('推广天数')->width(100);
+        $grid->addtime('开始时间')->display(function ($addtime) {
+            return date('Y-m-d H:i:s', $addtime);
+        });
+        $grid->endtime('结束时间')->display(function ($endtime) {
+            return date('Y-m-d H:i:s', $endtime);
+        });
+        $grid->disableExport();
+        $grid->actions(function ($actions) {
+            if (Admin::user()->can('perosn_promotion_tag_edit')) {
+                $actions->disableEdit(false);
+            }
+            if (Admin::user()->can('perosn_promotion_tag_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+        //新增按钮
+        if (Admin::user()->can('perosn_promotion_tag_create')) {
+            $grid->disableCreateButton(false);
+        }
+        //批量删除
+        if (Admin::user()->can('perosn_promotion_tag_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+        }
+
+        $grid->filter(function ($filter) {
+            $filter->disableIdFilter();
+            $filter->like('memberInfo.realname', '姓名');
+            $filter->equal('resume_uid', '会员ID');
+            $filter->equal('resume_id', '简历ID');
+            $filter->equal('tag_id', '标签')->select(Category::categoryType('AIX_personaltag'));
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonalServiceTagLog::findOrFail($id));
+
+        $show->id('ID');
+        $show->resume_id('简历ID');
+
+        $show->resume_uid('用户名')->as(function ($resume_uid) {
+            $member_info = MemberInfo::where(['uid'=>$resume_uid])->first();
+            if ($member_info) {
+                return $member_info->realname;
+            }
+            return '';
+        });
+        $show->days('醒目标签天数')->as(function ($days) {
+            return $days.' 天';
+        });
+        $show->tag_cn('醒目标签');
+        $show->points('消耗积分')->as(function ($points) {
+            return $points.' 积分';
+        });
+        $show->addtime('开始时间')->as(function ($addtime) {
+            return date('Y-m-d H:i:s', $addtime);
+        });
+        $show->endtime('结束时间')->as(function ($endtime) {
+            return date('Y-m-d H:i:s', $endtime);
+        });
+        $show->created_at('创建时间');
+        $show->updated_at('更新时间');
+
+        $show->panel()->tools(function ($tools) {
+            $tools->disableEdit();
+            $tools->disableDelete();
+        });
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonalServiceTagLog);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+    public function addTag(Request $request)
+    {
+        $data['resume_id'] = $request->resume_id;
+        $data['resume_uid'] = $request->resume_uid;
+        $data['days'] = $request->days;
+        $data['tag_id'] = $request->tag;
+        $tags = Category::categoryType('AIX_personaltag');
+        if ($tags) {
+            $data['tag_cn'] = array_get($tags, $request->tag);
+        }
+        $where = array(
+            array('resume_id','=',$data['resume_id']),
+            array('endtime','>=',time()),
+        );
+        if (PersonalServiceTagLog::where($where)->first()) {
+            admin_toastr('该简历正在执行此推广,请选择其他简历', 'error');
+            return back();
+        }
+        if (!$data['resume_id'] || !$data['resume_uid']) {
+            admin_toastr('请选择推广的简历', 'error');
+            return back();
+        }
+        if (!$data['days']) {
+            admin_toastr('请填写推广的天数', 'error');
+            return back();
+        }
+        if (!$data['tag_id']) {
+            admin_toastr('请选择标签', 'error');
+            return back();
+        }
+        $data['points'] = 0;
+        $data['addtime'] = time();
+        $data['endtime'] = $data['addtime']+$data['days']*86400;
+        if (!PersonalServiceTagLog::create($data)) {
+            admin_toastr('保存失败', 'error');
+            return back();
+        }
+        $resume =  Resume::where(['id'=>$request->resume_id])->first();
+        $resume->strong_tag = $data['tag_id'];
+        $resume->save();
+        admin_toastr('保存成功', 'success');
+        return redirect(route('admin.personal.personaltag.index'));
+    }
+
+    protected function editForm($id)
+    {
+        $form = new Form(new PersonalServiceTagLog);
+        $form->display('id')->setWidth(2);
+        $form->display('memberInfo.realname', '姓名')->setWidth(2)->with(function ($name) use ($id){
+            $res = PersonalServiceTagLog::find($id);
+            $MemberInfo = MemberInfo::where('uid',$res->resume_uid)->first();
+            return $MemberInfo ? $MemberInfo->realname : '';
+        });
+        $form->display('resume_uid', '会员ID')->setWidth(2);
+        $form->display('ptype', '推广方案')->setWidth(2)->with(function ($ptype) {
+            return "醒目标签";
+        });
+
+        $form->hidden('endtime', '结束时间');
+        $form->display('days', '推广天数')->setWidth(2);
+        $form->hidden('days');
+        $form->select('tag_id', '醒目标签')->options(Category::categoryType('AIX_personaltag'))->setWidth(2);
+        $form->text('day', '延迟推广天数')->setWidth(2);
+        $form->display('dead_line', '推广期限')->setWidth(3);
+        return $form;
+    }
+
+    public function update($id)
+    {
+        if (!Input::get('day')) {
+            admin_toastr('请填写要延迟推广的天数', 'error');
+            return back();
+        }
+        $old_days = (int)Input::get('days');
+        $day = (int)Input::get('day');
+        $days = $old_days + $day;
+        $data = [
+            'endtime' =>Input::get('endtime')+Input::get('day')*86400,
+            'days' =>$days ,
+            'tag_id'=>Input::get('tag_id'),
+        ];
+        return $this->editForm($id)->update($id, $data);
+    }
+
+}

+ 1 - 0
app/Admin/Controllers/Person/README.md

@@ -0,0 +1 @@
+后台个人管理模块

+ 839 - 0
app/Admin/Controllers/Person/ResumeController.php

@@ -0,0 +1,839 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Admin\Exports\Person\ResumeExport;
+use App\Admin\Extensions\Form\ValueForm;
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Company;
+use App\Models\Member;
+use App\Models\Pms;
+use App\Models\Resume;
+use App\Models\SmsRule;
+use App\Models\SmsTemplate;
+use App\Models\Subsite;
+use App\Services\Common\EmailService;
+use App\Services\Common\SmsService;
+use App\Validators\Rules\MobileRule;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Encore\Admin\Widgets\Tab;
+use Encore\Admin\Widgets\Table;
+use Illuminate\Http\Request;
+use phpDocumentor\Reflection\Types\Context;
+
+class ResumeController extends Controller
+{
+    use HasResourceActions;
+
+    protected $smsService;
+    protected $emailService;
+    protected $resume;
+
+    /**
+     * AjaxController constructor.
+     * @param $smsService
+     */
+    public function __construct(SmsService $smsService, EmailService $emailService, Resume $resume)
+    {
+        $this->smsService = $smsService;
+        $this->emailService = $emailService;
+        $this->resume = $resume;
+    }
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+       $grid = $this->grid()->render();
+        return $content
+            ->header('简历列表')
+            ->description('')
+            ->body(view('admin.resume.resume')->with(['grid'=>$grid]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('简历详情')
+            ->description()
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('简历列表')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('简历列表')
+            ->description('创建')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Resume);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->where('subsite_id', get_subsite_id());
+            $query->whereHas('subsite',function ($query){
+                $query->where('effective', 1);
+            });
+        })->orderByRaw("FIELD(audit, 1,2,0)")->orderBy('updated_at', 'desc');
+        $grid->id('ID');
+        $grid->column('memberInfos.images', '姓名')->display(function ($images) {
+            $expires = '';
+            $style = 'color:#3c8dbc';
+            if($this->expires && $this->expires<time()){
+                $expires = '[已过期]';
+                $style = 'color:#CCCCCC';
+            }
+            if ($images) {
+                return '<span class="vtip" title="<img src='.upload_asset($images).' width=120 height=120>">
+                            <img class="avatar small" src="'.upload_asset($images).'" align="absmiddle" style="width: 36px;height: 36px;">
+                        </span>&nbsp;&nbsp;&nbsp;'.'<span style="'.$style.'">'.htmlspecialchars($this->fullname).'&nbsp;&nbsp;'.$expires.'</span>';
+            } else {
+                return '<span class="vtip" ></span>&nbsp;&nbsp;&nbsp;'. '<span style="'.$style.'">'.$this->fullname.'&nbsp;&nbsp;'.$expires.'</span>';
+            }
+        })->width(200);
+        $grid->title('简历名称')->display(function ($title) {
+            return '<a href="/content/resumes/show?id='.$this->id.'&token=1" target="_blank">'.$title.'</a>';
+        })->width(150);
+
+        $grid->complete_percent('简历完整度')->display(function ($complete_percent) {
+             return $complete_percent.'%';
+        })->label();
+        $grid->audit('审核状态')->display(function ($audit) {
+            if ($audit==0) {
+                return'<span style="color:#666666">审核未通过</span><a style="margin-left: 5px;" ls="'.$this->id.'" class="audit_log"><i class="fa fa-eye"></i></a>';
+            } elseif ($audit==2) {
+                return'<span style="color: #009900">审核通过</span><a style="margin-left: 5px;" ls="'.$this->id.'" class="audit_log"><i class="fa fa-eye"></i></a>';
+            } else {
+                return'<span style="color:#FF6600">等待审核</span><a style="margin-left: 5px;" ls="'.$this->id.'" class="audit_log"><i class="fa fa-eye"></i></a>';
+            }
+        });
+        $grid->display('公开')->display(function ($display) {
+            return $display ? '公开' : '保密';
+        });
+        $grid->entrust('委托状态')->display(function ($entrust) {
+            $value = $entrust - time();
+            if ($value < 0) {
+                return'<span style="color:#666666">无</span>';
+            } elseif ($value >= 0 && $value < 59) {
+                return'<span style="color:#009900">'.$value.'秒</span>';
+            } elseif ($value >= 60 && $value < 3600) {
+                $min = intval($value / 60);
+                return'<span style="color:#009900">'.$min.'分钟</span>';
+            } elseif ($value >=3600 && $value < 86400) {
+                $h = intval($value / 3600);
+                return'<span style="color:#009900">'.$h.'小时</span>';
+            } elseif ($value >= 86400 && $value < 86400*30) {
+                $d = intval($value / 86400);
+                return'<span style="color:#009900">'.intval($d).'天</span>';
+
+            } elseif ($value >= 86400*30 && $value < 86400*30*12) {
+                $mon  = intval($value / (86400*30));
+                return'<span style="color:#009900">'.$mon.'月</span>';
+                return $mon."月";
+            } else {
+                $y = intval($value / (86400*30*12));
+                return'<span style="color:#009900">'.$y.'年</span>';
+            }
+        });
+        if(get_subsite_open()){
+            $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            })->width(150);
+        }
+        $grid->created_at('添加时间')->sortable();
+        $grid->updated_at('更新时间')->sortable();
+        $grid->actions(function ($actions) use ($grid) {
+            $actions->disableView(false);
+            if (Admin::user()->can('person_resume_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+            if (Admin::user()->can('perosn_business')) {
+                $actions->append('<button class="btn btn-primary btn-xs business" ls="'.$actions->row['uid'].'" ld="'. htmlspecialchars($actions->row['fullname']) .'" title="业务" >业务</button>');
+            }
+            if (Admin::user()->can('person_resume_matching')) {
+                if (!empty($actions->row['entrust']) && $actions->row['entrust']>time()) {
+                    $actions->append('<button class="btn btn-primary btn-xs piPei" ls="'.$actions->row['id'].'" ld="'.$actions->row['uid'].'" title="匹配" >匹配</button>');
+                }
+            }
+            if (Admin::user()->can('person_resume_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('person_resume_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('person_resume_audit')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="audit_resume" title="审核简历">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">审核简历
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+
+        if (Admin::user()->can('person_resume_export')) {
+            $grid->disableExport(false); //显示导出按钮
+            $grid->exporter(new ResumeExport()); //传入自己在第1步创建的导出类
+        }
+
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+//            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('display', '可见状态')->select([
+                    0=>'不可见',
+                    1=>'可见'
+                ]);
+                $filter->equal('audit', '审核状态')->select([
+                    0=>'审核未通过',
+                    1=>'等待审核',
+                    2=>'审核通过',
+                ]);
+                $filter->equal('photo', '简历照片')->select([
+                    0=>'无',
+                    1=>'有',
+                ]);
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("entrust > ".time()." and entrust<=".strtotime('3 day'));
+                            break;
+                        case 7:
+                            $query->whereRaw("entrust > ".time()." and entrust<=".strtotime('7 day'));
+                            break;
+                        case 14:
+                            $query->whereRaw("entrust > ".time()." and entrust<=".strtotime('14 day'));
+                            break;
+                        case 30:
+                            $query->whereRaw("entrust > ".time()." and entrust<=".strtotime('30 day'));
+                            break;
+                    }
+                }, '是否委托', 'entrust')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    14=>'二周内',
+                    30=>'一月内',
+                ]);
+
+                if(get_subsite_id()==0 && get_subsite_open()){
+                    $filter->equal('subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+
+            });
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('uid', '会员ID');
+                $filter->like('fullname', '姓名');
+                $filter->like('memberInfos.id_card', '身份证');
+                $filter->like('memberInfos.phone', '手机号');
+                $filter->between('created_at', '创建时间')->datetime();
+                $filter->between('updated_at', '刷新时间')->datetime();
+                /*$filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '创建时间', 'created_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("updated_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                    }
+                }, '刷新时间', 'updated_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                ]);*/
+            });
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $result = Resume::find($id)->getResumeAllInfo();
+
+        if(isset($result->memberInfos->display_images)){
+            if($result->memberInfos->display_images==1){
+                $display_images = '公开';
+            } elseif ($result->memberInfos->display_images==2){
+                $display_images = '不公开';
+            }else{
+                $display_images = '未上传照片';
+            }
+        }else{
+            $display_images = '未上传照片';
+        }
+
+        if(isset($result->memberInfos->images)){
+            if($result->memberInfos->images){
+                $imk = upload_asset($result->memberInfos->images);
+                $images =  '<img border="0" src="'.$imk.'">';
+            } else{
+                $images = '';
+            }
+        }else{
+            $images = '';
+        }
+
+        if($result->audit==2){
+            $audit = '已通过审核';
+        }elseif ($result->audit==0){
+            $audit = '审核未通过请修改';
+        }else{
+            $audit = '正在审核中';
+        }
+        $resume = [$result->title,$result->display?'公开':'不公开',$display_images,
+            $result->complete_percent.'%',$audit,$result->talent?'高级':'普通',$result->created_at,$result->updated_at];
+        $member_info = [];
+        if($result->memberInfos){
+            $data = $result->memberInfos;
+            $member_info = [$data->realname,$data->sex_cn,date('Y')-($data->birthday),
+                $data->height,$data->education_cn,$data->marriage_cn,$data->experience_cn,$data->householdaddress_cn,$data->phone,$data->email,$images];
+        }
+        $job_intention = [$result->nature_cn,$result->district_cn,
+            $result->wage_cn,$result->intention_jobs,$result->trade_cn];
+        $profile =[$result->specialty];
+        $education = [];
+        if(!$result->resumeEducation->isEmpty()){
+            foreach ($result->resumeEducation as $resumeEducation){
+                if($resumeEducation->todate){
+                    $time =$resumeEducation->startyear.'年'.$resumeEducation->startmonth.'月-'.'至今';
+                }else{
+                    $time =$resumeEducation->startyear.'年'.$resumeEducation->startmonth.'月-'.$resumeEducation->endyear.'年'.$resumeEducation->endmonth.'月';
+                }
+                $education[]= [$time,$resumeEducation->school,$resumeEducation->speciality,$resumeEducation->education_cn];
+            }
+        }
+        $work = [];
+        if(!$result->resumeWork->isEmpty()){
+            foreach ($result->resumeWork as $resumeWork){
+                if($resumeWork->todate){
+                    $time =$resumeWork->startyear.'年'.$resumeWork->startmonth.'月-'.'至今';
+                }else{
+                    $time =$resumeWork->startyear.'年'.$resumeWork->startmonth.'月-'.$resumeWork->endyear.'年'.$resumeWork->endmonth.'月';
+                }
+                $work[]= [$time,$resumeWork->companyname,$resumeWork->jobs];
+            }
+        }
+        $train=[];
+        if(!$result->resumeTrain->isEmpty()){
+            foreach ($result->resumeTrain as $resumeTrain){
+                if($resumeTrain->todate){
+                    $time =$resumeTrain->startyear.'年'.$resumeTrain->startmonth.'月-'.'至今';
+                }else{
+                    $time =$resumeTrain->startyear.'年'.$resumeTrain->startmonth.'月-'.$resumeTrain->endyear.'年'.$resumeTrain->endmonth.'月';
+                }
+                $train[]= [$time,$resumeTrain->agency,$resumeTrain->course];
+            }
+        }
+        $credent = [];
+        if(!$result->resumeCredent->isEmpty()){
+            foreach ($result->resumeCredent as $resumeCredent){
+                $time =$resumeCredent->year.'年'.$resumeCredent->month.'月';
+                $credent[]= [$time,$resumeCredent->name];
+            }
+        }
+        $language = [];
+        if(!$result->resumeLanguage->isEmpty()){
+            foreach ($result->resumeLanguage as $resumeLanguage){
+                $language[]= [$resumeLanguage->language_cn,$resumeLanguage->level_cn];
+            }
+        }
+        $tag_cn = [$result->tag_cn];
+        $title = [
+            '基本设置',
+            '基本信息',
+            '求职意向',
+            '个人简介',
+            '教育经历',
+            '工作经历',
+            '培训经历',
+            '获得证书',
+            '语言能力',
+            '特长标签',
+        ];
+        $tab_content=[];
+        foreach ($title as $key => $val) {
+            if ($key==0) {
+                $headers = ['简历名称', '公开设置', '照片公开设置', '简历完整度','简历审核','简历等级','创建时间','刷新时间'];
+                $rows = [
+                    $resume
+                ];
+                $table = new Table($headers, $rows);
+            } elseif($key==1) {
+                $headers = ['姓名', '性别', '年龄', '身高','学历','婚姻状况','工作经验','户籍','联系电话','联系邮箱','头像'];
+                $rows = [
+                    $member_info
+                ];
+                $table = new Table($headers, $rows,['base_info']);
+            } elseif($key==2) {
+                $headers = ['期望岗位性质', '期望工作地', '期望月薪', '期望从事的岗位','期望从事的行业'];
+                $rows = [
+                    $job_intention
+                ];
+                $table = new Table($headers, $rows);
+            } elseif($key==3) {
+                $headers = [];
+                $rows = [
+                    $profile
+                ];
+                $table = new Table($headers, $rows);
+            } elseif($key==4) {
+                $headers = ['起止年月', '学校名称', '专业名称', '学历'];
+                $rows = $education;
+                $table = new Table($headers, $rows);
+            } elseif($key==5) {
+                $headers = ['起止年月', '公司名称', '职位名称'];
+                $rows =  $work;
+                $table = new Table($headers, $rows);
+            } elseif($key==6) {
+                $headers = ['起止年月', '机构名称', '培训课程'];
+                $rows = $train;
+                $table = new Table($headers, $rows);
+            }elseif($key==7) {
+                $headers = ['起止年月', '证书名称'];
+                $rows = $credent;
+                $table = new Table($headers, $rows);
+            }elseif($key==8) {
+                $headers = ['语言类型', '语言等级'];
+                $rows = $language;
+                $table = new Table($headers, $rows);
+            }elseif($key==9) {
+                $headers = [];
+                $rows = [$tag_cn];
+                $table = new Table($headers, $rows);
+            }
+            $tab_content[$key]['type'] = $val;
+            $tab_content[$key]['form'] = $table;
+        }
+        return view('admin.resume.detail')->with(['contents'=>$tab_content,'result'=>$result])->render();
+
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Resume);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+
+    /**
+     * @审核日志
+     * @param Request $request
+     * @return array
+     */
+    public function audit(Request $request)
+    {
+        $id = $request->id;
+        $type = $request->type;
+        $headers = ['status'=>'审核状态', 'tim'=>'审核时间', 'sec'=>'描述'];
+
+        $res = AuditReason::where(['type_id'=>$id,'type'=>$type])->get();
+        $data = [];
+        foreach ($res as $k => $v) {
+            if ($v['status']==0) {
+                $data[$k]['status'] = '审核未通过';
+            } elseif ($v['status']==2) {
+                $data[$k]['status'] = '审核通过';
+            } else {
+                $data[$k]['status'] = '等待审核';
+            }
+            $data[$k]['tim'] = $v['created_at'];
+            $data[$k]['sec'] = $v['audit_man'].'--'.$v['reason'];
+        }
+        $rows = $data;
+        $table = new Table($headers, $rows);
+        return ['html'=>$table->render(),'detail'=>'审核日志'];
+    }
+
+    public function manager(Request $request)
+    {
+        $uid = $request->uid;
+        $fullname = $request->fullname;
+        $members = Member::where(['id'=>$uid])->select(['id','username','email','mobile','utype'])->first();
+        $header2 = ['会员管理'];
+        $rows2 = '';
+        /*$rows2 = [
+            [
+                '<div class="manitem"><a target="_blank" href="/admin/personal/managerRes/'.$members['id'].'">简历管理</a></div>',
+                '<div class="manitem"><a target="_blank" href="/admin/personal/points?uid='.$members['id'].'&utype='.$members['utype'].'">积分管理</a></div>',
+                '<div class="manitem"><a target="_blank" href="'.admin_base_path("/firm/order/personal")."?uid=".$members['id'].'">充值/订单</a></div>',
+                '<div class="manitem"><a target="_blank" href="">简历推广</a></div>',
+                '<div class="manitem"><a target="_blank" href="/admin/personal/applyJobs?personal_uid='.$members['id'].'">申请的职位</a></div>',
+                '<div class="manitem"><a target="_blank" href="/admin/personal/members?id='.$members['id'].'">个人资料</a></div>',
+            ]
+         ];*/
+        $header3 = ['分析统计'];
+        $rows3= [
+            [
+                '<div class="manitem"><a target="_blank" href="">行为分析</a></div>',
+                '<div class="manitem" ><a target="_blank" href="">会员日志</a></div>',
+            ]
+        ];
+        $header4 = ['联系会员  (手机:'.$members['mobile'].',邮箱:'.$members['email'].')'];
+        $sendSms = '';
+        $sendEmail = '';
+        $sendSys = '';
+        if (Admin::user()->can('person_business_sms')) {
+            $sendSms = '<div class="manitem"><a style="cursor:pointer"  id="fa_sms" ls="'.$members['mobile'].'">发送短信</a></div>';
+        }
+
+        if (Admin::user()->can('person_business_email')) {
+            $sendEmail = '<div class="manitem" ><a style="cursor:pointer" id="fa_email" ls="'.$members['email'].'">发送邮件</a></div>';
+        }
+
+        if (Admin::user()->can('person_business_sys')) {
+            $sendSys =  '<div class="manitem" ><a style="cursor:pointer" id="fa_sys" ls="'.$members['id'].'">发送站内信</a></div>';
+        }
+
+        $rows4= [
+            [
+                $sendSms,
+                $sendEmail,
+                $sendSys,
+            ]
+        ];
+        $table2 = new Table($header2, $rows2);
+        $table3 = new Table($header3, $rows3);
+        $table3->style('width:180px');
+        $table4 = new Table($header4, $rows4);
+        $had = '';
+        if (Admin::user()->can('person_business_login')) {
+            $had = '<div style="height:30px;">对 <strong style="color:#FF6600">'. htmlspecialchars($fullname) .'</strong> 进行以下操作<span style="color: #999999;padding-left: 8px;">用户名:'.htmlspecialchars($members['username']).',uid:'.$uid.'</span>&nbsp;&nbsp;&nbsp;&nbsp;<a target="_blank" href="'.admin_base_path().'/personal/manager/into/'.$members['id'].'">进入会员中心&gt;&gt;</a></div>';
+        }
+        return json_encode(['html'=>[$table2->render(),$table3->render(),$table4->render()],'detail'=>'管理','had'=>$had]);
+    }
+
+    /**
+     * 发送短信
+     * return json
+     */
+    public function sms(Request $request)
+    {
+        $mobile = $request->mobile;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.uidSms'));
+        $form->disableReset();
+        $form->html('
+            <strong style="color:#FF6600">
+                <span>您当前配置的短信接口是【阿里大鱼】。</span>
+            </strong>
+        ');
+        $form->mobile('mobile', '接受手机')->default($mobile);
+        $form->textarea('message','消息');
+        $form->hidden('sms_id')->default('sms_custom');
+        return json_encode(['html'=>$form->render(),'detail'=>'发送短信']);
+    }
+
+    public function uidSms(Request $request)
+    {
+        $moile = $request->mobile;
+        $sms_id = $request->sms_id;
+        $message = $request->message;
+        if (!$moile || !$sms_id || !$message) {
+            admin_toastr('请把资料信息填写完整!', 'error');
+            return back();
+        }
+        $SmsRule = SmsRule::where('alias', $sms_id)->first();
+        if (isset($SmsRule->status) && !empty($SmsRule->status)) {
+            $this->smsService->sendSms($moile, $sms_id, ['content'=>$message]);
+            admin_toastr('短信发送成功', 'success');
+        } else {
+            admin_toastr('请先开启短信-短信规则配置!', 'error');
+        }
+        return back();
+    }
+
+    /**
+     * 发送邮件.
+     * return json
+     */
+    public function email(Request $request)
+    {
+        $email = $request->email;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.uidEmail'));
+        $form->disableReset();
+        $form->email('email', '收件地址')->default($email);
+        $form->text('title', '邮件标题');
+        $form->textarea('body', '邮件内容');
+        return json_encode(['html'=>$form->render(),'detail'=>'发送邮件']);
+    }
+
+    public function uidEmail(Request $request)
+    {
+        $email = $request->email;
+        $title = $request->title;
+        $body = $request->body;
+        if (!$email || !$title || !$body) {
+            admin_toastr('请把资料信息填写完整!', 'error');
+            return back();
+        }
+        $this->emailService->sendMail($email, EmailService::TEMPLATE_SEND_CONTENT, ['title'=>$title], ['content'=>$body]);
+        admin_toastr('邮件发送成功', 'success');
+        return back();
+    }
+
+    /**
+     * 发送站内信
+     * return json
+     */
+    public function sys(Request $request)
+    {
+        $uid = $request->uid;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.uidSend'));
+        $form->disableReset();
+        $form->hidden('uid')->default($uid);
+        $form->textarea('body', '发送内容');
+        return json_encode(['html'=>$form->render(),'detail'=>'发送站内信']);
+    }
+
+    public function uidSend(Request $request)
+    {
+        if (!$request->uid) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        if (!$request->body) {
+            admin_toastr('发送内容不能为空!', 'error');
+            return back();
+        }
+        $data = [];
+        $url = $request->route()->uri;
+        $use_type = explode('/', $url)[1];
+        if ($use_type=='personal') {
+            $userManager = Member::findOrfail($request->uid);
+        } else {
+            $userManager = Company::findOrfail($request->uid);
+        }
+        if (!$userManager) {
+            admin_toastr('该用户不存在!', 'error');
+            return back();
+        }
+        $data['utype'] = $userManager->utype;
+        $data['msgtype'] = 1;
+        $data['msgfromuid'] = Admin::user()->id;
+        $data['msgfrom'] = Admin::user()->username;
+        $data['msgtoname'] = $userManager->username;
+        $data['msgtouid'] = $userManager->id;
+        $data['message'] =  $request->body;
+        if (Pms::create($data)) {
+            admin_toastr('发送成功!', 'success');
+        } else {
+            admin_toastr('发送失败!', 'error');
+        }
+        return back();
+    }
+
+    /**
+     *  return json
+     */
+    public function auditResume(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.auditR'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '审核')->options([2=>'审核通过',0=>'审核未通过'])->default(2);
+        $form->textarea('remark', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核简历']);
+    }
+
+    public function auditR(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $remark = $request->remark;
+        $pms_notice = $request->pms_notice;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $reus=Resume::with(['members:id,username,mobile'])->whereIn('id', $arr)->get();
+        $mobile = [];
+        foreach ($reus as $res) {
+            if (isset($res->members->mobile)) {
+                if (validator_check($res->members->mobile, new MobileRule())) {
+                    $mobile[] = $res->members->mobile;
+                }
+            }
+        }
+        $mobile = array_unique($mobile);
+        $sms_id = $audit ? 'sms_resumeallow' : 'sms_resumenotallow';
+        $result = Resume::whereIn('id', $arr)->update(['audit'=>$audit]);
+        $data=[];
+        foreach ($arr as $k => $v) {
+            $data[$k]['type'] = 1;
+            $data[$k]['type_id'] = $v;
+            $data[$k]['status'] = $audit;
+            $data[$k]['reason'] = $remark;
+            $data[$k]['audit_man'] = Admin::user()->username;
+            $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+            $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        $this->auditReason($data);
+        if ($pms_notice) {
+            if ($audit==0) {
+                $stat='审核未通过';
+            } elseif ($audit==2) {
+                $stat = '审核通过';
+            } else {
+                $stat='等待审核';
+            }
+            $da = [];
+            foreach ($reus as $k => $v) {
+                $da[$k]['uid'] = $v['members']['id'];
+                $da[$k]['username'] = $v['members']['username'];
+                $da[$k]['resume_title'] = $v->title;
+            }
+            foreach ($da as $k => $v) {
+                $ds[$k]['msgtype'] = 1;
+                $ds[$k]['msgfromuid'] = Admin::user()->id;
+                $ds[$k]['msgfrom'] = Admin::user()->username;
+                $ds[$k]['msgtoname'] = $v['username'] ? $v['username'] : 'admin';
+                $ds[$k]['msgtouid'] = $v['uid'] ? $v['uid'] : 0;
+                if ($v['resume_title']) {
+                    $resume_title = '('.$v['resume_title'].')';
+                } else {
+                    $resume_title = '';
+                }
+                $ds[$k]['message'] =  $remark ? '简历'.$resume_title.$stat.'<备注:'.$remark.'>' : '简历'.$resume_title.$stat;
+                $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+            }
+            Pms::insert($ds);
+        }
+        if ($result) {
+            event_search_update(Resume::class, (string)implode(',', $arr), 'update');
+            $this->resumeSms($sms_id, $mobile);
+            admin_toastr('审核成功', 'success');
+        } else {
+            admin_toastr('审核失败', 'error');
+        }
+        return back();
+    }
+
+    /**
+     * CREAT 审核日志.
+     * @param $type
+     * @param $status
+     * @param $reason
+     * @param $audit_man
+     * return arr
+     */
+    public function auditReason($data)
+    {
+        AuditReason::insert($data);
+    }
+
+    public function resumeSms($sms_id, $mobile)
+    {
+        $SmsRule = SmsRule::where('alias', $sms_id)->first();
+        if (isset($SmsRule->status) && !empty($SmsRule->status)) {
+            if ($mobile) {
+                foreach ($mobile as $mobiles) {
+                    $this->smsService->sendSms($mobiles, $sms_id, ['sitename'=>config('aix.system.site.site.site_name'),'sitedomain'=>config('aix.system.site.site.site_domain')]);
+                }
+            }
+        }
+    }
+
+}

+ 305 - 0
app/Admin/Controllers/Person/ResumeImgController.php

@@ -0,0 +1,305 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\Pms;
+use App\Models\ResumeImg;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+
+class ResumeImgController extends Controller
+{
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('附件作品')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('附件作品')
+            ->description('详细')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('附件作品')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('附件作品')
+            ->description('创建')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ResumeImg);
+
+        $grid->model()->with('memberInfos')->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('resumes', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+                $query->whereHas('subsite',function ($query){
+                    $query->where('effective', 1);
+                });
+            });
+        })->orderByRaw("FIELD(audit, 1,2,0)")->orderBy('updated_at', 'desc');
+        $grid->id('ID');
+        $grid->uid('UID');
+        $grid->img()->image('', '150', '150');
+        $grid->created_at();
+        $grid->audit();
+        $grid->title()->display(function ($title){
+            return upload_asset($this->img);
+        });
+        $grid->setView('admin.resumeImg.img');
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('person_resume_img_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+            if (Admin::user()->can('person_resume_img_delete')) {
+                $actions->disableDelete(false);
+            }
+        });
+
+        if (Admin::user()->can('person_resume_img_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }
+
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('person_resume_img_audit')) {
+                $but = <<<EOT
+<div class="btn-group" data-toggle="buttons">
+    <label class="btn btn-google btn-sm" id="audit_img" title="审核图片">
+        <i class="fa fa-audio-description"></i>
+        <input type="radio" class="user-gender">审核图片
+    </label>
+</div>
+EOT;
+                $tools->append($but);
+            }
+        });
+
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('memberInfos.realname', '姓名');
+                $filter->like('resumes.title', '简历名称');
+                $filter->like('memberInfos.phone', '手机');
+                $filter->like('memberInfos.email', '邮箱');
+            });
+            $filter->column(1/2, function ($filter) {
+                if(get_subsite_id()==0 && get_subsite_open()){
+                    $filter->equal('resumes.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+                $filter->equal('audit', '审核状态')->select([
+                    0=>'审核未通过',
+                    1=>'等待审核',
+                    2=>'审核通过',
+                ]);
+                $filter->where(function ($query) {
+                    switch ($this->input) {
+                        case 3:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-3 day'))."'");
+                            break;
+                        case 7:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-7 day'))."'");
+                            break;
+                        case 30:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-30 day'))."'");
+                            break;
+                        case 90:
+                            $query->whereRaw("created_at>='".date('Y-m-d H:i:s', strtotime('-90 day'))."'");
+                            break;
+                    }
+                }, '添加时间', 'created_at')->select([
+                    3=>'三天内',
+                    7=>'一周内',
+                    30=>'一月内',
+                    90=>'三月内',
+                ]);
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ResumeImg::findOrFail($id));
+
+        $show->id('ID');
+        $show->audit('审核状态')->unescape()->as(function ($audit){
+             if ($audit==0) {
+                 return '<span class="label label-danger">审核未通过</span>';
+             } elseif ($audit==2) {
+                 return '<span class="label label-success">审核通过</span>';
+             } else {
+                 return '<span class="label label-warning">等待审核</span>';
+             }
+        });
+        $show->img()->image('', '150', '150');
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ResumeImg);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+    /**
+     * 审核图片
+     * return json
+     */
+    public function auditImg(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.auditI'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '照片')->options([2=>'审核通过',0=>'审核未通过'])->default(2);
+        $form->textarea('remark', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核图片']);
+    }
+    public function auditI(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $remark = $request->remark;
+        $pms_notice = $request->pms_notice;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        $result = ResumeImg::whereIn('id', $arr)->update(['audit'=>$audit]);
+        foreach ($arr as $k => $v) {
+            $data[$k]['type'] = 4;
+            $data[$k]['type_id'] = $v;
+            $data[$k]['status'] = $audit;
+            $data[$k]['reason'] = $remark;
+            $data[$k]['audit_man'] = Admin::user()->username;
+            $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+            $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        $this->auditReason($data);
+        if ($pms_notice) {
+            if ($audit==0) {
+                $stat='审核未通过';
+            } elseif ($audit==2) {
+                $stat = '审核通过';
+            } else {
+                $stat='等待审核';
+            }
+            $reus=ResumeImg::with(['members:id,username'])->whereIn('id', $arr)->select(['id','uid'])->get();
+            foreach ($reus as $k => $v) {
+                $da[$k]['uid'] = $v['members']['id'];
+                $da[$k]['username'] = $v['members']['username'];
+            }
+            foreach ($da as $k => $v) {
+                $ds[$k]['msgtype'] = 1;
+                $ds[$k]['msgfromuid'] = Admin::user()->id;
+                $ds[$k]['msgfrom'] = Admin::user()->username;
+                $ds[$k]['msgtoname'] = isset($v['username']) ? $v['username'] : 'XX';
+                $ds[$k]['msgtouid'] = isset($v['uid']) ? $v['uid'] : 0;
+                $ds[$k]['message'] = $remark ? '附件作品(id:'.array_values($arr)[$k].')'.$stat.'<备注:'.$remark.'>' : '附件作品(id:'.array_values($arr)[$k].')'.$stat;
+                $ds[$k]['created_at'] = date('Y-m-d H:i:s', time());
+                $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+            }
+            Pms::insert($ds);
+        }
+        if ($result) {
+            admin_toastr('审核成功', 'success');
+        } else {
+            admin_toastr('审核失败', 'error');
+        }
+        return back();
+    }
+    /**
+     * CREAT 审核日志.
+     * @param $type
+     * @param $status
+     * @param $reason
+     * @param $audit_man
+     * return arr
+     */
+    public function auditReason($data)
+    {
+        AuditReason::insert($data);
+    }
+}

+ 430 - 0
app/Admin/Controllers/Person/ResumePhotoController.php

@@ -0,0 +1,430 @@
+<?php
+
+namespace App\Admin\Controllers\Person;
+
+use App\Http\Controllers\Controller;
+use App\Models\AuditReason;
+use App\Models\MemberInfo;
+use App\Models\Pms;
+use App\Models\Resume;
+use App\Models\Subsite;
+use App\Validators\Rules\MobileRule;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+
+class ResumePhotoController extends Controller
+{
+    use HasResourceActions;
+
+    protected  $resumeController;
+
+    public function __construct(ResumeController $resumeController)
+    {
+        $this->resumeController = $resumeController;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content, Request $request)
+    {
+        return $content
+            ->header('简历照片')
+            ->description('')
+            ->body(view('admin.resumePhoto.photo')->with(['grid'=>$this->grid($request)]));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('简历照片')
+            ->description('详细')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('简历照片')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('简历照片')
+            ->description('创建')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid($request)
+    {
+        $grid = new Grid(new MemberInfo);
+
+        $grid->model()->when(get_subsite_id()>0, function ($query) {
+            $query->whereHas('members', function ($query) {
+                $query->where('subsite_id', get_subsite_id());
+            });
+        })->where('photo', 1)->orderByRaw("FIELD(photo_audit, 1,2,0)")->orderBy('updated_at', 'desc');
+        $grid->images('姓名')->display(function ($images) {
+            if ($images) {
+                return '<span class="vtip" title="<img src='.upload_asset($images).' width=120 height=120>">
+                            <img class="avatar small" src="'.upload_asset($images).'" align="absmiddle" style="width: 36px;height: 36px;">
+                        </span>&nbsp;&nbsp;&nbsp;'.$this->realname;
+            } else {
+                return '<span class="vtip" ></span>&nbsp;&nbsp;&nbsp;'. $this->realname;
+            }
+        })->width(200);
+        $grid->sex_cn('性别')->width(100);
+        $grid->birthday('出生日期')->width(100);
+        $grid->photo_audit('照片审核')->display(function ($photo_audit) {
+            if ($photo_audit==0) {
+                return'<span style="color:#666666">审核未通过</span><a style="margin-left: 5px;" ls="'.$this->id.'" class="audit_log"><i class="fa fa-eye"></i></a>';
+            } elseif ($photo_audit==2) {
+                return'<span style="color: #009900">审核通过</span><a style="margin-left: 5px;" ls="'.$this->id.'" class="audit_log"><i class="fa fa-eye"></i></a>';
+            } else {
+                return'<span style="color:#FF6600">等待审核</span><a style="margin-left: 5px;" ls="'.$this->id.'" class="audit_log"><i class="fa fa-eye"></i></a>';
+            }
+        });
+        $grid->education_cn('最高学历')->width(150);
+        $grid->experience_cn('工作经验')->width(150);
+        $grid->phone('手机')->width(150);
+        $grid->email('邮箱')->width(150);
+        if(get_subsite_open()){
+            $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
+                if ($subsite_id) {
+                    $Subsite = Subsite::find($subsite_id);
+                    return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+                }
+                return '总站';
+            })->width(150);
+        }
+        $grid->created_at('添加时间')->sortable();
+        $grid->updated_at('更新时间')->sortable();
+
+        $grid->disableCreateButton();
+        $grid->disableExport();
+        $grid->actions(function ($actions) use ($grid) {
+            if (Admin::user()->can('perosn_business')) {
+                $actions->append('<button class="btn btn-primary btn-xs business" ls="'.$actions->row['uid'].'" ld="'.$actions->row['realname'].'" title="业务" >业务</button>');
+            }
+            if (Admin::user()->can('person_resume_photo_audit')) {
+                $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
+            }
+
+           /* if (Admin::user()->can('person_resume_photo_delete')) {
+                $actions->disableDelete(false);
+            }*/
+        });
+
+       /* if (Admin::user()->can('person_resume_photo_delete')) {
+            $grid->tools(function ($tools) {
+                $tools->batch(function ($batch) {
+                    $batch->disableDelete(false);
+                });
+            });
+            $grid->disableRowSelector(false);
+        }*/
+
+        $grid->tools(function ($tools) {
+            if (Admin::user()->can('person_resume_photo_audit')) {
+                $but = <<<EOT
+     <div class="btn-group" data-toggle="buttons">
+                <label class="btn btn-google btn-sm" id="audit_photo" title="审核头像">
+                    <i class="fa fa-audio-description"></i>
+                    <input type="radio" class="user-gender">审核头像
+                </label>
+            </div>
+EOT;
+                $tools->append($but);
+            }
+
+            if (Admin::user()->can('person_resume_image_delete')) {
+                $but = <<<EOT
+     <div class="btn-group" data-toggle="buttons">
+                <label class="btn btn-google btn-sm" id="DeleteImg" title="删除头像">
+                    <i class="fa fa-audio-description"></i>
+                    <input type="radio" class="user-gender">删除头像
+                </label>
+            </div>
+EOT;
+                $tools->append($but);
+            }
+
+        });
+
+        $grid->filter(function ($filter) {
+            // 去掉默认的id过滤器
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->like('phone', '手机');
+                $filter->like('email', '邮箱');
+                $filter->equal('photo_audit', '审核状态')->select([
+                    0=>'审核未通过',
+                    1=>'等待审核',
+                    2=>'审核通过',
+                ]);
+                if(get_subsite_id()==0 && get_subsite_open()){
+                    $filter->equal('members.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
+                }
+            });
+            $filter->column(1/2, function ($filter) {
+                // 关联关系查询
+                $filter->like('realname', '姓名');
+                $filter->equal('sex_cn', '性别');
+                $filter->equal('birthday', '出生日期');
+                $filter->equal('education_cn', '最高学历');
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(MemberInfo::findOrFail($id));
+
+        $show->id('Id');
+        $show->realname('姓名');
+        $show->sex_cn('性别');
+        $show->birthday('出生日期');
+        $show->photo_audit('照片审核')->as(function ($photo_audit) {
+            if ($photo_audit==0) {
+                return '审核未通过';
+            } elseif ($photo_audit==2) {
+                return '审核通过';
+            } else {
+                return '等待审核';
+            }
+        });
+        $show->education_cn('最高学历');
+        $show->experience_cn('工作经验');
+        $show->phone('手机');
+        $show->email('邮箱');
+
+        $show->members()->subsite_id('所属分站')->as(function ($subsite_id) {
+            if ($subsite_id->subsite_id) {
+                $Subsite = Subsite::find($subsite_id->subsite_id);
+                return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
+            }
+            return '总站';
+        });
+        $show->created_at('Created at');
+        $show->updated_at('Updated at');
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Resume);
+
+        $form->text('name', 'Name');
+        $form->email('email', 'Email');
+        $form->password('password', 'Password');
+        $form->text('remember_token', 'Remember token');
+
+        return $form;
+    }
+
+    /**
+     * 审核图片
+     * return json
+     */
+    public function auditPhoto(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.auditP'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('audit', '头像')->options([2=>'审核通过',0=>'审核未通过'])->default(2);
+        $form->textarea('remark', '备注');
+        $form->html('<label style="color: rgb(0, 153, 0)"><input type="checkbox" name="pms_notice" value="1" checked="checked">站内信通知</label>');
+        return json_encode(['html'=>$form->render(),'detail'=>'审核头像']);
+    }
+    public function auditP(Request $request)
+    {
+        $id = $request->id;
+        $audit = $request->audit;
+        $remark = $request->remark;
+        $pms_notice = $request->pms_notice;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+             admin_toastr('数据异常', 'error');
+             return back();
+        }
+        $result = MemberInfo::whereIn('id', $arr)->update(['photo_audit'=>$audit]);
+
+        foreach ($arr as $k => $v) {
+            $data[$k]['type'] = 2;
+            $data[$k]['type_id'] = $v;
+            $data[$k]['status'] = $audit;
+            $data[$k]['reason'] = $remark;
+            $data[$k]['audit_man'] = Admin::user()->username;
+            $data[$k]['created_at'] = date('Y-m-d H:i:s', time());
+            $data[$k]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+        $this->auditReason($data);
+
+        $reus = MemberInfo::with(['members'])->whereIn('id', $arr)->get();
+        $resume_uid = [];
+        if ($audit==0) {
+            $stat='审核未通过';
+        } elseif ($audit==2) {
+            $stat = '审核通过';
+        } else {
+            $stat='等待审核';
+        }
+        $mobile = [];
+        foreach ($reus as $res) {
+            if (isset($res->members->mobile)) {
+                if (validator_check($res->members->mobile, new MobileRule())) {
+                    $mobile[] = $res->members->mobile;
+                }
+            }
+        }
+        $mobile = array_unique($mobile);
+        $sms_id = $audit ? 'sms_resume_photoallow' : 'sms_resume_photonotallow';
+        foreach ($reus as $key => $val) {
+            $ds[$key]['msgtype'] = 1;
+            $ds[$key]['msgfromuid'] = Admin::user()->id;
+            $ds[$key]['msgfrom'] = Admin::user()->username;
+            $ds[$key]['msgtoname'] = $val->members->username;
+            $ds[$key]['msgtouid'] = $val->uid;
+            $resume_uid[] = $val->uid;
+
+            if ($val->members->username) {
+                $username_title = '('.$val->members->username.')';
+            } else {
+                $username_title = '';
+            }
+            $ds[$key]['message'] = $remark ? '简历头像'.$username_title.$stat.'<备注:'.$remark.'>' : '简历头像'.$username_title.$stat;
+            $ds[$key]['created_at'] = date('Y-m-d H:i:s', time());
+            $ds[$key]['updated_at'] = date('Y-m-d H:i:s', time());
+        }
+
+        if ($pms_notice) {
+            Pms::insert($ds);
+        }
+        if ($result) {
+            $this->resumeController->resumeSms($sms_id, $mobile);
+            if ($resume_uid) {
+                event_search_update(Resume::class, [['whereIn','uid', $resume_uid]], 'update');
+            }
+            admin_toastr('审核成功', 'success');
+        } else {
+             admin_toastr('审核失败', 'error');
+        }
+        return back();
+    }
+    /**
+     * CREAT 审核日志.
+     * @param $type
+     * @param $status
+     * @param $reason
+     * @param $audit_man
+     * return arr
+     */
+    public function auditReason($data)
+    {
+        AuditReason::insert($data);
+    }
+
+    public function deleteIma(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('admin.personal.deleteImage'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->html('<div>删除头像会使简历完整度下降,是否删除?</div>');
+        return json_encode(['html'=>$form->render(),'detail'=>'删除头像']);
+    }
+
+    public function deleteImage(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('数据异常', 'error');
+            return back();
+        }
+        \DB::beginTransaction();
+        try {
+            MemberInfo::whereIn('id',$arr)->update(['images'=>'','photo'=>0,'photo_audit'=>1]);
+            $resume_uid = MemberInfo::whereIn('id', $arr)->pluck('uid')->toArray();
+            if ($resume_uid) {
+                $resume = Resume::whereIn('uid',$resume_uid)->get();
+                if(!$resume->isEmpty()){
+                    foreach ($resume as $resumes){
+                        if ($resumes->complete_percent-5>0) {
+                            if ($resumes->complete_percent-5>=70 && $resumes->complete_percent-5<90) {
+                                Resume::where(['id'=>$resumes->id])
+                                    ->update(['complete_percent'=>$resumes->complete_percent-5,'level'=>2]);
+                            } elseif ($resumes->complete_percent-5>=90 && $resumes->complete_percent-15<=100) {
+                                Resume::where(['id'=>$resumes->id])
+                                    ->update(['complete_percent'=>$resumes->complete_percent-5,'level'=>1]);
+                            } else {
+                                Resume::where(['id'=>$resumes->id])
+                                    ->update(['complete_percent'=>$resumes->complete_percent-5,'level'=>0]);
+                            }
+                        }
+                    }
+                }
+                event_search_update(Resume::class, [['whereIn','uid', $resume_uid]], 'update');
+            }
+            \DB::commit();
+            admin_toastr('删除成功', 'success');
+        } catch (\Exception $e) {
+            \DB::rollback();
+            admin_toastr('删除失败', 'error');
+        }
+        return back();
+    }
+
+
+}

+ 538 - 0
app/Admin/Controllers/PersonalTalents/PersonalTalentsController.php

@@ -0,0 +1,538 @@
+<?php
+
+namespace App\Admin\Controllers\PersonalTalents;
+
+use App\Admin\Exports\PersonalTalents\PersonalTalentsExport;
+use App\Models\Admin\AdminUser;
+use App\Models\Category;
+use App\Models\Company;
+use App\Models\PersonalTalents;
+use App\Models\PersonalTalentsLog;
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Show;
+use App\Repositories\CategoryRepository;
+use App\Repositories\CategoryMajorRepository;
+use App\Services\Person\ResumeService;
+use Encore\Admin\Widgets\Table;
+use Illuminate\Http\Request;
+
+class PersonalTalentsController extends Controller
+{
+    use HasResourceActions;
+    protected $CategoryRepository;
+    protected $CategoryMajorRepository;
+    protected $ResumeService;
+    protected $role_id_1 = 30;
+
+    public function __construct(CategoryRepository $CategoryRepository, CategoryMajorRepository $CategoryMajorRepository, ResumeService $ResumeService)
+    {
+
+        $this->CategoryRepository = $CategoryRepository;
+        $this->CategoryMajorRepository = $CategoryMajorRepository;
+        $this->ResumeService = $ResumeService;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        $grid = $this->grid()->render();
+        return $content
+            ->header('人才服务')
+            ->description('人才服务列表')
+            //  ->body($this->grid());
+            ->body(view('admin.personalTalents.index')->with('grid', $grid));
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->header('人才服务')
+            ->description('人才服务详情')
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('人才服务')
+            ->description('人才服务编辑')
+            ->body($this->editForm($id)->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('Create')
+            ->description('description')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new PersonalTalents);
+        $grid->model()->orderBy('id', 'desc');
+        $grid->rc_username('会员名称');
+        $grid->rc_level('人才等级')->display(function () {
+            if ($this->ifconform == 1) {
+                return $this->rc_level;
+            } elseif ($this->ifconform == 2) {
+                return '不符合人才标准';
+            }
+        });
+        $grid->rc_where('人才来源')->display(function () {
+            if ($this->rc_where == 1) {
+                return '自主申报';
+            } elseif ($this->rc_where == 2) {
+                return '企业申报';
+            } elseif ($this->rc_where == 3) {
+                return '信息采集';
+            }
+        });
+        $grid->rc_audit('审核状态')->display(function () {
+            if ($this->rc_audit == 1) {
+                return '<span style="color: #009900">认证通过</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+            } elseif ($this->rc_audit == 2) {
+                return '<span style="color:#FF6600">预判</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+            } elseif ($this->rc_audit == 3) {
+                return '<span style="color:#666666">认证不通过</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
+            }
+        });
+
+        if (Admin::user()->id == 1) {
+            $states = [
+                '1' => ['value' => 1, 'text' => '已完结', 'color' => 'primary'],
+                '0' => ['value' => 0, 'text' => '未完结', 'color' => 'default'],
+            ];
+            $grid->if_finish('完结状态')->switch($states);
+        }
+
+        $grid->created_at('添加时间');
+        $grid->if_agree('推送简历')->display(function () {
+            if ($this->if_agree == 1) {
+                return '<span style="color: #009900">同意</span>';
+            } elseif ($this->if_agree == 2) {
+                return '<span style="color:#666666">不同意</span>';
+            } elseif ($this->if_agree == 0) {
+                return '<span style="color:#FF6600">待定</span>';
+            }
+        });
+
+        $grid->column('admin_user.name', '所属客服')->display(function ($name) {
+            return $name ? $name : '<span style="color:#FF6600">待分配</span>';
+        });
+
+
+        /*批量删除*/
+        $grid->tools(function ($tools) {
+            $admin_user = <<<EOT
+            <div class="btn-group" data-toggle="buttons">
+                <label class="btn btn-google btn-sm" id="admin_user" title="分配客服">
+                    <i class="fa fa-audio-description"></i>
+                    <input type="radio" class="user-gender">分配客服
+                </label>
+            </div>
+EOT;
+            $admin_user_result = AdminUser::where('id', 3)->get();
+            if ($admin_user_result) {
+                $tools->append($admin_user);
+
+            }
+
+            $tools->batch(function ($batch) {
+                $batch->disableDelete(false);
+            });
+        });
+        $grid->disableExport(false); //显示导出按钮
+        $grid->exporter(new PersonalTalentsExport()); //传入自己在第1步创建的导出类
+        $grid->disableCreateButton(true);
+        $grid->actions(function ($actions) {
+            $actions->disableEdit();
+            $actions->disableDelete();
+            $actions->disableView();
+            if ($actions->row['if_finish'] != 1) {
+                $actions->append("<button class='btn btn-primary btn-xs levelSet' data-code=" . $actions->row['id'] . ">人才审核</button>");
+                $actions->append('<button class="btn btn-primary btn-xs" title="录入进度" onclick="window.open(\'' . route('personalTalentsLog.create',
+                        ['id' => $actions->row['id']]) . '\')">录入进度</button>');
+            }
+            $actions->append('<button class="btn btn-primary btn-xs" title="查看进度" onclick="window.open(\'' . route('personalTalentsLog.list',
+                    ['id' => $actions->row['id']]) . '\')">查看进度</button>');
+            if ($actions->row['if_agree'] == 1) {
+                $actions->append('<button class="btn btn-primary btn-xs" title="推送简历" onclick="window.open(\'' . route('push.set',
+                        ['id' => $actions->row['id'], 'uid' => $actions->row['uid']]) . '\')">推送简历</button>');
+            } else {
+                $actions->append("<button class='btn btn-primary btn-xs agreeSet' data-code=" . $actions->row['id'] . ">设置推送</button>");
+            }
+        });
+        $grid->filter(function ($filter) {
+            $filter->column(1 / 2, function ($filter) {
+                $filter->like('rc_username', '姓名');
+                $filter->equal('rc_where', '人才来源')->select([1 => '自主申报', 2 => '企业申报', 3 => '信息申报']);
+                $filter->equal('rc_audit', '审核状态')->select([1 => '认证通过', 2 => '预判', 3 => '认证不通过']);
+                $filter->equal('if_agree', '推送简历')->select([0 => '待确定', 1 => '同意', 2 => '不同意']);
+            });
+
+            $filter->column(1 / 2, function ($filter) {
+                $admin_user_result = AdminUser::where('admin_role_users.role_id', 30)->leftJoin('admin_role_users', 'admin_role_users.user_id', '=', 'admin_users.id');
+                if ($admin_user_result) {
+                    $admin_user_arr = AdminUser::where('admin_role_users.role_id', 30)->leftJoin('admin_role_users', 'admin_role_users.user_id', '=', 'admin_users.id')->pluck('admin_users.name', 'admin_users.id');
+                    $filter->equal('admin_id', '客服')->select($admin_user_arr);
+                }
+                $RC_categoryArr = array_column($this->CategoryRepository->getCategoryByAlias(['alias' => 'RC_category'])->toArray(), 'demand', 'id');
+                $filter->equal('rc_level_id', '人才等级')->select($RC_categoryArr);
+                $filter->equal('if_finish', '完结状态')->select([1 => '已完结', 0 => '未完结']);
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(PersonalTalents::findOrFail($id));
+
+        $show->id('ID');
+        $show->name('学校名称');
+        $show->address('学校地址');
+        $show->created_at('创建时间');
+        $show->updated_at('修改时间');
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new PersonalTalents);
+
+        $form->display('ID');
+        $form->display('Created at');
+        $form->display('Updated at');
+
+        return $form;
+    }
+    public function personalTalentsLog(Request $request)
+    {
+
+        $id = $request->id;
+        $headers = ['content'=>'日志内容', 'log_time'=>'操作时间', 'auth_man'=>'操作人员'];
+        $data = [];
+        $res = PersonalTalentsLog::where(['talents_id'=>$id])->orderBy('id', 'desc')->get();
+        if (!$res) {
+            $rows = $data;
+        } else {
+            foreach ($res as $k => $v) {
+                $data[$k]['content'] = $v['content'];
+                $data[$k]['log_time'] = $v['created_at'];
+                $data[$k]['auth_man'] = $v['auth_man'];
+            }
+            $rows = $data;
+        }
+
+        $table = new Table($headers, $rows);
+        return ['html'=>$table->render(),'detail'=>'日志信息'];
+    }
+
+
+    // 人才审核
+    public function levelSet(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('level.set.update'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $RC_categoryArr = array_column($this->CategoryRepository->getCategoryByAlias(['alias' => 'RC_category'])->toArray(), 'demand', 'id');
+        $form->select('rc_level_id', '人才等级')->options(
+            $RC_categoryArr
+        )->rules([
+            'required',
+        ])->setMustMark();
+        $form->radio('rc_audit', '人才认证状态')->options([1 => '认证通过', 3 => '认证未通过']);
+        return json_encode(['html' => $form->render(), 'detail' => '人才审核']);
+    }
+
+    // 人才审核
+    public function levelSetUpdate(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('请勾选需要人才审核的会员', 'error');
+            return back();
+        }
+
+        $rc_level_id = $request->rc_level_id;
+        if (empty($rc_level_id)) {
+            admin_toastr('人才等级不能为空', 'error');
+            return back();
+        }
+
+        $rc_level = Category::where('id', $rc_level_id)->first();
+
+        if (!$rc_level) {
+            admin_toastr('参数错误', 'error');
+            return back();
+        }
+
+        $role_arr = [];
+        if (!empty(Admin::user()->roles)) {
+            foreach (Admin::user()->roles as $key => $val) {
+                $role_arr[] = $val->id;
+            }
+        }
+
+        if (!in_array($this->role_id_1, $role_arr)) {
+            admin_toastr('人才客服才可以操作', 'error');
+            return back();
+        }
+
+        //判断是否为此人才的所属客服在操作
+        $adminid = PersonalTalents::where(array('id' => $id))->value('admin_id');
+        if ($adminid != Admin::user()->id) {
+            admin_toastr('此人才的客服才可以操作', 'error');
+            return back();
+        }
+
+        $time = time();
+        $data = array();
+        $data['rc_level_id'] = $rc_level_id;
+        $data['rc_level'] = $rc_level->demand;
+        $data['rc_sort'] = $rc_level->order;
+        $data['audit_time'] = $time;//审核时间
+        $data['rc_audit'] = $request->rc_audit;
+
+        if(!empty($rc_level)){
+            $data['ifconform'] = 1;
+        }
+
+        try {
+            PersonalTalents::where('id', $id)->update($data);
+            $log = array();
+            if ($request->audit == 1) {
+                $authinfo = "认证通过";
+            } else {
+                $authinfo = "认证不通过";
+            }
+            $log['talents_id'] = $id;
+            $log['log_class'] = 2;//日志类型
+            $log['content'] = Admin::user()->username . "将人才认证为'" . $rc_level->demand . "',审核状态设置为'" . $authinfo . "'";
+            $log['log_time'] = time();
+            $log['auth_man'] = Admin::user()->username;
+            PersonalTalentsLog::create($log);
+            admin_toastr('审核成功', 'success');
+            return back();
+        } catch (\Exception $e) {
+            admin_toastr('审核失败', 'error');
+            return back();
+        }
+    }
+
+    public function adminUserSet(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('adminUser.set.update'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->select('admin_id', '客服名称')->options(
+            AdminUser::where('admin_role_users.role_id', 30)->leftJoin('admin_role_users', 'admin_role_users.user_id', '=', 'admin_users.id')->pluck('admin_users.name', 'admin_users.id')
+        )->rules([
+            'required',
+        ])->setMustMark();
+        return json_encode(['html' => $form->render(), 'detail' => '分配客服']);
+    }
+
+    public function adminUserSetUpdate(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('请勾选需要分配客服的会员', 'error');
+            return back();
+        }
+        $admin_user_id = $request->admin_id;
+        if (empty($admin_user_id)) {
+            admin_toastr('客服不能为空', 'error');
+            return back();
+        }
+        if (Admin::user()->id != 1) {
+            admin_toastr('高级管理员才可以操作', 'error');
+            return back();
+        }
+
+        try {
+            $time = time();
+            $admin_user = AdminUser::find($admin_user_id);
+            foreach ($arr as $key => $val) {
+                $info = array();
+                PersonalTalents::where('id', $val)->update(array('admin_id' => $admin_user_id));
+                //填入日志
+                $info['talents_id'] = $val;
+                $info['log_class'] = 3;//日志类型高级管理员分配客服
+                $info['content'] = Admin::user()->username . "将此人才的客服更改为客服人员‘" . $admin_user->username . "’";
+                $info['log_time'] = $time;
+                $info['auth_man'] = Admin::user()->username;
+                PersonalTalentsLog::create($info);
+            }
+            admin_toastr('分配成功', 'success');
+            return back();
+        } catch (\Exception $e) {
+            admin_toastr('分配失败', 'error');
+            return back();
+        }
+    }
+
+    // 设置推送
+    public function agreeSet(Request $request)
+    {
+        $id = $request->id;
+        $form = new \Encore\Admin\Widgets\Form();
+        $form->action(route('agree.set.update'));
+        $form->disableReset();
+        $form->hidden('id', 'ID')->default($id);
+        $form->radio('rc_agree', '推送简历')->options([1 => '同意', 2 => '不同意']);
+        $form->textarea('agree_content', '备注');
+        return json_encode(['html' => $form->render(), 'detail' => '设置推送']);
+    }
+
+    // 设置推送
+    public function agreeSetUpdate(Request $request)
+    {
+        $id = $request->id;
+        $arr = array_filter(explode(',', $id));
+        if (empty($arr)) {
+            admin_toastr('请选择需要推送的会员', 'error');
+            return back();
+        }
+
+        $rc_agree = $request->rc_agree;
+        if (empty($rc_agree)) {
+            admin_toastr('参数有误', 'error');
+            return back();
+        }
+
+        try {
+            PersonalTalents::where('id', $id)->update(array('if_agree' => $rc_agree));
+            $log = array();
+            //存入日志
+            if ($rc_agree == 1) {
+                $agree = '同意';
+            } elseif ($rc_agree == 2) {
+                $agree = '不同意';
+            }
+            $log['talents_id'] = $id;
+            $log['log_class'] = 6;//日志类型
+            $content = $request->agree_content;
+            if ($content != '') {
+                $log['content'] = Admin::user()->username . "设置此人才" . $agree . '推送简历' . ',备注:' . $content;
+            } else {
+                $log['content'] = Admin::user()->username . "设置此人才" . $agree . '推送简历';
+            }
+            $log['log_time'] = time();
+            $log['auth_man'] = Admin::user()->username;
+            PersonalTalentsLog::create($log);
+            admin_toastr('操作成功', 'success');
+            return back();
+        } catch (\Exception $e) {
+            admin_toastr('操作失败', 'error');
+            return back();
+        }
+    }
+
+    // 推送简历
+    public function pushSet(Content $content)
+    {
+        $id = request()->id;
+        $form = new Form(new PersonalTalents);
+        $form->setAction(route('push.set.update'));
+        $form->disableReset();
+        $form->hidden('ids')->default($id);
+        $form->multipleSelect('company_id', '企业名称')->options(
+            Company::where('audit', 1)->pluck('companyname', 'id')->all()
+        )->rules([
+            'required',
+        ])->setMustMark();
+        return $content
+            ->header('推送简历')
+            ->description('创建')
+            ->body($form);
+    }
+
+
+    // 推送简历
+    public function pushSetUpdate(Request $request)
+    {
+        $data = $request->all();
+        $arr = array_filter(explode(',', $data['ids']));
+        if (empty($arr)) {
+            admin_toastr('请选择需要推送的会员', 'error');
+            return back();
+        }
+
+        if (empty($data['company_id'])) {
+            admin_toastr('请选择要推送的企业名称', 'error');
+            return back();
+        }
+
+        $company_id_arr = [];
+        $company_name_arr = [];
+        foreach ($data['company_id'] as $key => $val) {
+            if (!empty($val)) {
+                $company_id_arr[] = $val;
+                $company_name_arr[] = Company::where('id', $val)->value('companyname');
+            }
+        }
+
+        try {
+            $this->ResumeService->resumeEntrustByAdmin($company_id_arr,$data['ids'],Admin::user()->username);
+            admin_toastr('推送成功', 'success');
+        } catch (\Exception $e) {
+            admin_toastr('职位不匹配,推送失败!', 'error');
+        }
+        return redirect(admin_base_path("personalTalents/personaltalents"));
+    }
+}

+ 177 - 0
app/Admin/Controllers/PersonalTalents/PersonalTalentsLogController.php

@@ -0,0 +1,177 @@
+<?php
+
+namespace App\Admin\Controllers\PersonalTalents;
+
+use App\Http\Controllers\Controller;
+use App\Models\PersonalTalents;
+use App\Models\PersonalTalentsLog;
+use Encore\Admin\Controllers\HasResourceActions;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Layout\Content;
+
+
+class PersonalTalentsLogController extends Controller
+{
+    protected $role_id_1 = 30;
+    use HasResourceActions;
+
+    /**
+     * Index interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('进度列表')
+            ->description('')
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param mixed $id
+     * @param Content $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->header('进度列表')
+            ->description('编辑')
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param Content $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->header('进度列表')
+            ->description('创建')
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $id = request()->id;
+        if(empty($id)){
+            admin_toastr('请选择人才!', 'error');
+            return back();
+        }
+        $grid = new Grid(new PersonalTalentsLog());
+        $grid->model()->where('talents_id', $id)->where('log_class', 5)->orderBy('id', 'desc');
+        $grid->id('ID');
+        $grid->log_time('操作时间')->display(function ($log_time) {
+            return date('Y-m-d',$log_time) ;
+        });
+        $grid->content('日志内容');
+        $grid->auth_man('操作人员');
+        $grid->actions(function ($actions) use ($grid) {
+            $actions->disableView();
+        });
+
+        $grid->filter(function ($filter) {
+            $filter->like('content', '内容');
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $id = request()->id;
+        $form = new Form(new PersonalTalentsLog);
+        $form->date('log_time',
+            '处理时间')->format('YYYY-MM-DD')->default(date('Y-m-s', time()))->setMustMark();
+        $form->textarea('inplan_content', '进度内容')->attribute(['maxlength'=>1000])->rules(['required'], ['required'=>"请填写进度内容"])->setMustMark();
+        $form->hidden('ids')->default($id);
+        return $form;
+    }
+
+    public function personalTalentsLogList(Content $content)
+    {
+        return $content
+            ->header('进度列表')
+            ->description('进度列表')
+            ->body($this->grid());
+    }
+
+    public function store()
+    {
+        $id = request()->ids;
+
+        $log_time = request()->log_time;
+        if (empty($log_time)) {
+            admin_toastr('请选择日期', 'error');
+            return back();
+        }
+
+        $inplan_content = request()->inplan_content;
+        if (empty($inplan_content)) {
+            admin_toastr('请填入进度内容', 'error');
+            return back();
+        }
+
+        $role_arr = [];
+        if (!empty(Admin::user()->roles)) {
+            foreach (Admin::user()->roles as $key => $val) {
+                $role_arr[] = $val->id;
+            }
+        }
+
+        if (!in_array($this->role_id_1, $role_arr)) {
+            admin_toastr('人才客服才可以操作', 'error');
+            return back();
+        }
+
+        //判断是否为此人才的所属客服在操作
+        $adminid = PersonalTalents::where(array('id' => $id))->value('admin_id');
+        if ($adminid != Admin::user()->id) {
+            admin_toastr('此人才的客服才可以操作', 'error');
+            return back();
+        }
+
+        try {
+            $log['talents_id'] = $id;
+            $log['content'] = $inplan_content;
+            $log['log_time'] = strtotime($log_time);
+            $log['log_class'] = 5;//日志类型
+            $log['auth_man'] = Admin::user()->username;
+            PersonalTalentsLog::create($log);
+            admin_toastr('操作成功', 'success');
+        } catch (\Exception $e) {
+            admin_toastr('操作失败', 'error');
+        }
+        return redirect(admin_base_path("personalTalents/personalTalentsLog/list/".request()->ids));
+    }
+}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно