WithdrawalController.php 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\dao\Estatisticas\RechargeWithDraw;
  4. use App\Facade\RedisConnect;
  5. use App\Facade\TableName;
  6. use App\Http\helper\Helper;
  7. use App\Http\helper\NumConfig;
  8. use App\Http\logic\admin\AccountsRecordLogic;
  9. use App\Http\logic\admin\WithdrawalLogic;
  10. use App\Models\AccountsInfo;
  11. use App\Models\AddDrawBase;
  12. use App\Models\PrivateMail;
  13. use App\Models\RecordScoreInfo;
  14. use App\Models\RecordUserDataStatistics;
  15. use App\Models\SystemStatusInfo;
  16. use App\Services\CashierMessage;
  17. use App\Services\CreateLog;
  18. use App\Services\LogDayStatisticalByDayAndChannel;
  19. use App\Services\StoredProcedure;
  20. use App\Utility\SetNXLock;
  21. use Carbon\Carbon;
  22. use Illuminate\Http\Request;
  23. use Illuminate\Support\Facades\DB;
  24. use Illuminate\Support\Facades\Log;
  25. use Illuminate\Support\Facades\Redis;
  26. use Illuminate\Support\Facades\Validator;
  27. class WithdrawalController extends BaseController
  28. {
  29. protected $logic;
  30. public function __construct()
  31. {
  32. $this->logic = new WithdrawalLogic();
  33. }
  34. // 待审核列表
  35. public function waitWithdrawal(Request $request)
  36. {
  37. $create_time_sort = $request->create_time_sort ?: '';
  38. $GameID = (int)$request->get('GameID') ?: '';
  39. $withdraw_search = (int)$request->get('withdraw_search') ?: '';
  40. $withdraw = $request->get('withdraw') ?? '';
  41. $state = $request->get('state') ?? '';
  42. $start_time = $request->get('start_time') ?? '';
  43. $end_time = $request->get('end_time') ?? '';
  44. $final_start_time = $request->get('final_start_time') ?? '';
  45. $final_end_time = $request->get('final_end_time') ?? '';
  46. $orderID = $request->get('orderID') ?? '';
  47. $excel = $request->get('excel') ?? '';
  48. $Channel = $request->get('Channel');
  49. $payState = $request->get('payState');
  50. $PackgeName = $request->PackgeName ?: '';
  51. $toNormalCs=Redis::get("normalCsOpen")??"close";
  52. $list = $this->logic->waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, '', false, $create_time_sort, $orderID, $final_start_time, $final_end_time, $excel, $Channel, $payState, '', 0, '', '', $PackgeName,$toNormalCs=="open"?2:0);
  53. $list['api_url']='/admin/withdrawal/waitWithdrawal';
  54. $list['normalCsOpen']=$toNormalCs;
  55. $list['specialCs']=false;
  56. return view('admin.Withdrawal.waitWithdrawal', $list);
  57. }
  58. public function changeNewWithdrawOpen(Request $request)
  59. {
  60. //普通客服开放新用户审核开关
  61. $toNormalCs=$request->input("normalCsOpen");
  62. Redis::set("normalCsOpen",$toNormalCs);
  63. return apiReturnSuc([],"","操作成功:".($toNormalCs=="open"?"开启":"关闭"));
  64. }
  65. public function waitWithdrawalNewPlayer(Request $request)
  66. {
  67. $toNormalCs=Redis::get("normalCsOpen")??"close";
  68. $create_time_sort = $request->create_time_sort ?: '';
  69. $GameID = (int)$request->get('GameID') ?: '';
  70. $withdraw_search = (int)$request->get('withdraw_search') ?: '';
  71. $withdraw = $request->get('withdraw') ?? '';
  72. $state = $request->get('state') ?? '';
  73. $start_time = $request->get('start_time') ?? '';
  74. $end_time = $request->get('end_time') ?? '';
  75. $final_start_time = $request->get('final_start_time') ?? '';
  76. $final_end_time = $request->get('final_end_time') ?? '';
  77. $orderID = $request->get('orderID') ?? '';
  78. $excel = $request->get('excel') ?? '';
  79. $Channel = $request->get('Channel');
  80. $payState = $request->get('payState');
  81. $PackgeName = $request->PackgeName ?: '';
  82. $list = $this->logic->waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, '', false, $create_time_sort, $orderID, $final_start_time, $final_end_time, $excel, $Channel, $payState, '', 0, '', '', $PackgeName,1);
  83. $list['api_url']='/admin/withdrawal/waitWithdrawalNewPlayer';
  84. $list['normalCsOpen']=$toNormalCs;
  85. $list['specialCs']=true;
  86. return view('admin.Withdrawal.waitWithdrawal', $list);
  87. }
  88. public function state5List(Request $request){
  89. $data = $request->all();
  90. if ($request->isMethod('post')) {
  91. $ID=$data['OrderId'];
  92. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId',$ID)->update(['State'=>1]);
  93. return json_encode(['id'=>$ID]);
  94. }
  95. $list=DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
  96. ->where('State','=',5)
  97. ->get()->toArray();
  98. // print_r($list);die;
  99. return view('admin.Withdrawal.statelist', ['list'=>$list]);
  100. }
  101. // 提现审核
  102. public function verify(Request $request)
  103. {
  104. $data = $request->all();
  105. if ($request->isMethod('get')) {
  106. if ($data['type'] == 'agree') { // 通过
  107. $open=(int)SystemStatusInfo::OnlyGetCacheValue(SystemStatusInfo::$KEY_WithDrawSwitch);
  108. $list = $this->logic->verify_agree($data['ids']);
  109. $list['open']=$open;
  110. return view('admin.Withdrawal.verify_agree', $list);
  111. } elseif ($data['type'] == 'refuse') { // 清退
  112. $list = $this->logic->verify_agree($data['ids']);
  113. return view('admin.Withdrawal.verify_refuse', $list);
  114. } elseif ($data['type'] == 'turn_down') { // 拒绝
  115. $list = $this->logic->verify_agree($data['ids']);
  116. return view('admin.Withdrawal.turn_down', $list);
  117. }
  118. } else {
  119. $admin_id = $request->session()->get('admin')->id;
  120. $save = $this->logic->save($data, $admin_id);
  121. return $save;
  122. }
  123. }
  124. // 已审核提现订单查询
  125. public function verify_finish(Request $request)
  126. {
  127. $GameID = (int)$request->get('GameID') ?: '';
  128. $withdraw_search = (int)$request->get('withdraw_search') ?: '';
  129. $withdraw = $request->get('withdraw') ?: '';
  130. $state = $request->get('state') ?? '';
  131. $agent = $request->get('agent') ?? '';
  132. $start_time = $request->get('start_time') ?? '';
  133. $end_time = $request->get('end_time') ?? '';
  134. $orderID = $request->get('orderID') ?? '';
  135. $excel = $request->get('excel') ?? '';
  136. $final_start_time = $request->get('final_start_time') ?? '';
  137. $final_end_time = $request->get('final_end_time') ?? '';
  138. $take_effect = $request->get('take_effect') ?? '';
  139. $Channel = $request->get('Channel');
  140. $payState = $request->get('payState');
  141. $start_time = str_replace('T', ' ', $start_time);
  142. $end_time = str_replace('T', ' ', $end_time);
  143. $isEmpty = $request->get('isEmpty') ?: '';
  144. $PackgeName = $request->PackgeName ?: '';
  145. $register_start_time = $request->input('register_start_time');
  146. $register_end_time = $request->input('register_end_time');
  147. $list = $this->logic->waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, $agent, true, '', $orderID, $final_start_time, $final_end_time, $excel, $Channel, $payState, $take_effect, $isEmpty, $register_start_time, $register_end_time, $PackgeName,2);
  148. $list['agents'] = DB::table('agent.dbo.admin_configs')
  149. ->where('type', 'cash')
  150. ->get();
  151. $list['request'] = $request;
  152. return view('admin.Withdrawal.verify_finish', $list);
  153. }
  154. // 提现拒绝
  155. public function turn_down(Request $request)
  156. {
  157. $redis = new RedisConnect();
  158. $limitKey = 'turn_down';
  159. $res = $redis->redis()->set($limitKey, 1, 3);
  160. if (empty($res)) return apiReturnFail('频繁操作');
  161. $post = $request->post();
  162. $ids = explode(',', $post['ids']);
  163. if (count($ids) < 1) {
  164. return apiReturnFail('数据不存在!');
  165. }
  166. foreach ($ids as $val) {
  167. // 查找订单
  168. $OrderWithDraw = DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  169. ->where('RecordID', $val)
  170. ->selectRaw('UserID,OrderID,WithDraw,ServiceFee')
  171. ->first();
  172. // 修改订单状态 locking=>[2清退不返打码量 3 拒绝返打码量]
  173. DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  174. ->where('RecordID', $val)
  175. ->update(['State' => -1, 'locking' => 3]);
  176. $remarks = $post['remarks'] ?? '';
  177. $admin_id = session('admin')['id'];
  178. // 添加用户提现操作记录
  179. (new AccountsRecordLogic())->create_record($val, 1, -2, $remarks, $admin_id, 1);
  180. $amount = $OrderWithDraw->WithDraw + $OrderWithDraw->ServiceFee;
  181. PrivateMail::refuseMail($OrderWithDraw->UserID, $OrderWithDraw->OrderID, $amount, true);
  182. }
  183. $redis->redis()->del($limitKey);
  184. return apiReturnSuc();
  185. }
  186. // 提现数值修改
  187. public function config()
  188. {
  189. // $fee = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  190. // ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  191. // $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  192. // })
  193. // ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  194. // ->where('si.StatusName', 'WithDrawTax')
  195. // ->select('StatusValue', 'account', 'create_at')
  196. // ->first();
  197. $fee = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  198. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  199. $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  200. })
  201. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  202. ->where('si.StatusName', 'WithDrawTax')
  203. ->select('StatusValue', 'account', 'create_at')
  204. ->first();
  205. $artificial = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  206. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  207. $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  208. })
  209. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  210. ->where('si.StatusName', 'WithDrawAILimit')
  211. ->select('StatusValue', 'account', 'create_at')
  212. ->first();
  213. $proportion = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  214. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  215. $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  216. })
  217. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  218. ->where('si.StatusName', 'WithDrawRate')
  219. ->select('StatusValue', 'account', 'create_at')
  220. ->first();
  221. $WithDrawMin = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  222. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  223. $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  224. })
  225. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  226. ->where('si.StatusName', 'WithDrawMin')
  227. ->select('StatusValue', 'account', 'create_at')
  228. ->first();
  229. $WithDrawMax = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  230. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  231. $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  232. })
  233. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  234. ->where('si.StatusName', 'WithDrawMax')
  235. ->select('StatusValue', 'account', 'create_at')
  236. ->first();
  237. $WithDrawPoint = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  238. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  239. $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  240. })
  241. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  242. ->where('si.StatusName', 'WithDrawPoint')
  243. ->select('StatusValue', 'account', 'create_at')
  244. ->first();
  245. $MaxTXNotRecharge = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
  246. ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
  247. $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
  248. })
  249. ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
  250. ->where('si.StatusName', 'MaxTXNotRecharge')
  251. ->select('StatusValue', 'account', 'create_at')
  252. ->first();
  253. $fee->StatusValue = number_float(-$fee->StatusValue / NumConfig::NUM_VALUE);
  254. $artificial->StatusValue = number_float($artificial->StatusValue / NumConfig::NUM_VALUE);
  255. $proportion->StatusValue = number_float((10000 - $proportion->StatusValue) / NumConfig::NUM_VALUE);
  256. $WithDrawMin->StatusValue = number_float(($WithDrawMin->StatusValue) / NumConfig::NUM_VALUE);
  257. $WithDrawMax->StatusValue = number_float(($WithDrawMax->StatusValue) / NumConfig::NUM_VALUE);
  258. $WithDrawPoint->StatusValue = number_float(($WithDrawPoint->StatusValue) / NumConfig::NUM_VALUE);
  259. $MaxTXNotRecharge->StatusValue = number_float(($MaxTXNotRecharge->StatusValue) / NumConfig::NUM_VALUE);
  260. $compact = compact('fee', 'artificial', 'proportion', 'WithDrawMin', 'WithDrawMax', 'WithDrawPoint', 'MaxTXNotRecharge');
  261. return view('admin.Withdrawal.config', $compact);
  262. }
  263. // 提现保底额度
  264. public function WithDrawPoint(Request $request)
  265. {
  266. if ($request->isMethod('post')) {
  267. $StatusValue = abs((int)$request->StatusValue * 100) ?: '';
  268. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawPoint')->update(['StatusValue' => $StatusValue]);
  269. $admin_id = session('admin')->id;
  270. CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
  271. return apiReturnSuc('success');
  272. }
  273. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawPoint')->value('StatusValue') / 100 ?? 0;
  274. return view('admin.Withdrawal.WithDrawPoint', ['info' => $result]);
  275. }
  276. // 提现手续费设置
  277. public function fee(Request $request)
  278. {
  279. if ($request->isMethod('post')) {
  280. $StatusValue = abs((int)$request->StatusValue) ?: '';
  281. if ($StatusValue > 1000) {
  282. return apiReturnFail('手续费最大值为1000');
  283. }
  284. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawTax')->update(['StatusValue' => $StatusValue]);
  285. $admin_id = session('admin')->id;
  286. CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
  287. return apiReturnSuc('success');
  288. }
  289. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawTax')->value('StatusValue');
  290. return view('admin.Withdrawal.fee', ['info' => $result]);
  291. }
  292. // 提现金额比例设置
  293. public function artificial(Request $request)
  294. {
  295. if ($request->isMethod('post')) {
  296. $StatusValue = abs((int)$request->StatusValue) ?: '';
  297. $StatusValue *= 100;
  298. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawAILimit')->update(['StatusValue' => $StatusValue]);
  299. $admin_id = session('admin')->id;
  300. CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
  301. return apiReturnSuc('success');
  302. }
  303. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawAILimit')->value('StatusValue');
  304. $result = $result / 100;
  305. return view('admin.Withdrawal.artificial', ['info' => $result]);
  306. }
  307. //人工审核额度设置
  308. public function proportion(Request $request)
  309. {
  310. if ($request->isMethod('post')) {
  311. $StatusValue = (int)$request->StatusValue ?: '';
  312. $StatusValue = abs($StatusValue);
  313. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawRate')->update(['StatusValue' => $StatusValue]);
  314. $admin_id = session('admin')->id;
  315. CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
  316. return apiReturnSuc('success');
  317. }
  318. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawRate')->value('StatusValue');
  319. return view('admin.Withdrawal.proportion', ['info' => $result]);
  320. }
  321. // 0充玩家提现限制最高额度
  322. public function MaxTXNotRecharge(Request $request)
  323. {
  324. if ($request->isMethod('post')) {
  325. $StatusValue = (int)$request->StatusValue ?: '';
  326. $StatusValue = $StatusValue * NumConfig::NUM_VALUE;
  327. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'MaxTXNotRecharge')->update(['StatusValue' => $StatusValue]);
  328. $admin_id = session('admin')->id;
  329. CreateLog::SystemStatusInfo_log($admin_id, 'MaxTXNotRecharge');
  330. return apiReturnSuc('success');
  331. } else {
  332. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'MaxTXNotRecharge')->value('StatusValue');
  333. $result = $result > 0 ? floatval($result / NumConfig::NUM_VALUE) : 0;
  334. return view('admin.Withdrawal.max_tx_not_recharge', ['info' => $result]);
  335. }
  336. }
  337. // 查看返回值
  338. public function show($sn = '')
  339. {
  340. $notify = DB::table('QPAccountsDB.dbo.withdraw_notify')->where('order_sn', $sn)->select('extra')->first()->extra ?? '';
  341. if ($notify) {
  342. $notify = \GuzzleHttp\json_decode($notify);
  343. }
  344. return view('admin.Withdrawal.show', ['info' => $notify]);
  345. }
  346. // 提现最大值修改
  347. public function WithDrawMax(Request $request)
  348. {
  349. if ($request->isMethod('post')) {
  350. $StatusValue = (int)$request->StatusValue ?: '';
  351. $StatusValue = abs($StatusValue) * NumConfig::NUM_VALUE;
  352. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMax')->update(['StatusValue' => $StatusValue]);
  353. $admin_id = session('admin')->id;
  354. CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
  355. return apiReturnSuc('success');
  356. }
  357. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMax')->value('StatusValue');
  358. $result /= 100;
  359. return view('admin.Withdrawal.WithDrawMax', ['info' => $result]);
  360. }
  361. // 提现最小值修改
  362. public function WithDrawMin(Request $request)
  363. {
  364. if ($request->isMethod('post')) {
  365. $StatusValue = (int)$request->StatusValue ?: '';
  366. $StatusValue = abs($StatusValue) * NumConfig::NUM_VALUE;
  367. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMin')->update(['StatusValue' => $StatusValue]);
  368. $admin_id = session('admin')->id;
  369. CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
  370. return apiReturnSuc('success');
  371. }
  372. $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMin')->value('StatusValue');
  373. $result /= 100;
  374. return view('admin.Withdrawal.WithDrawMin', ['info' => $result]);
  375. }
  376. // 风险评估
  377. public function risk_assessment(Request $request, $UserID)
  378. {
  379. $gear = $request->gear ?: '';
  380. $info = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
  381. ->join('QPAccountsDB.dbo.AccountsInfo as ain', 'ai.RegisterIP', 'ain.RegisterIP')
  382. ->where('ai.UserID', $UserID)
  383. ->whereNotNull('ai.RegisterIP')
  384. ->selectRaw('count(1) count,ai.RegisterIP,ai.RegisterDate,ai.GameID,ai.NickName')
  385. ->groupBy('ai.GameID', 'ai.NickName', 'ai.RegisterIP', 'ai.RegisterDate')
  386. ->first();
  387. // 总对局数
  388. $info->playerNum = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
  389. ->where('UserID', $UserID)
  390. ->sum('Cnt');
  391. // 推广佣金已领取 。
  392. $info->commission = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
  393. ->where('ScoreType', 53)
  394. ->where('UserID', $UserID)
  395. ->selectRaw('IsNull(sum(Score),0) Score')
  396. ->first()->Score / NumConfig::NUM_VALUE ?? 0;
  397. // 推广佣金可领取 。
  398. $waitCommission = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent')
  399. ->where('UserID', $UserID)
  400. ->selectRaw('IsNull((Balance1 + Balance2),0) as Balance')
  401. ->first()->Balance ?? 0;
  402. $info->waitCommission = $waitCommission > 0 ? $waitCommission / NumConfig::NUM_VALUE : 0;
  403. //今日彩金 -- 今日提现 -- 今日盈利 -- 今日充值
  404. $info->today = DB::connection('read')->table('QPRecordDB.dbo.RecordUserDataStatisticsNew')
  405. ->where('UserID', $UserID)
  406. ->where('DateID', date('Ymd'))
  407. ->selectRaw('IsNull(sum(Handsel),0)Handsel,IsNull(sum(Withdraw),0) Withdraw,IsNull((sum(WinScore) + sum(LostScore)), 0) Score,sum(Recharge) Recharge')
  408. ->first();
  409. // 全部彩金 -- 总提现 -- 总盈利 -- 总充值
  410. $info->total = DB::connection('read')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
  411. ->where('UserID', $UserID)
  412. ->selectRaw('IsNull(sum(Handsel),0)Handsel,IsNull(sum(Withdraw),0) Withdraw,IsNull((sum(WinScore) + sum(LostScore)) , 0) Score,sum(Recharge) Recharge')
  413. ->first();
  414. isset($info->total->Score) && $info->total->Score = number_float($info->total->Score / NumConfig::NUM_VALUE);
  415. isset($info->total->Handsel) && $info->total->Handsel = number_float($info->total->Handsel / NumConfig::NUM_VALUE);
  416. isset($info->total->Withdraw) && $info->total->Withdraw = number_float($info->total->Withdraw / NumConfig::NUM_VALUE);
  417. isset($info->total->Recharge) && $info->total->Recharge = number_float($info->total->Recharge);
  418. isset($info->today->Score) && $info->today->Score = number_float($info->today->Score / NumConfig::NUM_VALUE);
  419. isset($info->today->Handsel) && $info->today->Handsel = number_float($info->today->Handsel / NumConfig::NUM_VALUE);
  420. isset($info->today->Withdraw) && $info->today->Withdraw = number_float($info->today->Withdraw / NumConfig::NUM_VALUE);
  421. isset($info->today->Recharge) && $info->today->Recharge = number_float($info->today->Recharge);
  422. // 游戏对局数--分游戏
  423. $gameCount = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
  424. ->where('UserID', $UserID)
  425. ->select('Cnt', 'GameID')
  426. ->pluck('Cnt', 'GameID')->toArray();
  427. // 提现完成时间
  428. $info->finalTime = DB::connection('read')->table('QPAccountsDB.dbo.withdraw_notify')->where('user_id', $UserID)->orderByDesc('created_at')->value('finish_at');
  429. $accountsInfo=new AccountsInfo();
  430. $info->BankNO=$accountsInfo->sameBankNo($UserID);
  431. $info->sameWithDrawName=$accountsInfo->sameWithDrawBankNameByUserID($UserID);
  432. $info->sameWithDrawMail=$accountsInfo->sameWithDrawEmailByUserID($UserID);
  433. // 用户标签
  434. $getUserTab = StoredProcedure::getUserTab($UserID);
  435. $TabType = $getUserTab[0]->TabType ?? '';
  436. if (!empty($getUserTab) && $TabType == 1) {
  437. $Type12 = $getUserTab[0]->Type12 ?? 0;
  438. $userTab = DB::connection('read')->table('QPAccountsDB.dbo.AccountsTabExplain as el')
  439. ->where('TabID', $Type12)
  440. ->first()->TypeName;
  441. }
  442. return view('admin.Withdrawal.risk_assessment', [
  443. 'info' => $info,
  444. 'gear' => $gear,
  445. 'userTab' => $userTab ?? '',
  446. 'gameCount' => $gameCount,
  447. 'gameName'=>config("games.gameName")
  448. ]);
  449. }
  450. // 数据查重
  451. public function duplicate_checking(Request $request)
  452. {
  453. $type = $request->type ?: '';
  454. $val = $request->val ?: '';
  455. $list = [];
  456. switch ($type) {
  457. case 'RegisterIP':
  458. $type = '注册IP';
  459. $list = DB::table('QPAccountsDB.dbo.AccountsInfo')
  460. ->where('RegisterIP', $val)
  461. ->where('IsAndroid', 0)
  462. ->select('GameID', 'UserID')
  463. ->get();
  464. break;
  465. case 'BankNo':
  466. $type = '卡号';
  467. $list = DB::table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
  468. ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
  469. ->select('ai.GameID', 'ai.UserID')
  470. ->where('di.BankNo', $val)
  471. ->where('IsAndroid', 0)
  472. ->get();
  473. break;
  474. case 'LastLogonIP':
  475. $type = '登录IP';
  476. $list = DB::table('QPAccountsDB.dbo.AccountsInfo')
  477. ->where('LastLogonIP', $val)
  478. ->where('IsAndroid', 0)
  479. ->select('GameID', 'UserID')
  480. ->get();
  481. break;
  482. }
  483. return view('admin.Withdrawal.duplicate_checking', ['list' => $list, 'type' => $type]);
  484. }
  485. // 添加备注
  486. public function remarks(Request $request, $id)
  487. {
  488. $remark = $request->remark ?: '';
  489. $type = $request->type ?: 1;
  490. $admin_id = session('admin')->id;
  491. $RecordData = [
  492. 'admin_id' => $admin_id,
  493. 'remarks' => $remark,
  494. 'RecordID' => $id,
  495. 'create_at' => date('Y-m-d H:i:s'),
  496. 'update_at' => date('Y-m-d H:i:s'),
  497. 'type' => $type
  498. ];
  499. DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $id, 'type' => $type], $RecordData);
  500. return apiReturnSuc();
  501. }
  502. // 提现回收
  503. public function recovery($id)
  504. {
  505. $admin_id = session('admin')->id;
  506. $first = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  507. ->where('RecordID', $id)
  508. ->select('UserID', 'WithDraw', 'State', 'ServiceFee', 'OrderId', 'RecordID', 'locking')
  509. ->first();
  510. if (!$first) {
  511. return apiReturnFail('订单不存在');
  512. }
  513. if ($first->State != 1) {
  514. return apiReturnFail('订单重复操作');
  515. }
  516. // 添加提现回收数据
  517. $data = [
  518. 'UserID' => $first->UserID,
  519. 'WithDraw' => $first->WithDraw,
  520. 'ServiceFee' => $first->ServiceFee,
  521. 'OrderId' => $first->OrderId,
  522. 'admin_id' => $admin_id
  523. ];
  524. DB::table('QPAccountsDB.dbo.WithDrawRecovery')->insert($data);
  525. // 添加提现记录
  526. $RecordData = [
  527. 'admin_id' => $admin_id,
  528. 'before_state' => $first->State,
  529. 'after_state' => 4,
  530. 'RecordID' => $first->RecordID,
  531. 'create_at' => date('Y-m-d H:i:s'),
  532. 'update_at' => date('Y-m-d H:i:s')
  533. ];
  534. // 添加用户提现操作记录
  535. DB::table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $first->RecordID, 'type' => 1], $RecordData);
  536. // 修改订单状态
  537. DB::table('QPAccountsDB.dbo.OrderWithDraw')
  538. ->where('RecordID', $first->RecordID)
  539. ->update(['State' => 4, 'locking' => 0]);
  540. // 发送邮件
  541. // $TitleString = 'Your withdrawal order application failed';
  542. // $TextString = "1.Your withdrawal order: {$first->OrderId} application failed.
  543. // 2.Reasons for order submission failure:The system has detected malicious cheating on your account and recovered your chips
  544. // 3.If you have any questions, please contact customer service.
  545. // ";
  546. PrivateMail::RecoveryMail($first->UserID,$first->OrderId);
  547. return apiReturnSuc();
  548. }
  549. // 锁定订单
  550. public function locking($id)
  551. {
  552. $first = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $id)->first();
  553. if (!$first) {
  554. return apiReturnFail('订单不存在!');
  555. }
  556. if ($first->locking == 1) { // 解锁
  557. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
  558. ->where('RecordID', $id)
  559. ->update(['locking' => 0]);
  560. } else { // 加锁
  561. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
  562. ->where('RecordID', $id)
  563. ->update(['locking' => 1]);
  564. }
  565. return apiReturnSuc();
  566. }
  567. // 提现免审
  568. public function exempt_review()
  569. {
  570. $list = DB::connection('read')->table('agent.dbo.withdrawal_position_config as wp')
  571. ->leftJoin('agent.dbo.admin_configs as cf', function ($join) {
  572. $join->on('cf.config_value', '=', 'wp.agent');
  573. $join->where('cf.type', 'cash');
  574. })
  575. ->select('wp.*', 'cf.name as agent_name')
  576. ->paginate(10);
  577. foreach ($list as $value) {
  578. // $value->quota = $value->quota / NumConfig::NUM_VALUE;
  579. // $value->total_quota = $value->total_quota / NumConfig::NUM_VALUE;
  580. $value->useQuota = DB::connection('read')->table('agent.dbo.withdrawal_position_log')
  581. ->whereDate('create_at', date('Y-m-d'))
  582. ->where('config_id', $value->id)
  583. ->sum('use_quota') / NumConfig::NUM_VALUE;
  584. }
  585. return view('admin.Withdrawal.exempt_review', [
  586. 'list' => $list,
  587. ]);
  588. }
  589. // 免审添加
  590. public function exempt_review_add(Request $request)
  591. {
  592. if ($request->isMethod('get')) {
  593. $agent = DB::table('agent.dbo.admin_configs')
  594. ->where('type', 'cash')
  595. ->where('status', 1)
  596. ->get();
  597. return view('admin.Withdrawal.exempt_review_add', [
  598. 'agent' => $agent
  599. ]);
  600. } else {
  601. $admin_id = session('admin')['id'];
  602. $post = $request->all();
  603. if (isset($post['recharge_checkbox'])) {
  604. $first = DB::table('agent.dbo.withdrawal_position_config')
  605. ->where('recharge_min', '>=', $post['recharge_min'])
  606. ->where('recharge_max', '<=', $post['recharge_max'])
  607. ->first();
  608. if ($first) {
  609. return apiReturnFail('已有重复的充值额度档位!');
  610. }
  611. }
  612. $data = [
  613. 'name' => $post['name'],
  614. 'recharge_min' => $post['recharge_min'],
  615. 'recharge_max' => $post['recharge_max'],
  616. 'type' => $post['type'],
  617. 'quota' => $post['quota'] ?: 0,
  618. 'total_quota' => $post['total_quota'],
  619. 'admin_id' => $admin_id,
  620. 'status' => $post['status'],
  621. 'agent' => $post['agent'],
  622. 'draw_gt_recharge' => $post['draw_gt_recharge'],
  623. 'draw_total' => $post['draw_total'],
  624. 'draw_bi' => $post['draw_bi'],
  625. 'game_time' => $post['game_time'] * 60, // 小时转换分
  626. 'recharge_checkbox' => isset($post['recharge_checkbox']) ? 1 : 0 // 小时转换分
  627. ];
  628. DB::table('agent.dbo.withdrawal_position_config')->insert($data);
  629. return apiReturnSuc();
  630. }
  631. }
  632. // 免审修改
  633. public function exempt_review_update(Request $request, $id)
  634. {
  635. if ($request->isMethod('get')) {
  636. $agent = DB::table('agent.dbo.admin_configs')
  637. ->where('type', 'cash')
  638. ->where('status', 1)
  639. ->get();
  640. $info = DB::table('agent.dbo.withdrawal_position_config')->find($id);
  641. $info->game_time = $info->game_time > 0 ? $info->game_time / 60 : 0;
  642. return view('admin.Withdrawal.exempt_review_update', [
  643. 'info' => $info,
  644. 'agent' => $agent
  645. ]);
  646. } else {
  647. $admin_id = session('admin')['id'];
  648. $post = $request->all();
  649. if (isset($post['recharge_checkbox'])) {
  650. $first = DB::table('agent.dbo.withdrawal_position_config')
  651. ->where('recharge_min', '>=', $post['recharge_min'])
  652. ->where('recharge_max', '<=', $post['recharge_max'])
  653. ->first();
  654. if ($first && $id != $first->id) {
  655. return apiReturnFail('已有重复的充值额度档位!');
  656. }
  657. }
  658. $data = [
  659. 'name' => $post['name'],
  660. 'recharge_min' => $post['recharge_min'],
  661. 'recharge_max' => $post['recharge_max'],
  662. 'type' => $post['type'],
  663. 'quota' => $post['quota'] ?: 0,
  664. 'total_quota' => $post['total_quota'],
  665. 'admin_id' => $admin_id,
  666. 'status' => $post['status'],
  667. 'agent' => $post['agent'],
  668. 'draw_gt_recharge' => $post['draw_gt_recharge'],
  669. 'draw_total' => $post['draw_total'],
  670. 'draw_bi' => $post['draw_bi'],
  671. 'game_time' => $post['game_time'] * 60, // 小时转换分
  672. 'recharge_checkbox' => isset($post['recharge_checkbox']) ? 1 : 0
  673. ];
  674. DB::table('agent.dbo.withdrawal_position_config')->where('id', $id)->update($data);
  675. return apiReturnSuc();
  676. }
  677. }
  678. // 免审开关
  679. public function block(Request $request, $id)
  680. {
  681. $status = $request->status ?: '';
  682. if (empty($status)) {
  683. return apiReturnFail('参数错误!');
  684. }
  685. DB::table('agent.dbo.withdrawal_position_config')->where('id', $id)->update(['status' => $status]);
  686. return apiReturnSuc();
  687. }
  688. // 用户提充统计
  689. public function userWithdrawalStatistics(Request $request)
  690. {
  691. $date = $request->date ?: date('Y-m-d');
  692. $excel = $request->excel ?: 0;
  693. $gameID = $request->GameID ?: '';
  694. $channel = $request->Channel ?: '';
  695. [$list, $channelList] = $this->logic->userWithdrawalStatistics($date, $excel, $gameID, $channel);
  696. return view('admin.Withdrawal.userWithdrawalStatistics', compact('list', 'channelList', 'date', 'gameID','channel'));
  697. }
  698. // 回调补偿
  699. public function compensateNotify($RecordID, Request $request)
  700. {
  701. $redisKey = 'Withdrawal_compensateNotify_'.$RecordID;
  702. $res = SetNXLock::getExclusiveLock($redisKey, 5);
  703. if (!$res) {
  704. return apiReturnFail('操作频繁');
  705. }
  706. $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $RecordID)
  707. ->first();
  708. if (!$withdrawOrder) {
  709. SetNXLock::release($redisKey);
  710. return apiReturnFail('订单不存在');
  711. }
  712. if ($withdrawOrder->State != 5 && $withdrawOrder->State != 7) {
  713. SetNXLock::release($redisKey);
  714. return apiReturnFail('订单状态不正确, 请刷新页面重试');
  715. }
  716. Log::info('提现模拟回调', [
  717. 'recordID' => $RecordID,
  718. 'params' => $request->all()
  719. ]);
  720. /** @var WithdrawalLogic $logic */
  721. $logic = app()->make(WithdrawalLogic::class);
  722. $res = $logic->compensateNotify($withdrawOrder);
  723. SetNXLock::release($redisKey);
  724. if ($res) {
  725. return apiReturnSuc();
  726. }
  727. return apiReturnFail('修改失败');
  728. }
  729. public function monitorOrderFailCall($OrderID, Request $request)
  730. {
  731. $redisKey = 'Withdrawal_monitorOrderFailCall_' . $OrderID;
  732. $res = SetNXLock::getExclusiveLock($redisKey, 5);
  733. if (!$res) {
  734. return apiReturnFail('操作频繁');
  735. }
  736. $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  737. ->where('OrderId', $OrderID)
  738. ->first();
  739. if (!$withdrawOrder) {
  740. SetNXLock::release($redisKey);
  741. return apiReturnFail('订单不存在');
  742. }
  743. if ($withdrawOrder->State != 5 && $withdrawOrder->State != 7) {
  744. SetNXLock::release($redisKey);
  745. return apiReturnFail('订单状态不正确, 请刷新页面重试');
  746. }
  747. Log::info('提现手动设置失败', [
  748. 'OrderID' => $OrderID,
  749. 'params' => $request->all()
  750. ]);
  751. $agent = $withdrawOrder->agent;
  752. $TakeMoney = $withdrawOrder->WithDraw + $withdrawOrder->ServiceFee;
  753. $msg = (new CashierMessage())
  754. ->returnMsg($agent)
  755. ->msgStr('Encomenda rejeitada pelo banco');
  756. $bonus = '30000,' . $TakeMoney;
  757. PrivateMail::failMail($withdrawOrder->UserID, $OrderID, $TakeMoney, $msg, $bonus);
  758. // 修改订单状态为失败
  759. $withdraw_data = ['State' => 6, 'agent' => $agent];
  760. $notify_data = ['state' => 2];
  761. $RecordData = [
  762. 'before_state' => $withdrawOrder->State,
  763. 'after_state' => $withdraw_data['State'] ?? 0,
  764. 'RecordID' => $withdrawOrder->RecordID,
  765. 'update_at' => date('Y-m-d H:i:s')
  766. ];
  767. // 添加用户提现操作记录
  768. DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $withdrawOrder->RecordID, 'type' => 1], $RecordData);
  769. DB::connection('write')->table('QPAccountsDB.dbo.withdraw_notify')->updateOrInsert(['order_sn' => $OrderID], $notify_data);
  770. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $withdrawOrder->OrderId)->update($withdraw_data);
  771. if (isset($withdraw_data['State']) && $withdraw_data['State'] == 2) {
  772. // 单控标签
  773. StoredProcedure::user_label($withdrawOrder->UserID, 2, $TakeMoney);
  774. // 渠道后台埋点
  775. (new LogDayStatisticalByDayAndChannel())->updateData($withdrawOrder->UserID, 2);
  776. }
  777. SetNXLock::release($redisKey);
  778. return apiReturnSuc();
  779. }
  780. public function drawBaseChangeLog(Request $request)
  781. {
  782. $query = AddDrawBase::query();
  783. if ($request->input('GameID')) {
  784. $userID = AccountsInfo::where('GameID', $request->input('GameID'))->value('UserID');
  785. $query->where('user_id', intval($userID));
  786. }
  787. $officials = DB::table('QPAccountsDB.dbo.IDWhiteUser')->pluck('UserID')->toArray();
  788. $list = $query->orderBy('id', 'desc')->paginate(20);
  789. return view('admin.Withdrawal.draw_base_change_log', [
  790. 'list' => $list,
  791. 'request' => $request,
  792. 'officials' => $officials
  793. ]);
  794. }
  795. // 回调补偿
  796. public function initData($RecordID, Request $request)
  797. {
  798. $redisKey = 'Withdrawal_init_'.$RecordID;
  799. $res = SetNXLock::getExclusiveLock($redisKey, 5);
  800. if (!$res) {
  801. return apiReturnFail('操作频繁');
  802. }
  803. $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $RecordID)
  804. ->first();
  805. if (!$withdrawOrder) {
  806. SetNXLock::release($redisKey);
  807. return apiReturnFail('订单不存在');
  808. }
  809. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
  810. ->where('RecordID', $withdrawOrder->RecordID)
  811. ->update(['State' => 1,'OrderId' => $withdrawOrder->OrderId.rand(1,9)]);
  812. SetNXLock::release($redisKey);
  813. return apiReturnSuc();
  814. }
  815. public function withdrawRank(Request $request)
  816. {
  817. $date = Carbon::now();
  818. $start_time = $request->input('start_time', $date->format('Y-m-d'));
  819. $end_time = $request->input('end_time', $date->format('Y-m-d'));
  820. $where = [];
  821. !empty($start_time) && $where[] = ['DateID', '>=', Carbon::parse($start_time)->format('Ymd')];
  822. !empty($end_time) && $where[] = ['DateID', '<', Carbon::parse($end_time)->addDay(1)->format('Ymd')];
  823. $order_sql = 'Withdraw DESC';
  824. if (true) {
  825. $list = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  826. ->where('Withdraw', '>', 0)
  827. ->where($where)
  828. ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
  829. ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
  830. ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
  831. ->orderByRaw($order_sql)
  832. ->paginate(10);
  833. $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  834. ->where('Withdraw', '>', 0)
  835. ->where($where)
  836. ->selectRaw('sum(ds.Withdraw) Withdraw,UserID')
  837. ->groupBy('UserID')
  838. ->pluck('Withdraw', 'UserID')->toArray();
  839. $UserIDs = [];
  840. foreach ($list as $value) {
  841. $UserIDs[] = $value->UserID;
  842. }
  843. foreach ($list as $key => &$value) {
  844. $second = $value->PlayTimeCount;
  845. $day = floor($second / (3600 * 24));
  846. $second = $second % (3600 * 24);//除去整天之后剩余的时间
  847. $hour = floor($second / 3600);
  848. $second = $second % 3600;//除去整小时之后剩余的时间
  849. $minute = floor($second / 60);
  850. //返回字符串
  851. $value->Experience = $day . '天' . $hour . '小时' . $minute . '分';
  852. $value->type = '玩家';
  853. $value->rank = $key + 1;
  854. $value->money = $rechargeSum[$value->UserID] ?? 0;
  855. $value->money = $value->money /100;
  856. $value->time = Carbon::parse(now())->diffInDays($value->LastLogonDate, true);
  857. }
  858. return view('admin.Withdrawal.rank', [
  859. 'list' => $list,
  860. 'end_time' => $end_time,
  861. 'start_time' => $start_time,
  862. ]);
  863. }
  864. }
  865. public function nameStatics(){
  866. // DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  867. // ->selectRaw('count(distinct (UserID)) as nums,BankUserName')
  868. // ->groupBy("BankUserName")
  869. // ->orderBy("nums","desc");
  870. $sql = "select nums,BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName ) s where nums>1";
  871. // $sql = "select * from OrderWithDraw where BankUserName in (select BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName ) s where nums>1) order by BankUserName";
  872. $multiNames = DB::select($sql);
  873. $sql="select nums,EmailAddress from (select count(distinct (UserID)) as nums,EmailAddress from QPAccountsDB.dbo.OrderWithDraw group by EmailAddress ) s where nums>1";
  874. $multiEmails = DB::select($sql);
  875. // $res=DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  876. // ->selectRaw('count(distinct (UserID)) as nums')
  877. // ->where("EmailAddress","ciceroedsondasilvasantos19@gmail.com")
  878. // ->first();
  879. // print_r($res)
  880. return view('admin.Withdrawal.statics', [
  881. 'names' => $multiNames,
  882. 'emails' => $multiEmails,
  883. ]);
  884. // select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName order by nums desc;
  885. }
  886. }