Commit edde675c authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into develop

parents b9f5149c 8bed813d
...@@ -44,7 +44,8 @@ class ExchangeBusiness ...@@ -44,7 +44,8 @@ class ExchangeBusiness
15 => 'Bitnasdaq', 15 => 'Bitnasdaq',
16 => 'Dag', 16 => 'Dag',
17 => 'Coinka', 17 => 'Coinka',
18 => 'Boc', 18 => 'Isummit',
19 => 'Boc',
//1 => 'Hadax', //不需要 //1 => 'Hadax', //不需要
...@@ -116,10 +117,10 @@ class ExchangeBusiness ...@@ -116,10 +117,10 @@ class ExchangeBusiness
if (strtoupper($tag) == 'FZM') { if (strtoupper($tag) == 'FZM') {
$quotation = [ $quotation = [
'low' => 41, 'low' => 30,
'high' => 41, 'high' => 30,
'last' => 41, 'last' => 30,
'rmb' => 41, 'rmb' => 30,
]; ];
goto doEnd; goto doEnd;
} }
...@@ -139,6 +140,12 @@ class ExchangeBusiness ...@@ -139,6 +140,12 @@ class ExchangeBusiness
} }
$f = false; $f = false;
$quotation = []; $quotation = [];
if (in_array(strtoupper($tag), ['SUM', 'USDW', 'FUT'])) {
$exchange = ExchangeFactory::createExchange("Isummit");
$quotation = $exchange->getTicker($tag, 'USDT');
goto doEnd;
}
if (in_array(strtoupper($tag), ['PAX'])) { if (in_array(strtoupper($tag), ['PAX'])) {
$exchange = ExchangeFactory::createExchange("HuoBi"); $exchange = ExchangeFactory::createExchange("HuoBi");
$quotation = $exchange->getTicker($tag, 'husd'); $quotation = $exchange->getTicker($tag, 'husd');
...@@ -337,9 +344,13 @@ class ExchangeBusiness ...@@ -337,9 +344,13 @@ class ExchangeBusiness
$exchange = ExchangeFactory::createExchange("Go"); $exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD"); $rate = $exchange->getTicker("CNY", "USD");
$cny_usd_rate = 1 / $rate['last']; $cny_usd_rate = 1 / $rate['last'];
if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA', 'DAG', 'BNC', 'GHP', 'DRA', 'ETC', 'PAX', 'STH', 'XJH', 'SFT', 'TSC'])) { if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA', 'DAG', 'BNC', 'GHP', 'DRA', 'ETC', 'PAX', 'STH', 'XJH', 'SFT', 'TSC', 'SUM', 'USDW', 'FUT'])) {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']); $quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate); $quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate);
$quotation['low'] = (float)sprintf("%0.4f", $quotation['low']);
$quotation['high'] = (float)sprintf("%0.4f", $quotation['high']);
$quotation['last'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['open'] = (float)sprintf("%0.4f", $quotation['open']);
} else if (in_array(strtoupper($tag), ['SUSD'])) { } else if (in_array(strtoupper($tag), ['SUSD'])) {
$quotation['usd'] = (float)sprintf("%0.4f", 1); $quotation['usd'] = (float)sprintf("%0.4f", 1);
} else { } else {
......
...@@ -11,6 +11,9 @@ class CoinAirDropTransfer extends BaseActiveRecord ...@@ -11,6 +11,9 @@ class CoinAirDropTransfer extends BaseActiveRecord
const ORIGIN_ADD = 2; const ORIGIN_ADD = 2;
const ORIGIN_API = 3; const ORIGIN_API = 3;
const TYPE_COINS = 1;
const TYPE_TOKEN = 2;
public static function getDb() public static function getDb()
{ {
return Yii::$app->get('p_sources'); return Yii::$app->get('p_sources');
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-26
* Time: 下午7:21
*/
namespace common\service\exchange;
use Yii;
use linslin\yii2\curl\Curl;
class Isummit extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_isummit';
protected $quotation_prefix = 'quotation_isummit_';
protected $base_url = 'http://www.isummit.top';
public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{
return strtolower(trim($tag) . trim($aim));
}
public function setSupportedSymbol()
{
}
public function setQuotation()
{
$curl = new Curl();
$api = $this->base_url . '/api/coins/market';
$res = $curl->get($api, false);
if (isset($res['code']) && 200 == $res['code'] && isset($res['data'])) {
foreach ($res['data'] as $item) {
if (in_array(strtoupper($item['coin']), ['SUM', 'USDW', 'FUT'])) {
$low = isset($item['price']) ? $item['price'] : 0;
$high = isset($item['price']) ? $item['price'] : 0;
$last = isset($item['price']) ? $item['price'] : 0;
$open = isset($item['price']) ? $item['price'] : 0;
$cache_key = $this->quotation_prefix . strtolower($item['coin'] . 'USDT');
$this->redis->hmset($cache_key, 'low', $low, 'high', $high, 'last', $last, 'open', $open);
}
}
}
}
}
...@@ -14,7 +14,7 @@ class Zg extends Exchange implements ExchangeInterface ...@@ -14,7 +14,7 @@ class Zg extends Exchange implements ExchangeInterface
{ {
protected $supported_symbol = 'supported_symbol_zg'; protected $supported_symbol = 'supported_symbol_zg';
protected $quotation_prefix = 'quotation_zg_'; protected $quotation_prefix = 'quotation_zg_';
protected $base_url = 'https://api1.zg.com/tickers'; protected $base_url = 'https://api.zg.com/openapi/quote/v1/ticker/24hr';
public function symbolExists($tag = 'HL', $aim = "USDT") public function symbolExists($tag = 'HL', $aim = "USDT")
{ {
...@@ -24,6 +24,7 @@ class Zg extends Exchange implements ExchangeInterface ...@@ -24,6 +24,7 @@ class Zg extends Exchange implements ExchangeInterface
} }
return false; return false;
} }
/** /**
* 转化交易对为请求变量 * 转化交易对为请求变量
* *
...@@ -33,7 +34,7 @@ class Zg extends Exchange implements ExchangeInterface ...@@ -33,7 +34,7 @@ class Zg extends Exchange implements ExchangeInterface
*/ */
public function formatSymbol($tag = 'HL', $aim = 'USDT') public function formatSymbol($tag = 'HL', $aim = 'USDT')
{ {
return strtoupper($tag .'_'. $aim); return strtoupper($tag . '_' . $aim);
} }
/** /**
...@@ -58,14 +59,19 @@ class Zg extends Exchange implements ExchangeInterface ...@@ -58,14 +59,19 @@ class Zg extends Exchange implements ExchangeInterface
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36', 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
]); ]);
$content = $curl->get($this->base_url, false); $content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['ticker'])) { if (is_array($content)) {
$data = $content['ticker']; foreach ($content as $item) {
foreach ($data as $item) { if (in_array($item['symbol'], ['HLUSDT', 'GHPUSDT'])) {
if (in_array($item['symbol'], ['HL_USDT', 'GHP_CNZ'])) { if ($item['symbol'] == 'HLUSDT') {
$symbol = 'HL_USDT';
}
if ($item['symbol'] == 'GHPUSDT') {
$symbol = 'GHP_CNZ';
}
$data = $item; $data = $item;
$key = $this->quotation_prefix . $item['symbol']; $key = $this->quotation_prefix . $symbol;
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last']); $this->redis->hmset($key, 'low', $data['lowPrice'], 'high', $data['highPrice'], 'last', $data['lastPrice'], 'open', $data['openPrice']);
$this->redis->sadd($this->supported_symbol, $item['symbol']); $this->redis->sadd($this->supported_symbol, $symbol);
} }
} }
} }
......
...@@ -158,4 +158,9 @@ class TrusteeShipService ...@@ -158,4 +158,9 @@ class TrusteeShipService
return $this->send("POST", $uri, $params); return $this->send("POST", $uri, $params);
} }
public function handleAsset($uri, $method, $params)
{
return $this->send($method, $uri, $params);
}
} }
...@@ -250,7 +250,7 @@ class AirDropController extends Controller ...@@ -250,7 +250,7 @@ class AirDropController extends Controller
} }
/** /**
* 获取游戏状态 * 自定义空投
* @return * @return
*/ */
public function actionAutoAirDrop() public function actionAutoAirDrop()
...@@ -260,6 +260,7 @@ class AirDropController extends Controller ...@@ -260,6 +260,7 @@ class AirDropController extends Controller
echo date('Y-m-d H:i:s') . '暂无空投计划' . PHP_EOL; echo date('Y-m-d H:i:s') . '暂无空投计划' . PHP_EOL;
return 0; return 0;
} }
foreach ($model as $key => $val) { foreach ($model as $key => $val) {
go(function () use ($val) { go(function () use ($val) {
\Co::sleep(0.5); \Co::sleep(0.5);
...@@ -268,11 +269,20 @@ class AirDropController extends Controller ...@@ -268,11 +269,20 @@ class AirDropController extends Controller
$amount = $val['amount'] * 1e8; $amount = $val['amount'] * 1e8;
$fee = 100000; $fee = 100000;
$note = ''; $note = '';
$execer = isset(Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']) ? Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']['execer'] : null; if (CoinAirDropTransfer::TYPE_COINS == $val['type']) {
$node_params = Yii::$app->params['chain_parallel']['primary'];
$node_params = Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']; $service = new Chain33Service($node_params);
$service = new Chain33Service($node_params); $execer = 'coins';
$createRawTransaction = $service->createRawTransaction($to, $amount, $fee, $note, $execer); $createRawTransaction = $service->createRawTransaction($to, $amount, $fee, $note, $execer);
}
if (CoinAirDropTransfer::TYPE_TOKEN == $val['type']) {
$node_params = Yii::$app->params['chain_parallel']['parallel'];
$service = new Chain33Service($node_params);
$execer = 'user.p.mall.token';
$isToken = true;
$tokenSymbol = $val['coin_name'];
$createRawTransaction = $service->createTokenRawTransaction($to, $amount, $isToken, $tokenSymbol, $fee, $note, $execer);
}
if (0 != $createRawTransaction['code']) { if (0 != $createRawTransaction['code']) {
$txhash = '0'; $txhash = '0';
...@@ -281,7 +291,7 @@ class AirDropController extends Controller ...@@ -281,7 +291,7 @@ class AirDropController extends Controller
} }
$txHex = $createRawTransaction['result']; $txHex = $createRawTransaction['result'];
$privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e21'; $privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2';
$expire = '1m'; $expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire); $signRawTx = $service->signRawTx($privkey, $txHex, $expire);
......
<?php
namespace wallet\controllers;
use Yii;
use yii\helpers\ArrayHelper;
use wallet\base\BaseController;
use common\models\psources\CoinPlatform;
use common\models\psources\CoinCurrency;
use common\models\psources\CoinSupportedCurrency;
use common\service\trusteeship\TrusteeShipService;
class AssetController extends BaseController
{
public function actionIndex()
{
$current_platform_id = Yii::$app->request->getPlatformId();
if (1 === $current_platform_id) {
$platform_id = Yii::$app->request->get('platform_id', 1);
$platform_id = empty($platform_id) ? 1 : $platform_id;
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
if (!isset(Yii::$app->params['trusteeship']['node_' . $platform_id])) {
return ['code' => -1, 'data' => [], 'msg' => '此钱包节点尚未开通'];
}
$node_params = Yii::$app->params['trusteeship']['node_' . $platform_id];
$uri = Yii::$app->request->post('uri', '');
$method = Yii::$app->request->post('method', 'GET');
$params = Yii::$app->request->post('params', '');
$time = time();
$appKey = isset($node_params['appKey']) ? $node_params['appKey'] : null;
$appSecret = isset($node_params['appSecret']) ? $node_params['appSecret'] : null;
$signature = self::getSign($params, $appKey, $appSecret, $time);
$headers = [
'FZM-Wallet-Signature' => $signature,
'FZM-Wallet-Timestamp' => $time,
'FZM-Wallet-AppKey' => $appKey,
'FZM-Wallet-AppIp' => Yii::$app->request->userIP
];
$service = new TrusteeShipService($node_params, $headers);
$result = $service->handleAsset($uri, $method, $params);
if (200 !== $result['code']) {
return ['code' => $result['code'], 'data' => [], 'msg' => $result['msg']];
}
return ['code' => 1, 'data' => $result['msg'], 'msg' => 'success'];
}
}
\ No newline at end of file
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