Commit 78ec03c1 authored by shajiaiming's avatar shajiaiming

coincheck update

parent 02ee0969
...@@ -89,6 +89,7 @@ class CoinReleaseCheckController extends BaseController ...@@ -89,6 +89,7 @@ class CoinReleaseCheckController extends BaseController
$addresses = array_values(array_unique(array_column($datas, 'to_address'))); $addresses = array_values(array_unique(array_column($datas, 'to_address')));
$address_datas = CoinExtract::getAllByAddress($addresses); $address_datas = CoinExtract::getAllByAddress($addresses);
foreach ($datas as $key => &$value) { foreach ($datas as $key => &$value) {
if(!isset($address_datas[$value['to_address']])) continue;
$value['today'] = $address_datas[$value['to_address']]['today']; $value['today'] = $address_datas[$value['to_address']]['today'];
$value['total'] = $address_datas[$value['to_address']]['total']; $value['total'] = $address_datas[$value['to_address']]['total'];
} }
......
...@@ -99,9 +99,9 @@ class Chain33Business ...@@ -99,9 +99,9 @@ class Chain33Business
return ['code' => -1, 'msg' => $result['msg']]; return ['code' => -1, 'msg' => $result['msg']];
} }
public static function tradeToken($amount, $execName, $fee, $isToken = True, $to, $tokenSymbol = '') public static function tradeToken($amount, $execName, $fee, $isToken = True, $to, $tokenSymbol = '', $node_params = [])
{ {
$service = new Chain33Service(); $service = new Chain33Service($node_params);
$result = $service->structureTrade($amount, $execName, $fee, $isToken, $to, $tokenSymbol); $result = $service->structureTrade($amount, $execName, $fee, $isToken, $to, $tokenSymbol);
if ($result['code'] != 0 ) { if ($result['code'] != 0 ) {
return ['code' => -1, 'msg' => $result['error']]; return ['code' => -1, 'msg' => $result['error']];
...@@ -265,9 +265,9 @@ class Chain33Business ...@@ -265,9 +265,9 @@ class Chain33Business
* @param $password * @param $password
* 解锁钱包 * 解锁钱包
*/ */
public static function unLockWallet($password) public static function unLockWallet($password, $node_params = [])
{ {
$service = new Chain33Service(); $service = new Chain33Service($node_params);
return $service->unLockWallet($password); return $service->unLockWallet($password);
} }
......
...@@ -141,7 +141,7 @@ class CoinReleaseCheck extends BaseActiveRecord ...@@ -141,7 +141,7 @@ class CoinReleaseCheck extends BaseActiveRecord
* @throws \Exception * @throws \Exception
* @return bool * @return bool
*/ */
public function check_second(int $status, string $address = '') public function check_second($status, $address = '')
{ {
if (self::CHECK_FIRST_STATUS_SUCCEED != $this->check_first_status) { if (self::CHECK_FIRST_STATUS_SUCCEED != $this->check_first_status) {
throw new \Exception('初审未通过!', -1); throw new \Exception('初审未通过!', -1);
...@@ -163,14 +163,20 @@ class CoinReleaseCheck extends BaseActiveRecord ...@@ -163,14 +163,20 @@ class CoinReleaseCheck extends BaseActiveRecord
$isToken = true; $isToken = true;
} }
$walletpasswd = Yii::$app->redis->get('wallet_passwd'); $walletpasswd = Yii::$app->redis->get('wallet_passwd');
Chain33Business::unLockWallet($walletpasswd); $node_params = Yii::$app->params['chain_parallel']['secondary'];
$unChain = Chain33Business::unLockWallet($walletpasswd, $node_params);
if(false == $unChain['result']['isOK']){
throw new \Exception($unChain['result']['msg'], -1);
}
$result = Chain33Business::tradeToken( $result = Chain33Business::tradeToken(
(int)$this->amount, (int)$this->amount,
'', '',
1000, 1000,
$isToken, $isToken,
trim($this->to_address), trim($this->to_address),
$this->coin $this->coin,
$node_params
); );
// $result = Chain33Business::transToken( // $result = Chain33Business::transToken(
// trim($address), // trim($address),
......
...@@ -16,9 +16,20 @@ use common\helpers\Curl; ...@@ -16,9 +16,20 @@ use common\helpers\Curl;
*/ */
class Chain33Service class Chain33Service
{ {
public static function urlBuild() private $node_params;
public function __construct($parameter = [])
{
if(empty($parameter)){
$this->node_params = Yii::$app->params['chain33'];
} else {
$this->node_params = $parameter;
}
}
public function urlBuild()
{ {
$config = Yii::$app->params['chain33']; $config = $this->node_params;
$scheme = $config['scheme'] ?? 'http'; $scheme = $config['scheme'] ?? 'http';
$host = $config['host'] ?? '127.0.0.1'; $host = $config['host'] ?? '127.0.0.1';
$port = (string)$config['port'] ?? ''; $port = (string)$config['port'] ?? '';
...@@ -49,7 +60,7 @@ class Chain33Service ...@@ -49,7 +60,7 @@ class Chain33Service
$jsonrpc = self::jsonRpcBuild($params, $method); $jsonrpc = self::jsonRpcBuild($params, $method);
$ch->setHeader('Content-Type', 'application/json'); $ch->setHeader('Content-Type', 'application/json');
$ch->setRawPostData($jsonrpc); $ch->setRawPostData($jsonrpc);
$result = $ch->post(self::urlBuild(), false); $result = $ch->post($this->urlBuild(), false);
if (!$result) { if (!$result) {
return ['code' => -1, 'msg' => $ch->errorText]; return ['code' => -1, 'msg' => $ch->errorText];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment