| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 | 
							- <?php
 
- namespace App\Admin\Controllers\Content;
 
- use App\Admin\Exports\Content\HouseApplyZrExport;
 
- use App\Http\Controllers\Controller;
 
- use App\Models\TalentHouse;
 
- use App\Models\TalentHouseApply;
 
- use App\Services\Common\SmsService;
 
- use Encore\Admin\Controllers\HasResourceActions;
 
- use Encore\Admin\Facades\Admin;
 
- use Encore\Admin\Grid;
 
- use Encore\Admin\Layout\Content;
 
- use Illuminate\Http\Request;
 
- use Illuminate\Support\Facades\DB;
 
- class BuyHouseZrController extends Controller
 
- {
 
-     use HasResourceActions;
 
-     private $status = ['未知', '待审核', '审核通过', '审核驳回', '审核不通过'];
 
-     private $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
 
-     /**
 
-      * Index interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function index(Content $content)
 
-     {
 
-         return $content
 
-             ->header('申报列表')
 
-             ->description(' ')
 
-             ->body(view('admin.content.buy_house_zr')->with(['grid' => $this->grid()]));
 
-     }
 
-     /**
 
-      * Make a grid builder.
 
-      *
 
-      * @return Grid
 
-      */
 
-     protected function grid()
 
-     {
 
-         $grid = new Grid(new TalentHouseApply());
 
-         $grid->model()->with(['house', 'idcard'])->where('is_back', 2)->where('rs_check_status', 2)->orderBy('zr_check_status', 'ASC');
 
-         $status_text = $this->status;
 
-         $grid->id('ID');
 
-         $grid->name('姓名');
 
-         $grid->mobile('联系电话');
 
-         $grid->talent_level('人才层次');
 
-         $grid->column('房源')->display(function () {
 
-             return $this->house->name;
 
-         });
 
-         $grid->zr_check_status('状态')->display(function () use ($status_text) {
 
-             return $status_text[$this->zr_check_status];
 
-         });
 
-         $grid->zr_check_comment('备注')->style('max-width:400px');
 
-         $grid->actions(function ($actions) {
 
-             $actions->append(" <button class='btn btn-primary btn-xs detail' id=" . $actions->row['id'] . ">详情审核</button>");
 
-         });
 
-         $grid->filter(function ($filter) {
 
-             $filter->disableIdFilter();
 
-             $filter->like('name', '姓名');
 
-             $filter->equal('house_id', '房源')->select(TalentHouse::all()->pluck('name', 'id'));
 
-             $status_option = ['全部', '待审核', '审核通过', '审核驳回', '审核不通过'];
 
-             $filter->where(function ($query) {
 
-                 if ($this->input > 0) {
 
-                     $query->where('zr_check_status', '=', $this->input);
 
-                 }
 
-             }, '状态', 'status')->radio($status_option);
 
-         });
 
-         $grid->disableExport(false); //显示导出按钮
 
-         $grid->exporter(new HouseApplyZrExport()); //传入自己在第1步创建的导出类
 
-         return $grid;
 
-     }
 
-     /**
 
-      * 审核
 
-      */
 
-     public function audit(Request $request, SmsService $smsService)
 
-     {
 
-         $id     = $request->id;
 
-         $status = $request->status;
 
-         $reason = $request->reason;
 
-         $url    = empty($request->url) ? admin_base_path('content/buy_house_zj') : $request->url;
 
-         if (empty($id)) {
 
-             admin_toastr('数据异常', 'error');
 
-             return redirect(admin_base_path('content/buy_house_zj'));
 
-         }
 
-         $apply                   = TalentHouseApply::find($id);
 
-         $apply->zr_check_status  = $status;
 
-         $apply->zr_check_comment = $reason;
 
-         $apply->zr_check_time    = date('Y-m-d H:i:s');
 
-         if ($apply->status == 4) {
 
-             $apply->is_sock = 2;
 
-         } else {
 
-             if ($apply->zj_check_status == 2) {
 
-                 $apply->status = $status;
 
-             } else {
 
-                 $apply->status = $status == 2 ? 1 : $status;
 
-             }
 
-         }
 
-         $result = $apply->save();
 
-         //日志
 
-         $house = TalentHouse::find($apply['house_id']);
 
-         $admin = Admin::user();
 
-         $log   = [
 
-             'house_name'    => $house['name'],
 
-             'user_name'     => $apply['name'],
 
-             'check_name'    => $admin['name'],
 
-             'data'          => json_encode($apply),
 
-             'created_at'    => date('Y-m-d H:i:s'),
 
-             'check_status'  => $apply['zr_check_status'],
 
-             'check_comment' => $apply['zr_check_comment'],
 
-         ];
 
-         DB::table('talent_house_check_log')->insert($log);
 
-         //审核不通过发送短信
 
-         if ($status == 3) {
 
-             $time = strtotime($house['supply_time']);
 
-             $smsService->sendSms($apply['mobile'], 'sms_buyhouse_supply', ['name' => $apply['name'], 'month' => date('m', $time), 'day' => date('d', $time)]);
 
-         }
 
-         if ($result) {
 
-             admin_toastr('审核成功', 'success');
 
-         } else {
 
-             admin_toastr('该信息不存在或已审核', 'error');
 
-         }
 
-         return redirect($url);
 
-     }
 
-     /**
 
-      * 详情
 
-      */
 
-     public function detail(Request $request)
 
-     {
 
-         $id               = $request->id;
 
-         $info             = TalentHouseApply::with('idcard')->where('id', $id)->first();
 
-         $info->family     = json_decode($info->family);
 
-         $info->marry_text = $this->marry[$info->marry];
 
-         //数据处理
 
-         if (!empty(json_decode($info->certificates))) {
 
-             $info->certificates = json_decode($info->certificates);
 
-         } else {
 
-             $info->certificates = [];
 
-         }
 
-         if (!empty(json_decode($info->marry_prove))) {
 
-             $info->marry_prove = json_decode($info->marry_prove);
 
-         } else {
 
-             $info->marry_prove = [];
 
-         }
 
-         if (!empty(json_decode($info->household_register))) {
 
-             $info->household_register = json_decode($info->household_register);
 
-         } else {
 
-             $info->household_register = [];
 
-         }
 
-         if (!empty(json_decode($info->work_prove))) {
 
-             $info->work_prove = json_decode($info->work_prove);
 
-         } else {
 
-             $info->work_prove = [];
 
-         }
 
-         $with                 = ['info' => $info, 'form_url' => route('content.buy_house_zr.audit'), 'status' => $this->status];
 
-         $with['check_status'] = $info['zr_check_status'];
 
-         $html = view('admin.ajax.buy_house_detail')->with($with)->render();
 
-         return response()->json(['code' => 1, 'data' => $html]);
 
-     }
 
- }
 
 
  |