LuckyStreakController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <?php
  2. namespace App\Http\Controllers\Game;
  3. use App\Facade\TableName;
  4. use App\Game\GameCard;
  5. use App\Game\GlobalUserInfo;
  6. use App\Game\LogGamecardClick;
  7. use App\Game\Services\OuroGameService;
  8. use App\Game\Services\PlatformService;
  9. use App\Game\Services\ServerService;
  10. use App\Game\Services\LuckyStreakService;
  11. use App\Http\helper\NumConfig;
  12. use App\Models\AccountsInfo;
  13. use App\Notification\TelegramBot;
  14. use App\Util;
  15. use App\Utility\SetNXLock;
  16. use GuzzleHttp\Client;
  17. use GuzzleHttp\Exception\RequestException;
  18. use Illuminate\Http\Request;
  19. use Illuminate\Routing\Controller;
  20. use Illuminate\Support\Facades\DB;
  21. use Illuminate\Support\Facades\Redis;
  22. use Illuminate\Support\Facades\Log;
  23. class LuckyStreakController extends Controller
  24. {
  25. protected $client;
  26. protected $currency;
  27. protected $operatorId;
  28. protected $operatorName;
  29. protected $clientId;
  30. protected $clientSecret;
  31. protected $apiUrl;
  32. protected $luckyStreakService;
  33. private $hmacData=['path' => '',
  34. 'method' => '',
  35. 'timestamp' => '',
  36. 'nonce' => ''];
  37. public function __construct(LuckyStreakService $luckyStreakService)
  38. {
  39. $this->client = new Client();
  40. $this->currency = env('CONFIG_24680_CURRENCY');
  41. $this->operatorId = env('LUCKYSTREAK_OPERATOR_ID', '526');
  42. $this->operatorName = env('LUCKYSTREAK_OPERATOR_NAME', 'AEG');
  43. $this->clientId = env('LUCKYSTREAK_CLIENT_ID', 'AEG_operator');
  44. $this->clientSecret = env('LUCKYSTREAK_CLIENT_SECRET', 'X6vuibvYJI2Z9NglbzZE');
  45. $this->apiUrl = env('LUCKYSTREAK_API_URL', 'https://integ.livepbt.com');
  46. $this->luckyStreakService = $luckyStreakService;
  47. }
  48. /**
  49. * 验证请求的真实性
  50. *
  51. * @param Request $request
  52. * @return bool
  53. */
  54. private function verifyRequest(Request $request)
  55. {
  56. // 获取Authorization头
  57. $authHeader = $request->header('Authorization');
  58. // 如果没有Authorization头,拒绝请求
  59. if (empty($authHeader)) {
  60. Util::WriteLog('luckystreak_hmac', 'No Authorization header found');
  61. return true;
  62. }
  63. // 检查是否是Hawk认证格式
  64. if (strpos($authHeader, 'hawk ') !== 0) {
  65. Util::WriteLog('luckystreak_hmac', 'Not a Hawk authentication format');
  66. return false;
  67. }
  68. // 解析Hawk头信息
  69. $matches = [];
  70. preg_match('/id="([^"]+)"/', $authHeader, $matches);
  71. $id = $matches[1] ?? '';
  72. preg_match('/ts="([^"]+)"/', $authHeader, $matches);
  73. $timestamp = $matches[1] ?? '';
  74. preg_match('/nonce="([^"]+)"/', $authHeader, $matches);
  75. $nonce = $matches[1] ?? '';
  76. preg_match('/mac="([^"]+)"/', $authHeader, $matches);
  77. $mac = $matches[1] ?? '';
  78. preg_match('/hash="([^"]+)"/', $authHeader, $matches);
  79. $hash = $matches[1] ?? '';
  80. preg_match('/ext="([^"]+)"/', $authHeader, $matches);
  81. $ext = $matches[1] ?? '';
  82. // 如果缺少必要参数,拒绝请求
  83. if (empty($id) || empty($timestamp) || empty($nonce) || empty($mac)) {
  84. Util::WriteLog('luckystreak_hmac', 'Missing required Hawk parameters');
  85. return false;
  86. }
  87. // Util::WriteLog('luckystreak_hmac', $authHeader);
  88. // 获取请求方法和路径
  89. $method = $request->method();
  90. $path = '/'.$request->path();
  91. // 获取请求体
  92. $body = $request->getContent();
  93. // 构建验证数据
  94. $data = [
  95. 'path' => $path,
  96. 'method' => $method,
  97. 'timestamp' => $timestamp,
  98. 'nonce' => $nonce
  99. ];
  100. if (!empty($body)) {
  101. $data['body'] = $body;
  102. }
  103. if (!empty($ext)) {
  104. $data['ext'] = $ext;
  105. }
  106. if (!empty($hash)) {
  107. $data['hash'] = $hash;
  108. }
  109. $this->hmacData=$data;
  110. // 使用LuckyStreakService验证签名
  111. $isValid = $this->luckyStreakService->verifyHmacSignature($data, $mac);
  112. // Util::WriteLog('luckystreak_hmac', compact('isValid', 'data','hash','mac','ext'));
  113. return $isValid;
  114. }
  115. public function reponseHeader($request,$responseData,$status=200)
  116. {
  117. // 生成响应对象
  118. $response = response()->json($responseData,$status);
  119. // 获取响应内容
  120. $responseContent = json_encode($responseData);
  121. // 生成HMAC头
  122. $hmacHeaders = $this->luckyStreakService->generateHmacSignature($this->hmacData, $responseContent);
  123. // 添加HMAC头到响应
  124. foreach ($hmacHeaders as $header => $value) {
  125. $response->header($header, str_replace("\n", " ", $value));
  126. }
  127. return $response;
  128. }
  129. /**
  130. * 验证玩家身份
  131. *
  132. * @param Request $request
  133. * @return \Illuminate\Http\JsonResponse
  134. */
  135. public function validate(Request $request)
  136. {
  137. $requestData = $request->all();
  138. Util::WriteLog('luckystreak_validate', [$requestData,$request->header()]);
  139. // 验证请求的真实性
  140. if (!$this->verifyRequest($request)) {
  141. return response()->json([
  142. 'errors' => [
  143. ['code' => 'AUTH_001', 'message' => 'Unauthorized request']
  144. ]
  145. ], 401);
  146. }
  147. // 按照LuckyStreak API格式获取请求数据
  148. if (isset($requestData['data'])) {
  149. $data = $requestData['data'];
  150. } else {
  151. $data = $requestData;
  152. }
  153. $authCode = $data['AuthorizationCode'] ?? null;
  154. $operatorName = $data['OperatorName'] ?? $this->operatorName;
  155. if (!$authCode) {
  156. return $this->reponseHeader($request,[
  157. 'errors' => [
  158. ['code' => 'AUTH_002', 'message' => 'Authorization code is required']
  159. ]
  160. ], 400);
  161. }
  162. // 在这里我们用authCode作为用户名,因为LuckyStreak使用它来标识玩家
  163. $username = $authCode;
  164. if(!ServerService::IsLocalUser($username)) {
  165. $data=$this->luckyStreakService->callSubApi($username, $request);
  166. return $this->reponseHeader($request,$data);
  167. }
  168. // 尝试查找用户
  169. $user = GlobalUserInfo::getGameUserInfo('GlobalUID', $username);
  170. if (!$user) {
  171. return response()->json([
  172. 'errors' => [
  173. ['code' => 'AUTH_003', 'message' => 'Player not found']
  174. ]
  175. ], 404);
  176. }
  177. // 获取用户余额
  178. $balance = GlobalUserInfo::getScoreByUserID($user->UserID);
  179. // 获取当前时间,格式化为UTC格式
  180. $currentTimeUtc = gmdate('Y-m-d\TH:i:s.u\Z');
  181. // 准备响应数据
  182. $responseData = [
  183. 'data' => [
  184. 'userName' => $username,
  185. 'currency' => $this->currency,
  186. 'language' => GlobalUserInfo::getLocale() . 'US', // 例如:enUS, esUS等
  187. 'timeZone' => null,
  188. 'nickname' => strlen($user->NickName)<6?$user->NickName.$user->NickName:$user->NickName,
  189. 'balance' => $balance,
  190. 'type' => null,
  191. 'subOperator' => null,
  192. 'balanceTimestamp' => $currentTimeUtc,
  193. 'lastUpdateDate' => $currentTimeUtc,
  194. 'additionalFields' => null,
  195. 'errorMessage' => null,
  196. 'isError' => false
  197. ],
  198. 'errors' => null
  199. ];
  200. return $this->reponseHeader($request,$responseData);
  201. }
  202. /**
  203. * 获取玩家余额
  204. *
  205. * @param Request $request
  206. * @return \Illuminate\Http\JsonResponse
  207. */
  208. public function getBalance(Request $request)
  209. {
  210. $data = $request->all();
  211. Util::WriteLog('luckystreak_validate', [$data,$request->header()]);
  212. // 验证请求的真实性
  213. if (!$this->verifyRequest($request)) {
  214. return response()->json([
  215. 'errors' => [
  216. ['code' => 'AUTH_001', 'message' => 'Unauthorized request']
  217. ]
  218. ], 401);
  219. }
  220. $data=$data['data'];
  221. $username = $data['username'] ?? null;
  222. if (!$username) {
  223. return response()->json([
  224. 'errors' => [
  225. ['code' => 'AUTH_002', 'message' => 'Username is required']
  226. ]
  227. ], 400);
  228. }
  229. if(!ServerService::IsLocalUser($username)) {
  230. $data=$this->luckyStreakService->callSubApi($username, $request);
  231. return $this->reponseHeader($request,$data);
  232. }
  233. // 获取用户信息
  234. $user = GlobalUserInfo::getGameUserInfo('GlobalUID', $username);
  235. if (!$user) {
  236. return response()->json([
  237. 'errors' => [
  238. ['code' => 'AUTH_003', 'message' => 'Player not found']
  239. ]
  240. ], 404);
  241. }
  242. // 获取用户余额
  243. $balance = GlobalUserInfo::getScoreByUserID($user->UserID);
  244. // 准备响应数据
  245. $responseData = [
  246. 'data' => [
  247. 'errorCode' => 0,
  248. 'balance' => $balance,
  249. 'balanceTimestamp' => gmdate('Y-m-d\TH:i:s.u\Z'),
  250. 'currency' => $this->currency,
  251. 'refTransactionId' => $data['transactionRequestId'] ?? null,
  252. ]
  253. ];
  254. return $this->reponseHeader($request,$responseData);
  255. }
  256. /**
  257. * 处理资金移动请求(投注和赢取)
  258. *
  259. * @param Request $request
  260. * @return \Illuminate\Http\JsonResponse
  261. */
  262. public function moveFunds(Request $request)
  263. {
  264. $data = $request->all();
  265. Util::WriteLog('luckystreak_validate', $data);
  266. // 验证请求的真实性
  267. if (!$this->verifyRequest($request)) {
  268. return response()->json([
  269. 'errors' => [
  270. ['code' => 'AUTH_001', 'message' => 'Unauthorized request']
  271. ]
  272. ], 401);
  273. }
  274. $data=$data['data'];
  275. // 获取请求参数
  276. $username = $data['username'] ?? null;
  277. if(!ServerService::IsLocalUser($username)) {
  278. $data=$this->luckyStreakService->callSubApi($username, $request);
  279. return $this->reponseHeader($request,$data);
  280. }
  281. // 验证请求的真实性
  282. if ($data['operatorId']!=$this->operatorId||$data['currency']!=$this->currency) {
  283. return response()->json([
  284. 'errors' => [
  285. ['code' => 'AUTH_001', 'message' => 'Unauthorized request']
  286. ]
  287. ], 401);
  288. }
  289. $amount = isset($data['amount']) ? floatval($data['amount']) : 0;
  290. $transactionRequestId = $data['transactionRequestId'] ?? null;
  291. $direction = $data['direction'] ?? null; // Debit(投注) 或 Credit(赢取)
  292. $eventType = $data['eventType'] ?? null; // Bet, Win, Loss 等
  293. $gameId = $data['gameId'] ?? null;
  294. $gameType = $data['gameType'] ?? null;
  295. $roundId = $data['roundId'] ?? null;
  296. $eventId = $data['eventId'] ?? null;
  297. // 验证必须的参数
  298. if (!$username || !$transactionRequestId || !$direction || $amount === 0) {
  299. return response()->json([
  300. 'errors' => [
  301. ['code' => 'REQ_001', 'message' => 'Missing required parameters']
  302. ]
  303. ], 400);
  304. }
  305. // 获取用户信息
  306. $user = GlobalUserInfo::getGameUserInfo('GlobalUID', $username);
  307. if (!$user) {
  308. return response()->json([
  309. 'errors' => [
  310. ['code' => 'AUTH_003', 'message' => 'Player not found']
  311. ]
  312. ], 404);
  313. }
  314. $userId = $user->UserID;
  315. // 检查是否已经处理过这个交易
  316. $transactionKey = 'luckystreak_tx_' . $transactionRequestId;
  317. if (Redis::exists($transactionKey)) {
  318. // 交易已处理,返回上次的结果
  319. $previousResult = json_decode(Redis::get($transactionKey), true);
  320. // 生成响应对象,添加Hawk头
  321. return $this->reponseHeader($request,$previousResult);
  322. }
  323. // 获取当前余额
  324. $currentBalance = GlobalUserInfo::getScoreByUserID($userId)*NumConfig::NUM_VALUE;
  325. $amountInCents = intval($amount * NumConfig::NUM_VALUE);
  326. // 处理不同方向的资金移动
  327. if ($direction === 'Debit') {
  328. // 检查余额是否足够
  329. if ($currentBalance < $amountInCents) {
  330. $errorResponse = [
  331. 'errors' => [
  332. ['code' => 'ERR-FUND-001', 'message' => 'Insufficient funds']
  333. ]
  334. ];
  335. return $this->reponseHeader($request,$errorResponse,400);
  336. }
  337. // 获取独占锁确保事务安全
  338. $res = SetNXLock::getExclusiveLock('luckystreak_bet_' . $transactionRequestId, 86400);
  339. if (!$res) {
  340. // 已经处理过,返回之前的结果
  341. return $this->getBalance($request);
  342. }
  343. // 扣除余额
  344. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')
  345. ->where('UserID', $userId)
  346. ->decrement('Score', $amountInCents);
  347. // 记录下注
  348. PlatformService::platformBet('luckystreak', $gameId, $amountInCents, $userId);
  349. // 保存交易数据用于可能的取消
  350. Redis::set('luckystreak_bet_amount_' . $transactionRequestId, $gameId.'_'.$amountInCents);
  351. Redis::expire('luckystreak_bet_amount_' . $transactionRequestId, 86400);
  352. // 更新当前余额
  353. $currentBalance -= $amountInCents;
  354. } elseif ($direction === 'Credit') {
  355. // 获取独占锁确保事务安全
  356. $res = SetNXLock::getExclusiveLock('luckystreak_win_' . $transactionRequestId, 86400);
  357. if (!$res) {
  358. // 已经处理过,返回之前的结果
  359. return $this->getBalance($request);
  360. }
  361. // 原始下注金额,如果有的话
  362. $originalBetKey = 'luckystreak_bet_amount_' . $eventId;
  363. $originalBet = Redis::exists($originalBetKey) ? intval(Redis::get($originalBetKey)) : 0;
  364. // 增加余额
  365. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')
  366. ->where('UserID', $userId)
  367. ->increment('Score', $amountInCents);
  368. // 记录赢取
  369. PlatformService::platformWin(
  370. $userId,
  371. 'luckystreak',
  372. $gameId,
  373. $amountInCents,
  374. $originalBet,
  375. $currentBalance + $amountInCents
  376. );
  377. // 更新当前余额
  378. $currentBalance += $amountInCents;
  379. } else {
  380. $errorResponse = [
  381. 'errors' => [
  382. ['code' => 'DIR_001', 'message' => 'Invalid direction']
  383. ]
  384. ];
  385. return $this->reponseHeader($request,$errorResponse,400);
  386. }
  387. // 构造成功响应
  388. $responseData = [
  389. 'data' => [
  390. 'refTransactionId' => $transactionRequestId,
  391. 'balanceTimestamp' => gmdate('Y-m-d\TH:i:s.u\Z'),
  392. 'balance' => $currentBalance/NumConfig::NUM_VALUE,
  393. 'currency' => $this->currency
  394. ]
  395. ];
  396. // 缓存交易结果
  397. Redis::set($transactionKey, json_encode($responseData));
  398. Redis::expire($transactionKey, 86400);
  399. return $this->reponseHeader($request,$responseData);
  400. }
  401. /**
  402. * 处理资金移动中止请求
  403. *
  404. * @param Request $request
  405. * @return \Illuminate\Http\JsonResponse
  406. */
  407. public function abortMoveFunds(Request $request)
  408. {
  409. $data = $request->all();
  410. Util::WriteLog('luckystreak_validate', $data);
  411. // 验证请求的真实性
  412. if (!$this->verifyRequest($request)) {
  413. return response()->json([
  414. 'errors' => [
  415. ['code' => 'AUTH_001', 'message' => 'Unauthorized request']
  416. ]
  417. ], 401);
  418. }
  419. $data=$data['data'];
  420. // 获取请求参数
  421. $username = $data['username'] ?? null;
  422. if(!ServerService::IsLocalUser($username)) {
  423. $data=$this->luckyStreakService->callSubApi($username, $request);
  424. return $this->reponseHeader($request,$data);
  425. }
  426. $transactionRequestId = $data['transactionRequestId'] ?? null;
  427. $originalTransactionRequestId = $data['abortedTransactionRequestId'] ?? null;
  428. // 验证必须的参数
  429. if (!$username || !$transactionRequestId || !$originalTransactionRequestId) {
  430. $errorResponse = [
  431. 'errors' => [
  432. ['code' => 'REQ_001', 'message' => 'Missing required parameters']
  433. ]
  434. ];
  435. return $this->reponseHeader($request,$errorResponse,400);
  436. }
  437. // 获取用户信息
  438. $user = GlobalUserInfo::getGameUserInfo('GlobalUID', $username);
  439. if (!$user) {
  440. $errorResponse = [
  441. 'errors' => [
  442. ['code' => 'AUTH_003', 'message' => 'Player not found']
  443. ]
  444. ];
  445. return $this->reponseHeader($request,$errorResponse,404);
  446. }
  447. $userId = $user->UserID;
  448. // 检查是否已经处理过这个中止请求
  449. $abortKey = 'luckystreak_abort_' . $transactionRequestId;
  450. if (Redis::exists($abortKey)) {
  451. // 中止请求已处理,返回上次的结果
  452. $previousResult = json_decode(Redis::get($abortKey), true);
  453. return $this->reponseHeader($request,$previousResult);
  454. }
  455. // 获取原始交易金额
  456. $originalBetKey = 'luckystreak_bet_amount_' . $originalTransactionRequestId;
  457. if (!Redis::exists($originalBetKey)) {
  458. // 找不到原始交易,返回错误
  459. $errorResponse = [
  460. 'errors' => [
  461. ['code' => 'ABORT_001', 'message' => 'Original transaction not found']
  462. ]
  463. ];
  464. // 生成错误响应,添加Hawk头
  465. return $this->reponseHeader($request,$errorResponse,404);
  466. }
  467. $originalBetKey=Redis::get($originalBetKey);
  468. $originalBetKey=explode('_',$originalBetKey);
  469. $gameId = $originalBetKey[0];
  470. $originalAmount = intval($originalBetKey[1]);
  471. // 获取独占锁确保事务安全
  472. $res = SetNXLock::getExclusiveLock($abortKey, 86400);
  473. if (!$res) {
  474. // 已经处理过,返回之前的结果
  475. return $this->getBalance($request);
  476. }
  477. // 获取当前余额
  478. $currentBalance = GlobalUserInfo::getScoreByUserID($userId)*NumConfig::NUM_VALUE;
  479. // 退还金额
  480. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')
  481. ->where('UserID', $userId)
  482. ->increment('Score', $originalAmount);
  483. // 记录取消交易
  484. PlatformService::platformBet('luckystreak', $gameId, -$originalAmount,$userId);
  485. // 更新当前余额
  486. $currentBalance += $originalAmount;
  487. // 构造成功响应
  488. $responseData = [
  489. 'data' => [
  490. 'refTransactionId' => $transactionRequestId,
  491. 'balance' => $currentBalance / NumConfig::NUM_VALUE,
  492. 'currency' => $this->currency
  493. ]
  494. ];
  495. // 缓存中止请求结果
  496. Redis::set($abortKey, json_encode($responseData));
  497. Redis::expire($abortKey, 86400);
  498. return $this->reponseHeader($request,$responseData);
  499. }
  500. /**
  501. * 游戏启动页面
  502. *
  503. * @param Request $request
  504. * @return \Illuminate\Http\JsonResponse
  505. */
  506. public function gameLunch(Request $request)
  507. {
  508. // 获取请求参数
  509. $gid = $request->input('gid');
  510. $user = $request->user();
  511. $userId = $user->UserID;
  512. $globalUID = $user->GlobalUID;
  513. // 检查用户渠道权限 (如果需要)
  514. if ($user->Channel != 99 && $user->Channel != 44) {
  515. http_response_code(404);
  516. exit();
  517. }
  518. // 找到游戏卡片
  519. GameCard::$enableStateCheck = false;
  520. // 记录游戏点击
  521. $gamecard = GameCard::where('gid', $gid)->where('brand', 'LuckyStreak')->first();
  522. $gamecard->increment('play_num', 1);
  523. LogGamecardClick::recordClick($gamecard->id, $userId);
  524. // 检查用户当前游戏状态
  525. $inGameId = OuroGameService::getUserInGame($userId, $globalUID);
  526. if ($inGameId != intval($gamecard->id)) {
  527. Util::WriteLog('24680game', compact('inGameId', 'gamecard', 'user'));
  528. }
  529. // 获取用户语言
  530. $lang = GlobalUserInfo::getLocale();
  531. $supportedLangs = ['en', 'da', 'de', 'es', 'fi', 'fr', 'it', 'pt', 'ru', 'zh','ar','ur'];
  532. if (!in_array($lang, $supportedLangs)) {
  533. $lang = 'en';
  534. }
  535. // 关闭加载动画
  536. echo "<script>
  537. parent.postMessage({cmd:\"closeLoading\"},\"*\");
  538. </script>";
  539. // 设置缓存控制头
  540. header("Cache-Control: no-cache, no-store, must-revalidate");
  541. header("Expires: 0");
  542. try {
  543. // 使用服务获取游戏启动URL
  544. $htmlContent = $this->luckyStreakService->getLaunchURLHTML($gid, $globalUID, $request->ip(), $lang);
  545. echo $htmlContent;
  546. exit();
  547. } catch (\Exception $e) {
  548. Util::WriteLog('luckystreak_error', $e->getMessage());
  549. echo "<script>alert('System error: " . $e->getMessage() . "');</script>";
  550. exit();
  551. }
  552. }
  553. /**
  554. * 获取游戏列表
  555. *
  556. * @param Request $request
  557. * @return \Illuminate\Http\JsonResponse
  558. */
  559. public function gameList(Request $request)
  560. {
  561. try {
  562. // 使用服务获取游戏列表
  563. $result = $this->luckyStreakService->getGamesList();
  564. return response()->json($result);
  565. } catch (\Exception $e) {
  566. Util::WriteLog('luckystreak_error', $e->getMessage());
  567. return response()->json([
  568. 'error' => $e->getMessage()
  569. ], 500);
  570. }
  571. }
  572. /**
  573. * 获取游戏列表
  574. *
  575. * @param Request $request
  576. * @return \Illuminate\Http\JsonResponse
  577. */
  578. public function jackpot(Request $request)
  579. {
  580. try {
  581. // 使用服务获取游戏列表
  582. $result = $this->luckyStreakService->getJackpot();
  583. return response()->json($result);
  584. } catch (\Exception $e) {
  585. Util::WriteLog('luckystreak_error', $e->getMessage());
  586. return response()->json([
  587. 'error' => $e->getMessage()
  588. ], 500);
  589. }
  590. }
  591. /**
  592. * 获取第三方游戏提供商游戏列表
  593. *
  594. * @param Request $request
  595. * @return \Illuminate\Http\JsonResponse
  596. */
  597. public function providerGameList(Request $request)
  598. {
  599. dd($this->luckyStreakService->getCachedAuthToken());
  600. try {
  601. // 使用服务获取提供商游戏列表
  602. $result = $this->luckyStreakService->getProviderGamesList();
  603. return response()->json($result);
  604. } catch (\Exception $e) {
  605. Util::WriteLog('luckystreak_provider_error', $e->getMessage());
  606. return response()->json([
  607. 'error' => $e->getMessage()
  608. ], 500);
  609. }
  610. }
  611. }