Commit a89fbf6f authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/trade-node' into 'master'

Feature/trade node See merge request !14
parents 02ee0969 39f44bdd
...@@ -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'];
} }
...@@ -148,8 +149,8 @@ class CoinReleaseCheckController extends BaseController ...@@ -148,8 +149,8 @@ class CoinReleaseCheckController extends BaseController
//获取所有管理员 //获取所有管理员
$admins = $this->getAccessAdmins(); $admins = $this->getAccessAdmins();
foreach ($datas as $key => &$value) { foreach ($datas as $key => &$value) {
$value['check_first_uid'] = isset($admins[$value['check_first_uid']]) ? $admins[$value['check_first_uid']] : ''; $value['check_first_uid'] = isset($admins[$value['check_first_uid']]) ? $admins[$value['check_first_uid']] : '自动审核';
$value['check_second_uid'] = isset($admins[$value['check_second_uid']]) ? $admins[$value['check_second_uid']] : ''; $value['check_second_uid'] = isset($admins[$value['check_second_uid']]) ? $admins[$value['check_second_uid']] : '自动审核';
} }
return ['code' => 0, 'count' => $count, 'data' => $datas]; return ['code' => 0, 'count' => $count, 'data' => $datas];
......
...@@ -209,5 +209,11 @@ IndexAsset::register($this); ...@@ -209,5 +209,11 @@ IndexAsset::register($this);
失败 失败
{{# }else if(4==d.status){ }} {{# }else if(4==d.status){ }}
完成 完成
{{# }else if(5==d.status){ }}
审核中
{{# }else if(6==d.status){ }}
审核失败
{{# }else if(7==d.status){ }}
审核异常
{{# } }} {{# } }}
</script> </script>
\ No newline at end of file
...@@ -89,9 +89,9 @@ class Chain33Business ...@@ -89,9 +89,9 @@ class Chain33Business
* @param string $tokenSymbol * @param string $tokenSymbol
* @return array|string * @return array|string
*/ */
public static function transToken($from, $to, $amount, $note = "", $isToken = true, $tokenSymbol = "") public static function transToken($from, $to, $amount, $note = "", $isToken = true, $tokenSymbol = "", $node_params = [])
{ {
$service = new Chain33Service(); $service = new Chain33Service($node_params);
$result = $service->transToken($from, $to, $amount, $note, $isToken, $tokenSymbol); $result = $service->transToken($from, $to, $amount, $note, $isToken, $tokenSymbol);
if ($result['code'] == 0) { if ($result['code'] == 0) {
return $result['result']['hash']; return $result['result']['hash'];
...@@ -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];
} }
......
...@@ -72,14 +72,16 @@ class ReleaseCheckController extends Controller ...@@ -72,14 +72,16 @@ class ReleaseCheckController extends Controller
$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'];
Chain33Business::unLockWallet($walletpasswd, $node_params);
$result = Chain33Business::transToken( $result = Chain33Business::transToken(
trim($from), trim($from),
trim($coin_release_check->to_address), trim($coin_release_check->to_address),
(int)$coin_release_check->amount, (int)$coin_release_check->amount,
"锁仓释放", "锁仓释放",
$isToken, $isToken,
$coin_release_check->coin $coin_release_check->coin,
$node_params
); );
if (is_array($result)) { if (is_array($result)) {
$isBlockFalse = true; //区块链报错 $isBlockFalse = true; //区块链报错
......
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