|
|
@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Log;
|
|
|
*/
|
|
|
class UrsCheckWebhook extends WebhookReceiver
|
|
|
{
|
|
|
+
|
|
|
/**
|
|
|
* 构造函数
|
|
|
*
|
|
|
@@ -45,7 +46,7 @@ class UrsCheckWebhook extends WebhookReceiver
|
|
|
$this->validateCheckRequest($request);
|
|
|
|
|
|
// 处理余额检查通知
|
|
|
- return $this->processCheckNotification($request);
|
|
|
+ return $this->processCheck($request);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -56,7 +57,7 @@ class UrsCheckWebhook extends WebhookReceiver
|
|
|
*/
|
|
|
protected function validateCheckRequest(Request $request): void
|
|
|
{
|
|
|
- $requiredFields = ['user_id', 'check_type'];
|
|
|
+ $requiredFields = [ 'user_id', 'check_type' ];
|
|
|
|
|
|
foreach ($requiredFields as $field) {
|
|
|
if (!$request->has($field)) {
|
|
|
@@ -72,182 +73,19 @@ class UrsCheckWebhook extends WebhookReceiver
|
|
|
|
|
|
// 验证检查类型
|
|
|
$checkType = $request->input('check_type');
|
|
|
- if (!in_array($checkType, ['balance', 'transaction', 'status', 'limit'])) {
|
|
|
+ if (!in_array($checkType, [ 'balance', 'transaction', 'status', 'limit' ])) {
|
|
|
throw new \Exception('检查类型无效,必须是: balance, transaction, status, limit');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 处理余额检查通知
|
|
|
- *
|
|
|
- * @param Request $request 请求对象
|
|
|
- * @return array
|
|
|
- */
|
|
|
- protected function processCheckNotification(Request $request): array
|
|
|
- {
|
|
|
- $userId = $request->input('user_id');
|
|
|
- $checkType = $request->input('check_type');
|
|
|
- $requestId = $request->input('request_id', '');
|
|
|
-
|
|
|
- // 记录处理日志
|
|
|
- Log::info("URS余额检查通知处理", [
|
|
|
- 'user_id' => $userId,
|
|
|
- 'check_type' => $checkType,
|
|
|
- 'request_id' => $requestId,
|
|
|
- 'webhook_request_id' => $this->getRequestId(),
|
|
|
- ]);
|
|
|
-
|
|
|
- // 根据检查类型执行不同的处理逻辑
|
|
|
- switch ($checkType) {
|
|
|
- case 'balance':
|
|
|
- return $this->handleBalanceCheck($userId, $requestId);
|
|
|
- case 'transaction':
|
|
|
- return $this->handleTransactionCheck($userId, $requestId);
|
|
|
- case 'status':
|
|
|
- return $this->handleStatusCheck($userId, $requestId);
|
|
|
- case 'limit':
|
|
|
- return $this->handleLimitCheck($userId, $requestId);
|
|
|
- default:
|
|
|
- throw new \Exception("未知的检查类型: {$checkType}");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理余额检查
|
|
|
- *
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @param string $requestId 请求ID
|
|
|
- * @return array
|
|
|
- */
|
|
|
- protected function handleBalanceCheck(int $userId, string $requestId): array
|
|
|
- {
|
|
|
- // 这里可以调用Fund模块获取用户余额
|
|
|
- // 例如:$balance = FundService::getBalance($userId);
|
|
|
-
|
|
|
- // 模拟余额数据
|
|
|
- $balanceData = [
|
|
|
- 'total_balance' => 1000.50,
|
|
|
- 'available_balance' => 950.00,
|
|
|
- 'frozen_balance' => 50.50,
|
|
|
- 'currency' => 'CNY',
|
|
|
- ];
|
|
|
-
|
|
|
- return [
|
|
|
- 'message' => '余额检查处理完成',
|
|
|
- 'user_id' => $userId,
|
|
|
- 'request_id' => $requestId,
|
|
|
- 'check_type' => 'balance',
|
|
|
- 'data' => $balanceData,
|
|
|
- 'status' => 'success',
|
|
|
- 'processed_at' => now()->toISOString(),
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理交易记录检查
|
|
|
- *
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @param string $requestId 请求ID
|
|
|
- * @return array
|
|
|
- */
|
|
|
- protected function handleTransactionCheck(int $userId, string $requestId): array
|
|
|
+ public function processCheck()
|
|
|
{
|
|
|
- // 这里可以调用Fund模块获取用户交易记录
|
|
|
- // 例如:$transactions = FundService::getTransactions($userId);
|
|
|
-
|
|
|
- // 模拟交易数据
|
|
|
- $transactionData = [
|
|
|
- 'recent_transactions' => [
|
|
|
- [
|
|
|
- 'id' => 'TXN001',
|
|
|
- 'type' => 'deposit',
|
|
|
- 'amount' => 100.00,
|
|
|
- 'status' => 'success',
|
|
|
- 'created_at' => '2025-06-14 14:30:00',
|
|
|
- ],
|
|
|
- [
|
|
|
- 'id' => 'TXN002',
|
|
|
- 'type' => 'withdraw',
|
|
|
- 'amount' => 50.00,
|
|
|
- 'status' => 'pending',
|
|
|
- 'created_at' => '2025-06-14 15:00:00',
|
|
|
- ],
|
|
|
- ],
|
|
|
- 'total_count' => 25,
|
|
|
- ];
|
|
|
-
|
|
|
+ // 是否允许,钻石余额 ,本金总数,手续费总数,所需总数
|
|
|
+ // 调用 充值模块 来完成
|
|
|
return [
|
|
|
- 'message' => '交易记录检查处理完成',
|
|
|
- 'user_id' => $userId,
|
|
|
- 'request_id' => $requestId,
|
|
|
- 'check_type' => 'transaction',
|
|
|
- 'data' => $transactionData,
|
|
|
- 'status' => 'success',
|
|
|
- 'processed_at' => now()->toISOString(),
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理状态检查
|
|
|
- *
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @param string $requestId 请求ID
|
|
|
- * @return array
|
|
|
- */
|
|
|
- protected function handleStatusCheck(int $userId, string $requestId): array
|
|
|
- {
|
|
|
- // 这里可以调用相关模块获取用户状态
|
|
|
- // 例如:$status = UserService::getStatus($userId);
|
|
|
-
|
|
|
- // 模拟状态数据
|
|
|
- $statusData = [
|
|
|
- 'account_status' => 'active',
|
|
|
- 'kyc_status' => 'verified',
|
|
|
- 'risk_level' => 'low',
|
|
|
- 'last_login' => '2025-06-14 16:00:00',
|
|
|
+ 'check' => true,
|
|
|
];
|
|
|
|
|
|
- return [
|
|
|
- 'message' => '状态检查处理完成',
|
|
|
- 'user_id' => $userId,
|
|
|
- 'request_id' => $requestId,
|
|
|
- 'check_type' => 'status',
|
|
|
- 'data' => $statusData,
|
|
|
- 'status' => 'success',
|
|
|
- 'processed_at' => now()->toISOString(),
|
|
|
- ];
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 处理限额检查
|
|
|
- *
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @param string $requestId 请求ID
|
|
|
- * @return array
|
|
|
- */
|
|
|
- protected function handleLimitCheck(int $userId, string $requestId): array
|
|
|
- {
|
|
|
- // 这里可以调用相关模块获取用户限额信息
|
|
|
- // 例如:$limits = UserService::getLimits($userId);
|
|
|
-
|
|
|
- // 模拟限额数据
|
|
|
- $limitData = [
|
|
|
- 'daily_deposit_limit' => 10000.00,
|
|
|
- 'daily_withdraw_limit' => 5000.00,
|
|
|
- 'used_deposit_today' => 1500.00,
|
|
|
- 'used_withdraw_today' => 200.00,
|
|
|
- 'remaining_deposit' => 8500.00,
|
|
|
- 'remaining_withdraw' => 4800.00,
|
|
|
- ];
|
|
|
-
|
|
|
- return [
|
|
|
- 'message' => '限额检查处理完成',
|
|
|
- 'user_id' => $userId,
|
|
|
- 'request_id' => $requestId,
|
|
|
- 'check_type' => 'limit',
|
|
|
- 'data' => $limitData,
|
|
|
- 'status' => 'success',
|
|
|
- 'processed_at' => now()->toISOString(),
|
|
|
- ];
|
|
|
- }
|
|
|
}
|