songxingwei 2 gadi atpakaļ
vecāks
revīzija
e4473582f3
1 mainītis faili ar 15 papildinājumiem un 7 dzēšanām
  1. 15 7
      application/api/controller/Timedtask.php

+ 15 - 7
application/api/controller/Timedtask.php

@@ -104,13 +104,21 @@ class Timedtask
         Db::name('hash2')->where('success',0)->chunk(50,function ($list){
             $redis = new Redis();
             foreach ($list as &$v){
-                $url = 'http://192.144.219.204:8083/ddc/getTransactionReceipt?hash='.$v['hash'];
-                $res=curlRequest($url);
-                Db::name('hash2')->where('id',$v['id'])->update(['result'=>$res]);
-                $result3=json_decode($res,true);
-                if (isset($result3['status']) && $result3['status']=='0x1') {
-                    $update_data['success'] = 1;
-                    Db::name('hash2')->where('id', $v['id'])->update($update_data);
+                $hash_count = $redis->get('hash_'.$v['id']);
+                if ($hash_count>=5){
+                    Db::name('hash2')->where('id',$v['id'])->delete();
+                    $redis->Incrby('castingHash_'.$v['id'],$v['amout']);
+                }else{
+                    $url = 'http://192.144.219.204:8083/ddc/getTransactionReceipt?hash='.$v['hash'];
+                    $res=curlRequest($url);
+                    Db::name('hash2')->where('id',$v['id'])->update(['result'=>$res]);
+                    $result3=json_decode($res,true);
+                    if (isset($result3['status']) && $result3['status']=='0x1') {
+                        $update_data['success'] = 1;
+                        Db::name('hash2')->where('id', $v['id'])->update($update_data);
+                    }else{
+                        $redis->Incrby('hash_'.$v['id'],1);
+                    }
                 }
             }
         },'id', 'asc');