WithDrawInfoController.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  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 = DB::table(TableName::QPAccountsDB() . 'AccountPhone')->where('UserID', $UserID)->value('PhoneNum');
  470. $phone = trim(env('COUNTRY_CODE',1) . $phone);
  471. if (empty($phone)) {
  472. return apiReturnFail(['web.verify.phone_not_bound', 'Phone number not bound']);
  473. }
  474. $verifyStatus = \App\Models\GamePhoneVerityCode::verifyCode($phone, $code);
  475. if ($verifyStatus == 1) {
  476. return apiReturnFail(['web.verify.code_error', 'Invalid verification code']);
  477. }
  478. // 验证通过,清除验证码
  479. \App\Models\GamePhoneVerityCode::clearPhoneCode($phone);
  480. }
  481. // $UserID = (int)$request->globalUser->UserID;//$request->input('UserID');
  482. // $RequestDynamicPass = $request->input('DynamicPass');
  483. $PixType = $request->input('cbPixType');
  484. $BankUserName = urldecode($request->input('userName'));
  485. $EmailAddress = $request->input('email');
  486. $PixNum = $request->input('PixNum');
  487. if(!empty($EmailAddress))$EmailAddress=Util::cleanEmptyString($EmailAddress);
  488. if(!empty($PixNum))$PixNum=Util::cleanEmptyString($PixNum);
  489. if (!empty($EmailAddress)&&!Util::validateEmail($EmailAddress)) {
  490. return apiReturnFail(['web.user.email_fail','Wrong email format']);
  491. }
  492. $redisKey = 'withDrawInfo_withDrawInfo_'.$UserID;
  493. if (!SetNXLock::getExclusiveLock($redisKey)) {
  494. Util::WriteLog("withdrawInfo",[1, $request->all()]);
  495. return apiReturnFail(['web.withdraw.try_again_later','Tente novamente mais tarde']);
  496. }
  497. if (!$UserID) {
  498. Util::WriteLog("withdrawInfo",[2, $request->all()]);
  499. Log::info('miss UserID', $request->all());
  500. SetNXLock::release($redisKey);
  501. return apiReturnFail(['web.withdraw.params_error','params error']);
  502. }
  503. if (empty($PixType)) {
  504. Util::WriteLog("withdrawInfo",[3, $request->all()]);
  505. SetNXLock::release($redisKey);
  506. return apiReturnFail(["web.withdraw.pix_type_missing",'O tipo PIX está ausente']);
  507. }
  508. // 验证PixNum绑定次数
  509. // if (!empty($PixNum)) {
  510. // $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  511. // ->where('BankCard', $PixNum)
  512. // ->lock('WITH(NOLOCK)')
  513. // ->count();
  514. // if ($BindCount >= 6) {
  515. // Util::WriteLog("withdrawInfo",[4, $request->all()]);
  516. // SetNXLock::release($redisKey);
  517. // return apiReturnFail(['web.withdraw.cpf_number_used','O número do CPF foi usado várias vezes e não pode ser salvo'], [], 302);
  518. // }
  519. // }
  520. if ($PixType==1) {
  521. // 验证 cashapp
  522. if (!empty($PixNum)) {
  523. // 如果 PixNum 第一个字符不是 "$",则在前面添加 "$"
  524. if (substr($PixNum, 0, 1) !== '$') {
  525. $PixNum = '$' . $PixNum;
  526. }
  527. // 构建 cash.app URL
  528. $cashAppUrl = 'https://cash.app/' . $PixNum;
  529. try {
  530. // 使用 stream context 来获取 HTTP 响应头
  531. $context = stream_context_create([
  532. 'http' => [
  533. 'method' => 'GET',
  534. 'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36\r\n",
  535. 'ignore_errors' => true
  536. ]
  537. ]);
  538. $htmlContent = @file_get_contents($cashAppUrl, false, $context);
  539. // 检查 HTTP 响应头中的状态码
  540. if ($htmlContent === false || (isset($http_response_header) && preg_match('/HTTP\/\d\.\d\s+404/', implode("\n", $http_response_header)))) {
  541. Util::WriteLog("withdrawInfo", [5, $request->all(), 'Invalid cashapp: ' . $PixNum]);
  542. SetNXLock::release($redisKey);
  543. return apiReturnFail(['web.withdraw.invalid_cashapp', 'Invalid CashApp account']);
  544. }
  545. if ($htmlContent !== false) {
  546. // 去除空格换行,转换成一行字符串
  547. $htmlContent = preg_replace('/\s+/', '', $htmlContent);
  548. Util::WriteLog("withdrawInfo", [5, $request->all(), 'CashApp verification response: ' . $htmlContent]);
  549. // 检查响应内容中是否包含 "404 Not Found"
  550. if (stripos($htmlContent, '404NotFound') !== false) {
  551. Util::WriteLog("withdrawInfo", [5, $request->all(), 'Invalid cashapp: ' . $PixNum]);
  552. SetNXLock::release($redisKey);
  553. return apiReturnFail(['web.withdraw.invalid_cashapp', 'Invalid CashApp account']);
  554. }
  555. }
  556. } catch (\Exception $e) {
  557. // 其他异常也记录日志但不阻止流程
  558. Util::WriteLog("withdrawInfo", [5, $request->all(), 'CashApp verification error: ' . $e->getMessage()]);
  559. }
  560. }
  561. $data = compact('PixType', 'BankUserName', 'PixNum');
  562. } else {
  563. $data = compact('PixType', 'EmailAddress');
  564. }
  565. foreach ($data as $key => &$val) {
  566. $data[$key] = trim($val);
  567. }
  568. unset($val);
  569. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  570. ->lock('WITH(NOLOCK)')
  571. ->where('UserID', $UserID)
  572. ->first();
  573. if (!$AccountWithDrawInfo) {
  574. $data['UserID'] = $UserID;
  575. $data['Achieves'] = 0;
  576. $data['HistoryWithDraw'] = 0;
  577. try {
  578. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  579. ->where('UserID', $UserID)
  580. ->insert($data);
  581. } catch (\Exception $e) {
  582. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  583. Util::WriteLog("withdrawInfo",[6, $request->all(),$data]);
  584. }
  585. } else {
  586. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  587. ->where('UserID', $UserID)
  588. ->update($data);
  589. }
  590. // 记录修改时间,限制24小时
  591. Redis::setex($limitKey, 86400, time());
  592. SetNXLock::release($redisKey);
  593. return apiReturnSuc();
  594. }
  595. public function withDrawInfoSA(Request $request)
  596. {
  597. // return apiReturnFail('params error');
  598. $UserID = $request->input('UserID');
  599. $RequestDynamicPass = $request->input('DynamicPass');
  600. $PixType = $request->input('cbPixType');
  601. $BankNO = $request->input('bank');
  602. $AccountsBank = urldecode($request->input('account'));
  603. $BankUserName = urldecode($request->input('userName'));
  604. // 原始代码
  605. $BankUserName = Util::filterNickName($BankUserName);
  606. // 新增处理:在大写字母前加空格
  607. $BankUserName = preg_replace('/(?<!^)([A-Z])/', ' $1', $BankUserName);
  608. $PhoneNumber = $request->input('phone');
  609. $EmailAddress = $request->input('email');
  610. $IFSCNumber = $request->input('IFSC');
  611. $PANNumber = $request->input('PAN');
  612. $AdhaarNumber = $request->input('adhaar');
  613. $BranchBank = $request->input('branceBank');
  614. $PixNum = $request->input('PixNum');
  615. $redisKey = 'withDrawInfo_withDrawInfo_'.$UserID;
  616. if (!SetNXLock::getExclusiveLock($redisKey)) {
  617. Util::WriteLog("withdrawInfo",[1, $request->all()]);
  618. return apiReturnFail('Tente novamente mais tarde');
  619. }
  620. if (!$UserID) {
  621. Util::WriteLog("withdrawInfo",[2, $request->all()]);
  622. Log::info('miss UserID', $request->all());
  623. SetNXLock::release($redisKey);
  624. return apiReturnFail('params error');
  625. }
  626. if (empty($PixType)) {
  627. Util::WriteLog("withdrawInfo",[3, $request->all()]);
  628. SetNXLock::release($redisKey);
  629. return apiReturnFail('O tipo PIX está ausente');
  630. }
  631. // Util::validateSouthAmericanPhone('',)
  632. // 验证PixNum绑定次数
  633. if (!empty($PixNum)) {
  634. $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  635. ->where('BankCard', $PixNum)
  636. ->lock('WITH(NOLOCK)')
  637. ->count();
  638. if ($BindCount >= 8) {
  639. Util::WriteLog("withdrawInfo",[4, $request->all()]);
  640. SetNXLock::release($redisKey);
  641. return apiReturnFail(['web.withdraw.cpf_number_used','The CPF number has been used several times and cannot be saved'], [], 302);
  642. }
  643. }
  644. // if(!is_numeric($PixNum)){
  645. // return apiReturnFail(['web.withdraw.pix_failed','The CPF number has been used several times and cannot be saved'], [], 302);
  646. // }
  647. // 验证玩家信息
  648. $DynamicPass = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')
  649. ->where('UserID', $UserID)
  650. ->lock('WITH(NOLOCK)')
  651. ->value('DynamicPass');
  652. if ($DynamicPass != $RequestDynamicPass || empty($DynamicPass)) {
  653. SetNXLock::release($redisKey);
  654. Util::WriteLog("withdrawInfo",[5, $request->all()]);
  655. return apiReturnFail('As informações do jogador são inconsistentes');
  656. }
  657. $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum','BankNO', 'AccountsBank', 'IFSCNumber', 'PANNumber', 'AdhaarNumber', 'BranchBank');
  658. foreach ($data as $key => &$val) {
  659. $data[$key] = trim($val);
  660. }
  661. unset($val);
  662. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  663. ->lock('WITH(NOLOCK)')
  664. ->where('UserID', $UserID)
  665. ->first();
  666. if (!$AccountWithDrawInfo) {
  667. $data['UserID'] = $UserID;
  668. $data['Achieves'] = 0;
  669. $data['HistoryWithDraw'] = 0;
  670. try {
  671. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  672. ->where('UserID', $UserID)
  673. ->insert($data);
  674. } catch (\Exception $e) {
  675. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  676. Util::WriteLog("withdrawInfo",[6, $request->all(),$data]);
  677. }
  678. } else {
  679. $data = array_filter($data, function ($value) {
  680. return !is_null($value) && $value !== '';
  681. });
  682. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  683. ->where('UserID', $UserID)
  684. ->update($data);
  685. }
  686. // 添加绑定记录
  687. if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
  688. try {
  689. if(!DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')->where('UserID', $UserID)->exists()&&is_numeric($PixNum)) {
  690. DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  691. ->insert([
  692. 'UserID' => $UserID,
  693. 'BankCard' => $PixNum ?? '',
  694. 'BindDate' => now()
  695. ]);
  696. Util::WriteLog('update_pix', [
  697. 'UserID' => $UserID,
  698. 'BankCard' => $PixNum ?? '',
  699. 'BindDate' => now()
  700. ]);
  701. }
  702. } catch (\Exception $e) {
  703. Log::error('insert RecordBankCardBind failed', ['data' => $data]);
  704. Util::WriteLog("withdrawInfo",[7, $request->all(),$data]);
  705. }
  706. }
  707. SetNXLock::release($redisKey);
  708. return apiReturnSuc();
  709. }
  710. public function kycSimpleEU(Request $request)
  711. {
  712. // return apiReturnFail('params error');
  713. $user = $request->user();
  714. $UserID=$user->UserID;
  715. $firstName = Util::filterNickName(urldecode($request->input('firstName')));
  716. $lastName = Util::filterNickName(urldecode($request->input('lastName')));
  717. // 原始代码
  718. $BankUserName = $firstName.'|'.$lastName;
  719. $PhoneNumber = $request->input('phone');
  720. $EmailAddress = $request->input('email');
  721. Util::WriteLog("kyc_eu",$request->all());
  722. if(isset($EmailAddress)&&!empty($EmailAddress)){
  723. $validator = Validator::make(
  724. ['email' => $EmailAddress],
  725. ['email' => 'required|email']
  726. );
  727. if ($validator->fails()) {
  728. return apiReturnFail(['web.user.email_fail','Wrong email format']);
  729. }
  730. }
  731. if (!$BankUserName || $BankUserName == 'undefined') {
  732. return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
  733. }
  734. $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
  735. if (!SetNXLock::getExclusiveLock($redisKey)) {
  736. return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
  737. }
  738. if (!$UserID) {
  739. Log::info('miss UserID', $request->all());
  740. SetNXLock::release($redisKey);
  741. return apiReturnFail(['web.bank.missing_userid', 'params error']);
  742. }
  743. $data = compact('BankUserName', 'PhoneNumber', 'EmailAddress');
  744. foreach ($data as $key => &$val) {
  745. $data[$key] = trim($val);
  746. if(empty($val))unset($data[$key]);
  747. }
  748. unset($val);
  749. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  750. ->lock('WITH(NOLOCK)')
  751. ->where('UserID', $UserID)
  752. ->first();
  753. if (!$AccountWithDrawInfo) {
  754. $data['UserID'] = $UserID;
  755. $data['Achieves'] = 0;
  756. $data['HistoryWithDraw'] = 0;
  757. try {
  758. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  759. ->where('UserID', $UserID)
  760. ->insert($data);
  761. } catch (\Exception $e) {
  762. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  763. }
  764. } else {
  765. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  766. ->where('UserID', $UserID)
  767. ->update($data);
  768. }
  769. SetNXLock::release($redisKey);
  770. return apiReturnSuc();
  771. }
  772. public function withDrawInfoEU(Request $request)
  773. {
  774. // return apiReturnFail('params error');
  775. $user = $request->user();
  776. $UserID=$user->UserID;
  777. // $UserID = $request->input('UserID');
  778. // $RequestDynamicPass = $request->input('DynamicPass');
  779. $PixType = $request->input('cbPixType');
  780. $firstName = Util::filterNickName(urldecode($request->input('firstName')));
  781. $lastName = Util::filterNickName(urldecode($request->input('lastName')));
  782. // 原始代码
  783. $BankUserName = $firstName.'|'.$lastName;
  784. $BankNO = $request->input('account');
  785. $AccountsBank = $request->input('account');
  786. $PhoneNumber = $request->input('phone');
  787. $EmailAddress = $request->input('email');
  788. $IFSCNumber = $request->input('IFSCNumber');
  789. $BranchBank = $request->input('bank');//银行编号
  790. $PixNum = $request->input('account');
  791. Util::WriteLog("euwithdraw",$request->all());
  792. if(isset($EmailAddress)&&!empty($EmailAddress)){
  793. $validator = Validator::make(
  794. ['email' => $EmailAddress],
  795. ['email' => 'required|email']
  796. );
  797. if ($validator->fails()) {
  798. return apiReturnFail(['web.user.email_fail','Wrong email format']);
  799. }
  800. }
  801. if (!$AccountsBank || $AccountsBank == 'undefined') {
  802. return apiReturnFail(['web.bank.account_empty', 'The bank account cannot be empty']);
  803. }
  804. if (!(strlen($AccountsBank) == 16 || strlen($AccountsBank) == 18)) {
  805. return apiReturnFail(['web.bank.account_invalid_length', 'The bank number must have 16 or 18 digits']);
  806. }
  807. if (!(strlen($IFSCNumber) == 18 && $IFSCNumber)) {
  808. return apiReturnFail(['web.bank.clabe_invalid_length', 'The Clabe number must have 18 digits']);
  809. }
  810. if (!$BankUserName || $BankUserName == 'undefined') {
  811. return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
  812. }
  813. if (!$BranchBank || $BranchBank == 'undefined') {
  814. return apiReturnFail(['web.bank.branch_empty', 'The branch code cannot be empty']);
  815. }
  816. if (strlen($AccountsBank) == 16) {
  817. $PixType = 2;
  818. }
  819. if (strlen($AccountsBank) == 18) {
  820. $PixType = 1;
  821. }
  822. $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
  823. if (!SetNXLock::getExclusiveLock($redisKey)) {
  824. return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
  825. }
  826. if (!$UserID) {
  827. Log::info('miss UserID', $request->all());
  828. SetNXLock::release($redisKey);
  829. return apiReturnFail(['web.bank.missing_userid', 'params error']);
  830. }
  831. if (empty($PixType)) {
  832. SetNXLock::release($redisKey);
  833. return apiReturnFail(['web.bank.pix_type_missing', 'The PIX type is missing']);
  834. }
  835. // 验证PixNum绑定次数
  836. if (!empty($PixNum)) {
  837. $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  838. ->where('BankCard', $PixNum)
  839. ->lock('WITH(NOLOCK)')
  840. ->count();
  841. if ($BindCount >= 3) {
  842. SetNXLock::release($redisKey);
  843. return apiReturnFail(['web.bank.cpf_used_multiple_times', 'The CPF number has been used multiple times and cannot be saved'], [], 302);
  844. }
  845. }
  846. // 验证玩家信息
  847. if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
  848. return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  849. }
  850. if ($PixType < 10 && false) {
  851. $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum');
  852. } else {
  853. $data = compact('PixType', 'BankUserName','IFSCNumber', 'PhoneNumber', 'EmailAddress','BankNO', 'AccountsBank','BranchBank','PixNum');
  854. $PixNum = $BankNO;
  855. }
  856. foreach ($data as $key => &$val) {
  857. $data[$key] = trim($val);
  858. }
  859. unset($val);
  860. $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  861. ->lock('WITH(NOLOCK)')
  862. ->where('UserID', $UserID)
  863. ->first();
  864. if (!$AccountWithDrawInfo) {
  865. $data['UserID'] = $UserID;
  866. $data['Achieves'] = 0;
  867. $data['HistoryWithDraw'] = 0;
  868. try {
  869. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  870. ->where('UserID', $UserID)
  871. ->insert($data);
  872. } catch (\Exception $e) {
  873. Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
  874. }
  875. } else {
  876. DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  877. ->where('UserID', $UserID)
  878. ->update($data);
  879. }
  880. // 添加绑定记录
  881. if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
  882. try {
  883. DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
  884. ->insert([
  885. 'UserID' => $UserID,
  886. 'BankCard' => $PixNum ?: '',
  887. 'BindDate' => now()
  888. ]);
  889. } catch (\Exception $e) {
  890. Log::error('insert RecordBankCardBind failed', ['data' => $data]);
  891. }
  892. }
  893. SetNXLock::release($redisKey);
  894. return apiReturnSuc();
  895. }
  896. // 获取提现信息
  897. public function getWithDrawInfo(Request $request)
  898. {
  899. // $UserID = (int)$request->globalUser->UserID;//$request->input('UserID');
  900. $user = $request->user();
  901. $UserID=$user->UserID;
  902. // $paypass = $request->input('paypass');
  903. // if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
  904. // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
  905. // }
  906. $info = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
  907. ->where('UserID', $UserID)
  908. ->lock('WITH(NOLOCK)')
  909. ->first();
  910. if (!$info) { // 赋值 -- 避免客户端报错
  911. $info = [
  912. // 'BankNO' => '',
  913. // 'AccountsBank' => '',
  914. 'BankUserName' => '',
  915. // 'PhoneNumber' => '',
  916. // 'IFSCNumber' => '',
  917. 'EmailAddress' => '',
  918. // 'Achieves' => '',
  919. // 'PANNumber' => '',
  920. // 'AdhaarNumber' => '',
  921. // 'BranchBank' => '',
  922. 'PixNum' => '',
  923. 'PixType' => '',
  924. ];
  925. }
  926. $info = json_decode(json_encode($info),true);
  927. if(env('REGION_24680')=='na-mexico') {
  928. $info['bank_list'] = config('games.mex_bank_list');
  929. }else if(env('REGION_24680')=='eu-russian') {
  930. $info['bank_list'] = config('games.ru_bank_list');
  931. }
  932. // 获取绑定手机号
  933. $phone = DB::table(TableName::QPAccountsDB() . 'AccountPhone')->where('UserID', $UserID)->value('PhoneNum');
  934. if ($phone) {
  935. // 简单脱敏处理,例如:5511******88
  936. $info['bind_phone'] = substr($phone, 0, 4) . '****' . substr($phone, -2);
  937. } else {
  938. $info['bind_phone'] = '';
  939. }
  940. $AccountsInfoModel = new AccountsInfo();
  941. $total = $AccountsInfoModel->accountTotalStatistics([$UserID]);
  942. $totalRecharge= @$total[0]->Recharge ?? 0;
  943. $info['total_recharge'] = intval($totalRecharge);
  944. $info['withdraw_level'] = env('MIN_RECHARGE',20);
  945. $hasSuccessWithdraw = DB::table('QPAccountsDB.dbo.OrderWithDraw')
  946. ->lock('WITH(NOLOCK)')
  947. ->where('UserID', $UserID)
  948. ->where('State', 2)
  949. ->exists();
  950. $info['has_success_withdraw'] = $hasSuccessWithdraw;
  951. return apiReturnSuc(compact('info'));
  952. }
  953. }