| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997 |
- <?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 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{
- if(!$PhoneNumber||strlen($PhoneNumber)!=11){
- return apiReturnFail(['withdraw.account.tip.phone_error', '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) {
- $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'));
- }
- }
|