all(); $page_size = empty($params['page_size']) ? 10 : $params['page_size']; $keyword = $request->get("keyword"); if (is_null($keyword)) { $corpInfos = Corps::orderBy("corp_id")->paginate($page_size); } else { $corpInfos = Corps::where("corp_name", "like", "%" . $keyword . "%") ->orderBy("corp_id")->paginate($page_size); } //数据处理 foreach($corpInfos as $k=>$corpInfo){ if($corpInfo['source_type'] == 'agh'){ $corpInfos[$k]['source_type'] = '爱关怀'; } $corpInfos[$k]['has_wesuit'] = $corpInfo['has_wesuit'] == 0 ? '未开启':'已开启'; $corpInfos[$k]['activity_num'] = Activitys::where('corp_id', $corpInfo['corp_id'])->where('status', 1)->where('is_complete_set', 1)->count(); } $corpInfos->withPath("list?keyword=".$keyword); return view("superadmin.brainstorming.corp_list", ['data'=>$corpInfos]); } /** * 爱答题活动列表 * @return string */ public function activityList(Request $request){ $params = $request->all(); $keyword = isset($params['keyword'])?$params['keyword']:''; $corp_id = isset($params['corp_id'])?$params['corp_id']:0; $page_size = empty($params['page_size']) ? 15 : $params['page_size']; $sql = Activitys::where('status', '1')->where('is_complete_set', '1')->orderByDesc("create_time"); if(isset($params['corp_id']) && !empty($params['corp_id'])){ $sql = $sql->where('corp_id', $params['corp_id']); } if (isset($params['keyword']) && !empty($params['keyword'])) { $sql = $sql->where('title', 'like', "%" . $params['keyword'] . "%"); } $data = $sql->paginate($page_size); //企业信息 $corpIds = $data->pluck("corp_id"); $corpNames = Corps::whereIn("corp_id",$corpIds)->pluck("corp_name","corp_id"); //时间戳格式化 foreach ($data as $key => $val) { //活动状态 if ($val['start_time'] > time()) { $data[$key]['activity_status_text'] = '未开始'; } elseif ($val['end_time'] < time()) { $data[$key]['activity_status_text'] = '已结束'; } else { if ($val['is_temp_stop'] == 1) { $data[$key]['activity_status_text'] = '已暂停'; } else { $data[$key]['activity_status_text'] = '进行中'; } } $data[$key]['start_time'] = date('Y-m-d H:i', $val['start_time']); $data[$key]['end_time'] = date('Y-m-d H:i', $val['end_time']); $data[$key]['corp_name'] = $corpNames[$val['corp_id']]; //管理路由地址 $app_info = Apps::where('app_id', $val['app_id'])->first()->toArray(); $data[$key]['admin_url'] = $app_info['admin_url']; //游戏路由地址 $data[$key]['game_url'] = env('WEB_URL') . '/' . $app_info['app_code'] . '?activity_id=' . $val['activity_id']; } //分页 $data->withPath("list?keyword=".$keyword.'&corp_id='.$corp_id); return view("superadmin.brainstorming.activity_list", ['data'=>$data]); } /** * 活动新增 */ public function activityAdd(Request $request){ $params = $request->all(); $app_id = 1; $keys = array('corp_id'); foreach ($keys as $key) { if (empty($params[$key])) { return Api::json(config('code.params_error'), trans('params.'.$key) . trans('msg.params_not_null')); } } // $res = ActivityService::addAct($params['corp_id'], $app_id); return redirect(env('WEB_URL')."/manage/static/index.html#/Configger?app_id=1&corp_id=".$params['corp_id']); } /** * 爱答题活动回收站 */ public function activityRecycle(Request $request){ $params = $request->all(); $keyword = isset($params['keyword'])?$params['keyword']:''; $corp_id = isset($params['corp_id'])?$params['corp_id']:0; $page_size = empty($params['page_size']) ? 15 : $params['page_size']; $sql = Activitys::where('status', '0')->where('is_complete_set', '1')->orderByDesc("create_time"); if(isset($params['corp_id']) && !empty($params['corp_id'])){ $sql = $sql->where('corp_id', $params['corp_id']); } if (isset($params['keyword']) && !empty($params['keyword'])) { $sql = $sql->where('title', 'like', "%" . $params['keyword'] . "%"); } $data = $sql->paginate($page_size); //企业信息 $corpIds = $data->pluck("corp_id"); $corpNames = Corps::whereIn("corp_id",$corpIds)->pluck("corp_name","corp_id"); //时间戳格式化 foreach ($data as $key => $val) { $data[$key]['start_time'] = date('Y-m-d H:i', $val['start_time']); $data[$key]['end_time'] = date('Y-m-d H:i', $val['end_time']); $data[$key]['corp_name'] = $corpNames[$val['corp_id']]; //管理路由地址 $app_info = Apps::where('app_id', $val['app_id'])->first()->toArray(); $data[$key]['admin_url'] = $app_info['admin_url']; //游戏路由地址 $data[$key]['game_url'] = env('WEB_URL') . '/' . $app_info['app_code'] . '?activity_id=' . $val['activity_id']; } //分页 $data->withPath("recycle?keyword=".$keyword.'&corp_id='.$corp_id); return view("superadmin.brainstorming.activity_recycle", ['data'=>$data]); } /** * 活动二维码弹框页面 * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function imageUrl(Request $request){ return view("superadmin.brainstorming.image_url", ['data'=>'']); } /** * 修改活动收费状态 1 免费限制人数 2 收费不限人数 * @param Request $request * @return array|string */ public function postChangeActivityType(Request $request){ $params = $request->all(); if(!isset($params['activity_id']) || empty($params['activity_id'])){ return Api::json(config('code.params_error'), trans('msg.params_error')); } $activity_info = Activitys::where('activity_id', $params['activity_id'])->first(); if(!$activity_info){ return Api::json(config('code.fail'), trans('msg.activity_not_exist')); } $res = Activitys::where('activity_id', $params['activity_id'])->update(['activity_type'=> 2]); if($res){ return Api::json(config('code.success'), trans('msg.success')); } else { Api::json(config('code.fail'), trans('msg.fail')); } return $params; } /** * 超管看板 * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function board(){ $data = []; $data['user_online_count'] = Redis::get('bs_online'); $data['activity_active_count'] = Activitys::where('end_time', '>', time())->where('start_time', '<', time())->where('status', 1)->where('is_complete_set', 1)->count(); $data['activity_active'] = Activitys::where('end_time', '>', time())->where('start_time', '<', time())->where('status', 1)->where('is_complete_set', 1)->orderByDesc('update_time')->get(); $data['activity_end'] = Activitys::where('end_time', '<', time())->where('status', 1)->where('is_complete_set', 1)->orderByDesc('end_time')->limit(10)->get(); foreach($data['activity_active'] as $k=>$v){ $data['activity_active'][$k]['user_count'] = Users::where('activity_id', $v['activity_id'])->where('status', 1)->count(); $data['activity_active'][$k]['user_join'] = Users::where('activity_id', $v['activity_id'])->where('status', 1)->where('platform', '!=', NULL)->count(); $user_online = Redis::get('bs_online:'.$v['activity_id']); $data['activity_active'][$k]['user_online'] = $user_online?$user_online:0; $data['activity_active'][$k]['must_success'] = Users::where('activity_id', $v['activity_id'])->where('status', 1)->where('is_blockade_success', 1)->count(); $data['activity_active'][$k]['blockade_num'] = Blockades::where('activity_id', $v['activity_id'])->count(); $data['activity_active'][$k]['pk_num'] = PkRooms::where('activity_id', $v['activity_id'])->count(); $data['activity_active'][$k]['corp_short_name'] = Corps::where('corp_id', $v['corp_id'])->value('corp_short_name'); } foreach($data['activity_end'] as $k=>$v){ $data['activity_end'][$k]['user_count'] = Users::where('activity_id', $v['activity_id'])->where('status', 1)->count(); $data['activity_end'][$k]['user_join'] = Users::where('activity_id', $v['activity_id'])->where('status', 1)->where('platform', '!=', NULL)->count(); $data['activity_end'][$k]['must_success']= Users::where('activity_id', $v['activity_id'])->where('status', 1)->where('is_blockade_success', 1)->count(); $data['activity_end'][$k]['blockade_num']= Blockades::where('activity_id', $v['activity_id'])->count(); $data['activity_end'][$k]['pk_num'] = PkRooms::where('activity_id', $v['activity_id'])->count(); $data['activity_end'][$k]['corp_short_name'] = Corps::where('corp_id', $v['corp_id'])->value('corp_short_name'); } $data['source'] = $_SERVER['HTTP_USER_AGENT']; return view("superadmin.brainstorming.board", ['data'=>$data]); } /** * 活动复制 */ public function activityCopy(Request $request){ $params = $request->all(); $keys = array('activity_id', 'corp_id', 'app_id'); foreach ($keys as $key) { if (empty($params[$key])) { return Api::json(config('code.params_error'), trans('params.'.$key) . trans('msg.params_not_null')); } } $res = ActivityService::copyActivity($params); return redirect(env('WEB_URL')."/manage/static/index.html#/Gamemove?activity_id=".$res."&corp_id=".$params['corp_id']."&app_id=".$params['app_id']."&index=2"); } public function getChangeAdminIndex(Request $request){ $params = $request->all(); $activityId = $params['activity_id']; $activityInfo = ActivityService::getActivityInfo($activityId); $corpInfo = Corps::where('corp_id', $activityInfo['corp_id'])->first(); $adminInfo = Admin::where('id', $activityInfo['creator'])->first(); $data['title'] = $activityInfo['title']; $data['corp_name'] = $corpInfo['corp_name']; $data['username'] = $adminInfo['username']; $data['activity_id'] = $activityId; return view("superadmin.brainstorming.admin_change", ['data' => $data]); } /** * 活动转移 * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string */ public function postChangeAdmin(Request $request){ $params = $request->all(); $activityId = $params['activity_id']; $admin_new = $params['admin_new']; //活动信息 $activityInfo = ActivityService::getActivityInfo($activityId); if(!$activityInfo){ return Api::json(config('code.fail'), trans('msg.activity_not_exist')); } //新管理员信息 $adminInfo = Admin::where('username', $admin_new)->where('status', 1)->first(); if(!$adminInfo){ return Api::json(config('code.fail'), trans('msg.admin_not_exist')); } $activity_res = Activitys::where('activity_id', $activityId)->update(['creator'=>$adminInfo['id'], 'corp_id'=>$adminInfo['corp_id']]); if($activityInfo['corp_id'] != $adminInfo['corp_id']) { $config_res = Configs::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $user_res = Users::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $category_res = Categorys::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $question_res = Questions::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $blockades_res = Blockades::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $blockades_answer_res = BlockadeAnswer::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $department_res = Departments::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $knowledge_res = KnowledgeRecords::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $pk_room_res = PkRooms::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $pk_answer_res = PkAnswer::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $lottery_res = Lotterys::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); $prize_res = Prizes::where('activity_id', $activityId)->update(['corp_id' => $adminInfo['corp_id']]); if($config_res && $user_res && $category_res && $question_res && $blockades_res && $blockades_answer_res && $department_res && $knowledge_res && $pk_room_res && $pk_answer_res && $lottery_res && $prize_res){ return Api::json(config('code.success'), trans('msg.success')); } } if($activity_res){ return Api::json(config('code.success'), trans('msg.success')); } else { return Api::json(config('code.fail'), trans('msg.sql_error')); } } /** * 公告发布 * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string */ public function notice(Request $request){ if($request->isMethod('post')){ if(!empty($_FILES['file']['tmp_name'])) { $file = $request->file('file'); $name = $file->getClientOriginalName();//得到图片名; $ext = $file->getClientOriginalExtension();//得到图片后缀; $fileName = md5(uniqid($name)); $fileName = $fileName.'.'.$ext;//生成新的的文件名 Storage::disk('public')->put($fileName,file_get_contents($file->getRealPath())); $data = [ 'src' => env('WEB_URL').'/manage/uploads/'.$fileName, 'title' => '', ]; return response()->json([ 'code' => 0, 'msg' => '', 'data' => $data ]); } } else { $params = $request->all(); if(empty($params['message_id'])) { if(isset($params['title']) && isset($params['content'])) { //新增公告 $query = []; $query['title'] = $params['title']; $query['content'] = $params['content']; $query['create_time'] = time(); Messages::insert($query); return redirect('/manage/super/brainstorming/notice/list'); } else { return view("superadmin.brainstorming.notice"); } } else { if(isset($params['title']) && isset($params['content'])) { //编辑公告 $query = []; $query['title'] = $params['title']; $query['content'] = $params['content']; Messages::where('ID', $params['message_id'])->update($query); return redirect('/manage/super/brainstorming/notice/list'); } else { $data = Messages::where('ID', $params['message_id'])->where('status', 1)->first(); return view("superadmin.brainstorming.notice", ['data' => $data]); } } } } /** * 公告列表 * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function noticeList(Request $request){ $params = $request->all(); $keyword = isset($params['keyword'])?$params['keyword']:''; $page_size = empty($params['page_size']) ? 10 : $params['page_size']; if(empty($keyword)){ $sql = Messages::where('status', 1); } else { $sql = Messages::where('status', 1)->where('title', 'like', "%".$keyword."%"); } $data = $sql->orderByDesc('create_time')->paginate($page_size); //分页 $data->withPath("list?keyword=".$keyword); return view("superadmin.brainstorming.notice_list", ['data'=>$data]); } /** * 公告删除 * @param Request $request * @return string */ public function noticeDelete(Request $request){ $params = $request->all(); if(empty($params['message_id'])){ return Api::json(config('code.params_error'), trans('msg.params_error')); } $res = Messages::where('ID', $params['message_id'])->update(['status'=>0]); if($res){ return Api::json(config('code.success'), trans('msg.success')); } else { return Api::json(config('code.fail'), trans('msg.sql_error')); } } }