GlobalController.php 93 KB

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