GlobalUser.php 41 KB

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