get("keyword"); if (is_null($keyword)) { $data = DB::table('topic_e16_zq_corps')->orderBy("corp_id")->paginate($page_size); } else { $data = DB::table('topic_e16_zq_corps')->where("corp_name", "like", "%" . $keyword . "%")->orderBy("corp_id")->paginate($page_size); } $data->withPath("list?keyword=".$keyword); return view("superadmin.games.autumn.list", ['data'=>$data]); } public function autumnUserUpload(Request $request){ $params = $request->all(); $corp_id = $params['corp_id']; if($request->isMethod('post')){ $filePath = $_FILES['file']['tmp_name']; Excel::load($filePath, function ($reader) { $reader = $reader->getSheet(0); $res = $reader->toArray(); if($res[0][0] != '姓名' || $res[0][1] != '电话号码'){ print_r(Api::json(config('code.fail'), '文件错误')); exit; } unset($res[0]); $res = json_encode($res); Redis::set('autumn_user_load', $res); }); $data = Redis::get('autumn_user_load'); $userData = json_decode($data, true); foreach($userData as $k=>$v){ $userQuery = []; $userQuery['corp_id'] = $corp_id; $userQuery['realname'] = $v[0]; $userQuery['phone'] = $v[1]; $userQuery['create_time'] = time(); $repeat_res = DB::table('topic_e16_zq_user')->where('corp_id', $corp_id)->where('phone', $v[1])->first(); if($repeat_res){ DB::table('topic_e16_zq_user')->where('corp_id', $corp_id)->where('phone', $v[1])->update($userQuery); } else { DB::table('topic_e16_zq_user')->insert($userQuery); } } return Api::json(config('code.success'), trans('msg.success')); } } }