Ejemplo n.º 1
0
 /**
  * @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));
 }