wesmiler 1 year ago
parent
commit
7110f25556
2 changed files with 4 additions and 8 deletions
  1. 1 1
      app/Http/Controllers/Api/v1/TestController.php
  2. 3 7
      app/Services/WalletService.php

+ 1 - 1
app/Http/Controllers/Api/v1/TestController.php

@@ -23,7 +23,7 @@ class TestController extends webApp
 
     public function check()
     {
-        $result  = WalletService::make()->getUsdtBalance('58YsXE527EojowwqSFDV1V7tCWUGVFbEqnD1f3TUUALQ',true);
+        $result  = WalletService::make()->getUsdtBalance('58YsXE527EojowwqSFDV1V7tCWUGVFbEqnD1f3TUUALQ');
         var_dump($result);
 //        $result = CregisPayService::make()->withdraw('58YsXE527EojowwqSFDV1V7tCWUGVFbEqnD1f3TUUALQ',1,'TS'.date('YmdHis'),1000);
 //        $result = MemberService::make()->pledgeUserList();

+ 3 - 7
app/Services/WalletService.php

@@ -244,14 +244,11 @@ class WalletService extends BaseService
         }
 
         $cacheKey = "caches:wallet:balance:sol_usdt_{$address}";
-        if ($data = RedisService::get($cacheKey) && $cache) {
+        $data = RedisService::get($cacheKey);
+        if ($data && !$cache) {
             return $data;
         }
 
-        if (RedisService::get($cacheKey . '_lock') && $cache) {
-            return false;
-        }
-
         try {
             $apiUrl = ConfigService::make()->getConfigByCode('solana_scan_api', '');
             if (empty($apiUrl)) {
@@ -286,8 +283,7 @@ class WalletService extends BaseService
                 }
             }
 
-            RedisService::set($cacheKey, ['amount'=> $balance,'tokenAccount'=>$tokenAccount], rand(3, 5));
-            RedisService::set($cacheKey . '_lock', true, rand(3, 5));
+            RedisService::set($cacheKey, ['amount'=> $balance,'tokenAccount'=>$tokenAccount], rand(5, 10));
             return ['amount'=> $balance,'tokenAccount'=>$tokenAccount];
 
         } catch (\Exception $exception) {