Commit 5ce0f792 authored by shajiaiming's avatar shajiaiming

fix

parents 3fa15b6f edc2bb2e
......@@ -19,12 +19,14 @@ class BaseController extends Controller
public $header_list = [];
public $lang;
public $currency_id;
public $platform_id;
private static $default_header_list = [];
public function init()
{
if ('cli' !== php_sapi_name()){
if ('cli' !== php_sapi_name()) {
$this->header_list = self::$default_header_list;
$this->fzmCrossHeader();
}
......@@ -33,9 +35,15 @@ class BaseController extends Controller
public function fzmCrossHeader()
{
$this->lang = \Yii::$app->request->headers->get('lang') ?? 'zh-CN';
if ('en' == strtolower($this->lang)){
if ('en' == strtolower($this->lang)) {
$this->lang = 'en-US';
}
if (\Yii::$app->request->headers->get('FZM-PLATFORM-ID')) {
$this->platform_id = \Yii::$app->request->headers->get('FZM-PLATFORM-ID');
}
if (\Yii::$app->request->headers->get('FZM-CURRENCY-ID')) {
$this->currency_id = \Yii::$app->request->headers->get('FZM-CURRENCY-ID');
}
}
public function beforeAction($action)
......@@ -75,7 +83,7 @@ class BaseController extends Controller
'errmsg' => $errmsg,
];
if($data !== null) {
if ($data !== null) {
$result['data'] = Yii::createObject('yii\rest\Serializer')->serialize($data);
}
......@@ -83,7 +91,7 @@ class BaseController extends Controller
$response->format = Response::FORMAT_JSON;
//jsonp数据格式
if(!is_null($callback)) {
if (!is_null($callback)) {
Yii::$app->getResponse()->format = Response::FORMAT_JSONP;
$result = [
'data' => $result,
......
......@@ -33,17 +33,17 @@ class ApplicationController extends BaseController
$recommendData = ApplicationBusiness::getRecommendList($condition);
foreach($recommendData as $j => &$val){
$name_arr = json_decode($val['name'], true);
$val['name'] = $name_arr[$this->lang];
$val['name'] = isset($name_arr[$this->lang]) ? $name_arr[$this->lang] : '';
}
$data['recommend'] =$recommendData;
$cate_app_data = ApplicationBusiness::getCategoryAppList($condition);
foreach ($cate_app_data as $key => &$val){
$name = json_decode($val['name'], true);
$val['name'] = $name[$this->lang];
$val['name'] = isset($name[$this->lang]) ? $name[$this->lang] : '';
if(!empty($val['apps'])){
foreach($val['apps'] as $j => &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
$value['name'] = isset($name[$this->lang]) ? $name[$this->lang] : '';
}
}
}
......@@ -64,11 +64,11 @@ class ApplicationController extends BaseController
$result['data'] = ApplicationBusiness::getCategoryAppList();
foreach ($result['data'] as $key => &$val){
$name = json_decode($val['name'], true);
$val['name'] = $name[$this->lang];
$val['name'] = isset($name[$this->lang]) ? $name[$this->lang] : '';
if(!empty($val['apps'])){
foreach($val['apps'] as $j => &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
$value['name'] = isset($name[$this->lang]) ? $name[$this->lang] : '';
}
}
}
......@@ -86,7 +86,7 @@ class ApplicationController extends BaseController
$result = ApplicationBusiness::appInfo($id);
$data = $result['data'];
$name = json_decode($data['name'], true);
$data['name'] = $name[$this->lang];
$data['name'] = isset($name[$this->lang]) ? $name[$this->lang] : '';
return ['code' => 0,'data' => $data];
}else{
return ['code' => 1,'data' => [],'msg' => 'id不能为空'];
......@@ -155,7 +155,7 @@ class ApplicationController extends BaseController
$icon_Infos = CoinImage::getItemsByIds($icon_Items);
foreach($appItems as &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
$value['name'] = isset($name[$this->lang]) ? $name[$this->lang] : '';
if($value['icon']){
$value['icon'] = Yii::$app->params['service']['OssService']['url'].$icon_Infos[$value['icon']]['file_url'];
}else{
......@@ -169,7 +169,7 @@ class ApplicationController extends BaseController
$app_id = $item['app_id'];
$cate_app_items[$cate_id]['cate_id'] = $cate_id;
$name_arr = json_decode($item['name'], true);
$name = $name_arr[$this->lang];
$name = isset($name_arr[$this->lang]) ? $name_arr[$this->lang] : '';
$cate_app_items[$cate_id]['name'] = $name;
$cate_app_items[$cate_id]['apps'][] = $appItems[$app_id];
}
......@@ -191,7 +191,7 @@ class ApplicationController extends BaseController
$cate_id = $request->get('cate_id','');
if($cate_id){
$cate_info = CoinApplicationCategory::getCategoryById($cate_id);
$name = $cate_info->name[$this->lang];
$name = isset($cate_info->name[$this->lang]) ? $cate_info->name[$this->lang] : '';
$cate_info_data['id'] = $cate_info->id;
$cate_info_data['name'] = $name;
$appItems = ApplicationBusiness::getCateAppInfo(0,[['cate_id' => $cate_id]]);
......@@ -200,7 +200,7 @@ class ApplicationController extends BaseController
foreach($appItems as &$value){
$value['app_user_num'] = ApplicationBusiness::getAppUserNum($value['app_id']);
$name_arr = json_decode($value['name'], true);
$value['name'] = $name_arr[$this->lang];
$value['name'] = isset($name_arr[$this->lang]) ? $name_arr[$this->lang] : '';
}
$cate_info_data['apps'] = $appItems;
return ['code' => 0,'data' => $cate_info_data];
......
<?php
namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\psources\ExploreApp;
use common\models\psources\CoinBannerItem;
use common\models\psources\ExploreAppCategory;
class BannerController extends BaseController
{
public function actionIndex()
{
$header = Yii::$app->request->headers;
$type = Yii::$app->request->get('type', 0);
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
$data = null;
if (false == $platform_id || false == $type) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$model = CoinBannerItem::find()
->select('banner_url, image_url, title, sort')
->where(['platform_id' => $platform_id, 'type' => $type, 'status' => CoinBannerItem::STATUS_ON])
->orderBy('sort')
->asArray()
->all();
$data = $model;
$msg = 'success';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
......@@ -15,10 +15,12 @@ use common\business\Chain33Business;
use common\business\CoinBusiness;
use common\business\ExchangeBusiness;
use common\models\psources\Coin;
use common\models\psources\CoinCurrency;
use common\models\psources\CoinPlatformWithHold;
use common\models\psources\CoinRecommend;
use common\models\psources\MinerFee;
use Yii;
use yii\data\Pagination;
/**
* 币种信息管理控制器
......@@ -43,8 +45,8 @@ class CoinController extends BaseController
$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];
$data['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$data['introduce'] = isset($introduce[$this->lang]) ? $introduce[$this->lang] : '';
return $data;
}
}
......@@ -142,9 +144,9 @@ class CoinController extends BaseController
$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];
$val['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$introduce = json_decode($val['introduce'], true);
$val['introduce'] = $introduce[$this->lang];
$val['introduce'] = isset($introduce[$this->lang]) ? $introduce[$this->lang] : '';
}
//获取行情信息
$coin_names = array_column($coin_infos, 'name');
......@@ -243,20 +245,92 @@ class CoinController extends BaseController
foreach ($chains as $key => $value) {
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
$last[] = 1;
$currency = CoinCurrency::find()->where(['pj_id' => $this->currency_id])->one();
if (false != $currency) {
if (1111 == $this->currency_id) {
$last[] = 1;
} else {
$last = Yii::$app->redis_currency->hmget('quotation_boc_' . 'CNY_' . $currency->symbol, 'last');
}
}
foreach ($result['data'] as $key => &$value) {
if (!isset($value['nickname']) || empty($value['nickname'])) continue;
$nickname = json_decode($value['nickname'], true);
$introduce = json_decode($value['introduce'], true);
$value['nickname'] = $nickname[$this->lang];
$value['introduce'] = $introduce[$this->lang];
$value['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$value['introduce'] = isset($introduce[$this->lang]) ? $introduce[$this->lang] : '';
$value['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
$value['chain_rmb'] = isset($value['chain_quotation']['rmb']) ? $value['chain_quotation']['rmb'] : 0;
$value['chain_usd'] = isset($value['chain_quotation']['usd']) ? $value['chain_quotation']['usd'] : 0;
$value['chain_country_rate'] = (float)sprintf("%0.4f", $last[0] * $value['chain_rmb']);
$value['country_rate'] = (false == $currency) ? $value['chain_rmb'] : (float)sprintf("%0.4f", $last[0] * $value['rmb']);
}
return $result;
}
}
public function actionSearch()
{
$params = Yii::$app->request->post();
$chain = isset($params['chain']) ? $params['chain'] : '';
$keyword = isset($params['keyword']) ? $params['keyword'] : '';
$platform = isset($params['platform']) ? $params['platform'] : '';
$platform_id = isset($params['platform_id']) ? $params['platform_id'] : '';
$page = empty($params['page']) ? 1 : $params['page'];
$limit = empty($params['limit']) ? 10 : $params['limit'];
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$query = Coin::find()
->select('id, sid, icon, name, optional_name, nickname, platform, chain, address as contract_address, treaty')
->where(['platform_id' => (int)$platform_id])
->orderBy('id');
if (false != $chain) {
$query->andWhere(['chain' => $chain]);
}
if (false != $platform) {
$query->andWhere(['platform' => $platform]);
}
if (false != $keyword) {
$query->andWhere(['or', ['like', 'address', $keyword], ['like', 'name', $keyword], ['like', 'nickname', $keyword]]);
}
$data = $query->offset(($page - 1) * $limit)->limit($limit)->asArray()->all();
$count = $query->count();
if (false != $data) {
$chains = array_unique(array_column($data, 'chain'));
$chain_quotation = [];
foreach ($chains as $key => $value) {
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
foreach ($data as $key => $value) {
$data[$key]['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
}
foreach ($data as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$value['chain_rmb'] = isset($value['chain_quotation']['rmb']) ? $value['chain_quotation']['rmb'] : 0;
$value['chain_usd'] = isset($value['chain_quotation']['usd']) ? $value['chain_quotation']['usd'] : 0;
}
}
$code = 0;
doEnd :
return ['code' => $code, 'data' => $data, 'count' => $count];
}
/**
* 按照名称搜索币种
*
......@@ -301,7 +375,7 @@ class CoinController extends BaseController
}
foreach ($result as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = $nickname[$this->lang];
$value['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$value['chain_rmb'] = isset($value['chain_quotation']['rmb']) ? $value['chain_quotation']['rmb'] : 0;
$value['chain_usd'] = isset($value['chain_quotation']['usd']) ? $value['chain_quotation']['usd'] : 0;
}
......@@ -365,7 +439,7 @@ class CoinController extends BaseController
if (1 == $coin_info['treaty']) {
$platform_with_hold['exer'] = 'user.p.' . $platform . '.token';
if ('BTY' !== strtoupper($platform)) {
$platform_with_hold['tokensymbol'] = $platform.'.'.$coin_name;
$platform_with_hold['tokensymbol'] = $platform . '.' . $coin_name;
} else {
$platform_with_hold['tokensymbol'] = $coin_name;
}
......
......@@ -126,10 +126,12 @@ class CoinDogController extends BaseController
public function actionArticleBanner()
{
$type = Yii::$app->request->get('type', 1);
$data = Article::find()
->select('id, image_url ,title, url')
->limit(5)
->where(['type' => $type])
->orderBy('update_at desc')
->limit(5)
->asArray()
->all();
......
<?php
namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\psources\ExploreApp;
use common\models\psources\CoinBannerItem;
use common\models\psources\ExploreAppCategory;
class ExploreController extends BaseController
{
public function actionIndex()
{
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
$data = null;
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$app_category_model = ExploreAppCategory::find()->where(['platform_id' => $platform_id, 'status' => ExploreAppCategory::STATUS_ON])->orderBy('sort')->all();
if (false == $app_category_model) {
$msg = 'success';
$code = 0;
goto doEnd;
}
foreach ($app_category_model as $key => $val) {
unset($val->apps);
$val->name = isset($val->name[$this->lang]) ? $val->name[$this->lang] : '';
$apps_model = ExploreApp::find()->select('id, name, icon, type, app_url, slogan')
->where(['app_category_id' => (int)$val->id, 'status' => ExploreApp::STATUS_ON])
->orderBy('sort')
->limit($val->limit)
->all();
if (empty($apps_model)) {
unset($app_category_model[$key]);
continue;
}
foreach ($apps_model as &$app) {
$app->name = isset($app->name[$this->lang]) ? $app->name[$this->lang] : '';
}
$val->apps = $apps_model;
unset($val->sort);
unset($val->limit);
unset($val->platform_id);
}
foreach ($app_category_model as $val) {
$data[] = $val;
}
$msg = 'success';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionCategory()
{
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
$category_id = Yii::$app->request->get('id', 0);
if (false == $platform_id || false == $category_id) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$app_category_model = ExploreAppCategory::find()->where(['id' => (int)$category_id, 'platform_id' => $platform_id])->all();
if (false == $app_category_model) {
$msg = 'success';
$code = 0;
$data = null;
goto doEnd;
}
foreach ($app_category_model as &$val) {
foreach ($val->applications as $app) {
$app->name = isset($app->name[$this->lang]) ? $app->name[$this->lang] : '';
}
$val->name = isset($val->name[$this->lang]) ? $val->name[$this->lang] : '';
$val->apps = $val->applications;
unset($val->id);
unset($val->sort);
unset($val->style);
unset($val->limit);
unset($val->platform_id);
}
$data = $app_category_model;
$msg = 'success';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionSearch()
{
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
$ids = Yii::$app->request->get('ids', '');
if (false == $platform_id || false == $ids) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$id_arr = explode(',', $ids);
$order = "FIELD(`id`,$ids)";
$apps_model = ExploreApp::find()->select('id, name, icon, type, app_url, slogan')
->where(['status' => ExploreApp::STATUS_ON])
->andWhere(['in', 'id', $id_arr])
->orderBy([$order => true])
->limit(4)
->all();
if (false == $apps_model) {
$msg = 'success';
$code = 0;
$data = null;
goto doEnd;
}
foreach ($apps_model as &$app) {
$app->name = isset($app->name[$this->lang]) ? $app->name[$this->lang] : '';
}
$data = $apps_model;
$msg = 'success';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionBanner()
{
$msg = 'ok';
$code = 0;
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$coin_banner = CoinBannerItem::find()->select('banner_url, image_url, title')->where(['platform_id' => $platform_id])->asArray()->all();
$data = $coin_banner;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
<?php
namespace api\controllers;
use common\models\psources\Coin;
use Yii;
use api\base\BaseController;
use common\models\psources\CoinPlatform;
class IssueChainController extends BaseController
{
/**
* 可发行链列表
* @return array
*/
public function actionIndex()
{
$data = null;
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
if (empty($platform_id)) {
$msg = '缺少必要的参数';
$code = -1;
goto doEnd;
}
$chain_model = CoinPlatform::find()->where(['id' => $platform_id])->all();
if (false == $chain_model) {
$msg = '不存在的链';
$code = -1;
goto doEnd;
}
foreach ($chain_model as &$val) {
$val->chain_name = isset($val->chain->platform) ? $val->chain->platform : '';
$val->issue_charge = (float)sprintf("%0.3f", $val->issue_charge);
$coin_model = Coin::find()->select('name, treaty')->where(['name' => strtoupper($val->charge_unit), 'platform' => $val->chain_name, 'treaty' => 2])->one();
$val->tokens = empty($coin_model) ? false : true;
if (empty($coin_model)) {
$val->exer = isset($val->chain->exer) ? $val->chain->exer : '';
} else {
if (1 == $coin_model->treaty) {
$val->exer = 'user.p.' . $val->chain->platform . '.token';
} else {
$val->exer = 'user.p.' . $val->chain->platform . '.coins';
}
}
unset($val->download_url);
unset($val->introduce);
unset($val->create_time);
unset($val->update_time);
}
$msg = 'ok';
$code = 0;
$data = is_array($chain_model) ? $chain_model : [$chain_model];
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
/**
* 人工审核状态
* @return array
*/
public function actionManualReviewStatus()
{
$status = 0;
$manual_review = Yii::$app->redis->get('issue_chain_manual_review');
if (false == $manual_review || 'open' == $manual_review) {
$status = 1;
}
return ['code' => 0, 'data' => $status];
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -103,7 +103,7 @@ class ServiceController extends BaseController
$rows = Coin::getSelectList(1, 999, $fields, [['in', 'id', $coin_recommendItems]], $coin_recommendItems);
foreach ($rows['data'] as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = $nickname[$this->lang];
$value['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
}
return ['code' => 0, 'data' => $rows, 'msg' => '币种列表获取成功'];
}
......
This diff is collapsed.
......@@ -3,8 +3,11 @@
namespace api\controllers;
use api\base\BaseController;
use common\models\psources\Coin;
use common\models\psources\CoinAirDropTrade;
use common\models\psources\CoinIssueTransfer;
use common\models\psources\CoinPlatform;
use common\models\psources\CoinPlatformWithHold;
use common\service\chain33\Chain33Service;
use Yii;
......@@ -16,7 +19,7 @@ class WalletController extends BaseController
$code = 0;
$msg = 'success';
$platform_id = Yii::$app->request->get('platform_id', '');
if(empty($platform_id)){
if (empty($platform_id)) {
$msg = '参数不能为空';
$code = -1;
$data = null;
......@@ -24,7 +27,7 @@ class WalletController extends BaseController
}
$data = CoinPlatform::find()->select("name, download_url, introduce")->where(['id' => $platform_id])->asArray()->one();
if(empty($data)){
if (empty($data)) {
$msg = '数据不存在';
$data = null;
$code = -1;
......@@ -39,16 +42,16 @@ class WalletController extends BaseController
public function actionGameTradeUpdate()
{
$coinAirDropTrade = CoinAirDropTrade::find()->where(['attach' => 2 ,'msg' => '0'])->limit(30)->all();
foreach ($coinAirDropTrade as $val){
$coinAirDropTrade = CoinAirDropTrade::find()->where(['attach' => 2, 'msg' => '0'])->limit(30)->all();
foreach ($coinAirDropTrade as $val) {
$fee = 100000;
$amount = 1 * 1e8;
$execer = 'coins';
$note = '';
$service = new Chain33Service();
$createRawTransaction = $service->createRawTransaction($val->coins_address, $amount, $fee, $note, $execer);
if(0 != $createRawTransaction['code']){
$createRawTransaction = $service->createRawTransaction($val->coins_address, $amount, $fee, $note, $execer);
if (0 != $createRawTransaction['code']) {
continue;
}
......@@ -57,13 +60,13 @@ class WalletController extends BaseController
$expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire);
if(0 != $signRawTx['code']){
if (0 != $signRawTx['code']) {
continue;
}
$sign_str = $signRawTx['result'];
$result = $service->sendTransaction($sign_str);
if(0 != $result['code']){
if (0 != $result['code']) {
continue;
}
$currentModel = CoinAirDropTrade::findOne($val->id);
......@@ -77,23 +80,106 @@ class WalletController extends BaseController
public function actionGetBalance()
{
$coinAirDropTrade = CoinAirDropTrade::find()->where(['balance' => 0])->limit(60)->all();
$address = [];
foreach ($coinAirDropTrade as $val){
$address[] = $val->coins_address;
$code = 0;
$msg = 'success';
$platform_id = Yii::$app->request->get('platform_id', '');
$token = Yii::$app->request->get('address', '');
$symbol = Yii::$app->request->get('symbol', '');
if (empty($platform_id) || empty($token) || empty($symbol)) {
$msg = '参数不能为空';
$code = -1;
$data = null;
goto doEnd;
}
$service = new Chain33Service();
$execer = 'coins';
$result = $service->getBalance($address, $execer);
if(0 == $result['code']){
$result_balance = $result['result'];
foreach ($result_balance as $val){
$coinAirDropTrade = CoinAirDropTrade::find()->where(['coins_address' => $val['addr']])->one();
if(empty($coinAirDropTrade)) continue;
$coinAirDropTrade->balance = $val['balance'];
$coinAirDropTrade->save();
$chain_model = CoinPlatform::find()->select('chain_id')->where(['id' => $platform_id])->andWhere(['<>', 'chain_id', 0])->one();
if (empty($chain_model)) {
$msg = '此功能为付费功能,有兴趣请与销售联系';
$code = -1;
goto doEnd;
}
$platform = CoinPlatformWithHold::find()->select('exer, platform')->where(['id' => $chain_model->chain_id])->one();
if (empty($platform)) {
$msg = '此功能为付费功能,有兴趣请与销售联系';
$code = -1;
goto doEnd;
}
$node = Yii::$app->params['chain_nodes'][strtoupper($platform->platform)];
if (empty($node)) {
$msg = '此功能为付费功能,有兴趣请与销售联系';
$code = -1;
goto doEnd;
}
$coin_model = Coin::find()->select('name, treaty')->where(['name' => strtoupper($symbol), 'platform' => $platform->platform])->one();
$switch = false;
if (empty($coin_model)) {
$execer = $platform->exer;
} else {
if (1 == $coin_model->treaty) {
$execer = 'user.p.' . $chain_model->chain->platform . '.token';
} else {
$execer = 'user.p.' . $chain_model->chain->platform . '.coins';
$switch = true;
}
}
return ['code' => 1, 'msg' => 'ok'];
if ('BTY' == strtoupper($symbol)) {
$switch = true;
$node = \Yii::$app->params['chain_parallel']['primary'];
}
$service = new Chain33Service($node);
$address[] = $token;
if (false == $switch) {
$result = $service->getTokenBalance($address, $execer, $symbol);
} else {
$result = $service->getBalance($address, $execer = '');
}
if (0 !== $result['code']) {
$msg = '当前发币人数过多,请客官稍后再试';
$code = -1;
$data = null;
goto doEnd;
}
$data = $result['result'];
doEnd :
return ['code' => $code, 'data' => $data, 'msg' => $msg];
}
public function actionTransfer()
{
$code = -1;
$request = Yii::$app->request;
$post = $request->post();
if (!$request->isPost) {
$msg = '请求错误!';
goto doEnd;
}
$txhex = isset($post['txhex']) ? $post['txhex'] : '';
$issue_coin_id = isset($post['issue_coin_id']) ? $post['issue_coin_id'] : 0;
if (false == $txhex || false == $issue_coin_id) {
$msg = '参数错误!';
goto doEnd;
}
$model = new CoinIssueTransfer();
$data['txhex'] = $txhex;
$data['issue_coin_id'] = (int)$issue_coin_id;
$model->load($data, '');
$model->save();
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg];
}
}
\ No newline at end of file
<?php
namespace backend\assets\coinSupportedCoin;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-supported-coin';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
......@@ -92,15 +92,11 @@ class ApplicationCategoryController extends BaseController
$fields = ['id', 'name', 'sort', 'icon', 'banner', 'banner_url'];
$params = $this->initParams(Yii::$app->request->post(), $fields);
$params['platform_id'] = Yii::$app->user->identity->platform_id;
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $params['name'];
$name = [];
foreach ($name_arr as $key => $val) {
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($params['name']);
......@@ -124,15 +120,10 @@ class ApplicationCategoryController extends BaseController
$category = CoinApplicationCategory::getCategoryById($params['id']);
$params['platform_id'] = $category->platform_id;
$application_category->setScenario(CoinApplicationCategoryForm::SCENARIO_EDIT);
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $params['name'];
$name = [];
foreach ($name_arr as $key => $val) {
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($params['name']);
......@@ -150,6 +141,7 @@ class ApplicationCategoryController extends BaseController
$coin['name_ja'] = isset($name_arr['ja']) ? $name_arr['ja'] : '';
$coin['name_zh'] = isset($name_arr['zh-CN']) ? $name_arr['zh-CN'] : '';
$coin['name_en'] = isset($name_arr['en-US']) ? $name_arr['en-US'] : '';
$coin['name_ko'] = isset($name_arr['ko']) ? $name_arr['ko'] : '';
$this->layout = false;
return $this->render('edit', ['model' => $coin]);
}
......
......@@ -65,15 +65,10 @@ class ApplicationController extends BaseController
$category_id = Yii::$app->request->get('category_id');
$fields = ['category_id', 'h5_icon', 'official_url', 'introduce_image', 'show_width', 'show_height', 'open_type', 'open_type_app', 'platform_type', 'name', 'sort', 'icon', 'type', 'native_url', 'native_login_url', 'h5_url', 'android_url', 'ios_url', 'app_store_url', 'advertise', 'description', 'redirect_type', 'platform_id'];
$data = Yii::$app->request->post();
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $data['name'];
$name = [];
foreach ($name_arr as $key => $val){
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($data['name']);
$data['name'] = $name;
......@@ -104,21 +99,15 @@ class ApplicationController extends BaseController
$fields = ['category_id', 'id', 'h5_icon', 'official_url', 'introduce_image', 'show_width', 'show_height', 'open_type', 'open_type_app', 'platform_type', 'name', 'sort', 'icon', 'type', 'native_url', 'native_login_url', 'h5_url', 'android_url', 'ios_url', 'app_store_url', 'advertise', 'description', 'redirect_type', 'platform_id'];
$data = Yii::$app->request->post();
$lang = [
'zh-CN',
'en-US',
'ja'
];
$name_arr = $data['name'];
$name = [];
foreach ($name_arr as $key => $val){
$name[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($name_arr[$val]) ? $name_arr[$val] : '';
}
unset($data['name']);
$data['name'] = $name;
$data['open_type_app'] = (0 == $data['open_type_app']) ? 1 : $data['open_type_app'];
#var_dump($data);exit;
$params = array_merge($data, ['platform_id' => Yii::$app->user->identity->platform_id]);
$params = $this->initParams($params, $fields);
$coin_applicateion_form = new CoinApplicationForm();
......@@ -165,9 +154,10 @@ class ApplicationController extends BaseController
#echo json_encode($applicate);exit;
$applicate['sort'] = $app_cate->sort;
$name_arr = json_decode($applicate['name'], true);
$applicate['name_ja'] = $name_arr['ja'];
$applicate['name_en'] = $name_arr['en-US'];
$applicate['name_zh'] = $name_arr['zh-CN'];
$applicate['name_ja'] = isset($name_arr['ja']) ? $name_arr['ja'] : '';
$applicate['name_en'] = isset($name_arr['en-US']) ? $name_arr['en-US'] : '';
$applicate['name_zh'] = isset($name_arr['zh-CN']) ? $name_arr['zh-CN'] : '';
$applicate['name_ko'] = isset($name_arr['ko']) ? $name_arr['ko'] : '';
$this->layout = false;
return $this->render('edit', ['item' => $applicate, 'category_id' => $category_id]);
}
......
......@@ -95,22 +95,18 @@ class CoinController extends BaseController
$data['name'] = strtoupper(trim($data['name']));
$data['platform'] = $data['platform'];
$data['chain'] = strtoupper($data['chain']);
$lang = [
'zh-CN',
'en-US',
'ja',
'ko'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = trim($val);
foreach (Yii::$app->params['lang'] as $key => $val) {
$nickname[$val] = isset($nickname_arr[$val]) ? $nickname_arr[$val] : '';
}
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$introduce[$val] = isset($introduce_arr[$val]) ? $introduce_arr[$val] : '';
}
unset($data['nickname']);
unset($data['introduce']);
$data['nickname'] = $nickname;
......@@ -168,21 +164,15 @@ class CoinController extends BaseController
$can = true;
}
if ($can) {
$lang = [
'zh-CN',
'en-US',
'ja',
'ko'
];
$nickname_arr = $data['nickname'];
$introduce_arr = $data['introduce'];
$nickname = [];
$introduce = [];
foreach ($nickname_arr as $key => $val) {
$nickname[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$nickname[$val] = isset($nickname_arr[$val]) ? $nickname_arr[$val] : '';
}
foreach ($introduce_arr as $key => $val) {
$introduce[$lang[$key]] = $val;
foreach (Yii::$app->params['lang'] as $key => $val) {
$introduce[$val] = isset($introduce_arr[$val]) ? $introduce_arr[$val] : '';
}
unset($data['nickname']);
$data['nickname'] = $nickname;
......
<?php
namespace backend\controllers;
use common\models\psources\CoinSupportedCoin;
use Yii;
class CoinSupportedCoinController extends BaseController
{
public function actionList()
{
$platform_id = Yii::$app->request->get('id');
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$id = $request->get('id', '');
$where = [];
if ($id) {
$where[] = ['platform_id' => $id];
}
$data = CoinSupportedCoin::getList($page, $limit, $where);
$data['code'] = 0;
Yii::$app->response->format = 'json';
return $data;
}
return $this->render('index', ['platform_id' => $platform_id]);
}
public function actionAdd()
{
$this->layout = false;
$model = new CoinSupportedCoin();
$model->setScenario(CoinSupportedCoin::SCENARIOS_CREATE);
if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$data = Yii::$app->request->post();
if ($model->load($data, '') && $model->save()) {
return ['code' => 0, 'msg' => 'succeed'];
}
$error = $model->errors;
if ($error) {
return ['code' => -1, 'msg' => current($model->firstErrors)];
}
}
$platform_id = Yii::$app->request->get('platform_id');
return $this->render('add', ['model' => $model, 'platform_id' => $platform_id]);
}
public function actionDelete()
{
Yii::$app->response->format = 'json';
$id = Yii::$app->request->get('id', 0);
if ($id) {
$model = CoinSupportedCoin::findOne(['id' => $id]);
if ($model) {
try {
$model->delete();
return ['code' => 0, 'msg' => 'succeed'];
} catch (\Throwable $t) {
return ['code' => $t->getCode(), 'msg' => $t->getMessage()];
}
}
}
return ['code' => -1, 'msg' => '删除失败'];
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ namespace backend\controllers;
use backend\models\coin\CoinPlatformForm;
use common\models\psources\CoinPlatform;
use common\models\psources\CoinPlatformWithHold;
use Yii;
......@@ -39,6 +40,7 @@ class WalletController extends BaseController
{
$model = new CoinPlatformForm();
$model->scenario = 'add';
$platform_withhold = CoinPlatformWithHold::find()->select('id, platform')->orderBy('platform')->asArray()->all();
if (Yii::$app->request->isPost) {
$data = Yii::$app->request->post();
if ($model->load($data, '') && $model->validate()) {
......@@ -60,7 +62,8 @@ class WalletController extends BaseController
}
$this->error($errors, Yii::$app->request->getReferrer());
}
return $this->render('add', ['model' => $model]);
return $this->render('add', ['model' => $model, 'platform_withhold' => $platform_withhold]);
}
public function actionEdit()
......@@ -90,9 +93,10 @@ class WalletController extends BaseController
} elseif (Yii::$app->request->isGet) {
$id = Yii::$app->request->get('id', null);
if ($id) {
$platform_withhold = CoinPlatformWithHold::find()->select('id, platform')->orderBy('platform')->asArray()->all();
$coin = CoinPlatform::findOne(['id' => $id]);
$this->layout = false;
return $this->render('edit', ['model' => $coin]);
return $this->render('edit', ['model' => $coin, 'platform_withhold' => $platform_withhold]);
}
}
}
......
......@@ -14,6 +14,7 @@ class CoinPlatformForm extends Model
{
public $id;
public $name;
public $chain_id;
public $download_url;
public $introduce;
......@@ -27,6 +28,7 @@ class CoinPlatformForm extends Model
return [
[['name'], 'required', 'on' => 'add'],
[['id', 'name'], 'required', 'on' => 'update'],
[['chain_id', 'download_url', 'introduce'], 'safe']
];
}
......@@ -34,6 +36,7 @@ class CoinPlatformForm extends Model
{
return [
'id' => 'ID',
'chain_id' => '所属链',
'name' => '名称',
'download_url' => '下载链接',
'introduce' => '介绍'
......@@ -46,10 +49,16 @@ class CoinPlatformForm extends Model
'add' => [
'id',
'name',
'chain_id',
'download_url',
'introduce'
],
'update' => [
'id',
'name',
'chain_id',
'download_url',
'introduce'
],
];
}
......
......@@ -21,7 +21,7 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" required lay-verify="required" placeholder=""
<input class="layui-input" name="name[zh-CN]" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
</div>
......@@ -29,13 +29,19 @@
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
<input class="layui-input" name="name[en-US]" value="">
</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="name[]" value="">
<input class="layui-input" name="name[ja]" value="">
</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="name[ko]" value="">
</div>
</div>
<div class="layui-form-item layui-form-text">
......
......@@ -21,19 +21,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_zh'] ?>">
<input class="layui-input" name="name[zh-CN]" value="<?= $model['name_zh'] ?>">
</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="name[]" value="<?= $model['name_en'] ?>">
<input class="layui-input" name="name[en-US]" value="<?= $model['name_en'] ?>">
</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="name[]" value="<?= $model['name_ja'] ?>">
<input class="layui-input" name="name[ja]" value="<?= $model['name_ja'] ?>">
</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="name[ko]" value="<?= $model['name_ko'] ?>">
</div>
</div>
<div class="layui-form-item layui-form-text">
......
......@@ -48,19 +48,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[zh-CN]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[en-US]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
<input class="layui-input" name="name[ja]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[ko]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
......@@ -51,19 +51,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_zh'] ?>" lay-verify="required">
<input class="layui-input" name="name[zh-CN]" value="<?= $item['name_zh'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_en'] ?>" lay-verify="required">
<input class="layui-input" name="name[en-US]" value="<?= $item['name_en'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_ja'] ?>" lay-verify="required">
<input class="layui-input" name="name[ja]" value="<?= $item['name_ja'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[ko]" value="<?= $item['name_ko'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
<div style="padding: 5px 20px;">
<br>
<form id="addData">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<div class="input-group my-group">
<span class="input-group-addon">币种名称</span>
<input name="coin_name" type="text" class="form-control" lay-verify="required">
</div>
<input class="layui-input" name="platform_id" type="hidden" value="<?= $platform_id ?>"
lay-verify="required">
</form>
</div>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use backend\assets\coinSupportedCoin\IndexAsset;
IndexAsset::register($this);
?>
<style>
.layui-table-tips-c {
padding: 0px;
}
</style>
<h4>货币列表</h4>
<div class="layui-row">
<div class="layui-col-md1">
<button class="layui-btn layui-btn-sm" lay-event="add" id="add">单笔添加</button>
</div>
</div>
<input id="platform_id" type="hidden" value="<?= $platform_id ?>">
<div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<script type="text/html" id="operationTpl">
<a lay-event="delete">
<button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe640;</i></button>
</a>
</script>
......@@ -34,19 +34,25 @@
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
<input class="layui-input" name="nickname[zh-CN]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
<input class="layui-input" name="nickname[en-US]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
<input class="layui-input" name="nickname[ja]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">韩文名</label>
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[ko]" value="<?= $model->nickname['ko'] ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -135,19 +141,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
<textarea class="layui-textarea" name="introduce[zh-CN]"><?= $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>
<textarea class="layui-textarea" name="introduce[en-US]"><?= $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['ja'] ?></textarea>
<textarea class="layui-textarea" name="introduce[ja]"><?= $model->introduce['ja'] ?></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[ko]"><?= $model->introduce['ko'] ?></textarea>
</div>
</div>
<div class="layui-inline">
......
......@@ -34,19 +34,25 @@
<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['zh-CN'] ?>">
<input class="layui-input" name="nickname[zh-CN]" value="<?= isset($model->nickname['zh-CN']) ? $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'] ?>">
<input class="layui-input" name="nickname[en-US]" value="<?= isset($model->nickname['en-US']) ? $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'] ?>">
<input class="layui-input" name="nickname[ja]" value="<?= isset($model->nickname['ja']) ? $model->nickname['ja'] : '' ?>">
</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[ko]" value="<?= isset($model->nickname['ko']) ? $model->nickname['ko'] : '' ?>">
</div>
</div>
<div class="layui-form-item">
......@@ -141,19 +147,25 @@
<div class="layui-form-item">
<label class="layui-form-label">中文介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce[]"><?= $model->introduce['zh-CN'] ?></textarea>
<textarea class="layui-textarea" name="introduce[zh-CN]"><?= isset($model->introduce['zh-CN']) ? $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>
<textarea class="layui-textarea" name="introduce[en-US]"><?= isset($model->introduce['en-US']) ? $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['ja'] ?></textarea>
<textarea class="layui-textarea" name="introduce[ja]"><?= isset($model->introduce['ja']) ? $model->introduce['ja'] : '' ?></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[ko]"><?= isset($model->introduce['ko']) ? $model->introduce['ko'] : '' ?></textarea>
</div>
</div>
<div class="layui-inline">
......
......@@ -23,6 +23,18 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">所属链</label>
<div class="layui-input-block">
<select name="chain_id">
<?php foreach ($platform_withhold as $val): ?>
<option value="<?= $val['id'] ?>" <?php if ($model->chain_id == $val['id']) {
echo "selected";
} ?>><?= $val['platform'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">下载地址</label>
<div class="layui-input-block">
<input class="layui-input" name="download_url" value="<?= $model->download_url ?>">
......@@ -40,3 +52,6 @@
</form>
</div>
</div>
<script>
layui.form.render();
</script>
......@@ -24,6 +24,18 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">所属链</label>
<div class="layui-input-block">
<select name="chain_id">
<?php foreach ($platform_withhold as $val): ?>
<option value="<?= $val['id'] ?>" <?php if ($model->chain_id == $val['id']) {
echo "selected";
} ?>><?= $val['platform'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">下载地址</label>
<div class="layui-input-block">
<input class="layui-input" name="download_url" value="<?= $model->download_url ?>">
......
......@@ -42,11 +42,8 @@ IndexAsset::register($this);
</div>
<script type="text/html" id="operationTpl">
<a lay-event="edit">
<button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe642;</i></button>
</a>
<a lay-event="delete">
<button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe640;</i></button>
</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/coin-supported-symbol/list?id={{d.id}}" >支持发行货币对</a>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-xs" lay-event="delete">删除</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/coin-supported-symbol/list?id={{d.id}}">C2C支持货币对</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/coin-supported-coin/list?id={{d.id}}">支持发行货币种类</a>
</script>
/**
* @author rlgyzhcn@qq.com
*/
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
var platform_id = $("#platform_id").val();
var tableIns = table.render({
elem: "#table1",
url: '/admin/coin-supported-coin/list?id=' + platform_id,
limit: 10,
page: 1,
loading: true,
cols: [[
{field: 'id', title: 'ID'},
{field: 'coin_name', title: '货币对'},
{field: 'create_time', title: '创建时间'},
{field: 'id', title: '操作', templet: '#operationTpl'}
]],
});
form.on('submit(form1)', function (data) {
table.reload("table1", {
where: data.field,
page: {curr: 1},
});
return false;
});
//监听单元格事件
table.on('tool(table1)', function (obj) {
var data = obj.data;
if (obj.event == 'delete') {
layer.confirm('真的要删除' + data.coin_name + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.close(index);
//向服务端发送删除指令
$.get('/admin/coin-supported-coin/delete?id=' + obj.data.id, function (data, status) {
if (data.code == 0) {
obj.del(); //删除对应行(tr)的DOM结构
}
layer.msg(data.msg);
});
});
}
});
$('#add').click(function () {
//打开弹窗
$.get('/admin/coin-supported-coin/add?platform_id=' + platform_id, {}, function (str) {
var index = layer.open({
type: 1,
title: '添加数据',
id: 'add-one',
skin: 'layui-layer-lan',
area: ['320px', 'auto'],
content: str,
btn: ['确认', '取消'],
btn1: function () {
$.post('/admin/coin-supported-coin/add', $("#addData").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
layer.close(index);
table.reload("table1", {});
}
});
}
});
layui.form.render();
});
return false;
});
\ No newline at end of file
......@@ -14,6 +14,7 @@ class BaseRequest extends Request
{
private $user_id = 0;
private $platform_id = 0;
private $group = '';
public function getUserId()
{
......@@ -34,4 +35,14 @@ class BaseRequest extends Request
{
$this->platform_id = $value;
}
public function getGroup()
{
return $this->group;
}
public function setGroup($value)
{
$this->group = $value;
}
}
\ No newline at end of file
......@@ -26,18 +26,20 @@ class LoginStatusAuthInterceptor extends ActionFilter
$token_string = Yii::$app->request->headers->get('Token');
if(false == $token_string){
$msg = 'platform auth error';
$code = '40004';
$code = '40001';
goto doEnd;
}
$model = new Admin();
$user = $model->loginByAccessToken($token_string,'');
if(false == $user){
$msg = 'user auth error';
$code = '40004';
$code = '40002';
goto doEnd;
}
$group = $user->group;
$user_id = $user->uid;
$platform_id = $user->platform_id;
Yii::$app->request->setGroup($group);
Yii::$app->request->setUserId($user_id);
Yii::$app->request->setPlatformId($platform_id);
return true;
......
......@@ -34,8 +34,10 @@ class UserAuthInterceptor extends ActionFilter
$msg = 'user auth error';
goto doEnd;
}
$group = $user->group;
$user_id = $user->uid;
$platform_id = $user->platform_id;
Yii::$app->request->setGroup($group);
Yii::$app->request->setUserId($user_id);
Yii::$app->request->setPlatformId($platform_id);
$user_auth = Yii::$app->params['user_auth']['user_auth'];
......
......@@ -33,19 +33,21 @@ class ExchangeBusiness
4 => 'Bittrex',
5 => 'Zb',
6 => 'Token7',
7 => 'S',
8 => 'Zg',
9 => 'Go',
10 => 'Zhaobi',
11 => 'Gdpro',
12 => 'Ex',
13 => 'Zt',
14 => 'Tsc',
15 => 'Binance',
16 => 'Ceohk',
17 => 'Biki',
18 => 'Bilaxy',
19 => 'Boc'
7 => 'Zg',
8 => 'Go',
9 => 'Zhaobi',
10 => 'Ex',
11 => 'Zt',
12 => 'Tsc',
13 => 'Binance',
14 => 'Biki',
15 => 'Bilaxy',
16 => 'Bitnasdaq',
17 => 'Dag',
18 => 'Boc',
//7 => 'S',//已挂
//11 => 'Gdpro',//已挂
//16 => 'Ceohk', //已挂
];
/**
......@@ -98,7 +100,7 @@ class ExchangeBusiness
goto doEnd;
}
if (strtoupper($tag) == 'GST' || strtoupper($tag) == 'JNTK' || strtoupper($tag) == 'SPT' ||strtoupper($tag) == 'STO' || strtoupper($tag) == 'GM' || strtoupper($tag) == 'BSTC' || strtoupper($tag) == 'RYH' || strtoupper($tag) == 'CNDT' || strtoupper($tag) == 'WL' || strtoupper($tag) == 'ETS' || strtoupper($tag) == 'LIMS' || strtoupper($tag) == 'AT' || strtoupper($tag) == 'BTJ') {
if (strtoupper($tag) == 'GST' || strtoupper($tag) == 'JNTK' || strtoupper($tag) == 'SPT' || strtoupper($tag) == 'STO' || strtoupper($tag) == 'GM' || strtoupper($tag) == 'BSTC' || strtoupper($tag) == 'RYH' || strtoupper($tag) == 'CNDT' || strtoupper($tag) == 'WL' || strtoupper($tag) == 'ETS' || strtoupper($tag) == 'LIMS' || strtoupper($tag) == 'AT' || strtoupper($tag) == 'BTJ') {
$quotation = [
'low' => 0,
'high' => 0,
......@@ -121,6 +123,20 @@ class ExchangeBusiness
goto doEnd;
}
if (in_array(strtoupper($tag), ['DAG'])) {
$exchange = ExchangeFactory::createExchange("Dag");
$quotation = $exchange->getTicker($tag, 'USDT');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['BNC'])) {
$exchange = ExchangeFactory::createExchange("Bitnasdaq");
$quotation = $exchange->getTicker($tag, 'USDT');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['GM', 'BSTC'])) {
$exchange = ExchangeFactory::createExchange("Token7");
$quotation = $exchange->getTicker($tag, 'HA');
......@@ -136,8 +152,8 @@ class ExchangeBusiness
}
if (in_array(strtoupper($tag), ['GHP'])) {
$exchange = ExchangeFactory::createExchange("Zg");
$quotation = $exchange->getTicker($tag, 'CNZ');
$exchange = ExchangeFactory::createExchange("Bitnasdaq");
$quotation = $exchange->getTicker($tag);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
......@@ -280,7 +296,7 @@ class ExchangeBusiness
$exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD");
$cny_usd_rate = 1 / $rate['last'];
if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA'])) {
if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA', 'DAG', 'BNC'])) {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate);
} else if (in_array(strtoupper($tag), ['SUSD'])) {
......
<?php
namespace common\components;
use yii\base\Component;
class ErrorMessage extends Component
{
/**
* 预定义错误信息
*/
public static $errors = [
'ErrTokenNameLen' => "token名字太长",
'ErrTokenSymbolLen' => " token符号太长",
'ErrTokenTotalOverflow' => ' token 总数过大, 或是负的',
'ErrTokenSymbolUpper' => ' token symbol 需要全是大写字母',
'ErrTokenIntroLen' => ' Token介绍太长',
'ErrTokenExist' => ' Token Symbol 已经存在',
'ErrTokenNotPrecreated' => ' Token 还没有预创建',
'ErrTokenCreatedApprover' => 'Token Approver 没有权限',
'ErrTokenRevoker' => ' Token Revoker 错误 (需要创建者自己撤销)',
'ErrTokenCanotRevoked' => 'Token 不能撤销',
'ErrTokenOwner' => 'Token Owner 错误',
'ErrTokenHavePrecreated' => 'Token已经被预创建',
'ErrTokenBlacklist' => 'Token 在黑名单里',
'ErrTokenNotExist' => 'Token 不存在',
'ErrTokenSymbolExistAlready' => 'Token Symbol 已经存在'
];
/**
* 获取错误信息
*/
public static function getMessage($msg)
{
$message = isset(self::$errors[$msg]) ? self::$errors[$msg] : '未知错误';
return $message;
}
}
\ No newline at end of file
<?php
namespace common\models;
use Yii;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use yii\helpers\FileHelper;
class Tools
{
/**
* 获取随机验证码
* @return string
*/
public static function getRandomNumber($count = 6, $type = 'mixed')
{
$chars = '1234567890abcdefghijklmnopqrstuvwxyz';
switch($type) {
case 'number':
$startIndex = 0;
$endIndex = 9;
break;
case 'letter':
$startIndex = 10;
$endIndex = 35;
break;
default :
$startIndex = 0;
$endIndex = 35;
break;
}
$randomNumber = '';
for($i = 0; $i<$count; $i++) {
$randomNumber .= substr($chars, rand($startIndex, $endIndex), 1);
}
return $randomNumber;
}
/**
* 获取文件全路径
* @param type $filename
* @param type $type
* @return string
*/
public static function getFileUrl($fileName)
{
return $fileName? Url::to('@resDomain' . $fileName): '';
}
/**
* 判断当前日期是否是可用日期
* @param type $startData
* @param type $endData
*/
public static function isAvailableDate($start, $end)
{
$current = date('Y-m-d');
$start = $start?date('Y-m-d', strtotime($start)):$current;
$end = $end?date('Y-m-d', strtotime($end)):$current;
if($start <= $current && $end >= $current) {
return true;
} else {
return false;
}
}
/**
* 添加get查询数据
* @param type $values
*/
public static function addQueryParams($values)
{
Yii::$app->request->setQueryParams(\yii\helpers\ArrayHelper::merge(Yii::$app->request->get(), $values));
}
/**
* 获取post数据, 可附加额外数据
* @param array $values 附加数据,必须是数组形式
* @param string $formName 指定数据附加到特定键
*/
public static function getPost(array $values, $formName = null)
{
if(Yii::$app->request->isPost) {
$data = Yii::$app->request->post();
if($formName !== null) {
$data[$formName] = ArrayHelper::merge($data[$formName], $values);
} else {
$data = ArrayHelper::merge($data, $values);
}
return $data;
} else {
return;
}
}
/**
* 获取到下个给定时间点还有多长时间,单位 秒
* @param mixed $time 可以是一个时间字符串,也可以是时间字符串数组
* 格式为 h:m:s
* @return $duration 返回值为到下个时间点还有多长时间,以秒为单位
*/
public static function getDuration($time)
{
if(!is_array($time)) {
$time = (array)$time;
}
$seconds = [];
foreach($time as $value) {
$timeArray = explode(':', $value);
if(3 != count($timeArray)) {
return false;
}
list($hour, $minute, $second) = $timeArray;
if((int)$hour < 0 || (int)$hour > 23 || (int)$minute < 0 || (int)$minute > 59 || (int)$second < 0 || (int)$second > 59) {
return false;
}
$seconds[] = $hour * 3600 + $minute * 60 + $second;
}
sort($seconds);
$currentTimeSecond = idate('H') * 3600 + idate('i') * 60 + idate('s');
foreach($seconds as $second) {
if(($second - $currentTimeSecond) > 0) {
return $second - $currentTimeSecond;
}
}
return $seconds[0] + (24 * 3600 - $currentTimeSecond);
}
/**
* 保留小数位数,向下取数
* @param float $number //数字
* @param int $precision //精度
* 例如, roundDown(1.20058, 4) return 1.2005
*/
public static function roundDown($number, $precision)
{
$pow = pow(10, (int)$precision);
return floor($number*$pow)/$pow;
}
/**
* 获取一条错误信息
* @param type $errors
* @return type
*/
public static function getFirstError($errors,$defaultError = null)
{
if(count($errors) > 0){
foreach($errors as $error) {
return $error[0];
}
}
$defaultError = '请求数据有误';
return $defaultError;
}
/**
* 格式化数字
* @param int $num
* @return string
*/
public static function formatNumber($num)
{
return ($num/100000000 > 1) ? sprintf('%.2f', $num/100000000).'亿' : (($num/10000 > 1) ? sprintf('%.2f', $num/10000).'万' : sprintf('%.2f', $num));
}
/**
* 获取配置参数
* @param string $moduleId 模块ID
* @param mixed $keys
* @param mixed $default 默认值
*/
public static function getModuleParams($moduleId, $keys, $default = null)
{
if(is_string($keys) && isset(Yii::$app->params[$moduleId][$keys])) {
return Yii::$app->params[$moduleId][$keys];
} elseif(is_array($keys) && isset(Yii::$app->params[$moduleId])) {
$params = Yii::$app->params[$moduleId];
foreach($keys as $key) {
if(isset($params[$key])) {
$params = $params[$key];
} else {
return $default;
}
}
return $params;
}
return $default;
}
/**
* 获取上传文件目录
* @param string $moduleId 模块ID
* @param array $moduleSubDir 模块子目录
*/
public static function getUploadDir($moduleId, $moduleSubdir = null)
{
$uploadDir = '/' . $moduleId;
if(is_array($moduleSubdir)) {
foreach($moduleSubdir as $dirName) {
$uploadDir .= '/' . $dirName;
}
}
return $uploadDir;
}
/**
* 复制文件夹及子目录文件
* @param string $source
* @param string $destination
*/
public static function xCopy($source, $destination)
{
if(!is_dir($source)) {
return;
}
FileHelper::createDirectory($destination, 0755, true);
$handle = opendir($source);
while (($file = readdir($handle)) !== false) {
if ($file === '.' || $file === '..') {
continue;
}
$path = $source . DIRECTORY_SEPARATOR . $file;
if (is_dir($path)) {
static::xCopy($path, $destination . DIRECTORY_SEPARATOR . $file);
} else {
copy($path, $destination . DIRECTORY_SEPARATOR . $file);
}
}
closedir($handle);
}
/**
* 压缩文件或文件夹
* @param string $source 文件夹或文件路径
*/
public static function folderToZip($source, &$zipArchive, $exclusiveLength)
{
if (is_dir($source) || is_file($source)) {
$handle = opendir($source);
while (($file = readdir($handle)) !== false) {
if ($file === '.' || $file === '..') {
continue;
}
$path = $source . DIRECTORY_SEPARATOR . $file;
$localPath = substr($path, $exclusiveLength);
if (is_file($path)) {
$zipArchive->addFile($path, $localPath);
} elseif (is_dir($path)) {
$zipArchive->addEmptyDir($localPath);
static::folderToZip($path, $zipArchive, $exclusiveLength);
}
}
closedir($handle);
}
}
/**
* 压缩文件夹
* @param string $source
*/
public static function zipDir($source)
{
$pathinfo = pathinfo($source);
$basename = $pathinfo['basename'];
$dirname = $pathinfo['dirname'];
$zipArchive = new \ZipArchive();
$zipArchive->open($dirname . DIRECTORY_SEPARATOR . $basename . '.zip', \ZipArchive::CREATE);
$exclusiveLength = strlen($dirname) + 1;
static::folderToZip($source, $zipArchive, $exclusiveLength);
$zipArchive->close();
}
public static function unZip($source)
{
$pathinfo = pathinfo($source);
$dirname = $pathinfo['dirname'];
$zipArchive = new \ZipArchive();
$resource = $zipArchive->open($source);
if ($resource === true) {
$zipArchive->extractTo($dirname);
$zipArchive->close();
}
}
/**
* 生成全球唯一标识uuid
* @param string $source
*/
public function uuid(){
if (function_exists('com_create_guid')) {
return com_create_guid();
} else {
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
return $uuid;
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
* Date: 2018/12/18
* Time: 16:56
*/
namespace common\models\psources;
use common\core\BaseActiveRecord;
......@@ -12,6 +13,13 @@ use Yii;
class CoinBannerItem extends BaseActiveRecord
{
const STATUS_ON = 1; //激活
const STATUS_OFF = 0; //未激活
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public static function getDb()
{
return Yii::$app->get('p_sources');
......@@ -22,6 +30,40 @@ class CoinBannerItem extends BaseActiveRecord
return '{{coin_banner_item}}';
}
public function rules()
{
return [
[['image_url', 'platform_id', 'sort', 'status', 'type'], 'required'],
[['platform_id', 'sort', 'type', 'status', 'type'], 'integer'],
['banner_url', 'default', 'value' => '#'],
[['banner_url', 'title'], 'safe'],
[['image_url'], 'url'],
];
}
public function attributeLabels()
{
return [
'banner_url' => 'banner跳转链接',
'image_url' => 'banner图片链接',
'title' => 'banner标题',
'platform_id' => '所属平台',
'sort' => 'banner排序',
'status' => 'banner状态',
'type' => 'banner类型'
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['banner_url', 'image_url', 'title', 'platform_id', 'sort', 'status', 'type'],
self:: SCENARIOS_UPDATE => ['id', 'banner_url', 'image_url', 'title', 'platform_id', 'sort', 'status', 'type'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public static function getItems($condition = [])
{
return self::find()->joinWith('platform')->where($condition)->asArray()->all();
......@@ -34,6 +76,6 @@ class CoinBannerItem extends BaseActiveRecord
public function getPlatform()
{
return $this->hasOne(CoinPlatform::className(), ['id'=>'platform_id']);
return $this->hasOne(CoinPlatform::className(), ['id' => 'platform_id']);
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinCurrency extends BaseActiveRecord
{
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{coin_currency}}';
}
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public function rules()
{
return [
[['pj_id', 'pj_name'], 'required'],
[['pj_symbol', 'lang'], 'safe'],
[['platform_id', 'currency_id'], 'integer'],
];
}
public function attributeLabels()
{
return [
'platform_id' => '钱包Id',
'currency_id' => '货币Id',
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['pj_id', 'pj_name', 'pj_symbol', 'lang'],
self:: SCENARIOS_UPDATE => ['id', 'pj_id', 'pj_name', 'pj_symbol', 'lang'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
class CoinIssueChainRecord extends CommonActiveRecord
{
//定义场景
const SCENARIOS_PRE_CREATE = 'create';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_issue_chain_record}}';
}
public function rules()
{
return [
[['pre_create_tx', 'pre_send_transaction', 'pre_query_transaction', 'finish_tx', 'finish_send_transaction', 'finish_query_transaction', 'issue_coin_id'], 'required'],
[['issue_coin_id'], 'integer'],
[['finish_tx'], 'safe']
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_PRE_CREATE => ['pre_create_tx', 'pre_send_transaction', 'pre_query_transaction', 'finish_tx', 'finish_send_transaction', 'finish_query_transaction', 'issue_coin_id'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function getCoin()
{
return $this->hasOne(CoinIssueCoin::className(), ['id' => 'issue_coin_id']);
}
public function getAdvance()
{
return $this->hasOne(CoinIssueCoin::className(), ['id' => 'issue_coin_id'])->where(['status' => CoinIssueCoin::STATUS_ADVANCE]);
}
public function getConfirm()
{
return $this->hasOne(CoinIssueCoin::className(), ['id' => 'issue_coin_id'])->where(['>', 'status', CoinIssueCoin::STATUS_CONFIRM]);
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use yii\db\Expression;
class CoinIssueCoin extends CommonActiveRecord
{
const UN_PAY = 0;
const ALLOW_PAY = 1;
const SUCCESS_PAY = 2;
const STATUS_ADVANCE = 0; //预发行,待确认
const STATUS_PEDDING = 1; //预发行成功,待用户确认
const STATUS_CANCEL = 2; //用户点击撤消后的状态
const STATUS_CANCEL_SUCCESS = 3; //撤消成功
const STATUS_CANCEL_FAILED = 4; //撤消失败
const STATUS_CONFIRM = 5; //用户点击确认后的状态
const STATUS_ALLOW = 6; //开启人工审核,管理员后台点击通过后的状态 (未开启人工审核,跳过该状态)
const STATUS_REFUSE = 7; //开启人工审核,管理员后台点击拒绝后的状态 (未开启人工审核,跳过该状态)
const STATUS_SUCCESS = 8; //发行成功
const STATUS_FAILED = 9; //(预)发行失败
const TYPE_NO = 0; //不是增发
const TYPE_YES = 1; //是增发
const ISSUE_TOKEN = 'issue_token';
const REVOKE_TOKEN = 'revoke_token';
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
const SCENARIOS_CANCEL = 'cancel';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_issue_coin}}';
}
public function rules()
{
return [
[['name', 'symbol', 'total', 'owner', 'introduction', 'category', 'type', 'platform_id', 'chain_id', 'charge_unit', 'charge'], 'required'],
[['total', 'category', 'type', 'platform_id', 'chain_id'], 'integer'],
[['introduction', 'charge_unit'], 'string', 'length' => [1, 20]],
['symbol', 'string', 'length' => [1, 6]],
['name', 'string', 'length' => [1, 20]],
#['status', 'in', 'range' => [1, 2, 0]],
['name', 'verfiyName'],
['symbol', 'verfiySymbol'],
['total', 'verfiyAmount']
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['name', 'symbol', 'total', 'owner', 'introduction', 'category', 'type', 'platform_id', 'chain_id', 'charge_unit', 'charge'],
self:: SCENARIOS_UPDATE => ['status'],
self:: SCENARIOS_CANCEL => ['status'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function verfiyName($attribute, $params)
{
//增发
if (CoinIssueCoin::TYPE_YES == $this->type) {
$model = CoinIssueCoin::find()->where(['name' => $this->name, 'owner' => $this->owner, 'platform_id' => $this->platform_id, 'status' => CoinIssueCoin::STATUS_SUCCESS])->orderBy('id desc')->one();
if (false == $model) {
$this->addError($attribute, '该Token币种尚未发行');
return false;
}
if (0 == $model->category) {
$this->addError($attribute, '该Token币种不可增发');
return false;
}
}
//非增发
if (CoinIssueCoin::TYPE_NO == $this->type) {
$model = CoinIssueCoin::find()
->where(['name' => $this->name, 'platform_id' => $this->platform_id])
->andWhere(['<>', 'status', CoinIssueCoin::STATUS_FAILED])
->orderBy('id desc')->one();
if ($model) {
$this->addError($attribute, 'Token名称已存在');
return false;
}
}
}
public function verfiySymbol($attribute, $params)
{
if (!preg_match('/^[A-Z]+$/', $this->symbol)) {
$this->addError($attribute, 'Token简称必须大写');
return false;
}
if (CoinIssueCoin::TYPE_YES == $this->type) {
$model = CoinIssueCoin::find()->where(['symbol' => $this->symbol, 'owner' => $this->owner, 'platform_id' => $this->platform_id, 'status' => CoinIssueCoin::STATUS_SUCCESS])->orderBy('id desc')->one();
if (false == $model) {
$this->addError($attribute, '该Token币种尚未发行');
return false;
}
if (0 == $model->category) {
$this->addError($attribute, '该Token币种不可增发');
return false;
}
}
if (CoinIssueCoin::TYPE_NO == $this->type) {
$model = CoinIssueCoin::find()
->where(['symbol' => $this->symbol, 'platform_id' => $this->platform_id])
->andWhere(['<>', 'status', CoinIssueCoin::STATUS_FAILED])
->orderBy('id desc')->one();
if ($model) {
$this->addError($attribute, 'Token名称已存在');
return false;
}
}
}
public function verfiyAmount($attribute, $params)
{
if (CoinIssueCoin::TYPE_YES == $this->type) {
if ($this->$attribute > 10) {
$this->addError($attribute, '增发发行量不能超过10亿');
return false;
}
}
$issue_record = CoinIssueCoin::find()->where(['platform_id' => $this->platform_id, 'symbol' => $this->symbol, 'status' => CoinIssueCoin::STATUS_SUCCESS])->sum('total');
$issue_record = empty($issue_record) ? 0 : $issue_record;
if ($issue_record + $this->$attribute > 900) {
$this->addError($attribute, '最大发行量900亿,目前已发行' . $issue_record . '亿');
return false;
}
}
public function attributeLabels()
{
return [
'name' => 'Token全称',
'symbol' => 'Token简称',
'total' => '发行数量',
'owner' => '接收地址',
'introduction' => 'Token简介',
'category' => '是否增发',
'chain_id' => '平行链名称',
'msg' => '失败原因',
'status' => '状态',
'charge_unit' => '手续费',
];
}
public function attributes()
{
return array_merge(parent::attributes(), ['issue_charge', 'url', 'chain_name']);
}
/**
* 获取状态数组
* @return array
*/
public static function getAgentStatus()
{
return [
self::STATUS_SUCCESS => '发行成功',
self::STATUS_FAIL => '发行失败',
];
}
public function getChain()
{
return $this->hasOne(CoinPlatformWithHold::className(), ['id' => 'chain_id']);
}
public function getPlatform()
{
return $this->hasOne(CoinPlatform::className(), ['id' => 'platform_id']);
}
public function getTransfer()
{
return $this->hasOne(CoinIssueChainRecord::className(), ['issue_coin_id' => 'id']);
}
public function getRevoke()
{
return $this->hasOne(CoinIssueRevokeRecord::className(), ['issue_coin_id' => 'id']);
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
class CoinIssueRecord extends CommonActiveRecord
{
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_issue_record}}';
}
public function rules()
{
return [
[['platform_id', 'total'], 'required'],
[['total', 'platform_id'], 'integer'],
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['platform_id', 'total'],
self:: SCENARIOS_UPDATE => ['platform_id', 'total'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
class CoinIssueRevokeRecord extends CommonActiveRecord
{
//定义场景
const SCENARIOS_CREATE = 'create';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coins_issue_revoke_record}}';
}
public function rules()
{
return [
[['revoke_tx', 'revoke_send_transaction', 'issue_coin_id'], 'required'],
[['issue_coin_id'], 'integer'],
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['revoke_tx', 'revoke_send_transaction', 'issue_coin_id', 'revoke_query_transaction'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function getCoin()
{
return $this->hasOne(CoinIssueCoin::className(), ['id' => 'issue_coin_id']);
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ namespace common\models\psources;
class CoinPlatform extends BaseActiveRecord
{
public static function tableName()
{
return '{{%coin_platform}}';
......@@ -18,8 +19,8 @@ class CoinPlatform extends BaseActiveRecord
/**
* 获取钱包信息列表
*
* @param int $page
* @param int $limit
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
......@@ -30,7 +31,7 @@ class CoinPlatform extends BaseActiveRecord
$query = $query->andWhere($item);
}
$count = $query->count();
$data = $query->offset(($page - 1) * 10)->limit($limit)->asArray()->all();
$data = $query->offset(($page - 1) * 10)->limit($limit)->asArray()->all();
return ['count' => $count, 'data' => $data];
}
......@@ -73,4 +74,24 @@ class CoinPlatform extends BaseActiveRecord
return ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
}
}
public function attributes()
{
return array_merge(parent::attributes(), ['chain_name', 'charge_unit', 'tokens', 'exer']);
}
public function getChain()
{
return $this->hasOne(CoinPlatformWithHold::className(), ['id' => 'chain_id']);
}
public function getGas()
{
return $this->hasOne(CoinSupportedCoin::className(), ['id' => 'charge_unit_id']);
}
public function getCurrency()
{
return $this->hasMany(CoinSupportedCurrency::className(), ['platform_id' => 'id']);
}
}
......@@ -70,4 +70,9 @@ class CoinPlatformWithHold extends BaseActiveRecord
return ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
}
}
public function attributes()
{
return array_merge(parent::attributes(), ['tokens', 'platform_id', 'issue_charge', 'charge_unit']);
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use yii\db\Expression;
class CoinSupportedCoin extends CommonActiveRecord
{
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_supported_coin}}';
}
public function rules()
{
return [
[['platform_id', 'coin_name'], 'required'],
[['platform_id'], 'integer'],
['coin_name', 'string', 'length' => [1, 50]],
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['platform_id', 'coin_name'],
self:: SCENARIOS_UPDATE => ['platform_id', 'coin_name'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function attributeLabels()
{
return [
'platform_id' => '所属钱包',
'coin_name' => '币种名称',
];
}
public static function getList($page = 1, $limit = 10, $condition = [])
{
$query = self::find();
foreach ($condition as $item) {
$query = $query->andWhere($item);
}
$count = $query->count();
$data = $query->offset(($page - 1) * 10)->limit($limit)->asArray()->all();
return ['count' => $count, 'data' => $data];
}
public function addOne($params)
{
$params = array_filter($params, function ($value) {
if (null == $value) {
return false;
}
return true;
});
$this->setAttributes($params, false);
try {
return (bool)$this->save();
} catch (\Exception $exception) {
return ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
}
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinSupportedCurrency extends BaseActiveRecord
{
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{coin_supported_currency}}';
}
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public function rules()
{
return [
[['platform_id', 'currency_id'], 'required'],
[['platform_id', 'currency_id', 'sort'], 'integer'],
];
}
public function attributeLabels()
{
return [
'platform_id' => '钱包Id',
'currency_id' => '货币Id',
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['platform_id', 'currency_id', 'sort'],
self:: SCENARIOS_UPDATE => ['id', 'platform_id', 'currency_id', 'sort'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function attributes()
{
return array_merge(parent::attributes(), ['pj_id', 'pj_name', 'pj_symbol', 'rate']);
}
public function getCurrency()
{
return $this->hasOne(CoinCurrency::className(), ['id' => 'currency_id']);
}
public static function loadArray(array $data)
{
return self::getDb()->createCommand()->batchInsert(self::tableName(),
['platform_id', 'currency_id'],
$data)->execute();
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
use yii\web\Linkable;
use yii\web\Link;
class CommonActiveRecord extends ActiveRecord
{
public $cacheKeyStorage = []; //缓存key寄存器
public function toArray(array $fields = [], array $expand = [], $recursive = true)
{
$data = [];
$cachePrefix = __CLASS__;
$cache = Yii::$app->cache;
foreach ($this->resolveFields($fields, $expand) as $field => $definition) {
if (strpos($field, '.')) {
$fieldChunks = explode('.', $field);
$primaryKey = is_array($this->primaryKey) ? implode('-', $this->primaryKey) : $this->primaryKey;
$uniqueRelationCacheKey = "{$cachePrefix}_{$primaryKey}_{$fieldChunks[0]}";
$this->addCacheKeyToStorage($uniqueRelationCacheKey);
$relation = $cache->get($uniqueRelationCacheKey);
if (!$relation) {
$relation = $this->{$fieldChunks[0]};
$cache->set($uniqueRelationCacheKey, $relation);
}
if (is_array($relation)) {
foreach ($relation as $relatedField => $relatedObject) {
if (!is_object($relatedObject)) {
continue;
}
$data[$fieldChunks[0]][$relatedField][$fieldChunks[1]] = $this->getRelationField($relatedObject, $fieldChunks[1]);
}
} else {
if (!is_object($relation)) {
continue;
}
$data[$fieldChunks[0]][$fieldChunks[1]] = $this->getRelationField($relation, $fieldChunks[1]);
}
} else {
$data[$field] = is_string($definition) ? $this->$definition : call_user_func($definition, $this, $field);
}
}
$this->deleteStorageCaches();
if ($this instanceof Linkable) {
$data['_links'] = Link::serialize($this->getLinks());
}
return $recursive ? ArrayHelper::toArray($data) : $data;
}
/**
* This method also will check relations which are declared in [[extraFields()]]
* to determine which related fields can be returned.
* @inheritdoc
*/
protected function resolveFields(array $fields, array $expand)
{
$result = [];
foreach ($this->fields() as $field => $definition) {
if (is_integer($field)) {
$field = $definition;
}
if (empty($fields) || in_array($field, $fields, true)) {
$result[$field] = $definition;
}
}
if (empty($expand)) {
return $result;
}
$extraFieldsKeys = array_keys($this->extraFields());
foreach($expand as $expandedAttribute) {
if(in_array(explode('.',$expandedAttribute)[0], $this->extraFields())) {
$result[$expandedAttribute] = $expandedAttribute;
}else if(in_array($expandedAttribute, $extraFieldsKeys)) {
$result[$expandedAttribute] = $this->extraFields()[$expandedAttribute];
}
}
return $result;
}
/**
* Additional method to check the related model has specified field
*/
private function getRelationField($relatedRecord, $field)
{
if (!$relatedRecord->hasAttribute($field) && !$relatedRecord->isRelationPopulated($field)) {
throw new \yii\web\ServerErrorHttpException(sprintf(
"Related record '%s' does not have attribute '%s'",
get_class($relatedRecord), $field)
);
}
if($relatedRecord->hasAttribute($field)) {
return ArrayHelper::toArray($relatedRecord)[$field];
} else {
return $relatedRecord->{$field};
}
}
public static function quoteDbName($dbname)
{
return '`' . $dbname . '`';
}
/**
* 添加cache key到寄存器
* @param type $cacheKey
*/
public function addCacheKeyToStorage($cacheKey)
{
if(!in_array($cacheKey, $this->cacheKeyStorage)) {
$this->cacheKeyStorage[] = $cacheKey;
}
}
/**
* 删除寄存器里所有的cache
*/
public function deleteStorageCaches()
{
foreach($this->cacheKeyStorage as $cacheKey) {
Yii::$app->cache->delete($cacheKey);
}
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use yii\db\Expression;
use common\core\BaseActiveRecord;
use yii\behaviors\TimestampBehavior;
class ExploreApp extends BaseActiveRecord
{
const STATUS_ON = 1; //激活
const STATUS_OFF = 0; //未激活
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{explore_app}}';
}
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public function rules()
{
return [
[['name', 'icon', 'app_url', 'type', 'sort', 'status', 'platform_id', 'app_category_id'], 'required'],
[['type', 'sort', 'status', 'platform_id', 'app_category_id'], 'integer'],
['slogan', 'string', 'max' => 50],
[['slogan'], 'safe'],
[['icon'], 'url']
];
}
public function attributeLabels()
{
return [
'name' => '应用名称',
'icon' => '应用图标',
'app_url' => 'H5链接',
'slogan' => '应用宣传语',
'type' => '应用类型',
'sort' => '应用排序',
'status' => '应用状态'
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['name', 'icon', 'app_url', 'slogan', 'type', 'sort', 'status', 'platform_id', 'app_category_id'],
self:: SCENARIOS_UPDATE => ['id', 'name', 'icon', 'app_url', 'slogan', 'type', 'sort', 'status', 'platform_id', 'app_category_id'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function getAppCategory()
{
return $this->hasOne(ExploreAppCategory::className(), ['id' => 'app_category_id']);
}
public static function getCasesStatus()
{
return [
self::STATUS_ON => '激活',
self::STATUS_OFF => '未激活',
];
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class ExploreAppCategory extends BaseActiveRecord
{
const STATUS_ON = 1; //激活
const STATUS_OFF = 0; //未激活
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{explore_app_category}}';
}
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public function rules()
{
return [
[['name', 'sort', 'limit', 'style', 'platform_id', 'status'], 'required'],
];
}
public function attributes()
{
return array_merge(parent::attributes(), ['apps']);
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['name', 'sort', 'limit', 'style', 'platform_id', 'status'],
self:: SCENARIOS_UPDATE => ['name', 'sort', 'limit', 'style', 'platform_id', 'status'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function attributeLabels()
{
return [
'name' => '应用分类名称',
'sort' => '应用分类排序',
'limit' => '该分类下首页可显示的应用数量',
'style' => '应用分类展示样式',
'status' => '应用分类状态'
];
}
public function getApplications()
{
return $this->hasMany(ExploreApp::className(), ['app_category_id' => 'id'])->select(['id', 'name', 'icon', 'app_url', 'slogan', 'type'])->where(['status' => ExploreApp::STATUS_ON])->orderBy('sort');
}
}
\ No newline at end of file
......@@ -246,15 +246,35 @@ class Chain33Service
return $this->send($params, 'Chain33.QueryTransaction');
}
public function getBalance($address, $execer)
public function query()
{
$params = [
"execer" => 'manage',
"funcName" => "GetConfigItem",
"payload" => ['data' => 'token-finisher']
];
return $this->send($params, 'Chain33.Query');
}
public function getBalance($address, $execer = "")
{
$params = [
'addresses' => $address,
'execer' => $execer
'execer' => $execer,
];
return $this->send($params, 'Chain33.GetBalance');
}
public function getTokenBalance($address, $execer, $tokenSymbol)
{
$params = [
'addresses' => $address,
'execer' => $execer,
'tokenSymbol' => $tokenSymbol
];
return $this->send($params, 'token.GetTokenBalance');
}
public function createNoBalanceTransaction($txHex, $payAddr, $privkey)
{
$params = [
......@@ -298,6 +318,29 @@ class Chain33Service
return $this->send($params, 'Chain33.SignRawTx');
}
public function createRawTokenPreCreateTx($params)
{
return $this->send($params, 'token.CreateRawTokenPreCreateTx');
}
public function createRawTokenFinishTx($symbol, $owner)
{
$params = [
'symbol' => $symbol,
'owner' => $owner
];
return $this->send($params, 'token.CreateRawTokenFinishTx');
}
public function createRawTokenRevokeTx($symbol, $owner)
{
$params = [
'symbol' => $symbol,
'owner' => $owner
];
return $this->send($params, 'token.CreateRawTokenRevokeTx');
}
public function getBlock2MainInfo($start, $end)
{
$params = [
......@@ -361,6 +404,26 @@ class Chain33Service
}
/**
* 查询所有预创建的token GetTokens
* @param string $execer
* @param string $funcName
* @return array
*/
public function getTokens($execer, $funcName)
{
$params = [
'execer' => $execer,
'funcName' => $funcName,
'payload' => [
'status' => 1,
'queryAll' => true,
'symbolOnly' => true
]
];
return $this->send($params, 'Chain33.Query');
}
/**
* @param array $hashes
* @return array
*/
......
<?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 Bitnasdaq extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_bitnasdaq';
protected $quotation_prefix = 'quotation_bitnasdaq_';
protected $base_url = 'https://www.bitnasdaq.com/';
public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{
return strtolower(trim($tag) . trim($aim));
}
public function setSupportedSymbol()
{
$curl = new Curl();
$api = $this->base_url . '/api/v1/ticker/24hr';
$res = $curl->get($api, false);//json
if (is_array($res)) {
foreach ($res as $item) {
$this->redis->sadd($this->supported_symbol, strtolower($item['symbol']));
}
}
}
public function setQuotation()
{
$curl = new Curl();
$api = $this->base_url . '/app/tradeMarket/coinPrice';
$res = $curl->get($api, false);
if (is_array($res) && isset($res['obj'])) {
$data = $res['obj'];
foreach ($data as $key => $item) {
$low = isset($item['minPrice']) ? $item['minPrice'] : 0;
$high = isset($item['maxPrice']) ? $item['maxPrice'] : 0;
$last = isset($item['currentExchangPrice']) ? $item['currentExchangPrice'] : 0;
$open = isset($item['openPrice']) ? $item['openPrice'] : 0;
$vol = isset($item['transactionSum']) ? $item['transactionSum'] : 0;
$cache_key = strtolower($this->quotation_prefix . str_replace('_', '', $key));
$this->redis->hmset($cache_key, 'low', $low, 'high', $high, 'last', $last, 'open', $open, 'vol', $vol);
$this->redis->sadd($this->supported_symbol, strtoupper(str_replace('_', '', $key)));
}
}
}
}
......@@ -15,7 +15,7 @@ class Boc extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_boc';
protected $quotation_prefix = 'quotation_boc_';
protected $base_url = 'http://srh.bankofchina.com/search/whpj/search.jsp';
protected $base_url = 'https://srh.bankofchina.com/search/whpj/search_cn.jsp';
public function symbolExists($tag = 'CNY', $aim = "JPY")
{
......@@ -25,6 +25,7 @@ class Boc extends Exchange implements ExchangeInterface
}
return false;
}
/**
* 转化交易对为请求变量
*
......@@ -34,7 +35,7 @@ class Boc extends Exchange implements ExchangeInterface
*/
public function formatSymbol($tag = 'CNY', $aim = 'JPY')
{
return strtoupper($tag .'_'. $aim);
return strtoupper($tag . '_' . $aim);
}
/**
......@@ -60,17 +61,19 @@ class Boc extends Exchange implements ExchangeInterface
'erectDate' => '',
'nothing' => '',
'pjname' => 1323
])->post('http://srh.bankofchina.com/search/whpj/search.jsp');
])->post('https://srh.bankofchina.com/search/whpj/search_cn.jsp');
$response = iconv('UTF-8', 'GBK//TRANSLIT',$response);
$response = iconv('UTF-8', 'GBK//TRANSLIT', $response);
$html = HtmlDomParser::str_get_html($response);
$div = ($html->find('div.BOC_main'));
foreach ($div->find('td') as $key => $e){
if($key == 5){
$key = $this->quotation_prefix . 'CNY_JPY';
$this->redis->hmset($key, 'low', $e->innertext, 'high', $e->innertext, 'last', $e->innertext);
$this->redis->sadd($this->supported_symbol, 'CNYJPY');
break;
if ($div->find('td')) {
foreach ($div->find('td') as $key => $e) {
if ($key == 5) {
$key = $this->quotation_prefix . 'CNY_JPY';
$this->redis->hmset($key, 'low', $e->innertext, 'high', $e->innertext, 'last', $e->innertext);
$this->redis->sadd($this->supported_symbol, 'CNYJPY');
break;
}
}
}
}
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Dag extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_dag';
protected $quotation_prefix = 'quotation_dag_';
protected $base_url = 'https://www.7xex.com/m/ticker/DAGUSDT';
public function symbolExists($tag = 'DAG', $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 = 'DAG', $aim = 'USDT')
{
return strtoupper($tag . $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'DAGUSDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content)) {
$key = $this->quotation_prefix . 'DAGUSDT';
$this->redis->hmset($key, 'low', $content['low'], 'high', $content['high'], 'last', $content['close'], 'open', $content['open'], 'vol', $content['volume']);
$this->redis->sadd($this->supported_symbol, 'DAGUSDT');
}
}
}
\ No newline at end of file
......@@ -44,18 +44,18 @@ class BinanceBuilder extends FactoryService
}
if (false != $condition) {
if ('price' == $condition['data_value']) {
if ('price-asc' == $condition['sort_value']) {
if ('price_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_asc, $this->start, $this->end);
}
if ('price-desc' == $condition['sort_value']) {
if ('price_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_desc, $this->start, $this->end);
}
}
if ('change' == $condition['data_value']) {
if ('change-asc' == $condition['sort_value']) {
if ('change_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_asc, $this->start, $this->end);
}
if ('change-desc' == $condition['sort_value']) {
if ('change_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_desc, $this->start, $this->end);
}
}
......@@ -114,6 +114,12 @@ class BinanceBuilder extends FactoryService
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = $close;
foreach ($this->basic_coin as $k => $coin) {
$explode_arr = explode(strtoupper($coin), strtoupper($symbol));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
}
}
$temp['low'] = $low;
$temp['high'] = $high;
$temp['open'] = $open;
......@@ -124,7 +130,7 @@ class BinanceBuilder extends FactoryService
$this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol);
}
$ticker_sort_close = Tools::arraySort($ticker, 'close');
$ticker_sort_close = Tools::arraySort($ticker, 'close_rmb');
$this->redis_ticker->del($this->supported_symbol_close_asc);
$this->redis_ticker->del($this->supported_symbol_close_desc);
foreach ($ticker_sort_close as $val) {
......
<?php
/**
* Created by PhpStorm.
* User: jiaming
* Date: 2019/8/15
* Time: 10:10
*/
namespace common\service\exchange\factory;
use common\components\Tools;
use linslin\yii2\curl\Curl;
class BitnasdaqBuilder extends FactoryService
{
protected $base_url = 'https://www.bitnasdaq.com';
protected $supported_symbol = 'supported_symbol_bitnasdaq';
protected $supported_symbol_list = 'supported_symbol_bitnasdaq_list';
protected $supported_symbol_close_asc = 'supported_symbol_close_asc_bitnasdaq';
protected $supported_symbol_close_desc = 'supported_symbol_close_desc_bitnasdaq';
protected $supported_symbol_change_asc = 'supported_symbol_change_asc_bitnasdaq';
protected $supported_symbol_change_desc = 'supported_symbol_change_desc_bitnasdaq';
protected $quotation_prefix = 'quotation_bitnasdaq_';
public function getTickerFromCache($page = 1, $condition = [])
{
$size = 0;
for ($i = 0; $i < $page; $i++) {
$size += 50;
$this->end = $size;
}
$this->start = $this->end - 50;
$this->end = $this->end - 1;
$keys = $this->redis->smembers($this->supported_symbol);
if (false == $this->redis->exists($this->supported_symbol_list)) {
foreach ($keys as $val) {
if (in_array(strtoupper($val), ['BNCUSDT', 'BTCUSDT', 'CNYTUSDT', 'ETCUSDT', 'ETHUSDT', 'GHPUSDT', 'LTCUSDT', 'BTCCNYT', 'ETCCNYT', 'ETHCNYT', 'GHPCNYT', 'LTCCNYT'])) {
$this->redis->lpush($this->supported_symbol_list, strtoupper($val));
}
}
}
if (false != $condition) {
if ('price' == $condition['data_value']) {
if ('price_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_asc, $this->start, $this->end);
}
if ('price_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_desc, $this->start, $this->end);
}
}
if ('change' == $condition['data_value']) {
if ('change_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_asc, $this->start, $this->end);
}
if ('change_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_desc, $this->start, $this->end);
}
}
} else {
$keys = $this->redis->lrange($this->supported_symbol_list, $this->start, $this->end);
}
$ticker = [];
foreach ($keys as $val) {
foreach ($this->basic_coin as $k => $coin) {
$explode_arr = explode(strtoupper($coin), strtoupper($val));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
if (false != $condition) {
list($low, $high, $close, $open, $vol) = $this->redis_ticker->hmget($this->quotation_prefix . strtoupper($val), 'low', 'high', 'last', 'open', 'vol');
} else {
list($low, $high, $close, $open, $vol) = $this->redis->hmget($this->quotation_prefix . strtolower($val), 'low', 'high', 'last', 'open', 'vol');
}
$temp = [];
$temp['symbol'] = strtoupper($explode_arr[0]) . '/' . $coin;
$temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = strtoupper($coin);
$temp['close'] = rtrim(sprintf('%.8f', floatval($close)), '0');
$temp['close_usd'] = rtrim(sprintf('%.6f', floatval($close * $this->basic_price[$coin]['usd'])), '0');
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
$temp['change'] = (false == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price[$coin]['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price[$coin]['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price[$coin]['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $low * $this->basic_price[$coin]['rmb']);
$temp['vol'] = (float)sprintf("%0.4f", $vol);
$temp['optional'] = false;
$temp['platform_zh'] = '比特纳斯达克';
$temp['platform_us'] = 'BitNasdaq';
array_push($ticker, $temp);
}
}
}
$this->code = 0;
$data = [
'ticker' => $ticker,
'page' => [
'pageSize' => 50,
'currentPage' => (int)$page,
]
];
return ['code' => $this->code, 'data' => $data];
}
public function TickerSort()
{
$len = $this->redis->llen($this->supported_symbol_list);
$ticker = [];
for ($i = 0; $i < $len; $i++) {
$symbol = $this->redis->lindex($this->supported_symbol_list, $i);
list($close, $open, $low, $high, $vol) = $this->redis->hmget($this->quotation_prefix . strtolower($symbol), 'last', 'open', 'low', 'high', 'vol');
if ('0.00000000' == $close) continue;
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = $close;
foreach ($this->basic_coin as $k => $coin) {
$explode_arr = explode(strtoupper($coin), strtoupper($symbol));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
}
}
$temp['low'] = $low;
$temp['high'] = $high;
$temp['open'] = $open;
$temp['vol'] = $vol;
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
array_push($ticker, $temp);
$key = $this->quotation_prefix . strtoupper($symbol);
$this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol);
}
$ticker_sort_close = Tools::arraySort($ticker, 'close_rmb');
$this->redis_ticker->del($this->supported_symbol_close_asc);
$this->redis_ticker->del($this->supported_symbol_close_desc);
foreach ($ticker_sort_close as $val) {
$this->redis_ticker->lpush($this->supported_symbol_close_asc, strtoupper($val['symbol']));
$this->redis_ticker->rpush($this->supported_symbol_close_desc, strtoupper($val['symbol']));
}
$ticker_change_close = Tools::arraySort($ticker, 'change');
$this->redis_ticker->del($this->supported_symbol_change_asc);
$this->redis_ticker->del($this->supported_symbol_change_desc);
foreach ($ticker_change_close as $val) {
$this->redis_ticker->lpush($this->supported_symbol_change_asc, strtoupper($val['symbol']));
$this->redis_ticker->rpush($this->supported_symbol_change_desc, strtoupper($val['symbol']));
}
}
public function getHotTicker($symbol = [])
{
if (empty($symbol)) {
return ['code' => $this->code, 'ticker' => []];
}
$ticker = [];
foreach ($symbol as $val) {
list($low, $high, $close, $open, $vol) = $this->redis->hmget($this->quotation_prefix . strtolower($val), 'low', 'high', 'last', 'open', 'vol');
$explode_arr = explode('usdt', $val);
$temp = [];
$temp['symbol'] = strtoupper($explode_arr[0]) . '/USDT';
$temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = 'USDT';
$temp['close'] = (float)sprintf("%0.6f", $close);
$temp['close_usd'] = (float)sprintf("%0.6f", $close * $this->basic_price['USDT']['usd']);
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price['USDT']['rmb']);
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['rmb']);
$temp['vol'] = (float)sprintf("%0.4f", $vol);
array_push($ticker, $temp);
}
if (count($ticker) > 0) {
$this->code = 0;
}
return ['code' => $this->code, 'ticker' => $ticker];
}
}
<?php
/**
* Created by PhpStorm.
* User: jiaming
* Date: 2019/8/15
* Time: 10:10
*/
namespace common\service\exchange\factory;
use common\components\Tools;
use linslin\yii2\curl\Curl;
class DagBuilder extends FactoryService
{
protected $supported_symbol = 'supported_symbol_dag';
protected $quotation_prefix = 'quotation_dag_';
public function getHotTicker($symbol = [])
{
if (empty($symbol)) {
return ['code' => $this->code, 'ticker' => []];
}
$ticker = [];
foreach ($symbol as $val) {
list($low, $high, $close, $open, $vol) = $this->redis->hmget($this->quotation_prefix . strtoupper($val), 'low', 'high', 'last', 'open', 'vol');
$explode_arr = explode('usdt', $val);
$temp = [];
$temp['symbol'] = strtoupper($explode_arr[0]) . '/USDT';
$temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = 'USDT';
$temp['close'] = (float)sprintf("%0.6f", $close);
$temp['close_usd'] = (float)sprintf("%0.6f", $close * $this->basic_price['USDT']['usd']);
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price['USDT']['rmb']);
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['rmb']);
$temp['vol'] = (float)sprintf("%0.4f", $vol);
array_push($ticker, $temp);
}
if (count($ticker) > 0) {
$this->code = 0;
}
return ['code' => $this->code, 'ticker' => $ticker];
}
}
......@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl;
abstract class FactoryService
{
protected $code = -1;
protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY'];
protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY', 'CNYT'];
protected $basic_price = [];
protected $redis;
......@@ -31,6 +31,7 @@ abstract class FactoryService
"btc,btc",
"usdt,ethereum",
"bty,bty",
"cnyt,bitnasdaqchain"
]
];
$params = json_encode($data);
......
......@@ -64,18 +64,18 @@ class HuobiBuilder extends FactoryService
}
if (false != $condition) {
if ('price' == $condition['data_value']) {
if ('price-asc' == $condition['sort_value']) {
if ('price_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_asc, $this->start, $this->end);
}
if ('price-desc' == $condition['sort_value']) {
if ('price_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_desc, $this->start, $this->end);
}
}
if ('change' == $condition['data_value']) {
if ('change-asc' == $condition['sort_value']) {
if ('change_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_asc, $this->start, $this->end);
}
if ('change-desc' == $condition['sort_value']) {
if ('change_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_desc, $this->start, $this->end);
}
}
......@@ -97,8 +97,8 @@ class HuobiBuilder extends FactoryService
$temp['symbol'] = strtoupper($explode_arr[0]) . '/' . $coin;
$temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = strtoupper($coin);
$temp['close'] = rtrim(sprintf('%.8f', floatval($close)),'0');
$temp['close_usd'] = rtrim(sprintf('%.6f', floatval($close * $this->basic_price[$coin]['usd'])),'0');
$temp['close'] = rtrim(sprintf('%.8f', floatval($close)), '0');
$temp['close_usd'] = rtrim(sprintf('%.6f', floatval($close * $this->basic_price[$coin]['usd'])), '0');
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
$temp['change'] = (false == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price[$coin]['usd']);
......@@ -135,6 +135,12 @@ class HuobiBuilder extends FactoryService
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = $close;
foreach ($this->basic_coin as $k => $coin) {
$explode_arr = explode(strtoupper($coin), strtoupper($symbol));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
}
}
$temp['low'] = $low;
$temp['high'] = $high;
$temp['open'] = $open;
......@@ -145,7 +151,7 @@ class HuobiBuilder extends FactoryService
$this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol);
}
$ticker_sort_close = Tools::arraySort($ticker, 'close');
$ticker_sort_close = Tools::arraySort($ticker, 'close_rmb');
$this->redis_ticker->del($this->supported_symbol_close_asc);
$this->redis_ticker->del($this->supported_symbol_close_desc);
foreach ($ticker_sort_close as $val) {
......@@ -162,13 +168,12 @@ class HuobiBuilder extends FactoryService
}
}
public function getHotTicker()
public function getHotTicker($symbol = [])
{
$symbol = [
'btcusdt',
'ethusdt',
'eosusdt'
];
if (empty($symbol)) {
return ['code' => $this->code, 'ticker' => []];
}
$ticker = [];
foreach ($symbol as $val) {
list($low, $high, $close, $open, $vol) = $this->redis->hmget($this->quotation_prefix . strtolower($val), 'low', 'high', 'last', 'open', 'vol');
......
......@@ -28,18 +28,18 @@ class ZhaobiBuilder extends FactoryService
$this->end = 50;
if (false != $condition) {
if ('price' == $condition['data_value']) {
if ('price-asc' == $condition['sort_value']) {
if ('price_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_asc, $this->start, $this->end);
}
if ('price-desc' == $condition['sort_value']) {
if ('price_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_close_desc, $this->start, $this->end);
}
}
if ('change' == $condition['data_value']) {
if ('change-asc' == $condition['sort_value']) {
if ('change_asc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_asc, $this->start, $this->end);
}
if ('change-desc' == $condition['sort_value']) {
if ('change_desc' == $condition['sort_value']) {
$keys = $this->redis_ticker->lrange($this->supported_symbol_change_desc, $this->start, $this->end);
}
}
......@@ -103,13 +103,21 @@ class ZhaobiBuilder extends FactoryService
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = number_format($close, 6, '.', '');
foreach ($this->basic_coin as $k => $coin) {
$explode_arr = explode(strtoupper($coin), strtoupper($symbol));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
}
if ('SFTCNY' == strtoupper($symbol) || 'BTYCCNY' == strtoupper($symbol) || 'USDTCCNY' == strtoupper($symbol)) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * 1);
}
}
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
array_push($ticker, $temp);
$key = $this->quotation_prefix . strtoupper($symbol);
$this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol);
}
$ticker_sort_close = Tools::arraySort($ticker, 'close');
$ticker_sort_close = Tools::arraySort($ticker, 'close_rmb');
$this->redis_ticker->del($this->supported_symbol_close_asc);
$this->redis_ticker->del($this->supported_symbol_close_desc);
foreach ($ticker_sort_close as $val) {
......@@ -159,13 +167,34 @@ class ZhaobiBuilder extends FactoryService
return ['code' => $this->code, 'notice' => $data];
}
protected function arraySort($array, $keys, $sort = SORT_DESC)
public function getHotTicker($symbol = [])
{
$keysValue = [];
foreach ($array as $k => $v) {
$keysValue[$k] = $v[$keys];
if (empty($symbol)) {
return ['code' => $this->code, 'ticker' => []];
}
$ticker = [];
foreach ($symbol as $val) {
list($low, $high, $close, $open, $vol) = $this->redis->hmget($this->quotation_prefix . strtolower($val), 'low', 'high', 'last', 'open', 'vol');
$explode_arr = explode('usdt', $val);
$temp = [];
$temp['symbol'] = strtoupper($explode_arr[0]) . '/USDT';
$temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = 'USDT';
$temp['close'] = (float)sprintf("%0.6f", $close);
$temp['close_usd'] = (float)sprintf("%0.6f", $close * $this->basic_price['USDT']['usd']);
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price['USDT']['rmb']);
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['rmb']);
$temp['vol'] = (float)sprintf("%0.4f", $vol);
array_push($ticker, $temp);
}
if (count($ticker) > 0) {
$this->code = 0;
}
array_multisort($keysValue, $sort, $array);
return $array;
return ['code' => $this->code, 'ticker' => $ticker];
}
}
\ No newline at end of file
......@@ -38,7 +38,12 @@ class TrusteeShipService
}
if (!empty($params)) {
$ch->setGetParams($params);
if ('GET' == strtoupper($method)) {
$ch->setGetParams($params);
}
if ('POST' == strtoupper($method)) {
$ch->setPostParams($params);
}
}
$result = $ch->$method($this->urlBuild($uri), false);
......@@ -73,5 +78,31 @@ class TrusteeShipService
return $this->send("GET", $uri, $params);
}
public function getManualList($params = [])
{
$uri = 'backend/user/manual-real-list';
return $this->send("GET", $uri, $params);
}
public function verifyReal($params = [])
{
$uri = 'backend/user/verify-real';
return $this->send("POST", $uri, $params);
}
public function refuseReal($params = [])
{
$uri = 'backend/user/refuse-real';
return $this->send("POST", $uri, $params);
}
public function revokeReal($params = [])
{
$uri = 'backend/user/revoke-real';
return $this->send("POST", $uri, $params);
}
}
......@@ -207,36 +207,5 @@ class CrossChainController extends Controller
$this->queryTransaction($node_params, $result['result']['tx']['next']);
}
return $result;
// if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
// if (isset($result['result']['tx']['next'])) {
// $this->queryTransaction($node_params, $result['result']['tx']['next']);
// }
// }
//
// if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']){
// if (isset($result['result']['tx']['next'])) {
// $this->queryTransaction($node_params, $result['result']['tx']['next']);
// }
// }
//
// return $result;
// if (isset($result['result']['receipt']) && is_array($result['result']['receipt']['logs'])){
// foreach ($result['result']['receipt']['logs'] as $log) {
// if (isset($log['tyName']) && 'logerr' == strtolower($log['tyName'])){
// return $result;
// }
// }
// }
// static $result = [];
// $service = new Chain33Service($node_params);
// $result = $service->QueryTransaction($send_result);
// echo json_encode($result) . PHP_EOL;
// if (isset($result['result']['tx']['next'])) {
// $this->queryTransaction($node_params, $result['result']['tx']['next']);
// }
// return $result;
}
}
This diff is collapsed.
......@@ -2,19 +2,18 @@
namespace console\controllers;
use common\business\Chain33Business;
use common\models\psources\CoinGameBet;
use common\service\chain33\Chain33Service;
use common\service\exchange\ExchangeBuilderFactory;
use common\service\exchange\ExchangeFactory;
use yii\console\Controller;
use Yii;
use linslin\yii2\curl\Curl;
use yii\console\Controller;
use voku\helper\HtmlDomParser;
use common\models\psources\CoinSupportedCurrency;
use common\service\exchange\ExchangeBuilderFactory;
class TickerController extends Controller
{
public function actionSort()
{
$class = ['Binance', 'Huobi', 'Zhaobi'];
$class = ['Binance', 'Huobi', 'Zhaobi', 'Bitnasdaq'];
foreach ($class as $val) {
go(function () use ($val) {
\Co::sleep(0.5);
......@@ -22,13 +21,47 @@ class TickerController extends Controller
$ticker_builder->TickerSort();
});
}
echo date('Y-m-d H:i:s') . '排序更新成功' . PHP_EOL;
return 0;
}
public function actionHot()
{
$ticker_builder = ExchangeBuilderFactory::create('Huobi');
$ticker_builder->hotTickerUpdate();
echo date('Y-m-d H:i:s') .'更新成功' . PHP_EOL;
echo date('Y-m-d H:i:s') . '更新成功' . PHP_EOL;
return 0;
}
public function actionCurrency()
{
$currency_model = CoinSupportedCurrency::find()->groupBy('currency_id')->all();
$curl = new Curl();
foreach ($currency_model as $val) {
if (1111 == $val->currency->pj_id) continue;
go(function () use ($val, $curl) {
\Co::sleep(0.5);
$response = $curl->setPostParams([
'erectDate' => '',
'nothing' => '',
'pjname' => $val->currency->pj_id
])->post('https://srh.bankofchina.com/search/whpj/search_cn.jsp');
$response = iconv('UTF-8', 'GBK//TRANSLIT', $response);
$html = HtmlDomParser::str_get_html($response);
$div = ($html->find('div.BOC_main'));
if ($div->find('td')) {
foreach ($div->find('td') as $key => $e) {
if ($key == 5) {
$key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol;
$currency = rtrim(sprintf('%.6f', 1 / ($e->innertext / 100)), '0');
Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency);
}
}
}
});
}
echo date('Y-m-d H:i:s') . '计价货币更新成功' . PHP_EOL;
return 0;
}
}
\ No newline at end of file
<?php
namespace wallet\controllers;
use Yii;
use yii\data\Pagination;
use wallet\base\BaseController;
use common\models\psources\CoinBannerItem;
class BannerController extends BaseController
{
public function actionType()
{
$data = array_unique(Yii::$app->params['banner_type']);
return ['code' => 0, 'msg' => 'success', 'data' => $data];
}
public function actionIndex()
{
$msg = 'ok';
$code = 0;
$data = null;
if (Yii::$app->request->isGet) {
$type = Yii::$app->request->get('type', 0);
$page = Yii::$app->request->get('page', 1);
$size = Yii::$app->request->get('size', 10);
$platform_id = Yii::$app->request->get('platform_id', 0);
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$query = CoinBannerItem::find()->where(['platform_id' => $platform_id])->orderBy('sort');
if (false != $type) {
$query->andWhere(['type' => $type]);
}
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]);
$models = $query->offset($pages->offset)
->limit($pages->limit)
->all();
$data = [
'list' => $models,
'page' => [
'pageCount' => $pages->pageCount,
'pageSize' => $size,
'currentPage' => (int)$page,
]
];
}
if (Yii::$app->request->isPost) {
$model = new CoinBannerItem();
$model->setScenario(CoinBannerItem::SCENARIOS_CREATE);
$model->load(Yii::$app->request->post(), '');
if (!$model->validate()) {
$msg = $model->errors;
$code = -1;
goto doEnd;
}
$model->save();
}
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionUpdate()
{
$msg = 'ok';
$code = 0;
$data = null;
$group = Yii::$app->request->getGroup();
$platform_id = Yii::$app->request->getPlatformId();
if (Yii::$app->request->isGet) {
$id = Yii::$app->request->get('id');
if ('administrator' == $group) {
$data = CoinBannerItem::find()->where(['id' => $id])->asArray()->one();
} else {
$data = CoinBannerItem::find()->where(['platform_id' => $platform_id, 'id' => $id])->asArray()->one();
}
goto doEnd;
}
if (Yii::$app->request->isPut) {
$params = Yii::$app->request->post();
$id = isset($params['id']) ? $params['id'] : null;
if (false == $id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$model = CoinBannerItem::findOne($id);
if ('administrator' != $group && $model->platform_id != $platform_id) {
$msg = '无权修改';
$code = -1;
goto doEnd;
}
$model->setScenario(CoinBannerItem::SCENARIOS_UPDATE);
$model->load(array_merge(Yii::$app->request->post(), ['platform_id' => $model->platform_id]), '');
if (!$model->validate()) {
$msg = $model->errors;
$code = -1;
goto doEnd;
}
$model->save();
}
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionRemove()
{
$msg = 'ok';
$code = 0;
$data = null;
$group = Yii::$app->request->getGroup();
$platform_id = Yii::$app->request->getPlatformId();
$id = Yii::$app->request->get('id');
if (false == $id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
if (Yii::$app->request->isDelete) {
$model = CoinBannerItem::findOne($id);
if ('administrator' != $group && $model->platform_id != $platform_id) {
$msg = '无权删除';
$code = -1;
goto doEnd;
}
$model->delete();
}
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
This diff is collapsed.
<?php
namespace wallet\controllers;
use Yii;
use yii\data\Pagination;
use wallet\base\BaseController;
use common\models\psources\CoinBannerItem;
class ExploreBannerController extends BaseController
{
public function actionIndex()
{
$msg = 'ok';
$code = 0;
$data = null;
$platform_id = Yii::$app->request->getPlatformId();
$page = Yii::$app->request->get('page', 1);
if (Yii::$app->request->isGet) {
$query = CoinBannerItem::find()
->select('id, banner_url, image_url, title')
->where(['platform_id' => $platform_id])
->asArray();
$banner_model = $query->offset(($page - 1) * 10)->limit(10)->asArray()->all();
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => '10']);
$data = [
'list' => $banner_model,
'page' => [
'pageCount' => $pages->pageCount,
'pageSize' => 10,
'currentPage' => $page,
]
];
goto doEnd;
}
if (Yii::$app->request->isPost) {
$model = new CoinBannerItem();
$model->setScenario(CoinBannerItem::SCENARIOS_CREATE);
$params = Yii::$app->request->post();
$params['platform_id'] = $platform_id;
if ($model->load($params, '') && $model->save()) {
goto doEnd;
}
$msg = $model->errors;
$code = -1;
goto doEnd;
}
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionUpdate()
{
$msg = 'ok';
$code = 0;
$data = null;
$platform_id = Yii::$app->request->getPlatformId();
if (Yii::$app->request->isGet) {
$id = Yii::$app->request->get('id');
$data = CoinBannerItem::find()->select('id, banner_url, image_url, title')->where(['platform_id' => $platform_id, 'id' => $id])->asArray()->one();
goto doEnd;
}
if (Yii::$app->request->isPut) {
$params = Yii::$app->request->post();
$id = isset($params['id']) ? $params['id'] : null;
if (false == $id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$model = CoinBannerItem::findOne($id);
$model->setScenario(CoinBannerItem::SCENARIOS_UPDATE);
unset($params['id']);
if ($model->load($params, '') && $model->save()) {
goto doEnd;
}
$msg = $model->errors;
$code = -1;
goto doEnd;
}
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionRemove()
{
$msg = 'ok';
$code = 0;
$data = null;
$platform_id = Yii::$app->request->getPlatformId();
$id = Yii::$app->request->get('id');
if (false == $id) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
if (Yii::$app->request->isDelete) {
$model = CoinBannerItem::find()->where(['id' => $id, 'platform_id' => $platform_id])->one();
if (false == $model || !$model->delete()) {
$msg = '删除失败';
$code = -1;
goto doEnd;
}
}
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
<?php
namespace wallet\controllers;
use common\models\psources\Coin;
use common\models\psources\CoinPlatform;
use common\models\psources\CoinPlatformWithHold;
use common\models\psources\CoinSupportedCoin;
use common\service\chain33\Chain33Service;
use Yii;
use wallet\base\BaseController;
class IssueChainController extends BaseController
{
/**
* 可发行链列表
* @return array
*/
public function actionIndex()
{
$data = null;
$group = Yii::$app->request->getGroup();
if ('administrator' == $group) {
$chain_model = CoinPlatform::find()->where(['<>', 'chain_id', 0])->all();
} else {
$platform_id = Yii::$app->request->getPlatformId();
$chain_model = CoinPlatform::find()->where(['id' => $platform_id])->andWhere(['<>', 'chain_id', 0])->all();
}
if (false == $chain_model) {
$msg = '不存在的链';
$code = -1;
goto doEnd;
}
foreach ($chain_model as $key => $val) {
if (!isset(Yii::$app->params['chain_nodes'][strtoupper($val->chain->platform)])) {
unset($chain_model[$key]);
}
$val->chain_name = isset($val->chain->platform) ? $val->chain->platform : '';
unset($val->download_url);
unset($val->introduce);
unset($val->create_time);
unset($val->update_time);
}
$data = [];
foreach ($chain_model as $val) {
$data[] = $val;
}
$msg = 'ok';
$code = 0;
#$data = $chain_model;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
/**
* 发行链信息
* @return array
*/
public function actionChainInfo()
{
$data = null;
$platform_id = Yii::$app->request->getPlatformId();
if (empty($platform_id)) {
$msg = '缺少必要的参数';
$code = -1;
goto doEnd;
}
if (1 == $platform_id) {
$chain_model = CoinPlatform::find()->select('id, chain_id')->all();
} else {
$chain_model = CoinPlatform::find()->select('id, chain_id')->where(['id' => $platform_id])->all();
}
if (false == $chain_model) {
$msg = '不存在的链';
$code = -1;
goto doEnd;
}
foreach ($chain_model as &$val) {
$val->chain_name = isset($val->chain->platform) ? $val->chain->platform : '';
$coin_supported_coin = CoinSupportedCoin::find()->select('id, coin_name')->where(['platform_id' => $val->id])->asArray()->all();
$val->charge_unit = $coin_supported_coin;
}
$msg = 'ok';
$code = 0;
$data = is_array($chain_model) ? $chain_model : [$chain_model];
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
/**
* 设置手续费
* @param integer issue_charge
* @param integer charge_unit_id
* @param integer platform_id
* @return array
*/
public function actionSetCharge()
{
$data = null;
$result = Yii::$app->request->post();
$group = Yii::$app->request->getGroup();
if ('administrator' == $group) {
$platform_id = isset($result['platform_id']) ? (int)$result['platform_id'] : 0;
} else {
$platform_id = Yii::$app->request->getPlatformId();
}
$issue_charge = isset($result['issue_charge']) ? $result['issue_charge'] : '';
$charge_unit = isset($result['charge_unit']) ? strtoupper($result['charge_unit']) : '';
if (false == $charge_unit || false == $platform_id) {
$msg = '提交数据有误';
$code = -1;
goto doEnd;
}
if (floatval($issue_charge) == 0) {
$msg = '数量错误';
$code = -1;
goto doEnd;
}
$chain_model = CoinPlatform::find()->where(['id' => $platform_id])->andWhere(['<>', 'chain_id', 0])->one();
if (false == $chain_model) {
$msg = '钱包尚未开通一键发币功能,不能设置手续费';
$code = -1;
goto doEnd;
}
$chain_model->issue_charge = $issue_charge;
$chain_model->charge_unit = $charge_unit;
if (false == $chain_model->save()) {
$msg = '手续费设置失败';
$code = -1;
goto doEnd;
}
$msg = 'ok';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg];
}
/**
* 人工审核开启/关闭
* @param string manual_review
* @return array
*/
public function actionManageReview()
{
$data = null;
$group = Yii::$app->request->getGroup();
if ('administrator' != $group) {
$msg = '当前账户无权限操作';
$code = -1;
goto doEnd;
}
$manual_review = \Yii::$app->request->post('manual_review', '');
if (!in_array($manual_review, ['open', 'close'])) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
Yii::$app->redis->set('issue_chain_manual_review', $manual_review);
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg];
}
/**
* 查询所有预创建的token
* @param string execer
* @return array
*/
public function actionGetTokens()
{
$data = null;
$group = Yii::$app->request->getGroup();
if ('administrator' == $group) {
$chains = array_keys(Yii::$app->params['chain_nodes']);
$platform = CoinPlatformWithHold::find()->select('id, platform, exer')->where(['in', 'platform', $chains])->all();
} else {
$platform_id = Yii::$app->request->getPlatformId();
$chain_model = CoinPlatform::find()->select('chain_id')->where(['id' => $platform_id])->andWhere(['<>', 'chain_id', 0])->one();
if (empty($chain_model)) {
$msg = '尚未开通此功能';
$code = -1;
goto doEnd;
}
$platform = CoinPlatformWithHold::find()->select('id, platform, exer')->where(['id' => $chain_model->chain_id])->one();
if (empty($platform)) {
$msg = '尚未开通此功能';
$code = -1;
goto doEnd;
}
if (!isset(Yii::$app->params['chain_nodes'][strtoupper($platform->platform)])) {
$msg = '尚未开通此功能';
$code = -1;
goto doEnd;
}
$platform = array($platform);
}
foreach ($platform as $val) {
$val->tokens = [];
$symbol = [];
if (!empty($val->exer)) {
$node = Yii::$app->params['chain_nodes'][strtoupper($val->platform)];
$service = new Chain33Service($node);
$funcName = 'GetTokens';
$result = $service->getTokens($val->exer, $funcName);
if (isset($result['code']) && 0 == $result['code']) {
foreach ($result['result']['tokens'] as $temp) {
$symbol[] = $temp['symbol'];
}
}
$coin_model = Coin::find()->select('name')->where(['platform' => $val->platform, 'treaty' => 2])->one();
if (!empty($coin_model)) {
array_unshift($symbol, $coin_model->name);
}
array_unshift($symbol, 'BTY');
$val->tokens = $symbol;
$val->platform_id = Yii::$app->params['chain_nodes'][strtoupper($val->platform)]['platform_id'];
}
unset($val->exer);
$coin_platform = CoinPlatform::find()->select('issue_charge, charge_unit')->where(['id' => Yii::$app->params['chain_nodes'][strtoupper($val->platform)]['platform_id']])->one();
$val->issue_charge = empty($coin_platform->issue_charge) ? '' : $coin_platform->issue_charge;
$val->charge_unit = empty($coin_platform->charge_unit) ? '' : $coin_platform->charge_unit;
}
$data = $platform;
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
<?php
namespace wallet\controllers;
use common\models\psources\CoinIssueChainRecord;
use Yii;
use yii\data\Pagination;
use wallet\base\BaseController;
use common\models\psources\CoinIssueCoin;
class IssueCoinController extends BaseController
{
/**
* 申请列表
* @param integer page
* @param integer size
* @param integer status
* @param string owner
* @param integer chain_id
* @return array
*/
public function actionApplyList()
{
$platform_id = Yii::$app->request->getPlatformId();
$page = \Yii::$app->request->get('page', 1);
$size = \Yii::$app->request->get('size', 10);
$status = \Yii::$app->request->get('status', -1);
$owner = \Yii::$app->request->get('owner', '');
$chain_id = \Yii::$app->request->get('chain_id', '');
if (1 == $platform_id) {
$query = CoinIssueCoin::find()
->select('id, name, total, status, chain_id, charge_unit, charge, platform_id, owner, category, type, symbol, introduction, create_time')
->where(['in', 'status', [CoinIssueCoin::STATUS_CONFIRM, CoinIssueCoin::STATUS_ALLOW, CoinIssueCoin::STATUS_REFUSE, CoinIssueCoin::STATUS_SUCCESS, CoinIssueCoin::STATUS_FAILED]])
->orderBy('create_time desc');
} else {
$query = CoinIssueCoin::find()
->select('id, name, total, status, chain_id, charge_unit, charge, platform_id, owner, category, type, symbol, introduction, create_time')
->where(['platform_id' => $platform_id])
->andWhere(['in', 'status', [CoinIssueCoin::STATUS_CONFIRM, CoinIssueCoin::STATUS_ALLOW, CoinIssueCoin::STATUS_REFUSE, CoinIssueCoin::STATUS_SUCCESS, CoinIssueCoin::STATUS_FAILED]])
->orderBy('create_time desc');
}
if ($status > -1) {
$query->andWhere(['status' => $status]);
}
if (false != $owner) {
$query->andWhere(['owner' => $owner]);
}
if (false != $chain_id) {
$query->andWhere(['chain_id' => $chain_id]);
}
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]);
$models = $query->offset($pages->offset)
->limit($pages->limit)
->all();
foreach ($models as &$val) {
$platform = isset($val->chain->platform) ? $val->chain->platform : '';
$val->chain_name = $platform;
$val->url = Yii::$app->redis->hget('platform_brower_info', $platform);
$val->total = (int)$val->total * 1e8;
}
$data = [
'list' => $models,
'page' => [
'pageCount' => $pages->pageCount,
'pageSize' => $size,
'currentPage' => (int)$page,
]
];
$msg = 'ok';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
/**
* 申请详情
* @param integer id
* @return array
*/
public function actionApplyDetail()
{
$id = Yii::$app->request->get('id', '');
$data = null;
if (empty($id)) {
$msg = '缺少必要的参数';
$code = -1;
goto doEnd;
}
$data = CoinIssueCoin::find()->where(['id' => $id])->one();
$platform = isset($data->chain->platform) ? $data->chain->platform : '';
$data->total = (int)$data->total * 1e8;
$data->issue_charge = rtrim(sprintf('%.3f', floatval($data->charge)), '0');
$data->url = Yii::$app->redis->hget('platform_brower_info', $platform);
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
/**
* 申请操作管理
* @param integer id
* @param integer status
* @param string msg
* @return array
*/
public function actionVerify()
{
$id = Yii::$app->request->post('id', '');
$status = Yii::$app->request->post('status', '');
$msg = Yii::$app->request->post('msg', '');
if (false == $id || false == $status) {
$msg = '缺少必要的参数';
$code = -1;
goto doEnd;
}
if (!in_array($status, [CoinIssueCoin::STATUS_ALLOW, CoinIssueCoin::STATUS_REFUSE])) {
$msg = '状态值错误';
$code = -1;
goto doEnd;
}
$model = CoinIssueCoin::findOne($id);
if (false == $model) {
$msg = '不存在的记录';
$code = -1;
goto doEnd;
}
$data = [
'status' => $status,
#'msg' => $msg
];
$model->setScenario(CoinIssueCoin::SCENARIOS_UPDATE);
$model->load($data, '');
if (!$model->save()) {
$msg = current($model->firstErrors);
$code = -1;
goto doEnd;
}
$record = CoinIssueChainRecord::find()->where(['issue_coin_id' => $id])->one();
$record->finish_tx = 'failed';
$record->finish_send_transaction = 'failed';
$record->finish_query_transaction = $msg;
$record->save();
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg];
}
}
\ No newline at end of file
<?php
namespace wallet\controllers;
use Yii;
use OSS\OssClient;
use yii\web\UploadedFile;
use wallet\base\BaseController;
class OssController extends BaseController
{
protected $accessKeyId = "LTAI4FxZ787zpBmjLmr6yMwA";
protected $accessKeySecret = "5OMu030RFIE2KP3fNJrhVRTlVqBLaE";
protected $endpoint = "http://oss-cn-shanghai.aliyuncs.com";
protected $bucket = "bqbwallet";
public function actionUpload()
{
$data = [];
$type = Yii::$app->request->post('type', '');
$uploaded_file = UploadedFile::getInstanceByName('file');
if (false == $uploaded_file || false == $type) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$object = md5(date('Y-m-d H:i:s') . $uploaded_file->tempName) . '.' . $uploaded_file->extension;
$filePath = $uploaded_file->tempName;
$ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
$result = $ossClient->uploadFile($this->bucket, 'upload/' . (empty($type) ? '' : $type . '/') . $object, $filePath);
if (!isset($result["info"]['url'])) {
$msg = '上传失败';
$code = -1;
goto doEnd;
}
$code = 0;
$msg = 'ok';
$data = $result["info"]['url'];
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
......@@ -46,7 +46,8 @@ class UserController extends BaseController
'username' => $user->username,
'uid' => isset($user->bind_uid) ? $user->bind_uid : $user->uid,
'type' => isset($user->bind_uid) ? 2 : 1,
'platform_id' => $user->platform_id
'platform_id' => $user->platform_id,
'group' => $user->group
];
return ['code' => $code, 'msg' => $msg, 'data' => $data];
......@@ -175,4 +176,111 @@ class UserController extends BaseController
return ['code' => 1, 'data' => $result['msg'], 'msg' => 'success'];
}
/**
* 人工实名全部列表
*/
public function actionManualList()
{
$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];
$page = Yii::$app->request->get('page', 1);
$size = Yii::$app->request->get('size', 15);
$status = Yii::$app->request->get('status', '');
$search = Yii::$app->request->get('search', '');
$start_time = Yii::$app->request->get('start_time', '');
$end_time = Yii::$app->request->get('end_time', '');
$params = [
'page' => $page,
'size' => $size,
'status' => $status,
'search' => $search,
'start_time' => $start_time,
'end_time' => $end_time
];
$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->getManualList($params);
if (200 !== $result['code']) {
return ['code' => $result['code'], 'data' => [], 'msg' => $result['msg']];
}
return ['code' => 1, 'data' => $result['msg'], 'msg' => 'success'];
}
public function actionVerify()
{
$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];
$post = Yii::$app->request->post();
$uid = isset($post['uid']) ? $post['uid'] : null;
$action = isset($post['action']) ? $post['action'] : null;
if(false == $uid || false == $action){
return ['code' => -1, 'data' => [], 'msg' => '参数错误'];
}
$params = [
'uid' => $uid,
];
$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);
if ('verify' == strtolower($action)) {
$result = $service->verifyReal($params);
}
if ('refuse' == strtolower($action)) {
$result = $service->refuseReal($params);
}
if ('revoke' == strtolower($action)) {
$result = $service->revokeReal($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
This diff is collapsed.
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