Commit e598d212 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/sakura' into 'feature/bet'

Feature/sakura See merge request !29
parents 6df49191 57f76bcd
......@@ -17,6 +17,24 @@ class BaseController extends Controller
public $start;
public $end;
public $header_list = [];
public $lang;
private static $default_header_list = [];
public function init()
{
if ('cli' !== php_sapi_name()){
$this->header_list = self::$default_header_list;
$this->fzmCrossHeader();
}
}
public function fzmCrossHeader()
{
$this->lang = \Yii::$app->request->headers->get('lang') ?? 'zh-CN';
}
public function beforeAction($action)
{
$this->start = microtime(true);
......
......@@ -39,7 +39,12 @@ class CoinController extends BaseController
if ($id) {
$ret = CoinBusiness::getCoinAllById($id);
if ($ret) {
return $ret[0];
$data = $ret[0];
$nickname = json_decode($data['nickname'], true);
$introduce = json_decode($data['introduce'], true);
$data['nickname'] = $nickname[$this->lang];
$data['introduce'] = $introduce[$this->lang];
return $data;
}
}
return [];
......@@ -134,6 +139,10 @@ class CoinController extends BaseController
$coin_ids = array_column($coin_recommends, 'cid');
//获取币种信息
$coin_infos = Coin::getCoinInfoByIds($coin_ids, $select, 'id');
foreach ($coin_infos as $key => &$val){
$nickname = json_decode($val['nickname'], true);
$val['nickname'] = $nickname[$this->lang];
}
//获取行情信息
$coin_names = array_column($coin_infos, 'name');
$coin_names = array_merge($coin_names, array_column($coin_infos, 'chain'));
......@@ -231,6 +240,8 @@ class CoinController extends BaseController
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
foreach ($result['data'] as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = $nickname[$this->lang];
$value['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
}
return $result;
......@@ -279,6 +290,10 @@ class CoinController extends BaseController
foreach ($result as $key => $value) {
$result[$key]['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
}
foreach ($result as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = $nickname[$this->lang];
}
return ['code' => 0, 'count' => $total, 'data' => $result];
}
}
......
......@@ -92,6 +92,24 @@ class CoinController extends BaseController
$data['name'] = strtoupper($data['name']);
$data['platform'] = strtolower($data['platform']);
$data['chain'] = strtoupper($data['chain']);
$lang = [
'zh-CN',
'en-US',
'ja'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val){
$nickname[$lang[$key]] = $val;
}
foreach ($introduce_arr as $key => $val){
$introduce[$lang[$key]] = $val;
}
unset($data['nickname']);
$data['nickname'] = $nickname;
$data['introduce'] = $introduce;
$result = $coin->addOne($data);
if ($result === true) {
$this->success('添加成功', '/admin/coin/index');
......@@ -142,6 +160,24 @@ class CoinController extends BaseController
$can = true;
}
if ($can) {
$lang = [
'zh-CN',
'en-US',
'ja'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val){
$nickname[$lang[$key]] = $val;
}
foreach ($introduce_arr as $key => $val){
$introduce[$lang[$key]] = $val;
}
unset($data['nickname']);
$data['nickname'] = $nickname;
$data['introduce'] = $introduce;
$coin = Yii::createObject(Coin::className());
$result = $coin->updateOne($data);
if ($result === true) {
......
......@@ -109,13 +109,13 @@ class CoinReleaseCheckController extends BaseController
if ($model->load($get) && $model->validate()) {
$page = $get['page'] ?? 1;
$limit = $get['limit'] ?? 10;
$mobile = $get['mobile'] ?? '';
$query = CoinReleaseCheck::find()->andFilterWhere(['!=', 'status', 0])->andFilterWhere([
'status' => $model->status,
'coin' => $model->coin,
'check_first_uid' => $model->check_first_uid,
'check_second_uid' => $model->check_second_uid,
]);
$user_id = Yii::$app->user->identity->id;
$auth = Yii::$app->authManager;
$user_role = current($auth->getRolesByUser($user_id));
......@@ -141,6 +141,10 @@ class CoinReleaseCheckController extends BaseController
if ($model->end_time) {
$query = $query->andFilterWhere(['<=', 'create_time', $model->end_time]);
}
if($mobile){
$query = $query->andFilterWhere(['mobile' => $mobile]);
}
$count = $query->count();
$datas = $query->limit($limit)->offset(($page - 1) * $limit)->orderBy('id desc')->asArray()->all();
//获取审核员id
......
......@@ -25,8 +25,20 @@
</div>
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="nickname" value="<?= $model->nickname ?>">
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -113,9 +125,21 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">介绍</label>
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['en-US'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce"><?= $model->introduce ?></textarea>
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['ja'] ?></textarea>
</div>
</div>
<div class="layui-inline">
......
......@@ -25,8 +25,20 @@
</div>
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="nickname" value="<?= $model->nickname ?>">
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -117,9 +129,21 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">介绍</label>
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['en-US'] ?></textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce"><?= $model->introduce ?></textarea>
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['ja'] ?></textarea>
</div>
</div>
<div class="layui-inline">
......
......@@ -313,9 +313,9 @@ class Chain33Business
* @param array $hashes
* @return array
*/
public static function getTxByHashs($hashes)
public static function getTxByHashs($hashes, $node_params = [])
{
$service = new Chain33Service();
$service = new Chain33Service($node_params);
return $service->getTxByHashes($hashes);
}
......
......@@ -33,7 +33,10 @@ class ExchangeBusiness
4 => 'Bittrex',
5 => 'Zb',
6 => 'Token7',
7 => 'S'
7 => 'S',
8 => 'Zg',
9 => 'Go',
10 => 'Zhaobi'
];
/**
......@@ -96,6 +99,20 @@ class ExchangeBusiness
return $quotation;
}
if(in_array(strtoupper($tag),['GHP'])){
$exchange = ExchangeFactory::createExchange("Zg");
$quotation = $exchange->getTicker($tag, 'CNZ');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
return $quotation;
}
if(in_array(strtoupper($tag),['SFT'])){
$exchange = ExchangeFactory::createExchange("Zhaobi");
$quotation = $exchange->getTicker($tag, 'CNY');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
return $quotation;
}
foreach (self::$exchanges as $exchange) {
/**
* @var $exchange \common\service\exchange\Exchange
......@@ -139,10 +156,14 @@ class ExchangeBusiness
/**
* @var $exchange \common\service\exchange\Exchange
*/
$exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD");
$rate = $rate['last'] ?? '';
if(empty($rate)) {
$exchange = ExchangeFactory::createExchange("Bty");
$rate = $exchange->getTicker("BTY", "USDT");
$rate = (float)$rate['rmb'] / $rate['last'];
}
$quotation['rmb'] = (float)sprintf("%0.2f", $rate * $quotation['last']);
return $quotation;
......@@ -203,8 +224,7 @@ class ExchangeBusiness
$quotation = self::getquatation($row['name']);
if (!$quotation) {
$quotation = [];
//使用Coin服务
try {
if(in_array($row['name'], ['BTY', 'YCC'])){
$coinServer = CoinFactory::createCoin($row['name'], $row['id'], $row['sid']);
$rows[$key]['sid'] = ucfirst($rows[$key]['sid']);
$rows[$key]['rmb'] = $coinServer->getPrice();
......@@ -212,12 +232,11 @@ class ExchangeBusiness
$rows[$key]['low'] = $coinServer->getLow();
$rows[$key]['high'] = $coinServer->getHigh();
$coinServer->__destruct();
} catch (\Exception $exception) {
} else {
$rows[$key]['rmb'] = 0;
$rows[$key]['last'] = 0;
$rows[$key]['low'] = 0;
$rows[$key]['high'] = 0;
\Yii::error($exception->getMessage());
}
}
if (strtoupper($row['platform']) == 'GUODUN') {
......
......@@ -14,7 +14,7 @@ class Bty extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_bty';
protected $quotation_prefix = 'quotation_bty_';
protected $base_url = 'https://zbapi.licai.cn/api/data/Ticker?sort=cname&platform=';
protected $base_url = 'https://api.zhaobi.xyz/api/data/Ticker?sort=cname&platform=';
/**
* 转化交易对为请求变量
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Go extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_go';
protected $quotation_prefix = 'quotation_go_';
protected $base_url = 'https://otc-api.eiijo.cn/v1/data/trade-market?country=37&currency=1&payMethod=0&currPage=1&coinId=2&tradeType=sell&blockType=general&online=1';
public function symbolExists($tag = 'CNY', $aim = "USD")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'CNY', $aim = 'USD')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'CNY_USD');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['code']) && (200 == $content['code'])) {
$data = $content['data'];
foreach ($data as $item) {
$key = $this->quotation_prefix . 'CNY_USD';
$this->redis->hmset($key, 'low', $item['price'], 'high', $item['price'], 'last', $item['price']);
$this->redis->sadd($this->supported_symbol, 'CNY_USD');
break;
}
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Zg extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_zg';
protected $quotation_prefix = 'quotation_zg_';
protected $base_url = 'https://api1.zg.com/tickers';
public function symbolExists($tag = 'HL', $aim = "USDT")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'HL', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'HL_USDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$curl->setHeaders([
'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);
if (is_array($content) && isset($content['ticker'])) {
$data = $content['ticker'];
foreach ($data as $item) {
if (in_array($item['symbol'], ['HL_USDT', 'GHP_CNZ'])) {
$data = $item;
$key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
}
}
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Zhaobi extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_zhaobi';
protected $quotation_prefix = 'quotation_zhaobi_';
protected $base_url = 'https://api.biqianbao.top/api/data/basecoinprice?base=CNY&coin=SFT&platform=zhaobi';
public function symbolExists($tag = 'SFT', $aim = "CNY")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'SFT', $aim = 'CNY')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'SFT_CNY');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['code']) && (200 == $content['code'])) {
$data = $content['data'][0];
$key = $this->quotation_prefix . 'SFT_CNY';
$this->redis->hmset($key, 'low', $data['value'], 'high', $data['value'], 'last', $data['value']);
$this->redis->sadd($this->supported_symbol, 'SFT_CNY');
}
}
}
\ No newline at end of file
......@@ -74,12 +74,12 @@ class ReleaseCheckController extends Controller
$walletpasswd = Yii::$app->redis->get('wallet_passwd');
$node_params = Yii::$app->params['chain_parallel']['secondary'];
Chain33Business::unLockWallet($walletpasswd, $node_params);
$result = Chain33Business::transToken(
trim($from),
trim($coin_release_check->to_address),
$result = Chain33Business::tradeToken(
(int)$coin_release_check->amount,
"锁仓释放",
'',
1000,
$isToken,
trim($coin_release_check->to_address),
$coin_release_check->coin,
$node_params
);
......@@ -124,7 +124,8 @@ class ReleaseCheckController extends Controller
foreach($coin_release_checkItems as $coin_release_check){
$coin_release_list = CoinReleaseList::findOne($coin_release_check->list_id);
if ($coin_release_list) {
$result = Chain33Business::getTxByHashs([$coin_release_check->txhash]);
$node_params = Yii::$app->params['chain_parallel']['secondary'];
$result = Chain33Business::getTxByHashs([$coin_release_check->txhash], $node_params);
if ($result['code'] == 0) {
$result = $result['result']['txs'][0]['receipt']['ty'] ?? 0;
if ($result == 1) {
......
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