WithDrawInfoController.php 44 KB

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