| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055 |
- <?php
- namespace App\Http\Controllers\Game;
- use App\Facade\TableName;
- use App\Game\GlobalUserInfo;
- use App\Http\helper\NumConfig;
- use App\Models\AccountsInfo;
- use App\Models\Treasure\GameScoreLocker;
- use App\Notification\TelegramBot;
- use App\Util;
- use App\Utility\SetNXLock;
- use GuzzleHttp\Client;
- use GuzzleHttp\Exception\RequestException;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Hash;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Validator;
- class WithDrawInfoController
- {
- public function FreeWithDrawInfo(Request $request)
- {
- $user = $request->user();
- $userScoreData = GlobalUserInfo::getScoreDataByUserID($user->UserID);
- if(!$userScoreData['Recharge']){
- $totalWithdraw = max($userScoreData['InsureScore'],40);
- if($userScoreData['InsureScore']<40){
- //第一种状态,我免费领了10块钱,但是金额不足40,点进去页面填信息后点击提现,提示我去玩游戏
- return apiReturnSuc(['state' => 1, 'total' => $totalWithdraw,'InsureScore' => $userScoreData['InsureScore']]);
- }else{
- //第二种状态,我免费金额足够40,提现按钮会点亮,告知用户点击进去
- return apiReturnSuc(['state' => 2, 'total' => $totalWithdraw,'InsureScore' => $userScoreData['InsureScore']]);
- }
- }else{
- //第四种状态,VIP状态下,金额不足了,进度条颜色红色,按钮灰色(不可点击),次日整个消失
- if($userScoreData['InsureScore']<10){
- return apiReturnSuc(['state' => 4, 'total' => max($userScoreData['InsureScore'],40),'InsureScore' => max($userScoreData['InsureScore'],40)]);
- }else{
- //第三种状态,进去完成了充值未提现,提现按钮会高光,引导用户完成提现
- return apiReturnSuc(['state' => 3, 'total' => max($userScoreData['InsureScore'],40),'InsureScore' => max($userScoreData['InsureScore'],40)]);
- }
- }
- }
- public function WithDrawRecord(Request $request)
- {
- $user = $request->user();
- $UserID=$user->UserID;
- // $paypass = $request->input('paypass');
- // if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
- // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
- // }
- $list=DB::table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('UserID', $UserID)
- ->selectRaw("CreateDate,OrderId,[State],WithDraw,ServiceFee,PixType")
- ->paginate(10);
- return apiReturnSuc($list);
- }
- public function GetWithDrawBaseInfo(Request $request)
- {
- $user = $request->user();
- $UserID=$user->UserID;
- // $paypass = $request->input('paypass');
- //
- // if (empty($user->InsurePass)||!Hash::check($paypass,$user->InsurePass)) {
- // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
- // }
- $dbh = DB::connection()->getPdo();
- $sql="DECLARE @return_value int
- set nocount on use QPAccountsDB
- EXEC @return_value = GSP_GR_GetWithDrawBaseInfo '$UserID'
- SELECT 'ReturnValue' = @return_value";
- // echo $sql;die;
- $stmt = $dbh->prepare($sql);
- $stmt->execute();
- $retval = $stmt->fetch(\PDO::FETCH_ASSOC);
- $retval['srate']=env('CONFIG_24680_RATE',1);
- return apiReturnSuc($retval);
- }
- public function GoWithDraw(Request $request)
- {
- $user = $request->user();
- $UserID=$user->UserID;
- // $paypass = $request->input('paypass');
- //
- // if (empty($user->InsurePass)||!Hash::check($paypass,$user->InsurePass)) {
- // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
- // }
- $score=$request->input('score',0);
- if(!$score||is_float($score)||$score<=0){
- return apiReturnFail(['web.withdraw.score_fail', 'Amount must be an integer value.']);
- }
- $redisKey = 'withdraw_'.$UserID;
- if (!SetNXLock::getExclusiveLock($redisKey)) {
- return apiReturnFail(['web.withdraw.try_again_later','Tente novamente mais tarde']);
- }
- GameScoreLocker::where('UserID',$UserID)->delete();
- $dbh = DB::connection()->getPdo();
- // $score=$score*NumConfig::NUM_VALUE;
- $sql="DECLARE @return_value int
- set nocount on use QPAccountsDB
- EXEC @return_value = GSP_GR_GetWithDraw '$UserID','$score'
- SELECT 'ReturnValue' = @return_value";
- // echo $sql;die;
- $stmt = $dbh->prepare($sql);
- $stmt->execute();
- SetNXLock::release($redisKey);
- $retval = $stmt->fetch(\PDO::FETCH_ASSOC);
- try {
- // set @ret = 1 --可提额度不足
- // set @ret = 2 --低于最低可提现金额
- // set @ret = 3 --高于最高可提现金额
- // set @ret = 4 --超过每天提现次数上限
- // set @ret = 5 --身上钱不够
- // set @ret = 6 --开在游戏里面
- // set @ret = 7 --未充值的用户TX额度
- if (isset($retval['ReturnValue'])) {
- $ReturnValue = $retval['ReturnValue'];
- // set @ret = 1 -- Insufficient withdrawal amount
- // set @ret = 2 -- Lower than the minimum withdrawal amount
- // set @ret = 3 -- Higher than the maximum withdrawal amount
- // set @ret = 4 -- Exceeded the daily withdrawal limit
- // set @ret = 5 -- Not enough money on hand
- // set @ret = 6 -- Opened in the game
- // set @ret = 7 -- Undeposited user TX amount
- $errors = [
- [],
- ['web.withdraw.no_withdraw_value', "The withdrawable amount is not enough"],
- ['web.withdraw.too_low', 'Lower than the minimum withdrawal amount'],
- ['web.withdraw.too_high', 'Higher than the maximum withdrawal amount'],
- ['web.withdraw.day_max', 'Exceeded the daily withdrawal limit'],
- ['web.withdraw.no_enouth_score', 'Not enough money on hand'],
- ['web.withdraw.in_game', 'Sorry, You\'re in game for now'],
- ['web.withdraw.no_deposit', ' You need deposit first!'],
- ];
- return apiReturnFail($errors[$ReturnValue], [], $ReturnValue == 7 ? 777 : 301);
- }else{
- return apiReturnSuc($retval);
- }
- }catch (\Exception $e){
- TelegramBot::getDefault()->sendProgramNotify("WithDraw Error:", var_export($retval,true).':'.$e->getTraceAsString());
- return apiReturnSuc($retval);
- }
- }
- public function saveCpf(Request $request)
- {
- // $user = $request->user();
- // $UserID=$user->UserID;
- //
- // $account = $request->Account ?: '';
- // $phone = $request->Phone ?: '';
- // $email = $request->Email ?: '';
- // $PixNum = $request->PixNum ?: '';
- //
- // if(!Util::validateCpf($PixNum)){
- // return apiReturnFail(['withdraw.account.tip.cpf_error','Cpf error format']);
- // }
- //
- // $redisKey = 'Api_updateAccountsPayInfo_'.$UserID;
- // $lock = SetNXLock::getExclusiveLock($redisKey);
- // if (!$lock) {
- // return apiReturnFail(['web.withdraw.try_again_later','Tente novamente mais tarde']);
- // }
- // $exist = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')->where('UserID', $UserID)->first();
- //
- // if ($exist) {
- // DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')->where('UserID', $UserID)->update(['PixNum' => $PixNum]);
- // } else {
- //
- // $data = ['BankUserName' => $account, 'PhoneNumber' => $phone, 'EmailAddress' => $email, 'UserID' => $UserID, 'PixNum' => $PixNum, 'Achieves' => '', 'HistoryWithDraw' => 0];
- // DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- // ->insert($data);
- // }
- // SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- public function MexWithDrawInfo(Request $request)
- {
- $user = $request->user();
- $UserID=$user->UserID;
- $paypass = $request->input('paypass');
- $PixType = $request->input('cbPixType');;
- $BankNO = $request->input('account');
- $AccountsBank = $request->input('account');
- $BankUserName = $request->input('userName');
- $PhoneNumber = $request->input('phone');
- $EmailAddress = $request->input('email');
- $IFSCNumber = $request->input('IFSCNumber');
- // $PANNumber = $request->input('PAN');
- // $AdhaarNumber = $request->input('adhaar');
- // $BranchBank = $request->input('branceBank');
- $BranchBank = $request->input('bank');//银行编号
- $PixNum = $request->input('account');
- Util::WriteLog("mexwithdraw",$request->all());
- if(isset($EmailAddress)&&!empty($EmailAddress)){
- $validator = Validator::make(
- ['email' => $EmailAddress],
- ['email' => 'required|email']
- );
- if ($validator->fails()) {
- return apiReturnFail(['web.user.email_fail','Wrong email format']);
- }
- }
- if (!$AccountsBank || $AccountsBank == 'undefined') {
- return apiReturnFail(['web.bank.account_empty', 'The bank account cannot be empty']);
- }
- if (!(strlen($AccountsBank) == 16 || strlen($AccountsBank) == 18)) {
- return apiReturnFail(['web.bank.account_invalid_length', 'The bank number must have 16 or 18 digits']);
- }
- if (!(strlen($IFSCNumber) == 18 && $IFSCNumber)) {
- return apiReturnFail(['web.bank.clabe_invalid_length', 'The Clabe number must have 18 digits']);
- }
- if (!$BankUserName || $BankUserName == 'undefined') {
- return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
- }
- if (!$BranchBank || $BranchBank == 'undefined') {
- return apiReturnFail(['web.bank.branch_empty', 'The branch code cannot be empty']);
- }
- if (strlen($AccountsBank) == 16) {
- $PixType = 2;
- }
- if (strlen($AccountsBank) == 18) {
- $PixType = 1;
- }
- $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
- if (!SetNXLock::getExclusiveLock($redisKey)) {
- return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
- }
- if (!$UserID) {
- Log::info('miss UserID', $request->all());
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.missing_userid', 'params error']);
- }
- if (empty($PixType)) {
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.pix_type_missing', 'The PIX type is missing']);
- }
- // 验证PixNum绑定次数
- if (!empty($PixNum)) {
- $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->where('BankCard', $PixNum)
- ->lock('WITH(NOLOCK)')
- ->count();
- if ($BindCount >= 3) {
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.cpf_used_multiple_times', 'The CPF number has been used multiple times and cannot be saved'], [], 302);
- }
- }
- // 验证玩家信息
- if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
- return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
- }
- if ($PixType < 10 && false) {
- $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum');
- } else {
- $data = compact('PixType', 'BankUserName','IFSCNumber', 'PhoneNumber', 'EmailAddress','BankNO', 'AccountsBank','BranchBank','PixNum');
- $PixNum = $BankNO;
- }
- foreach ($data as $key => &$val) {
- $data[$key] = trim($val);
- }
- unset($val);
- $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->lock('WITH(NOLOCK)')
- ->where('UserID', $UserID)
- ->first();
- if (!$AccountWithDrawInfo) {
- $data['UserID'] = $UserID;
- $data['Achieves'] = 0;
- $data['HistoryWithDraw'] = 0;
- try {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->insert($data);
- } catch (\Exception $e) {
- Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
- }
- } else {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->update($data);
- }
- // 添加绑定记录
- if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
- try {
- DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->insert([
- 'UserID' => $UserID,
- 'BankCard' => $PixNum ?: '',
- 'BindDate' => now()
- ]);
- } catch (\Exception $e) {
- Log::error('insert RecordBankCardBind failed', ['data' => $data]);
- }
- }
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- public function RuWithDrawInfo(Request $request)
- {
- $user = $request->user();
- $UserID=$user->UserID;
- $paypass = $request->input('paypass');
- $PixType = $request->input('PixType');;
- $BankNO = $request->input('account');
- $BankUserName = $request->input('userName');
- $PhoneNumber = $request->input('phone');
- // $EmailAddress = $request->input('email');
- // $IFSCNumber = $request->input('IFSCNumber');
- // $PANNumber = $request->input('PAN');
- // $AdhaarNumber = $request->input('adhaar');
- // $BranchBank = $request->input('branceBank');
- $BranchBank = $request->input('bank');//银行编号
- $PixNum = $BankNO;
- $AccountsBank = $BankNO;
- Util::WriteLog("ruwithdraw",$request->all());
- if (!$BankUserName || $BankUserName == 'undefined') {
- return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
- }
- if($PixType==1) {
- if (!$AccountsBank || $AccountsBank == 'undefined') {
- return apiReturnFail(['web.bank.account_empty', 'The bank account cannot be empty']);
- }
- if (!(strlen($AccountsBank) == 16 )) {
- return apiReturnFail(['web.bank.account_invalid_length', 'The bank number must have 16 digits']);
- }
- // if (!(strlen($IFSCNumber) == 11 && $IFSCNumber)) {
- // return apiReturnFail(['web.bank.clabe_invalid_length', 'The Clabe number must have 18 digits']);
- // }
- }else{
- // 墨西哥 +52 手机号 10 位(可带区号总长 12 位);其他地区 11 位
- $digits = preg_replace('/\D/', '', $PhoneNumber ?? '');
- $isMexico = (env('COUNTRY_CODE', '52') === '52');
- $valid = $isMexico
- ? (strlen($digits) === 10 || strlen($digits) === 12)
- : (strlen($digits) === 11);
- if (!$PhoneNumber || !$valid) {
- return apiReturnFail(['withdraw.account.tip.phone_error', $isMexico ? 'The phone number must be 10 digits (Mexico)' : 'The phone number is error']);
- }
- if (!$BranchBank || $BranchBank == 'undefined') {
- return apiReturnFail(['web.bank.branch_empty', 'The branch code cannot be empty']);
- }
- }
- $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
- if (!SetNXLock::getExclusiveLock($redisKey)) {
- return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
- }
- if (!$UserID) {
- Log::info('miss UserID', $request->all());
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.missing_userid', 'params error']);
- }
- if (empty($PixType)) {
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.pix_type_missing', 'The PIX type is missing']);
- }
- // 验证PixNum绑定次数
- if (!empty($PixNum)) {
- $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->where('BankCard', $PixNum)
- ->lock('WITH(NOLOCK)')
- ->count();
- if ($BindCount >= 3) {
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.cpf_used_multiple_times', 'The CPF number has been used multiple times and cannot be saved'], [], 302);
- }
- }
- // 验证玩家信息
- if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
- return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
- }
- $data = compact('PixType', 'BankUserName', 'PhoneNumber','BankNO', 'AccountsBank','BranchBank','PixNum');
- $PixNum = $BankNO;
- foreach ($data as $key => &$val) {
- $data[$key] = trim($val);
- }
- unset($val);
- $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->lock('WITH(NOLOCK)')
- ->where('UserID', $UserID)
- ->first();
- if (!$AccountWithDrawInfo) {
- $data['UserID'] = $UserID;
- $data['Achieves'] = 0;
- $data['HistoryWithDraw'] = 0;
- try {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->insert($data);
- } catch (\Exception $e) {
- Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
- }
- } else {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->update($data);
- }
- // 添加绑定记录
- if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
- try {
- DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->insert([
- 'UserID' => $UserID,
- 'BankCard' => $PixNum ?: '',
- 'BindDate' => now()
- ]);
- } catch (\Exception $e) {
- Log::error('insert RecordBankCardBind failed', ['data' => $data]);
- }
- }
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- public function withDrawInfo(Request $request)
- {
- // return apiReturnFail('params error');
- $user = $request->user();
- $UserID=$user->UserID;
- // $UserID = (int)$request->globalUser->UserID;//$request->input('UserID');
- // $RequestDynamicPass = $request->input('DynamicPass');
- $PixType = $request->input('cbPixType');
- $BankUserName = urldecode($request->input('userName'));
- $EmailAddress = $request->input('email');
- $PixNum = $request->input('PixNum');
- if(!empty($EmailAddress))$EmailAddress=Util::cleanEmptyString($EmailAddress);
- if(!empty($PixNum))$PixNum=Util::cleanEmptyString($PixNum);
- if (!empty($EmailAddress)&&!Util::validateEmail($EmailAddress)) {
- return apiReturnFail(['web.user.email_fail','Wrong email format']);
- }
- $redisKey = 'withDrawInfo_withDrawInfo_'.$UserID;
- if (!SetNXLock::getExclusiveLock($redisKey)) {
- Util::WriteLog("withdrawInfo",[1, $request->all()]);
- return apiReturnFail(['web.withdraw.try_again_later','Tente novamente mais tarde']);
- }
- if (!$UserID) {
- Util::WriteLog("withdrawInfo",[2, $request->all()]);
- Log::info('miss UserID', $request->all());
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.withdraw.params_error','params error']);
- }
- if (empty($PixType)) {
- Util::WriteLog("withdrawInfo",[3, $request->all()]);
- SetNXLock::release($redisKey);
- return apiReturnFail(["web.withdraw.pix_type_missing",'O tipo PIX está ausente']);
- }
- // 验证PixNum绑定次数
- // if (!empty($PixNum)) {
- // $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- // ->where('BankCard', $PixNum)
- // ->lock('WITH(NOLOCK)')
- // ->count();
- // if ($BindCount >= 6) {
- // Util::WriteLog("withdrawInfo",[4, $request->all()]);
- // SetNXLock::release($redisKey);
- // return apiReturnFail(['web.withdraw.cpf_number_used','O número do CPF foi usado várias vezes e não pode ser salvo'], [], 302);
- // }
- // }
- if ($PixType==1) {
- // 验证 cashapp
- if (!empty($PixNum)) {
- // 如果 PixNum 第一个字符不是 "$",则在前面添加 "$"
- if (substr($PixNum, 0, 1) !== '$') {
- $PixNum = '$' . $PixNum;
- }
-
- // 构建 cash.app URL
- $cashAppUrl = 'https://cash.app/' . $PixNum;
-
- try {
- // 使用 stream context 来获取 HTTP 响应头
- $context = stream_context_create([
- 'http' => [
- 'method' => 'GET',
- 'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36\r\n",
- 'ignore_errors' => true
- ]
- ]);
-
- $htmlContent = @file_get_contents($cashAppUrl, false, $context);
-
- // 检查 HTTP 响应头中的状态码
- if ($htmlContent === false || (isset($http_response_header) && preg_match('/HTTP\/\d\.\d\s+404/', implode("\n", $http_response_header)))) {
- Util::WriteLog("withdrawInfo", [5, $request->all(), 'Invalid cashapp: ' . $PixNum]);
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.withdraw.invalid_cashapp', 'Invalid CashApp account']);
- }
-
- if ($htmlContent !== false) {
- // 去除空格换行,转换成一行字符串
- $htmlContent = preg_replace('/\s+/', '', $htmlContent);
- Util::WriteLog("withdrawInfo", [5, $request->all(), 'CashApp verification response: ' . $htmlContent]);
-
- // 检查响应内容中是否包含 "404 Not Found"
- if (stripos($htmlContent, '404NotFound') !== false) {
- Util::WriteLog("withdrawInfo", [5, $request->all(), 'Invalid cashapp: ' . $PixNum]);
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.withdraw.invalid_cashapp', 'Invalid CashApp account']);
- }
- }
- } catch (\Exception $e) {
- // 其他异常也记录日志但不阻止流程
- Util::WriteLog("withdrawInfo", [5, $request->all(), 'CashApp verification error: ' . $e->getMessage()]);
- }
- }
-
- $data = compact('PixType', 'BankUserName', 'PixNum');
-
- } else {
- $data = compact('PixType', 'EmailAddress');
- }
- foreach ($data as $key => &$val) {
- $data[$key] = trim($val);
- }
- unset($val);
- $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->lock('WITH(NOLOCK)')
- ->where('UserID', $UserID)
- ->first();
- if (!$AccountWithDrawInfo) {
- $data['UserID'] = $UserID;
- $data['Achieves'] = 0;
- $data['HistoryWithDraw'] = 0;
- try {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->insert($data);
- } catch (\Exception $e) {
- Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
- Util::WriteLog("withdrawInfo",[6, $request->all(),$data]);
- }
- } else {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->update($data);
- }
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- public function withDrawInfoSA(Request $request)
- {
- // return apiReturnFail('params error');
- $UserID = $request->input('UserID');
- $RequestDynamicPass = $request->input('DynamicPass');
- $PixType = $request->input('cbPixType');
- $BankNO = $request->input('bank');
- $AccountsBank = urldecode($request->input('account'));
- $BankUserName = urldecode($request->input('userName'));
- // 原始代码
- $BankUserName = Util::filterNickName($BankUserName);
- // 新增处理:在大写字母前加空格
- $BankUserName = preg_replace('/(?<!^)([A-Z])/', ' $1', $BankUserName);
- $PhoneNumber = $request->input('phone');
- $EmailAddress = $request->input('email');
- $IFSCNumber = $request->input('IFSC');
- $PANNumber = $request->input('PAN');
- $AdhaarNumber = $request->input('adhaar');
- $BranchBank = $request->input('branceBank');
- $PixNum = $request->input('PixNum');
- $redisKey = 'withDrawInfo_withDrawInfo_'.$UserID;
- if (!SetNXLock::getExclusiveLock($redisKey)) {
- Util::WriteLog("withdrawInfo",[1, $request->all()]);
- return apiReturnFail('Tente novamente mais tarde');
- }
- if (!$UserID) {
- Util::WriteLog("withdrawInfo",[2, $request->all()]);
- Log::info('miss UserID', $request->all());
- SetNXLock::release($redisKey);
- return apiReturnFail('params error');
- }
- if (empty($PixType)) {
- Util::WriteLog("withdrawInfo",[3, $request->all()]);
- SetNXLock::release($redisKey);
- return apiReturnFail('O tipo PIX está ausente');
- }
- // Util::validateSouthAmericanPhone('',)
- // 验证PixNum绑定次数
- if (!empty($PixNum)) {
- $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->where('BankCard', $PixNum)
- ->lock('WITH(NOLOCK)')
- ->count();
- if ($BindCount >= 8) {
- Util::WriteLog("withdrawInfo",[4, $request->all()]);
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.withdraw.cpf_number_used','The CPF number has been used several times and cannot be saved'], [], 302);
- }
- }
- // if(!is_numeric($PixNum)){
- // return apiReturnFail(['web.withdraw.pix_failed','The CPF number has been used several times and cannot be saved'], [], 302);
- // }
- // 验证玩家信息
- $DynamicPass = DB::table(TableName::QPAccountsDB() . 'AccountsInfo')
- ->where('UserID', $UserID)
- ->lock('WITH(NOLOCK)')
- ->value('DynamicPass');
- if ($DynamicPass != $RequestDynamicPass || empty($DynamicPass)) {
- SetNXLock::release($redisKey);
- Util::WriteLog("withdrawInfo",[5, $request->all()]);
- return apiReturnFail('As informações do jogador são inconsistentes');
- }
- $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum','BankNO', 'AccountsBank', 'IFSCNumber', 'PANNumber', 'AdhaarNumber', 'BranchBank');
- foreach ($data as $key => &$val) {
- $data[$key] = trim($val);
- }
- unset($val);
- $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->lock('WITH(NOLOCK)')
- ->where('UserID', $UserID)
- ->first();
- if (!$AccountWithDrawInfo) {
- $data['UserID'] = $UserID;
- $data['Achieves'] = 0;
- $data['HistoryWithDraw'] = 0;
- try {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->insert($data);
- } catch (\Exception $e) {
- Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
- Util::WriteLog("withdrawInfo",[6, $request->all(),$data]);
- }
- } else {
- $data = array_filter($data, function ($value) {
- return !is_null($value) && $value !== '';
- });
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->update($data);
- }
- // 添加绑定记录
- if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
- try {
- if(!DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')->where('UserID', $UserID)->exists()&&is_numeric($PixNum)) {
- DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->insert([
- 'UserID' => $UserID,
- 'BankCard' => $PixNum ?? '',
- 'BindDate' => now()
- ]);
- Util::WriteLog('update_pix', [
- 'UserID' => $UserID,
- 'BankCard' => $PixNum ?? '',
- 'BindDate' => now()
- ]);
- }
- } catch (\Exception $e) {
- Log::error('insert RecordBankCardBind failed', ['data' => $data]);
- Util::WriteLog("withdrawInfo",[7, $request->all(),$data]);
- }
- }
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- public function kycSimpleEU(Request $request)
- {
- // return apiReturnFail('params error');
- $user = $request->user();
- $UserID=$user->UserID;
- $firstName = Util::filterNickName(urldecode($request->input('firstName')));
- $lastName = Util::filterNickName(urldecode($request->input('lastName')));
- // 原始代码
- $BankUserName = $firstName.'|'.$lastName;
- $PhoneNumber = $request->input('phone');
- $EmailAddress = $request->input('email');
- Util::WriteLog("kyc_eu",$request->all());
- if(isset($EmailAddress)&&!empty($EmailAddress)){
- $validator = Validator::make(
- ['email' => $EmailAddress],
- ['email' => 'required|email']
- );
- if ($validator->fails()) {
- return apiReturnFail(['web.user.email_fail','Wrong email format']);
- }
- }
- if (!$BankUserName || $BankUserName == 'undefined') {
- return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
- }
- $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
- if (!SetNXLock::getExclusiveLock($redisKey)) {
- return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
- }
- if (!$UserID) {
- Log::info('miss UserID', $request->all());
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.missing_userid', 'params error']);
- }
- $data = compact('BankUserName', 'PhoneNumber', 'EmailAddress');
- foreach ($data as $key => &$val) {
- $data[$key] = trim($val);
- if(empty($val))unset($data[$key]);
- }
- unset($val);
- $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->lock('WITH(NOLOCK)')
- ->where('UserID', $UserID)
- ->first();
- if (!$AccountWithDrawInfo) {
- $data['UserID'] = $UserID;
- $data['Achieves'] = 0;
- $data['HistoryWithDraw'] = 0;
- try {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->insert($data);
- } catch (\Exception $e) {
- Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
- }
- } else {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->update($data);
- }
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- public function withDrawInfoEU(Request $request)
- {
- // return apiReturnFail('params error');
- $user = $request->user();
- $UserID=$user->UserID;
- // $UserID = $request->input('UserID');
- // $RequestDynamicPass = $request->input('DynamicPass');
- $PixType = $request->input('cbPixType');
- $firstName = Util::filterNickName(urldecode($request->input('firstName')));
- $lastName = Util::filterNickName(urldecode($request->input('lastName')));
- // 原始代码
- $BankUserName = $firstName.'|'.$lastName;
- $BankNO = $request->input('account');
- $AccountsBank = $request->input('account');
- $PhoneNumber = $request->input('phone');
- $EmailAddress = $request->input('email');
- $IFSCNumber = $request->input('IFSCNumber');
- $BranchBank = $request->input('bank');//银行编号
- $PixNum = $request->input('account');
- Util::WriteLog("euwithdraw",$request->all());
- if(isset($EmailAddress)&&!empty($EmailAddress)){
- $validator = Validator::make(
- ['email' => $EmailAddress],
- ['email' => 'required|email']
- );
- if ($validator->fails()) {
- return apiReturnFail(['web.user.email_fail','Wrong email format']);
- }
- }
- if (!$AccountsBank || $AccountsBank == 'undefined') {
- return apiReturnFail(['web.bank.account_empty', 'The bank account cannot be empty']);
- }
- if (!(strlen($AccountsBank) == 16 || strlen($AccountsBank) == 18)) {
- return apiReturnFail(['web.bank.account_invalid_length', 'The bank number must have 16 or 18 digits']);
- }
- if (!(strlen($IFSCNumber) == 18 && $IFSCNumber)) {
- return apiReturnFail(['web.bank.clabe_invalid_length', 'The Clabe number must have 18 digits']);
- }
- if (!$BankUserName || $BankUserName == 'undefined') {
- return apiReturnFail(['web.bank.username_empty', 'The name cannot be empty']);
- }
- if (!$BranchBank || $BranchBank == 'undefined') {
- return apiReturnFail(['web.bank.branch_empty', 'The branch code cannot be empty']);
- }
- if (strlen($AccountsBank) == 16) {
- $PixType = 2;
- }
- if (strlen($AccountsBank) == 18) {
- $PixType = 1;
- }
- $redisKey = 'withDrawInfo_withDrawInfo_' . $UserID;
- if (!SetNXLock::getExclusiveLock($redisKey)) {
- return apiReturnFail(['web.bank.try_again_later', 'Please try again later']);
- }
- if (!$UserID) {
- Log::info('miss UserID', $request->all());
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.missing_userid', 'params error']);
- }
- if (empty($PixType)) {
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.pix_type_missing', 'The PIX type is missing']);
- }
- // 验证PixNum绑定次数
- if (!empty($PixNum)) {
- $BindCount = DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->where('BankCard', $PixNum)
- ->lock('WITH(NOLOCK)')
- ->count();
- if ($BindCount >= 3) {
- SetNXLock::release($redisKey);
- return apiReturnFail(['web.bank.cpf_used_multiple_times', 'The CPF number has been used multiple times and cannot be saved'], [], 302);
- }
- }
- // 验证玩家信息
- if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
- return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
- }
- if ($PixType < 10 && false) {
- $data = compact('PixType', 'BankUserName', 'PhoneNumber', 'EmailAddress', 'PixNum');
- } else {
- $data = compact('PixType', 'BankUserName','IFSCNumber', 'PhoneNumber', 'EmailAddress','BankNO', 'AccountsBank','BranchBank','PixNum');
- $PixNum = $BankNO;
- }
- foreach ($data as $key => &$val) {
- $data[$key] = trim($val);
- }
- unset($val);
- $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->lock('WITH(NOLOCK)')
- ->where('UserID', $UserID)
- ->first();
- if (!$AccountWithDrawInfo) {
- $data['UserID'] = $UserID;
- $data['Achieves'] = 0;
- $data['HistoryWithDraw'] = 0;
- try {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->insert($data);
- } catch (\Exception $e) {
- Log::error('insert AccountWithDrawInfo failed', ['data' => $data]);
- }
- } else {
- DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->update($data);
- }
- // 添加绑定记录
- if (empty($AccountWithDrawInfo->PixNum) || $AccountWithDrawInfo->PixNum != $PixNum) {
- try {
- DB::table(TableName::QPRecordDB() . 'RecordBankCardBind')
- ->insert([
- 'UserID' => $UserID,
- 'BankCard' => $PixNum ?: '',
- 'BindDate' => now()
- ]);
- } catch (\Exception $e) {
- Log::error('insert RecordBankCardBind failed', ['data' => $data]);
- }
- }
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- // 获取提现信息
- public function getWithDrawInfo(Request $request)
- {
- // $UserID = (int)$request->globalUser->UserID;//$request->input('UserID');
- $user = $request->user();
- $UserID=$user->UserID;
- // $paypass = $request->input('paypass');
- // if (!empty($user->InsurePass)&&!Hash::check($paypass,$user->InsurePass)) {
- // return apiReturnFail(['web.user.paypass_fail', 'A senha original está errada, digite-a novamente.'], '', 2);
- // }
- $info = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
- ->where('UserID', $UserID)
- ->lock('WITH(NOLOCK)')
- ->first();
- if (!$info) { // 赋值 -- 避免客户端报错
- $info = [
- // 'BankNO' => '',
- // 'AccountsBank' => '',
- 'BankUserName' => '',
- // 'PhoneNumber' => '',
- // 'IFSCNumber' => '',
- 'EmailAddress' => '',
- // 'Achieves' => '',
- // 'PANNumber' => '',
- // 'AdhaarNumber' => '',
- // 'BranchBank' => '',
- 'PixNum' => '',
- 'PixType' => '',
- ];
- }
- $info = json_decode(json_encode($info),true);
- if(env('REGION_24680')=='na-mexico') {
- $info['bank_list'] = config('games.mex_bank_list');
- }else if(env('REGION_24680')=='eu-russian') {
- $info['bank_list'] = config('games.ru_bank_list');
- }
- $AccountsInfoModel = new AccountsInfo();
- $total = $AccountsInfoModel->accountTotalStatistics([$UserID]);
- $totalRecharge= @$total[0]->Recharge ?? 0;
- $info['total_recharge'] = intval($totalRecharge);
- $info['withdraw_level'] = env('MIN_RECHARGE',20);
- return apiReturnSuc(compact('info'));
- }
- }
|