where(['txhash' => "0"])->limit(20)->asArray()->all(); if (empty($model)) { echo date('Y-m-d H:i:s') . '暂无跨链交易计划' . PHP_EOL; return 0; } foreach ($model as $val) { // go(function () use ($val) { // \Co::sleep(0.5); if (1 == $val['current_step']) { $seq = 'first'; $step = 1; } else if (2 == $val['current_step']) { $seq = 'second'; $step = 2; } else if (3 == $val['current_step']) { $seq = 'thrid'; $step = 3; } else { $seq = 'first'; $step = 1; } $node_params = $val['transfer_url_' . $seq]; $node_params = explode(':', $node_params); $node_params = [ 'scheme' => $node_params[0], 'host' => str_replace('//', '', $node_params[1]), 'port' => $node_params[2] ]; $service = new Chain33Service($node_params); $sign_str = $val['txhex_' . $seq]; $result = $service->sendTransaction($sign_str); if (0 != $result['code']) { $txhash = '0'; $msg = $result['msg']; goto doEnd; } $txhash = $result['result']; $msg = 'success'; $step = ($step + 1 > 3) ? 3 : ($step + 1); doEnd : $current_step = $step; $currentModel = CoinCrossChain::findOne($val['id']); $currentModel->current_step = $current_step; $currentModel->txhash = $txhash; $currentModel->msg = $msg; $currentModel->save(); // }); } return 0; } }