瀏覽代碼

Weenier 168otc项目部署 0630

wesmiler 3 年之前
父節點
當前提交
f0936b4041
共有 2 個文件被更改,包括 18 次插入11 次删除
  1. 4 2
      app/Services/Common/CoinLogService.php
  2. 14 9
      app/Services/UsdtWalletService.php

+ 4 - 2
app/Services/Common/CoinLogService.php

@@ -473,7 +473,8 @@ class CoinLogService extends BaseService
                 }
 
                 // 更新订单状态
-                if(!$this->model->where(['id'=> $id])->update(['txid'=> $result['txID'],'status'=> 4,'update_time'=>time()])){
+                $txid = isset($result['txID'])? $result['txID'] :'';
+                if(!$this->model->where(['id'=> $id])->update(['txid'=> $txid,'status'=> 4,'update_time'=>time()])){
                     $this->model->rollBack();
                     $this->error = '5002';
                     return false;
@@ -504,7 +505,8 @@ class CoinLogService extends BaseService
                     return false;
                 }
 
-                if(!$this->model->where(['id'=> $id])->update(['status'=> 4,'update_time'=>time()])){
+                $txid = isset($result['txid'])? $result['txid'] :'';
+                if(!$this->model->where(['id'=> $id])->update(['txid'=> $txid,'status'=> 4,'update_time'=>time()])){
                     $this->model->rollBack();
                     $this->error = '5002';
                     return false;

+ 14 - 9
app/Services/UsdtWalletService.php

@@ -177,7 +177,7 @@ class UsdtWalletService extends BaseService
         $trxWallet = new TRC20($api, ['contract_address' => $this->config['tron_contract_address'], 'decimals' => 6]);
 
         // 获取钱包参数
-//        try {
+        try {
 
             // 用出账钱包转账
             $otcAddress = $from ? $from : ConfigService::make()->getConfigByCode('trc_out_address');
@@ -199,14 +199,19 @@ class UsdtWalletService extends BaseService
             $from = new \Tron\Address($otcAddress['base58'], $otcAddressPrivate, $otcAddress['hex']);
             $to = new \Tron\Address($toAddress['base58'], '', $toAddress['hex']);
             $result = $trxWallet->transfer($from, $to, $amount);
-            return $result;
-//        } catch (\Exception $exception) {
-//            $message = $exception->getMessage();
-//            $this->error = $message;
-//
-//            RedisService::set("caches:wallet:transfer:error_{$toAddress['base58']}", $exception, 600);
-//            return false;
-//        }
+            $result = (array)$result;
+            if(isset($result['txID'])){
+                return $result;
+            }
+
+             return false;
+        } catch (\Exception $exception) {
+            $message = $exception->getMessage();
+            $this->error = $message;
+
+            RedisService::set("caches:wallet:transfer:error_{$toAddress['base58']}", $exception, 600);
+            return false;
+        }
     }
 
     /**