public function actionLeague() { $leagueModel = new LeagueModel(); $res = $leagueModel->findByMaster('7c7fbc5309', 1); if ($res[0]->double_loop) { var_dump($res[0]->double_loop); exit; } else { var_dump($res[0]->double_loop); echo 'ww'; exit; } }
/** * @desc 判断该联赛是否已分组 * @return bool */ public static function isGrouped() { $masterId = self::getUserId(); $leagueModel = new LeagueModel(); $res = $leagueModel->findByMaster($masterId, 1); if (isset($res[0]->grouped) && $res[0]->grouped == true) { return true; } else { return false; } }
/** * @desc 修复android严重比赛结果后没保存TeamScore的问题 */ public function actionTestSaveTeamScore() { $masterId = CommonFunction::getUserId(); $gameId = "b404c1fc88"; $homeTeamScore = "8"; $opponentTeamScore = "0"; $leagueModel = new LeagueModel(); $res = $leagueModel->findByMaster($masterId, 1); if (empty($res)) { throw new CHttpException(500, '该用户无权限管理联赛'); } $leagueId = $res[0]->objectId; $gameModel = new TournamentModel(); $userModel = new UserModel(); $gameArr = $gameModel->findByObjectId($gameId); if (isset($gameArr[0])) { $game = $gameArr[0]; if (isset($game->home_court->captain->objectId)) { $homeTeamCaptainId = $game->home_court->captain->objectId; $homeTeamCaptain = $userModel->getByObjectId($homeTeamCaptainId); if (!empty($homeTeamCaptain)) { if (isset($homeTeamCaptain->username) && !empty($homeTeamCaptain->username)) { $homeTeamCaptainUsername = $homeTeamCaptain->username; } } } if (isset($game->opponent->captain->objectId)) { $opponentTeamCaptainId = $game->opponent->captain->objectId; $opponentTeamCaptain = $userModel->getByObjectId($opponentTeamCaptainId); } } // var_dump($game);exit; $res = ''; try { // $res = $gameModel->updateScore($gameId,$homeTeamScore,$opponentTeamScore); } catch (Exception $e) { //echo $e; } if (true) { if (isset($gameArr[0])) { $game = $gameArr[0]; $teamScoreModel = new TeamScoreModel(); if (isset($game->home_court->objectId)) { $homeTeamId = $game->home_court->objectId; if (isset($game->home_court->name)) { $homeTeamName = $game->home_court->name; } $diffScore = $homeTeamScore - $opponentTeamScore; $win = false; $draw = false; $loss = false; $score = 0; if ($diffScore > 0) { $win = true; $score = 3; } elseif ($diffScore == 0) { $draw = true; $score = 1; } elseif ($diffScore < 0) { $loss = true; } $homeTeamBasic = array('league' => array("__type" => "Pointer", "className" => "League", "objectId" => $leagueId), 'competition' => array("__type" => "Pointer", "className" => "Tournament", "objectId" => $gameId), 'team' => array("__type" => "Pointer", "className" => "Team", "objectId" => $homeTeamId), 'name' => $homeTeamName); $homeTeamDev = array('goals' => $homeTeamScore, 'goals_against' => $opponentTeamScore, 'goal_difference' => $diffScore, 'win' => $win, 'draw' => $draw, 'loss' => $loss, 'score' => $score); $hasData = $teamScoreModel->findByCompetitionTeam($gameId, $homeTeamId); if (!isset($hasData[0]->objectId)) { $homeTeamData = array_merge($homeTeamBasic, $homeTeamDev); $teamScoreModel->save($homeTeamData); } else { $teamScoreId = $hasData[0]->objectId; $teamScoreModel->update($teamScoreId, $homeTeamDev); } } if (isset($game->opponent->objectId)) { $opponentTeamId = $game->opponent->objectId; if (isset($game->opponent->name)) { $opponentTeamName = $game->opponent->name; } $diffScore = $opponentTeamScore - $homeTeamScore; $win2 = false; $draw2 = false; $loss2 = false; $score2 = 0; if ($diffScore > 0) { $win2 = true; $score2 = 3; } elseif ($diffScore == 0) { $draw2 = true; $score2 = 1; } elseif ($diffScore < 0) { $loss2 = true; } $opponentTeamBasic = array('league' => array("__type" => "Pointer", "className" => "League", "objectId" => $leagueId), 'competition' => array("__type" => "Pointer", "className" => "Tournament", "objectId" => $gameId), 'team' => array("__type" => "Pointer", "className" => "Team", "objectId" => $opponentTeamId), 'name' => $opponentTeamName); $opponentTeamDev = array('goals' => $opponentTeamScore, 'goals_against' => $homeTeamScore, 'goal_difference' => $diffScore, 'win' => $win2, 'draw' => $draw2, 'loss' => $loss2, 'score' => $score2); $hasData2 = $teamScoreModel->findByCompetitionTeam($gameId, $opponentTeamId); if (!isset($hasData2[0]->objectId)) { $opponentTeamData = array_merge($opponentTeamBasic, $opponentTeamDev); $teamScoreModel->save($opponentTeamData); } else { $teamScoreId2 = $hasData2[0]->objectId; $teamScoreModel->update($teamScoreId2, $opponentTeamDev); } } } $response = 'success'; } else { $response = 'fail'; } }
/** * @desc 邀请球队 */ public function actionInviteTeam() { isset(Yii::app()->user->oid) ? $masterId = Yii::app()->user->oid : ($masterId = ''); $teamName = Yii::app()->request->getPost('teamname'); $mobileNum = Yii::app()->request->getPost('mobilenum'); if (empty($teamName) || empty($mobileNum) || !CommonFunction::checkMobile($mobileNum)) { CommonFunction::ajaxResult(State::$TEAM_SENDMSG_ERROR_CODE, State::$TEAM_SENDMSG_ERROR_MSG); } $leagueModel = new LeagueModel(); $resM = $leagueModel->findByMaster($masterId, 1); $leagueId = $resM[0]->objectId; $leagueName = $resM[0]->name; $inviteCode = $resM[0]->inviteCode; $msgUrl = Yii::app()->params['inviteMsgUrl']; if (preg_match("/^0?(13[0-9]|15[0-9]|17[678]|18[0-9]|14[57])[0-9]{8}\$/i", $mobileNum)) { // $data = array( // 'account'=>Yii::app()->params['MsgUsername'], // 'password'=>Yii::app()->params['MsgPwd'], // 'destMobiles'=> $mobileNum, // 'msgContents'=>'诚邀你的球队:'.$teamName.',加入联赛:'.$leagueName.',邀请码是:'.$leagueId.'【踢球吧】' // ); // $msgBack = CommonFunction::sendMobileMsg($msgUrl,$data); $data = array('mobile' => $mobileNum, 'content' => '诚邀你的球队:' . $teamName . ',加入联赛:' . $leagueName . ', 联赛邀请码是:' . $inviteCode); $mobileMsgModel = new BmobMobileMsg(); $msgBack = $mobileMsgModel->send($data); } else { CommonFunction::ajaxResult(State::$TEAM_SENDMSG_ERROR_CODE, State::$TEAM_SENDMSG_ERROR_MSG); } // echo $msgBack;exit; // $msgBack = 1; if (!is_numeric($msgBack) || $msgBack > 0) { $msgBack = 1; } CommonFunction::ajaxResult(State::$SUSSION_CODE, State::$SUSSION_MSG, array('response' => $msgBack)); }
/** * 给邀请球赛的队长发送邀请推送 * @param unknown_type $leagueId 联赛的id * @param unknown_type $teamId 球队的id * @param unknown_type $captain 队长的object */ public function sendInviteMessageForTeamCaptain($leagueId, $teamId, $captain) { $targetId = $leagueId . "&" . $teamId; $leagueModel = new LeagueModel(); $res = $leagueModel->get($leagueId); if (empty($res)) { throw new CHttpException(500, '获取联赛信息失败'); } $leagueName = $res->name; $this->push($captain, $leagueName, "你的球队已被邀请参加联赛", 4, 12, array("targetId" => $targetId)); }