WithDrawInfoController.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. <?php
  2. namespace App\Http\Controllers\Game;
  3. use App\Facade\TableName;
  4. use App\Game\GlobalUserInfo;
  5. use App\Http\helper\NumConfig;
  6. use App\Models\Account\UserBlacklist;
  7. use App\Models\AccountsInfo;
  8. use App\Models\Treasure\GameScoreLocker;
  9. use App\Notification\TelegramBot;
  10. use App\Util;
  11. use App\Utility\SetNXLock;
  12. use GuzzleHttp\Client;
  13. use GuzzleHttp\Exception\RequestException;
  14. use Illuminate\Http\Request;
  15. use Illuminate\Support\Facades\DB;
  16. use Illuminate\Support\Facades\Hash;
  17. use Illuminate\Support\Facades\Log;
  18. use Illuminate\Support\Facades\Redis;
  19. use Illuminate\Support\Facades\Validator;
  20. class WithDrawInfoController
  21. {
  22. public function FreeWithDrawInfo(Request $request)
  23. {
  24. $user = $request->user();
  25. $userScoreData = GlobalUserInfo::getScoreDataByUserID($user->UserID);
  26. if(!$userScoreData['Recharge']){
  27. $totalWithdraw = max($userScoreData['InsureScore'],40);
  28. if($userScoreData['InsureScore']<40){
  29. //第一种状态,我免费领了10块钱,但是金额不足40,点进去页面填信息后点击提现,提示我去玩游戏
  30. return apiReturnSuc(['state' => 1, 'total' => $totalWithdraw,'InsureScore' => $userScoreData['InsureScore']]);
  31. }else{
  32. //第二种状态,我免费金额足够40,提现按钮会点亮,告知用户点击进去
  33. return apiReturnSuc(['state' => 2, 'total' => $totalWithdraw,'InsureScore' => $userScoreData['InsureScore']]);
  34. }
  35. }else{
  36. //第四种状态,VIP状态下,金额不足了,进度条颜色红色,按钮灰色(不可点击),次日整个消失
  37. if($userScoreData['InsureScore']<10){
  38. return apiReturnSuc(['state' => 4, 'total' => max($userScoreData['InsureScore'],40),'InsureScore' => max($userScoreData['InsureScore'],40)]);
  39. }else{
  40. //第三种状态,进去完成了充值未提现,提现按钮会高光,引导用户完成提现
  41. return apiReturnSuc(['state' => 3, 'total' => max($userScoreData['InsureScore'],40),'InsureScore' => max($userScoreData['InsureScore'],40)]);
  42. }
  43. }
  44. }
  45. public function WithDrawRecord(Request $request)
  46. {
  47. $user = $request->user();
  48. $UserID=$user->UserID;
  49. // $paypass = $request->input('paypass');
  50. // if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
  51. // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  52. // }
  53. $scoreType = intval($request->input('score_type', -1));
  54. if (!in_array($scoreType, [-1, 0, 1], true)) {
  55. return apiReturnFail(['web.withdraw.params_error', 'score_type must be -1, 0 or 1'], [], 422);
  56. }
  57. $sort = strtolower($request->input('sort', 'desc'));
  58. $sort = in_array($sort, ['asc', 'desc']) ? $sort : 'desc';
  59. $sortBy = strtolower($request->input('sort_by', 'createdate'));
  60. $pageSize = intval($request->input('page_size', 10));
  61. if ($pageSize <= 0) {
  62. $pageSize = 100;
  63. }
  64. $query = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  65. ->where('UserID', $UserID);
  66. if ($scoreType !== -1) {
  67. $query->where('score_type', $scoreType);
  68. }
  69. $allowedSortColumns = [
  70. 'withdraw' => 'WithDraw',
  71. 'createdate' => 'CreateDate',
  72. ];
  73. $sortColumn = $allowedSortColumns[$sortBy] ?? 'CreateDate';
  74. $list = $query
  75. ->selectRaw("CreateDate,OrderId,[State],WithDraw,ServiceFee,PixType,score_type")
  76. ->where('CreateDate', '>=', date('Y-m-d', strtotime('-30 day')))
  77. ->orderBy($sortColumn, $sort)
  78. ->paginate($pageSize);
  79. return apiReturnSuc($list);
  80. }
  81. public function GetWithDrawBaseInfo(Request $request)
  82. {
  83. $user = $request->user();
  84. $UserID=$user->UserID;
  85. // $paypass = $request->input('paypass');
  86. //
  87. // if (empty($user->InsurePass)||!Hash::check($paypass,$user->InsurePass)) {
  88. // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  89. // }
  90. $dbh = DB::connection()->getPdo();
  91. $sql="DECLARE @return_value int
  92. set nocount on use QPAccountsDB
  93. EXEC @return_value = GSP_GR_GetWithDrawBaseInfo '$UserID'
  94. SELECT 'ReturnValue' = @return_value";
  95. // echo $sql;die;
  96. $stmt = $dbh->prepare($sql);
  97. $stmt->execute();
  98. $retval = $stmt->fetch(\PDO::FETCH_ASSOC);
  99. $retval['srate']=env('CONFIG_24680_RATE',1);
  100. // 获取绑定手机号
  101. $phone = DB::table(TableName::QPAccountsDB() . 'AccountPhone')->where('UserID', $UserID)->value('PhoneNum');
  102. $phone = trim($phone);
  103. // 去掉国家号前缀
  104. $countryCode = (string) env('COUNTRY_CODE', '1');
  105. if ($countryCode !== '' && strpos($phone, $countryCode) === 0) {
  106. $phone = substr($phone, mb_strlen($countryCode));
  107. }
  108. $retval['bind_phone'] = $phone;
  109. $hasSuccessWithdraw = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  110. ->lock('WITH(NOLOCK)')
  111. ->where('UserID', $UserID)
  112. ->where('State', 2)
  113. ->exists();
  114. $retval['has_success_withdraw'] = $hasSuccessWithdraw;
  115. return apiReturnSuc($retval);
  116. }
  117. public function GoWithDraw(Request $request)
  118. {
  119. $user = $request->user();
  120. $UserID=$user->UserID;
  121. // $paypass = $request->input('paypass');
  122. //
  123. // if (empty($user->InsurePass)||!Hash::check($paypass,$user->InsurePass)) {
  124. // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  125. // }
  126. $exists = UserBlacklist::where('UserID', $UserID)->first();
  127. if ($exists){
  128. return apiReturnFail(['web.withdraw.try_again_later','User In Control']);
  129. }
  130. $score=$request->input('score',0);
  131. if(!$score||is_float($score)||$score<=0){
  132. return apiReturnFail(['web.withdraw.score_fail', 'Amount must be an integer value.']);
  133. }
  134. $redisKey = 'withdraw_'.$UserID;
  135. if (!SetNXLock::getExclusiveLock($redisKey)) {
  136. return apiReturnFail(['web.withdraw.try_again_later','Tente novamente mais tarde']);
  137. }
  138. GameScoreLocker::where('UserID',$UserID)->delete();
  139. $dbh = DB::connection()->getPdo();
  140. // $score=$score*NumConfig::NUM_VALUE;
  141. $sql="DECLARE @return_value int
  142. set nocount on use QPAccountsDB
  143. EXEC @return_value = GSP_GR_GetWithDraw20260312 '$UserID','$score'
  144. SELECT 'ReturnValue' = @return_value";
  145. // echo $sql;die;
  146. $stmt = $dbh->prepare($sql);
  147. $stmt->execute();
  148. SetNXLock::release($redisKey);
  149. $retval = $stmt->fetch(\PDO::FETCH_ASSOC);
  150. try {
  151. // set @ret = 1 --可提额度不足
  152. // set @ret = 2 --低于最低可提现金额
  153. // set @ret = 3 --高于最高可提现金额
  154. // set @ret = 4 --超过每天提现次数上限
  155. // set @ret = 5 --身上钱不够
  156. // set @ret = 6 --开在游戏里面
  157. // set @ret = 7 --未充值的用户TX额度
  158. if (isset($retval['ReturnValue'])) {
  159. $ReturnValue = $retval['ReturnValue'];
  160. // set @ret = 1 -- Insufficient withdrawal amount
  161. // set @ret = 2 -- Lower than the minimum withdrawal amount
  162. // set @ret = 3 -- Higher than the maximum withdrawal amount
  163. // set @ret = 4 -- Exceeded the daily withdrawal limit
  164. // set @ret = 5 -- Not enough money on hand
  165. // set @ret = 6 -- Opened in the game
  166. // set @ret = 7 -- Undeposited user TX amount
  167. $errors = [
  168. [],
  169. ['web.withdraw.no_withdraw_value', "The withdrawable amount is not enough"],
  170. ['web.withdraw.too_low', 'Lower than the minimum withdrawal amount'],
  171. ['web.withdraw.too_high', 'Higher than the maximum withdrawal amount'],
  172. ['web.withdraw.day_max', 'Exceeded the daily withdrawal limit'],
  173. ['web.withdraw.no_enouth_score', 'Not enough money on hand'],
  174. ['web.withdraw.in_game', 'Sorry, You\'re in game for now'],
  175. ['web.withdraw.no_deposit', ' You need deposit first!'],
  176. ];
  177. return apiReturnFail($errors[$ReturnValue], [], $ReturnValue == 7 ? 777 : 301);
  178. }else{
  179. return apiReturnSuc($retval);
  180. }
  181. }catch (\Exception $e){
  182. TelegramBot::getDefault()->sendProgramNotify("WithDraw Error:", var_export($retval,true).':'.$e->getTraceAsString());
  183. return apiReturnSuc($retval);
  184. }
  185. }
  186. public function saveCpf(Request $request)
  187. {
  188. // $user = $request->user();
  189. // $UserID=$user->UserID;
  190. //
  191. // $account = $request->Account ?: '';
  192. // $phone = $request->Phone ?: '';
  193. // $email = $request->Email ?: '';
  194. // $PixNum = $request->PixNum ?: '';
  195. //
  196. // if(!Util::validateCpf($PixNum)){
  197. // return apiReturnFail(['withdraw.account.tip.cpf_error','Cpf error format']);
  198. // }
  199. //
  200. // $redisKey = 'Api_updateAccountsPayInfo_'.$UserID;
  201. // $lock = SetNXLock::getExclusiveLock($redisKey);
  202. // if (!$lock) {
  203. // return apiReturnFail(['web.withdraw.try_again_later','Tente novamente mais tarde']);
  204. // }
  205. // $exist = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')->where('UserID', $UserID)->first();
  206. //
  207. // if ($exist) {
  208. // DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')->where('UserID', $UserID)->update(['PixNum' => $PixNum]);
  209. // } else {
  210. //
  211. // $data = ['BankUserName' => $account, 'PhoneNumber' => $phone, 'EmailAddress' => $email, 'UserID' => $UserID, 'PixNum' => $PixNum, 'Achieves' => '', 'HistoryWithDraw' => 0];
  212. // DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  213. // ->insert($data);
  214. // }
  215. // SetNXLock::release($redisKey);
  216. return apiReturnSuc();
  217. }
  218. public function MexWithDrawInfo(Request $request)
  219. {
  220. $user = $request->user();
  221. $UserID=$user->UserID;
  222. $paypass = $request->input('paypass');
  223. $PixType = $request->input('cbPixType');;
  224. $BankNO = $request->input('account');
  225. $AccountsBank = $request->input('account');
  226. $BankUserName = $request->input('userName');
  227. $PhoneNumber = $request->input('phone');
  228. $EmailAddress = $request->input('email');
  229. $IFSCNumber = $request->input('IFSCNumber');
  230. // $PANNumber = $request->input('PAN');
  231. // $AdhaarNumber = $request->input('adhaar');
  232. // $BranchBank = $request->input('branceBank');
  233. $BranchBank = $request->input('bank');//银行编号
  234. $PixNum = $request->input('account');
  235. Util::WriteLog("mexwithdraw",$request->all());
  236. if(isset($EmailAddress)&&!empty($EmailAddress)){
  237. $validator = Validator::make(
  238. ['email' => $EmailAddress],
  239. ['email' => 'required|email']
  240. );
  241. if ($validator->fails()) {
  242. return apiReturnFail(['web.user.email_fail','Wrong email format']);
  243. }
  244. }
  245. if (!$AccountsBank || $AccountsBank == 'undefined') {
  246. return apiReturnFail(['web.bank.account_empty', 'The bank account cannot be empty']);
  247. }
  248. if (!(strlen($AccountsBank) == 16 || strlen($AccountsBank) == 18)) {
  249. return apiReturnFail(['web.bank.account_invalid_length', 'The bank number must have 16 or 18 digits']);
  250. }
  251. if (!(strlen($IFSCNumber) == 18 && $IFSCNumber)) {
  252. return apiReturnFail(['web.bank.clabe_invalid_length', 'The Clabe number must have 18 digits']);
  253. }
  254. if (!$BankUserName || $BankUserName == 'undefined') {
  255. return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
  256. }
  257. if (!$BranchBank || $BranchBank == 'undefined') {
  258. return apiReturnFail(['web.bank.branch_empty', 'The branch code cannot be empty']);
  259. }
  260. if (strlen($AccountsBank) == 16) {
  261. $PixType = 2;
  262. }
  263. if (strlen($AccountsBank) == 18) {
  264. $PixType = 1;
  265. }
  266. $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
  267. if (!SetNXLock::getExclusiveLock($redisKey)) {
  268. return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
  269. }
  270. if (!$UserID) {
  271. Log::info('miss UserID', $request->all());
  272. SetNXLock::release($redisKey);
  273. return apiReturnFail(['web.bank.missing_userid', 'params error']);
  274. }
  275. if (empty($PixType)) {
  276. SetNXLock::release($redisKey);
  277. return apiReturnFail(['web.bank.pix_type_missing', 'The PIX type is missing']);
  278. }
  279. // 验证PixNum绑定次数
  280. if (!empty($PixNum)) {
  281. $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  282. ->where('BankCard', $PixNum)
  283. ->lock('WITH(NOLOCK)')
  284. ->count();
  285. if ($BindCount >= 3) {
  286. SetNXLock::release($redisKey);
  287. return apiReturnFail(['web.bank.cpf_used_multiple_times', 'The CPF number has been used multiple times and cannot be saved'], [], 302);
  288. }
  289. }
  290. // 验证玩家信息
  291. if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
  292. return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  293. }
  294. if ($PixType < 10 && false) {
  295. $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum');
  296. } else {
  297. $data = compact('PixType', 'BankUserName','IFSCNumber', 'PhoneNumber', 'EmailAddress','BankNO', 'AccountsBank','BranchBank','PixNum');
  298. $PixNum = $BankNO;
  299. }
  300. foreach ($data as $key => &$val) {
  301. $data[$key] = trim($val);
  302. }
  303. unset($val);
  304. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  305. ->lock('WITH(NOLOCK)')
  306. ->where('UserID', $UserID)
  307. ->first();
  308. if (!$AccountWithDrawInfo) {
  309. $data['UserID'] = $UserID;
  310. $data['Achieves'] = 0;
  311. $data['HistoryWithDraw'] = 0;
  312. try {
  313. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  314. ->where('UserID', $UserID)
  315. ->insert($data);
  316. } catch (\Exception $e) {
  317. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  318. }
  319. } else {
  320. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  321. ->where('UserID', $UserID)
  322. ->update($data);
  323. }
  324. // 添加绑定记录
  325. if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
  326. try {
  327. DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  328. ->insert([
  329. 'UserID' => $UserID,
  330. 'BankCard' => $PixNum ?: '',
  331. 'BindDate' => now()
  332. ]);
  333. } catch (\Exception $e) {
  334. Log::error('insert RecordBankCardBind failed', ['data' => $data]);
  335. }
  336. }
  337. SetNXLock::release($redisKey);
  338. return apiReturnSuc();
  339. }
  340. public function RuWithDrawInfo(Request $request)
  341. {
  342. $user = $request->user();
  343. $UserID=$user->UserID;
  344. $paypass = $request->input('paypass');
  345. $PixType = $request->input('PixType');;
  346. $BankNO = $request->input('account');
  347. $BankUserName = $request->input('userName');
  348. $PhoneNumber = $request->input('phone');
  349. // $EmailAddress = $request->input('email');
  350. // $IFSCNumber = $request->input('IFSCNumber');
  351. // $PANNumber = $request->input('PAN');
  352. // $AdhaarNumber = $request->input('adhaar');
  353. // $BranchBank = $request->input('branceBank');
  354. $BranchBank = $request->input('bank');//银行编号
  355. $PixNum = $BankNO;
  356. $AccountsBank = $BankNO;
  357. Util::WriteLog("ruwithdraw",$request->all());
  358. if (!$BankUserName || $BankUserName == 'undefined') {
  359. return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
  360. }
  361. if($PixType==1) {
  362. if (!$AccountsBank || $AccountsBank == 'undefined') {
  363. return apiReturnFail(['web.bank.account_empty', 'The bank account cannot be empty']);
  364. }
  365. if (!(strlen($AccountsBank) == 16 )) {
  366. return apiReturnFail(['web.bank.account_invalid_length', 'The bank number must have 16 digits']);
  367. }
  368. // if (!(strlen($IFSCNumber) == 11 && $IFSCNumber)) {
  369. // return apiReturnFail(['web.bank.clabe_invalid_length', 'The Clabe number must have 18 digits']);
  370. // }
  371. }else{
  372. if(!$PhoneNumber||strlen($PhoneNumber)!=11){
  373. return apiReturnFail(['withdraw.account.tip.phone_error', 'The phone number is error']);
  374. }
  375. if (!$BranchBank || $BranchBank == 'undefined') {
  376. return apiReturnFail(['web.bank.branch_empty', 'The branch code cannot be empty']);
  377. }
  378. }
  379. $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
  380. if (!SetNXLock::getExclusiveLock($redisKey)) {
  381. return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
  382. }
  383. if (!$UserID) {
  384. Log::info('miss UserID', $request->all());
  385. SetNXLock::release($redisKey);
  386. return apiReturnFail(['web.bank.missing_userid', 'params error']);
  387. }
  388. if (empty($PixType)) {
  389. SetNXLock::release($redisKey);
  390. return apiReturnFail(['web.bank.pix_type_missing', 'The PIX type is missing']);
  391. }
  392. // 验证PixNum绑定次数
  393. if (!empty($PixNum)) {
  394. $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  395. ->where('BankCard', $PixNum)
  396. ->lock('WITH(NOLOCK)')
  397. ->count();
  398. if ($BindCount >= 3) {
  399. SetNXLock::release($redisKey);
  400. return apiReturnFail(['web.bank.cpf_used_multiple_times', 'The CPF number has been used multiple times and cannot be saved'], [], 302);
  401. }
  402. }
  403. // 验证玩家信息
  404. if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
  405. return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  406. }
  407. $data = compact('PixType', 'BankUserName', 'PhoneNumber','BankNO', 'AccountsBank','BranchBank','PixNum');
  408. $PixNum = $BankNO;
  409. foreach ($data as $key => &$val) {
  410. $data[$key] = trim($val);
  411. }
  412. unset($val);
  413. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  414. ->lock('WITH(NOLOCK)')
  415. ->where('UserID', $UserID)
  416. ->first();
  417. if (!$AccountWithDrawInfo) {
  418. $data['UserID'] = $UserID;
  419. $data['Achieves'] = 0;
  420. $data['HistoryWithDraw'] = 0;
  421. try {
  422. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  423. ->where('UserID', $UserID)
  424. ->insert($data);
  425. } catch (\Exception $e) {
  426. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  427. }
  428. } else {
  429. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  430. ->where('UserID', $UserID)
  431. ->update($data);
  432. }
  433. // 添加绑定记录
  434. if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
  435. try {
  436. DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  437. ->insert([
  438. 'UserID' => $UserID,
  439. 'BankCard' => $PixNum ?: '',
  440. 'BindDate' => now()
  441. ]);
  442. } catch (\Exception $e) {
  443. Log::error('insert RecordBankCardBind failed', ['data' => $data]);
  444. }
  445. }
  446. SetNXLock::release($redisKey);
  447. return apiReturnSuc();
  448. }
  449. public function withDrawInfo(Request $request)
  450. {
  451. // return apiReturnFail('params error');
  452. $user = $request->user();
  453. $UserID=$user->UserID;
  454. // 检查是否有成功的提现记录 (State = 2 表示成功)
  455. $hasSuccessWithdraw = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  456. ->lock('WITH(NOLOCK)')
  457. ->where('UserID', $UserID)
  458. ->where('State', 2)
  459. ->exists();
  460. $limitKey = 'last_withdraw_info_update_' . $UserID;
  461. if ($hasSuccessWithdraw) {
  462. if (Redis::exists($limitKey)) {
  463. return apiReturnFail(['web.withdraw.update_limit', 'You can only update your information once every 24 hours.']);
  464. }
  465. $code = $request->input('code');
  466. if (empty($code)) {
  467. return apiReturnFail(['web.verify.code_empty', 'Verification code cannot be empty']);
  468. }
  469. $phone = trim((string)DB::table(TableName::QPAccountsDB() . 'AccountPhone')->where('UserID', $UserID)->value('PhoneNum'));
  470. $countryCode = preg_replace('/\D/s', '', trim((string)env('COUNTRY_CODE',1)));
  471. if ($phone !== '' && $countryCode !== '' && !str_starts_with($phone, $countryCode)) {
  472. $phone = $countryCode . $phone;
  473. }
  474. if (empty($phone)) {
  475. return apiReturnFail(['web.verify.phone_not_bound', 'Phone number not bound']);
  476. }
  477. $verifyStatus = \App\Models\GamePhoneVerityCode::verifyCode($phone, $code);
  478. if ($verifyStatus == 1) {
  479. return apiReturnFail(['web.verify.code_error', 'Invalid verification code']);
  480. }
  481. // 验证通过,清除验证码
  482. \App\Models\GamePhoneVerityCode::clearPhoneCode($phone);
  483. }
  484. // $UserID = (int)$request->globalUser->UserID;//$request->input('UserID');
  485. // $RequestDynamicPass = $request->input('DynamicPass');
  486. $PixType = $request->input('cbPixType');
  487. $BankUserName = urldecode($request->input('userName'));
  488. $EmailAddress = $request->input('email');
  489. $PixNum = $request->input('PixNum');
  490. if(!empty($EmailAddress))$EmailAddress=Util::cleanEmptyString($EmailAddress);
  491. if(!empty($PixNum))$PixNum=Util::cleanEmptyString($PixNum);
  492. if (!empty($EmailAddress)&&!Util::validateEmail($EmailAddress)) {
  493. return apiReturnFail(['web.user.email_fail','Wrong email format']);
  494. }
  495. $redisKey = 'withDrawInfo_withDrawInfo_'.$UserID;
  496. if (!SetNXLock::getExclusiveLock($redisKey)) {
  497. Util::WriteLog("withdrawInfo",[1, $request->all()]);
  498. return apiReturnFail(['web.withdraw.try_again_later','Tente novamente mais tarde']);
  499. }
  500. if (!$UserID) {
  501. Util::WriteLog("withdrawInfo",[2, $request->all()]);
  502. Log::info('miss UserID', $request->all());
  503. SetNXLock::release($redisKey);
  504. return apiReturnFail(['web.withdraw.params_error','params error']);
  505. }
  506. if (empty($PixType)) {
  507. Util::WriteLog("withdrawInfo",[3, $request->all()]);
  508. SetNXLock::release($redisKey);
  509. return apiReturnFail(["web.withdraw.pix_type_missing",'O tipo PIX está ausente']);
  510. }
  511. // 验证PixNum绑定次数
  512. // if (!empty($PixNum)) {
  513. // $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  514. // ->where('BankCard', $PixNum)
  515. // ->lock('WITH(NOLOCK)')
  516. // ->count();
  517. // if ($BindCount >= 6) {
  518. // Util::WriteLog("withdrawInfo",[4, $request->all()]);
  519. // SetNXLock::release($redisKey);
  520. // return apiReturnFail(['web.withdraw.cpf_number_used','O número do CPF foi usado várias vezes e não pode ser salvo'], [], 302);
  521. // }
  522. // }
  523. if ($PixType==1) {
  524. // 验证 cashapp
  525. if (!empty($PixNum)) {
  526. // 如果 PixNum 第一个字符不是 "$",则在前面添加 "$"
  527. if (substr($PixNum, 0, 1) !== '$') {
  528. $PixNum = '$' . $PixNum;
  529. }
  530. // 构建 cash.app URL
  531. $cashAppUrl = 'https://cash.app/' . $PixNum;
  532. try {
  533. // 使用 stream context 来获取 HTTP 响应头
  534. $context = stream_context_create([
  535. 'http' => [
  536. 'method' => 'GET',
  537. 'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36\r\n",
  538. 'ignore_errors' => true
  539. ]
  540. ]);
  541. $htmlContent = @file_get_contents($cashAppUrl, false, $context);
  542. // 检查 HTTP 响应头中的状态码
  543. if ($htmlContent === false || (isset($http_response_header) && preg_match('/HTTP\/\d\.\d\s+404/', implode("\n", $http_response_header)))) {
  544. Util::WriteLog("withdrawInfo", [5, $request->all(), 'Invalid cashapp: ' . $PixNum]);
  545. SetNXLock::release($redisKey);
  546. return apiReturnFail(['web.withdraw.invalid_cashapp', 'Invalid CashApp account']);
  547. }
  548. if ($htmlContent !== false) {
  549. // 去除空格换行,转换成一行字符串
  550. $htmlContent = preg_replace('/\s+/', '', $htmlContent);
  551. Util::WriteLog("withdrawInfo", [5, $request->all(), 'CashApp verification response: ' . $htmlContent]);
  552. // 检查响应内容中是否包含 "404 Not Found"
  553. if (stripos($htmlContent, '404NotFound') !== false) {
  554. Util::WriteLog("withdrawInfo", [5, $request->all(), 'Invalid cashapp: ' . $PixNum]);
  555. SetNXLock::release($redisKey);
  556. return apiReturnFail(['web.withdraw.invalid_cashapp', 'Invalid CashApp account']);
  557. }
  558. }
  559. } catch (\Exception $e) {
  560. // 其他异常也记录日志但不阻止流程
  561. Util::WriteLog("withdrawInfo", [5, $request->all(), 'CashApp verification error: ' . $e->getMessage()]);
  562. }
  563. }
  564. $data = compact('PixType', 'BankUserName', 'PixNum');
  565. } else {
  566. $data = compact('PixType', 'EmailAddress');
  567. }
  568. foreach ($data as $key => &$val) {
  569. $data[$key] = trim($val);
  570. }
  571. unset($val);
  572. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  573. ->lock('WITH(NOLOCK)')
  574. ->where('UserID', $UserID)
  575. ->first();
  576. if (!$AccountWithDrawInfo) {
  577. $data['UserID'] = $UserID;
  578. $data['Achieves'] = 0;
  579. $data['HistoryWithDraw'] = 0;
  580. try {
  581. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  582. ->where('UserID', $UserID)
  583. ->insert($data);
  584. } catch (\Exception $e) {
  585. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  586. Util::WriteLog("withdrawInfo",[6, $request->all(),$data]);
  587. }
  588. } else {
  589. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  590. ->where('UserID', $UserID)
  591. ->update($data);
  592. }
  593. // 记录修改时间,限制24小时
  594. Redis::setex($limitKey, 86400, time());
  595. SetNXLock::release($redisKey);
  596. return apiReturnSuc();
  597. }
  598. public function withDrawInfoSA(Request $request)
  599. {
  600. // return apiReturnFail('params error');
  601. $UserID = $request->input('UserID');
  602. $RequestDynamicPass = $request->input('DynamicPass');
  603. $PixType = $request->input('cbPixType');
  604. $BankNO = $request->input('bank');
  605. $AccountsBank = urldecode($request->input('account'));
  606. $BankUserName = urldecode($request->input('userName'));
  607. // 原始代码
  608. $BankUserName = Util::filterNickName($BankUserName);
  609. // 新增处理:在大写字母前加空格
  610. $BankUserName = preg_replace('/(?<!^)([A-Z])/', ' $1', $BankUserName);
  611. $PhoneNumber = $request->input('phone');
  612. $EmailAddress = $request->input('email');
  613. $IFSCNumber = $request->input('IFSC');
  614. $PANNumber = $request->input('PAN');
  615. $AdhaarNumber = $request->input('adhaar');
  616. $BranchBank = $request->input('branceBank');
  617. $PixNum = $request->input('PixNum');
  618. $redisKey = 'withDrawInfo_withDrawInfo_'.$UserID;
  619. if (!SetNXLock::getExclusiveLock($redisKey)) {
  620. Util::WriteLog("withdrawInfo",[1, $request->all()]);
  621. return apiReturnFail('Tente novamente mais tarde');
  622. }
  623. if (!$UserID) {
  624. Util::WriteLog("withdrawInfo",[2, $request->all()]);
  625. Log::info('miss UserID', $request->all());
  626. SetNXLock::release($redisKey);
  627. return apiReturnFail('params error');
  628. }
  629. if (empty($PixType)) {
  630. Util::WriteLog("withdrawInfo",[3, $request->all()]);
  631. SetNXLock::release($redisKey);
  632. return apiReturnFail('O tipo PIX está ausente');
  633. }
  634. // Util::validateSouthAmericanPhone('',)
  635. // 验证PixNum绑定次数
  636. if (!empty($PixNum)) {
  637. $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  638. ->where('BankCard', $PixNum)
  639. ->lock('WITH(NOLOCK)')
  640. ->count();
  641. if ($BindCount >= 8) {
  642. Util::WriteLog("withdrawInfo",[4, $request->all()]);
  643. SetNXLock::release($redisKey);
  644. return apiReturnFail(['web.withdraw.cpf_number_used','The CPF number has been used several times and cannot be saved'], [], 302);
  645. }
  646. }
  647. // if(!is_numeric($PixNum)){
  648. // return apiReturnFail(['web.withdraw.pix_failed','The CPF number has been used several times and cannot be saved'], [], 302);
  649. // }
  650. // 验证玩家信息
  651. $DynamicPass = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')
  652. ->where('UserID', $UserID)
  653. ->lock('WITH(NOLOCK)')
  654. ->value('DynamicPass');
  655. if ($DynamicPass != $RequestDynamicPass || empty($DynamicPass)) {
  656. SetNXLock::release($redisKey);
  657. Util::WriteLog("withdrawInfo",[5, $request->all()]);
  658. return apiReturnFail('As informações do jogador são inconsistentes');
  659. }
  660. $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum','BankNO', 'AccountsBank', 'IFSCNumber', 'PANNumber', 'AdhaarNumber', 'BranchBank');
  661. foreach ($data as $key => &$val) {
  662. $data[$key] = trim($val);
  663. }
  664. unset($val);
  665. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  666. ->lock('WITH(NOLOCK)')
  667. ->where('UserID', $UserID)
  668. ->first();
  669. if (!$AccountWithDrawInfo) {
  670. $data['UserID'] = $UserID;
  671. $data['Achieves'] = 0;
  672. $data['HistoryWithDraw'] = 0;
  673. try {
  674. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  675. ->where('UserID', $UserID)
  676. ->insert($data);
  677. } catch (\Exception $e) {
  678. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  679. Util::WriteLog("withdrawInfo",[6, $request->all(),$data]);
  680. }
  681. } else {
  682. $data = array_filter($data, function ($value) {
  683. return !is_null($value) && $value !== '';
  684. });
  685. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  686. ->where('UserID', $UserID)
  687. ->update($data);
  688. }
  689. // 添加绑定记录
  690. if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
  691. try {
  692. if(!DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')->where('UserID', $UserID)->exists()&&is_numeric($PixNum)) {
  693. DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  694. ->insert([
  695. 'UserID' => $UserID,
  696. 'BankCard' => $PixNum ?? '',
  697. 'BindDate' => now()
  698. ]);
  699. Util::WriteLog('update_pix', [
  700. 'UserID' => $UserID,
  701. 'BankCard' => $PixNum ?? '',
  702. 'BindDate' => now()
  703. ]);
  704. }
  705. } catch (\Exception $e) {
  706. Log::error('insert RecordBankCardBind failed', ['data' => $data]);
  707. Util::WriteLog("withdrawInfo",[7, $request->all(),$data]);
  708. }
  709. }
  710. SetNXLock::release($redisKey);
  711. return apiReturnSuc();
  712. }
  713. public function kycSimpleEU(Request $request)
  714. {
  715. // return apiReturnFail('params error');
  716. $user = $request->user();
  717. $UserID=$user->UserID;
  718. $firstName = Util::filterNickName(urldecode($request->input('firstName')));
  719. $lastName = Util::filterNickName(urldecode($request->input('lastName')));
  720. // 原始代码
  721. $BankUserName = $firstName.'|'.$lastName;
  722. $PhoneNumber = $request->input('phone');
  723. $EmailAddress = $request->input('email');
  724. Util::WriteLog("kyc_eu",$request->all());
  725. if(isset($EmailAddress)&&!empty($EmailAddress)){
  726. $validator = Validator::make(
  727. ['email' => $EmailAddress],
  728. ['email' => 'required|email']
  729. );
  730. if ($validator->fails()) {
  731. return apiReturnFail(['web.user.email_fail','Wrong email format']);
  732. }
  733. }
  734. if (!$BankUserName || $BankUserName == 'undefined') {
  735. return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
  736. }
  737. $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
  738. if (!SetNXLock::getExclusiveLock($redisKey)) {
  739. return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
  740. }
  741. if (!$UserID) {
  742. Log::info('miss UserID', $request->all());
  743. SetNXLock::release($redisKey);
  744. return apiReturnFail(['web.bank.missing_userid', 'params error']);
  745. }
  746. $data = compact('BankUserName', 'PhoneNumber', 'EmailAddress');
  747. foreach ($data as $key => &$val) {
  748. $data[$key] = trim($val);
  749. if(empty($val))unset($data[$key]);
  750. }
  751. unset($val);
  752. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  753. ->lock('WITH(NOLOCK)')
  754. ->where('UserID', $UserID)
  755. ->first();
  756. if (!$AccountWithDrawInfo) {
  757. $data['UserID'] = $UserID;
  758. $data['Achieves'] = 0;
  759. $data['HistoryWithDraw'] = 0;
  760. try {
  761. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  762. ->where('UserID', $UserID)
  763. ->insert($data);
  764. } catch (\Exception $e) {
  765. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  766. }
  767. } else {
  768. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  769. ->where('UserID', $UserID)
  770. ->update($data);
  771. }
  772. SetNXLock::release($redisKey);
  773. return apiReturnSuc();
  774. }
  775. public function withDrawInfoEU(Request $request)
  776. {
  777. // return apiReturnFail('params error');
  778. $user = $request->user();
  779. $UserID=$user->UserID;
  780. // $UserID = $request->input('UserID');
  781. // $RequestDynamicPass = $request->input('DynamicPass');
  782. $PixType = $request->input('cbPixType');
  783. $firstName = Util::filterNickName(urldecode($request->input('firstName')));
  784. $lastName = Util::filterNickName(urldecode($request->input('lastName')));
  785. // 原始代码
  786. $BankUserName = $firstName.'|'.$lastName;
  787. $BankNO = $request->input('account');
  788. $AccountsBank = $request->input('account');
  789. $PhoneNumber = $request->input('phone');
  790. $EmailAddress = $request->input('email');
  791. $IFSCNumber = $request->input('IFSCNumber');
  792. $BranchBank = $request->input('bank');//银行编号
  793. $PixNum = $request->input('account');
  794. Util::WriteLog("euwithdraw",$request->all());
  795. if(isset($EmailAddress)&&!empty($EmailAddress)){
  796. $validator = Validator::make(
  797. ['email' => $EmailAddress],
  798. ['email' => 'required|email']
  799. );
  800. if ($validator->fails()) {
  801. return apiReturnFail(['web.user.email_fail','Wrong email format']);
  802. }
  803. }
  804. if (!$AccountsBank || $AccountsBank == 'undefined') {
  805. return apiReturnFail(['web.bank.account_empty', 'The bank account cannot be empty']);
  806. }
  807. if (!(strlen($AccountsBank) == 16 || strlen($AccountsBank) == 18)) {
  808. return apiReturnFail(['web.bank.account_invalid_length', 'The bank number must have 16 or 18 digits']);
  809. }
  810. if (!(strlen($IFSCNumber) == 18 && $IFSCNumber)) {
  811. return apiReturnFail(['web.bank.clabe_invalid_length', 'The Clabe number must have 18 digits']);
  812. }
  813. if (!$BankUserName || $BankUserName == 'undefined') {
  814. return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
  815. }
  816. if (!$BranchBank || $BranchBank == 'undefined') {
  817. return apiReturnFail(['web.bank.branch_empty', 'The branch code cannot be empty']);
  818. }
  819. if (strlen($AccountsBank) == 16) {
  820. $PixType = 2;
  821. }
  822. if (strlen($AccountsBank) == 18) {
  823. $PixType = 1;
  824. }
  825. $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
  826. if (!SetNXLock::getExclusiveLock($redisKey)) {
  827. return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
  828. }
  829. if (!$UserID) {
  830. Log::info('miss UserID', $request->all());
  831. SetNXLock::release($redisKey);
  832. return apiReturnFail(['web.bank.missing_userid', 'params error']);
  833. }
  834. if (empty($PixType)) {
  835. SetNXLock::release($redisKey);
  836. return apiReturnFail(['web.bank.pix_type_missing', 'The PIX type is missing']);
  837. }
  838. // 验证PixNum绑定次数
  839. if (!empty($PixNum)) {
  840. $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  841. ->where('BankCard', $PixNum)
  842. ->lock('WITH(NOLOCK)')
  843. ->count();
  844. if ($BindCount >= 3) {
  845. SetNXLock::release($redisKey);
  846. return apiReturnFail(['web.bank.cpf_used_multiple_times', 'The CPF number has been used multiple times and cannot be saved'], [], 302);
  847. }
  848. }
  849. // 验证玩家信息
  850. if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
  851. return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  852. }
  853. if ($PixType < 10 && false) {
  854. $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum');
  855. } else {
  856. $data = compact('PixType', 'BankUserName','IFSCNumber', 'PhoneNumber', 'EmailAddress','BankNO', 'AccountsBank','BranchBank','PixNum');
  857. $PixNum = $BankNO;
  858. }
  859. foreach ($data as $key => &$val) {
  860. $data[$key] = trim($val);
  861. }
  862. unset($val);
  863. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  864. ->lock('WITH(NOLOCK)')
  865. ->where('UserID', $UserID)
  866. ->first();
  867. if (!$AccountWithDrawInfo) {
  868. $data['UserID'] = $UserID;
  869. $data['Achieves'] = 0;
  870. $data['HistoryWithDraw'] = 0;
  871. try {
  872. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  873. ->where('UserID', $UserID)
  874. ->insert($data);
  875. } catch (\Exception $e) {
  876. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  877. }
  878. } else {
  879. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  880. ->where('UserID', $UserID)
  881. ->update($data);
  882. }
  883. // 添加绑定记录
  884. if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
  885. try {
  886. DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  887. ->insert([
  888. 'UserID' => $UserID,
  889. 'BankCard' => $PixNum ?: '',
  890. 'BindDate' => now()
  891. ]);
  892. } catch (\Exception $e) {
  893. Log::error('insert RecordBankCardBind failed', ['data' => $data]);
  894. }
  895. }
  896. SetNXLock::release($redisKey);
  897. return apiReturnSuc();
  898. }
  899. // 获取提现信息
  900. public function getWithDrawInfo(Request $request)
  901. {
  902. // $UserID = (int)$request->globalUser->UserID;//$request->input('UserID');
  903. $user = $request->user();
  904. $UserID=$user->UserID;
  905. // $paypass = $request->input('paypass');
  906. // if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
  907. // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  908. // }
  909. $info = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  910. ->where('UserID', $UserID)
  911. ->lock('WITH(NOLOCK)')
  912. ->first();
  913. if (!$info) { // 赋值 -- 避免客户端报错
  914. $info = [
  915. // 'BankNO' => '',
  916. // 'AccountsBank' => '',
  917. 'BankUserName' => '',
  918. // 'PhoneNumber' => '',
  919. // 'IFSCNumber' => '',
  920. 'EmailAddress' => '',
  921. // 'Achieves' => '',
  922. // 'PANNumber' => '',
  923. // 'AdhaarNumber' => '',
  924. // 'BranchBank' => '',
  925. 'PixNum' => '',
  926. 'PixType' => '',
  927. ];
  928. }
  929. $info = json_decode(json_encode($info),true);
  930. if(env('REGION_24680')=='na-mexico') {
  931. $info['bank_list'] = config('games.mex_bank_list');
  932. }else if(env('REGION_24680')=='eu-russian') {
  933. $info['bank_list'] = config('games.ru_bank_list');
  934. }
  935. // 获取绑定手机号
  936. $phone = DB::table(TableName::QPAccountsDB() . 'AccountPhone')->where('UserID', $UserID)->value('PhoneNum');
  937. if ($phone) {
  938. // 简单脱敏处理,例如:5511******88
  939. $info['bind_phone'] = substr($phone, 0, 4) . '****' . substr($phone, -2);
  940. } else {
  941. $info['bind_phone'] = '';
  942. }
  943. $AccountsInfoModel = new AccountsInfo();
  944. $total = $AccountsInfoModel->accountTotalStatistics([$UserID]);
  945. $totalRecharge= @$total[0]->Recharge ?? 0;
  946. $info['total_recharge'] = intval($totalRecharge);
  947. $info['withdraw_level'] = env('MIN_RECHARGE',20);
  948. $hasSuccessWithdraw = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  949. ->lock('WITH(NOLOCK)')
  950. ->where('UserID', $UserID)
  951. ->where('State', 2)
  952. ->exists();
  953. $info['has_success_withdraw'] = $hasSuccessWithdraw;
  954. return apiReturnSuc(compact('info'));
  955. }
  956. }