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
$addresses = array_values(array_unique(array_column($datas, 'to_address')));
$address_datas = CoinExtract::getAllByAddress($addresses);
foreach ($datas as $key => &$value) {
if(!isset($address_datas[$value['to_address']])) continue;
$value['today'] = $address_datas[$value['to_address']]['today'];
$value['total'] = $address_datas[$value['to_address']]['total'];
}
......@@ -148,8 +149,8 @@ class CoinReleaseCheckController extends BaseController
//获取所有管理员
$admins = $this->getAccessAdmins();
foreach ($datas as $key => &$value) {
$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_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']] : '自动审核';
}
return ['code' => 0, 'count' => $count, 'data' => $datas];
......
......@@ -209,5 +209,11 @@ IndexAsset::register($this);
失败
{{# }else if(4==d.status){ }}
完成
{{# }else if(5==d.status){ }}
审核中
{{# }else if(6==d.status){ }}
审核失败
{{# }else if(7==d.status){ }}
审核异常
{{# } }}
</script>
\ No newline at end of file
......@@ -89,9 +89,9 @@ class Chain33Business
* @param string $tokenSymbol
* @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);
if ($result['code'] == 0) {
return $result['result']['hash'];
......@@ -99,9 +99,9 @@ class Chain33Business
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);
if ($result['code'] != 0 ) {
return ['code' => -1, 'msg' => $result['error']];
......@@ -265,9 +265,9 @@ class Chain33Business
* @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);
}
......
......@@ -141,7 +141,7 @@ class CoinReleaseCheck extends BaseActiveRecord
* @throws \Exception
* @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) {
throw new \Exception('初审未通过!', -1);
......@@ -163,14 +163,20 @@ class CoinReleaseCheck extends BaseActiveRecord
$isToken = true;
}
$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(
(int)$this->amount,
'',
1000,
$isToken,
trim($this->to_address),
$this->coin
$this->coin,
$node_params
);
// $result = Chain33Business::transToken(
// trim($address),
......
......@@ -16,9 +16,20 @@ use common\helpers\Curl;
*/
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';
$host = $config['host'] ?? '127.0.0.1';
$port = (string)$config['port'] ?? '';
......@@ -49,7 +60,7 @@ class Chain33Service
$jsonrpc = self::jsonRpcBuild($params, $method);
$ch->setHeader('Content-Type', 'application/json');
$ch->setRawPostData($jsonrpc);
$result = $ch->post(self::urlBuild(), false);
$result = $ch->post($this->urlBuild(), false);
if (!$result) {
return ['code' => -1, 'msg' => $ch->errorText];
}
......
......@@ -72,14 +72,16 @@ class ReleaseCheckController extends Controller
$isToken = true;
}
$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(
trim($from),
trim($coin_release_check->to_address),
(int)$coin_release_check->amount,
"锁仓释放",
$isToken,
$coin_release_check->coin
$coin_release_check->coin,
$node_params
);
if (is_array($result)) {
$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