| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <?php
- namespace App\Http\Controllers\Game;
- use App\Game\GameCard;
- use App\Game\GlobalUserInfo;
- use App\Game\LogGamecardClick;
- use App\Game\Services\OuroGameService;
- use App\Models\AccountsInfo;
- use App\Notification\TelegramBot;
- use App\Util;
- use Illuminate\Http\Request;
- use Illuminate\Routing\Controller;
- use Illuminate\Support\Facades\Redis;
- class HacksawController extends Controller
- {
- /** gid => version(与 CDN 静态资源目录一致) */
- private static $gameVersions = [
- '1632' => '1.34.2', // Speed Crash
- '1624' => '1.43.2', // Limbo
- '1590' => '1.30.0', // Dice
- '1446' => '1.59.1', // Baccarat
- '1416' => '1.30.1', // Twenty-One
- '1386' => '1.36.2', // Colors
- '1380' => '1.34.1', // Blocks
- '1321' => '1.41.0', // Wheel
- '1334' => '1.41.1', // Lines
- '1148' => '1.27.3', // Coins
- '1294' => '1.88.1', // Plinko
- '1328' => '1.43.0', // Hi-Lo
- '1126' => '1.135.0', // Mines
- '1154' => '1.68.1', // Boxes
- '1042' => '1.47.0',
- '1043' => '1.44.16',
- '1048' => '1.58.1',
- '1049' => '1.50.4',
- '1055' => '1.60.1',
- '1058' => '1.42.2',
- '1059' => '1.66.3',
- '1066' => '1.43.0',
- '1067' => '1.70.2',
- '1069' => '1.56.3',
- '1070' => '1.32.0',
- '1071' => '1.50.1',
- '1081' => '1.32.0',
- '1083' => '1.52.2',
- '1084' => '1.64.0',
- '1087' => '1.44.3',
- '1091' => '1.36.3',
- '1093' => '1.41.5',
- '1096' => '1.16.1',
- '1099' => '1.23.1',
- '1102' => '1.35.2',
- '1117' => '1.29.0',
- '1127' => '1.33.5',
- '1131' => '1.34.2',
- '1135' => '1.45.2',
- '1140' => '1.28.2',
- '1144' => '1.46.2',
- '1160' => '1.48.0',
- '1164' => '1.75.1',
- '1168' => '1.43.0',
- '1172' => '1.48.1',
- '1176' => '1.39.1',
- '1181' => '1.74.1',
- '1185' => '1.11.2',
- '1189' => '1.14.3',
- '1193' => '1.50.5',
- '1197' => '1.31.2',
- '1201' => '1.40.3',
- '1205' => '1.21.2',
- '1209' => '1.29.0',
- '1213' => '1.39.1',
- '1217' => '1.35.3',
- '1221' => '1.21.1',
- '1225' => '1.46.2',
- '1229' => '1.25.1',
- '1233' => '1.33.2',
- '1237' => '1.20.2',
- '1243' => '1.29.1',
- '1247' => '1.47.1',
- '1251' => '1.21.0',
- '1259' => '1.21.4',
- '1263' => '1.15.2',
- '1267' => '1.10.3',
- '1271' => '1.14.0',
- '1275' => '1.21.3',
- '1279' => '1.22.7',
- '1305' => '1.22.4',
- '1309' => '1.22.0',
- '1314' => '1.19.1',
- '1340' => '1.14.2',
- '1344' => '1.16.6',
- '1348' => '1.25.0',
- '1352' => '1.23.1',
- '1356' => '1.26.0',
- '1360' => '1.18.0',
- '1364' => '1.16.1',
- '1372' => '1.17.4',
- '1392' => '1.29.2',
- '1396' => '1.19.0',
- '1400' => '1.33.0',
- '1404' => '1.18.6',
- '1408' => '1.58.1',
- '1422' => '1.47.3',
- '1426' => '1.37.0',
- '1430' => '1.10.3',
- '1434' => '1.28.5',
- '1438' => '1.31.0',
- '1442' => '1.26.1',
- '1452' => '1.63.2',
- '1456' => '1.30.0',
- '1460' => '1.17.0',
- '1474' => '1.15.0',
- '1478' => '1.23.5',
- '1482' => '1.43.2',
- '1490' => '1.24.3',
- '1494' => '1.19.1',
- '1508' => '1.31.0',
- '1514' => '1.16.3',
- '1530' => '1.35.5',
- '1534' => '1.37.1',
- '1554' => '1.10.5',
- '1558' => '1.28.1',
- '1562' => '1.46.0',
- '1570' => '1.17.1',
- '1580' => '1.32.2',
- '1584' => '1.28.7',
- '1602' => '1.45.0',
- '1608' => '1.39.1',
- '1612' => '1.24.5',
- '1616' => '1.27.7',
- '1620' => '1.37.0',
- '1689' => '1.31.0',
- ];
- /**
- * Hacksaw 子游戏载入入口
- * 请求: /game/hacksaw/lunch?gid=1632
- */
- public function gameLunch(Request $request)
- {
- $gid = (string) $request->input('gid');
- $user = $request->user();
- $userid = $user->UserID;
- $version = self::$gameVersions[$gid] ?? null;
- if ($version === null) {
- abort(404, 'Hacksaw game version not configured for gid: ' . $gid);
- }
- GameCard::$enableStateCheck = false;
- $gamecard = GameCard::where('gid', $gid)->where('brand', 'Hacksaw')->first();
- if (!$gamecard) {
- abort(404, 'Game not found');
- }
- $in_gameid = OuroGameService::getUserInGame($userid, $user->GlobalUID);
- if ($in_gameid != intval($gamecard->id)) {
- Util::WriteLog('24680game', compact('in_gameid', 'gamecard', 'user'));
- }
- $gamecard->increment('play_num', 1);
- LogGamecardClick::recordClick($gamecard->id, $userid);
- $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';
- }
- $configurls = json_decode(env('CONFIG_GAMES'), true);
- $configurl = $configurls['hacksaw'] ?? $configurls['hkg'] ?? null;
- if (!$configurl) {
- $staticHost = 'static.pgn-nmu2nd.com';
- $apiHost = 'api.pgn-nmu2nd.com';
- } else {
- $staticHost = $configurl['source'] ?? 'static.pgn-nmu2nd.com';
- $apiHost = $configurl['api'] ?? 'api.pgn-nmu2nd.com';
- }
- $cdnserver = 'https://' . $staticHost;
- $apiBase = 'https://' . $apiHost . '/api';
- $lobbyurl = $cdnserver;
- // $sign = GlobalUserInfo::genGuuidSign($user);
- $newToken = base64_encode(random_bytes(20));
- $Currency = env("CONFIG_24680_CURRENCY", "BRL");
- $CurrencySymbol = env("CONFIG_24680_DOLLAR", "R$");
- $data['currency'] = $Currency;
- $data['dollar'] = $CurrencySymbol;
- $data['limit_room']=0;
- $account = AccountsInfo::where('UserID', $userid)->first();
- if(!$account){
- TelegramBot::getDefault()->sendMsgWithEnv("hawksaw_ fail11111:" . json_encode([$request->all(),$data]) );
- abort(404, 'User not found');
- }else{
- $account=$account->toArray();
- }
- $data = array_merge($data, $account);
- Redis::setex($newToken, 7200, json_encode($data));
- $params = [
- 'language' => $lang,
- 'channel' => 'mobile',
- 'gameid' => $gid,
- 'mode' => 2,
- 'token' => $newToken,
- 'lobbyurl' => $lobbyurl,
- 'currency' => env('CONFIG_24680_CURRENCY', 'EUR'),
- 'partner' => 'demo',
- 'env' => $apiBase,
- 'realmoneyenv' => $apiBase,
- ];
- $url = $cdnserver . '/' . $gid . '/' . $version . '/index.html?' . http_build_query($params);
- return "<script>
- parent.postMessage({cmd:\"closeLoading\"},\"*\");
- location.href='$url';
- </script>";
- }
- }
|