| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 | 
							- <?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;
 
-     }
 
- }
 
 
  |