Jelajahi Sumber

异常处理

彭俊 6 tahun lalu
induk
melakukan
7d37cf6d2f
1 mengubah file dengan 31 tambahan dan 2 penghapusan
  1. 31 2
      Application/Api/Controller/Betorder.php

+ 31 - 2
Application/Api/Controller/Betorder.php

@@ -522,14 +522,43 @@ class Betorder extends BaseController{
                 unset($data['bunch'][count($data['bunch'])-1]);//删除最后一个元素
                 $this->stringBet($data['bunch'],$data_all,$userInfo,$batch_id);
             }
-            print_r($odds_ids);exit;
             _commit();//提交
             Render('', '1',lang('Errors','Api')->get('error-1'));
+          
+            //延时处理滚球投注
+            $this->Handle($odds_ids);
+
         } catch (Exception $e) {
             _rollBack();//回滚
             print $e->getMessage();
         }
-}
+    }
+
+
+    /**
+     * 追加滚球投注 延时处理审核
+     */
+    public function Handle($odds_ids = []){
+        $size = ob_get_length();
+        header("Content-Length: $size");
+        header('Connection: close');
+        header("HTTP/1.1 200 OK");
+        header("Content-Type: application/json;charset=utf-8");
+        ob_end_flush();
+        if(ob_get_length())
+            ob_flush();
+        flush();
+        if (function_exists("fastcgi_finish_request")) { // yii或yaf默认不会立即输出,加上此句即可(前提是用的fpm)
+            fastcgi_finish_request(); // 响应完成, 立即返回到前端,关闭连接
+        }
+        ignore_user_abort(true);//在关闭连接后,继续运行php脚本
+        set_time_limit(0); //no time limit,不设置超时时间(根据实际情况使用)
+        //继续运行的代码
+        sleep(20);//等待20秒后执行
+
+        file_put_contents("test.txt", "This is something.");
+       
+    }
 
     /**
      * token获取用户详情