Browse Source

Weenier 168otc项目部署 0630

wesmiler 3 years ago
parent
commit
1a3933f585
2 changed files with 40 additions and 0 deletions
  1. 13 0
      app/Models/MemberModel.php
  2. 27 0
      app/Services/UsdtWalletService.php

+ 13 - 0
app/Models/MemberModel.php

@@ -11,6 +11,8 @@
 
 namespace App\Models;
 
+use App\Services\UsdtWalletService;
+
 /**
  * 会员-模型
  * @author laravel开发员
@@ -55,6 +57,7 @@ class MemberModel extends BaseModel
             if (isset($info['birthday'])) {
                 $info['birthday'] = $info['birthday']? datetime($info['birthday']) : '';
             }
+
             // 城市
             if ($info['province_id'] && $info['city_id'] && $info['district_id']) {
                 $city = [];
@@ -63,6 +66,16 @@ class MemberModel extends BaseModel
                 $city[] = $info['district_id'];
                 $info['city'] = $city;
             }
+
+            // 钱包余额
+            $trcNum = UsdtWalletService::make()->getTrxBalance($info['trc_address']);
+            $info['trc_num'] = floatval($trcNum);
+            $trcUsdtNum = UsdtWalletService::make()->getTrc20Usdt($info['trc_address']);
+            $info['trc_usdt_num'] = floatval($trcUsdtNum);
+            $ercNum = UsdtWalletService::make()->getErcBalance($info['erc_hexaddress']);
+            $info['erc_num'] = floatval($ercNum);
+            $ercUsdtNum = UsdtWalletService::make()->getErc20Usdt($info['erc_hexaddress']);
+            $info['erc_usdt_num'] = floatval($ercUsdtNum);
         }
         return $info;
     }

+ 27 - 0
app/Services/UsdtWalletService.php

@@ -798,6 +798,33 @@ class UsdtWalletService extends BaseService
     }
 
     /**
+     * TRC余额
+     * @param $address
+     * @return false|float|string
+     */
+    public function getErcBalance($address)
+    {
+        $cacheKey = "caches:wallet:balance:{$address}";
+        if (RedisService::get($cacheKey)) {
+            return false;
+        }
+
+        if (empty($address)) {
+            $this->error = '1018';
+            return false;
+        }
+
+        try {
+            $result = 0;
+            return $result ? floatval($result) : '0.00';
+
+        } catch (\Exception $exception) {
+            $this->error = $exception->getMessage();
+            return false;
+        }
+    }
+
+    /**
      * USDT-ERC20余额
      * @param $address
      * @return false|float|string