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 $key => $val) { go(function () use ($val) { \Co::sleep(0.5); if (1 == $val['step']) { $seq = 'first'; } else if (2 == $val['step']) { $seq = 'second'; } else if (3 == $val['step']) { $seq = 'thrid'; } else { } $node_params = $val['transfer_url_' . $seq]; $node_params = Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']; $service = new Chain33Service($node_params); $txHex = $val['txhex_' . $seq]; $privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e21'; $expire = '1m'; $signRawTx = $service->signRawTx($privkey, $txHex, $expire); if (0 != $signRawTx['code']) { $txhash = '0'; $msg = $signRawTx['msg']; goto doEnd; } $sign_str = $signRawTx['result']; $result = $service->sendTransaction($sign_str); if (0 != $result['code']) { $txhash = '0'; $msg = $result['msg']; goto doEnd; } $txhash = $result['result']; $msg = 'success'; doEnd : $currentModel = CoinAirDropTransfer::findOne($id); $currentModel->txhash = $txhash; $currentModel->msg = $msg; $currentModel->save(); }); } return 0; } }