WithDrawInfoController.php 45 KB

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