ApiController.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Facade\TableName;
  4. use App\Http\Controllers\Controller;
  5. use App\Http\helper\HttpCurl;
  6. use App\Http\helper\NumConfig;
  7. use App\IpLocation;
  8. use App\Jobs\Order;
  9. use App\Models\AccountsInfo;
  10. use App\Models\Cpf;
  11. use App\Models\PrivateMail;
  12. use App\Models\RecordScoreInfo;
  13. use App\Models\SystemStatusInfo;
  14. use App\Notification\TelegramBot;
  15. use App\Services\Custom;
  16. use App\Services\Goopago;
  17. use App\Services\IpCheck;
  18. use App\Services\OrderServices;
  19. use App\Services\StoredProcedure;
  20. use App\Util;
  21. use App\Utility\SetNXLock;
  22. use Illuminate\Http\Request;
  23. use Illuminate\Support\Facades\DB;
  24. use Illuminate\Support\Facades\Redis;
  25. use Log;
  26. // use Yansongda\Pay\Log;
  27. class ApiController extends Controller
  28. {
  29. public function sendTele(Request $request)
  30. {
  31. TelegramBot::getDefault()->sendMsg($request->str);
  32. }
  33. public function log(Request $request){
  34. Util::WriteLog("log",$request->all());
  35. }
  36. public function weblog(Request $request){
  37. Util::WriteLog("weblog",$request->all());
  38. return "OK";
  39. }
  40. public function sendfbevent(Request $request){
  41. Util::WriteLog("sendfbevent",$request->all());
  42. return "OK";
  43. }
  44. public function sendggevent(Request $request){
  45. Util::WriteLog("sendggevent",$request->all());
  46. return "OK";
  47. }
  48. public function inith5client(Request $request){
  49. Util::WriteLog("inith5client",$request->all());
  50. return "OK";
  51. }
  52. public function pushSubscribe(Request $request)
  53. {
  54. //{"fingerprint":"","userid":0,"subscibe_info":"{\"endpoint\":\"https://fcm.googleapis.com/fcm/send/eg7A5CJ_pyA:APA91bEZYZd92knXEH-qRzinP6H7kguaVDwmAvDjCFgwCPW-BMKOraXaQxBf5ONP5vMJu0jmZLOn0_f0wONxlmTOu3yBVmBlkQBFY4XrDofNhGJwnVxKbNh3sxWFqvptmCo97St9ZPSe\",\"expirationTime\":null,\"keys\":{\"p256dh\":\"BB8s_jUbX-0UPuy3aGLLxYbbNNdA0aEu7awsmK-Bxe0ZLX5lPItWHpRHVtTfxQnXDwVflEhbG6qnUSBLQxiLduA\",\"auth\":\"UnYCllcPM7nMmjj4XLXxZQ\"}}","channel":"100","web_site":"https://dev.winus777.com/pwa/landingpage2?pixel=2775919695949438&campaign=%7B%7Bcampaign.name%7D%7D+%28%7B%7Bcampaign.id%7D%7D%29&adgroup=%7B%7Badset.name%7D%7D+%28%7B%7Badset.id%7D%7D%29&creative=%7B%7Bad.name%7D%7D+%28%7B%7Bad.id%7D%7D%29&fbclid=","platform":"Android","installed":0}
  55. // {"publicKey":"BEKE0qlrGMp-XyUHppeFMscDiJg-sL98jr4b51glbvicHnD69oNZ9JiLHKIQ9_3K0ImSZlo0Ggw-RE3FxYOUwJo","privateKey":"VPFE6_2QL-pFHENBuhbp2WH-8DeBbK92WIwZg6BPJtc"}
  56. try {
  57. $fpid = $request->input('fingerprint');
  58. $userid = $request->input('userid');
  59. $subscibe_info = $request->input('subscibe_info');
  60. $channel = $request->input('channel');
  61. $web_site = $request->input('web_site');
  62. $platform = $request->input('platform');
  63. $installed = $request->input('installed', 0);
  64. // 验证必填字段
  65. if (empty($fpid) || empty($subscibe_info)) {
  66. return apiReturnFail(__('messages.api.common.missing_info'));
  67. }
  68. // 解析订阅信息
  69. if (is_string($subscibe_info)) {
  70. $subscibe_info = json_decode($subscibe_info, true);
  71. if (json_last_error() !== JSON_ERROR_NONE) {
  72. return apiReturnFail('Invalid subscription info format');
  73. }
  74. }
  75. // 提取endpoint作为唯一标识
  76. $endpoint = $subscibe_info['endpoint'] ?? '';
  77. if (empty($endpoint)) {
  78. return apiReturnFail('Missing endpoint in subscription info');
  79. }
  80. // 检查是否已存在该订阅
  81. $existing = DB::table('QPAccountsDB.dbo.WebPushSubscriptions')
  82. ->where('Endpoint', $endpoint)
  83. ->first();
  84. $data = [
  85. 'FPID' => $fpid,
  86. 'UserID' => $userid ?? 0,
  87. 'SubscriptionInfo' => json_encode($subscibe_info),
  88. 'Endpoint' => $endpoint,
  89. 'Channel' => $channel ?? '',
  90. 'WebSite' => $web_site ?? '',
  91. 'Platform' => $platform ?? 'Other',
  92. 'Installed' => $installed,
  93. 'Status' => 1, // 1=激活, 0=禁用
  94. 'UpdatedAt' => date('Y-m-d H:i:s')
  95. ];
  96. if ($existing) {
  97. // 更新现有订阅
  98. DB::table('QPAccountsDB.dbo.WebPushSubscriptions')
  99. ->where('ID', $existing->ID)
  100. ->update($data);
  101. return apiReturnSuc(['message' => 'Subscription updated', 'id' => $existing->ID]);
  102. } else {
  103. // 创建新订阅
  104. $data['CreatedAt'] = date('Y-m-d H:i:s');
  105. $id = DB::table('QPAccountsDB.dbo.WebPushSubscriptions')->insertGetId($data);
  106. return apiReturnSuc(['message' => 'Subscription created', 'id' => $id]);
  107. }
  108. } catch (\Exception $e) {
  109. Log::error('Push subscribe error: ' . $e->getMessage(), [
  110. 'request' => $request->all(),
  111. 'trace' => $e->getTraceAsString()
  112. ]);
  113. return apiReturnFail('Subscription failed: ' . $e->getMessage());
  114. }
  115. }
  116. /**
  117. * 上传订阅状态
  118. * 记录用户对Web Push订阅的响应结果
  119. */
  120. public function uploadSubscribeState(Request $request)
  121. {
  122. try {
  123. $userid = $request->input('userid', 0);
  124. $result = $request->input('result'); // 1=接受, 2=未接受, 3=不支持, 4=拒绝
  125. $machineserial = $request->input('machineserial'); // FPID
  126. $ish5 = $request->input('ish5', 0); // 0=app(w2a), 1=h5(pwa)
  127. $p_source = $request->input('p_source'); // channel
  128. // 验证必填字段
  129. if (empty($machineserial) || !in_array($result, [1, 2, 3, 4])) {
  130. return apiReturnFail(__('messages.api.common.missing_info'));
  131. }
  132. // 状态映射
  133. $statusMap = [
  134. 1 => 'accepted', // 接受
  135. 2 => 'not_accepted', // 未接受
  136. 3 => 'not_supported', // 不支持
  137. 4 => 'denied' // 拒绝
  138. ];
  139. $status = $statusMap[$result] ?? 'unknown';
  140. // 检查是否已存在记录
  141. $existing = DB::table('QPAccountsDB.dbo.WebPushSubscribeStates')
  142. ->where('FPID', $machineserial)
  143. ->where('UserID', $userid)
  144. ->orderBy('ID', 'desc')
  145. ->first();
  146. $data = [
  147. 'UserID' => $userid,
  148. 'FPID' => $machineserial,
  149. 'Result' => $result,
  150. 'Status' => $status,
  151. 'IsH5' => $ish5,
  152. 'Channel' => $p_source ?? '',
  153. 'UserAgent' => substr($request->header('user-agent') ?? '', 0, 500),
  154. 'ClientIP' => $request->ip(),
  155. 'UpdatedAt' => date('Y-m-d H:i:s')
  156. ];
  157. if ($existing) {
  158. // 如果状态没有变化,只更新时间
  159. if ($existing->Result == $result) {
  160. DB::table('QPAccountsDB.dbo.WebPushSubscribeStates')
  161. ->where('ID', $existing->ID)
  162. ->update(['UpdatedAt' => date('Y-m-d H:i:s')]);
  163. return apiReturnSuc(['message' => 'State updated', 'id' => $existing->ID]);
  164. }
  165. }
  166. // 插入新记录
  167. $data['CreatedAt'] = date('Y-m-d H:i:s');
  168. $id = DB::table('QPAccountsDB.dbo.WebPushSubscribeStates')->insertGetId($data);
  169. return apiReturnSuc(['message' => 'State recorded', 'id' => $id, 'status' => $status]);
  170. } catch (\Exception $e) {
  171. Log::error('Upload subscribe state error: ' . $e->getMessage(), [
  172. 'request' => $request->all(),
  173. 'trace' => $e->getTraceAsString()
  174. ]);
  175. return apiReturnFail('Upload state failed: ' . $e->getMessage());
  176. }
  177. }
  178. public function checkLocale(Request $request){
  179. $UserID=$request->input("UserID");
  180. $user=AccountsInfo::where("UserID",$UserID)->first();
  181. if(!$user){
  182. return apiReturnFail(['web.error.user_not_exist',__('messages.api.user.user_not_exist')]);
  183. }
  184. $Locale=$user->BindLocale;
  185. return apiReturnSuc(compact('UserID','Locale'));
  186. }
  187. public function bindLocale(Request $request){
  188. $UserID=$request->input("UserID");
  189. $Locale=$request->input("Locale");
  190. $user=AccountsInfo::where("UserID",$UserID)->first();
  191. if(!is_string($Locale))$Locale='en';
  192. if(!$user){
  193. return apiReturnFail(['web.error.user_not_exist',__('messages.api.user.user_not_exist')]);
  194. }
  195. if(strstr(env('VALID_LOCALE','pt,en,es'),$Locale)){
  196. return apiReturnFail(['web.error.Locale_not_found',__('messages.api.user.locale_not_supported')]);
  197. }
  198. AccountsInfo::where("UserID",$UserID)->update(["BindLocale"=>$Locale]);
  199. return apiReturnSuc(compact('UserID','Locale'));
  200. }
  201. public function checkCountry(Request $request){
  202. $UserID=$request->input("UserID");
  203. $user=AccountsInfo::where("UserID",$UserID)->first();
  204. if(!$user){
  205. return apiReturnFail(['web.error.user_not_exist',__('messages.api.user.user_not_exist')]);
  206. }
  207. $Country=$user->BindCountry;
  208. return apiReturnSuc(compact('UserID','Country'));
  209. }
  210. public function bindCountry(Request $request){
  211. $UserID=$request->input("UserID");
  212. $Country=$request->input("Country");
  213. $user=AccountsInfo::where("UserID",$UserID)->first();
  214. if(!is_string($Country))$Country='CO';
  215. if(!$user){
  216. return apiReturnFail(['web.error.user_not_exist',__('messages.api.user.user_not_exist')]);
  217. }
  218. // if(!empty($user->BindCountry)&&$user->BindCountry!=$Country){
  219. // return apiReturnFail(['web.error.user_already_bind',__('messages.api.user.user_already_bind')]);
  220. // }
  221. if(!isset(IpCheck::$countries[$Country])){
  222. return apiReturnFail(['web.error.country_not_found',__('messages.api.user.country_not_found')]);
  223. }
  224. AccountsInfo::where("UserID",$UserID)->update(["BindCountry"=>$Country]);
  225. return apiReturnSuc(compact('UserID','Country'));
  226. }
  227. public function errorReport(Request $request){
  228. Util::WriteLog('clientError',$request->header());
  229. try {
  230. $config = $request->input('config');
  231. $sign = $request->input('s');
  232. if (md5($config . 'nicaia') == $sign) {
  233. $exception = $request->input('exception');
  234. $config = $request->input('config');
  235. $uid = $request->input('uid');
  236. $hash = md5($exception);
  237. $config = substr($config, 0, 3000);
  238. $userinfo = ['ErrorID' => 0, 'IP' => $request->ip(), 'UserID' => $uid, 'Config' => $config, 'Lang' => $request->header('accept-language') ?? '', 'UserAgent' => substr($request->header('user-agent') ?? '', 0, 200)];
  239. $exception = \GuzzleHttp\json_decode($exception, true);
  240. $config = \GuzzleHttp\json_decode($config, true);
  241. $config['firstUseIpList'] = array_slice($config['firstUseIpList'], 0, 1);
  242. $userinfo['Config'] = json_encode($config);
  243. $exception = ['HashKey' => $hash, 'Msg' => urldecode($exception[2]), 'Stack' => urldecode($exception[3]), 'Package' => $config['AppId'] . '_' . $config['ClientVersion'], 'Channel' => Util::getPackageByURL($config['AppId'])['channel']];
  244. $package = $exception['Package'];
  245. $error = DB::table("QPRecordDB.dbo.ClientError")->where(["HashKey" => $hash, 'Package' => $package])->first();
  246. if (!$error) {
  247. $userinfo['ErrorID'] = DB::table("QPRecordDB.dbo.ClientError")->insertGetId($exception);
  248. } else {
  249. $userinfo['ErrorID'] = $error->ID;
  250. if ($error->DateKey != date("Y-m-d") && $error->Sign == 0) {
  251. $userinfo['ErrorID'] = DB::table("QPRecordDB.dbo.ClientError")->insertGetId($exception);
  252. } else {
  253. DB::table("QPRecordDB.dbo.ClientError")->where('ID', $error->ID)->update(['Times' => $error->Times + 1]);
  254. }
  255. }
  256. $exuser = DB::table("QPRecordDB.dbo.ClientErrorUsers")->where(['ErrorID' => $userinfo['ErrorID'], 'UserID' => $userinfo['UserID'], 'DateKey' => date("Y-m-d")])->first();
  257. if ($exuser && isset($exuser->ID)) {
  258. DB::table("QPRecordDB.dbo.ClientErrorUsers")->where('ID', $exuser->ID)->update(['Times' => $exuser->Times + 1]);
  259. } else {
  260. // DB::table("QPRecordDB.dbo.ClientErrorUsers")->insert($userinfo);
  261. }
  262. if ($hash == 'ca512f200c7060491b76af73d12c8952') {
  263. return apiReturnSuc(['script' => 'jsb.fileUtils.removeDirectory(jsb.fileUtils.getWritablePath());setTimeout(()=>cc.game.restart(), 500);']);
  264. }
  265. // Util::WriteLog('clientError',$request->header());
  266. return apiReturnSuc([]);
  267. }
  268. }catch (\Exception $exception){
  269. return apiReturnSuc([]);
  270. }
  271. }
  272. public function maintain(){
  273. return apiReturnSuc(['ret' =>['state' => 0 ,'content' => __('messages.api.common.maintenance_in_progress')]]);
  274. }
  275. //评论过
  276. public function rateUs(Request $request){
  277. $pack=$request->input("PackageName");
  278. $v=$request->input("v");
  279. $UserID=$request->input("UserID");
  280. $cv=1;
  281. if(isset($request->cv)){
  282. $cvstr=explode('.',$request->cv);
  283. $cv=array_pop($cvstr);
  284. }
  285. DB::table("QPRecordDB.dbo.AccountsRateUsRecord")->insert(['UserID'=>$UserID,'Package'=>$pack."_$v"."_$cv"]);
  286. }
  287. //设置分销
  288. public function setCommission(Request $request)
  289. {
  290. $user_id = $request->input('user_id');
  291. $commission = $request->input('commission');
  292. $result = Subordinate::setCommission(['user_id' => $user_id, 'commission' => $commission]);
  293. return $result;
  294. }
  295. //用户留言
  296. public function userMessageAdd(Request $request)
  297. {
  298. $params = $request->all();
  299. if (empty($params['GameID'])) {
  300. return ['status' => false, 'msg' => __('messages.api.common.user_info_not_obtained')];
  301. }
  302. $insert['GameID'] = $params['GameID'];
  303. $insert['PID'] = 0;
  304. $url = $request->url() . '?message=' . $params['message'];
  305. $url = urldecode($url);
  306. $query = parse_url($url)['query'];
  307. $paramsArr = explode('&', $query);
  308. foreach ($paramsArr as $k => $v) {
  309. $a = explode('=', $v);
  310. $arr[$a[0]] = $a[1];
  311. }
  312. if (empty($arr['message']) || !isset($arr['message'])) {
  313. return ['status' => false, 'msg' => __('messages.api.common.fill_message')];
  314. }
  315. $insert['Msg'] = $arr['message'];
  316. if (mb_strlen($insert['Msg']) > 300) {
  317. return apiReturnFail(__('messages.api.common.characters_too_long'));
  318. }
  319. $insert['CreateAt'] = date('Y-m-d H:i:s');
  320. $insert['Type'] = 0;
  321. $result = DB::table('QPAccountsDB.dbo.Message')
  322. ->insert($insert);
  323. if ($result) {
  324. return ['status' => true, 'msg' => __('messages.api.message.leave_success'), 'code' => 200];
  325. } else {
  326. return ['status' => false, 'msg' => __('messages.api.message.leave_fail'), 'code' => 301];
  327. }
  328. }
  329. //获取留言
  330. public function userMessageList(Request $request)
  331. {
  332. $game_id = $request->input('GameID');
  333. if ($game_id == 0) {
  334. return ['status' => true, 'msg' => __('messages.api.message.get_success'), 'data' => []];
  335. }
  336. $ids = DB::connection('read')->table('QPAccountsDB.dbo.Message')
  337. ->where('GameID', $game_id)
  338. ->pluck('ID');
  339. $data = DB::connection('read')->table('QPAccountsDB.dbo.Message')
  340. ->whereIn('PID', $ids)
  341. ->orwhere('GameID', $game_id)
  342. ->orderBy('CreateAt', 'desc')
  343. ->get()->toArray();
  344. $data = array_reverse($data);
  345. foreach ($data as &$val) {
  346. $val->CreateAt = date('Y-m-d H:i:s', strtotime($val->CreateAt));
  347. }
  348. $ids = $ids->toArray();
  349. // 消息改已读
  350. DB::connection('write')->table('QPAccountsDB.dbo.Message')
  351. ->whereIn('PID', $ids)
  352. ->update(['is_read' => 1]);
  353. $r = DB::connection('write')->table('QPAccountsDB.dbo.Message')->where('GameID', $game_id)->update(['is_read' => 1]);
  354. // foreach ($ids as $v) {
  355. // DB::table('QPAccountsDB.dbo.Message')->where('PID', $v)->update(['is_read' => 1]);
  356. // }
  357. if ($data) {
  358. return ['status' => true, 'msg' => __('messages.api.message.get_success'), 'data' => $data];
  359. } else {
  360. return ['status' => false, 'msg' => __('messages.api.message.no_chat_record'), 'data' => []];
  361. }
  362. }
  363. // 获取用户未读消息总数
  364. public function wait_read(Request $request)
  365. {
  366. $GameID = (int)$request->GameID ?: '';
  367. if (empty($GameID)) {
  368. return apiReturnSuc();
  369. }
  370. $ids = DB::connection('read')->table('QPAccountsDB.dbo.Message')
  371. ->where('GameID', $GameID)
  372. ->pluck('ID');
  373. $count = DB::connection('read')->table('QPAccountsDB.dbo.Message as a')
  374. ->join('QPAccountsDB.dbo.Message as b', function ($query) use ($GameID) {
  375. $query->on('a.ID', 'b.ID')->orwhere('b.GameID', $GameID)->where('b.is_read', 0);
  376. })
  377. ->whereIn('a.PID', $ids)
  378. ->where('a.is_read', 0)
  379. ->count();
  380. return apiReturnSuc($count);
  381. }
  382. public function getServiceList(){
  383. $key='customer_service_n';
  384. if(Redis::exists($key)) {
  385. $list=json_decode(Redis::get($key));
  386. }
  387. if(!isset($list)||empty($list)){
  388. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  389. ->where('StatusName', 'Email')
  390. ->orWhere('StatusName', 'WhatsApp')
  391. ->orWhere('StatusName', 'Telegram')
  392. ->get();
  393. $WhatsApp_ID = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  394. ->where('StatusName', 'WhatsApp_ID')
  395. ->first();
  396. $chat = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  397. ->where('StatusName', 'Telegram')
  398. ->first();
  399. foreach ($list as &$value) {
  400. if ($value->StatusName == 'WhatsApp') {
  401. $value->StatusValue = $WhatsApp_ID->StatusString;
  402. }
  403. if ($value->StatusName == 'Telegram') {
  404. $value->StatusValue = $chat->StatusString;
  405. // if (rand(1, 100) > 50) {
  406. // $value->StatusValue = '';
  407. // }
  408. }
  409. }
  410. Redis::set($key,json_encode($list));
  411. Redis::expire($key, 600);
  412. }
  413. $packinfo=Util::getPackageByURL();
  414. if($packinfo&&isset($packinfo['channel'])) {
  415. $channel = $packinfo['channel'];
  416. }else{
  417. $channel=100;
  418. }
  419. $rand_value=-1;
  420. foreach ($list as &$value) {
  421. if ($value->StatusName == 'WhatsApp') {
  422. if(strstr($value->StatusValue,"{")) {
  423. $value->StatusValue = json_decode($value->StatusValue, true);
  424. if(isset($value->StatusValue[$channel])){
  425. $value->StatusValue=$value->StatusValue[$channel];
  426. }else{
  427. $value->StatusValue=$value->StatusValue['default'];
  428. }
  429. //一个渠道下多个
  430. if(strstr($value->StatusValue,',')) {
  431. $arr=explode(',',$value->StatusValue);
  432. if($rand_value==-1)$rand_value=array_rand($arr);
  433. $value->StatusValue=$arr[$rand_value];
  434. }
  435. }
  436. if(strstr($value->StatusString,'{')) {
  437. $value->StatusString = json_decode($value->StatusString, true);
  438. if(isset($value->StatusString[$channel])){
  439. $value->StatusString=$value->StatusString[$channel];
  440. }else{
  441. $value->StatusString=$value->StatusString['default'];
  442. }
  443. //一个渠道下多个
  444. if(strstr($value->StatusString,',')) {
  445. $arr=explode(',',$value->StatusString);
  446. if($rand_value==-1)$rand_value=array_rand($arr);
  447. $value->StatusString=$arr[$rand_value];
  448. }
  449. //替换+和补?
  450. $d=$value->StatusString;
  451. if(strstr($d,'+')){
  452. $d=str_replace('+','',$d);
  453. }
  454. if(!strstr($d,'?')){
  455. $d.='?';
  456. }
  457. $value->StatusString=$d;
  458. }
  459. }
  460. }
  461. return $list;
  462. }
  463. private function getServiceListHigh(){
  464. $key='high_customer_service';
  465. if(Redis::exists($key)) {
  466. $list=json_decode(Redis::get($key));
  467. }
  468. if(!isset($list)||empty($list)){
  469. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  470. ->where('StatusName', 'Email')
  471. ->orWhere('StatusName', 'WhatsApp')
  472. ->orWhere('StatusName', 'OnlineChat')
  473. ->get();
  474. $WhatsApp_ID = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  475. ->where('StatusName', 'WhatsApp_ID')
  476. ->first();
  477. $chat = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  478. ->where('StatusName', 'OnlineChat')
  479. ->first();
  480. foreach ($list as &$value) {
  481. if ($value->StatusName == 'WhatsApp') {
  482. $value->StatusValue = $WhatsApp_ID->StatusString;
  483. }
  484. if ($value->StatusName == 'OnlineChat') {
  485. $value->StatusValue = $chat->StatusString;
  486. if (rand(1, 100) > 50) {
  487. $value->StatusValue = '';
  488. }
  489. }
  490. }
  491. Redis::set($key,json_encode($list));
  492. Redis::expire($key, 600);
  493. }
  494. $packinfo=Util::getPackageByURL();
  495. if($packinfo&&isset($packinfo['channel'])) {
  496. $channel = $packinfo['channel'];
  497. }else{
  498. $channel=100;
  499. }
  500. $rand_value=-1;
  501. foreach ($list as &$value) {
  502. if ($value->StatusName == 'WhatsApp') {
  503. if(strstr($value->StatusValue,"{")) {
  504. $value->StatusValue = json_decode($value->StatusValue, true);
  505. if(isset($value->StatusValue[$channel])){
  506. $value->StatusValue=$value->StatusValue[$channel];
  507. }else{
  508. $value->StatusValue=$value->StatusValue['default'];
  509. }
  510. //一个渠道下多个
  511. if(strstr($value->StatusValue,',')) {
  512. $arr=explode(',',$value->StatusValue);
  513. if($rand_value==-1)$rand_value=array_rand($arr);
  514. $value->StatusValue=$arr[$rand_value];
  515. }
  516. }
  517. if(strstr($value->StatusString,'{')) {
  518. $value->StatusString = json_decode($value->StatusString, true);
  519. if(isset($value->StatusString[$channel])){
  520. $value->StatusString=$value->StatusString[$channel];
  521. }else{
  522. $value->StatusString=$value->StatusString['default'];
  523. }
  524. //一个渠道下多个
  525. if(strstr($value->StatusString,',')) {
  526. $arr=explode(',',$value->StatusString);
  527. if($rand_value==-1)$rand_value=array_rand($arr);
  528. $value->StatusString=$arr[$rand_value];
  529. }
  530. }
  531. }
  532. }
  533. return $list;
  534. }
  535. // 客服功能
  536. public function customer_service()
  537. {
  538. $list=$this->getServiceList();
  539. $result = apiReturnSuc($list);
  540. // $dir = $path = app()->basePath() . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'cache';
  541. // if (!file_exists($dir)) {
  542. // mkdir($dir, 0777);
  543. // }
  544. // $path = $dir . DIRECTORY_SEPARATOR . "customer_service.json";
  545. // file_put_contents($path, json_encode($result));
  546. return $result;
  547. }
  548. // 渠道审核屏蔽ID白名单
  549. public function channel_shield_id_white(Request $request)
  550. {
  551. $GameID = $request->GameID ?: '';
  552. if (empty($GameID)) {
  553. return apiReturnFail(__('messages.api.common.missing_user_id'));
  554. }
  555. $State = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  556. ->where('StatusName', 'ChannelShieldIDWhite')
  557. ->first();
  558. if ($State->StatusValue == 2) {
  559. return apiReturnFail();
  560. }
  561. $first = DB::connection('write')->table('QPPlatformDB.dbo.ChannelShieldIDWhite')
  562. ->where('GameID', $GameID)
  563. ->where('State', 1)
  564. ->first();
  565. if ($first) {
  566. return apiReturnSuc();
  567. }
  568. return apiReturnFail();
  569. }
  570. public function getLoginIpMap($package){
  571. $key="getLoginIpMap_$package";
  572. try {
  573. if (Redis::exists($key)) {
  574. $arrs = json_decode(Redis::get($key), true);
  575. }
  576. }catch (\Exception $e){}
  577. if(!isset($arrs)){
  578. $pack = Util::getPackageByURL($package);
  579. $channel = 100;
  580. if (isset($pack) && $pack['bundleid'] == $package) {
  581. $channel = $pack['channel'];
  582. }
  583. // SELECT FROM LoginIPMap WITH(nolock) WHERE Channel=@Channel AND Status=1
  584. if (!DB::table("QPPlatformDB.dbo.LoginIPMap")->where("Channel", $channel)->exists()) $channel = 100;
  585. $arrs = DB::table("QPPlatformDB.dbo.LoginIPMap")
  586. ->select("ID", "LoginAddr", "LoginPort")
  587. ->where("Channel", $channel)
  588. ->orderBy("ID")
  589. ->get()->toArray();
  590. Redis::set($key,json_encode($arrs));
  591. Redis::expire($key,60);
  592. }
  593. return $arrs;
  594. }
  595. // 返回登录IP
  596. public function LoginIPMap(Request $request)
  597. {
  598. $PackageName = (string)$request->get('PackageName');
  599. // $list = StoredProcedure::getLoginIPMap($PackageName);
  600. $list = $this->getLoginIpMap($PackageName);
  601. $result = $request->ip();
  602. return apiReturnSuc($list, $result);
  603. }
  604. public function LoginIP_Hand($ip_check_key,Request $request){
  605. $data=$this->LoginIPData($request);
  606. $ndata=[
  607. $ip_check_key.'_list' => $data['list'],
  608. // $ip_check_key.'_login_ip' => $data['login_ip'],
  609. $ip_check_key.'_ouro_init' => $data['ouro_init']??"",
  610. $ip_check_key=>$data['ip_check'],
  611. ];
  612. return base64_encode(json_encode(apiReturnSuc($ndata)));
  613. }
  614. public function LoginIP_Mask($ip_check_key,Request $request){
  615. $code=base64_decode($request->get("code"));
  616. $data=$this->LoginIPData($request,json_decode($code,true));
  617. $ndata=[
  618. $ip_check_key.'_list' => $data['list'],
  619. // $ip_check_key.'_login_ip' => $data['login_ip'],
  620. $ip_check_key.'_init' => $data['ouro_init']??"",
  621. $ip_check_key=>$data['ip_check'],
  622. ];
  623. // dd($ndata);
  624. return base64_encode(json_encode(apiReturnSuc($ndata)));
  625. }
  626. public function LoginIP_NMask($checkkey,$ip_check_key,Request $request){
  627. $ck2package=[
  628. 'check'=>'gold.ruby777.play',
  629. 'version'=>'com.legends777.game.slots'
  630. ];
  631. $chatport=[
  632. 'check'=>8340,
  633. 'version'=>8340
  634. ];
  635. $api=[
  636. 'check'=>'api',
  637. 'version'=>'api'
  638. ];
  639. $PackageName = $request->get('PackageName')??"";
  640. if(empty($PackageName)&&!isset($ck2package[$checkkey]))return;
  641. $ver=$request->ver??$request->cv;
  642. $cvstr = explode('.', $ver);
  643. $cv = array_pop($cvstr);//js客户端版本
  644. $v = array_pop($cvstr);//android code
  645. $requestInfo=[
  646. 'PackageName'=>$PackageName??$ck2package[$checkkey],
  647. 'v'=>$v
  648. ];
  649. $data=$this->LoginIPData($request,$requestInfo);
  650. // dd($data);
  651. $ndata=[
  652. $ip_check_key=>$data['ip_check'],
  653. $ip_check_key.'1' => $data['list'],
  654. // $ip_check_key.'_login_ip' => $data['login_ip'],
  655. $ip_check_key.'2' => $data['ouro_init']??"",
  656. $ip_check_key.'3' => $data['base_url']??"",
  657. $ip_check_key.'4' => ChannelController::searchChannel($requestInfo['PackageName'],$cv),
  658. $ip_check_key.'5' => $checkkey=="version"?GetVersionController::getVersion():GetVersionController::getVersionRuby(),
  659. $ip_check_key.'6' => 'http://'.$_SERVER["HTTP_HOST"].'/'.$api[$checkkey].'/game_api/billboard',
  660. $ip_check_key.'7' => $data['customer']??"",
  661. $ip_check_key.'8' => $data['cdn']??"",
  662. $ip_check_key.'9' => $chatport[$checkkey],
  663. ];
  664. // dd($ndata);
  665. return str_replace('Y','%',base64_encode(json_encode(apiReturnSuc($ndata))));
  666. }
  667. private function LoginIPData(Request $request,$otherData=[]){
  668. $PackageName = strval($request->get('PackageName')??$otherData['PackageName']??"");
  669. if(empty($PackageName))return;
  670. $v = $request->get('v')??0;
  671. if(!$v&&isset($otherData['v']))$v=$otherData['v'];
  672. $v=intval($v);
  673. $cv=Util::getClientVer();
  674. $service = new IpCheck();
  675. // $list = StoredProcedure::getLoginIPMap($PackageName);
  676. $list = $this->getLoginIpMap($PackageName);
  677. // $login_ip = $request->ip();
  678. $login_ip = IpLocation::getIP();
  679. $rip=IpLocation::getRealIp();
  680. $ip=IpLocation::getIP();
  681. if($login_ip!=$rip||$login_ip!=$ip){
  682. TelegramBot::getDefault()->sendMsgWithEnv(json_encode(['login_ip'=>$login_ip,'rip'=>$rip,'ip'=>$ip]));
  683. }
  684. $ipcheck=$service->ipCheck($login_ip,$PackageName,$v);
  685. $needfake=0;
  686. if(strstr($PackageName,'com.ouro777.ares')){
  687. if(!$ipcheck)$needfake=1;
  688. $ipcheck='BR';
  689. }
  690. $data = [
  691. 'list' => $ipcheck?$list:[$list[0]],
  692. 'login_ip' => $login_ip,
  693. 'ip_check' => $ipcheck?true:false,
  694. 'ip_black'=>false,
  695. 'customer'=>'',
  696. 'chatport'=>0,
  697. 'org'=>true,
  698. ];
  699. // 'showRateUs'=>1,//发起评分
  700. if(!$ipcheck){
  701. $data = [
  702. 'list' => $ipcheck?$list:[$list[0]],
  703. 'login_ip' => '',
  704. 'ip_check' => $ipcheck?true:false,
  705. 'ip_black'=>false,
  706. ];
  707. }else{
  708. $data['gamesorts']=ChannelController::searchChannel($PackageName,$cv);
  709. $data['gameversions']=GetVersionController::getVersion();
  710. $data['webgamerooms']=GameApiController::webGameRooms();
  711. $data['show_billboard']='http://'.$request->getHttpHost().'/api/game_api/billboard';
  712. $data['customer']=$this->getServiceList();
  713. $data['wss_server']='wss://'.env('CONFIG_OURO_WSS').':';
  714. $data['chatport']=8340;
  715. $data['vip_config']=RechargeController::getVipConfig();
  716. $packinfo=DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
  717. ->where('PackageName', $PackageName)->select("AdjustConfig","Version")->first();
  718. $data['adjust']=$packinfo->AdjustConfig??0;
  719. $data['spv']=$packinfo->Version??0;
  720. //PK支付在paychanel显示手机号确认
  721. $data['show_phone_confirm']=0;
  722. $data['g']=$needfake;
  723. $data['base_url']=env('APP_URL').'/';
  724. $data['gear_act']=false;
  725. $data['free_relief']=1;
  726. $data['runhorse_value']=1;
  727. if($login_ip=='116.87.197.194'){
  728. // $data['gear_act']=env('BASE_CDN').'glo/pakistan/assets/act/deposit.png';
  729. }
  730. $data['share_rich']=env('SHARE_MAIN_TITLE','<bold><color=#FFCC00>PK3</c><color=#ffffff>.BET</color></bold>');
  731. $data['kefu_switch']=0;
  732. $data['upgrade_bonus'] = SystemStatusInfo::OnlyGetCacheValue('BindPhoneReward') ?? 100;
  733. $VALID_COUNTRY=explode(',',env('VALID_COUNTRY','BR'));
  734. if(count($VALID_COUNTRY)) {
  735. $data['valid_countries'] = array_filter(IpCheck::$countries,function ($v) use($VALID_COUNTRY){return in_array($v,$VALID_COUNTRY);},ARRAY_FILTER_USE_KEY);
  736. // $data['valid_countries'] = ['CO' => IpCheck::$countries['CO'], 'PE' => IpCheck::$countries['PE']];
  737. }
  738. if(env('MULTI_COUNTRY',0)==1) {
  739. $data['loc'] = $ipcheck;
  740. }else{
  741. $data['loc'] = env('VALID_COUNTRY');
  742. }
  743. }
  744. $data['init_games']=[Util::$KIND_ID_FRUIT9X,Util::$KIND_ID_HALLOWEEN];
  745. switch (env('VALID_COUNTRY','BR')){
  746. case 'PK':
  747. {
  748. $data['init_games'] = [Util::$KIND_ID_FRUIT9X, Util::$KIND_ID_OLYMPUS, Util::$KIND_ID_AVIATOR2, Util::$KIND_ID_MINES, Util::$KIND_ID_LHD];
  749. break;
  750. }
  751. case 'BD':
  752. {
  753. $data['init_games'] = [Util::$KIND_ID_FRUIT9X, Util::$KIND_ID_OLYMPUS, Util::$KIND_ID_AVIATOR2, Util::$KIND_ID_MINES, Util::$KIND_ID_LHD];
  754. break;
  755. }
  756. }
  757. if(in_array($PackageName,['com.ssme2.ttt','com.bigwinappstore.spain','com.ssme.test'])){
  758. if($ipcheck){
  759. $data['ouro_init'] = "truco_init_bx";
  760. }else{
  761. $data['ouro_init'] = "";
  762. }
  763. }
  764. if(in_array($PackageName,['com.silamedia.chocolaterecipe','com.fantasy.fruit'])){
  765. $data['ou']='close';//closeUpdate
  766. }
  767. if(strstr($ipcheck,"MX")){
  768. if($PackageName==Util::$PACKAGE_110||$PackageName==Util::$PACKAGE_113) {
  769. $data['ouro_init'] = "mx_init_1224";
  770. }else{
  771. $data['ouro_init']="mx_init7";
  772. }
  773. // if(in_array($PackageName,["com.game.dream.snake","com.rosidapps.lagufelix","com.crazy.balloon","com.crazy.balloon2","com.rosidapps.lagufelix2","com.game.dream.snake2","com.secggplcheck.ott","com.secggplcheck.ott2","com.colorclicker.nhbfv","com.colorclicker.nhbfv2"])){
  774. // }
  775. Util::WriteLog('entermx','');
  776. }
  777. if(strstr($ipcheck,"MXX")){
  778. if($PackageName==Util::$PACKAGE_110) {
  779. $data['ouro_init'] = "mx_init_1224";
  780. }
  781. }
  782. return $data;
  783. }
  784. // 返回登录IP--新接口
  785. public function LoginIP(Request $request)
  786. {
  787. $data=$this->LoginIPData($request);
  788. return apiReturnSuc($data);
  789. }
  790. // 返回登录IP--新接口
  791. public function LoginIPCheck(Request $request)
  792. {
  793. $PackageName = (string)$request->get('PackageName');
  794. $login_ip = (string)$request->get('ip');
  795. $service = new IpCheck();
  796. // $list = StoredProcedure::getLoginIPMap($PackageName);
  797. $list = $this->getLoginIpMap($PackageName);
  798. $data = [
  799. 'list' => $list,
  800. 'login_ip' => $login_ip,
  801. 'kefu_switch' => 0,
  802. 'ip_check' => $service->ipCheck($login_ip),
  803. 'base_url'=>'',//多对多跳转
  804. // 'show_billboard'=>'http://api.slotfuns.com/api/rank/index?UserID=186408',//billboardd地址
  805. 'customer'=>$this->getServiceList()
  806. ];
  807. if($PackageName=="com.vencedor.appstore"||$PackageName=="com.vencedor.ios"){
  808. $data['ip_check']=false;
  809. Util::WriteLog('appstore',$data );
  810. }
  811. return apiReturnSuc($data);
  812. }
  813. // 用户支付绑定信息修改
  814. public function updateAccountsPayInfo(Request $request)
  815. {
  816. $account = $request->Account ?: '';
  817. $phone = $request->Phone ?: '';
  818. $email = $request->Email ?: '';
  819. $UserID = $request->UserID ?: '';
  820. $PixNum = $request->PixNum ?: '';
  821. if (empty($UserID)) return apiReturnFail(__('messages.api.common.missing_info'));
  822. if(!Util::validateCpf($PixNum)){
  823. return apiReturnFail(__('messages.api.withdraw_info.wrong_cpf'));
  824. }
  825. $redisKey = 'Api_updateAccountsPayInfo_'.$UserID;
  826. $lock = SetNXLock::getExclusiveLock($redisKey);
  827. if (!$lock) {
  828. return apiReturnFail(__('messages.api.withdraw_info.try_again_later'));
  829. }
  830. $exist = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')->where('UserID', $UserID)->first();
  831. if ($exist) {
  832. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')->where('UserID', $UserID)->update(['PixNum' => $PixNum]);
  833. } else {
  834. $data = ['BankUserName' => $account, 'PhoneNumber' => $phone, 'EmailAddress' => $email, 'UserID' => $UserID, 'PixNum' => $PixNum, 'Achieves' => '', 'HistoryWithDraw' => 0];
  835. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  836. ->insert($data);
  837. }
  838. SetNXLock::release($redisKey);
  839. return apiReturnSuc();
  840. }
  841. // 用户支付绑定信息获取
  842. public function getAccountsPayInfo(Request $request)
  843. {
  844. $UserID = $request->UserID ?: '';
  845. if (empty($UserID)) return apiReturnFail(__('messages.api.common.missing_info'));
  846. if(strstr($UserID,"&")){
  847. $UserID=explode("&",$UserID)[0];
  848. }
  849. $userInfo = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')
  850. ->where('UserID', $UserID)
  851. ->first();
  852. if(!$userInfo)return apiReturnFail(__('messages.api.common.missing_info'));
  853. //同一个内网
  854. $localIp=explode('.',env('SERVER_GAME_REDIS_HOST'))[0];
  855. $RegisterIP=$userInfo->RegisterIP;
  856. $LastLogonIP=$userInfo->LastLogonIP;
  857. $ip=IpLocation::getIP();
  858. if(str_starts_with($RegisterIP,$localIp)){
  859. $RegisterIP=$ip;
  860. }
  861. if(str_starts_with($LastLogonIP,$localIp)){
  862. $LastLogonIP=$ip;
  863. }
  864. if($LastLogonIP!=$userInfo->LastLogonIP||$RegisterIP!=$userInfo->RegisterIP){
  865. DB::table(TableName::QPAccountsDB() . 'AccountsInfo')
  866. ->where('UserID', $UserID)
  867. ->update(['RegisterIP'=>$RegisterIP,'LastLogonIP'=>$LastLogonIP]);
  868. }
  869. $info = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  870. ->where('UserID', $UserID)
  871. ->select('PixNum')
  872. ->first();
  873. //召回
  874. try {
  875. $callback = DB::table(TableName::agent() . 'UserCallBack')->where('UserID', $UserID)->first();
  876. if($callback){
  877. if($callback->call_state == 0){
  878. $update = [
  879. 'call_state' => 1,
  880. 'CallbackDate' => date('Y-m-d H:i:s'),
  881. 'LastLogonDate' => date('Y-m-d H:i:s'),
  882. ];
  883. //召回奖励
  884. Custom::updateAdminBonus($callback->admin_id,20,1);
  885. }else{
  886. $update = [
  887. 'LastLogonDate' => date('Y-m-d H:i:s'),
  888. ];
  889. }
  890. DB::table(TableName::agent() . 'UserCallBack')->where('UserID', $UserID)->update($update);
  891. }
  892. }catch (\Exception $e){
  893. }
  894. //巴西才能这样验证
  895. if(!empty($info->PixNum)&&env('COUNTRY_CODE')=='55'){
  896. if(!Util::validateCpf($info->PixNum)){
  897. $info->PixNum="";
  898. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  899. ->where('UserID', $UserID)->update(['PixNum' => $info->PixNum]);
  900. }
  901. }
  902. return apiReturnSuc($info);
  903. }
  904. // 提现手续费返回
  905. public function withDrawTax()
  906. {
  907. $WithDrawTax = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  908. ->where('si.StatusName', 'WithDrawTax')
  909. ->value('StatusValue');
  910. $WithDrawTax = $WithDrawTax / 100;
  911. return apiReturnSuc(compact('WithDrawTax'));
  912. }
  913. public function newGuide(Request $request){
  914. $UserID = $request->UserID ?: '';
  915. if (empty($UserID)) return apiReturnSuc(['new_guide' => 0]);
  916. //玩家信息
  917. $userInfo = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')
  918. ->where('UserID', $UserID)
  919. ->first();
  920. if (empty($userInfo)) return apiReturnSuc(['new_guide' => 0]);
  921. return apiReturnSuc(['new_guide' =>(time() - strtotime($userInfo->RegisterDate)>4000)?0:1]);
  922. }
  923. public function test(Request $request){
  924. return apiReturnSuc(['ret' =>[]]);
  925. }
  926. public function onlineList(){
  927. if (Redis::exists('Online_Real')) {
  928. $online = Redis::get('Online_Real');
  929. $online = json_decode($online,true);
  930. } else {
  931. $field = ['gi.GameID', 'gi.Nullity', 'gi.SortID', 'gi.ServerName', 'gi.ServerID'];
  932. $list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
  933. ->whereIn('GameID', config('games.openKGame'))
  934. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gl', function ($query) {
  935. $query->on('gl.ServerID', 'gi.ServerID')->selectRaw('gl.ServerID')->groupBy('ServerID')->whereRaw('datediff(hh,gl.CollectDate,getdate())<=5');
  936. })
  937. ->select($field)
  938. ->where('Nullity', 0)
  939. ->selectRaw('IsNull(count(DISTINCT gl.UserID),0) as game_count')
  940. ->groupBy($field)
  941. ->orderBy('gi.GameID', 'asc')
  942. ->orderBy('gi.ServerName', 'asc')
  943. ->get()->toArray();
  944. $online = [];
  945. foreach ($list as $item) {
  946. $item = json_decode(json_encode($item), true);
  947. if (isset($online[$item['GameID']])) {
  948. $online[$item['GameID']][$item['SortID']] += intval($item['game_count']);
  949. } else {
  950. if ($item['GameID'] == 4000) {
  951. $online[$item['GameID']] = [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0];
  952. } else {
  953. $online[$item['GameID']] = [1 => 0, 2 => 0, 3 => 0];
  954. }
  955. $online[$item['GameID']][$item['SortID']] = intval($item['game_count']);
  956. }
  957. }
  958. $online[4010][1] = intval($online[3014][1] / 8);
  959. $online[4000][1] = intval($online[3017][1] / 7);
  960. $online[917][1] = intval($online[3010][1] / 6);
  961. foreach ($online as $gid => &$ol) {
  962. if($gid == 6001){
  963. $ol[1] = $ol[1] * 368;
  964. }else{
  965. $ol[1] = $ol[1] * 168;
  966. }
  967. $ol[2] = intval($ol[1] / 5);
  968. $ol[3] = intval($ol[1] / 16);
  969. if ($gid == 4000) {
  970. $ol[4] = intval($ol[1] / 18);
  971. $ol[5] = intval($ol[1] / 19);
  972. $ol[6] = intval($ol[1] / 20);
  973. $ol[7] = intval($ol[1] / 21);
  974. }
  975. if ($gid == 917) {
  976. $ol[1] = 0;
  977. $ol[2] = 0;
  978. }
  979. if ($gid == 4010) {
  980. $ol[3] = 0;
  981. }
  982. }
  983. Redis::set('Online_Real',json_encode($online));
  984. Redis::expire('Online_Real', 120);
  985. }
  986. return apiReturnSuc(['ret' =>$online]);
  987. }
  988. public function jackpot(){
  989. $redis = Redis::connection('ServerGameRedis');
  990. $data = [
  991. 3010 => [
  992. 1 => $redis->get("jackpot_3010_1")+0,
  993. 2 => $redis->get("jackpot_3010_2")+0,
  994. 3 => $redis->get("jackpot_3010_3")+0
  995. ],
  996. 3014 => [
  997. 1 => $redis->get("jackpot_3014_1")+0,
  998. 2 => $redis->get("jackpot_3014_2")+0,
  999. 3 => $redis->get("jackpot_3014_3")+0,
  1000. 4 => $redis->get("jackpot_3014_4")+0
  1001. ],
  1002. 3017 => [
  1003. 1 => $redis->get("jackpot_3017_1")+0,
  1004. 2 => $redis->get("jackpot_3017_2")+0,
  1005. 3 => $redis->get("jackpot_3017_3")+0
  1006. ],
  1007. 3018 => [
  1008. //jackpot_{$kindID}_{$v}_{$v1}
  1009. 1 => $redis->get("jackpot_3018_1_0")+$redis->get("jackpot_3018_1_1")+$redis->get("jackpot_3018_1_2")+$redis->get("jackpot_3018_1_3")+$redis->get("jackpot_3018_1_4"),
  1010. 2 => $redis->get("jackpot_3018_2_0")+$redis->get("jackpot_3018_2_1")+$redis->get("jackpot_3018_2_2")+$redis->get("jackpot_3018_2_3")+$redis->get("jackpot_3018_2_4"),
  1011. 3 => $redis->get("jackpot_3018_3_0")+$redis->get("jackpot_3018_3_1")+$redis->get("jackpot_3018_3_2")+$redis->get("jackpot_3018_3_3")+$redis->get("jackpot_3018_3_4"),
  1012. ],
  1013. 3020 => [
  1014. 1 => $redis->get("jackpot_3020_1_0")+$redis->get("jackpot_3020_1_1")+$redis->get("jackpot_3020_1_2")+$redis->get("jackpot_3020_1_3"),
  1015. 2 => $redis->get("jackpot_3020_2_0")+$redis->get("jackpot_3020_2_1")+$redis->get("jackpot_3020_2_2")+$redis->get("jackpot_3020_2_3"),
  1016. 3 => $redis->get("jackpot_3020_3_0")+$redis->get("jackpot_3020_3_1")+$redis->get("jackpot_3020_3_2")+$redis->get("jackpot_3020_3_3")
  1017. ]
  1018. ];
  1019. return apiReturnSuc(['ret' =>$data]);
  1020. }
  1021. }