GlobalUser.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  1. <?php
  2. namespace App\Services;
  3. use App\Facade\Redis;
  4. use App\Facade\TableName;
  5. use App\Http\helper\HttpCurl;
  6. use App\Http\helper\NumConfig;
  7. use App\Http\logic\admin\GlobalLogicController;
  8. use App\Http\logic\api\BaseApiLogic;
  9. use App\Models\AccountsInfo;
  10. use App\Models\Control;
  11. use App\Models\Order;
  12. use App\Models\RecordPlatformData;
  13. use App\Models\Withdrawal;
  14. use App\Util;
  15. use Illuminate\Support\Arr;
  16. use Illuminate\Support\Facades\DB;
  17. class GlobalUser extends BaseApiLogic
  18. {
  19. public function onLineUser($index, $count = 10)
  20. {
  21. $admin = session('admin');
  22. $account = $admin->account ?: '';
  23. $password = $admin->password ?: '';
  24. $url = config('transfer.stock')['url'] . 'queryOnlineByPage';
  25. $index = $index > 0 ? ($index - 1) * $count : 0;
  26. $data = [
  27. 'accounts' => $account,
  28. 'passworld' => $password,
  29. 'pos' => $index,
  30. 'count' => $count
  31. ];
  32. $build_query = $url . '?' . http_build_query($data);
  33. $json_decode = (new HttpCurl())->curl_get($build_query);
  34. if (empty($json_decode)) {
  35. $output = [];
  36. } else {
  37. $output = \GuzzleHttp\json_decode($json_decode, true);
  38. }
  39. $data = [];
  40. if (is_array($output)) {
  41. $toArr = explode(',', $output['data'] ?? '');
  42. $data['UserIDs'] = $toArr;
  43. $data['total'] = $output['total'];
  44. }
  45. return $data;
  46. }
  47. public function userlist($gameID, $phoneNum, $spreaderID, $nickName, $mobileModel, $startTime, $endTime, $obj, $vip, $excel, $accountsType, $channel, $user_tab, $packgeName, $quickSearch, $score,$MachineID,$startLoginTime='',$endLoginTime='')
  48. {
  49. $quickSearch = explode(',', trim($quickSearch, ','));
  50. $AccountsInfoM = new AccountsInfo();
  51. $StatusValue = DB::connection('read')->table('QPAccountsDB.dbo.SystemStatusInfo')
  52. ->where('StatusName', 'WithDrawPoint')
  53. ->select('StatusValue')
  54. ->lock('with(nolock)')
  55. ->first()->StatusValue ?? 0;
  56. $adminChannels=session('admin_channels');
  57. $field = ['ai.GameID', 'ai.UserID', 'ai.SpreaderID', 'ai.NickName', 'ai.MemberOrder', 'ai.Nullity', 'ai.WebLogonTimes', 'ai.LastLogonIP', 'ai.LastLogonDate', 'ai.LastLogonMobile', 'ai.RegisterIP', 'ai.RegisterDate', 'ai.Channel', 'gi.Score', 'gi.InsureScore', 'gi.MaxScore', 'gi.MaxWinScore'];
  58. $Sql = DB::connection('read')->table(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'))
  59. ->leftJoin(DB::raw(TableName::QPTreasureDB() . 'GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', 'gi.UserID')
  60. ->where('ai.IsAndroid', 0)
  61. ->select($field);
  62. if(count($adminChannels)<5)$Sql=$Sql->whereIn('ai.Channel', $adminChannels);
  63. $where = [];
  64. if (!empty($gameID))
  65. $where[] = ['ai.GameID', $gameID];
  66. if (!empty($MachineID))
  67. $where[] = ['ai.LastLogonMachine', $MachineID];
  68. if (!empty($nickName))
  69. $where[] = ['ai.NickName', $nickName];
  70. if (!empty($mobileModel))
  71. $where[] = ['ai.LastLogonMobile', '=', $mobileModel];
  72. if (!empty($startTime))
  73. $where[] = ['ai.RegisterDate', '>=', $startTime];
  74. if (!empty($endTime))
  75. $where[] = ['ai.RegisterDate', '<=', $endTime];
  76. if (!empty($startLoginTime))
  77. $where[] = ['ai.LastLogonDate', '>=', $startLoginTime];
  78. if (!empty($endLoginTime))
  79. $where[] = ['ai.LastLogonDate', '<=', $endLoginTime];
  80. if (!empty($vip))
  81. $where[] = ['ai.MemberOrder', $vip];
  82. if (!empty($channel))
  83. $where[] = ['ai.Channel', $channel];
  84. if (!empty($packgeName)) {
  85. $Sql = $Sql->join(TableName::QPRecordDB() . 'RecordPackageName as rn', 'ai.UserID')->where('PackgeName', $packgeName);
  86. }
  87. if (!empty($phoneNum)) {
  88. $Sql = $Sql->join(TableName::QPAccountsDB() . 'AccountPhone as ap', 'ai.UserID', 'ap.UserID')
  89. ->where('ap.PhoneNum', $phoneNum);
  90. }
  91. if (!empty($spreaderID)) {
  92. $Sql = $Sql->join(TableName::QPAccountsDB() . 'AccountsInfo as ai1', 'ai1.UserID', 'ai.SpreaderID')
  93. ->where('ai1.GameID', $spreaderID);
  94. }
  95. if (!empty($accountsType)) {
  96. if ($accountsType < 4 && empty($phoneNum)) {
  97. $Sql = $Sql->join(TableName::QPAccountsDB() . 'AccountPhone as ap', 'ai.UserID', 'ap.UserID');
  98. }
  99. switch ($accountsType) {
  100. case 1:
  101. $Sql = $Sql->where('ai.WebLogonTimes', 0)->whereNull('PhoneNum');
  102. break;
  103. case 2:
  104. $Sql = $Sql->where('ai.WebLogonTimes', 1)->whereNull('PhoneNum');
  105. break;
  106. case 3:
  107. $Sql = $Sql->WhereNotNull('PhoneNum');
  108. break;
  109. case 4:
  110. $Sql = $Sql->where('ai.Channel', 100);
  111. break;
  112. }
  113. }
  114. // 快速搜索
  115. if (!empty($quickSearch)) {
  116. // 游戏中
  117. if (in_array(1, $quickSearch)) {
  118. $Sql = $Sql->join(TableName::QPTreasureDB() . 'GameScoreLocker as gsl', 'gsl.UserID', 'ai.UserID')
  119. ->whereRaw('datediff(hh,CollectDate,getdate())<=5');
  120. }
  121. // 未实名
  122. if (in_array(2, $quickSearch)) {
  123. $Sql = $Sql->where('ai.PassPortID', '');
  124. }
  125. // 无手机号
  126. if (in_array(3, $quickSearch)) {
  127. $Sql = $Sql->whereNotExists(function ($query) {
  128. $query->from(TableName::QPAccountsDB() . 'AccountPhone as ap')
  129. ->whereRaw('ap.UserID=ai.UserID and ap.PhoneNum is not null');
  130. });
  131. }
  132. // 同IP
  133. if (in_array(4, $quickSearch)) {
  134. // TODO
  135. }
  136. // 无渠道
  137. if (in_array(5, $quickSearch)) {
  138. $Sql = $Sql->where('ai.Channel', 0);
  139. }
  140. // 未充值
  141. if (in_array(6, $quickSearch)) {
  142. $Sql = $Sql->whereNotExists(function ($query) {
  143. $query->from(TableName::QPRecordDB() . 'RecordUserTotalStatistics AS rts')
  144. ->where('Recharge', '>', 0)
  145. ->whereRaw('ai.UserID=rts.UserID');
  146. });
  147. }
  148. // 无上级
  149. if (in_array(7, $quickSearch)) {
  150. $Sql = $Sql->whereExists(function ($query) {
  151. $query->from(TableName::QPAccountsDB() . 'AccountsInfo AS ai1')
  152. ->where('SpreaderID', 0)
  153. ->whereRaw('ai.UserID=ai1.UserID');
  154. });
  155. }
  156. // 封号中
  157. if (in_array(8, $quickSearch)) {
  158. $Sql = $Sql->where('Nullity', 1);
  159. }
  160. // 官方账号
  161. if (in_array(9, $quickSearch)) {
  162. $Sql = $Sql->whereNotExists(function ($query) {
  163. $query->from(TableName::QPAccountsDB() . 'IDWhiteUser AS iu')
  164. ->whereRaw('ai.UserID=iu.UserID');
  165. });
  166. }
  167. }
  168. if (!empty($score)) {
  169. $orderBy = "Score $score";
  170. } else {
  171. $orderBy = 'ai.RegisterDate desc';
  172. }
  173. $list = $Sql->where($where)->orderByRaw($orderBy)->paginate(10);
  174. // 取出用户ID
  175. $UserIDs = [];
  176. foreach ($list as $value) {
  177. $UserIDs[] = $value->UserID;
  178. }
  179. // 用户上级ID
  180. $spreaderIDs = $AccountsInfoM->accountSpreaderID($UserIDs);
  181. // 输赢
  182. $winLost = $AccountsInfoM->accountWinLost($UserIDs);
  183. // 今日充值-- 今日提现-- 今日彩金 -- 总输赢
  184. $today = $AccountsInfoM->accountTodayStatistics($UserIDs);
  185. // 全部充值 -- 提现 -- 彩金 -- 总输赢 -- 总得提现手续费
  186. $total = $AccountsInfoM->accountTotalStatistics($UserIDs);
  187. // 游戏是否在线
  188. $userOnLine = DB::connection('read')->table(TableName::QPTreasureDB() . 'GameScoreLocker as gsl')
  189. ->whereIn('UserID', $UserIDs)
  190. ->join(TableName::QPPlatformDB() . 'GameRoomInfo as gri', 'gsl.ServerID', 'gri.ServerID')
  191. ->whereRaw('datediff(hh,CollectDate,getdate())<=5')
  192. ->select('ServerName', 'UserID')
  193. ->pluck('ServerName', 'UserID')->toArray();
  194. // 用户手机号
  195. $PhoneNums = $AccountsInfoM->accountPhone($UserIDs);
  196. foreach ($list as &$value) {
  197. $value->spreaderID = isset($spreaderIDs[$value->UserID]) ? $spreaderIDs[$value->UserID] : '';
  198. $value->winLost = isset($winLost[$value->UserID]) ? $winLost[$value->UserID] : '';
  199. $value->ServerName = isset($userOnLine[$value->UserID]) ? $userOnLine[$value->UserID] : '';
  200. $value->PhoneNum = isset($PhoneNums[$value->UserID]) ? $PhoneNums[$value->UserID] : '';
  201. $value->Nullity = $value->Nullity == 0 ? '正常' : '封禁';
  202. $value->Score = $value->Score / NumConfig::NUM_VALUE;
  203. $value->InsureScore = $value->InsureScore / NumConfig::NUM_VALUE;
  204. $value->MaxScore = $value->MaxScore / NumConfig::NUM_VALUE;
  205. $value->MaxWinScore = $value->MaxWinScore / NumConfig::NUM_VALUE;
  206. // 可提现额度
  207. $value->CashAble = $AccountsInfoM->CashAble($value->UserID, $value->Score, $StatusValue);
  208. foreach ($today as $val) {
  209. if ($val->UserID == $value->UserID) {
  210. $value->todayWithdraw = $val->Withdraw / NumConfig::NUM_VALUE;
  211. $value->todayScore = $val->Score / NumConfig::NUM_VALUE;
  212. $value->todayRecharge = $val->Recharge;
  213. $value->todayHandsel = $val->Handsel / NumConfig::NUM_VALUE;
  214. }
  215. }
  216. foreach ($total as $val) {
  217. if ($val->UserID == $value->UserID) {
  218. $value->totalWithdraw = $val->Withdraw / NumConfig::NUM_VALUE;
  219. $value->totalScore = $val->Score / NumConfig::NUM_VALUE;
  220. $value->totalRecharge = $val->Recharge;
  221. $value->totalHandsel = $val->Handsel / NumConfig::NUM_VALUE;
  222. }
  223. }
  224. }
  225. return $list;
  226. }
  227. public function userNewList($gameID, $startTime, $endTime, $lstartTime, $lendTime, $channel, $minRecharge, $maxRecharge,$excel)
  228. {
  229. $field = ['ai.GameID','ai.UserID', 'ai.NickName','gi.Score', 'ai.Nullity', 'ai.LastLogonDate', 'ai.RegisterDate', 'ai.Channel', 'ap.PhoneNum','Recharge','Withdraw','LostScore','WinScore'];
  230. $Sql = DB::connection('read')->table(TableName::QPAccountsDB() . 'AccountsInfo as ai')
  231. ->leftJoin(TableName::QPTreasureDB() . 'GameScoreInfo as gi', 'ai.UserID', 'gi.UserID')
  232. ->leftJoin(TableName::QPAccountsDB() . 'AccountPhone as ap', 'ai.UserID', 'ap.UserID')
  233. ->leftJoin(TableName::QPRecordDB().'RecordUserTotalStatistics as rut','ai.UserID', 'rut.UserID')
  234. ->where('ai.IsAndroid', 0)
  235. ->select($field);
  236. // return DB::connection('read')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
  237. // ->selectRaw('Recharge,Withdraw,Handsel,(WinScore + LostScore) Score,ServiceFee,UserID,Revenue')
  238. // ->whereIn('UserID', $UserIDs)
  239. // ->get();
  240. $where = [];
  241. if (!empty($gameID))
  242. $where[] = ['ai.GameID', $gameID];
  243. if (!empty($startTime))
  244. $where[] = ['ai.RegisterDate', '>=', $startTime];
  245. if (!empty($endTime))
  246. $where[] = ['ai.RegisterDate', '<=', $endTime];
  247. if (!empty($lstartTime))
  248. $where[] = ['ai.LastLogonDate', '>=', $lstartTime];
  249. if (!empty($lendTime))
  250. $where[] = ['ai.LastLogonDate', '<=', $lendTime];
  251. if (!empty($minRecharge))
  252. $where[] = ['rut.Recharge', '>=', $minRecharge];
  253. if (!empty($maxRecharge))
  254. $where[] = ['rut.Recharge', '<=', $maxRecharge];
  255. if (!empty($channel))
  256. $where[] = ['ai.Channel', $channel];
  257. $orderBy = 'ai.UserID desc';
  258. if($excel){
  259. $list = $Sql->where($where)->orderByRaw($orderBy)->limit(1000)->get();
  260. $list = json_decode(json_encode($list),true);
  261. //var_dump($list);
  262. //exit();
  263. foreach ($list as &$value) {
  264. $value['Nullity'] = $value['Nullity'] == 0 ? '正常' : '封禁';
  265. $value['Score'] = (string)round($value['Score'] / NumConfig::NUM_VALUE, 2);
  266. $value['Withdraw'] = (string)round(($value['Withdraw'] ?? 0) / NumConfig::NUM_VALUE, 2);
  267. $value['Recharge'] = (string)($value['Recharge'] ?? 0);
  268. $value['totalScore'] = (string)round(intval(($value['WinScore'] ?? 0) + ($value['LostScore'] ?? 0)) / NumConfig::NUM_VALUE, 2);
  269. unset($value['WinScore']);
  270. unset($value['LostScore']);
  271. }
  272. //dd($list);
  273. $title = ['UserID', '玩家ID', '昵称','余额', '状态', '离线时间', '注册时间', '玩家渠道', '手机号', '充值', '提现', '输赢'];
  274. // $cellData = json_decode(json_encode($list), true);
  275. downloadExcel($list, $title, '用户列表');
  276. return;
  277. }
  278. $list = $Sql->where($where)->orderByRaw($orderBy)->paginate(10);
  279. foreach ($list as &$value) {
  280. $value->Nullity = $value->Nullity == 0 ? '正常' : '封禁';
  281. $value->Score = $value->Score / NumConfig::NUM_VALUE;
  282. $value->totalScore = ($value->WinScore+$value->LostScore)/NumConfig::NUM_VALUE;
  283. $value->Withdraw = $value->Withdraw / NumConfig::NUM_VALUE;
  284. }
  285. return $list;
  286. }
  287. public function dk_userlist($GameID, $SpreaderID, $NickName, $start_time, $end_time, $user_label, $is_line, $game_room, $UserScoreControl, $ScoreSort, $amountSort, $sort_tx, $sort_date, $ChangeScore_sort, $Channel, $label_sort, $ServerNameSort)
  288. {
  289. $AccountsInfoM = new AccountsInfo();
  290. $StatusValue = DB::connection('read')->table('QPAccountsDB.dbo.SystemStatusInfo')
  291. ->where('StatusName', 'WithDrawPoint')
  292. ->select('StatusValue')
  293. ->lock('with(nolock)')
  294. ->first()->StatusValue ?? 0;
  295. $where = [];
  296. $field = ['ai.GameID', 'ai.UserID', 'ai.SpreaderID', 'ai.NickName', 'ai.MemberOrder', 'ai.Nullity', 'ai.WebLogonTimes', 'ai.LastLogonIP', 'ai.LastLogonDate', 'ai.RegisterIP', 'ai.RegisterDate', 'ai.Channel', 'gi.Score'];
  297. $Sql = DB::connection('read')->table(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'))
  298. ->where('ai.IsAndroid', 0)
  299. ->leftJoin(DB::raw(TableName::QPTreasureDB() . 'GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', 'gi.UserID')
  300. ->select($field);
  301. if (!empty($GameID))
  302. $where[] = ['ai.GameID', $GameID];
  303. if (!empty($NickName))
  304. $where[] = ['ai.NickName', $NickName];
  305. if (!empty($Channel) || $Channel === '0')
  306. $where[] = ['ai.Channel', '=', $Channel];
  307. if (!empty($start_time))
  308. $where[] = ['ai.RegisterDate', '>=', $start_time];
  309. if (!empty($end_time))
  310. $where[] = ['ai.RegisterDate', '<=', $end_time];
  311. if (!empty($channel))
  312. $where[] = ['ai.Channel', $channel];
  313. if (!empty($user_label))
  314. $Sql = $Sql->join(TableName::QPAccountsDB() . 'AccountLabelDanControlLabel as al', 'ai.UserID', 'al.UserID')
  315. ->where('type', $user_label);
  316. // 充值
  317. if (!empty($amountSort)) {
  318. $Sql = $Sql->join(TableName::QPAccountsDB() . 'YN_VIPAccount as vip', 'ai.UserID', 'vip.UserID')->orderByRaw("vip.Recharge $amountSort");
  319. }
  320. // 提现
  321. if (!empty($sort_tx)) {
  322. $Sql = $Sql->leftJoin(TableName::QPAccountsDB() . 'UserTabData as ud', 'ai.UserID', 'ud.UserID')->orderByRaw("TakeMoney $sort_tx");
  323. }
  324. if (!empty($ChangeScore_sort)) {
  325. $Sql = $Sql->leftJoin(TableName::QPRecordDB() . 'RecordUserTotalStatistics as rds', 'rds.UserID', 'ai.UserID')->orderByRaw("(WinScore + LostScore) $ChangeScore_sort");
  326. }
  327. // 受控制用户
  328. switch ($UserScoreControl) {
  329. case 1: // 控制
  330. $Sql = $Sql->whereExists(function ($query) {
  331. $query->from(TableName::QPTreasureDB() . 'UserScoreControl as usc')
  332. ->whereRaw('usc.UserID=ai.UserID');
  333. });
  334. break;
  335. case 2: // 不受控制
  336. $Sql = $Sql->whereNotExists(function ($query) {
  337. $query->from(TableName::QPTreasureDB() . 'UserScoreControl as usc')
  338. ->whereRaw('usc.UserID=ai.UserID');
  339. });
  340. break;
  341. case 3: // 自动控制 + 控制中
  342. $Sql = $Sql->whereExists(function ($query) {
  343. $query->from(TableName::QPTreasureDB() . 'UserScoreControl as usc')
  344. ->whereRaw('usc.UserID=ai.UserID');
  345. })->whereExists(function ($query) {
  346. $query->from(TableName::QPRecordDB() . 'RecordRechargeControl as rc')
  347. ->whereRaw('ai.UserID=rc.UserID and rc.State>0');
  348. });
  349. break;
  350. case 4:
  351. $Sql = $Sql->leftJoin('QPRecordDB.dbo.RecordRechargeControl as rc', 'ai.UserID', 'rc.UserID')
  352. ->Where('rc.State', '>', 0)->whereNull('usc.UserID');
  353. break;
  354. }
  355. if ($is_line == 1 || !empty($game_room)) { // 在线
  356. if (empty($game_room)) {
  357. $Sql = $Sql->whereExists(function ($query) {
  358. $query->from(TableName::QPTreasureDB() . 'GameScoreLocker as gsl')
  359. ->whereRaw('gsl.UserID=ai.UserID and datediff(hh,gsl.CollectDate,getdate())<=5');
  360. });
  361. } else {
  362. $Sql = $Sql->whereExists(function ($query) use ($game_room) {
  363. $query->from(TableName::QPTreasureDB() . 'GameScoreLocker as gsl')
  364. ->whereRaw("gsl.UserID=ai.UserID and datediff(hh,gsl.CollectDate,getdate())<=5 and ServerID=$game_room");
  365. });
  366. }
  367. } elseif ($is_line == 2) { // 离线
  368. $Sql = $Sql->whereNotExists(function ($query) {
  369. $query->from(TableName::QPTreasureDB() . 'GameScoreLocker as gsl')
  370. ->whereRaw('gsl.UserID=ai.UserID');
  371. });
  372. }
  373. if (!empty($spreaderID)) {
  374. $Sql = $Sql->join(TableName::QPAccountsDB() . 'AccountsInfo as ai1', 'ai1.UserID', 'ai.SpreaderID')
  375. ->where('ai1.GameID', $spreaderID);
  376. }
  377. // 金币排序
  378. if (!empty($ScoreSort))
  379. $Sql = $Sql->orderBy('Score', $ScoreSort);
  380. // 日期
  381. if (!empty($sort_date)) {
  382. $Sql = $Sql->orderBy('ai.RegisterDate', $sort_date);
  383. } else {
  384. $Sql = $Sql->orderBy('ai.RegisterDate', 'desc');
  385. }
  386. if (!empty($label_sort)) {
  387. $Sql = $Sql->orderBy('IDColor', $label_sort);
  388. }
  389. $list = $Sql->where($where)->paginate(10);
  390. // 取出用户ID
  391. $UserIDs = [];
  392. foreach ($list as $value) {
  393. $UserIDs[] = $value->UserID;
  394. }
  395. // 用户上级ID
  396. $spreaderIDs = $AccountsInfoM->accountSpreaderID($UserIDs);
  397. // 输赢
  398. $winLost = $AccountsInfoM->accountWinLost($UserIDs);
  399. // 今日充值-- 今日提现-- 今日彩金 -- 总输赢
  400. $today = $AccountsInfoM->accountTodayStatistics($UserIDs);
  401. // 全部充值 -- 提现 -- 彩金 -- 总输赢 -- 总得提现手续费
  402. $total = $AccountsInfoM->accountTotalStatistics($UserIDs);
  403. // 游戏是否在线
  404. $userOnLine = $AccountsInfoM->accountOnLine($UserIDs);
  405. // 用户手机号
  406. $PhoneNums = $AccountsInfoM->accountPhone($UserIDs);
  407. // 用户标签
  408. $AccountLabel = $AccountsInfoM->accountLabel($UserIDs);
  409. // 登录IP
  410. $LoginIP = $AccountsInfoM->LoginIP($UserIDs);
  411. // 备注
  412. $Remarks = $AccountsInfoM->remarks($UserIDs);
  413. // 未领邮件
  414. $mailData = $AccountsInfoM->mail($UserIDs);
  415. // 受控标签
  416. $controlLabel = $AccountsInfoM->controlLabel($UserIDs);
  417. // 单控
  418. $UserScoreControls = DB::table(TableName::QPTreasureDB() . 'UserScoreControl')
  419. ->whereIn('UserID', $UserIDs)
  420. ->select(['ControlRadian', 'ControlScore', 'EffectiveScore', 'UserID'])
  421. ->get();
  422. $redis = \Illuminate\Support\Facades\Redis::connection();
  423. $controlModel = new Control();
  424. $onLinUser = [];
  425. foreach ($userOnLine as $val) {
  426. $onLinUser[$val->UserID] = $val->KindID;
  427. }
  428. foreach ($list as &$value) {
  429. $value->spreaderID = isset($spreaderIDs[$value->UserID]) ? $spreaderIDs[$value->UserID] : '';
  430. $value->winLost = isset($winLost[$value->UserID]) ? $winLost[$value->UserID] : '';
  431. $value->PhoneNum = isset($PhoneNums[$value->UserID]) ? $PhoneNums[$value->UserID] : '';
  432. $value->Nullity = $value->Nullity == 0 ? '正常' : '封禁';
  433. $value->Score = $value->Score / NumConfig::NUM_VALUE;
  434. $value->notReceived = isset($mailData[$value->UserID]) ? number_float($mailData[$value->UserID] / NumConfig::NUM_VALUE) : 0;
  435. $value->RecordRechargeControl = isset($controlLabel[$value->UserID]) ? 1 : 0;
  436. $value->LoginIpCount = isset($LoginIP[$value->UserID]) ? $LoginIP[$value->UserID] : 0;
  437. $value->Remarks = isset($Remarks[$value->UserID]) ? $Remarks[$value->UserID] : '';
  438. // 可提现额度
  439. $value->CashAble = $AccountsInfoM->CashAble($value->UserID, $value->Score, $StatusValue);
  440. $value->control_record = $controlModel->getControlState($value->UserID, $onLinUser);
  441. foreach ($UserScoreControls as $val) {
  442. if ($val->UserID == $value->UserID) {
  443. $value->EffectiveScore = number_float($val->EffectiveScore / NumConfig::NUM_VALUE);
  444. $value->ControlScore = number_float($val->ControlScore / NumConfig::NUM_VALUE);
  445. $value->ControlRadian = $val->ControlRadian ?: number_float($val->ControlRadian);
  446. }
  447. }
  448. foreach ($userOnLine as $val) {
  449. if ($val->UserID == $value->UserID) {
  450. $value->ServerName = $val->ServerName;
  451. // 捕鱼控制
  452. if ($val->KindID == 2003) {
  453. $info = $redis->hmGet("userControl_{$value->UserID}", ['controlLevel', 'controlTarget', 'curControlValue']);
  454. $info['controlTarget'] /= NumConfig::NUM_VALUE;
  455. $info['curControlValue'] /= NumConfig::NUM_VALUE;
  456. // 控制分数
  457. if (!empty($info['controlLevel'])) {
  458. $value->fishControl = '捕鱼:控制等级:' . $info['controlLevel'] . ';控制分数:' . $info['controlTarget'] . ';生效分数:' . $info['curControlValue'];
  459. }
  460. }
  461. }
  462. }
  463. foreach ($today as $val) {
  464. if ($val->UserID == $value->UserID) {
  465. $value->todayWithdraw = $val->Withdraw / NumConfig::NUM_VALUE;
  466. $value->todayScore = $val->Score / NumConfig::NUM_VALUE;
  467. $value->todayRecharge = $val->Recharge;
  468. $value->todayHandsel = $val->Handsel / NumConfig::NUM_VALUE;
  469. }
  470. }
  471. foreach ($total as $val) {
  472. if ($val->UserID == $value->UserID) {
  473. $value->totalWithdraw = $val->Withdraw / NumConfig::NUM_VALUE;
  474. $value->totalScore = $val->Score / NumConfig::NUM_VALUE;
  475. $value->totalRecharge = $val->Recharge;
  476. $value->totalHandsel = $val->Handsel / NumConfig::NUM_VALUE;
  477. }
  478. }
  479. foreach ($AccountLabel as $val) {
  480. if ($val->UserID == $value->UserID) {
  481. $value->IDColor = $val->IDColor;
  482. $value->user_label = $AccountsInfoM->labelType($val->type);
  483. }
  484. }
  485. }
  486. return $list;
  487. }
  488. /**
  489. * 充值排行榜:总充值>100 且 提现/充值<35%
  490. */
  491. public function rechargeRankList($channel, $sortRegister = '', $sortLogin = '')
  492. {
  493. $AccountsInfoM = new AccountsInfo();
  494. $minRecharge = 100;
  495. $numVal = NumConfig::NUM_VALUE;
  496. $giTable = TableName::QPTreasureDB() . 'GameScoreInfo';
  497. $Sql = DB::connection('read')->table(TableName::QPAccountsDB() . 'AccountsInfo as ai')
  498. ->join(TableName::QPRecordDB() . 'RecordUserTotalStatistics as rut', 'ai.UserID', 'rut.UserID')
  499. ->where('ai.IsAndroid', 0)
  500. ->where('rut.Recharge', '>', $minRecharge)
  501. ->whereRaw("rut.Withdraw * 1.0 / (rut.Recharge * {$numVal}) < 0.35")
  502. ->distinct()
  503. ->selectRaw("ai.GameID, ai.UserID, ai.NickName, ai.Channel, ai.RegisterDate, ai.LastLogonDate, (select top 1 Score from {$giTable} where UserID = ai.UserID) as Score, rut.Recharge, rut.Withdraw");
  504. if (!empty($channel) || $channel === '0') {
  505. $Sql->where('ai.Channel', $channel);
  506. }
  507. $adminChannels = session('admin_channels');
  508. if (count($adminChannels) < 5) {
  509. $Sql->whereIn('ai.Channel', $adminChannels);
  510. }
  511. if (!empty($sortRegister) && in_array($sortRegister, ['asc', 'desc'])) {
  512. $Sql->orderBy('ai.RegisterDate', $sortRegister);
  513. } elseif (!empty($sortLogin) && in_array($sortLogin, ['asc', 'desc'])) {
  514. $Sql->orderBy('ai.LastLogonDate', $sortLogin);
  515. } else {
  516. $Sql->orderByRaw('rut.Recharge desc');
  517. }
  518. $list = $Sql->paginate(15);
  519. $UserIDs = [];
  520. foreach ($list as $value) {
  521. $UserIDs[] = $value->UserID;
  522. }
  523. $today = !empty($UserIDs) ? $AccountsInfoM->accountTodayStatistics($UserIDs) : [];
  524. $controlLabel = !empty($UserIDs) ? $AccountsInfoM->controlLabel($UserIDs) : [];
  525. $UserScoreControls = !empty($UserIDs)
  526. ? DB::table(TableName::QPTreasureDB() . 'UserScoreControl')
  527. ->whereIn('UserID', $UserIDs)
  528. ->select(['ControlRadian', 'ControlScore', 'EffectiveScore', 'UserID'])
  529. ->get()
  530. : collect();
  531. $controlModel = new Control();
  532. foreach ($list as &$value) {
  533. $value->Score = ($value->Score ?? 0) / NumConfig::NUM_VALUE;
  534. $recharge = $value->Recharge ?? 0;
  535. $withdraw = ($value->Withdraw ?? 0) / NumConfig::NUM_VALUE;
  536. $value->Recharge = $recharge;
  537. $value->Withdraw = $withdraw;
  538. $value->withdrawRate = $recharge > 0 ? round($withdraw / $recharge * 100, 2) : 0;
  539. $value->todayRecharge = 0;
  540. $value->todayWithdraw = 0;
  541. foreach ($today as $val) {
  542. if ($val->UserID == $value->UserID) {
  543. $value->todayRecharge = $val->Recharge;
  544. $value->todayWithdraw = $val->Withdraw / NumConfig::NUM_VALUE;
  545. }
  546. }
  547. $value->RecordRechargeControl = isset($controlLabel[$value->UserID]) ? 1 : 0;
  548. $value->ControlScore = null;
  549. $value->EffectiveScore = null;
  550. $value->control_record = $controlModel->getControlState($value->UserID, []);
  551. foreach ($UserScoreControls as $val) {
  552. if ($val->UserID == $value->UserID) {
  553. $value->EffectiveScore = number_float($val->EffectiveScore / NumConfig::NUM_VALUE);
  554. $value->ControlScore = number_float($val->ControlScore / NumConfig::NUM_VALUE);
  555. }
  556. }
  557. }
  558. return $list;
  559. }
  560. // 全局报表 - 用户相关
  561. public function accounts()
  562. {
  563. $AccountsInfoModel = new AccountsInfo();
  564. $WithdrawalModel = new Withdrawal();
  565. $GlobalLogic = new GlobalLogicController();
  566. // 用户支付信息
  567. $accountsPayInfo = Order::pay_sum();
  568. $paySum = $accountsPayInfo->Recharge ?? 0;
  569. $payUserCount = $accountsPayInfo->payCount;
  570. // 用户所有提现
  571. $withdraw = $WithdrawalModel->totalWithdraw()->Withdraw / NumConfig::NUM_VALUE ?? 0;
  572. // 累计提现回收金额
  573. $withDrawRecovery = $WithdrawalModel->WithDrawRecovery();
  574. // 休眠用户
  575. $dormancyUser = $AccountsInfoModel->dormancy_user();
  576. // 流失用户
  577. $lsUser = $AccountsInfoModel->ls_user();
  578. // 总注册用户
  579. $register = $AccountsInfoModel->user_count();
  580. // 签到总奖励
  581. $totalSignIn = $AccountsInfoModel->accountSignIn();
  582. // 周卡购买报表
  583. // $weeklyCard = $GlobalLogic->WeeklyCard();
  584. return compact('paySum', 'payUserCount', 'withdraw', 'withDrawRecovery', 'dormancyUser', 'lsUser', 'register','totalSignIn');
  585. }
  586. // 全局报表 - 游戏相关
  587. // 全局报表 - 游戏相关
  588. public function games($StartDataID, $EndDataID)
  589. {
  590. $redis = \Illuminate\Support\Facades\Redis::connection();
  591. $gameRtp =$redis->get("SomeConfigSpecial");
  592. $gameRtp = json_decode($gameRtp,true);
  593. // 流水、输赢、彩金
  594. $gameInfo = DB::connection('read')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
  595. // ->selectRaw('sum(TotalBet) as flowing_water,Isnull(sum(Revenue),0) as Revenue,IsNull((sum(LostScore) + sum(WinScore)),0) Score,Isnull(SUM(Handsel),0) as ChangeScore')
  596. ->selectRaw('sum(TotalBet) as flowing_water_new,IsNull((abs(sum(LostScore)) + sum(WinScore)),0) flowing_water,Isnull(sum(Revenue),0) as Revenue,IsNull((sum(LostScore) + sum(WinScore)),0) Score,Isnull(SUM(Handsel),0) as ChangeScore')
  597. ->first();
  598. foreach ($gameInfo as &$value) {
  599. $value = number_float($value / NumConfig::NUM_VALUE);
  600. }
  601. unset($value);
  602. // 房间库存
  603. $roomStock = GameRoomInfo::RoomStock(config('games.openKGame'));
  604. // 游戏房间数据--汇总
  605. // $gameRoomInfo = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordServerDataStatistics')
  606. // ->where('DateID', '>=', $StartDataID)
  607. // ->where('DateID', '<=', $EndDataID)
  608. //// ->selectRaw('sum(TotalBet) as flowing_water,Isnull(sum(Revenue),0) as Revenue,Isnull((sum(WinScore) + sum(LostScore)),0) as win_lose')
  609. // ->selectRaw('sum(TotalBet) as flowing_water_new,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')
  610. // ->first();
  611. $gameRoomInfo=DB::table('QPRecordDB.dbo.RecordGameRoomDayInfo')
  612. ->whereBetween('DateID', [$StartDataID, $EndDataID])
  613. ->where('SortID','-1')
  614. ->selectRaw('sum(TotalBet) as flowing_water_new,sum(PayTotalBet) as pay_flowing_water_new,sum(GameTurnOver) as flowing_water,sum(PayGameTurnOver) as pay_flowing_water,sum(GameRevenue) as Revenue,sum(PayGameRevenue) as pay_Revenue')
  615. ->first();
  616. $gameRoomInfo2=DB::table('QPPlatformDB.dbo.RoomStockDay')
  617. ->whereBetween('DateID', [$StartDataID, $EndDataID])
  618. ->selectRaw('sum(Winlost) as win_lose,sum(PayWinlost) as pay_win_lose')->first();
  619. $gameRoomInfo->win_lose=$gameRoomInfo2->win_lose;
  620. $gameRoomInfo->pay_win_lose=$gameRoomInfo2->pay_win_lose;
  621. $gameRoomInfo->free_flowing_water = $gameRoomInfo->flowing_water_new-$gameRoomInfo->pay_flowing_water_new;
  622. $gameRoomInfo->free_win_lose = $gameRoomInfo->win_lose-$gameRoomInfo->pay_win_lose;
  623. // 游戏人数
  624. $totalGameCount = DB::table(TableName::QPRecordDB() . 'RecordUserGameDayCount')
  625. ->whereBetween('DateID', [$StartDataID, $EndDataID])
  626. ->distinct()
  627. ->count('UserID');
  628. // 游戏人数
  629. $pay_totalGameCount = DB::table(TableName::QPRecordDB() . 'RecordUserGameDayCount as ru')
  630. ->join('QPAccountsDB.dbo.YN_VIPAccount as v', 'ru.UserID', '=', 'v.UserID')
  631. ->whereBetween('DateID', [$StartDataID, $EndDataID])
  632. ->distinct()
  633. ->count('ru.UserID');
  634. foreach ($gameRoomInfo as &$value) {
  635. $value = number_float($value / NumConfig::NUM_VALUE);
  636. }
  637. unset($value);
  638. $gameRoomInfo->Rtp = @$gameRtp['g0'];
  639. if (!empty($gameRoomInfo)) {
  640. // 平台输赢 = 输赢 + 税收
  641. // $gameRoomInfo->win_lose = $gameRoomInfo->win_lose;
  642. }
  643. // 游戏房间数据 -- 列表
  644. // $gameList = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
  645. // ->leftJoin('QPRecordDB.dbo.RecordServerDataStatistics as rds', 'rds.ServerID', 'gi.ServerID')
  646. // ->leftJoin('QPRecordDB.dbo.RecordUserGameDayCount as rgc', function ($query) {
  647. // $query->on('rgc.GameID', 'rds.ServerID')->on('rds.DateID', 'rgc.DateID');
  648. // })
  649. // ->whereBetween('rds.DateID', [$StartDataID, $EndDataID])
  650. // ->select('gi.GameID', 'gi.ServerName', 'gi.ServerID')
  651. // ->selectRaw('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')
  652. // ->selectRaw('WinScore,LostScore,Revenue,WinUserCount,LostUserCount,gi.GameID,gi.ServerName,gi.ServerID')
  653. // ->get();
  654. $gameList = DB::table(TableName::QPRecordDB() . 'RecordGameRoomDayInfo as ri')
  655. ->where('ri.SortID', '>', 0)
  656. ->whereBetween('ri.DateID', [$StartDataID, $EndDataID])
  657. ->leftJoin(TableName::QPPlatformDB() . 'RoomStockDay as rs', function ($query) {
  658. $query->on('ri.GameID', 'rs.GameID')->on('ri.SortID', 'rs.SortID')->on('ri.DateID', 'rs.DateID');
  659. })
  660. ->select('GamePlayer as Cnt', 'PayGamePlayer as pay_Cnt', 'GameRevenue as Revenue', 'PayGameRevenue as pay_Revenue', 'GameTurnOver as flowing_water', 'TotalBet as flowing_water_new','PayTotalBet as pay_flowing_water_new', 'Winlost as win_lose', 'PayWinlost as pay_win_lose', 'ri.GameID', 'ri.SortID','ri.DateID')
  661. ->get();
  662. // 游戏输赢 + 控制输赢
  663. $RoomControlStockDay = DB::table(TableName::QPPlatformDB().'RoomControlStockDay')
  664. ->whereBetween('DateID', [$StartDataID, $EndDataID])
  665. ->get();
  666. $gameServerNames = DB::table(TableName::QPPlatformDB() . 'RoomConfig')->get();
  667. $chu = $zhong = $gao = 0;
  668. $chu_n = $zhong_n = $gao_n = 0;
  669. // dd($gameList);
  670. $gamesorts=[];
  671. $revenueGames = config('games.revenueGames');
  672. // dd($gameRtp);
  673. foreach ($gameList as &$value) {
  674. $value->ServerName = '';
  675. $value->flowing_water = is_null($value->flowing_water) ? 0 : number_float($value->flowing_water / NumConfig::NUM_VALUE);
  676. $value->flowing_water_new = is_null($value->flowing_water_new) ? 0 : number_float($value->flowing_water_new / NumConfig::NUM_VALUE);
  677. // $value->Revenue = is_null($value->Revenue) ? 0 : number_float($value->Revenue / NumConfig::NUM_VALUE);
  678. $value->pay_flowing_water_new = is_null($value->pay_flowing_water_new) ? 0 : number_float($value->pay_flowing_water_new / NumConfig::NUM_VALUE);
  679. // $value->pay_Revenue = is_null($value->pay_Revenue) ? 0 : number_float($value->pay_Revenue / NumConfig::NUM_VALUE);
  680. $value->free_flowing_water = $value->flowing_water_new-$value->pay_flowing_water_new;
  681. //玩家不扣税的游戏不累计到统计里
  682. // if(!in_array($value->GameID,$revenueGames)){
  683. // $gameRoomInfo->win_lose = $gameRoomInfo->win_lose-$value->Revenue;
  684. // $gameRoomInfo->pay_win_lose = $gameRoomInfo->pay_win_lose-$value->pay_Revenue;
  685. // $gameRoomInfo->Revenue = $gameRoomInfo->Revenue-$value->Revenue; //真是税收收入
  686. // $gameRoomInfo->pay_Revenue = $gameRoomInfo->pay_Revenue-$value->pay_Revenue; //真是税收收入
  687. // }
  688. $value->win_lose = is_null($value->win_lose) ? 0 : number_float($value->win_lose / NumConfig::NUM_VALUE);
  689. $value->pay_win_lose = is_null($value->pay_win_lose) ? 0 : number_float($value->pay_win_lose / NumConfig::NUM_VALUE);
  690. $value->free_win_lose = $value->win_lose-$value->pay_win_lose;
  691. foreach ($gameServerNames as $serverName) {
  692. if ($value->GameID == $serverName->GameID && $value->SortID == $serverName->SortID) {
  693. $value->ServerName = $serverName->RoomName;
  694. }
  695. }
  696. // 游戏输赢 = 控制输赢 + 库存输赢
  697. foreach ($RoomControlStockDay as $val){
  698. if ($value->GameID == $val->GameID && $value->SortID == $val->SortID && $value->DateID == $val->DateID) {
  699. $value->win_lose = is_null($val->Winlost) ? $value->win_lose : $value->win_lose + ($val->Winlost / NumConfig::NUM_VALUE);
  700. }
  701. }
  702. if(is_array($gameRtp)){
  703. $value->Rtp = @$gameRtp['g'.$value->GameID]??'';
  704. }
  705. // if($value->SortID == 1){
  706. // $chu += $value->flowing_water;
  707. // $chu_n += $value->flowing_water_new;
  708. // }
  709. // if($value->SortID == 2){
  710. // $zhong += $value->flowing_water;
  711. // $zhong_n += $value->flowing_water_new;
  712. // }
  713. // if($value->SortID == 3){
  714. // $gao += $value->flowing_water;
  715. // $gao_n += $value->flowing_water_new;
  716. // }
  717. if(!isset($gamesorts[$value->GameID.'-'.$value->SortID])) {
  718. $gamesorts[$value->GameID.'-'.$value->SortID]=(object)['Cnt'=>0,'Revenue'=>0,'pay_Cnt'=>0,'pay_Revenue'=>0,'flowing_water'=>0,'free_win_lose' => 0,'free_flowing_water' => 0,'win_lose'=>0,'flowing_water_new'=>0,'pay_win_lose'=>0,'pay_flowing_water_new'=>0,'GameID'=>$value->GameID,'SortID'=>$value->SortID,'DateID'=>$value->DateID,'ServerName'=>$value->ServerName];
  719. }
  720. $oldvalue = &$gamesorts[$value->GameID.'-'.$value->SortID];
  721. $oldvalue->Cnt += $value->Cnt;
  722. // $oldvalue->Revenue += $value->Revenue;
  723. $oldvalue->flowing_water += $value->flowing_water;
  724. $oldvalue->flowing_water_new += $value->flowing_water_new;
  725. $oldvalue->win_lose += $value->win_lose;
  726. $oldvalue->pay_Cnt += $value->pay_Cnt;
  727. $oldvalue->pay_Revenue += $value->pay_Revenue;
  728. $oldvalue->pay_flowing_water_new += $value->pay_flowing_water_new;
  729. $oldvalue->pay_win_lose += $value->pay_win_lose;
  730. $oldvalue->free_win_lose += $value->free_win_lose;
  731. $oldvalue->free_flowing_water += $value->free_flowing_water;
  732. $oldvalue->Rtp = $value->Rtp;
  733. }
  734. $gameList=array_values($gamesorts);
  735. $gameList=Util::arraySort($gameList,'flowing_water_new',SORT_DESC);
  736. if(@$_REQUEST['nienie']){
  737. dd($gameList,$gameRoomInfo);
  738. }
  739. if($chu==0)$chu=1;
  740. $zhongRate = (ceil($zhong/$chu*100)/100);
  741. $gaoRate = (ceil($gao/$chu*100)/100);
  742. $total = 1+$zhongRate+$gaoRate;
  743. $zhongRate_n = (ceil($zhong/$chu*100)/100);
  744. $gaoRate_n = (ceil($gao/$chu*100)/100);
  745. $total_n = 1+$zhongRate+$gaoRate;
  746. $rateString = "1:$zhongRate:$gaoRate=$total";
  747. $rateString_n = "1:$zhongRate_n:$gaoRate_n=$total_n";
  748. unset($value);
  749. return compact('gameInfo', 'gameRoomInfo', 'gameList', 'roomStock', 'totalGameCount','pay_totalGameCount','rateString','rateString_n');
  750. }
  751. // 全局报表 - 彩金相关
  752. public function winnings($startTime, $endTime)
  753. {
  754. $startTime = date("Y-m-d 00:00:00", strtotime($startTime));
  755. $endTime = date("Y-m-d 23:59:59", strtotime($endTime));
  756. $ScoreType = [21, 33, 36, 44, 45, 51, 52, 53, 59, 70];
  757. // 21、绑定手机赠送 33、注册赠送 36、推广赚金(彩金) 42、邮件附件(充值彩金) 45、充值彩金 51、首充礼包(彩金) 52、邮件附件(群发彩金) 53、推广赚金(佣金)
  758. $winnings = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordUserScoreChange')
  759. ->where('UpdateTime', '>=', $startTime)
  760. ->where('UpdateTime', '<=', $endTime)
  761. ->whereIn('Reason', $ScoreType)
  762. ->selectRaw('Isnull(SUM(ChangeScore),0) as Score,Reason')
  763. ->groupBy('Reason')
  764. ->pluck('Score', 'Reason')->toArray();
  765. foreach ($winnings as &$val) {
  766. $val = number_float($val / NumConfig::NUM_VALUE);
  767. }
  768. unset($val);
  769. // 彩金总和
  770. $winningsSum = array_sum($winnings);
  771. // 推广总奖励
  772. $totalReward = DB::connection('read')->table(TableName::QPAccountsDB() . 'SystemAgentReward')->select('TotalReward')->first()->TotalReward / NumConfig::NUM_VALUE;
  773. // 签到
  774. $signIn = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordSignIn')
  775. ->where('SignInDate', '>=', $startTime)
  776. ->where('SignInDate', '<=', $endTime)
  777. ->selectRaw('IsNull(sum(RewardScore),0) RewardScore')
  778. ->first()->RewardScore / 100 ?? 0;
  779. return compact('winnings', 'winningsSum', 'totalReward', 'signIn');
  780. }
  781. }