songxingwei hace 2 años
padre
commit
247c55b1d8

+ 2 - 1
application/api/controller/Order.php

@@ -357,7 +357,8 @@ class Order extends Base
                     'company_hash_time'=>$company_hash_time,
                     //'ddcid'=>$ddcid,
                     'collectors_hash'=>$collectors_hash,
-                    'collectors_hash_time'=>''
+                    'collectors_hash_time'=>'',
+                    'type'=>2
                 ];
                 $array[] = $date;
             }

+ 2 - 1
application/api/controller/Pay.php

@@ -120,7 +120,8 @@ class Pay extends Controller
                     'company_hash_time'=>$company_hash_time,
                     //'ddcid'=>$ddcid,
                     'collectors_hash'=>$collectors_hash,
-                    'collectors_hash_time'=>''
+                    'collectors_hash_time'=>'',
+                    'type'=>2
                 ];
                 $array[] = $date;
             }

+ 76 - 2
application/api/controller/Timedtask.php

@@ -114,8 +114,17 @@ class Timedtask
                     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);
+                        $url4='http://192.144.219.204:8083/ddc/createDdcid?hash='.$v['hash'];
+                        $ddcid=curlRequest($url4);
+                        $result4=json_decode($ddcid,true);
+                        if($result4['code']){
+
+                        }else{
+                            $update_data['success'] = 1;
+                            $update_data['ddcid']=$ddcid;
+                            Db::name('hash2')->where('id', $v['id'])->update($update_data);
+                        }
+
                     }else{
                         $redis->Incrby('hash_'.$v['id'],1);
                     }
@@ -128,6 +137,70 @@ class Timedtask
 
 
 
+    /**
+     * 发放hash
+     * @url /api/Timedtask/sendHash
+     */
+    public function sendHash1(){
+        set_time_limit(0);
+        Db::name('store_order_info')
+            ->whereNotNull('company_hash')
+            ->whereIn('status','1,3')
+            ->where('company_hash','neq','')
+            ->where('type',2)
+            ->where('collectors_hash','eq','')
+            ->chunk('20',function ($list){
+                $from = '0xc472ec30ec813784b19872565e045c7153ea3f17';
+                $redis = new Redis();
+                foreach ($list as &$v){
+                    if ($v['status']==1){
+                        $mid = $v['mid'];
+                    }elseif ($v['status']==3){
+                        $from = Db::name('store_member')->where('id',$v['to_mid'])->value('wallet_address');
+                        $mid = $v['to_mid'];
+                    }
+
+                    $to = Db::name('store_member')->where('id',$mid)->value('wallet_address');
+                    if (empty($to) || $to == ''){
+                        continue;
+                    }
+//                    $url2='http://192.144.219.204:8083/ddc/getNonce';
+//                    $nonce=curlRequest($url2);
+                    if ($this->redisNonceSetNx()){
+                        $nonce = $redis->get('nonce');
+                        $ddcid = $v['ddcid'];
+                        $url = "http://192.144.219.204:8083/ddc/transfer?from=$from&to=$to&ddcid=$ddcid&nonce=".$nonce;
+                        $res=curlRequest($url);
+                        echo $res.'<br />';
+                        $result=json_decode($res,true);
+                        if($result['code']){
+                            continue;
+                        }else{
+                            Db::name('store_order_info')
+                                ->where('id',$v['id'])
+                                ->update(['collectors_hash'=>$res,'collectors_hash_time'=>date('Y-m-d H:i:s')]);
+                            $redis->set('nonce',$nonce+1);
+                            $redis->del('noncenx');
+                        }
+                    }
+
+                    //$ddcid = Db::name('hash')->where('hash',$v['company_hash'])->value('ddcid');
+
+                }
+            },'id','desc');
+    }
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 
@@ -285,6 +358,7 @@ class Timedtask
             ->whereNotNull('company_hash')
             ->whereIn('status','1,3')
             ->where('company_hash','neq','')
+            ->where('type',1)
             ->where('collectors_hash','eq','')
             ->chunk('20',function ($list){
                 $from = '0xc472ec30ec813784b19872565e045c7153ea3f17';