|
|
@@ -295,18 +295,119 @@ class ExtensionsController
|
|
|
return apiReturnFail(['web.turnplate.toofast','Requested too frequently']);
|
|
|
}
|
|
|
|
|
|
+ $exchangeScore = intval($activity->Amount ?? 0);
|
|
|
+ if ($exchangeScore < 4000) {
|
|
|
+ SetNXLock::release($redisKey);
|
|
|
+ return apiReturnFail(['web.turnplate.no_amount','No reward can be collected now']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $withdrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
|
|
|
+ ->where('UserID', $UserID)
|
|
|
+ ->first();
|
|
|
+ if (!$withdrawInfo) {
|
|
|
+ SetNXLock::release($redisKey);
|
|
|
+ return apiReturnFail(['web.turnplate.withdraw_info_missing','Please complete withdrawal info first']);
|
|
|
+ }
|
|
|
|
|
|
- DB::connection('write')->table('agent.dbo.ActivityTurnplate')->where('UserID', $UserID)->delete();
|
|
|
+// $taxRate = DB::table(TableName::QPAccountsDB() . 'SystemStatusInfo')
|
|
|
+// ->where('StatusName', 'WithDrawTax')
|
|
|
+// ->value('StatusValue') ?? 0;
|
|
|
+// $tax = (int) round($exchangeScore * intval($taxRate) / 10000);
|
|
|
+// $withDrawAmount = max($exchangeScore - $tax, 0);
|
|
|
+// $orderId = 'TP' . date('YmdHis') . strtoupper(Str::random(4));
|
|
|
|
|
|
- $insertData = json_decode(json_encode($activity),true);
|
|
|
+ $insertData = json_decode(json_encode($activity), true);
|
|
|
$insertData['updated'] = time();
|
|
|
- DB::connection('write')->table('agent.dbo.ActivityTurnplateHistory')->insert($insertData);
|
|
|
+ unset($insertData['id']);
|
|
|
+
|
|
|
+ $writeConn = DB::connection('write');
|
|
|
+ $recordTable = TableName::QPRecordDB() . 'RecordUserTotalStatistics';
|
|
|
+
|
|
|
+ $historyWithDraw = intval($withdrawInfo->HistoryWithDraw ?? 0);
|
|
|
+ $winAmount = intval($withdrawInfo->Win ?? 0);
|
|
|
+ $newHistory = max(0, $historyWithDraw - $exchangeScore);
|
|
|
+ $newWin = $winAmount + $exchangeScore;
|
|
|
+
|
|
|
+ try {
|
|
|
+ $writeConn->beginTransaction();
|
|
|
+
|
|
|
+ $writeConn->table('agent.dbo.ActivityTurnplate')
|
|
|
+ ->where('UserID', $UserID)
|
|
|
+ ->update(['State' => 2, 'Amount' => 0]);
|
|
|
+
|
|
|
+ $writeConn->table('agent.dbo.ActivityTurnplateHistory')->insert($insertData);
|
|
|
+
|
|
|
+ $writeConn->table(TableName::QPAccountsDB() . 'OrderWithDraw')->insert([
|
|
|
+ 'UserID' => $UserID,
|
|
|
+ 'AccountsBank' => $withdrawInfo->AccountsBank ?? '',
|
|
|
+ 'PhoneNumber' => $withdrawInfo->PhoneNumber ?? '',
|
|
|
+ 'IFSCNumber' => $withdrawInfo->IFSCNumber ?? '',
|
|
|
+ 'BankUserName' => $withdrawInfo->BankUserName ?? '',
|
|
|
+ 'EmailAddress' => $withdrawInfo->EmailAddress ?? '',
|
|
|
+ 'PANNumber' => $withdrawInfo->PANNumber ?? '',
|
|
|
+ 'AdhaarNumber' => $withdrawInfo->AdhaarNumber ?? '',
|
|
|
+ 'WithDraw' => $exchangeScore,
|
|
|
+ 'State' => 1,
|
|
|
+ 'AiCheckState' => 0,
|
|
|
+ 'BankNO' => $withdrawInfo->BankNO ?? '',
|
|
|
+ 'ServiceFee' => 0,
|
|
|
+ 'CreateDate' => now(),
|
|
|
+ 'BranchBank' => $withdrawInfo->BranchBank ?? '',
|
|
|
+ 'OrderId' => $activity->id,
|
|
|
+ 'PixNum' => $withdrawInfo->PixNum ?? '',
|
|
|
+ 'PixType' => $withdrawInfo->PixType ?? 0,
|
|
|
+ 'score_type' => 2
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $writeConn->table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
|
|
|
+ ->where('UserID', $UserID)
|
|
|
+ ->update([
|
|
|
+ 'HistoryWithDraw' => $newHistory,
|
|
|
+ 'Win' => $newWin,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $stats = $writeConn->table($recordTable)->where('UserID', $UserID)->first();
|
|
|
+ if ($stats) {
|
|
|
+ $writeConn->table($recordTable)
|
|
|
+ ->where('UserID', $UserID)
|
|
|
+ ->update(['DrawBase' => intval($stats->DrawBase ?? 0) + $exchangeScore]);
|
|
|
+ } else {
|
|
|
+ $writeConn->table($recordTable)
|
|
|
+ ->insert(['UserID' => $UserID, 'DrawBase' => $exchangeScore]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $writeConn->commit();
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ $writeConn->rollBack();
|
|
|
+ SetNXLock::release($redisKey);
|
|
|
+ Log::error('turnplate bonus failed', [
|
|
|
+ 'user_id' => $UserID,
|
|
|
+ 'error' => $e->getMessage()
|
|
|
+ ]);
|
|
|
+ return apiReturnFail(['web.turnplate.bonus_fail','failed'], [], 500);
|
|
|
+ }
|
|
|
+
|
|
|
+// select @AccountsBank = AccountsBank,@BankUserName = BankUserName,@Switch=Switch,
|
|
|
+// @PhoneNumber = PhoneNumber,@IFSCNumber = IFSCNumber,@EmailAddress = EmailAddress,
|
|
|
+// @PANNumber = PANNumber,@AdhaarNumber = AdhaarNumber,@BankNO = BankNO,@BranchBank = BranchBank,@PixNum=PixNum,@PixType=PixType
|
|
|
+// from QPAccountsDB.dbo.AccountWithDrawInfo where UserID = @UserID
|
|
|
+
|
|
|
+// insert into QPAccountsDB.dbo.OrderWithDraw (UserID,AccountsBank,PhoneNumber,IFSCNumber,
|
|
|
+// BankUserName,EmailAddress,PANNumber,AdhaarNumber,WithDraw,[State],AiCheckState,BankNO,ServiceFee,CreateDate,BranchBank,OrderId,PixNum,PixType)
|
|
|
+// values(@UserID,@AccountsBank,@PhoneNumber,@IFSCNumber,@BankUserName,@EmailAddress,@PANNumber,@AdhaarNumber,@ExchangeScore-@TAX,1,
|
|
|
+// 0,@BankNO,@TAX,GETDATE(),@BranchBank,@OrderId,@PixNum,@PixType)
|
|
|
+
|
|
|
+
|
|
|
+ //update QPAccountsDB.dbo.AccountWithDrawInfo set HistoryWithDraw = HistoryWithDraw-@ExchangeScore,Win=Win+@ExchangeScore where UserID = @UserID
|
|
|
+ //
|
|
|
+ // UPDATE QPRecordDB.dbo.RecordUserTotalStatistics SET DrawBase=DrawBase+@ExchangeScore WHERE UserID=@UserID
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- //领钱
|
|
|
- DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->increment('Score', 4000);
|
|
|
|
|
|
SetNXLock::release($redisKey);
|
|
|
- return apiReturnSuc(['bonus' => 10000]);
|
|
|
+ return apiReturnSuc(['Amount' => 0]);
|
|
|
}
|
|
|
|
|
|
|