HttpServerOnlySet.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/6/26
  6. * Time: 12:03
  7. */
  8. namespace datainf\logic;
  9. use App\Lib\ModelBase;
  10. use datainf\lib\GlobConfigs;
  11. use Illuminate\Database\Capsule\Manager as DB;
  12. use swoole;
  13. use App\Lib\Settlement\SettlementBase;
  14. class HttpServerOnlySet
  15. {
  16. const TASKQNUM = 'TASKQNUM';
  17. const SQLKEY = 'ALLSQLKEY';
  18. private $httpserver;
  19. private $config;
  20. private $redisconfig;
  21. private $redis;
  22. private $redisTime;
  23. private $PDatas = [];
  24. private $SettlementBaseObj;
  25. private $TaskSqlQueue;
  26. public function __construct($config)
  27. {
  28. $this->httpserver = new \swoole\http\server($config['host'], $config['port']);
  29. $this->httpserver->set($config['sets']);
  30. $this->config = $config;
  31. $this->redisconfig = GlobConfigs::getKey('redis');
  32. $this->httpserver->account = new \swoole\Atomic();
  33. $this->httpserver->taskWorkingNum = new \swoole\Atomic();
  34. $this->httpserver->on('request', array($this, 'OnRequest'));
  35. $this->httpserver->on('WorkerStart', array($this, 'onWorkerStart'));
  36. $this->httpserver->on('task', array($this, 'onTask'));
  37. $this->httpserver->on('finish', array($this, 'onFinish'));
  38. }
  39. public function onWorkerStart($serv, $worker_id)
  40. {
  41. ModelBase::init();
  42. $this->TaskSqlQueue = new \SplQueue();
  43. Swoole\Timer::tick(1000, function () {
  44. $this->TimeWork();
  45. });
  46. Swoole\Timer::tick(1000, function () {
  47. $this->TaskSQlToRedis();
  48. });
  49. if ($serv->worker_id == 0) {
  50. Swoole\Timer::tick(60000, function () {
  51. $this->logRunStatus();
  52. });
  53. }
  54. }
  55. private function logRunStatus()
  56. {
  57. echo date('Y-m-d H:i:s') . " 总请求数:" . $this->httpserver->account->get() . ' 运行任务数:' . $this->httpserver->taskWorkingNum->get();
  58. echo ' work_id:' . $this->httpserver->worker_id . " 内存使用量:" . (memory_get_usage() / 1000) . 'k 峰值:' . (memory_get_peak_usage() / 1000) . "k\n";
  59. }
  60. private function getRedis()
  61. {
  62. if (time() - $this->redisTime <= 60 * 30) {
  63. if ($this->redis) {
  64. return $this->redis;
  65. }
  66. } else {
  67. if ($this->redis) {
  68. $this->redis->close();
  69. }
  70. }
  71. $this->redis = new \redis();
  72. $ret = $this->redis->connect($this->redisconfig['host'], $this->redisconfig['port']);
  73. if (!$ret) {
  74. $this->redis = false;
  75. throw new \Exception("连接redis失败 " . date("Y-m-d H:i:s"));
  76. return;
  77. }
  78. if (!$this->redis->auth($this->redisconfig['passwd'])) {
  79. throw new \Exception("redis auth 失败 " . date("Y-m-d H:i:s"));
  80. return;
  81. }
  82. $this->redis->select($this->redisconfig['db']);
  83. $this->redisTime = time();
  84. return $this->redis;
  85. }
  86. //全部结算 结束要改结算和比赛状态
  87. private function doSettelement($paras)
  88. {
  89. $begin = microtime(true);
  90. try {
  91. list($order_ids, $bettype, $settype, $game_code, $match_id, $change_status) = $this->requestpara($paras);
  92. if (!$this->DataPre($order_ids, $bettype, $settype, $game_code, $match_id, $change_status)) {
  93. throw new \Exception('没找到订单信息');
  94. }
  95. $this->UndoSettlement();
  96. while (true) {
  97. $order_id = trim(array_shift($order_ids));
  98. if (empty($order_id)) {
  99. break;
  100. }
  101. $nowBuyDatasMainModel = $this->PDatas['Money_buy_Orders_Array'][$order_id];
  102. if ($nowBuyDatasMainModel->settle_status == 2 && $settype == 1) {
  103. continue;
  104. }
  105. $account_indent = $nowBuyDatasMainModel->account_identity;
  106. $batch_id = $nowBuyDatasMainModel->batch_id;
  107. $paras = [
  108. 'type' => 'Settelement',
  109. 'bet_type' => $bettype,
  110. 'set_type' => $settype,
  111. 'order_id' => $order_id,
  112. 'game_code' => $nowBuyDatasMainModel->game_code,
  113. 'match_id' => $match_id,
  114. 'simplexData' => $nowBuyDatasMainModel,
  115. 'matchDatas' => $this->PDatas['Money_buy_Match_array'][$batch_id],
  116. 'settelementMidDataID' => isset($this->PDatas['settlement_middle_detail_array'][$bettype][$order_id]) ? $this->PDatas['settlement_middle_detail_array'][$bettype][$order_id]->id : 0,
  117. 'account' => $this->PDatas['account_map_array'][$account_indent]->account,
  118. 'money_prize' => isset($this->PDatas['money_prize_map'][$order_id]) ? $this->PDatas['money_prize_map'][$order_id]->id : 0
  119. ];
  120. if ($bettype == 1) {
  121. $this->singOrder($paras);
  122. } else {
  123. $this->ChuanOrder($paras);
  124. }
  125. }
  126. $this->cgStatus($game_code, $match_id, $change_status);
  127. } catch (\Exception $e) {
  128. $this->PDatas = [];
  129. $data = Response::generate('', 10, '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
  130. echo $data . "\n";
  131. }
  132. $this->timeCost($begin);
  133. }
  134. private function requestpara($paras)
  135. {
  136. $this->PDatas = [];
  137. $paras = json_decode($paras, true);
  138. $idoarr = $paras['ids'];
  139. $order_ids = array_map(function ($i) {
  140. return strval($i);
  141. }, $idoarr);
  142. $bettype = isset($paras['bettype']) ? $paras['bettype'] : 0;
  143. $settype = isset($paras['settype']) ? $paras['settype'] : 0;
  144. $game_code = isset($paras['game_code']) ? $paras['game_code'] : '';
  145. $match_id = isset($paras['match_id']) ? $paras['match_id'] : 0;
  146. $change_status = isset($paras['change_status']) ? $paras['change_status'] : 0;
  147. if (intval($match_id) <= 0) {
  148. throw new \Exception('赛事ID不能为空!');
  149. return;
  150. }
  151. if (empty($game_code)) {
  152. throw new \Exception('赛事类型不能为空!');
  153. }
  154. if (!in_array($bettype, [1, 2])) {
  155. throw new \Exception('订单类型参数错误!');
  156. }
  157. if (!in_array($settype, [1, 2])) {
  158. throw new \Exception('结算参数错误');
  159. }
  160. $this->PDatas['bettype'] = $bettype;
  161. $this->PDatas['settype'] = $settype;
  162. $this->PDatas['game_code'] = $game_code;
  163. $this->PDatas['match_id'] = $match_id;
  164. $ret = [$order_ids, $bettype, $settype, $game_code, $match_id, $change_status];
  165. return $ret;
  166. }
  167. //重结算时,要先扣掉先前发的钱
  168. private function UndoSettlement()
  169. {
  170. if (empty($this->PDatas['settlement_middle_detail_array'])) {
  171. return true;
  172. }
  173. $bet_type = $this->GP('bettype');
  174. $nowArray = $this->PDatas['settlement_middle_detail_array'][$bet_type];
  175. foreach ($nowArray as $order => $val) {
  176. $money = abs(floatval($val->money));
  177. $acc = $val->account_identity;
  178. $sql = "update account_detailed set cash=cash-$money where identity='$acc' ";
  179. $this->PushSqlToArray($sql);
  180. $ids[] = $order;
  181. }
  182. $ids_array = array_map(function ($i) {
  183. return "'$i'";
  184. }, $ids);
  185. $ids_array = implode(",", $ids_array);
  186. unset($ids_array_0);
  187. $sql = "update settlement_middle_detail set money=0 where order_id in($ids_array) and bet_type=$bet_type ";
  188. $this->PushSqlToArray($sql);
  189. return true;
  190. }
  191. //得么一个临时变量
  192. private function GP($name)
  193. {
  194. return $this->PDatas[$name];
  195. }
  196. private function TimeWork()
  197. {
  198. $this->httpserver->taskWorkingNum->add();
  199. try {
  200. $ret = $this->getRedis()->rpop(self::TASKQNUM);
  201. if (!empty($ret)) {
  202. $this->httpserver->account->add();
  203. $this->doSettelement($ret);
  204. }
  205. } catch (\Exception $e) {
  206. echo "Error: " . $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine() . "\n";
  207. }
  208. $this->httpserver->taskWorkingNum->sub();
  209. }
  210. private function cgStatus($game_code, $match_id, $change_status)
  211. {
  212. $table1 = "st_" . $game_code . "_result";
  213. $table2 = "st_" . $game_code . "_competition";
  214. if ($change_status) {
  215. $this->PushSqlToArray("update $table1 set status=3 where match_id=$match_id ");
  216. $this->PushSqlToArray("update $table2 set status=3 where match_id=$match_id ");
  217. }
  218. unset($table1, $table2);
  219. }
  220. private function timeCost($begin, $now = 0, $txt = '')
  221. {
  222. if ($now == 0) {
  223. $now = microtime(true);
  224. }
  225. $cost = $now - $begin;
  226. echo " Cost: $txt " . $cost . " 秒\n";
  227. }
  228. private function TaskSQlToRedis()
  229. {
  230. if ($this->TaskSqlQueue->isEmpty()) {
  231. return;
  232. }
  233. $this->sqltoRedisqueue();
  234. }
  235. /**
  236. * 单式注单结算
  237. * @param mixed $order_id 注单ID
  238. */
  239. private function singOrder($task)
  240. {
  241. $matchDatas = $task['matchDatas'];
  242. $simplexData = $task['simplexData'];
  243. $account_identity = $simplexData->account_identity;
  244. $bet_type = $task['bet_type'];
  245. $order_id = $task['order_id'];
  246. $match_id = $task['match_id'];
  247. $game_code = $task['game_code'];
  248. $account = $task['account'];
  249. $money_prize = $task['money_prize'];
  250. foreach ($matchDatas as $val) {
  251. if (!in_array($val->result, [-1, 1, 2, 3, 4])) {
  252. throw new \Exception('match比赛结果异常或还没有输赢结果->' . $val->id);
  253. }
  254. }
  255. if (empty($this->SettlementBaseObj)) {
  256. $settlementBase = $this->SettlementBaseObj = new SettlementBase();
  257. } else {
  258. $settlementBase = $this->SettlementBaseObj;
  259. }
  260. $returnMoney = 0;
  261. $oddsResult = [];
  262. foreach ($matchDatas as $k => $v) {
  263. if ($v->result == -1) {
  264. continue;
  265. }
  266. $oddsResult[0]['winOrLose'] = $v->result;
  267. $oddsResult[0]['odds'] = $v->odds;
  268. $getReturnMoney = $settlementBase->stringOdds($oddsResult);
  269. $returnMoney += $getReturnMoney['returnMoney'] * $v->bet_money;
  270. }
  271. $returnMoney = sprintf("%.2f", substr(sprintf("%.3f", $returnMoney), 0, -1));
  272. // 判断盈亏 1 赢 2 输 3 平
  273. $game_status = $returnMoney > $simplexData->money ? 1 : ($returnMoney == $simplexData->money ? 3 : 2);
  274. // 修改投注表状态及盈亏
  275. $this->PushSqlToArray(["update money_buy_simplex set settle_status=2, game_status=$game_status,gain_money=$returnMoney where order_id='$order_id' "]);
  276. $this->WriteOrAddSettlement($game_code, $match_id, $bet_type, $order_id, $account_identity, $returnMoney);
  277. $this->insertData(
  278. $order_id,
  279. $returnMoney,
  280. $account_identity,
  281. 1,
  282. $game_code,
  283. $simplexData->info_identity,
  284. $simplexData->money,
  285. $match_id,
  286. $account,
  287. $money_prize
  288. );
  289. }
  290. private function WriteOrAddSettlement($game_code, $match_id, $bet_type, $order_id, $account_ident, $money)
  291. {
  292. if (intval($money * 1000) < 10) {
  293. return;
  294. }
  295. if ($this->set_type == 2 && isset($this->settlement_middle_detail_array[$bet_type][$order_id])) {
  296. $this->PushSqlToArray("update settlement_middle_detail set money=$money where game_code='$game_code' and bet_type=$bet_type and order_id='$order_id' ");
  297. } else {
  298. $this->PushSqlToArray("insert into settlement_middle_detail(game_code,match_id,account_identity,bet_type,order_id,money) values('$game_code','$match_id','$account_ident',$bet_type,'$order_id',$money)");
  299. }
  300. return true;
  301. }
  302. private function PushSqlToArray($cmdArray)
  303. {
  304. if (is_string($cmdArray)) {
  305. $this->TaskSqlQueue->enqueue($cmdArray);
  306. } else {
  307. foreach ($cmdArray as $sql) {
  308. $this->TaskSqlQueue->enqueue($sql);
  309. }
  310. }
  311. }
  312. private function ChuanOrder($task)
  313. {
  314. $matchDatas = $task['matchDatas'];
  315. $simplexData = $task['simplexData'];
  316. $account_identity = $simplexData->account_identity;
  317. $bet_type = $task['bet_type'];
  318. $order_id = $task['order_id'];
  319. $match_id = $task['match_id'];
  320. $game_code = $task['game_code'];
  321. $account = $task['account'];
  322. $money_prize = $task['money_prize'];
  323. foreach ($matchDatas as $val) {
  324. if (!in_array($val->result, [-1, 1, 2, 3, 4])) {
  325. throw new \Exception('match比赛结果异常或还没有输赢结果->' . $val->id);
  326. }
  327. }
  328. $batch_id = $simplexData->batch_id;
  329. $matchModels = $matchDatas;
  330. if (count($matchModels) <= 0) {
  331. throw new \Exception('match 数据异常-' . $batch_id);
  332. }
  333. if (empty($this->SettlementBaseObj)) {
  334. $settlementBase = $this->SettlementBaseObj = new SettlementBase();
  335. } else {
  336. $settlementBase = $this->SettlementBaseObj;
  337. }
  338. $newTime = date('Y-m-d H:i:s');
  339. if ($simplexData->status == 1) {
  340. $in_array = [];
  341. foreach ($matchModels as $val) {
  342. if (!in_array($val->result, [-1, 1, 2, 3, 4])) {
  343. throw new \Exception('match 比赛结果异常或还没有输赢结果->' . $val->id);
  344. }
  345. if ($val->result == -1) {
  346. $this->PushSqlToArray("update money_buy_str set wait_match_num=0, prize_note=0, game_status=3, settle_status=2, gain_money=0,settlementTime='" . date('Y-m-d H:i:s') . "' where batch_id='$batch_id' ");
  347. return true;
  348. }
  349. $in_array[] = ['odds' => $val->odds, 'winOrLose' => $val->result];
  350. }
  351. $chuanNum = intval(substr($simplexData->str_type, 0, 1));
  352. $lasPeilv = $settlementBase->stringComputing([$in_array, $chuanNum]);
  353. $money = floatPointDigit($this->BuyDatasMainModel->money * $lasPeilv);
  354. } else {
  355. $money = $simplexData->money;
  356. }
  357. $this->PushSqlToArray(" update money_buy_str set settle_status=2 , game_status=1 , settlementTime='$newTime' , gain_money=$money where order_id = '$order_id'");
  358. $this->WriteOrAddSettlement($this->game_code, $this->match_id, $this->orderType, $order_id, $this->BuyDatasMainModel->account_identity, $money);
  359. $this->insertData($order_id, $money, $this->BuyDatasMainModel->account_identity, 2, $val->game_code, $this->BuyDatasMainModel->info_identity, $this->BuyDatasMainModel->money, $this->match_id, $account, $money_prize);
  360. return true;
  361. }
  362. /**
  363. * 结算数据填入
  364. * @param mixed $order_id 注单ID
  365. * @param mixed $returnMoney 返现金额
  366. * @param mixed $account_identity 用户ID
  367. * @param mixed $type 1单式 2串式
  368. * @param mixed $game_name 游戏名(zq,lq)
  369. * @param mixed $buy_identity 游戏投注id
  370. * @param mixed $money 投注金额
  371. * @param mixed $match_id 赛场ID
  372. */
  373. private function insertData($order_id, $returnMoney, $account_identity, $type, $game_name, $buy_identity, $money, $match_id = 0, $account = '', $money_prizeID = 0)
  374. {
  375. // 添加流水记录
  376. $info_identity = UUID();
  377. $money_time = date('Y-m-d H:i:s', time());
  378. $trade_desc = $type == 1 ? '单式投注订单回款' : '串式投注订单回款';
  379. $reason = $type == 1 ? '单式投注订单回款' : '串式投注订单回款';
  380. $sql = "insert into money_details(info_identity,trade_id,account_name,account_identity,money,money_time,money_type,money_cash,trade_type,trade_desc,reason,sysetem_user,status) values(";
  381. $sql .= "'$info_identity','$order_id','$account','$account_identity',$returnMoney,'$money_time',1,0,4,'$trade_desc','$reason','系统',1)";
  382. $this->PushSqlToArray($sql);
  383. // 修改用余额
  384. $this->PushSqlToArray("update account_detailed set available_cash=available_cash+$money,cash=cash+$money where account_identity='$account_identity' ");
  385. // 新增用户中奖信息
  386. $content = $type == 1 ? '您的单式投注订单' . $order_id . '于' . $money_time . '成功回款' . $returnMoney . '该次投注流程结束,如有疑问请联系客服'
  387. : '您的串式投注订单' . $order_id . '于' . $money_time . '成功回款' . $returnMoney . '该次投注流程结束,如有疑问请联系客服';
  388. $sql = "insert into account_news(identity,account_identity,title,content,details,write_time,read_status,type) values ";
  389. $sql .= "('$info_identity','$account_identity','投注订单回款通知','$content','$content','$money_time',-1,1)";
  390. $this->PushSqlToArray($sql);
  391. // 新增中奖记录表
  392. $table = 'money_prize';
  393. if ($money_prizeID) {
  394. $this->PushSqlToArray("update $table set money=$money,prize_money=$returnMoney, get_money= $returnMoney - $money where id=$money_prizeID");
  395. } else {
  396. $sql = "insert into $table (info_identity,order_id,account_identity,account_name,game_name,buy_identity,money,money_time,status,prize_money,get_money) values ";
  397. $sql .= "('$info_identity','$order_id','$account_identity','$account','$game_name','$buy_identity',$money,'$money_time',1,$returnMoney,$returnMoney - $money)";
  398. $this->PushSqlToArray($sql);
  399. }
  400. return true;
  401. }
  402. //数据预批量获取
  403. private function DataPre($order_ids, $bettype, $settype, $game_code, $match_id, $change_status)
  404. {
  405. if ($bettype == 1) {
  406. $moneytable = 'money_buy_simplex';
  407. $ret = DB::table('money_buy_simplex')->where(['game_code' => $game_code, 'match_id' => $match_id])->whereIn('order_id', $order_ids)->get();
  408. } else {
  409. $moneytable = 'money_buy_str';
  410. $ret = DB::table('money_buy_str')->whereIn('order_id', $order_ids)->get();
  411. }
  412. if (empty($ret) || count($ret) <= 0) {
  413. return false;
  414. }
  415. foreach ($ret as $val) {
  416. $this->PDatas['Money_buy_Orders_Array'][$val->order_id] = $val;
  417. $orderarr[] = $val->order_id;
  418. $this->PDatas['Money_buy_Orders_batch_Array'][$val->batch_id][] = $val;
  419. $tmpbatchid[] = $val->batch_id;
  420. $userindentys[] = $val->account_identity;
  421. }
  422. $tmpbatchid = array_unique($tmpbatchid);
  423. $userindentys = array_unique($userindentys);
  424. if ($bettype == 1) {
  425. $ret = DB::table('money_buy_match')->where(['game_code' => $game_code, 'match_id' => $match_id])->whereIn('batch_id', $tmpbatchid)->get();
  426. } else {
  427. $ret = DB::table('money_buy_match')->where(['game_code' => $game_code])->whereIn('batch_id', $tmpbatchid)->get();
  428. }
  429. foreach ($ret as $val) {
  430. $this->PDatas['Money_buy_Match_array'][$val->batch_id][] = $val;
  431. }
  432. $ret = DB::table('account_detailed')->whereIn('account_identity', $userindentys)->get();
  433. foreach ($ret as $val) {
  434. $this->PDatas['account_indentity_map_array'][$val->account_identity] = $val;
  435. }
  436. $ret = DB::table('account')->whereIn('identity', $userindentys)->get();
  437. foreach ($ret as $val) {
  438. $this->PDatas['account_map_array'][$val->identity] = $val;
  439. }
  440. if ($settype == 2) {
  441. $ret = DB::table('settlement_middle_detail')->where(['game_code' => $game_code, 'match_id' => $match_id])->whereIn('order_id', $order_ids)->get();
  442. if ($ret) {
  443. foreach ($ret as $val) {
  444. $this->PDatas['settlement_middle_detail_array'][$val->bet_type][$val->order_id] = $val;
  445. }
  446. }
  447. $order_str_1 = array_map(function ($item) {
  448. return "'$item'";
  449. }, $orderarr);
  450. $order_str = implode(",", $order_str_1);
  451. if ($change_status) {
  452. if ($bettype == 1) {
  453. $sql_tmp = "update $moneytable set settle_status=1, gain_money=0, game_status=0 where game_code='$game_code' and match_id=$match_id and status=1 and order_id in ($order_str) ";
  454. } else {
  455. $sql_tmp = "update $moneytable set settle_status=1, gain_money=0 where order_id in ($order_str) ";
  456. }
  457. $this->PushSqlToArray($sql_tmp);
  458. }
  459. }
  460. $ret = DB::table('money_prize')->whereIn('order_id', $order_ids)->where('money', '>', 0.01)->get();
  461. if ($ret) {
  462. foreach ($ret as $val) {
  463. $this->PDatas['money_prize_map'][$val->order_id] = $val;
  464. }
  465. }
  466. return true;
  467. }
  468. private function sqltoRedisqueue()
  469. {
  470. $sqlQueue = $this->TaskSqlQueue;
  471. $redis = $this->getRedis();
  472. $i = 1;
  473. $maxStep = 10000;
  474. $sql = '';
  475. if (!$sqlQueue->isEmpty()) {
  476. $redis->pipeline();
  477. while ($i < $maxStep) {
  478. if (!$sqlQueue->isEmpty()) {
  479. $sql = $sqlQueue->dequeue();
  480. if (empty($sql)) {
  481. break;
  482. }
  483. $redis->lpush(self::SQLKEY, $sql);
  484. }
  485. $i++;
  486. }
  487. $redis->exec();
  488. }
  489. unset($sqlQueue, $sql, $i, $maxStep, $ret);
  490. return;
  491. }
  492. public function OnRequest($request, $response)
  493. {
  494. }
  495. public function onTask($serv, $task)
  496. {
  497. }
  498. public function onFinish($serv, int $task_id, $data)
  499. {
  500. }
  501. public function start()
  502. {
  503. $this->httpserver->start();
  504. }
  505. }