GlobalController.php 94 KB

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