get("dd_corp_id"); $corpId = 0; if(!empty($ddCorpId)){ $corp = Corp::where("dd_corp_id",$ddCorpId)->first(); if($corp){ $corpId = $corp->corp_id; } }else{ $corpId = $request->get("corp_id"); } if(empty($corpId)){ $corpId = empty(Cookie::get("oauth_corp_id"))? 0:Cookie::get("oauth_corp_id"); } $status = $request->get("status","running"); $redisKey = "bs_corp:".$status.":".$corpId; //$redisValue = Redis::get($redisKey); $redisValue = ""; if(empty($redisValue)){ $curTime = time(); $where = " and A.corp_id={$corpId} and A.status=1 and is_complete_set=1"; switch ($status) { case "upcoming": $where .= " and A.start_time>".$curTime; break; case "finish": $where .= " and A.end_time<".$curTime; break; default: $where .= " and (A.start_time<$curTime and A.end_time>$curTime)"; break; } $data = []; $activitys = DB::select("select A.activity_id,A.title,B.share_home_desc,A.start_time,A.end_time,B.top_banner from agh_activitys as A,bs_configs as B where A.activity_id=B.activity_id ".$where." limit 0,100"); foreach ($activitys as $activity){ $userCount = User::where("activity_id",$activity->activity_id)->where("status",1)->count(); $data[] = [ "activity_id" => $activity->activity_id, "title" => $activity->title, "desc" => $activity->share_home_desc, "start_time" => $activity->start_time*1000, "end_time" => $activity->end_time*1000, "top_banner" => $activity->top_banner, "url" => env("WEB_URL")."?activity_id=".$activity->activity_id, "user_count" => $userCount ]; } Redis::setex($redisKey,300,json_encode($data)); }else{ $data = json_decode($redisValue,true); } return response()->json([ "error" => 0, "message" => "OK", "data" => $data ]); }catch (\Exception $exception){ Log::info($exception->getTraceAsString()); return response()->json([ "error" => 0, "message" => "OK", "data" => [] ]); } } /** * 我加入的活动 * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function joinActivity(Request $request){ try{ $openId = $request->get("openid"); $ddCorpId = $request->get("dd_corp_id"); $corpId = 0; if(!empty($ddCorpId)){ $corp = Corp::where("dd_corp_id",$ddCorpId)->first(); if($corp){ $corpId = $corp->corp_id; } }else{ $corpId = $request->get("corp_id"); } $data = []; if($openId){ $redisKey = "bs_corp:activitys:".$openId; //$redisValue = Redis::get($redisKey); $redisValue = ""; if(empty($redisValue)){ $where = " and B.open_id='$openId' and A.corp_id='$corpId' and A.status=1"; $activitys = DB::select("select A.activity_id,A.title,C.share_home_desc,A.start_time,A.end_time from agh_activitys as A,bs_users as B,bs_configs as C where A.activity_id=C.activity_id and A.activity_id=B.activity_id ".$where." limit 0,100"); foreach ($activitys as $activity){ $activityRedis = BrainstormingService::getInstance()->get($activity->activity_id); $userCount = User::where("activity_id",$activity->activity_id)->where("status",1)->count(); $data[] = [ "activity_id" => $activity->activity_id, "title" => $activity->title, "desc" => $activity->share_home_desc, "start_time" => $activity->start_time*1000, "end_time" => $activity->end_time*1000, "top_banner" => $activityRedis["top_banner"], "url" => env("WEB_URL")."?activity_id=".$activity->activity_id, "user_count" => $userCount ]; } Redis::setex($redisKey,300,json_encode($data)); }else{ $data = json_decode($redisValue,true); } } return response()->json([ "error" => 0, "message" => "OK", "data" => $data ]); }catch (\Exception $exception){ Log::info($exception->getTraceAsString()); return response()->json([ "error" => 0, "message" => "OK", "data" => [] ]); } } }