|
@@ -479,7 +479,7 @@ class WalletService extends BaseService
|
|
|
$url = sprintf($this->apiUrls['transactions'], $address, $limit, $accountType==2? 'false': 'true', $accountType==2?'true':'false');
|
|
$url = sprintf($this->apiUrls['transactions'], $address, $limit, $accountType==2? 'false': 'true', $accountType==2?'true':'false');
|
|
|
$result = curl_get($this->config['tron_api_url'] . $url, [], $headers, 5);
|
|
$result = curl_get($this->config['tron_api_url'] . $url, [], $headers, 5);
|
|
|
$result = $result ? json_decode($result, true) : [];
|
|
$result = $result ? json_decode($result, true) : [];
|
|
|
- $datas = isset($result['data']) ? $result['data'] : [];
|
|
|
|
|
|
|
+ $datas = isset($result['data']) && is_array($result['data'])? $result['data'] : [];
|
|
|
$status = isset($result['success']) ? $result['success'] : '';
|
|
$status = isset($result['success']) ? $result['success'] : '';
|
|
|
RedisService::set("caches:wallets:listen_{$address}", ['url' => $this->config['tron_api_url'] . $url, 'result' => $result], 7200);
|
|
RedisService::set("caches:wallets:listen_{$address}", ['url' => $this->config['tron_api_url'] . $url, 'result' => $result], 7200);
|
|
|
if ($status != true || empty($datas)) {
|
|
if ($status != true || empty($datas)) {
|
|
@@ -492,6 +492,7 @@ class WalletService extends BaseService
|
|
|
$coinInMin = $coinInMin > 0 ? $coinInMin : 0;
|
|
$coinInMin = $coinInMin > 0 ? $coinInMin : 0;
|
|
|
$cacheKey = "caches:wallet:listen:{$address}_{$accountType}:";
|
|
$cacheKey = "caches:wallet:listen:{$address}_{$accountType}:";
|
|
|
$dateTime = date('Y-m-d H:i:s');
|
|
$dateTime = date('Y-m-d H:i:s');
|
|
|
|
|
+ $success = 0;
|
|
|
if ($datas) {
|
|
if ($datas) {
|
|
|
foreach ($datas as $v) {
|
|
foreach ($datas as $v) {
|
|
|
$amount = isset($v['value']) ? intval($v['value']) : 0;
|
|
$amount = isset($v['value']) ? intval($v['value']) : 0;
|
|
@@ -501,7 +502,7 @@ class WalletService extends BaseService
|
|
|
$ownerAddress = isset($v['from']) ? $v['from'] : '';
|
|
$ownerAddress = isset($v['from']) ? $v['from'] : '';
|
|
|
$toAddress = isset($v['to']) ? $v['to'] : '';
|
|
$toAddress = isset($v['to']) ? $v['to'] : '';
|
|
|
if($amount < $coinInMin) {
|
|
if($amount < $coinInMin) {
|
|
|
- echo "【{$dateTime} wallet】账户[{$ownerAddress}]到钱包[{$toAddress}]记录[{$txid}]金额较小不处理\n";
|
|
|
|
|
|
|
+ echo "【{$dateTime} wallet】账户[{$ownerAddress}]到钱包[{$toAddress}]记录[{$txid}]金额[{$amount}],金额较小不处理\n";
|
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'金额较小不处理','data'=> $v], 7200);
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'金额较小不处理','data'=> $v], 7200);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -509,8 +510,8 @@ class WalletService extends BaseService
|
|
|
// 充值处理
|
|
// 充值处理
|
|
|
if($toAddress == $address && $ownerAddress && $accountType != 2){
|
|
if($toAddress == $address && $ownerAddress && $accountType != 2){
|
|
|
if (BalanceLogModel::checkExists($txid)) {
|
|
if (BalanceLogModel::checkExists($txid)) {
|
|
|
- echo "【{$dateTime} recharge】账户[{$ownerAddress}]充值到钱包[{$address}]记录[{$txid}]金额[{$amount}]已处理\n";
|
|
|
|
|
- RedisService::set($cacheKey."{$txid}:error", ['error'=>'记录已处理','data'=> $v], 7200);
|
|
|
|
|
|
|
+ echo "【{$dateTime} recharge】账户[{$ownerAddress}]充值到钱包[{$address}]记录[{$txid}]金额[{$amount}]交易已处理过\n";
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:error", ['error'=>'交易已处理过','data'=> $v], 7200);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -524,7 +525,7 @@ class WalletService extends BaseService
|
|
|
$userId = isset($memberInfo['id'])? intval($memberInfo['id']) : 0;
|
|
$userId = isset($memberInfo['id'])? intval($memberInfo['id']) : 0;
|
|
|
if(empty($memberInfo)){
|
|
if(empty($memberInfo)){
|
|
|
echo "【{$dateTime} recharge】账户[{$ownerAddress}]充值到钱包[{$address}]记录[{$txid}]金额[{$amount}]未绑定用户\n";
|
|
echo "【{$dateTime} recharge】账户[{$ownerAddress}]充值到钱包[{$address}]记录[{$txid}]金额[{$amount}]未绑定用户\n";
|
|
|
- RedisService::set($cacheKey."{$txid}:error", ['error'=>'用户不存在','data'=> $v], 7200);
|
|
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:error", ['error'=>'未绑定用户','data'=> $v], 7200);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -639,20 +640,46 @@ class WalletService extends BaseService
|
|
|
EmailService::make()->sendUserEmail($userId, $message, $coinName.'充值到账通知',3);
|
|
EmailService::make()->sendUserEmail($userId, $message, $coinName.'充值到账通知',3);
|
|
|
RedisService::set($cacheKey."{$txid}:success", ['error'=>'处理成功','log'=>$data,'member'=> $memberInfo,'data'=> $v], 7200);
|
|
RedisService::set($cacheKey."{$txid}:success", ['error'=>'处理成功','log'=>$data,'member'=> $memberInfo,'data'=> $v], 7200);
|
|
|
echo "【{$dateTime} recharge】账户[{$ownerAddress}]充值到钱包[{$address}]记录[{$txid}]金额[{$amount}]充值成功\n";
|
|
echo "【{$dateTime} recharge】账户[{$ownerAddress}]充值到钱包[{$address}]记录[{$txid}]金额[{$amount}]充值成功\n";
|
|
|
|
|
+ RedisService::clear("caches:wallet:balanceLog:{$txid}");
|
|
|
|
|
+ $success++;
|
|
|
}
|
|
}
|
|
|
// 提现处理
|
|
// 提现处理
|
|
|
else if($ownerAddress == $address && $toAddress && $accountType == 2){
|
|
else if($ownerAddress == $address && $toAddress && $accountType == 2){
|
|
|
|
|
+ // 处理锁跳过
|
|
|
|
|
+ if(RedisService::get($cacheKey."{$txid}:lock")){
|
|
|
|
|
+ echo "【{$dateTime} withdraw】提现记录[{$txid}]金额[{$amount}]间隔时间不处理\n";
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:error", ['error'=>'间隔时间内不处理','data'=> $v], 600);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$info = BalanceLogModel::checkExists($txid);
|
|
$info = BalanceLogModel::checkExists($txid);
|
|
|
$logId = isset($info['id'])? $info['id'] : 0;
|
|
$logId = isset($info['id'])? $info['id'] : 0;
|
|
|
$userId = isset($info['user_id'])? $info['user_id'] : 0;
|
|
$userId = isset($info['user_id'])? $info['user_id'] : 0;
|
|
|
$money = isset($info['money'])? $info['money'] : 0;
|
|
$money = isset($info['money'])? $info['money'] : 0;
|
|
|
$actualMoney = isset($info['actual_money'])? $info['actual_money'] : 0;
|
|
$actualMoney = isset($info['actual_money'])? $info['actual_money'] : 0;
|
|
|
$coinType = isset($info['coin_type'])? $info['coin_type'] : 1;
|
|
$coinType = isset($info['coin_type'])? $info['coin_type'] : 1;
|
|
|
|
|
+ $payStatus = isset($info['pay_status'])? $info['pay_status'] : 0;
|
|
|
|
|
+ $status = isset($info['status'])? $info['status'] : 0;
|
|
|
$trcUrl = isset($info['trc_url'])? trim($info['trc_url']) : '';
|
|
$trcUrl = isset($info['trc_url'])? trim($info['trc_url']) : '';
|
|
|
$walletUrl = isset($info['wallet_url'])? trim($info['wallet_url']) : '';
|
|
$walletUrl = isset($info['wallet_url'])? trim($info['wallet_url']) : '';
|
|
|
if (empty($info) || $logId<=0 || $userId<=0) {
|
|
if (empty($info) || $logId<=0 || $userId<=0) {
|
|
|
- echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}]不存在\n";
|
|
|
|
|
|
|
+ echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}]提现记录不存在\n";
|
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现记录不存在','data'=> $v], 7200);
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现记录不存在','data'=> $v], 7200);
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:lock", ['error'=>'提现记录不存在','data'=> $v], rand(30,60));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($status != 2){
|
|
|
|
|
+ echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}]提现记录未审核\n";
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现记录未审核','data'=> $v], 7200);
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:lock", ['error'=>'提现记录未审核','data'=> $v], rand(30,60));
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($payStatus == 20){
|
|
|
|
|
+ echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}]提现记录已打款\n";
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现记录已打款','data'=> $v], 7200);
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:lock", ['error'=>'提现记录已打款','data'=> $v], rand(30,60));
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -666,12 +693,13 @@ class WalletService extends BaseService
|
|
|
if(abs($actualMoney - $amount) > 1){
|
|
if(abs($actualMoney - $amount) > 1){
|
|
|
echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}],提现金额与交易金额不匹配\n";
|
|
echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}],提现金额与交易金额不匹配\n";
|
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现金额与交易金额不匹配','info'=>$info,'data'=> $v], 7200);
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现金额与交易金额不匹配','info'=>$info,'data'=> $v], 7200);
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:lock", ['error'=>'提现金额与交易金额不匹配','data'=> $v], rand(30,60));
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新状态
|
|
// 更新状态
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
|
- if(!BalanceLogModel::where(['id'=> $logId])->update(['status'=> 2, 'update_time'=>time()])){
|
|
|
|
|
|
|
+ if(!BalanceLogModel::where(['id'=> $logId])->update(['pay_status'=> 20,'pay_at'=>$dateTime, 'update_time'=>time()])){
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}],提现状态更新失败\n";
|
|
echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}],提现状态更新失败\n";
|
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现状态更新失败','info'=>$info,'data'=> $v], 7200);
|
|
RedisService::set($cacheKey."{$txid}:error", ['error'=>'提现状态更新失败','info'=>$info,'data'=> $v], 7200);
|
|
@@ -712,10 +740,12 @@ class WalletService extends BaseService
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
$accounts = [1=>'USDT',2=>'星豆',3=>'C2C额度',4=>'佣金',5=>'商户余额'];
|
|
$accounts = [1=>'USDT',2=>'星豆',3=>'C2C额度',4=>'佣金',5=>'商户余额'];
|
|
|
$coinName = isset($accounts[$coinType])? $accounts[$coinType] : '余额';
|
|
$coinName = isset($accounts[$coinType])? $accounts[$coinType] : '余额';
|
|
|
- $message = "您在 {$dateTime} (UTC+8) 从星链平台{$coinName}账户提现{$amount}成功,明细如下:<br>提现账户:{$trcUrl}<br>提现数量:{$money}<br>到账:{$total} USDT<br>单号:{$orderNo}<br>交易单号:{$txid} <a href='https://tronscan.org/#/transaction/{$txid}'>查看交易详情</a>";
|
|
|
|
|
|
|
+ $message = "您在 {$dateTime} (UTC+8) 从星链平台{$coinName}账户提现{$amount}成功,明细如下:<br>提现账户:{$trcUrl}<br>提现数量:{$money}<br>到账:{$amount} USDT<br>单号:{$orderNo}<br>交易单号:{$txid} <a href='https://tronscan.org/#/transaction/{$txid}'>查看交易详情</a>";
|
|
|
EmailService::make()->sendUserEmail($userId, $message, $coinName.'提现到账通知', 3);
|
|
EmailService::make()->sendUserEmail($userId, $message, $coinName.'提现到账通知', 3);
|
|
|
- RedisService::set($cacheKey."{$txid}:success", ['error'=>'处理成功','log'=>$info,'member'=> $memberInfo,'data'=> $v], 7200);
|
|
|
|
|
|
|
+ RedisService::set($cacheKey."{$txid}:success", ['error'=>'处理成功','log'=>$log,'info'=>$info,'data'=> $v], 7200);
|
|
|
echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}],提现成功\n";
|
|
echo "【{$dateTime} withdraw】账户[{$toAddress}]从[{$address}]提现记录[{$txid}]金额[{$amount}],提现成功\n";
|
|
|
|
|
+ RedisService::clear("caches:wallet:balanceLog:{$txid}");
|
|
|
|
|
+ $success++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 处理交易记录
|
|
// 处理交易记录
|
|
@@ -736,7 +766,7 @@ class WalletService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->error = 1010;
|
|
$this->error = 1010;
|
|
|
- return $result;
|
|
|
|
|
|
|
+ return ['success'=> $success, 'total'=> count($datas)];
|
|
|
} catch (\Exception $exception) {
|
|
} catch (\Exception $exception) {
|
|
|
$message = $exception->getMessage();
|
|
$message = $exception->getMessage();
|
|
|
$this->error = $message;
|
|
$this->error = $message;
|