GlobalController.php 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Facade\TableName;
  4. use App\Game\GameCard;
  5. use App\Http\Controllers\Controller;
  6. use App\Http\helper\HttpCurl;
  7. use App\Http\helper\NumConfig;
  8. use App\Http\logic\admin\GlobalLogicController;
  9. use App\Models\AccountsInfo;
  10. use App\Models\AdminScore;
  11. use App\Models\Control;
  12. use App\Models\ControlRecord;
  13. use App\Models\Cpf;
  14. use App\Models\Order;
  15. use App\Models\RecordPlatformData;
  16. use App\Models\Withdrawal;
  17. use App\Services\CreateLog;
  18. use App\Services\GameRoomInfo;
  19. use App\Services\GlobalUser;
  20. use App\Services\Paging;
  21. use App\Services\StoredProcedure;
  22. use App\Util;
  23. use App\Utility\Helper;
  24. use Illuminate\Http\Request;
  25. use Illuminate\Pagination\Paginator;
  26. use Illuminate\Support\Facades\DB;
  27. use Illuminate\Support\Facades\Redis;
  28. class GlobalController extends Controller
  29. {
  30. public function index(Request $request)
  31. {
  32. $start_time = $request->start_time ?: date('Y-m-d 00:00:00');
  33. $end_time = $request->end_time ?: date('Y-m-d 23:59:59');
  34. if (!empty($request->post('date'))) {
  35. switch ($request->post('date')) {
  36. case 2:
  37. $start_time = date("Y-m-d 00:00:00", strtotime("-1 day"));
  38. $end_time = date("Y-m-d 23:59:59", strtotime("-1 day"));
  39. break;
  40. case 3:
  41. //当前日期
  42. $sdefaultDate = date("Y-m-d 00:00:00");
  43. //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
  44. $first = 1;
  45. //获取当前周的第几天 周日是 0 周一到周六是 1 - 6
  46. $w = date('w', strtotime($sdefaultDate));
  47. $start_time = date('Y-m-d 00:00:00', strtotime("$sdefaultDate -" . ($w ? $w - $first : 6) . ' days'));
  48. $end_time = date('Y-m-d 23:59:59', strtotime("$start_time +6 days"));
  49. break;
  50. case 4:
  51. $start_time = date("Y-m-01 00:00:00");
  52. $end_time = date("Y-m-t 23:59:59");
  53. break;
  54. }
  55. }
  56. $StartDataID = date('Ymd', strtotime($start_time));
  57. $EndDataID = date('Ymd', strtotime($end_time));
  58. $RecordPlatformDataModel = new RecordPlatformData();
  59. $GlobalUserService = new GlobalUser();
  60. ///////////////////////////////////////////////////
  61. // 用户相关
  62. ///////////////////////////////////////////////////
  63. $accounts = $GlobalUserService->accounts();
  64. ///////////////////////////////////////////////////
  65. // 游戏相关
  66. ///////////////////////////////////////////////////
  67. $games = $GlobalUserService->games($StartDataID, $EndDataID);
  68. ///////////////////////////////////////////////////
  69. // 彩金相关
  70. ///////////////////////////////////////////////////
  71. // 用户彩金
  72. $winnings = $GlobalUserService->winnings($start_time, $end_time);
  73. // 按日期搜索注册用户
  74. $dayAccountInfo = $RecordPlatformDataModel->dayAccountInfo($StartDataID, $EndDataID);
  75. $start_time = date('Y-m-d', strtotime($start_time)) . 'T' . date('H:i:s', strtotime($start_time));
  76. $end_time = date('Y-m-d', strtotime($end_time)) . 'T' . date('H:i:s', strtotime($end_time));
  77. return view('admin.global.index', compact('accounts', 'games', 'winnings', 'dayAccountInfo', 'start_time', 'end_time'));
  78. }
  79. //全局报表
  80. public function index1(Request $request)
  81. {
  82. //总充值金额
  83. $order = Order::pay_sum();
  84. $pay_sum = isset($order->pay_sum) ? number_float($order->pay_sum / NumConfig::NUM_VALUE) : 0;
  85. // 签到总奖励
  86. $totalSignIn = DB::connection('read')->table('QPAccountsDB.dbo.UserSignInInfo')
  87. ->selectRaw('IsNull(sum(TotalReward),0) TotalReward')
  88. ->first()->TotalReward / 100 ?? 0;
  89. //总付费用户
  90. $pay_user_count = $order->pay_user_count ?? 0;
  91. // 历史流水和税收
  92. $gameInfo = DB::connection('read')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
  93. ->selectRaw('IsNull((abs(sum(LostScore)) + sum(WinScore)),0) flowing_water,Isnull(sum(Revenue),0) as Revenue,IsNull((sum(LostScore) + sum(WinScore)),0) Score,IsNull(sum(Withdraw),0) WithDraw,Isnull(SUM(Handsel),0) as ChangeScore')
  94. ->first();
  95. // 累计提现金额
  96. $txAmount = $gameInfo->WithDraw / 100 ?? 0;
  97. // 累计提现回收金额
  98. $WithDrawRecovery = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw as ow')
  99. ->where('State', 4)
  100. ->selectRaw('sum(WithDraw+ServiceFee) as WithDraw')
  101. ->first()->WithDraw ?? 0;
  102. $AllWorkingScore = number_float(($gameInfo->flowing_water + $gameInfo->Revenue) / 100);
  103. //赠送总金豆
  104. $cellData = $gameInfo->ChangeScore;
  105. $z_give = number_float($cellData / 100);
  106. //总注册用户
  107. $user_count = AccountsInfo::user_count();
  108. //休眠用户
  109. $dormancy_user = AccountsInfo::dormancy_user();
  110. //流失用户
  111. $ls_user = AccountsInfo::ls_user();
  112. /* 根据时间搜索查询数据 */
  113. $start_time = $request->start_time ?? date('Y-m-d 00:00:00');
  114. $end_time = $request->end_time ?? date('Y-m-d 23:59:59');
  115. if (!empty($request->post('start_time'))) $start_time = $request->post('start_time');
  116. if (!empty($request->post('end_time'))) $end_time = $request->post('end_time');
  117. $start_time = str_replace('T', ' ', $start_time);
  118. $end_time = str_replace('T', ' ', $end_time);
  119. if (!empty($request->post('date'))) {
  120. switch ($request->post('date')) {
  121. case 2:
  122. $start_time = date("Y-m-d 00:00:00", strtotime("-1 day"));
  123. $end_time = date("Y-m-d 23:59:59", strtotime("-1 day"));
  124. break;
  125. case 3:
  126. //当前日期
  127. $sdefaultDate = date("Y-m-d 00:00:00");
  128. //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
  129. $first = 1;
  130. //获取当前周的第几天 周日是 0 周一到周六是 1 - 6
  131. $w = date('w', strtotime($sdefaultDate));
  132. $start_time = date('Y-m-d 00:00:00', strtotime("$sdefaultDate -" . ($w ? $w - $first : 6) . ' days'));
  133. $end_time = date('Y-m-d 23:59:59', strtotime("$start_time +6 days"));
  134. break;
  135. case 4:
  136. $start_time = date("Y-m-01 00:00:00");
  137. $end_time = date("Y-m-t 23:59:59");
  138. break;
  139. }
  140. }
  141. /* 活动数据 */
  142. // 用户彩金
  143. $ScoreType = [21, 33, 36, 37, 42, 44, 45, 49, 51, 52, 53, 59, 70];
  144. // 21、绑定手机赠送 33、注册赠送 36、推广赚金(彩金) 37、人工增加金币 42、邮件附件(充值彩金) 45、充值彩金 49、月卡彩金 51、首充礼包(彩金) 52、邮件附件(群发彩金) 53、推广赚金(佣金)
  145. $RecordUserScoreStatistics = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
  146. ->whereBetween('DateID', [date('Ymd', strtotime($start_time)), date('Ymd', strtotime($end_time))])
  147. ->whereIn('ScoreType', $ScoreType)
  148. ->select('ScoreType')
  149. ->selectRaw('Isnull(SUM(Score),0) as Score')
  150. ->groupBy('ScoreType')
  151. ->pluck('Score', 'ScoreType')->toArray();
  152. $list['bd'] = isset($RecordUserScoreStatistics['21']) ? number_float($RecordUserScoreStatistics['21'] / NumConfig::NUM_VALUE) : 0;
  153. $list['zc'] = isset($RecordUserScoreStatistics['33']) ? number_float($RecordUserScoreStatistics['33'] / NumConfig::NUM_VALUE) : 0;
  154. $list['tg'] = isset($RecordUserScoreStatistics['36']) ? number_float($RecordUserScoreStatistics['36'] / NumConfig::NUM_VALUE) : 0;
  155. $list['rg'] = isset($RecordUserScoreStatistics['37']) ? number_float($RecordUserScoreStatistics['37'] / NumConfig::NUM_VALUE) : 0;
  156. $list['mailCellData'] = isset($RecordUserScoreStatistics['42']) ? number_float($RecordUserScoreStatistics['42'] / NumConfig::NUM_VALUE) : 0;
  157. $list['cz'] = isset($RecordUserScoreStatistics['45']) ? number_float($RecordUserScoreStatistics['45'] / NumConfig::NUM_VALUE) : 0;
  158. $list['yk'] = isset($RecordUserScoreStatistics['49']) ? number_float($RecordUserScoreStatistics['49'] / NumConfig::NUM_VALUE) : 0;
  159. $list['sc'] = isset($RecordUserScoreStatistics['51']) ? number_float($RecordUserScoreStatistics['51'] / NumConfig::NUM_VALUE) : 0;
  160. $list['qf'] = isset($RecordUserScoreStatistics['52']) ? number_float($RecordUserScoreStatistics['52'] / NumConfig::NUM_VALUE) : 0;
  161. $list['commission'] = isset($RecordUserScoreStatistics['53']) ? number_float($RecordUserScoreStatistics['53'] / NumConfig::NUM_VALUE) : 0;
  162. $list['weekCard'] = isset($RecordUserScoreStatistics['59']) ? number_float($RecordUserScoreStatistics['59'] / NumConfig::NUM_VALUE) : 0;
  163. $list['Backwater'] = isset($RecordUserScoreStatistics['70']) ? number_float($RecordUserScoreStatistics['70'] / NumConfig::NUM_VALUE) : 0;
  164. // 签到
  165. $signIn = DB::connection('read')->table('QPRecordDB.dbo.RecordSignIn')
  166. ->where('SignInDate', '>=', date("Y-m-d 00:00:00", strtotime("$start_time")))
  167. ->where('SignInDate', '<=', date("Y-m-d 23:59:59", strtotime("$end_time")))
  168. ->selectRaw('IsNull(sum(RewardScore),0) RewardScore')
  169. ->first()->RewardScore / 100 ?? 0;
  170. // 推广总奖励
  171. $TotalReward = DB::connection('read')->table('QPAccountsDB.dbo.SystemAgentReward')->select('TotalReward')->first()->TotalReward;
  172. $data['TotalReward'] = number_float($TotalReward / 100);
  173. // 非正式会员的彩金
  174. $notMemberProfit = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew as rs')
  175. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ai.UserID', 'rs.UserID')
  176. ->where('Channel', 100)
  177. ->whereIn('ScoreType', $ScoreType)
  178. ->whereBetween('DateID', [date('Ymd', strtotime($start_time)), date('Ymd', strtotime($end_time))])
  179. ->selectRaw('Isnull(SUM(Score),0) as Score')
  180. ->first()->Score;
  181. // 正式会员彩金
  182. $MemberProfit = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew as rs')
  183. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ai.UserID', 'rs.UserID')
  184. ->whereIn('ScoreType', $ScoreType)
  185. ->where('Channel', '<>', 100)
  186. ->whereBetween('DateID', [date('Ymd', strtotime($start_time)), date('Ymd', strtotime($end_time))])
  187. ->selectRaw('Isnull(SUM(Score),0) as Score')
  188. ->first()->Score;
  189. // 总彩金 = 邮件送金 + 充值送金 + 注册送金 + 月卡 + 绑定 + 签到 + 群发邮件 + 人工增加金币 + 周卡 + 返水 + 谷歌会员 + 正式会员
  190. $data['cellData'] = array_sum($list) + $signIn + ($notMemberProfit / 100) + ($MemberProfit / 100);
  191. // 非正式会员人数-- 进入TP试玩场人数
  192. $notMemberNum = DB::connection('read')->table('QPTreasureDB.dbo.RecordUserInout as ri')
  193. ->join('QPPlatformDB.dbo.GameRoomInfo as gi', 'ri.ServerID', 'gi.ServerID')
  194. ->where('gi.ServerType', 2)
  195. ->where('GameID', 1005)
  196. ->where('ri.EnterTime', '>=', date("Y-m-d 00:00:00", strtotime("$start_time")))
  197. ->where('ri.EnterTime', '<=', date("Y-m-d 23:59:59", strtotime("$end_time")))
  198. ->selectRaw('count(distinct(ri.UserID)) count_u')
  199. ->first()->count_u ?? 0;
  200. // 谷歌渠道--付费人数--付费金额
  201. $google_pay = DB::connection('read')->table('agent.dbo.order as o')
  202. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
  203. ->where('Channel', 100)
  204. ->where('o.pay_at', '>=', "$start_time")
  205. ->where('o.pay_at', '<=', "$end_time")
  206. ->selectRaw('IsNull(sum(amount),0) as amount,count(distinct(o.user_id)) as c_user_id')
  207. ->first();
  208. /* 用户数据 */
  209. //注册用户
  210. $data['today_register'] = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  211. ->selectRaw('count(*) as today_register')
  212. ->where('IsAndroid', 0)
  213. ->where('RegisterDate', '>=', "$start_time")
  214. ->where('RegisterDate', '<=', "$end_time")
  215. ->first()->today_register;
  216. //充值人数
  217. $pay_count = DB::connection('read')->table('agent.dbo.order')
  218. ->where('pay_at', '>=', "$start_time")
  219. ->where('pay_at', '<=', "$end_time")
  220. ->selectRaw('count(DISTINCT user_id) as today_pay_count,cast(sum(amount) as int) as today_pay_sum')
  221. ->first();
  222. // 提现人数
  223. $cash = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw')
  224. ->where('finishDate', '>=', "$start_time")
  225. ->where('finishDate', '<=', "$end_time")
  226. ->selectRaw('count(DISTINCT UserID) as cash_count,cast(sum(WithDraw) as int) as cash_sum,count(RecordID) cash_bi')
  227. ->first();
  228. $data['today_pay_count'] = $pay_count->today_pay_count;
  229. //活跃用户数
  230. $data['lively_num'] = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogin')->selectRaw('count(distinct(UserID)) as lively_num')
  231. ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
  232. ->where('DateID', '<=', date('Ymd', strtotime($start_time)))
  233. ->first()->lively_num;
  234. //ios 安卓新增用户
  235. $player_list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  236. ->where('IsAndroid', 0)
  237. ->whereIn('LastLogonMobile', ['Android', 'IOS'])
  238. ->where('RegisterDate', '>=', "$start_time")
  239. ->where('RegisterDate', '<=', "$end_time")
  240. ->get();
  241. $data['android_num'] = $data['ios_num'] = 0; //安卓 ios 人数
  242. foreach ($player_list as $key => $value) {
  243. if ($value->LastLogonMobile === 'Android') {
  244. $data['android_num'] += 1;//安卓用户数
  245. } else {
  246. $data['ios_num'] += 1;//IOS用户数
  247. }
  248. }
  249. /* 充值数据 */
  250. //累计充值 总额
  251. $data['today_pay_sum'] = number_float($pay_count->today_pay_sum / 100);
  252. $data['android_recharge'] = $data['ios_recharge'] = 0;//安卓 ios 累计充值金额
  253. $data['android_recharge_num'] = $data['ios_recharge_num'] = 0;//安卓 ios 充值用户数
  254. // 累计提现
  255. $data['cash_sum'] = number_float($cash->cash_sum / 100);
  256. $data['cash_count'] = $cash->cash_count;
  257. $data['cash_bi'] = $cash->cash_bi;
  258. $pay = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rsn')
  259. ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
  260. ->where('DateID', '<=', date('Ymd', strtotime($end_time)))
  261. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'rsn.UserID', 'ai.UserID')
  262. ->where('LastLogonMobile', 'Android')
  263. ->selectRaw('count(rsn.UserID) count_u,sum(Recharge) amount')
  264. ->first();
  265. $data['android_recharge'] = isset($pay->amount) ? number_float($pay->amount) : 0;
  266. $data['android_recharge_num'] = $pay->count_u ?? 0;//安卓用户数
  267. // 游客人数
  268. $tourist = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  269. ->where('WebLogonTimes', 1)
  270. ->where('IsAndroid', 0)
  271. ->where('RegisterDate', '>=', $start_time)
  272. ->where('RegisterDate', '<=', $end_time)
  273. ->count();
  274. // 手机账号人数-包括游客升级来的
  275. $phoneNum = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone')
  276. ->where('BindDate', '>=', $start_time)
  277. ->where('BindDate', '<=', $end_time)
  278. ->count();
  279. // Facebook 人数
  280. $facebookNum = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  281. ->where('RegisterDate', '>=', $start_time)
  282. ->where('RegisterDate', '<=', $end_time)
  283. ->where('IsAndroid', 0)
  284. ->where('WebLogonTimes', 0)
  285. ->count();
  286. $data['android_recharge'] = number_float($data['android_recharge'] / 100);
  287. $data['ios_recharge'] = number_float($data['ios_recharge'] / 100);
  288. $data['amount'] = number_float($google_pay->amount / 100); // 谷歌渠道付费金额
  289. $data['c_user_id'] = $google_pay->c_user_id; // 谷歌渠道付费人数
  290. $list['notMemberProfit'] = number_float($notMemberProfit / NumConfig::NUM_VALUE);
  291. $list['MemberProfit'] = number_float($MemberProfit / NumConfig::NUM_VALUE);
  292. $list['signIn'] = number_float($signIn);
  293. // 总税收
  294. $z_revenue = number_float($gameInfo->Revenue / 100);
  295. //输赢总额 保留2位小数(平台总输赢)
  296. $z_robot_gold = number_float(-$gameInfo->Score / 100);
  297. // 库存统计 -- 玩家总额
  298. $sum = (new GlobalLogicController())->sum();
  299. foreach ($sum as &$val) {
  300. $val = number_float($val / 100);
  301. }
  302. $logic = new GlobalLogicController();
  303. // 月卡信息
  304. $MonthCard = $logic->MonthCard();
  305. // 首冲信息
  306. //$FirstRechargeGifts = $logic->FirstRechargeGifts();
  307. // 周卡信息
  308. $WeeklyCard = $logic->WeeklyCard();
  309. /* 游戏房间数据 */
  310. $gameRoomInfo = DB::connection('read')->table('QPRecordDB.dbo.RecordServerDataStatistics')
  311. ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
  312. ->where('DateID', '<=', date('Ymd', strtotime($start_time)))
  313. ->selectRaw('Isnull((sum(WinScore) + abs(sum(LostScore))),0) as flowing_water,Isnull(sum(Revenue),0) as Revenue,Isnull((sum(WinScore) + sum(LostScore)),0) as win_lose')
  314. ->first();
  315. //平台输赢 目前计算的是机器人输赢
  316. $gameRoomInfo->win_lose = isset($gameRoomInfo->win_lose) ? number_float($gameRoomInfo->win_lose / NumConfig::NUM_VALUE) : 0;
  317. //流水
  318. $gameRoomInfo->flowing_water = isset($gameRoomInfo->flowing_water) ? number_float(($gameRoomInfo->flowing_water) / NumConfig::NUM_VALUE) : 0;
  319. //税收
  320. $gameRoomInfo->Revenue = isset($gameRoomInfo->Revenue) ? number_float($gameRoomInfo->Revenue / NumConfig::NUM_VALUE) : 0;
  321. // 累计玩游戏人数
  322. $gameRoomInfo->GameCountUser = DB::connection('read')->table('QPRecordDB.dbo.PD_RecordScoreInfo')
  323. ->where('AtDate', '>=', date('Ymd', strtotime($start_time)))
  324. ->where('AtDate', '<=', date('Ymd', strtotime($end_time)))
  325. ->count(DB::raw('DISTINCT UserID'));
  326. $game_list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
  327. ->leftJoin('QPRecordDB.dbo.RecordServerDataStatistics as rds', 'rds.ServerID', 'gi.ServerID')
  328. ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
  329. ->where('DateID', '<=', date('Ymd', strtotime($start_time)))
  330. ->select('gi.GameID', 'gi.ServerName', 'gi.ServerID')
  331. ->selectRaw('gi.ServerID,Isnull((sum(WinScore) + abs(sum(LostScore))),0) as flowing_water,Isnull(sum(rds.Revenue),0) as Revenue,Isnull((sum(WinScore) + sum(LostScore)),0) as win_lose')
  332. ->groupBy('gi.GameID', 'gi.ServerName', 'gi.ServerID')
  333. ->orderByDesc('flowing_water')
  334. ->get();
  335. // 玩过游戏的人
  336. $playGameUser = DB::connection('write')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
  337. ->where('AtDate', '>=', date('Ymd', strtotime($start_time)))
  338. ->where('AtDate', '<=', date('Ymd', strtotime($end_time)))
  339. ->selectRaw('count(distinct(UserID)) as count_u,ServerID')
  340. ->groupBy('ServerID')
  341. ->pluck('count_u', 'ServerID')->toArray();
  342. foreach ($game_list as &$value) {
  343. $value->Score = number_float(($value->win_lose / NumConfig::NUM_VALUE)); // 平台输赢
  344. $value->ri_Revenue = number_float($value->Revenue / NumConfig::NUM_VALUE); // 税收
  345. $value->liushui = number_float(($value->flowing_water) / NumConfig::NUM_VALUE); // 流水
  346. $value->count_u = $playGameUser[$value->ServerID] ?? 0;
  347. }
  348. $start_time = strtotime($start_time);
  349. $end_time = strtotime($end_time);
  350. $start_time = str_replace('T', ' ', $start_time);
  351. $end_time = str_replace('T', ' ', $end_time);
  352. return view('admin.global.index', [
  353. 'pay_sum' => $pay_sum, //总充值金额
  354. 'totalSignIn' => $totalSignIn, //签到总奖励
  355. 'pay_user_count' => $pay_user_count, //总付费用户
  356. 'z_revenue' => $z_revenue,//总税收
  357. 'AllWorkingScore' => $AllWorkingScore,//总流水
  358. 'z_robot_gold' => $z_robot_gold,//机器人输赢总额 保留2位小数(平台总输赢)
  359. 'txAmount' => number_float($txAmount),//机器人输赢总额 保留2位小数(平台总输赢)
  360. 'WithDrawRecovery' => number_float($WithDrawRecovery / 100),//机器人输赢总额 保留2位小数(平台总输赢)
  361. 'z_give' => $z_give,//赠送总金豆
  362. 'user_count' => $user_count, //总注册用户
  363. 'dormancy_user' => $dormancy_user,//休眠用户
  364. 'ls_user' => $ls_user, //流失用户
  365. 'data' => $data,//统计数据
  366. 'list' => $list, //表格数据
  367. 'tourist' => $tourist,
  368. 'start_time' => date('Y-m-d', $start_time) . 'T' . date('H:i:s', $start_time),
  369. 'end_time' => date('Y-m-d', $end_time) . 'T' . date('H:i:s', $end_time),
  370. 'phoneNum' => $phoneNum,
  371. 'facebookNum' => $facebookNum,
  372. 'notMemberNum' => $notMemberNum,
  373. 'sum' => $sum,
  374. 'MonthCard' => $MonthCard,
  375. 'WeeklyCard' => $WeeklyCard,
  376. //'FirstRechargeGifts' => $FirstRechargeGifts,
  377. 'gameRoomInfo' => $gameRoomInfo,
  378. 'game_list' => $game_list,
  379. ]);
  380. }
  381. //房间实时数据
  382. public function room(Request $request)
  383. {
  384. $field = ['LostUserCount', 'WinUserCount', 'gi.GameID', 'gi.Nullity', 'gi.SortID', 'gi.ServerName', 'gi.ServerID', 'gi.RoomStock', 'WinInning', 'LostInning', 'TotalInning', 'Revenue', 'LostScore', 'WinScore'];
  385. $list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
  386. ->whereIn('GameID', config('games.openKGame'))
  387. ->leftJoin('QPRecordDB.dbo.RecordServerDataStatistics as rds', 'gi.ServerID', '=', 'rds.ServerID')
  388. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gl', function ($query) {
  389. $query->on('gl.ServerID', 'gi.ServerID')->selectRaw('gl.ServerID')->groupBy('ServerID')->whereRaw('datediff(hh,gl.CollectDate,getdate())<=5');
  390. })
  391. ->where('rds.DateID', date('Ymd'))
  392. ->select($field)
  393. ->selectRaw('IsNull(count(DISTINCT gl.UserID),0) as game_count')
  394. ->groupBy($field)
  395. ->orderBy('gi.GameID', 'asc')
  396. ->orderBy('gi.ServerName', 'asc')
  397. ->get()->toArray();
  398. $list = (new GlobalLogicController())->room($list);
  399. // 游戏在线人数
  400. // $line = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreLocker')
  401. // ->selectRaw('count(DISTINCT UserID) as game_count')
  402. // ->whereDate('CollectDate', date('Y-m-d'))
  403. // ->first()->game_count;
  404. $line = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreLocker')
  405. ->selectRaw('count(DISTINCT UserID) as game_count')
  406. ->whereRaw('datediff(hh,CollectDate,getdate())<=5')
  407. ->first()->game_count;
  408. $dt_line = 0;
  409. // 检查当前用户权限
  410. $admin = session('admin');
  411. $role_id = $admin->roles[0]->id;
  412. return view('admin.global.room', ['list' => $list, 'line' => $line, 'dt_line' => $dt_line, 'role_id' => $role_id]);
  413. }
  414. // 展示房间配置
  415. public function show_config($ServerID)
  416. {
  417. $GameKindItem = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
  418. ->join('QPPlatformDB.dbo.GameKindItem as gk', 'gi.GameID', 'gk.GameID')
  419. ->where('gi.ServerID', $ServerID)
  420. ->value('KindName');
  421. $logic = new GlobalLogicController();
  422. $result = $logic->teenpatti($ServerID);
  423. if ($GameKindItem == 'teenpatti') { // teenpatti
  424. return view('admin.global.teenpatti', $result);
  425. } else { // rummy
  426. //$result = $logic->rummy($ServerID);
  427. return view('admin.global.rummy', $result);
  428. }
  429. }
  430. //用户列表
  431. public function userlist(Request $request)
  432. {
  433. $adminChannels=session('admin_channels');
  434. $UserID = (int)$request->UserID ?: "";
  435. $MachineID = $request->MachineID ?: "";
  436. $gameID = (int)$request->GameID ?: "";
  437. $phoneNum = $request->PhoneNum ?? "";
  438. $spreaderID = (int)$request->SpreaderID ?: "";
  439. $nickName = $request->NickName ?? "";
  440. $startTime = str_replace('T', ' ', $request->start_time ?? "");
  441. $endTime = str_replace('T', ' ', $request->end_time ?? "");
  442. $startLoginTime = str_replace('T', ' ', $request->start_logintime ?? "");
  443. $endLoginTime = str_replace('T', ' ', $request->end_logintime ?? "");
  444. $obj = $request->obj ?? "";
  445. $vip = $request->vip ?? '';
  446. $excel = $request->excel ?? "";
  447. $accounts_type = $request->accounts_type ?: 0;
  448. $score = $request->Score ?: '';
  449. $channel = $request->channel;
  450. $user_tab = $request->user_tab ?: '';
  451. $packgeName = $request->PackgeName ?: '';
  452. // 快速搜索
  453. $quickSearch = $request->quickSearch ?: '';
  454. $list = (new GlobalUser())->userlist($gameID, $phoneNum, $spreaderID, $nickName, $startTime, $endTime, $obj, $vip, $excel, $accounts_type, $channel, $user_tab, $packgeName, $quickSearch, $score,$MachineID,$startLoginTime,$endLoginTime);
  455. // $channels = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('IsAndroid', 0)->groupBy('Channel')->pluck('Channel');
  456. $channels=$adminChannels;
  457. // $webLogonTimes = [1 => 'facebook', 2 => '游客', 3 => '手机号'];
  458. $webLogonTimes = [ 2 => __('auto.游客'), 3 => __('auto.手机号')];
  459. // 获取包名
  460. $ChannelPackageName = DB::connection('write')->table('QPPlatformDB.dbo.ChannelRechargeGameOpen')
  461. ->select('ChannelPackageName')
  462. ->pluck('ChannelPackageName')->toArray();
  463. // $ChannelPackageName[] = 'com.teenpatti.queen';
  464. $typeList = [1 => __('auto.游戏中'), 2 => __('auto.未实名'), 3 => __('auto.无手机号'), 5 => __('auto.无渠道'), 6 => __('auto.未充值'), 7 => __('auto.无上级'), 8 => __('auto.封号中'), 9 => __('auto.官方账号')];
  465. return view('admin.global.userlist', compact('list','MachineID', 'gameID', 'phoneNum', 'spreaderID', 'nickName', 'startTime', 'endTime','startLoginTime', 'endLoginTime', 'obj', 'vip', 'excel', 'accounts_type'
  466. , 'channel', 'user_tab', 'packgeName', 'channels', 'webLogonTimes', 'ChannelPackageName', 'score', 'quickSearch', 'typeList'
  467. ));
  468. }
  469. //用户列表
  470. public function userlist1(Request $request)
  471. {
  472. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  473. ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai1', 'ai.SpreaderID', '=', 'ai1.UserID')
  474. ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
  475. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gsl', 'gsl.UserID', '=', 'ai.UserID')
  476. ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as gri', 'gsl.ServerID', '=', 'gri.ServerID')
  477. ->leftJoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', 'ap.UserID')
  478. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  479. ->leftJoin('QPRecordDB.dbo.RecordPackageName as rn', 'ai.UserID', 'rn.UserID')
  480. ->where('ai.IsAndroid', 0);
  481. $UserID = (int)$request->UserID ?: "";
  482. $GameID = (int)$request->GameID ?: "";
  483. $RegisterMobile = $request->RegisterMobile ?? "";
  484. $SpreaderID = (int)$request->SpreaderID ?: "";
  485. $Compellation = $request->Compellation ?? "";
  486. $start_time = $request->start_time ?? "";
  487. $end_time = $request->end_time ?? "";
  488. $obj = $request->obj ?? "";
  489. $vip = $request->vip ?? '';
  490. $excel = $request->excel ?? "";
  491. $accounts_type = $request->accounts_type ?: '';
  492. $Score = $request->Score ?: '';
  493. $channel = $request->channel;
  494. $user_tab = $request->user_tab ?: '';
  495. $PackgeName = $request->PackgeName ?: '';
  496. $start_time = str_replace('T', ' ', $start_time);
  497. $end_time = str_replace('T', ' ', $end_time);
  498. if (!empty($PackgeName)) {
  499. $list->where('PackgeName', $PackgeName);
  500. }
  501. if (!empty($UserID)) {
  502. $list->where('ai.UserID', $UserID);
  503. }
  504. if (!empty($GameID)) {
  505. $list->where('ai.GameID', $GameID);
  506. }
  507. if (!empty($RegisterMobile)) {
  508. $RegisterMobile = str_replace(' ', '', $RegisterMobile);
  509. $list->where('ap.PhoneNum', 'like', $RegisterMobile . '%');
  510. }
  511. if (!empty($SpreaderID)) {
  512. $getSpreaderID = AccountsInfo::where('GameID', $SpreaderID)->value('UserID');
  513. $list->where('ai.SpreaderID', $getSpreaderID);
  514. }
  515. if (!empty($Compellation)) {
  516. $list->where('ai.NickName', 'like', '%' . $Compellation . '%');
  517. }
  518. if (!empty($start_time)) {
  519. $list->where('ai.RegisterDate', '>=', $start_time);
  520. $start_time = date('Y-m-d', strtotime($start_time)) . 'T' . date('H:i:s', strtotime($start_time));
  521. }
  522. if (!empty($end_time)) {
  523. $list->where('ai.RegisterDate', '<=', $end_time);
  524. $end_time = date('Y-m-d', strtotime($end_time)) . 'T' . date('H:i:s', strtotime($end_time));
  525. }
  526. if (!empty($user_tab)) {
  527. $user_tabArr = explode('_', $user_tab);
  528. $list->where($user_tabArr[0], $user_tabArr[1])->count();
  529. }
  530. (!empty($channel) || $channel === '0') && $list->where('ai.Channel', $channel);
  531. switch ($accounts_type) {
  532. case 1:
  533. $list->where('ai.WebLogonTimes', 0)->whereNull('PhoneNum');
  534. break;
  535. case 2:
  536. $list->where('ai.WebLogonTimes', 1)->whereNull('PhoneNum');
  537. break;
  538. case 3:
  539. $list->WhereNotNull('PhoneNum');
  540. break;
  541. case 4:
  542. $list->where('ai.Channel', 100);
  543. break;
  544. }
  545. if (!empty($Score)) {
  546. $list->orderBy('Score', $Score);
  547. } else {
  548. $list->orderBy('ai.RegisterDate', 'desc');
  549. }
  550. $build_str = $request->build_str ?: '';
  551. $arr = [];
  552. if (!empty($build_str)) {
  553. parse_str($build_str, $arr);
  554. }
  555. $build_query = '';
  556. $data = $request->post('search', []);
  557. $data = array_merge($data, $arr);
  558. if (!empty($data)) {
  559. $arr_filter = array_filter($data);
  560. $build_query = http_build_query($arr_filter);
  561. }
  562. $r = (new GlobalLogicController())->user_search($list, $data);
  563. $list = $r['build_sql'];
  564. $data = $r['data'];
  565. if (!empty($vip)) {
  566. $list->where('ai.MemberOrder', $vip);
  567. }
  568. //是否导出excel
  569. if (!empty($excel)) {
  570. $list = $list->selectRaw('ai.GameID,ai.NickName,ap.PhoneNum,ai.RegisterIP,gi.Score,ai1.GameID as SpreaderID,ai.MemberOrder,ai.RegisterDate,ai.Channel,ai.Accounts,ai.Nullity')
  571. ->limit(10000)->get();
  572. foreach ($list as $key => &$value) {
  573. $value->Score = number_float($value->Score / 100);
  574. switch ($value->Nullity) {
  575. case '0':
  576. $value->Nullity = '正常';
  577. break;
  578. case '1':
  579. $value->Nullity = '封禁';
  580. break;
  581. }
  582. }
  583. $title = ['会员ID', '姓名', '手机号', 'IP', '金豆余额', '上级ID', 'vip等级', '注册日期', '渠道名称', '账号', '账号状态'];
  584. $list = json_decode(json_encode($list), true);
  585. downloadExcel($list, $title, '房间输赢统计' . date('YmdHis'));
  586. } else {
  587. $list = $list
  588. ->select('ai.*', 'gi.Score', 'ai1.GameID as ain_GameID', 'gi.Revenue', 'gi.InsureScore', 'gsl.CollectDate', 'gi.BankScore', 'gri.ServerName', 'ap.PhoneNum', 'PackgeName')
  589. ->paginate(10);
  590. // 查找官方账号
  591. $userID = [];
  592. foreach ($list as $val) {
  593. $userID[] = $val->UserID;
  594. }
  595. // 游戏中用户
  596. $query_UserID = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->whereIn('UserID', $userID)->pluck('UserID')->toArray();
  597. // 禁止查看敏感信息
  598. $helper = new Helper();
  599. $flag = $helper->privacy($request);
  600. if ($flag) {
  601. foreach ($list->items() as &$val) {
  602. $val->LastLogonMobile = !empty($this->LastLogonMobile) ? $helper->sub_mobile($val->LastLogonMobile) : '';
  603. }
  604. }
  605. // 获取包名
  606. $ChannelPackageName = DB::connection('write')->table('QPPlatformDB.dbo.ChannelRechargeGameOpen')
  607. ->select('ChannelPackageName')
  608. ->pluck('ChannelPackageName')->toArray();
  609. $ChannelPackageName[] = 'com.teenpatti.queen';
  610. foreach ($list as &$val) {
  611. $val->Score = $val->Score / 100;
  612. $val->ipAddress = '';
  613. switch ($val->Nullity) {
  614. case '0':
  615. $val->Nullity = '正常';
  616. break;
  617. case 1:
  618. $val->Nullity = '封禁';
  619. break;
  620. }
  621. if (in_array($val->UserID, $query_UserID)) {
  622. $val->Nullity .= '<span style="color: Orange">(官方)</span>';
  623. }
  624. }
  625. $WebLogonTimes = [1 => 'facebook', 2 => '游客', 3 => '手机号'];
  626. $channels = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('IsAndroid', 0)->groupBy('Channel')->pluck('Channel');
  627. return view('admin.global.userlist', [
  628. 'list' => $list,
  629. 'UserID' => $UserID,
  630. 'GameID' => $GameID,
  631. 'RegisterMobile' => $RegisterMobile,
  632. 'SpreaderID' => $SpreaderID,
  633. 'Compellation' => $Compellation,
  634. 'start_time' => $start_time,
  635. 'end_time' => $end_time,
  636. 'obj' => $data,
  637. 'vip' => $vip,
  638. 'WebLogonTimes' => $WebLogonTimes,
  639. 'accounts_type' => $accounts_type,
  640. 'build_str' => $build_query,
  641. 'channel' => $channel,
  642. 'Score' => $Score,
  643. 'user_tab' => $user_tab,
  644. 'channels' => $channels,
  645. 'ChannelPackageName' => $ChannelPackageName,
  646. 'PackgeName' => $PackgeName
  647. ]);
  648. }
  649. }
  650. //用户修改
  651. public function user_update(Request $request)
  652. {
  653. if ($request->isMethod('get')) {
  654. $userID = $request->id;
  655. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  656. ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ain', 'ai.SpreaderID', '=', 'ain.UserID')
  657. ->where('ai.UserID', $userID)
  658. ->selectRaw('ai.UserID,ai.NickName,ai.Nullity,ai.Compellation,ai.SpreaderID,ai.GameID as ai_GameID,IsNull(ain.GameID,0) as GameID')
  659. ->first();
  660. $IDWhiteUser = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $userID)->first();
  661. return view('admin.global.user_update', ['list' => $list, 'IDWhiteUser' => $IDWhiteUser]);
  662. } elseif ($request->isMethod('post')) {
  663. $SpreaderID = (int)$request->post('SpreaderID') ?: "";
  664. $UserID = $request->post('UserID');
  665. $Nullity = $request->post('Nullity', '');
  666. $official = $request->post('official');
  667. $query = $IDWhiteUser = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $UserID)->first();
  668. $arr = [];
  669. if (!empty(trim($SpreaderID))) {
  670. $account = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('GameID', $SpreaderID)->selectRaw('UserID')->first();
  671. $arr['SpreaderID'] = $account->UserID;
  672. }
  673. if ($Nullity !== "" || $Nullity === 0) {
  674. $arr['Nullity'] = $Nullity;
  675. }
  676. try {
  677. DB::table('QPAccountsDB.dbo.AccountsInfo')->where('UserID', $UserID)->update($arr);
  678. if ($official == 1) { // 设置官方账号
  679. if (!$query) {
  680. DB::table('QPAccountsDB.dbo.IDWhiteUser')->insert(['UserID' => $UserID]);
  681. }
  682. } else {
  683. if ($query) {
  684. DB::table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $UserID)->delete();
  685. }
  686. }
  687. } catch (\Exception $e) {
  688. return $this->json(500, '修改失败');
  689. }
  690. return $this->json(200, '修改成功');
  691. }
  692. }
  693. //封号1 解封2
  694. public function ban(Request $request)
  695. {
  696. $url = config('transfer.stock')['url'] . 'banAccounts';
  697. try {
  698. if ($request->ban == 1) {
  699. $id = explode(',', $request->id);
  700. DB::table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->update(['Nullity' => 1]);
  701. // 查询用户gameId
  702. $gameID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->select('GameID')->get();
  703. $data = [];
  704. foreach ($gameID as $value) {
  705. $data[] = [
  706. 'GameID' => $value->GameID,
  707. 'CreateDate' => date('Y-m-d H:i:s'),
  708. 'State' => 0
  709. ];
  710. // 给中转服发送通知
  711. $admin = session('admin');
  712. $account = $admin->account ?: '';
  713. $password = $admin->password ?: '';
  714. $yc_data = [
  715. 'accounts' => $account,
  716. 'passworld' => $password,
  717. 'gameID' => $value->GameID,
  718. ];
  719. $build_query = $url . '?' . http_build_query($yc_data);
  720. $output = (new HttpCurl())->curl_get($build_query);
  721. }
  722. // 添加封号
  723. DB::table('QPAccountsDB.dbo.BanAccounts')->insert($data);
  724. } elseif ($request->ban == 2) {
  725. // 给中转服发送通知
  726. $admin = session('admin');
  727. $account = $admin->account ?: '';
  728. $password = $admin->password ?: '';
  729. $yc_data = [
  730. 'accounts' => $account,
  731. 'passworld' => $password,
  732. 'gameID' => 0,
  733. ];
  734. $build_query = $url . '?' . http_build_query($yc_data);
  735. $output = (new HttpCurl())->curl_get($build_query);
  736. $id = explode(',', $request->id);
  737. DB::table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->update(['Nullity' => 0]);
  738. } else {
  739. return $this->json(400, '操作失败');
  740. }
  741. } catch (\Exception $e) {
  742. return $this->json(500, $e->getMessage());
  743. }
  744. return $this->json(200, '操作成功');
  745. }
  746. //用户列表 ID跳转
  747. public function id_find(Request $request)
  748. {
  749. $UserID = $request->UserID;
  750. $OpenPage = $request->OpenPage ?: '';
  751. $r = (new GlobalLogicController())->id_find($UserID, $OpenPage);
  752. return view('admin.global.id_list', $r);
  753. }
  754. //关联 姓名 设备 IP
  755. public function join(Request $request)
  756. {
  757. $id = $request->id;
  758. if ($id == 1) {
  759. $ip = $request->RegisterIP;
  760. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  761. ->where('RegisterIP', $ip)
  762. ->where('IsAndroid', 0)
  763. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,UserID')
  764. ->paginate(100);
  765. return view('admin.global.join_ip', ['list' => $list, 'id' => $id, 'ip' => $ip]);
  766. } elseif ($id == 2) {
  767. $userid = $request->UserID;
  768. $mac = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics')
  769. ->where('UserID', $userid)
  770. ->where('mac', '<>','')
  771. ->pluck('mac')->toArray();
  772. $mac=array_unique($mac);
  773. $list=[];
  774. if($mac) {
  775. $userids= DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics')
  776. ->whereIn('mac', $mac)
  777. ->pluck('UserID')
  778. ->toArray();
  779. $userids=array_unique($userids);
  780. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  781. ->whereIn('UserID', $userids)
  782. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,UserID')
  783. ->paginate(100);
  784. }
  785. foreach ($list as &$value) {
  786. $value->login_count = DB::table('QPRecordDB.dbo.RecordUserLogin')->where('UserID', $value->UserID)->count();
  787. }
  788. return view('admin.global.join_facility', ['list' => $list, 'mac' => implode(",",$mac), 'id' => $id]);
  789. } elseif ($id == 3) {
  790. $BankNo = $request->Phone;
  791. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone as di')
  792. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
  793. ->where('di.PhoneNum', $BankNo)
  794. ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,ai.Channel,ai.NickName,ai.UserID')
  795. ->paginate(10);
  796. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
  797. } elseif ($id == 4) {
  798. $BankNo = $request->BankUserName;
  799. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
  800. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
  801. ->where('di.BankUserName', $BankNo)
  802. ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,Channel,ai.NickName,ai.UserID')
  803. ->paginate(10);
  804. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
  805. } elseif ($id == 5) {
  806. $BankNo = $request->EmailAddress;
  807. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
  808. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
  809. ->where('di.EmailAddress', $BankNo)
  810. ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,Channel,ai.NickName,ai.UserID')
  811. ->paginate(100);
  812. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
  813. } elseif ($id == 6) { // 关联IP
  814. $UserID = $request->UserID;
  815. $UserIDs = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics as rs')
  816. ->join('QPRecordDB.dbo.RecordUserLogonStatistics as rs1', function ($join) {
  817. $join->on('rs.LogonIP', 'rs1.LogonIP');
  818. })
  819. ->where('rs.UserID', $UserID)
  820. ->select('rs1.UserID')
  821. ->groupBy('rs1.UserID')
  822. ->limit(2000)
  823. ->pluck('rs1.UserID');
  824. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  825. ->whereIn('ai.UserID', $UserIDs)
  826. ->where('IsAndroid', 0)
  827. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,ai.UserID')
  828. ->paginate(1000);
  829. return view('admin.global.join_LastLogonIP', ['list' => $list, 'id' => $id, 'UserID' => $UserID]);
  830. } elseif ($id == 7) { // 登录IP记录
  831. $UserID = $request->UserID;
  832. $list = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics as rls')
  833. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'rls.UserID', 'ai.UserID')
  834. ->where('rls.UserID', $UserID)
  835. ->where('IsAndroid', 0)
  836. ->select('rls.UserID','LastLogonDate', 'LogonIP', 'LastDate', 'ai.GameID', 'NickName', 'Channel')
  837. ->orderByDesc('LastDate')
  838. ->paginate(1000);
  839. return view('admin.global.join_login_ip', ['list' => $list, 'UserID' => $UserID, 'id' => $id]);
  840. } elseif ($id == 8) { // 关联cpf
  841. $UserID = $request->UserID;
  842. $cpf=Cpf::getCpf($UserID,1);
  843. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  844. ->whereIn('ai.UserID', Cpf::getCpf($UserID))
  845. ->where('IsAndroid', 0)
  846. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,ai.UserID')
  847. ->paginate(1000);
  848. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'UserID' => $UserID, 'BankNo' => implode(",",$cpf)]);
  849. }
  850. }
  851. //用户单控系统
  852. public function dk(Request $request)
  853. {
  854. $start_time = $request->start_time ?: date('Y-m-d 00:00:00');
  855. $end_time = $request->end_time ?: date('Y-m-d 23:59:59');
  856. $date = $request->date ?: '';
  857. $r = (new GlobalLogicController())->dk($start_time, $end_time, $date);
  858. return view('admin.global.dk', $r);
  859. }
  860. //用户单控系统-详细用户列表
  861. public function dk_userlist(Request $request)
  862. {
  863. $GameID = (int)$request->GameID ?: "";
  864. $SpreaderID = (int)$request->SpreaderID ?: "";
  865. $NickName = (string)$request->NickName ?: "";
  866. $start_time = $request->start_time ?: "";
  867. $end_time = $request->end_time ?: "";
  868. $user_label = $request->label ?: "";
  869. $label_sort = $request->label_sort ?: "";
  870. $is_line = $request->is_line ?: "";
  871. $game_room = $request->game_room ?: "";
  872. $UserScoreControl = $request->UserScoreControl ?: "";
  873. $ScoreSort = $request->Score ?: "";
  874. $amountSort = $request->amount ?: "";
  875. $sort_tx = $request->sort_tx ?: "";
  876. $sort_date = $request->sort_date ?: "";
  877. $ChangeScoreSort = $request->ChangeScore ?: '';
  878. $Channel = $request->Channel;
  879. $ServerNameSort = $request->ServerNameSort ?: '';
  880. $start_time = str_replace('T', ' ', $start_time);
  881. $end_time = str_replace('T', ' ', $end_time);
  882. $list = (new GlobalUser())->dk_userlist($GameID, $SpreaderID, $NickName, $start_time, $end_time, $user_label, $is_line, $game_room, $UserScoreControl, $ScoreSort, $amountSort, $sort_tx, $sort_date, $ChangeScoreSort, $Channel, $label_sort, $ServerNameSort);
  883. $game_room_line = DB::connection('read')->table(TableName::QPPlatformDB() . 'GameRoomInfo')->select('ServerName', 'ServerID')->get();
  884. $allChannel = DB::connection('read')->table(TableName::QPPlatformDB() . 'ChannelPackageName')->pluck('Channel');
  885. $page = Paginator::resolveCurrentPage('page');
  886. $start_time = \App\Http\helper\Helper::timeChange($start_time);
  887. $end_time = \App\Http\helper\Helper::timeChange($end_time);
  888. $user_labels = [1 => '普通会员', 2 => '首充会员', 3 => '复充会员', 4 => '优质会员', 5 => '尊贵会员', 6 => '发育不良', 7 => '异常观察', 8 => '重点关注', 20 => '其他1', 21 => '其他2'];
  889. return view('admin.global.dk_userlist', compact('list', 'GameID', 'SpreaderID', 'NickName', 'start_time', 'end_time', 'user_label'
  890. , 'label_sort', 'is_line', 'game_room', 'UserScoreControl', 'ScoreSort', 'amountSort', 'sort_tx', 'sort_date', 'ChangeScoreSort', 'Channel', 'ServerNameSort'
  891. , 'game_room_line', 'allChannel', 'page', 'user_labels'
  892. ));
  893. }
  894. //用户单控系统-详细用户列表 修改
  895. public function dk_userlist_edit(Request $request)
  896. {
  897. $UserID = $request->UserID ?? '';
  898. $TempID = $request->TempID ?? '';
  899. $ControlModel = new Control();
  900. $build_sql = DB::connection('write')->table('QPTreasureDB.dbo.UserScoreControl');
  901. if ($request->isMethod('post')) {
  902. $post = $request->post();
  903. if (!empty($post['Template'])) {
  904. $cc=new ControlController();
  905. $Template=(array)$cc->getConfigByID($post['Template']);
  906. $post = array_merge($Template, $post);
  907. }
  908. // if (!empty($post['TPBai']) && empty($post['TpBaiGear'])) {
  909. // return apiReturnFail('TP百人额度未设置');
  910. // }
  911. // if (!empty($post['ABBai']) && empty($post['ABBaiGear'])) {
  912. // return apiReturnFail('A&B额度未设置');
  913. // }
  914. // if (empty($post['Template']) && empty($post['TP']) && empty($post['TPAK47']) && empty($post['TPJOKER']) && empty($post['Rummy5']) && empty($post['Rummy2'])) {
  915. // return apiReturnFail('概率没有配置,无法提交!');
  916. // }
  917. DB::connection('write')->table('QPTreasureDB.dbo.UserControlServer')->where('UserID', $UserID)->delete();
  918. $ControlScore = $post['ControlScore'];
  919. $Remarks = $post['Remarks'];
  920. $admin_id = session('admin')->id;
  921. $admin_user = DB::connection('read')->table('agent.dbo.admin_users')->where('id', $admin_id)->first();
  922. /*管理员彩金控制*/
  923. if ($ControlScore > 0) {
  924. if ($admin_user->recharge_amount < $ControlScore) return apiReturnFail('管理员彩金额度不足!');
  925. AdminScore::add_score($admin_user, abs($ControlScore), 2);
  926. }
  927. /*用户单控记录添加*/
  928. $GameData = (new Control())->GameData;
  929. foreach ($post as $key => &$value) {
  930. if ($key == 'ABBaiGear') {
  931. continue;
  932. }
  933. if (!isset($GameData[$key])) {
  934. unset($post[$key]);
  935. }
  936. }
  937. // 控制分数
  938. $prefix = $ControlScore < 0 ? '输' : '赢';
  939. // 概率
  940. $str = '';
  941. foreach ($post as $key => $value) {
  942. $str .= $key . ':' . number_float($value) . '% ,';
  943. }
  944. $content = $prefix . $ControlScore . '/' . rtrim($str, ',');
  945. $score = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
  946. ControlRecord::record_add($UserID, $admin_id, $content, $score);
  947. // 用户控制游戏和场次
  948. $ControlModel->userControl($post, $UserID);
  949. $data = [
  950. 'ControlScore' => (int)($ControlScore * NumConfig::NUM_VALUE),
  951. 'EffectiveScore' => 0,
  952. 'ControlKindID' => -1,
  953. 'Remarks' => $Remarks,
  954. 'InsertDate' => date('Y-m-d H:i:s'),
  955. 'ControlRadian' => 0,
  956. 'UserID'=>$UserID
  957. ];
  958. $build_sql->updateOrInsert(['UserID' => $UserID], $data);
  959. // 埋点,执行存储过程
  960. // 执行存储过程,-- 用户单控标签
  961. StoredProcedure::user_label($UserID, 3);
  962. return $this->json(200, "修改成功");
  963. }
  964. $ControlScore = $build_sql->where('UserID', $UserID)->first()->ControlScore ?? '0';
  965. $GameKindItem = DB::connection('read')->table('QPPlatformDB.dbo.GameKindItem')->pluck('KindID')->toArray();
  966. $UserControlKind = DB::connection('write')->table('QPTreasureDB.dbo.UserControlKind')
  967. ->where('UserID', $UserID)
  968. ->selectRaw('(ControlRadian) ControlRadian,KindID')
  969. ->pluck('ControlRadian', 'KindID')->toArray();
  970. $GameData = array_flip($ControlModel->GameData);
  971. foreach ($GameKindItem as $value) {
  972. if (!empty($GameData[$value] ?? '')) $UserControlKind[$GameData[$value]] = $UserControlKind[$value] ?? '';
  973. }
  974. // $TPBai = $UserControlKind['TPBai'];
  975. // $ABBai = $UserControlKind['ABBai'];
  976. // $substr = substr($TPBai, -3);
  977. // $UserControlKind['TPBai'] = (int)$substr;
  978. // $UserControlKind['TPBaiGear'] = !empty($TPBai) ? ($TPBai - $substr) / 1000 : '';
  979. // $substr = substr($ABBai, -3);
  980. // $UserControlKind['ABBai'] = (int)$substr;
  981. // $UserControlKind['ABBaiGear'] = !empty($ABBai) ? ($ABBai - $substr) / 1000 : '';
  982. $amount = DB::connection('write')->table('agent.dbo.order')
  983. ->where('user_id', $UserID)
  984. ->where('pay_status', 1)
  985. ->orderByDesc('pay_at')
  986. ->first()->amount ?? '';
  987. !empty($amount) && $amount = (int)($amount / 100);
  988. // $ControlScore = empty($ControlScore) ? $amount : $ControlScore / NumConfig::NUM_VALUE;
  989. $ControlScore = $ControlScore / NumConfig::NUM_VALUE;
  990. // $list = DB::connection('write')->table('agent.dbo.ControlConfig')->get();
  991. $cc=new ControlController();
  992. $list=$cc->getList();
  993. // $TpBaiGear = DB::connection('write')->table('agent.dbo.ControlGear')->where('KindID', 2010)->get();
  994. $ABBai = DB::connection('write')->table('agent.dbo.ControlGear')->where('KindID', 2012)->get();
  995. $ControlModel = new Control();
  996. $GameDataText=$ControlModel->GameDataText;
  997. $data = compact('UserID', 'UserControlKind', 'ControlScore', 'list', 'TempID', 'ABBai','GameDataText');
  998. return view('admin.global.dk_userlist_edit', $data);
  999. }
  1000. // 取消单控
  1001. public function cancel_dk(Request $request)
  1002. {
  1003. $UserID = $request->id ?? '';
  1004. $build_sql = DB::connection('write')->table('QPTreasureDB.dbo.UserScoreControl');
  1005. //$query = $build_sql->where('UserID',$UserID)->first();
  1006. $res = $build_sql->where('UserID', $UserID)->delete();
  1007. /*用户单控记录添加*/
  1008. $admin_id = session()->get('admin')->id;
  1009. if ($res) {
  1010. $score = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
  1011. ControlRecord::record_add($UserID, $admin_id, '取消单控', $score);
  1012. // 埋点,执行存储过程
  1013. // 执行存储过程,-- 用户单控标签
  1014. StoredProcedure::user_label($UserID, 5);
  1015. return apiReturnSuc("已取消单控");
  1016. }
  1017. return apiReturnFail('取消单控失败');
  1018. }
  1019. //输赢报表
  1020. public function winloser(Request $request)
  1021. {
  1022. $UserID = (int)trim($request->UserID) ?: '';
  1023. $UniqueCode = trim($request->UniqueCode) ?: '';
  1024. $room = trim($request->room) ?: '';
  1025. $searchGame = trim($request->searchGame) ?: '';
  1026. $start_time = trim($request->start_time) ?: '';
  1027. $end_time = trim($request->end_time) ?: '';
  1028. $start_time = str_replace('T', ' ', $start_time);
  1029. $end_time = str_replace('T', ' ', $end_time);
  1030. $excel = $request->excel ?: '';
  1031. $id_list = $request->id_list ?: '';
  1032. $ChangeScoreMin = $request->ChangeScoreMin;
  1033. $ChangeScoreMax = $request->ChangeScoreMax;
  1034. $PlayGames = $request->PlayGames ?: '';
  1035. $ChangeScoreSort = $request->ChangeScoreSort ?: '';
  1036. $afterScoreSort = $request->afterScoreSort ?: '';
  1037. $Jump = (int)$request->Jump ?? 0;
  1038. $result = (new GlobalLogicController())->winloser($UserID, $UniqueCode, $room, $start_time, $end_time, $excel, $id_list, $ChangeScoreMin, $ChangeScoreMax, $ChangeScoreSort, $afterScoreSort, $searchGame);
  1039. $Jump += 1;
  1040. $result['Jump'] = $Jump;
  1041. return view('admin.global.win_loser_list', $result);
  1042. }
  1043. // 查看战绩
  1044. public function game_record(Request $request)
  1045. {
  1046. $UniqueCode = $request->UniqueCode ?? '';
  1047. $gameId = $request->gameId ?? '';
  1048. $month = $request->month ?? '';
  1049. $result = (new GlobalLogicController())->game_record($UniqueCode, $gameId, $month);
  1050. return view('admin.global.game_record', $result);
  1051. }
  1052. //推广员奖励报表
  1053. public function reward(Request $request)
  1054. {
  1055. $UserID = (int)trim($request->UserID) ?: 0;
  1056. $SpreaderID = (int)trim($request->SpreaderID) ?: 0;
  1057. $start_time = trim($request->start_time) ?? '';
  1058. $end_time = trim($request->end_time) ?? '';
  1059. $Type = trim($request->Type) ?? '';
  1060. $start_time = str_replace('T', ' ', $start_time);
  1061. $end_time = str_replace('T', ' ', $end_time);
  1062. $result = (new GlobalLogicController())->reward($UserID, $SpreaderID, $start_time, $end_time, $Type);
  1063. return view('admin.global.reward_list', $result);
  1064. }
  1065. // 奖励来源玩家
  1066. public function userSource(Request $request)
  1067. {
  1068. $orderIds = $request->orderIds ?: '';
  1069. $Type = $request->Type ?: '';
  1070. $Id = $request->Id ?: '';
  1071. $GameID = $request->GameID ?: '';
  1072. switch ($Type) {
  1073. case 1:
  1074. $OrderIDs = explode(',', $orderIds);
  1075. $list = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
  1076. ->whereIn('OrderID', $OrderIDs)
  1077. ->where('OrderID', '>', 0)
  1078. ->where('Type', $Type)
  1079. ->paginate(10);
  1080. foreach ($list as &$value) {
  1081. $value->toGold /= NumConfig::NUM_VALUE;
  1082. }
  1083. unset($value);
  1084. $view = 'admin.extension.user_source';
  1085. break;
  1086. case 2:
  1087. break;
  1088. case 3:
  1089. $list = DB::connection('read')->table('QPRecordDB.dbo.RecordUserAgent as ua')
  1090. ->join('QPAccountsDB.dbo.accountsInfo as ai', 'ua.UserID', 'ai.UserID')
  1091. ->leftJoin('QPAccountsDB.dbo.accountsInfo as ain', 'ain.UserID', '=', 'ua.SourceUserID')
  1092. ->select('ai.GameID', 'ain.GameID as SourceUserID', 'DirectRebate', 'SendTime', 'OrderSn', 'ain.UserID', 'ua.Level')
  1093. ->where('ua.Id', $Id)
  1094. ->orderBy('SendTime', 'desc')
  1095. ->paginate(10);
  1096. foreach ($list as &$value) {
  1097. $value->DirectRebate = number_float($value->DirectRebate / NumConfig::NUM_VALUE);
  1098. }
  1099. $view = 'admin.extension.user_recharge_source';
  1100. break;
  1101. }
  1102. return view($view, compact('list', 'Type', 'orderIds', 'GameID'));
  1103. }
  1104. // 设置房间开关
  1105. public function update(Request $request)
  1106. {
  1107. $server_id = $request->post('server_id');
  1108. $type = $request->post('type');
  1109. $Nullity = ($type == 'on') ? 0 : 1;
  1110. DB::table('QPPlatformDB.dbo.GameRoomInfo')
  1111. ->where('ServerID', $server_id)
  1112. ->update(['Nullity' => $Nullity]);
  1113. // 向服务端发送通知
  1114. $url = config('transfer.stock')['url'] . 'serverState';
  1115. $data = [
  1116. 'serverid' => $server_id,
  1117. 'state' => $Nullity,
  1118. ];
  1119. (new HttpCurl())->service($url, $data);
  1120. return apiReturnSuc();
  1121. }
  1122. // 查看对局信息
  1123. public function match_information($RoomCode)
  1124. {
  1125. $list = cache()->remember('match_information_' . $RoomCode, 10, function () use ($RoomCode) {
  1126. return DB::connection('game')->table(TableName::QPRecordDB() . 'RecordUniqueScoreCode')
  1127. ->where('uniquescorecode', $RoomCode)
  1128. ->get();
  1129. });
  1130. if (count($list) < 1 || empty($list)) {
  1131. $info = DB::connection('game')->table(TableName::QPRecordDB() . 'RecordGamePlayNew')
  1132. ->where('RoomCode', $RoomCode)
  1133. ->value('RecordJson');
  1134. try {
  1135. $data = json_decode($info, true);
  1136. if (json_last_error() !== JSON_ERROR_NONE) {
  1137. echo "<p>JSON 解码出错:" . json_last_error_msg() . "</p>";
  1138. } else {
  1139. // 4. 美化输出,保留中文
  1140. echo '<pre>' . htmlspecialchars(json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT)) . '</pre>';
  1141. }
  1142. //echo $this->jsonFormat($info);
  1143. } catch (\Exception $exception) {
  1144. dump($info);
  1145. }
  1146. } else {
  1147. header('Content-Type: text/html; charset=utf-8');
  1148. foreach ($list as $value) {
  1149. $uniquecode = $value->uniquecode;
  1150. $info = cache()->remember('match_information_info_' . $uniquecode, 10, function () use ($uniquecode) {
  1151. return DB::connection('game')->table(TableName::QPRecordDB() . 'RecordGamePlayNew')
  1152. ->where('RoomCode', $uniquecode)
  1153. ->value('RecordJson');
  1154. });
  1155. try {
  1156. // $info = \GuzzleHttp\json_decode($info, true);
  1157. // echo "<script>document.write('$info')</script>";
  1158. // dump($info);
  1159. //echo $this->jsonFormat($info);
  1160. // 3. 解析 JSON
  1161. $data = json_decode($info, true);
  1162. if (json_last_error() !== JSON_ERROR_NONE) {
  1163. echo "<p>JSON 解码出错:" . json_last_error_msg() . "</p>";
  1164. } else {
  1165. echo '<pre>' . htmlspecialchars(json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT)) . '</pre>';
  1166. }
  1167. } catch (\Exception $exception) {
  1168. dump($info);
  1169. }
  1170. }
  1171. }
  1172. }
  1173. public function jsonFormat($data)
  1174. {
  1175. // 对数组中每个元素递归进行urlencode操作,保护中文字符
  1176. array_walk_recursive($data, function (&$val) {
  1177. if ($val !== true && $val !== false && $val !== null) {
  1178. $val = urlencode($val);
  1179. }
  1180. });
  1181. // json encode
  1182. $data = json_encode($data);
  1183. // 将urlencode的内容进行urldecode
  1184. $data = urldecode($data);
  1185. // 缩进处理
  1186. $ret = '';
  1187. $pos = 0;
  1188. $length = strlen($data);
  1189. $indent = isset($indent) ? $indent : ' ';
  1190. $newline = "\n";
  1191. $prevchar = '';
  1192. $outofquotes = true;
  1193. for ($i = 0; $i <= $length; $i++) {
  1194. $char = substr($data, $i, 1);
  1195. if ($char == '"' && $prevchar != '\\') {
  1196. $outofquotes = !$outofquotes;
  1197. } elseif (($char == '}' || $char == ']') && $outofquotes) {
  1198. $ret .= $newline;
  1199. $pos--;
  1200. for ($j = 0; $j < $pos; $j++) {
  1201. $ret .= $indent;
  1202. }
  1203. }
  1204. $ret .= $char;
  1205. if (($char == ',' || $char == '{' || $char == '[') && $outofquotes) {
  1206. $ret .= $newline;
  1207. if ($char == '{' || $char == '[') {
  1208. $pos++;
  1209. }
  1210. for ($j = 0; $j < $pos; $j++) {
  1211. $ret .= $indent;
  1212. }
  1213. }
  1214. $prevchar = $char;
  1215. }
  1216. return $ret;
  1217. }
  1218. // 在线用户
  1219. public function online_user(Request $request)
  1220. {
  1221. $index = $request->index ?: 0;
  1222. $globalService = new GlobalUser();
  1223. $onLineUser = $globalService->onLineUser($index);
  1224. $pageNum = 10;
  1225. $total = (isset($onLineUser['total']) && !empty($onLineUser)) ? $onLineUser['total'] : 0;
  1226. $link = 'http://' . $request->getHttpHost() . '/admin/global/online_user?index=';
  1227. $service = new Paging($pageNum, $total, $index, ($total / $pageNum), $link);
  1228. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1229. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as lck', 'ai.UserID', 'lck.UserID')
  1230. ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as gi', 'lck.ServerID', '=', 'gi.ServerID')
  1231. ->whereIn('ai.UserID', $onLineUser['UserIDs'])
  1232. ->select('ai.GameID', 'NickName', 'ai.UserID', 'gi.ServerName')->get();
  1233. $page = $service->subPageCss2();
  1234. return view('admin.global.online_user', [
  1235. 'list' => $list,
  1236. 'pages' => $page,
  1237. 'total' => $total
  1238. ]);
  1239. }
  1240. // 无感维护开关
  1241. public function GameRoomSwitch_view()
  1242. {
  1243. $list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
  1244. //->leftJoin('QPRecordDB.dbo.RecordGameInfo as ri', 'gi.ServerID', '=', 'ri.ServerID')
  1245. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gl', function ($query) {
  1246. $query->on('gl.ServerID', 'gi.ServerID')->selectRaw('gl.ServerID')->groupBy('ServerID')->whereDate('CollectDate', date('Y-m-d'));
  1247. })
  1248. ->whereIn('gi.GameID', [1005, 2030, 2050])
  1249. ->whereNotIn('gi.ServerID', [32, 33, 39])
  1250. ->selectRaw('gi.Nullity,gi.GameID,gi.SortID,gi.ServerName,gi.ServerID,gi.RoomStock,count(DISTINCT gl.UserID) as game_count')
  1251. ->groupBy('gi.GameID', 'gi.SortID', 'gi.ServerName', 'gi.ServerID', 'gi.RoomStock', 'gi.Nullity')
  1252. ->get();
  1253. return view('admin.global.game_room_switch', [
  1254. 'list' => $list
  1255. ]);
  1256. }
  1257. // 无感操作开关操作
  1258. public function GameRoomSwitch(Request $request)
  1259. {
  1260. $serverID = $request->serverID ?: '';
  1261. $type = $request->type ?: '';
  1262. $serverID = explode(',', rtrim($serverID, ','));
  1263. if (empty($type)) {
  1264. return apiReturnFail('缺少操作类型');
  1265. }
  1266. switch ($type) {
  1267. case 'on' :
  1268. $Nullity = 0;
  1269. break;
  1270. case 'off':
  1271. $Nullity = 1;
  1272. break;
  1273. }
  1274. DB::table('QPPlatformDB.dbo.GameRoomInfo')->whereIn('ServerID', $serverID)->update(['Nullity' => $Nullity]);
  1275. return apiReturnSuc();
  1276. }
  1277. // 关闭禁止提现标签
  1278. public function relieve($id)
  1279. {
  1280. // 用户标签
  1281. $getUserTab = StoredProcedure::getUserTab($id);
  1282. $TabType = $getUserTab[0]->TabType ?? '';
  1283. if (!empty($getUserTab) && $TabType == 1) {
  1284. $Type12 = $getUserTab[0]->Type12 ?? 0;
  1285. if (in_array($Type12, [1301, 1302, 1303])) {
  1286. DB::table('QPAccountsDB.dbo.AccountWithDrawInfo')
  1287. ->where('UserID', $id)
  1288. ->update(['Switch' => 0]);
  1289. }
  1290. }
  1291. return apiReturnSuc();
  1292. }
  1293. // 单控用户备注
  1294. public function remarks(Request $request, $id)
  1295. {
  1296. $remark = $request->remark ?: '';
  1297. DB::table('QPAccountsDB.dbo.IndividualDatum')
  1298. ->where('UserID', $id)
  1299. ->update(['UserNote' => $remark]);
  1300. return apiReturnSuc();
  1301. }
  1302. // 模拟器开关
  1303. public function androidCheck(Request $request)
  1304. {
  1305. if ($request->isMethod('post')) {
  1306. $StatusValue = (int)$request->StatusValue;
  1307. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  1308. ->where('StatusName', 'AndroidCheck')
  1309. ->update(['StatusValue' => $StatusValue]);
  1310. $admin_id = session('admin')->id;
  1311. CreateLog::SystemStatusInfo_log($admin_id, 'AgentCommisionState');
  1312. return apiReturnSuc();
  1313. } else {
  1314. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  1315. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', 'si.StatusName', 'log.StatusName')
  1316. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  1317. ->select('StatusString', 'StatusValue', 'account', 'create_at')
  1318. ->where('si.StatusName', 'AndroidCheck')
  1319. ->get();
  1320. return view('admin.global.androidCheck', [
  1321. 'list' => $list
  1322. ]);
  1323. }
  1324. }
  1325. // 推广赚金池数值修改
  1326. public function agent_reward(Request $request)
  1327. {
  1328. if ($request->method() == 'POST') {
  1329. $val = abs($request->StatusValue) ?: 0;
  1330. $val *= 100;
  1331. $r = DB::table('QPAccountsDB.dbo.SystemAgentReward')->update(['InitReward' => $val]);
  1332. if ($r) {
  1333. return apiReturnSuc();
  1334. }
  1335. return apiReturnFail('推广赚金池数值修改失败');
  1336. } else {
  1337. $value = DB::table('QPAccountsDB.dbo.SystemAgentReward')->value('InitReward');
  1338. $value = $value / 100;
  1339. return view('admin.global.agent_reward', compact('value'));
  1340. }
  1341. }
  1342. // 修改用户标签
  1343. public function update_label(Request $request, $id)
  1344. {
  1345. $type = $request->type ?: '';
  1346. if ($request->isMethod('post')) {
  1347. switch ($type) {
  1348. case 1:
  1349. StoredProcedure::user_label($id, 8);
  1350. break;
  1351. case 20:
  1352. StoredProcedure::user_label($id, 6);
  1353. break;
  1354. case 21:
  1355. StoredProcedure::user_label($id, 7);
  1356. break;
  1357. }
  1358. return apiReturnSuc();
  1359. } else {
  1360. $type = DB::connection('read')->table('QPAccountsDB.dbo.AccountLabelDanControlLabel')->where('UserID', $id)->value('type');
  1361. $label = [
  1362. 20 => '其他1',
  1363. 21 => '其他2'
  1364. ];
  1365. return view('admin.global.update_label', [
  1366. 'label' => $label,
  1367. 'type' => $type,
  1368. 'UserID' => $id
  1369. ]);
  1370. }
  1371. }
  1372. // 推广佣金开关
  1373. public function AgentCommisionState(Request $request)
  1374. {
  1375. if ($request->isMethod('post')) {
  1376. $StatusValue = (int)$request->StatusValue;
  1377. DB::table('QPAccountsDB.dbo.SystemStatusInfo')
  1378. ->where('StatusName', 'AgentCommisionState')
  1379. ->update(['StatusValue' => $StatusValue]);
  1380. $admin_id = session('admin')->id;
  1381. CreateLog::SystemStatusInfo_log($admin_id, 'AgentCommisionState');
  1382. return apiReturnSuc();
  1383. } else {
  1384. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  1385. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', 'si.StatusName', 'log.StatusName')
  1386. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  1387. ->select('StatusString', 'StatusValue', 'account', 'create_at')
  1388. ->where('si.StatusName', 'AgentCommisionState')
  1389. ->get();
  1390. return view('admin.global.agentCommisionState', [
  1391. 'list' => $list
  1392. ]);
  1393. }
  1394. }
  1395. // 清理玩家卡房间
  1396. public function deleteRoom($UserID)
  1397. {
  1398. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreLocker')
  1399. ->where('UserID', $UserID)
  1400. ->delete();
  1401. return apiReturnSuc();
  1402. }
  1403. public function control_statistics()
  1404. {
  1405. // +-------------------------------------
  1406. // 普通玩家
  1407. // +-------------------------------------
  1408. $now_time = '2021-11-17 14:25:00';
  1409. // 普通玩家 -- 控制分数
  1410. $ptAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1411. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1412. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1413. ->whereNull('iu.UserID')
  1414. ->where('ControlDate', '>', $now_time)
  1415. ->where('ControlState', 0)
  1416. ->selectRaw('sum(abs(ControlScore)) / 100 ControlScore')
  1417. ->first()->ControlScore ?? 0;
  1418. // 普通玩家 -- 控制赢分数
  1419. $ptWinAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1420. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1421. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1422. ->whereNull('iu.UserID')
  1423. ->where('ControlDate', '>', $now_time)
  1424. ->where('ControlState', 0)
  1425. ->where('ControlScore', '>', 0)
  1426. ->selectRaw('sum(ControlScore) /100 ControlScore,sum(EffectiveScore) /100 EffectiveScore')
  1427. ->first();
  1428. // 普通玩家 -- 控制输分数
  1429. $ptLoseAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1430. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1431. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1432. ->whereNull('iu.UserID')
  1433. ->where('ControlDate', '>', $now_time)
  1434. ->where('ControlState', 0)
  1435. ->where('ControlScore', '<', 0)
  1436. ->selectRaw('sum(ControlScore) / 100 ControlScore')
  1437. ->first()->ControlScore ?? 0;
  1438. // +-------------------------------------
  1439. // 分界线--------------------------------官方玩家-----------------------------------------------------
  1440. // +-------------------------------------
  1441. // 官方玩家 -- 控制分数
  1442. $gfAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1443. ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1444. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1445. ->where('ControlState', 0)
  1446. ->where('ControlDate', '>', $now_time)
  1447. ->selectRaw('sum(abs(ControlScore)) / 100 ControlScore')
  1448. ->first()->ControlScore ?? 0;
  1449. // 官方玩家 -- 控制赢分数
  1450. $gfWinAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1451. ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1452. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1453. ->where('ControlState', 0)
  1454. ->where('ControlDate', '>', $now_time)
  1455. ->where('ControlScore', '>', 0)
  1456. ->selectRaw('sum(ControlScore) / 100 ControlScore,sum(EffectiveScore) /100 EffectiveScore')
  1457. ->first();
  1458. // 官方玩家 -- 控制输分数
  1459. $gfLoseAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1460. ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1461. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1462. ->where('ControlState', 0)
  1463. ->where('ControlDate', '>', $now_time)
  1464. ->where('ControlScore', '<', 0)
  1465. ->selectRaw('sum(ControlScore) / 100 ControlScore')
  1466. ->first()->ControlScore ?? 0;
  1467. $ptTotal = $ptLoseAccounts + ($ptWinAccounts->EffectiveScore ?? 0);
  1468. $gfTotal = $gfLoseAccounts + ($gfWinAccounts->EffectiveScore ?? 0);
  1469. $data = compact('ptAccounts', 'ptLoseAccounts', 'ptWinAccounts', 'gfAccounts', 'gfLoseAccounts', 'gfWinAccounts', 'ptTotal', 'gfTotal');
  1470. return view('admin.global.control_statistics', $data);
  1471. }
  1472. // 用户头像审核列表
  1473. public function headAudit(Request $request)
  1474. {
  1475. $GameID = $request->GameID ?: '';
  1476. $start_time = $request->start_time ?: '';
  1477. $end_time = $request->end_time ?: '';
  1478. $where[] = ['Status', 0];
  1479. if (!empty($UserID)) {
  1480. $UserID = AccountsInfo::GetUserID($GameID);
  1481. $where[] = ['ua.UserID', $UserID];
  1482. }
  1483. if (!empty($start_time)) $where[] = ['CreateTime', '>=', $start_time];
  1484. if (!empty($end_time)) $where[] = ['CreateTime', '<=', $end_time];
  1485. $list = DB::table(TableName::agent() . 'UserHeadAuditoria as ua')
  1486. ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ua.UserID', 'ai.UserID')
  1487. ->select('Image', 'GameID', 'ua.UserID', 'ua.CreateTime')
  1488. ->where($where)->paginate(10);
  1489. return view('admin.global.head_audit', compact('list', 'GameID', 'start_time', 'end_time'));
  1490. }
  1491. // 头像审核
  1492. public function headAuditUpdate(Request $request, $UserID)
  1493. {
  1494. $status = $request->Status;
  1495. DB::table(TableName::agent() . 'UserHeadAuditoria')
  1496. ->where('UserID', $UserID)
  1497. ->update(['Status' => $status]);
  1498. if ($status == 1) {
  1499. $Image = DB::table(TableName::agent() . 'UserHeadAuditoria')->where('UserID', $UserID)->value('Image');
  1500. DB::connection('write')->table(TableName::QPAccountsDB() . 'AccountHead')
  1501. ->updateOrInsert(['UserID' => $UserID], ['UserID' => $UserID, 'Image' => 'http://' . $request->getHttpHost() . DIRECTORY_SEPARATOR . $Image, 'LastTime' => now()]);
  1502. }
  1503. return apiReturnSuc();
  1504. }
  1505. // 增加用户可提额度
  1506. public function add_draw_base(Request $request, $UserID)
  1507. {
  1508. if ($request->isMethod('post')) {
  1509. $draw_base = (int)$request->add_draw_base;
  1510. if ($draw_base < 0) return apiReturnFail('请输入正确的可提额度');
  1511. $draw_base = $draw_base * NumConfig::NUM_VALUE;
  1512. // 判断额度
  1513. $dayVerify = DB::table(TableName::agent() . 'add_draw_base')->where('user_id', $UserID)->whereDate('create_time', date('Y-m-d'))->sum('draw_base');
  1514. if ($dayVerify >= 10000 * NumConfig::NUM_VALUE) {
  1515. return apiReturnFail('单日用户最大额度一万');
  1516. }
  1517. $allVerify = DB::table(TableName::agent() . 'add_draw_base')->sum('draw_base');
  1518. if ($allVerify >= 100000 * NumConfig::NUM_VALUE) {
  1519. return apiReturnFail('总额度不足,联系管理员,最大额度五万');
  1520. }
  1521. // 增加可提额度
  1522. if (DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->first()) {
  1523. DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->increment('DrawBase', $draw_base);
  1524. } else {
  1525. DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->insert(['UserID' => $UserID, 'DrawBase' => $draw_base]);
  1526. }
  1527. // 增加记录
  1528. DB::table(TableName::agent() . 'add_draw_base')
  1529. ->insert([
  1530. 'user_id' => $UserID,
  1531. 'draw_base' => $draw_base,
  1532. 'create_time' => now(),
  1533. 'admin_id' => session('admin')['id']
  1534. ]);
  1535. return apiReturnSuc();
  1536. }
  1537. return view('admin.global.add_draw_base', compact('UserID'));
  1538. }
  1539. public function add_tax(Request $request, $UserID)
  1540. {
  1541. if ($request->isMethod('post')) {
  1542. $add_tax = (int)$request->add_tax;
  1543. $draw_base = $add_tax * NumConfig::NUM_VALUE;
  1544. //if($draw_base>0){
  1545. DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->increment('Revenue', $draw_base);
  1546. //}
  1547. return apiReturnSuc();
  1548. }
  1549. return view('admin.global.add_tax', compact('UserID'));
  1550. }
  1551. // 推广限制开关
  1552. public function register_invite_switches(Request $request, $UserID)
  1553. {
  1554. $Value = $request->Value;
  1555. $redis = Redis::connection();
  1556. $redis->set('register_invite_switches_' . $UserID, $Value);
  1557. return apiReturnSuc();
  1558. }
  1559. public function platformRecord(Request $request)
  1560. {
  1561. $date = $request->date ?: date('Y-m-d',strtotime('-1 days'));
  1562. $dateFormat = date('Ymd',strtotime($date));
  1563. if($dateFormat == date('Ymd')){
  1564. $list = [];
  1565. $platform = ['only','atmosfera','pg','pp'];
  1566. foreach ($platform as $pItem) {
  1567. $platformRecord = [
  1568. 'lid' => 0,
  1569. 'ldate' => $dateFormat,
  1570. 'platform' => $pItem,
  1571. 'all_bet' => Redis::get('platform_' . $pItem . '_bet') ?: 0,
  1572. 'all_win' => Redis::get('platform_' . $pItem . '_win') ?: 0,
  1573. 'current_bet' => Redis::get('platform_' . $pItem . '_bet_' . $dateFormat) ?: 0,
  1574. 'current_win' => Redis::get('platform_' . $pItem . '_win_' . $dateFormat) ?: 0,
  1575. 'current_play' => Redis::get('platform_' . $pItem . '_play_' . $dateFormat) ?: 0,
  1576. // 'sub_detail' => ''
  1577. ];
  1578. array_push($list, $platformRecord);
  1579. }
  1580. $list = json_decode(json_encode($list));
  1581. }else{
  1582. $list = DB::connection('mysql')->table('record_platform_data')->where('ldate', $dateFormat)->get();
  1583. }
  1584. $monthStart = date('Ym',strtotime($date)).'01';
  1585. $monthEnd = date('Ym',strtotime($date)).'31';
  1586. $where= [['ldate', '<=', $monthEnd],['ldate', '>=', $monthStart]];
  1587. $monthData = DB::connection('mysql')->table('record_platform_data')
  1588. ->where($where)
  1589. ->selectRaw('sum(current_bet) month_bet,sum(current_win) month_win,platform')
  1590. ->groupBy('platform')
  1591. ->get();
  1592. return view('admin.global.platformRecord', compact('list', 'date', 'monthData'));
  1593. }
  1594. public function platformSub($id)
  1595. {
  1596. // if($id>0){
  1597. // $record = DB::connection('mysql')->table('record_platform_data')->where('lid', $id)->first();
  1598. // }else{
  1599. // $DateID = date('Ymd');
  1600. //
  1601. // $only=GameCard::where('brand','OnlyPlay')->where('state','<>',0)->pluck('gid')->toArray();
  1602. //
  1603. // $atmosfera=[71,74,85,86,87,88,89,92,93];
  1604. // $platform = ['only','atmosfera'];
  1605. // foreach ($platform as $pItem){
  1606. //
  1607. // $gameType = ($pItem == 'only'?$only:$atmosfera);
  1608. // if(is_array($gameType)){
  1609. // $subData = [];
  1610. // foreach ($gameType as $item){
  1611. // $betkey = 'platform_'.$pItem.'_'.$item. '_bet_' . $DateID;
  1612. //
  1613. // $winkey = 'platform_'.$pItem.'_'.$item. '_win_' . $DateID;
  1614. //
  1615. // $playkey = 'platform_'.$pItem.'_'.$item.'_play_' . $DateID;
  1616. // $subData[$item] = ['current_bet' => Redis::get($betkey)?:0,'current_win' =>Redis::get($winkey)?:0,'current_play' =>Redis::get($playkey)?:0 ];
  1617. // }
  1618. // $platformRecord['sub_detail'] = json_encode($subData);
  1619. // }
  1620. // }
  1621. // }
  1622. $record = DB::connection('mysql')->table('record_platform_data')->where('lid', $id)->first();
  1623. $subDetail = [];
  1624. $atmosferaMap=[
  1625. 71 => 'Live-Roulette-EN',
  1626. 74 => 'Keno',
  1627. 85 => 'Auto-Roulette',
  1628. 86 => 'Blackjack-A',
  1629. 87 => 'Blackjack-B',
  1630. 88 => 'Blackjack-C',
  1631. 89 => 'Blackjack-D',
  1632. 92 => 'Cocktail-Roulette',
  1633. 93 => 'Blackjack-E'
  1634. ];
  1635. if($record){
  1636. if($record->sub_detail){
  1637. $subDetail = json_decode($record->sub_detail,true);
  1638. if(is_array($subDetail)){
  1639. if($record->platform == 'atmosfera'){
  1640. $newArr = [];
  1641. foreach ($subDetail as $kk => $vv){
  1642. $newArr[$atmosferaMap[$kk]] = $vv;
  1643. }
  1644. $subDetail = $newArr;
  1645. }
  1646. // current_play
  1647. $subDetail = Util::arraySort($subDetail,'current_play',SORT_DESC);
  1648. }
  1649. }
  1650. }
  1651. return view('admin.global.platform_sub_data', compact('id', 'subDetail'));
  1652. }
  1653. }