ppSoftService = $ppSoftService; $this->currency=env('CONFIG_24680_CURRENCY',$this->currency); } public function backLobby() { echo ""; } public function gameLunch(Request $request) { $gid=$request->input('gid'); $user = $request->user(); $userid=$user->UserID; GameCard::$enableStateCheck=false; $gamecard=GameCard::where('gid',$gid)->first(); $in_gameid=OuroGameService::getUserInGame($userid,$user->GlobalUID); if($in_gameid!=intval($gamecard->id)){ Util::WriteLog('24680game',compact('in_gameid','gamecard','user')); // die; } $lang=GlobalUserInfo::getLocale(); $supportLang = ['en','da','de','es','fi','fr','id','it','ja','ko','nl','no','pl','pt','ro','ru','sv','th','tr','vi','zh','my']; if(!in_array($lang,$supportLang)){ $lang = 'en'; } $rs = $this->ppSoftService->getLaunchURL($gid,$user->GlobalUID,$user->UserID,$this->currency,$lang); if(@$rs['gameURL']){ $gamecard=GameCard::where('gid',$gid)->where('brand','PP')->first(); $gamecard->increment('play_num',1); //$this->logGameClick($gamecard->id,$userid); LogGamecardClick::recordClick($gamecard->id,$userid); echo ""; exit(); }else{ echo ""; exit(); } } public function gameLogin(Request $request) { $gid = $request->input('gid','vs20olympx'); $guid = $request->input('guid','0685128230-b53b-eb1a-0004688302'); $uid = $request->input('uid','4688302'); $lang=GlobalUserInfo::getLocale(); $supportLang = ['en','da','de','es','fi','fr','id','it','ja','ko','nl','no','pl','pt','ro','ru','sv','th','tr','vi','zh','my']; if(!in_array($lang,$supportLang)){ $lang = 'en'; } $rs = $this->ppSoftService->getLaunchURL($gid,$guid,$uid,$this->currency,$lang); echo ""; // var_dump($rs); } public function gameList() { $response = $this->ppSoftService->getCasinoGames(); $gameList = $response['gameList']; foreach ($gameList as &$game) { unset($game['jurisdictions']); } return response()->json($gameList); } public function gameLobbyList() { $response = $this->ppSoftService->getLobbyGames(); return response()->json($response); } public function authenticate(Request $request){ $post = $request->all(); Util::WriteLog('pp_authenticate',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $token = $post['token']; $user = GlobalUserInfo::getGameUserInfo('GlobalUID', $token); if (!$user) return response()->json(['error' => 2,'description' => 'Player not found ']); $response = [ 'userId' => $user->UserID, 'currency' => $this->currency, 'cash' => GlobalUserInfo::getScoreByUserID($user->UserID), 'bonus' => 0, 'error' => 0, 'description' => 'Success' ]; return response()->json($response); } public function balance(Request $request) { $post = $request->all(); Util::WriteLog('pp_balance',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $response = [ 'currency' => $this->currency, 'cash' => GlobalUserInfo::getScoreByUserID($post['userId']), 'bonus' => 0, 'error' => 0, 'description' => 'Success' ]; return response()->json($response); } public function bet(Request $request) { $post = $request->all(); Util::WriteLog('pp_bet',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $UserID = $post['userId']; $transactionId = $post['reference']; $score = GlobalUserInfo::getScoreByUserID($UserID); $res = SetNXLock::getExclusiveLock('pp_bet'.$transactionId, 600); if (!$res) { Util::WriteLog('pp_bet_repeat',$post); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' => $score,'bonus' => 0,'usedPromo' => 0,'error' => 0,'description' => 'Success']; } if(round($post['amount'],2)>round($score,2)){ return response()->json(['error' => 1,'description' => 'Insufficient balance']); } $bet = intval($post['amount']*100); DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->decrement('Score', $bet); PlatformService::platformBet('PP',$post['gameId'],$bet,$UserID); $betKey = 'pp_bet_amount_'.$transactionId; Redis::set($betKey,$bet); Redis::expire($betKey,600); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' =>round($score-$post['amount'],2),'bonus' => 0,'usedPromo' => 0,'error' => 0,'description' => 'Success']; } public function result(Request $request) { $post = $request->all(); Util::WriteLog('pp_result',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $UserID = $post['userId']; $transactionId = $post['reference']; $score = GlobalUserInfo::getScoreByUserID($UserID); $res = SetNXLock::getExclusiveLock('pp_result'.$transactionId, 600); if (!$res) { Util::WriteLog('pp_win_repeat',$post); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' => $score,'bonus' => 0,'error' => 0,'description' => 'Success']; } $betKey = 'pp_bet_amount_'.$transactionId; $bet = Redis::get($betKey)?:0; Redis::del($betKey); $win = $post['amount']; if(isset($post['promoWinAmount'])){ if($post['promoWinAmount']>0){ $win = round($post['promoWinAmount']+$post['amount'],2); } } PlatformService::platformWin($UserID,'PP',$post['gameId'],intval($win*100),$bet,intval($score+$win)*100); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' =>round($score+$win,2),'bonus' => 0,'error' => 0,'description' => 'Success']; } public function bonusWin(Request $request) { $post = $request->all(); Util::WriteLog('pp_bonusWin',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $UserID = $post['userId']; $transactionId = $post['reference']; $score = GlobalUserInfo::getScoreByUserID($UserID); // $res = SetNXLock::getExclusiveLock('pp_bonusWin'.$transactionId, 600); // if (!$res) { // Util::WriteLog('pp_bonusWin_repeat',$post); // return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' => $score,'bonus' => 0,'error' => 0,'description' => 'Success']; // } // // PlatformService::platformWin($UserID,'PP','bonusWin',intval($post['amount']*100),0,intval($score+$post['amount'])*100); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' =>round($score,2),'bonus' => 0,'error' => 0,'description' => 'Success']; } public function jackpotWin(Request $request) { $post = $request->all(); Util::WriteLog('pp_jackpotWin',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $UserID = $post['userId']; $transactionId = $post['reference']; $score = GlobalUserInfo::getScoreByUserID($UserID); $res = SetNXLock::getExclusiveLock('pp_jackpotWin'.$transactionId, 600); if (!$res) { Util::WriteLog('pp_jackpotWin_repeat',$post); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' => $score,'bonus' => 0,'error' => 0,'description' => 'Success']; } PlatformService::platformWin($UserID,'PP',@$post['gameId'],intval($post['amount']*100),0,intval($score+$post['amount'])*100); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' =>round($score+$post['amount'],2),'bonus' => 0,'error' => 0,'description' => 'Success']; } public function refund(Request $request) { $post = $request->all(); Util::WriteLog('pp_refund',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $transactionId = $post['reference']; $UserID = $post['userId']; $betKey = 'pp_bet_amount_'.$transactionId; $bet = Redis::get($betKey)?:0; if($bet){ Redis::del($betKey); DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->increment('Score', $bet); } return ['transactionId' => $transactionId,'error' => 0,'description' => 'Success']; } public function promoWin(Request $request) { $post = $request->all(); Util::WriteLog('pp_promoWin',$post); if(!$this->ppSoftService->checkHash($post)){ return response()->json(['error' => 5,'description' => 'Invalid hash code']); } $UserID = $post['userId']; $transactionId = $post['reference']; $score = GlobalUserInfo::getScoreByUserID($UserID); $res = SetNXLock::getExclusiveLock('pp_promoWin'.$transactionId, 600); if (!$res) { Util::WriteLog('pp_promoWin_repeat',$post); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' => $score,'bonus' => 0,'error' => 0,'description' => 'Success']; } PlatformService::platformWin($UserID,'PP',@$post['gameId'],intval($post['amount']*NumConfig::NUM_VALUE),0,intval($score+$post['amount'])*NumConfig::NUM_VALUE); return ['transactionId' => $transactionId,'currency' => $this->currency,'cash' =>round($score+$post['amount'],2),'bonus' => 0,'error' => 0,'description' => 'Success']; } }