WithdrawalController.php 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  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. // 获取所有代付渠道配置(包括关闭的)
  637. $agent = DB::table('agent.dbo.admin_configs')
  638. ->where('type', 'cash')
  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. 'draw_gt_recharge' => $post['draw_gt_recharge'],
  668. 'draw_total' => $post['draw_total'],
  669. 'draw_bi' => $post['draw_bi'],
  670. 'game_time' => $post['game_time'] * 60, // 小时转换分
  671. 'recharge_checkbox' => isset($post['recharge_checkbox']) ? 1 : 0
  672. ];
  673. DB::table('agent.dbo.withdrawal_position_config')->where('id', $id)->update($data);
  674. return apiReturnSuc();
  675. }
  676. }
  677. // 提现渠道配置(新增和修改权重)
  678. public function cashier_channel_config(Request $request)
  679. {
  680. if ($request->isMethod('get')) {
  681. // 获取所有提现渠道
  682. $list = DB::table('agent.dbo.admin_configs')
  683. ->leftJoin('agent.dbo.admin_users as u', 'admin_configs.admin_id', '=', 'u.id')
  684. ->select('admin_configs.*', 'u.account')
  685. ->where('admin_configs.type', 'cash')
  686. ->orderBy('admin_configs.id', 'asc')
  687. ->get();
  688. return view('admin.Withdrawal.cashier_channel_config', ['list' => $list]);
  689. } else {
  690. // POST 提交 - 修改权重
  691. $validator = Validator::make($request->all(), [
  692. 'config.*.sort' => 'required|int',
  693. 'config.*.status' => 'required|in:1,-1',
  694. ]);
  695. if ($validator->fails()) {
  696. return apiReturnFail($validator->errors()->first());
  697. }
  698. $config = $request->input('config');
  699. // 验证权重总和
  700. $opened = array_filter($config, function ($item) {
  701. return $item['status'] == 1;
  702. });
  703. if (empty($opened)) {
  704. return apiReturnFail('至少需要开启一个提现渠道');
  705. }
  706. if (array_sum(array_column($opened, 'sort')) != 100) {
  707. return apiReturnFail('权重值分配不正确,开启的渠道权重总和必须为100');
  708. }
  709. // 更新配置
  710. foreach ($config as $id => $v) {
  711. $v['admin_id'] = session('admin')['id'];
  712. $v['updated_at'] = date('Y-m-d H:i:s');
  713. if ($v['status'] == -1) {
  714. $v['sort'] = 0;
  715. }
  716. DB::table('agent.dbo.admin_configs')->where('id', $id)->update($v);
  717. }
  718. return apiReturnSuc();
  719. }
  720. }
  721. // 新增提现渠道
  722. public function cashier_channel_add(Request $request)
  723. {
  724. if ($request->isMethod('get')) {
  725. return view('admin.Withdrawal.cashier_channel_add');
  726. } else {
  727. // POST 提交
  728. $validator = Validator::make($request->all(), [
  729. 'name' => 'required',
  730. 'config_value' => 'required',
  731. 'status' => 'required|in:1,-1',
  732. ]);
  733. if ($validator->fails()) {
  734. return apiReturnFail($validator->errors()->first());
  735. }
  736. // 获取最大ID
  737. $maxId = DB::table('agent.dbo.admin_configs')->max('id');
  738. $data = [
  739. 'id' => $maxId + 1,
  740. 'name' => $request->name,
  741. 'config_key' => $request->config_key ?: $request->name,
  742. 'config_value' => $request->config_value,
  743. 'type' => 'cash',
  744. 'status' => $request->status,
  745. 'sort' => (int)($request->sort ?: 0),
  746. 'remarks' => $request->remarks ?: '',
  747. 'admin_id' => session('admin')['id'],
  748. 'created_at' => date('Y-m-d H:i:s'),
  749. 'updated_at' => date('Y-m-d H:i:s'),
  750. ];
  751. try {
  752. DB::table('agent.dbo.admin_configs')->insert($data);
  753. return apiReturnSuc();
  754. } catch (\Exception $e) {
  755. return apiReturnFail('添加失败:' . $e->getMessage());
  756. }
  757. }
  758. }
  759. // 修改提现渠道
  760. public function cashier_channel_update(Request $request, $id)
  761. {
  762. if ($request->isMethod('get')) {
  763. $info = DB::table('agent.dbo.admin_configs')
  764. ->where('id', $id)
  765. ->where('type', 'cash')
  766. ->first();
  767. if (!$info) {
  768. return redirect()->back()->with('error', '渠道不存在');
  769. }
  770. return view('admin.Withdrawal.cashier_channel_update', ['info' => $info]);
  771. } else {
  772. // POST 提交
  773. $validator = Validator::make($request->all(), [
  774. 'name' => 'required',
  775. 'config_value' => 'required',
  776. 'status' => 'required|in:1,-1',
  777. ]);
  778. if ($validator->fails()) {
  779. return apiReturnFail($validator->errors()->first());
  780. }
  781. $data = [
  782. 'name' => $request->name,
  783. 'config_key' => $request->config_key ?: $request->name,
  784. 'config_value' => $request->config_value,
  785. 'status' => $request->status,
  786. 'sort' => (int)($request->sort ?: 0),
  787. 'remarks' => $request->remarks ?: '',
  788. 'admin_id' => session('admin')['id'],
  789. 'updated_at' => date('Y-m-d H:i:s'),
  790. ];
  791. try {
  792. DB::table('agent.dbo.admin_configs')
  793. ->where('id', $id)
  794. ->where('type', 'cash')
  795. ->update($data);
  796. return apiReturnSuc();
  797. } catch (\Exception $e) {
  798. return apiReturnFail('修改失败:' . $e->getMessage());
  799. }
  800. }
  801. }
  802. // 免审开关
  803. public function block(Request $request, $id)
  804. {
  805. $status = $request->status ?: '';
  806. if (empty($status)) {
  807. return apiReturnFail('参数错误!');
  808. }
  809. DB::table('agent.dbo.withdrawal_position_config')->where('id', $id)->update(['status' => $status]);
  810. return apiReturnSuc();
  811. }
  812. // 用户提充统计
  813. public function userWithdrawalStatistics(Request $request)
  814. {
  815. $date = $request->date ?: date('Y-m-d');
  816. $excel = $request->excel ?: 0;
  817. $gameID = $request->GameID ?: '';
  818. $channel = $request->Channel ?: '';
  819. [$list, $channelList] = $this->logic->userWithdrawalStatistics($date, $excel, $gameID, $channel);
  820. return view('admin.Withdrawal.userWithdrawalStatistics', compact('list', 'channelList', 'date', 'gameID','channel'));
  821. }
  822. // 回调补偿
  823. public function compensateNotify($RecordID, Request $request)
  824. {
  825. $redisKey = 'Withdrawal_compensateNotify_'.$RecordID;
  826. $res = SetNXLock::getExclusiveLock($redisKey, 5);
  827. if (!$res) {
  828. return apiReturnFail('操作频繁');
  829. }
  830. $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $RecordID)
  831. ->first();
  832. if (!$withdrawOrder) {
  833. SetNXLock::release($redisKey);
  834. return apiReturnFail('订单不存在');
  835. }
  836. if ($withdrawOrder->State != 5 && $withdrawOrder->State != 7) {
  837. SetNXLock::release($redisKey);
  838. return apiReturnFail('订单状态不正确, 请刷新页面重试');
  839. }
  840. Log::info('提现模拟回调', [
  841. 'recordID' => $RecordID,
  842. 'params' => $request->all()
  843. ]);
  844. /** @var WithdrawalLogic $logic */
  845. $logic = app()->make(WithdrawalLogic::class);
  846. $res = $logic->compensateNotify($withdrawOrder);
  847. SetNXLock::release($redisKey);
  848. if ($res) {
  849. return apiReturnSuc();
  850. }
  851. return apiReturnFail('修改失败');
  852. }
  853. public function monitorOrderFailCall($OrderID, Request $request)
  854. {
  855. $redisKey = 'Withdrawal_monitorOrderFailCall_' . $OrderID;
  856. $res = SetNXLock::getExclusiveLock($redisKey, 5);
  857. if (!$res) {
  858. return apiReturnFail('操作频繁');
  859. }
  860. $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  861. ->where('OrderId', $OrderID)
  862. ->first();
  863. if (!$withdrawOrder) {
  864. SetNXLock::release($redisKey);
  865. return apiReturnFail('订单不存在');
  866. }
  867. if ($withdrawOrder->State != 5 && $withdrawOrder->State != 7) {
  868. SetNXLock::release($redisKey);
  869. return apiReturnFail('订单状态不正确, 请刷新页面重试');
  870. }
  871. Log::info('提现手动设置失败', [
  872. 'OrderID' => $OrderID,
  873. 'params' => $request->all()
  874. ]);
  875. $agent = $withdrawOrder->agent;
  876. $TakeMoney = $withdrawOrder->WithDraw + $withdrawOrder->ServiceFee;
  877. $msg = (new CashierMessage())
  878. ->returnMsg($agent)
  879. ->msgStr('Encomenda rejeitada pelo banco');
  880. $bonus = '30000,' . $TakeMoney;
  881. PrivateMail::failMail($withdrawOrder->UserID, $OrderID, $TakeMoney, $msg, $bonus);
  882. // 修改订单状态为失败
  883. $withdraw_data = ['State' => 6, 'agent' => $agent];
  884. $notify_data = ['state' => 2];
  885. $RecordData = [
  886. 'before_state' => $withdrawOrder->State,
  887. 'after_state' => $withdraw_data['State'] ?? 0,
  888. 'RecordID' => $withdrawOrder->RecordID,
  889. 'update_at' => date('Y-m-d H:i:s')
  890. ];
  891. // 添加用户提现操作记录
  892. DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $withdrawOrder->RecordID, 'type' => 1], $RecordData);
  893. DB::connection('write')->table('QPAccountsDB.dbo.withdraw_notify')->updateOrInsert(['order_sn' => $OrderID], $notify_data);
  894. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $withdrawOrder->OrderId)->update($withdraw_data);
  895. if (isset($withdraw_data['State']) && $withdraw_data['State'] == 2) {
  896. // 单控标签
  897. StoredProcedure::user_label($withdrawOrder->UserID, 2, $TakeMoney);
  898. // 渠道后台埋点
  899. (new LogDayStatisticalByDayAndChannel())->updateData($withdrawOrder->UserID, 2);
  900. }
  901. SetNXLock::release($redisKey);
  902. return apiReturnSuc();
  903. }
  904. public function drawBaseChangeLog(Request $request)
  905. {
  906. $query = AddDrawBase::query();
  907. if ($request->input('GameID')) {
  908. $userID = AccountsInfo::where('GameID', $request->input('GameID'))->value('UserID');
  909. $query->where('user_id', intval($userID));
  910. }
  911. $officials = DB::table('QPAccountsDB.dbo.IDWhiteUser')->pluck('UserID')->toArray();
  912. $list = $query->orderBy('id', 'desc')->paginate(20);
  913. return view('admin.Withdrawal.draw_base_change_log', [
  914. 'list' => $list,
  915. 'request' => $request,
  916. 'officials' => $officials
  917. ]);
  918. }
  919. // 回调补偿
  920. public function initData($RecordID, Request $request)
  921. {
  922. $redisKey = 'Withdrawal_init_'.$RecordID;
  923. $res = SetNXLock::getExclusiveLock($redisKey, 5);
  924. if (!$res) {
  925. return apiReturnFail('操作频繁');
  926. }
  927. $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $RecordID)
  928. ->first();
  929. if (!$withdrawOrder) {
  930. SetNXLock::release($redisKey);
  931. return apiReturnFail('订单不存在');
  932. }
  933. DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
  934. ->where('RecordID', $withdrawOrder->RecordID)
  935. ->update(['State' => 1,'OrderId' => $withdrawOrder->OrderId.rand(1,9)]);
  936. SetNXLock::release($redisKey);
  937. return apiReturnSuc();
  938. }
  939. public function withdrawRank(Request $request)
  940. {
  941. $date = Carbon::now();
  942. $start_time = $request->input('start_time', $date->format('Y-m-d'));
  943. $end_time = $request->input('end_time', $date->format('Y-m-d'));
  944. $where = [];
  945. !empty($start_time) && $where[] = ['DateID', '>=', Carbon::parse($start_time)->format('Ymd')];
  946. !empty($end_time) && $where[] = ['DateID', '<', Carbon::parse($end_time)->addDay(1)->format('Ymd')];
  947. $order_sql = 'Withdraw DESC';
  948. if (true) {
  949. $list = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  950. ->where('Withdraw', '>', 0)
  951. ->where($where)
  952. ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
  953. ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
  954. ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
  955. ->orderByRaw($order_sql)
  956. ->paginate(10);
  957. $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  958. ->where('Withdraw', '>', 0)
  959. ->where($where)
  960. ->selectRaw('sum(ds.Withdraw) Withdraw,UserID')
  961. ->groupBy('UserID')
  962. ->pluck('Withdraw', 'UserID')->toArray();
  963. $UserIDs = [];
  964. foreach ($list as $value) {
  965. $UserIDs[] = $value->UserID;
  966. }
  967. foreach ($list as $key => &$value) {
  968. $second = $value->PlayTimeCount;
  969. $day = floor($second / (3600 * 24));
  970. $second = $second % (3600 * 24);//除去整天之后剩余的时间
  971. $hour = floor($second / 3600);
  972. $second = $second % 3600;//除去整小时之后剩余的时间
  973. $minute = floor($second / 60);
  974. //返回字符串
  975. $value->Experience = $day . '天' . $hour . '小时' . $minute . '分';
  976. $value->type = '玩家';
  977. $value->rank = $key + 1;
  978. $value->money = $rechargeSum[$value->UserID] ?? 0;
  979. $value->money = $value->money /100;
  980. $value->time = Carbon::parse(now())->diffInDays($value->LastLogonDate, true);
  981. }
  982. return view('admin.Withdrawal.rank', [
  983. 'list' => $list,
  984. 'end_time' => $end_time,
  985. 'start_time' => $start_time,
  986. ]);
  987. }
  988. }
  989. public function nameStatics(){
  990. // DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  991. // ->selectRaw('count(distinct (UserID)) as nums,BankUserName')
  992. // ->groupBy("BankUserName")
  993. // ->orderBy("nums","desc");
  994. $sql = "select nums,BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName ) s where nums>1";
  995. // $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";
  996. $multiNames = DB::select($sql);
  997. $sql="select nums,EmailAddress from (select count(distinct (UserID)) as nums,EmailAddress from QPAccountsDB.dbo.OrderWithDraw group by EmailAddress ) s where nums>1";
  998. $multiEmails = DB::select($sql);
  999. // $res=DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
  1000. // ->selectRaw('count(distinct (UserID)) as nums')
  1001. // ->where("EmailAddress","ciceroedsondasilvasantos19@gmail.com")
  1002. // ->first();
  1003. // print_r($res)
  1004. return view('admin.Withdrawal.statics', [
  1005. 'names' => $multiNames,
  1006. 'emails' => $multiEmails,
  1007. ]);
  1008. // select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName order by nums desc;
  1009. }
  1010. }