GlobalController.php 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105
  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. $mobileModel = trim($request->MobileModel ?? "");
  441. $startTime = str_replace('T', ' ', $request->start_time ?? "");
  442. $endTime = str_replace('T', ' ', $request->end_time ?? "");
  443. $startLoginTime = str_replace('T', ' ', $request->start_logintime ?? "");
  444. $endLoginTime = str_replace('T', ' ', $request->end_logintime ?? "");
  445. $obj = $request->obj ?? "";
  446. $vip = $request->vip ?? '';
  447. $excel = $request->excel ?? "";
  448. $accounts_type = $request->accounts_type ?: 0;
  449. $score = $request->Score ?: '';
  450. $channel = $request->channel;
  451. $user_tab = $request->user_tab ?: '';
  452. $packgeName = $request->PackgeName ?: '';
  453. $mobileModelOptions = ['iPhone', 'iPad', 'Android', 'PC', 'Mac'];
  454. // 快速搜索
  455. $quickSearch = $request->quickSearch ?: '';
  456. $list = (new GlobalUser())->userlist($gameID, $phoneNum, $spreaderID, $nickName, $mobileModel, $startTime, $endTime, $obj, $vip, $excel, $accounts_type, $channel, $user_tab, $packgeName, $quickSearch, $score,$MachineID,$startLoginTime,$endLoginTime);
  457. // $channels = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('IsAndroid', 0)->groupBy('Channel')->pluck('Channel');
  458. $channels=$adminChannels;
  459. // $webLogonTimes = [1 => 'facebook', 2 => '游客', 3 => '手机号'];
  460. $webLogonTimes = [ 2 => __('auto.游客'), 3 => __('auto.手机号')];
  461. // 获取包名
  462. $ChannelPackageName = DB::connection('write')->table('QPPlatformDB.dbo.ChannelRechargeGameOpen')
  463. ->select('ChannelPackageName')
  464. ->pluck('ChannelPackageName')->toArray();
  465. // $ChannelPackageName[] = 'com.teenpatti.queen';
  466. $typeList = [1 => __('auto.游戏中'), 2 => __('auto.未实名'), 3 => __('auto.无手机号'), 5 => __('auto.无渠道'), 6 => __('auto.未充值'), 7 => __('auto.无上级'), 8 => __('auto.封号中'), 9 => __('auto.官方账号')];
  467. return view('admin.global.userlist', compact('list','MachineID', 'gameID', 'phoneNum', 'spreaderID', 'nickName', 'mobileModel', 'mobileModelOptions', 'startTime', 'endTime','startLoginTime', 'endLoginTime', 'obj', 'vip', 'excel', 'accounts_type'
  468. , 'channel', 'user_tab', 'packgeName', 'channels', 'webLogonTimes', 'ChannelPackageName', 'score', 'quickSearch', 'typeList'
  469. ));
  470. }
  471. //用户列表
  472. public function userlist1(Request $request)
  473. {
  474. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  475. ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai1', 'ai.SpreaderID', '=', 'ai1.UserID')
  476. ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
  477. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gsl', 'gsl.UserID', '=', 'ai.UserID')
  478. ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as gri', 'gsl.ServerID', '=', 'gri.ServerID')
  479. ->leftJoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', 'ap.UserID')
  480. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  481. ->leftJoin('QPRecordDB.dbo.RecordPackageName as rn', 'ai.UserID', 'rn.UserID')
  482. ->where('ai.IsAndroid', 0);
  483. $UserID = (int)$request->UserID ?: "";
  484. $GameID = (int)$request->GameID ?: "";
  485. $RegisterMobile = $request->RegisterMobile ?? "";
  486. $SpreaderID = (int)$request->SpreaderID ?: "";
  487. $Compellation = $request->Compellation ?? "";
  488. $start_time = $request->start_time ?? "";
  489. $end_time = $request->end_time ?? "";
  490. $obj = $request->obj ?? "";
  491. $vip = $request->vip ?? '';
  492. $excel = $request->excel ?? "";
  493. $accounts_type = $request->accounts_type ?: '';
  494. $Score = $request->Score ?: '';
  495. $channel = $request->channel;
  496. $user_tab = $request->user_tab ?: '';
  497. $PackgeName = $request->PackgeName ?: '';
  498. $start_time = str_replace('T', ' ', $start_time);
  499. $end_time = str_replace('T', ' ', $end_time);
  500. if (!empty($PackgeName)) {
  501. $list->where('PackgeName', $PackgeName);
  502. }
  503. if (!empty($UserID)) {
  504. $list->where('ai.UserID', $UserID);
  505. }
  506. if (!empty($GameID)) {
  507. $list->where('ai.GameID', $GameID);
  508. }
  509. if (!empty($RegisterMobile)) {
  510. $RegisterMobile = str_replace(' ', '', $RegisterMobile);
  511. $list->where('ap.PhoneNum', 'like', $RegisterMobile . '%');
  512. }
  513. if (!empty($SpreaderID)) {
  514. $getSpreaderID = AccountsInfo::where('GameID', $SpreaderID)->value('UserID');
  515. $list->where('ai.SpreaderID', $getSpreaderID);
  516. }
  517. if (!empty($Compellation)) {
  518. $list->where('ai.NickName', 'like', '%' . $Compellation . '%');
  519. }
  520. if (!empty($start_time)) {
  521. $list->where('ai.RegisterDate', '>=', $start_time);
  522. $start_time = date('Y-m-d', strtotime($start_time)) . 'T' . date('H:i:s', strtotime($start_time));
  523. }
  524. if (!empty($end_time)) {
  525. $list->where('ai.RegisterDate', '<=', $end_time);
  526. $end_time = date('Y-m-d', strtotime($end_time)) . 'T' . date('H:i:s', strtotime($end_time));
  527. }
  528. if (!empty($user_tab)) {
  529. $user_tabArr = explode('_', $user_tab);
  530. $list->where($user_tabArr[0], $user_tabArr[1])->count();
  531. }
  532. (!empty($channel) || $channel === '0') && $list->where('ai.Channel', $channel);
  533. switch ($accounts_type) {
  534. case 1:
  535. $list->where('ai.WebLogonTimes', 0)->whereNull('PhoneNum');
  536. break;
  537. case 2:
  538. $list->where('ai.WebLogonTimes', 1)->whereNull('PhoneNum');
  539. break;
  540. case 3:
  541. $list->WhereNotNull('PhoneNum');
  542. break;
  543. case 4:
  544. $list->where('ai.Channel', 100);
  545. break;
  546. }
  547. if (!empty($Score)) {
  548. $list->orderBy('Score', $Score);
  549. } else {
  550. $list->orderBy('ai.RegisterDate', 'desc');
  551. }
  552. $build_str = $request->build_str ?: '';
  553. $arr = [];
  554. if (!empty($build_str)) {
  555. parse_str($build_str, $arr);
  556. }
  557. $build_query = '';
  558. $data = $request->post('search', []);
  559. $data = array_merge($data, $arr);
  560. if (!empty($data)) {
  561. $arr_filter = array_filter($data);
  562. $build_query = http_build_query($arr_filter);
  563. }
  564. $r = (new GlobalLogicController())->user_search($list, $data);
  565. $list = $r['build_sql'];
  566. $data = $r['data'];
  567. if (!empty($vip)) {
  568. $list->where('ai.MemberOrder', $vip);
  569. }
  570. //是否导出excel
  571. if (!empty($excel)) {
  572. $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')
  573. ->limit(10000)->get();
  574. foreach ($list as $key => &$value) {
  575. $value->Score = number_float($value->Score / 100);
  576. switch ($value->Nullity) {
  577. case '0':
  578. $value->Nullity = '正常';
  579. break;
  580. case '1':
  581. $value->Nullity = '封禁';
  582. break;
  583. }
  584. }
  585. $title = ['会员ID', '姓名', '手机号', 'IP', '金豆余额', '上级ID', 'vip等级', '注册日期', '渠道名称', '账号', '账号状态'];
  586. $list = json_decode(json_encode($list), true);
  587. downloadExcel($list, $title, '房间输赢统计' . date('YmdHis'));
  588. } else {
  589. $list = $list
  590. ->select('ai.*', 'gi.Score', 'ai1.GameID as ain_GameID', 'gi.Revenue', 'gi.InsureScore', 'gsl.CollectDate', 'gi.BankScore', 'gri.ServerName', 'ap.PhoneNum', 'PackgeName')
  591. ->paginate(10);
  592. // 查找官方账号
  593. $userID = [];
  594. foreach ($list as $val) {
  595. $userID[] = $val->UserID;
  596. }
  597. // 游戏中用户
  598. $query_UserID = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->whereIn('UserID', $userID)->pluck('UserID')->toArray();
  599. // 禁止查看敏感信息
  600. $helper = new Helper();
  601. $flag = $helper->privacy($request);
  602. if ($flag) {
  603. foreach ($list->items() as &$val) {
  604. $val->LastLogonMobile = !empty($this->LastLogonMobile) ? $helper->sub_mobile($val->LastLogonMobile) : '';
  605. }
  606. }
  607. // 获取包名
  608. $ChannelPackageName = DB::connection('write')->table('QPPlatformDB.dbo.ChannelRechargeGameOpen')
  609. ->select('ChannelPackageName')
  610. ->pluck('ChannelPackageName')->toArray();
  611. $ChannelPackageName[] = 'com.teenpatti.queen';
  612. foreach ($list as &$val) {
  613. $val->Score = $val->Score / 100;
  614. $val->ipAddress = '';
  615. switch ($val->Nullity) {
  616. case '0':
  617. $val->Nullity = '正常';
  618. break;
  619. case 1:
  620. $val->Nullity = '封禁';
  621. break;
  622. }
  623. if (in_array($val->UserID, $query_UserID)) {
  624. $val->Nullity .= '<span style="color: Orange">(官方)</span>';
  625. }
  626. }
  627. $WebLogonTimes = [1 => 'facebook', 2 => '游客', 3 => '手机号'];
  628. $channels = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('IsAndroid', 0)->groupBy('Channel')->pluck('Channel');
  629. return view('admin.global.userlist', [
  630. 'list' => $list,
  631. 'UserID' => $UserID,
  632. 'GameID' => $GameID,
  633. 'RegisterMobile' => $RegisterMobile,
  634. 'SpreaderID' => $SpreaderID,
  635. 'Compellation' => $Compellation,
  636. 'start_time' => $start_time,
  637. 'end_time' => $end_time,
  638. 'obj' => $data,
  639. 'vip' => $vip,
  640. 'WebLogonTimes' => $WebLogonTimes,
  641. 'accounts_type' => $accounts_type,
  642. 'build_str' => $build_query,
  643. 'channel' => $channel,
  644. 'Score' => $Score,
  645. 'user_tab' => $user_tab,
  646. 'channels' => $channels,
  647. 'ChannelPackageName' => $ChannelPackageName,
  648. 'PackgeName' => $PackgeName
  649. ]);
  650. }
  651. }
  652. //用户修改
  653. public function user_update(Request $request)
  654. {
  655. if ($request->isMethod('get')) {
  656. $userID = $request->id;
  657. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  658. ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ain', 'ai.SpreaderID', '=', 'ain.UserID')
  659. ->where('ai.UserID', $userID)
  660. ->selectRaw('ai.UserID,ai.NickName,ai.Nullity,ai.Compellation,ai.SpreaderID,ai.GameID as ai_GameID,IsNull(ain.GameID,0) as GameID')
  661. ->first();
  662. $IDWhiteUser = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $userID)->first();
  663. return view('admin.global.user_update', ['list' => $list, 'IDWhiteUser' => $IDWhiteUser]);
  664. } elseif ($request->isMethod('post')) {
  665. $SpreaderID = (int)$request->post('SpreaderID') ?: "";
  666. $UserID = $request->post('UserID');
  667. $Nullity = $request->post('Nullity', '');
  668. $official = $request->post('official');
  669. $query = $IDWhiteUser = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $UserID)->first();
  670. $arr = [];
  671. if (!empty(trim($SpreaderID))) {
  672. $account = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('GameID', $SpreaderID)->selectRaw('UserID')->first();
  673. $arr['SpreaderID'] = $account->UserID;
  674. }
  675. if ($Nullity !== "" || $Nullity === 0) {
  676. $arr['Nullity'] = $Nullity;
  677. }
  678. try {
  679. DB::table('QPAccountsDB.dbo.AccountsInfo')->where('UserID', $UserID)->update($arr);
  680. if ($official == 1) { // 设置官方账号
  681. if (!$query) {
  682. DB::table('QPAccountsDB.dbo.IDWhiteUser')->insert(['UserID' => $UserID]);
  683. }
  684. } else {
  685. if ($query) {
  686. DB::table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $UserID)->delete();
  687. }
  688. }
  689. } catch (\Exception $e) {
  690. return $this->json(500, '修改失败');
  691. }
  692. return $this->json(200, '修改成功');
  693. }
  694. }
  695. //封号1 解封2
  696. public function ban(Request $request)
  697. {
  698. $url = config('transfer.stock')['url'] . 'banAccounts';
  699. try {
  700. if ($request->ban == 1) {
  701. $id = explode(',', $request->id);
  702. DB::table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->update(['Nullity' => 1]);
  703. // 查询用户gameId
  704. $gameID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->select('GameID')->get();
  705. $data = [];
  706. foreach ($gameID as $value) {
  707. $data[] = [
  708. 'GameID' => $value->GameID,
  709. 'CreateDate' => date('Y-m-d H:i:s'),
  710. 'State' => 0
  711. ];
  712. // 给中转服发送通知
  713. $admin = session('admin');
  714. $account = $admin->account ?: '';
  715. $password = $admin->password ?: '';
  716. $yc_data = [
  717. 'accounts' => $account,
  718. 'passworld' => $password,
  719. 'gameID' => $value->GameID,
  720. ];
  721. $build_query = $url . '?' . http_build_query($yc_data);
  722. $output = (new HttpCurl())->curl_get($build_query);
  723. }
  724. // 添加封号
  725. DB::table('QPAccountsDB.dbo.BanAccounts')->insert($data);
  726. } elseif ($request->ban == 2) {
  727. // 给中转服发送通知
  728. $admin = session('admin');
  729. $account = $admin->account ?: '';
  730. $password = $admin->password ?: '';
  731. $yc_data = [
  732. 'accounts' => $account,
  733. 'passworld' => $password,
  734. 'gameID' => 0,
  735. ];
  736. $build_query = $url . '?' . http_build_query($yc_data);
  737. $output = (new HttpCurl())->curl_get($build_query);
  738. $id = explode(',', $request->id);
  739. DB::table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->update(['Nullity' => 0]);
  740. } else {
  741. return $this->json(400, '操作失败');
  742. }
  743. } catch (\Exception $e) {
  744. return $this->json(500, $e->getMessage());
  745. }
  746. return $this->json(200, '操作成功');
  747. }
  748. //用户列表 ID跳转
  749. public function id_find(Request $request)
  750. {
  751. $UserID = $request->UserID;
  752. $OpenPage = $request->OpenPage ?: '';
  753. $r = (new GlobalLogicController())->id_find($UserID, $OpenPage);
  754. return view('admin.global.id_list', $r);
  755. }
  756. //关联 姓名 设备 IP
  757. public function join(Request $request)
  758. {
  759. $id = $request->id;
  760. if ($id == 1) {
  761. $ip = $request->RegisterIP;
  762. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  763. ->where('RegisterIP', $ip)
  764. ->where('IsAndroid', 0)
  765. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,UserID')
  766. ->paginate(100);
  767. // 获取总充值和总提现
  768. $userIds = $list->pluck('UserID')->toArray();
  769. if (!empty($userIds)) {
  770. $accountsInfo = new AccountsInfo();
  771. $statistics = $accountsInfo->accountTotalStatistics($userIds);
  772. $statisticsMap = [];
  773. foreach ($statistics as $stat) {
  774. $statisticsMap[$stat->UserID] = $stat;
  775. }
  776. foreach ($list as &$item) {
  777. $item->Recharge = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Recharge : 0;
  778. $item->Withdraw = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Withdraw : 0;
  779. }
  780. }
  781. return view('admin.global.join_ip', ['list' => $list, 'id' => $id, 'ip' => $ip]);
  782. } elseif ($id == 2) {
  783. $userid = $request->UserID;
  784. $mac = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics')
  785. ->where('UserID', $userid)
  786. ->where('mac', '<>','')
  787. ->pluck('mac')->toArray();
  788. $mac=array_unique($mac);
  789. $list=[];
  790. if($mac) {
  791. $userids= DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics')
  792. ->whereIn('mac', $mac)
  793. ->pluck('UserID')
  794. ->toArray();
  795. $userids=array_unique($userids);
  796. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
  797. ->whereIn('UserID', $userids)
  798. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,UserID')
  799. ->paginate(100);
  800. }
  801. foreach ($list as &$value) {
  802. $value->login_count = DB::table('QPRecordDB.dbo.RecordUserLogin')->where('UserID', $value->UserID)->count();
  803. }
  804. // 获取总充值和总提现
  805. if (!empty($list)) {
  806. $userIds = $list->pluck('UserID')->toArray();
  807. $accountsInfo = new AccountsInfo();
  808. $statistics = $accountsInfo->accountTotalStatistics($userIds);
  809. $statisticsMap = [];
  810. foreach ($statistics as $stat) {
  811. $statisticsMap[$stat->UserID] = $stat;
  812. }
  813. foreach ($list as &$item) {
  814. $item->Recharge = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Recharge : 0;
  815. $item->Withdraw = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Withdraw : 0;
  816. }
  817. }
  818. return view('admin.global.join_facility', ['list' => $list, 'mac' => implode(",",$mac), 'id' => $id]);
  819. } elseif ($id == 3) {
  820. $BankNo = $request->Phone;
  821. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone as di')
  822. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
  823. ->where('di.PhoneNum', $BankNo)
  824. ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,ai.Channel,ai.NickName,ai.UserID')
  825. ->paginate(10);
  826. // 获取总充值和总提现
  827. $userIds = $list->pluck('UserID')->toArray();
  828. if (!empty($userIds)) {
  829. $accountsInfo = new AccountsInfo();
  830. $statistics = $accountsInfo->accountTotalStatistics($userIds);
  831. $statisticsMap = [];
  832. foreach ($statistics as $stat) {
  833. $statisticsMap[$stat->UserID] = $stat;
  834. }
  835. foreach ($list as &$item) {
  836. $item->Recharge = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Recharge : 0;
  837. $item->Withdraw = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Withdraw : 0;
  838. }
  839. }
  840. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
  841. } elseif ($id == 4) {
  842. $BankNo = $request->BankUserName;
  843. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
  844. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
  845. ->where('di.BankUserName', $BankNo)
  846. ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,Channel,ai.NickName,ai.UserID')
  847. ->paginate(10);
  848. // 获取总充值和总提现
  849. $userIds = $list->pluck('UserID')->toArray();
  850. if (!empty($userIds)) {
  851. $accountsInfo = new AccountsInfo();
  852. $statistics = $accountsInfo->accountTotalStatistics($userIds);
  853. $statisticsMap = [];
  854. foreach ($statistics as $stat) {
  855. $statisticsMap[$stat->UserID] = $stat;
  856. }
  857. foreach ($list as &$item) {
  858. $item->Recharge = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Recharge : 0;
  859. $item->Withdraw = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Withdraw : 0;
  860. }
  861. }
  862. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
  863. } elseif ($id == 5) {
  864. $BankNo = $request->EmailAddress;
  865. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
  866. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
  867. ->where('di.EmailAddress', $BankNo)
  868. ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,Channel,ai.NickName,ai.UserID')
  869. ->paginate(100);
  870. // 获取总充值和总提现
  871. $userIds = $list->pluck('UserID')->toArray();
  872. if (!empty($userIds)) {
  873. $accountsInfo = new AccountsInfo();
  874. $statistics = $accountsInfo->accountTotalStatistics($userIds);
  875. $statisticsMap = [];
  876. foreach ($statistics as $stat) {
  877. $statisticsMap[$stat->UserID] = $stat;
  878. }
  879. foreach ($list as &$item) {
  880. $item->Recharge = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Recharge : 0;
  881. $item->Withdraw = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Withdraw : 0;
  882. }
  883. }
  884. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
  885. } elseif ($id == 6) { // 关联IP
  886. $UserID = $request->UserID;
  887. $UserIDs = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics as rs')
  888. ->join('QPRecordDB.dbo.RecordUserLogonStatistics as rs1', function ($join) {
  889. $join->on('rs.LogonIP', 'rs1.LogonIP');
  890. })
  891. ->where('rs.UserID', $UserID)
  892. ->select('rs1.UserID')
  893. ->groupBy('rs1.UserID')
  894. ->limit(2000)
  895. ->pluck('rs1.UserID');
  896. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  897. ->whereIn('ai.UserID', $UserIDs)
  898. ->where('IsAndroid', 0)
  899. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,ai.UserID')
  900. ->paginate(1000);
  901. // 获取总充值和总提现
  902. $userIds = $list->pluck('UserID')->toArray();
  903. if (!empty($userIds)) {
  904. $accountsInfo = new AccountsInfo();
  905. $statistics = $accountsInfo->accountTotalStatistics($userIds);
  906. $statisticsMap = [];
  907. foreach ($statistics as $stat) {
  908. $statisticsMap[$stat->UserID] = $stat;
  909. }
  910. foreach ($list as &$item) {
  911. $item->Recharge = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Recharge : 0;
  912. $item->Withdraw = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Withdraw : 0;
  913. }
  914. }
  915. return view('admin.global.join_LastLogonIP', ['list' => $list, 'id' => $id, 'UserID' => $UserID]);
  916. } elseif ($id == 7) { // 登录IP记录
  917. $UserID = $request->UserID;
  918. $list = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics as rls')
  919. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'rls.UserID', 'ai.UserID')
  920. ->where('rls.UserID', $UserID)
  921. ->where('IsAndroid', 0)
  922. ->select('rls.UserID','LastLogonDate', 'LogonIP', 'LastDate', 'ai.GameID', 'NickName', 'Channel')
  923. ->orderByDesc('LastDate')
  924. ->paginate(1000);
  925. return view('admin.global.join_login_ip', ['list' => $list, 'UserID' => $UserID, 'id' => $id]);
  926. } elseif ($id == 8) { // 关联cpf
  927. $UserID = $request->UserID;
  928. $cpf=Cpf::getCpf($UserID,1);
  929. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  930. ->whereIn('ai.UserID', Cpf::getCpf($UserID))
  931. ->where('IsAndroid', 0)
  932. ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,ai.UserID')
  933. ->paginate(1000);
  934. // 获取总充值和总提现
  935. $userIds = $list->pluck('UserID')->toArray();
  936. if (!empty($userIds)) {
  937. $accountsInfo = new AccountsInfo();
  938. $statistics = $accountsInfo->accountTotalStatistics($userIds);
  939. $statisticsMap = [];
  940. foreach ($statistics as $stat) {
  941. $statisticsMap[$stat->UserID] = $stat;
  942. }
  943. foreach ($list as &$item) {
  944. $item->Recharge = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Recharge : 0;
  945. $item->Withdraw = isset($statisticsMap[$item->UserID]) ? $statisticsMap[$item->UserID]->Withdraw : 0;
  946. }
  947. }
  948. return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'UserID' => $UserID, 'BankNo' => implode(",",$cpf)]);
  949. }
  950. }
  951. //用户单控系统
  952. public function dk(Request $request)
  953. {
  954. $start_time = $request->start_time ?: date('Y-m-d 00:00:00');
  955. $end_time = $request->end_time ?: date('Y-m-d 23:59:59');
  956. $date = $request->date ?: '';
  957. $r = (new GlobalLogicController())->dk($start_time, $end_time, $date);
  958. return view('admin.global.dk', $r);
  959. }
  960. //用户单控系统-详细用户列表
  961. public function dk_userlist(Request $request)
  962. {
  963. $GameID = (int)$request->GameID ?: "";
  964. $SpreaderID = (int)$request->SpreaderID ?: "";
  965. $NickName = (string)$request->NickName ?: "";
  966. $start_time = $request->start_time ?: "";
  967. $end_time = $request->end_time ?: "";
  968. $user_label = $request->label ?: "";
  969. $label_sort = $request->label_sort ?: "";
  970. $is_line = $request->is_line ?: "";
  971. $game_room = $request->game_room ?: "";
  972. $UserScoreControl = $request->UserScoreControl ?: "";
  973. $ScoreSort = $request->Score ?: "";
  974. $amountSort = $request->amount ?: "";
  975. $sort_tx = $request->sort_tx ?: "";
  976. $sort_date = $request->sort_date ?: "";
  977. $ChangeScoreSort = $request->ChangeScore ?: '';
  978. $Channel = $request->Channel;
  979. $ServerNameSort = $request->ServerNameSort ?: '';
  980. $start_time = str_replace('T', ' ', $start_time);
  981. $end_time = str_replace('T', ' ', $end_time);
  982. $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);
  983. $game_room_line = DB::connection('read')->table(TableName::QPPlatformDB() . 'GameRoomInfo')->select('ServerName', 'ServerID')->get();
  984. $allChannel = DB::connection('read')->table(TableName::QPPlatformDB() . 'ChannelPackageName')->pluck('Channel');
  985. $page = Paginator::resolveCurrentPage('page');
  986. $start_time = \App\Http\helper\Helper::timeChange($start_time);
  987. $end_time = \App\Http\helper\Helper::timeChange($end_time);
  988. $user_labels = [1 => '普通会员', 2 => '首充会员', 3 => '复充会员', 4 => '优质会员', 5 => '尊贵会员', 6 => '发育不良', 7 => '异常观察', 8 => '重点关注', 20 => '其他1', 21 => '其他2'];
  989. return view('admin.global.dk_userlist', compact('list', 'GameID', 'SpreaderID', 'NickName', 'start_time', 'end_time', 'user_label'
  990. , 'label_sort', 'is_line', 'game_room', 'UserScoreControl', 'ScoreSort', 'amountSort', 'sort_tx', 'sort_date', 'ChangeScoreSort', 'Channel', 'ServerNameSort'
  991. , 'game_room_line', 'allChannel', 'page', 'user_labels'
  992. ));
  993. }
  994. //用户单控系统-详细用户列表 修改(简化版:只控制金额和整体概率)
  995. public function dk_userlist_edit(Request $request)
  996. {
  997. $UserID = $request->UserID ?? '';
  998. $build_sql = DB::connection('write')->table('QPTreasureDB.dbo.UserScoreControl');
  999. if ($request->isMethod('post')) {
  1000. $post = $request->post();
  1001. $ControlScore = (float)($post['ControlScore'] ?? 0);
  1002. $Probability = (float)($post['Probability'] ?? 0);
  1003. $Remarks = $post['Remarks'] ?? '';
  1004. // 概率范围 0-100
  1005. if ($Probability < 0 || $Probability > 100) {
  1006. return apiReturnFail('概率必须在0-100之间');
  1007. }
  1008. $admin_id = session('admin')->id;
  1009. $admin_user = DB::connection('read')->table('agent.dbo.admin_users')->where('id', $admin_id)->first();
  1010. /*管理员彩金控制*/
  1011. if ($ControlScore > 0) {
  1012. if ($admin_user->recharge_amount < $ControlScore) return apiReturnFail('管理员彩金额度不足!');
  1013. AdminScore::add_score($admin_user, abs($ControlScore), 2);
  1014. }
  1015. // 记录单控操作(只记金额和总体概率)
  1016. $prefix = $ControlScore < 0 ? '输' : '赢';
  1017. $content = $prefix . $ControlScore . '/ 概率:' . number_float($Probability) . '%';
  1018. $score = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
  1019. ControlRecord::record_add($UserID, $admin_id, $content, $score);
  1020. $data = [
  1021. 'ControlScore' => (int)($ControlScore * NumConfig::NUM_VALUE),
  1022. 'EffectiveScore' => 0,
  1023. 'ControlKindID' => -1,
  1024. 'Remarks' => $Remarks,
  1025. 'InsertDate' => date('Y-m-d H:i:s'),
  1026. // 概率直接写入 ControlRadian,不再区分游戏
  1027. 'ControlRadian' => $Probability,
  1028. 'UserID' => $UserID
  1029. ];
  1030. $build_sql->updateOrInsert(['UserID' => $UserID], $data);
  1031. // 埋点,执行存储过程
  1032. // 执行存储过程,-- 用户单控标签
  1033. StoredProcedure::user_label($UserID, 3);
  1034. return $this->json(200, "修改成功");
  1035. }
  1036. $row = $build_sql->where('UserID', $UserID)->first();
  1037. $ControlScore = $row->ControlScore ?? 0;
  1038. $Probability = $row->ControlRadian ?? 0;
  1039. $ControlScore = $ControlScore / NumConfig::NUM_VALUE;
  1040. $data = compact('UserID', 'ControlScore', 'Probability');
  1041. return view('admin.global.dk_userlist_edit', $data);
  1042. }
  1043. // 取消单控
  1044. public function cancel_dk(Request $request)
  1045. {
  1046. $UserID = $request->id ?? '';
  1047. $build_sql = DB::connection('write')->table('QPTreasureDB.dbo.UserScoreControl');
  1048. //$query = $build_sql->where('UserID',$UserID)->first();
  1049. $res = $build_sql->where('UserID', $UserID)->delete();
  1050. /*用户单控记录添加*/
  1051. $admin_id = session()->get('admin')->id;
  1052. if ($res) {
  1053. $score = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
  1054. ControlRecord::record_add($UserID, $admin_id, '取消单控', $score);
  1055. // 埋点,执行存储过程
  1056. // 执行存储过程,-- 用户单控标签
  1057. StoredProcedure::user_label($UserID, 5);
  1058. return apiReturnSuc("已取消单控");
  1059. }
  1060. return apiReturnFail('取消单控失败');
  1061. }
  1062. //输赢报表
  1063. public function winloser(Request $request)
  1064. {
  1065. $UserID = (int)trim($request->UserID) ?: '';
  1066. $UniqueCode = trim($request->UniqueCode) ?: '';
  1067. $room = trim($request->room) ?: '';
  1068. $searchGame = trim($request->searchGame) ?: '';
  1069. $start_time = trim($request->start_time) ?: '';
  1070. $end_time = trim($request->end_time) ?: '';
  1071. $start_time = str_replace('T', ' ', $start_time);
  1072. $end_time = str_replace('T', ' ', $end_time);
  1073. $excel = $request->excel ?: '';
  1074. $id_list = $request->id_list ?: '';
  1075. $ChangeScoreMin = $request->ChangeScoreMin;
  1076. $ChangeScoreMax = $request->ChangeScoreMax;
  1077. $PlayGames = $request->PlayGames ?: '';
  1078. $ChangeScoreSort = $request->ChangeScoreSort ?: '';
  1079. $afterScoreSort = $request->afterScoreSort ?: '';
  1080. $Jump = (int)$request->Jump ?? 0;
  1081. $result = (new GlobalLogicController())->winloser($UserID, $UniqueCode, $room, $start_time, $end_time, $excel, $id_list, $ChangeScoreMin, $ChangeScoreMax, $ChangeScoreSort, $afterScoreSort, $searchGame);
  1082. $Jump += 1;
  1083. $result['Jump'] = $Jump;
  1084. return view('admin.global.win_loser_list', $result);
  1085. }
  1086. // 查看战绩
  1087. public function game_record(Request $request)
  1088. {
  1089. $UniqueCode = $request->UniqueCode ?? '';
  1090. $gameId = $request->gameId ?? '';
  1091. $month = $request->month ?? '';
  1092. $result = (new GlobalLogicController())->game_record($UniqueCode, $gameId, $month);
  1093. return view('admin.global.game_record', $result);
  1094. }
  1095. //推广员奖励报表
  1096. public function reward(Request $request)
  1097. {
  1098. $UserID = (int)trim($request->UserID) ?: 0;
  1099. $SpreaderID = (int)trim($request->SpreaderID) ?: 0;
  1100. $start_time = trim($request->start_time) ?? '';
  1101. $end_time = trim($request->end_time) ?? '';
  1102. $Type = trim($request->Type) ?? '';
  1103. $start_time = str_replace('T', ' ', $start_time);
  1104. $end_time = str_replace('T', ' ', $end_time);
  1105. $result = (new GlobalLogicController())->reward($UserID, $SpreaderID, $start_time, $end_time, $Type);
  1106. return view('admin.global.reward_list', $result);
  1107. }
  1108. // 奖励来源玩家
  1109. public function userSource(Request $request)
  1110. {
  1111. $orderIds = $request->orderIds ?: '';
  1112. $Type = $request->Type ?: '';
  1113. $Id = $request->Id ?: '';
  1114. $GameID = $request->GameID ?: '';
  1115. switch ($Type) {
  1116. case 1:
  1117. $OrderIDs = explode(',', $orderIds);
  1118. $list = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
  1119. ->whereIn('OrderID', $OrderIDs)
  1120. ->where('OrderID', '>', 0)
  1121. ->where('Type', $Type)
  1122. ->paginate(10);
  1123. foreach ($list as &$value) {
  1124. $value->toGold /= NumConfig::NUM_VALUE;
  1125. }
  1126. unset($value);
  1127. $view = 'admin.extension.user_source';
  1128. break;
  1129. case 2:
  1130. break;
  1131. case 3:
  1132. $list = DB::connection('read')->table('QPRecordDB.dbo.RecordUserAgent as ua')
  1133. ->join('QPAccountsDB.dbo.accountsInfo as ai', 'ua.UserID', 'ai.UserID')
  1134. ->leftJoin('QPAccountsDB.dbo.accountsInfo as ain', 'ain.UserID', '=', 'ua.SourceUserID')
  1135. ->select('ai.GameID', 'ain.GameID as SourceUserID', 'DirectRebate', 'SendTime', 'OrderSn', 'ain.UserID', 'ua.Level')
  1136. ->where('ua.Id', $Id)
  1137. ->orderBy('SendTime', 'desc')
  1138. ->paginate(10);
  1139. foreach ($list as &$value) {
  1140. $value->DirectRebate = number_float($value->DirectRebate / NumConfig::NUM_VALUE);
  1141. }
  1142. $view = 'admin.extension.user_recharge_source';
  1143. break;
  1144. }
  1145. return view($view, compact('list', 'Type', 'orderIds', 'GameID'));
  1146. }
  1147. // 设置房间开关
  1148. public function update(Request $request)
  1149. {
  1150. $server_id = $request->post('server_id');
  1151. $type = $request->post('type');
  1152. $Nullity = ($type == 'on') ? 0 : 1;
  1153. DB::table('QPPlatformDB.dbo.GameRoomInfo')
  1154. ->where('ServerID', $server_id)
  1155. ->update(['Nullity' => $Nullity]);
  1156. // 向服务端发送通知
  1157. $url = config('transfer.stock')['url'] . 'serverState';
  1158. $data = [
  1159. 'serverid' => $server_id,
  1160. 'state' => $Nullity,
  1161. ];
  1162. (new HttpCurl())->service($url, $data);
  1163. return apiReturnSuc();
  1164. }
  1165. // 查看对局信息
  1166. public function match_information($RoomCode)
  1167. {
  1168. $list = cache()->remember('match_information_' . $RoomCode, 10, function () use ($RoomCode) {
  1169. return DB::connection('game')->table(TableName::QPRecordDB() . 'RecordUniqueScoreCode')
  1170. ->where('uniquescorecode', $RoomCode)
  1171. ->get();
  1172. });
  1173. if (count($list) < 1 || empty($list)) {
  1174. $info = DB::connection('game')->table(TableName::QPRecordDB() . 'RecordGamePlayNew')
  1175. ->where('RoomCode', $RoomCode)
  1176. ->value('RecordJson');
  1177. try {
  1178. $data = json_decode($info, true);
  1179. if (json_last_error() !== JSON_ERROR_NONE) {
  1180. echo "<p>JSON 解码出错:" . json_last_error_msg() . "</p>";
  1181. } else {
  1182. // 4. 美化输出,保留中文
  1183. echo '<pre>' . htmlspecialchars(json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT)) . '</pre>';
  1184. }
  1185. //echo $this->jsonFormat($info);
  1186. } catch (\Exception $exception) {
  1187. dump($info);
  1188. }
  1189. } else {
  1190. header('Content-Type: text/html; charset=utf-8');
  1191. foreach ($list as $value) {
  1192. $uniquecode = $value->uniquecode;
  1193. $info = cache()->remember('match_information_info_' . $uniquecode, 10, function () use ($uniquecode) {
  1194. return DB::connection('game')->table(TableName::QPRecordDB() . 'RecordGamePlayNew')
  1195. ->where('RoomCode', $uniquecode)
  1196. ->value('RecordJson');
  1197. });
  1198. try {
  1199. // $info = \GuzzleHttp\json_decode($info, true);
  1200. // echo "<script>document.write('$info')</script>";
  1201. // dump($info);
  1202. //echo $this->jsonFormat($info);
  1203. // 3. 解析 JSON
  1204. $data = json_decode($info, true);
  1205. if (json_last_error() !== JSON_ERROR_NONE) {
  1206. echo "<p>JSON 解码出错:" . json_last_error_msg() . "</p>";
  1207. } else {
  1208. echo '<pre>' . htmlspecialchars(json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT)) . '</pre>';
  1209. }
  1210. } catch (\Exception $exception) {
  1211. dump($info);
  1212. }
  1213. }
  1214. }
  1215. }
  1216. public function jsonFormat($data)
  1217. {
  1218. // 对数组中每个元素递归进行urlencode操作,保护中文字符
  1219. array_walk_recursive($data, function (&$val) {
  1220. if ($val !== true && $val !== false && $val !== null) {
  1221. $val = urlencode($val);
  1222. }
  1223. });
  1224. // json encode
  1225. $data = json_encode($data);
  1226. // 将urlencode的内容进行urldecode
  1227. $data = urldecode($data);
  1228. // 缩进处理
  1229. $ret = '';
  1230. $pos = 0;
  1231. $length = strlen($data);
  1232. $indent = isset($indent) ? $indent : ' ';
  1233. $newline = "\n";
  1234. $prevchar = '';
  1235. $outofquotes = true;
  1236. for ($i = 0; $i <= $length; $i++) {
  1237. $char = substr($data, $i, 1);
  1238. if ($char == '"' && $prevchar != '\\') {
  1239. $outofquotes = !$outofquotes;
  1240. } elseif (($char == '}' || $char == ']') && $outofquotes) {
  1241. $ret .= $newline;
  1242. $pos--;
  1243. for ($j = 0; $j < $pos; $j++) {
  1244. $ret .= $indent;
  1245. }
  1246. }
  1247. $ret .= $char;
  1248. if (($char == ',' || $char == '{' || $char == '[') && $outofquotes) {
  1249. $ret .= $newline;
  1250. if ($char == '{' || $char == '[') {
  1251. $pos++;
  1252. }
  1253. for ($j = 0; $j < $pos; $j++) {
  1254. $ret .= $indent;
  1255. }
  1256. }
  1257. $prevchar = $char;
  1258. }
  1259. return $ret;
  1260. }
  1261. // 在线用户
  1262. public function online_user(Request $request)
  1263. {
  1264. $index = $request->index ?: 0;
  1265. $globalService = new GlobalUser();
  1266. $onLineUser = $globalService->onLineUser($index);
  1267. $pageNum = 10;
  1268. $total = (isset($onLineUser['total']) && !empty($onLineUser)) ? $onLineUser['total'] : 0;
  1269. $link = 'http://' . $request->getHttpHost() . '/admin/global/online_user?index=';
  1270. $service = new Paging($pageNum, $total, $index, ($total / $pageNum), $link);
  1271. $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1272. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as lck', 'ai.UserID', 'lck.UserID')
  1273. ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as gi', 'lck.ServerID', '=', 'gi.ServerID')
  1274. ->whereIn('ai.UserID', $onLineUser['UserIDs'])
  1275. ->select('ai.GameID', 'NickName', 'ai.UserID', 'gi.ServerName')->get();
  1276. $page = $service->subPageCss2();
  1277. return view('admin.global.online_user', [
  1278. 'list' => $list,
  1279. 'pages' => $page,
  1280. 'total' => $total
  1281. ]);
  1282. }
  1283. // 无感维护开关
  1284. public function GameRoomSwitch_view()
  1285. {
  1286. $list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
  1287. //->leftJoin('QPRecordDB.dbo.RecordGameInfo as ri', 'gi.ServerID', '=', 'ri.ServerID')
  1288. ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gl', function ($query) {
  1289. $query->on('gl.ServerID', 'gi.ServerID')->selectRaw('gl.ServerID')->groupBy('ServerID')->whereDate('CollectDate', date('Y-m-d'));
  1290. })
  1291. ->whereIn('gi.GameID', [1005, 2030, 2050])
  1292. ->whereNotIn('gi.ServerID', [32, 33, 39])
  1293. ->selectRaw('gi.Nullity,gi.GameID,gi.SortID,gi.ServerName,gi.ServerID,gi.RoomStock,count(DISTINCT gl.UserID) as game_count')
  1294. ->groupBy('gi.GameID', 'gi.SortID', 'gi.ServerName', 'gi.ServerID', 'gi.RoomStock', 'gi.Nullity')
  1295. ->get();
  1296. return view('admin.global.game_room_switch', [
  1297. 'list' => $list
  1298. ]);
  1299. }
  1300. // 无感操作开关操作
  1301. public function GameRoomSwitch(Request $request)
  1302. {
  1303. $serverID = $request->serverID ?: '';
  1304. $type = $request->type ?: '';
  1305. $serverID = explode(',', rtrim($serverID, ','));
  1306. if (empty($type)) {
  1307. return apiReturnFail('缺少操作类型');
  1308. }
  1309. switch ($type) {
  1310. case 'on' :
  1311. $Nullity = 0;
  1312. break;
  1313. case 'off':
  1314. $Nullity = 1;
  1315. break;
  1316. }
  1317. DB::table('QPPlatformDB.dbo.GameRoomInfo')->whereIn('ServerID', $serverID)->update(['Nullity' => $Nullity]);
  1318. return apiReturnSuc();
  1319. }
  1320. // 关闭禁止提现标签
  1321. public function relieve($id)
  1322. {
  1323. // 用户标签
  1324. $getUserTab = StoredProcedure::getUserTab($id);
  1325. $TabType = $getUserTab[0]->TabType ?? '';
  1326. if (!empty($getUserTab) && $TabType == 1) {
  1327. $Type12 = $getUserTab[0]->Type12 ?? 0;
  1328. if (in_array($Type12, [1301, 1302, 1303])) {
  1329. DB::table('QPAccountsDB.dbo.AccountWithDrawInfo')
  1330. ->where('UserID', $id)
  1331. ->update(['Switch' => 0]);
  1332. }
  1333. }
  1334. return apiReturnSuc();
  1335. }
  1336. // 单控用户备注
  1337. public function remarks(Request $request, $id)
  1338. {
  1339. $remark = $request->remark ?: '';
  1340. DB::table('QPAccountsDB.dbo.IndividualDatum')
  1341. ->where('UserID', $id)
  1342. ->update(['UserNote' => $remark]);
  1343. return apiReturnSuc();
  1344. }
  1345. // 模拟器开关
  1346. public function androidCheck(Request $request)
  1347. {
  1348. if ($request->isMethod('post')) {
  1349. $StatusValue = (int)$request->StatusValue;
  1350. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  1351. ->where('StatusName', 'AndroidCheck')
  1352. ->update(['StatusValue' => $StatusValue]);
  1353. $admin_id = session('admin')->id;
  1354. CreateLog::SystemStatusInfo_log($admin_id, 'AgentCommisionState');
  1355. return apiReturnSuc();
  1356. } else {
  1357. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  1358. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', 'si.StatusName', 'log.StatusName')
  1359. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  1360. ->select('StatusString', 'StatusValue', 'account', 'create_at')
  1361. ->where('si.StatusName', 'AndroidCheck')
  1362. ->get();
  1363. return view('admin.global.androidCheck', [
  1364. 'list' => $list
  1365. ]);
  1366. }
  1367. }
  1368. // 推广赚金池数值修改
  1369. public function agent_reward(Request $request)
  1370. {
  1371. if ($request->method() == 'POST') {
  1372. $val = abs($request->StatusValue) ?: 0;
  1373. $val *= 100;
  1374. $r = DB::table('QPAccountsDB.dbo.SystemAgentReward')->update(['InitReward' => $val]);
  1375. if ($r) {
  1376. return apiReturnSuc();
  1377. }
  1378. return apiReturnFail('推广赚金池数值修改失败');
  1379. } else {
  1380. $value = DB::table('QPAccountsDB.dbo.SystemAgentReward')->value('InitReward');
  1381. $value = $value / 100;
  1382. return view('admin.global.agent_reward', compact('value'));
  1383. }
  1384. }
  1385. // 修改用户标签
  1386. public function update_label(Request $request, $id)
  1387. {
  1388. $type = $request->type ?: '';
  1389. if ($request->isMethod('post')) {
  1390. switch ($type) {
  1391. case 1:
  1392. StoredProcedure::user_label($id, 8);
  1393. break;
  1394. case 20:
  1395. StoredProcedure::user_label($id, 6);
  1396. break;
  1397. case 21:
  1398. StoredProcedure::user_label($id, 7);
  1399. break;
  1400. }
  1401. return apiReturnSuc();
  1402. } else {
  1403. $type = DB::connection('read')->table('QPAccountsDB.dbo.AccountLabelDanControlLabel')->where('UserID', $id)->value('type');
  1404. $label = [
  1405. 20 => '其他1',
  1406. 21 => '其他2'
  1407. ];
  1408. return view('admin.global.update_label', [
  1409. 'label' => $label,
  1410. 'type' => $type,
  1411. 'UserID' => $id
  1412. ]);
  1413. }
  1414. }
  1415. // 推广佣金开关
  1416. public function AgentCommisionState(Request $request)
  1417. {
  1418. if ($request->isMethod('post')) {
  1419. $StatusValue = (int)$request->StatusValue;
  1420. DB::table('QPAccountsDB.dbo.SystemStatusInfo')
  1421. ->where('StatusName', 'AgentCommisionState')
  1422. ->update(['StatusValue' => $StatusValue]);
  1423. $admin_id = session('admin')->id;
  1424. CreateLog::SystemStatusInfo_log($admin_id, 'AgentCommisionState');
  1425. return apiReturnSuc();
  1426. } else {
  1427. $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  1428. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', 'si.StatusName', 'log.StatusName')
  1429. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  1430. ->select('StatusString', 'StatusValue', 'account', 'create_at')
  1431. ->where('si.StatusName', 'AgentCommisionState')
  1432. ->get();
  1433. return view('admin.global.agentCommisionState', [
  1434. 'list' => $list
  1435. ]);
  1436. }
  1437. }
  1438. // 清理玩家卡房间
  1439. public function deleteRoom($UserID)
  1440. {
  1441. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreLocker')
  1442. ->where('UserID', $UserID)
  1443. ->delete();
  1444. return apiReturnSuc();
  1445. }
  1446. public function control_statistics()
  1447. {
  1448. // +-------------------------------------
  1449. // 普通玩家
  1450. // +-------------------------------------
  1451. $now_time = '2021-11-17 14:25:00';
  1452. // 普通玩家 -- 控制分数
  1453. $ptAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1454. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1455. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1456. ->whereNull('iu.UserID')
  1457. ->where('ControlDate', '>', $now_time)
  1458. ->where('ControlState', 0)
  1459. ->selectRaw('sum(abs(ControlScore)) / 100 ControlScore')
  1460. ->first()->ControlScore ?? 0;
  1461. // 普通玩家 -- 控制赢分数
  1462. $ptWinAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1463. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1464. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1465. ->whereNull('iu.UserID')
  1466. ->where('ControlDate', '>', $now_time)
  1467. ->where('ControlState', 0)
  1468. ->where('ControlScore', '>', 0)
  1469. ->selectRaw('sum(ControlScore) /100 ControlScore,sum(EffectiveScore) /100 EffectiveScore')
  1470. ->first();
  1471. // 普通玩家 -- 控制输分数
  1472. $ptLoseAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1473. ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1474. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1475. ->whereNull('iu.UserID')
  1476. ->where('ControlDate', '>', $now_time)
  1477. ->where('ControlState', 0)
  1478. ->where('ControlScore', '<', 0)
  1479. ->selectRaw('sum(ControlScore) / 100 ControlScore')
  1480. ->first()->ControlScore ?? 0;
  1481. // +-------------------------------------
  1482. // 分界线--------------------------------官方玩家-----------------------------------------------------
  1483. // +-------------------------------------
  1484. // 官方玩家 -- 控制分数
  1485. $gfAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1486. ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1487. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1488. ->where('ControlState', 0)
  1489. ->where('ControlDate', '>', $now_time)
  1490. ->selectRaw('sum(abs(ControlScore)) / 100 ControlScore')
  1491. ->first()->ControlScore ?? 0;
  1492. // 官方玩家 -- 控制赢分数
  1493. $gfWinAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1494. ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1495. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1496. ->where('ControlState', 0)
  1497. ->where('ControlDate', '>', $now_time)
  1498. ->where('ControlScore', '>', 0)
  1499. ->selectRaw('sum(ControlScore) / 100 ControlScore,sum(EffectiveScore) /100 EffectiveScore')
  1500. ->first();
  1501. // 官方玩家 -- 控制输分数
  1502. $gfLoseAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  1503. ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
  1504. ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
  1505. ->where('ControlState', 0)
  1506. ->where('ControlDate', '>', $now_time)
  1507. ->where('ControlScore', '<', 0)
  1508. ->selectRaw('sum(ControlScore) / 100 ControlScore')
  1509. ->first()->ControlScore ?? 0;
  1510. $ptTotal = $ptLoseAccounts + ($ptWinAccounts->EffectiveScore ?? 0);
  1511. $gfTotal = $gfLoseAccounts + ($gfWinAccounts->EffectiveScore ?? 0);
  1512. $data = compact('ptAccounts', 'ptLoseAccounts', 'ptWinAccounts', 'gfAccounts', 'gfLoseAccounts', 'gfWinAccounts', 'ptTotal', 'gfTotal');
  1513. return view('admin.global.control_statistics', $data);
  1514. }
  1515. // 用户头像审核列表
  1516. public function headAudit(Request $request)
  1517. {
  1518. $GameID = $request->GameID ?: '';
  1519. $start_time = $request->start_time ?: '';
  1520. $end_time = $request->end_time ?: '';
  1521. $where[] = ['Status', 0];
  1522. if (!empty($UserID)) {
  1523. $UserID = AccountsInfo::GetUserID($GameID);
  1524. $where[] = ['ua.UserID', $UserID];
  1525. }
  1526. if (!empty($start_time)) $where[] = ['CreateTime', '>=', $start_time];
  1527. if (!empty($end_time)) $where[] = ['CreateTime', '<=', $end_time];
  1528. $list = DB::table(TableName::agent() . 'UserHeadAuditoria as ua')
  1529. ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ua.UserID', 'ai.UserID')
  1530. ->select('Image', 'GameID', 'ua.UserID', 'ua.CreateTime')
  1531. ->where($where)->paginate(10);
  1532. return view('admin.global.head_audit', compact('list', 'GameID', 'start_time', 'end_time'));
  1533. }
  1534. // 头像审核
  1535. public function headAuditUpdate(Request $request, $UserID)
  1536. {
  1537. $status = $request->Status;
  1538. DB::table(TableName::agent() . 'UserHeadAuditoria')
  1539. ->where('UserID', $UserID)
  1540. ->update(['Status' => $status]);
  1541. if ($status == 1) {
  1542. $Image = DB::table(TableName::agent() . 'UserHeadAuditoria')->where('UserID', $UserID)->value('Image');
  1543. DB::connection('write')->table(TableName::QPAccountsDB() . 'AccountHead')
  1544. ->updateOrInsert(['UserID' => $UserID], ['UserID' => $UserID, 'Image' => 'http://' . $request->getHttpHost() . DIRECTORY_SEPARATOR . $Image, 'LastTime' => now()]);
  1545. }
  1546. return apiReturnSuc();
  1547. }
  1548. // 增加用户可提额度
  1549. public function add_draw_base(Request $request, $UserID)
  1550. {
  1551. if ($request->isMethod('post')) {
  1552. $draw_base = (int)$request->add_draw_base;
  1553. // if ($draw_base < 0) return apiReturnFail('请输入正确的可提额度');
  1554. $draw_base = $draw_base * NumConfig::NUM_VALUE;
  1555. // 判断额度
  1556. $dayVerify = DB::table(TableName::agent() . 'add_draw_base')->where('user_id', $UserID)->whereDate('create_time', date('Y-m-d'))->sum('draw_base');
  1557. if ($dayVerify >= 10000 * NumConfig::NUM_VALUE) {
  1558. return apiReturnFail('单日用户最大额度一万');
  1559. }
  1560. $allVerify = DB::table(TableName::agent() . 'add_draw_base')->sum('draw_base');
  1561. if ($allVerify >= 100000 * NumConfig::NUM_VALUE) {
  1562. return apiReturnFail('总额度不足,联系管理员,最大额度五万');
  1563. }
  1564. // 增加可提额度
  1565. if (DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->first()) {
  1566. DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->increment('DrawBase', $draw_base);
  1567. } else {
  1568. DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->insert(['UserID' => $UserID, 'DrawBase' => $draw_base]);
  1569. }
  1570. // 增加记录
  1571. DB::table(TableName::agent() . 'add_draw_base')
  1572. ->insert([
  1573. 'user_id' => $UserID,
  1574. 'draw_base' => $draw_base,
  1575. 'create_time' => now(),
  1576. 'admin_id' => session('admin')['id']
  1577. ]);
  1578. return apiReturnSuc();
  1579. }
  1580. return view('admin.global.add_draw_base', compact('UserID'));
  1581. }
  1582. public function add_tax(Request $request, $UserID)
  1583. {
  1584. if ($request->isMethod('post')) {
  1585. $add_tax = (int)$request->add_tax;
  1586. $draw_base = $add_tax * NumConfig::NUM_VALUE;
  1587. //if($draw_base>0){
  1588. DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')->where('UserID', $UserID)->increment('Revenue', $draw_base);
  1589. //}
  1590. return apiReturnSuc();
  1591. }
  1592. return view('admin.global.add_tax', compact('UserID'));
  1593. }
  1594. public function force_stock_mode(Request $request, $UserID)
  1595. {
  1596. // 常量定义
  1597. $USER_RIGHT_FORCE_STOCKMODE1 = 0b00000001; // 强制使用普通控制模式
  1598. $USER_RIGHT_FORCE_STOCKMODE2 = 0b00000010; // 强制使用库存模式2
  1599. if ($request->isMethod('post')) {
  1600. $force_mode = (int)$request->force_mode;
  1601. // 获取当前UserRight值
  1602. $gameScoreInfo = DB::table('QPTreasureDB.dbo.GameScoreInfo')
  1603. ->where('UserID', $UserID)
  1604. ->select('UserRight')
  1605. ->first();
  1606. if (!$gameScoreInfo) {
  1607. return apiReturnFail('用户不存在');
  1608. }
  1609. $currentUserRight = (int)($gameScoreInfo->UserRight ?? 0);
  1610. // 清除现有的强制模式标志
  1611. $newUserRight = $currentUserRight & ~($USER_RIGHT_FORCE_STOCKMODE1 | $USER_RIGHT_FORCE_STOCKMODE2);
  1612. // 根据选择设置新的强制模式
  1613. switch ($force_mode) {
  1614. case 1: // 强制使用普通控制模式
  1615. $newUserRight |= $USER_RIGHT_FORCE_STOCKMODE1;
  1616. break;
  1617. case 2: // 强制使用库存模式2
  1618. $newUserRight |= $USER_RIGHT_FORCE_STOCKMODE2;
  1619. break;
  1620. case 0: // 关闭所有强制模式
  1621. default:
  1622. // 已经清除了标志,无需额外操作
  1623. break;
  1624. }
  1625. // 更新UserRight
  1626. DB::table('QPTreasureDB.dbo.GameScoreInfo')
  1627. ->where('UserID', $UserID)
  1628. ->update(['UserRight' => $newUserRight]);
  1629. return apiReturnSuc('操作成功');
  1630. }
  1631. // 获取当前模式状态
  1632. $gameScoreInfo = DB::table('QPTreasureDB.dbo.GameScoreInfo')
  1633. ->where('UserID', $UserID)
  1634. ->select('UserRight')
  1635. ->first();
  1636. $userRight = (int)($gameScoreInfo->UserRight ?? 0);
  1637. $isForceStockMode1 = ($userRight & $USER_RIGHT_FORCE_STOCKMODE1) !== 0;
  1638. $isForceStockMode2 = ($userRight & $USER_RIGHT_FORCE_STOCKMODE2) !== 0;
  1639. return view('admin.global.force_stock_mode', compact('UserID', 'isForceStockMode1', 'isForceStockMode2'));
  1640. }
  1641. // 推广限制开关
  1642. public function register_invite_switches(Request $request, $UserID)
  1643. {
  1644. $Value = $request->Value;
  1645. $redis = Redis::connection();
  1646. $redis->set('register_invite_switches_' . $UserID, $Value);
  1647. return apiReturnSuc();
  1648. }
  1649. public function platformRecord(Request $request)
  1650. {
  1651. $date = $request->date ?: date('Y-m-d',strtotime('-1 days'));
  1652. $dateFormat = date('Ymd',strtotime($date));
  1653. if($dateFormat == date('Ymd')){
  1654. $list = [];
  1655. $platform = ['only','atmosfera','pg','pp'];
  1656. foreach ($platform as $pItem) {
  1657. $platformRecord = [
  1658. 'lid' => 0,
  1659. 'ldate' => $dateFormat,
  1660. 'platform' => $pItem,
  1661. 'all_bet' => Redis::get('platform_' . $pItem . '_bet') ?: 0,
  1662. 'all_win' => Redis::get('platform_' . $pItem . '_win') ?: 0,
  1663. 'current_bet' => Redis::get('platform_' . $pItem . '_bet_' . $dateFormat) ?: 0,
  1664. 'current_win' => Redis::get('platform_' . $pItem . '_win_' . $dateFormat) ?: 0,
  1665. 'current_play' => Redis::get('platform_' . $pItem . '_play_' . $dateFormat) ?: 0,
  1666. // 'sub_detail' => ''
  1667. ];
  1668. array_push($list, $platformRecord);
  1669. }
  1670. $list = json_decode(json_encode($list));
  1671. }else{
  1672. $list = DB::connection('mysql')->table('record_platform_data')->where('ldate', $dateFormat)->get();
  1673. }
  1674. $monthStart = date('Ym',strtotime($date)).'01';
  1675. $monthEnd = date('Ym',strtotime($date)).'31';
  1676. $where= [['ldate', '<=', $monthEnd],['ldate', '>=', $monthStart]];
  1677. $monthData = DB::connection('mysql')->table('record_platform_data')
  1678. ->where($where)
  1679. ->selectRaw('sum(current_bet) month_bet,sum(current_win) month_win,platform')
  1680. ->groupBy('platform')
  1681. ->get();
  1682. return view('admin.global.platformRecord', compact('list', 'date', 'monthData'));
  1683. }
  1684. public function platformSub($id)
  1685. {
  1686. // if($id>0){
  1687. // $record = DB::connection('mysql')->table('record_platform_data')->where('lid', $id)->first();
  1688. // }else{
  1689. // $DateID = date('Ymd');
  1690. //
  1691. // $only=GameCard::where('brand','OnlyPlay')->where('state','<>',0)->pluck('gid')->toArray();
  1692. //
  1693. // $atmosfera=[71,74,85,86,87,88,89,92,93];
  1694. // $platform = ['only','atmosfera'];
  1695. // foreach ($platform as $pItem){
  1696. //
  1697. // $gameType = ($pItem == 'only'?$only:$atmosfera);
  1698. // if(is_array($gameType)){
  1699. // $subData = [];
  1700. // foreach ($gameType as $item){
  1701. // $betkey = 'platform_'.$pItem.'_'.$item. '_bet_' . $DateID;
  1702. //
  1703. // $winkey = 'platform_'.$pItem.'_'.$item. '_win_' . $DateID;
  1704. //
  1705. // $playkey = 'platform_'.$pItem.'_'.$item.'_play_' . $DateID;
  1706. // $subData[$item] = ['current_bet' => Redis::get($betkey)?:0,'current_win' =>Redis::get($winkey)?:0,'current_play' =>Redis::get($playkey)?:0 ];
  1707. // }
  1708. // $platformRecord['sub_detail'] = json_encode($subData);
  1709. // }
  1710. // }
  1711. // }
  1712. $record = DB::connection('mysql')->table('record_platform_data')->where('lid', $id)->first();
  1713. $subDetail = [];
  1714. $atmosferaMap=[
  1715. 71 => 'Live-Roulette-EN',
  1716. 74 => 'Keno',
  1717. 85 => 'Auto-Roulette',
  1718. 86 => 'Blackjack-A',
  1719. 87 => 'Blackjack-B',
  1720. 88 => 'Blackjack-C',
  1721. 89 => 'Blackjack-D',
  1722. 92 => 'Cocktail-Roulette',
  1723. 93 => 'Blackjack-E'
  1724. ];
  1725. if($record){
  1726. if($record->sub_detail){
  1727. $subDetail = json_decode($record->sub_detail,true);
  1728. if(is_array($subDetail)){
  1729. if($record->platform == 'atmosfera'){
  1730. $newArr = [];
  1731. foreach ($subDetail as $kk => $vv){
  1732. $newArr[$atmosferaMap[$kk]] = $vv;
  1733. }
  1734. $subDetail = $newArr;
  1735. }
  1736. // current_play
  1737. $subDetail = Util::arraySort($subDetail,'current_play',SORT_DESC);
  1738. }
  1739. }
  1740. }
  1741. return view('admin.global.platform_sub_data', compact('id', 'subDetail'));
  1742. }
  1743. }