Commit 823929b4 authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/jinse

parents dbadc3ea 4596440c
......@@ -223,15 +223,15 @@ class CoinController extends BaseController
return ['code' => 0, 'data' => []];
}
foreach ($names as $key => $val) {
if(strpos($val, ',') !== false){
if (strpos($val, ',') !== false) {
$val_array = explode(',', $val);
if('USDT' == strtoupper($val_array[0]) && 'BTC' == strtoupper($val_array[1])) {
if ('USDT' == strtoupper($val_array[0]) && 'BTC' == strtoupper($val_array[1])) {
$condition[] = [$val_array[0], 'omni'];
continue;
}
$condition[] = [$val_array[0], $val_array[1]];
} else {
$condition[] = $val;
$condition[] = $val;
}
}
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition);
......@@ -344,25 +344,29 @@ class CoinController extends BaseController
$request = Yii::$app->request;
$platform = $request->get('platform', '');
$coin_name = $request->get('coinname', '');
$platform_with_hold = CoinPlatformWithHold::getRecord($platform);
if (empty($platform_with_hold)) {
return ['code' => 0, 'data' => null];
}
if (empty($coin_name)) {
$platform_with_hold = CoinPlatformWithHold::getRecord($platform);
$des = Yii::$app->des;
$platform_with_hold['private_key'] = $des->encrypt($platform_with_hold['private_key']);
$platform_with_hold['coins_name'] = '';
return ['code' => 0, 'data' => $platform_with_hold];
}
$platform_with_hold = CoinPlatformWithHold::getRecord($platform);
$coin_info = Coin::find()->select('treaty')->where(['name' => strtoupper($coin_name), 'platform' => $platform])->asArray()->one();
$des = Yii::$app->des;
$platform_with_hold['private_key'] = $des->encrypt($platform_with_hold['private_key']);
if (1 == $coin_info['treaty']) {
$platform_with_hold['exer'] = 'user.p.' . $platform . '.token';
$platform_with_hold['tokensymbol'] = $coin_name;
$platform_with_hold['fee'] = 0;
} else {
$platform_with_hold['exer'] = 'user.p.' . $platform . '.coins';
$platform_with_hold['tokensymbol'] = $platform . '.coins';
$platform_with_hold['fee'] = (float)sprintf("%0.4f", (double)$platform_with_hold['fee']);
}
$platform_with_hold['fee'] = (float)sprintf("%0.4f", (double)$platform_with_hold['fee']);
$coins_model = Coin::find()->select('name')->where(['platform' => $platform, 'treaty' => 2])->asArray()->one();
$platform_with_hold['coins_name'] = empty($coins_model) ? '' : $coins_model['name'];
$service = new Chain33Business();
$result = $service->getProperFee();
if (0 === $result['code']) {
......
<?php
namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\psources\CoinPlatformBanner;
class CoinPlatformBannerController extends BaseController
{
public function actionIndex()
{
$code = 0;
$msg = 'success';
$platform_id = Yii::$app->request->get('platform_id', '');
$type = Yii::$app->request->get('type', '');
if (empty($platform_id) || empty($type)) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$data = CoinPlatformBanner::find()->where(['platform_id' => $platform_id, 'type' => $type])->asArray()->all();
doEnd :
return ['code' => $code, 'data' => $data, 'msg' => $msg];
}
}
\ No newline at end of file
<?php
namespace api\controllers;
use api\base\BaseController;
use common\models\psources\CoinAirDropTrade;
use common\models\psources\CoinCrossChain;
use common\service\chain33\Chain33Service;
use Yii;
use yii\db\Exception;
class CrossChainController extends BaseController
{
public function actionTransfer()
{
$code = -1;
$request = Yii::$app->request;
if (!$request->isPost) {
$msg = '请求错误!';
goto doEnd;
}
$post = $request->post();
if (3 != count($post['txs'])) {
$msg = '交易笔数错误!';
goto doEnd;
}
$data['is_with_draw'] = (false == $post['isWithdraw']) ? 0 : 1;
$data['address'] = $post['address'];
$data['transfer_number'] = date('YmdHis') . self::getrandnums();
$redis = Yii::$app->redis;
if ($redis->exists($post['address'] . '_' . $data['is_with_draw'])) {
$msg = '存在未完成的交易!';
goto doEnd;
}
$redis->set($post['address'] . '_' . $data['is_with_draw'], $post['address'] . '_' . $data['is_with_draw']);
// $isExist = CoinCrossChain::find()
// ->where(['address' => $post['address'], 'is_with_draw' => $data['is_with_draw']])
// ->andWhere(['<>', 'query_result', 'success'])
// ->asArray()->all();
//
// if ($isExist) {
// $msg = '存在未完成的交易!';
// goto doEnd;
// }
foreach ($post['txs'] as $key => $val) {
$model = new CoinCrossChain();
$data['txhex'] = $val['tx'];
$data['transfer_url'] = $val['url'];
$model->load($data, '');
$model->save();
}
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg];
}
public function actionTransferStatus()
{
$code = -1;
$msg = 'fail';
$data = null;
$step = 0;
$request = Yii::$app->request;
if (!$request->isGet) {
$msg = '请求错误!';
goto doEnd;
}
$address = $request->get('address', '');
$is_with_draw = $request->get('isWithdraw', '');
if (empty($address)) {
$msg = '参数错误!';
goto doEnd;
}
$model = CoinCrossChain::find()->where(['address' => $address, 'is_with_draw' => $is_with_draw])->orderBy("id desc")->limit(3)->asArray()->all();
if (empty($model)) {
$msg = '数据不存在!';
goto doEnd;
}
sort($model);
foreach ($model as $key => $val) {
//未交易
if ('0' == $val['send_result'] && '0' == $val['query_result'] && '0' == $val['msg']) {
$step = $key + 1;
$code = 0;
$msg = '第' . ($key + 1) . '笔交易尚未执行';
goto doEnd;
}
//交易报错
if ('0' == $val['send_result'] && '0' == $val['query_result'] && true == $val['msg']) {
$step = $key + 1;
$code = -1;
$msg = $val['msg'];
goto doEnd;
}
//交易成功
if (true == $val['send_result'] && '0' == $val['query_result'] && '0' == $val['msg']) {
$step = $key + 1;
$code = 0;
$msg = $val['send_result'];
goto doEnd;
}
//交易成功,查询失败
if (true == $val['send_result'] && 'fail' == $val['query_result']) {
$step = $key + 1;
$code = -1;
$msg = $val['msg'];
goto doEnd;
}
//交易成功,查询成功
if (true == $val['send_result'] && 'success' == $val['query_result'] && 'success' == $val['msg']) {
if (2 == $key){
$step = (2 == $key) ? 4 : ($key + 2);
$code = 0;
$msg = $val['send_result'];
goto doEnd;
}
continue;
}
}
doEnd :
$data = [
'step' => $step
];
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public static function getrandnums()
{
$arr = array();
while (count($arr) < 6) {
$arr[] = rand(0, 9);
$arr = array_unique($arr);
}
return implode("", $arr);
}
}
\ No newline at end of file
<?php
namespace api\controllers;
use api\base\BaseController;
use common\models\psources\CoinAirDropTrade;
use common\models\psources\CoinSupportedSymbol;
use common\service\chain33\Chain33Service;
use Yii;
class SupportedSymbolController extends BaseController
{
public function actionSearch()
{
$platform_withhold_id = Yii::$app->request->get('id', '');
if (empty($platform_withhold_id)) {
$msg = '参数不能为空';
$code = -1;
$data = null;
goto doEnd;
}
$coinSupportedSymbol = CoinSupportedSymbol::find()->select('symbol')->where(['platform_withhold_id' => $platform_withhold_id])->asArray()->all();
$data = array_column($coinSupportedSymbol, 'symbol');
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
<?php
namespace backend\assets\coinTransfer;
namespace backend\assets\airDrop;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-transfer';
public $sourcePath = '@backend/web/js/air-drop';
public $js = [
'list.js',
];
......
<?php
namespace backend\assets\coinPlatformWithhold;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-platform-withhold';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
\ No newline at end of file
<?php
/**
* Created By Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-07 17:41:04
*/
namespace backend\assets\coinSupportedSymbol;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-supported-symbol';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
\ No newline at end of file
<?php
/**
* Created By Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-07 17:41:04
*/
namespace backend\assets\platformCoins;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/platform-coins';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: shaji
* Date: 2019/4/23
* Time: 10:04
*/
namespace backend\controllers;
use backend\models\Coin;
use common\service\chain33\Chain33Service;
use Yii;
use common\models\psources\CoinTransfer;
use yii\web\UploadedFile;
use common\models\psources\CoinAirDropTransfer;
class CoinTransferController extends BaseController
class AirDropController extends BaseController
{
public $enableCsrfValidation = false;
public function actionList()
{
$get = Yii::$app->request->get();
$page = $get['page'] ?? 1;
$get = Yii::$app->request->get();
$page = $get['page'] ?? 1;
$limit = $get['limit'] ?? 10;
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$condition = [];
$data = CoinTransfer::getList($page, $limit, $condition);
$data = CoinAirDropTransfer::getList($page, $limit, $condition);
return $data;
}
return $this->render('list');
......@@ -42,7 +35,7 @@ class CoinTransferController extends BaseController
$file = UploadedFile::getInstanceByName('file');
try {
$fd = fopen($file->tempName, 'r');
$fd = fopen($file->tempName, 'r');
$data = [];
while (($row = fgetcsv($fd)) !== false) {
$data[] = $row;
......@@ -50,12 +43,17 @@ class CoinTransferController extends BaseController
if (ctype_digit($data[0][0])) {
array_shift($data);
}
foreach ($data as $key => &$value){
foreach ($data as $key => &$value) {
$value[0] = trim($value[0]);
$value[1] = trim($value[1]);
}
if ($data) {
if (CoinTransfer::loadArray($data)) {
$additional = [1, '0', ' ', 0];
foreach ($data as $key => &$val) {
$val = array_merge($val, $additional);
}
if (CoinAirDropTransfer::loadArray($data)) {
return ['code' => 0, 'msg' => 'succeed'];
}
}
......@@ -65,48 +63,27 @@ class CoinTransferController extends BaseController
}
}
public function actionBatchTransfer()
public function actionAdd()
{
$model = CoinTransfer::find()->where(['status' => 0])->limit(30)->all();
foreach ($model as $val){
$id = $val->id;
$to = $val->address;
$amount = $val->amount * 1e8;
$fee = 100000;
$note = '';
$execer = 'user.p.tschain.coins';
$isExist = CoinTransfer::find()->where(['address' => $val->address, 'status' => 1])->one();
if($isExist) continue;
$service = new Chain33Service();
$createRawTransaction = $service->createRawTransaction($to, $amount, $fee, $note, $execer);
if(0 != $createRawTransaction['code']){
continue;
}
$txHex = $createRawTransaction['result'];
$privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2';
$expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire);
if(0 != $signRawTx['code']){
continue;
$this->layout = false;
if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$post = Yii::$app->request->post();
$model = new CoinAirDropTransfer();
$model->setScenario(CoinAirDropTransfer::SCENARIOS_CREATE);
$post['txhash'] = '0';
$post['msg'] = '';
$post['balance'] = 0;
$post['origin'] = CoinAirDropTransfer::ORIGIN_ADD;
if ($model->load($post, '') && $model->save()) {
return ['code' => 0, 'msg' => 'succeed'];
}
$sign_str = $signRawTx['result'];
$result = $service->sendTransaction($sign_str);
if(0 != $result['code']){
continue;
$error = $model->errors;
if ($error) {
return ['code' => -1, 'msg' => current($model->firstErrors)];
}
$hash = $result['result'];
$current_model = CoinTransfer::findOne($id);
$current_model->hash = $hash;
$current_model->status = 1;
$current_model->save();
echo $val->address."-----".$hash."<br/>";
} else {
return $this->render('add');
}
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ use backend\models\coin\CoinApplicationCategoryForm;
use common\models\psources\CoinApplicationCategory;
use common\models\psources\CoinBanner;
use common\models\psources\CoinImage;
use common\models\psources\CoinPlatform;
use Yii;
......@@ -24,7 +25,7 @@ class ApplicationCategoryController extends BaseController
public function actionIndex()
{
$user_platform_id = Yii::$app->user->identity->platform_id;
$platforms = CoinPlatform::find()->select('id, name')->asArray()->all();
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
......@@ -34,7 +35,13 @@ class ApplicationCategoryController extends BaseController
$where = [];
if (1 !== $user_platform_id) {
$where[] = ['platform_id' => $user_platform_id];
} else {
$platform_id = Yii::$app->request->get('platform', '');
if(!empty($platform_id)) {
$where[] = ['platform_id' => $platform_id];
}
}
if ($name) {
$where[] = ['name' => $name];
}
......@@ -42,14 +49,12 @@ class ApplicationCategoryController extends BaseController
foreach ($data['data'] as &$val) {
$val['name'] = str_replace('en-US', 'en', $val['name']);
$val['name'] = str_replace('zh-CN', 'zh', $val['name']);
}
foreach ($data['data'] as $key => &$val) {
$val['coin_name'] = isset($val['platform']['name']) ? $val['platform']['name'] : '';
}
return $data;
}
return $this->render('index');
return $this->render('index', ['platforms' => $platforms, 'user_platform_id' => $user_platform_id]);
}
/**
......
<?php
namespace backend\controllers;
use Yii;
use common\models\psources\CoinPlatformBanner;
class CoinPlatformBannerController extends BaseController
{
public function actionAdd()
{
$user_platform_id = Yii::$app->user->identity->platform_id;
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$image_url = $request->post('image_url', '');
$type = $request->post('banner_type', 1);
if ($image_url) {
$banner_item = new CoinPlatformBanner();
$banner_item->image_url = $image_url;
$banner_item->platform_id = $user_platform_id;
$banner_item->type = $type;
$banner_item->save();
return ['code' => 0, 'msg' => 'banner添加成功'];
} else {
return ['code' => 1, 'msg' => 'banner添加加失败'];
}
}
}
/**
* @return array
* banner删除
*/
public function actionDelete()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
if ($id) {
$banner = CoinPlatformBanner::getBanner($id);
if (!$banner) {
return ['code' => 1, 'msg' => 'banner不存在,不能删除'];
}
$banner->delete();
return ['code' => 0, 'msg' => 'banner删除成功'];
} else {
return ['code' => 1, 'msg' => 'banner删除失败'];
}
}
}
/**
* banner列表
*/
public function actionIndex()
{
$user_platform_id = Yii::$app->user->identity->platform_id;
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$condition = [];
if (1 !== $user_platform_id) {
$condition = ['platform_id' => $user_platform_id];
}
$data = CoinPlatformBanner::getItems($condition);
foreach ($data as $key => &$val) {
$val['coin_name'] = isset($val['platform']['name']) ? $val['platform']['name'] : '';
}
return ['data' => $data, 'code' => 0];
}
return $this->render('index');
}
}
\ No newline at end of file
<?php
namespace backend\controllers;
use backend\models\coin\CoinPlatformWithholdForm;
use common\models\psources\CoinPlatformWithHold;
use Yii;
class CoinPlatformWithholdController extends BaseController
{
public function actionIndex()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$platform = $request->get('platform', '');
$where = [];
if ($platform) {
$where[] = ['platform' => $platform];
}
$data = CoinPlatformWithHold::getList($page, $limit, $where);
return $data;
}
return $this->render('index');
}
public function actionAdd()
{
$model = new CoinPlatformWithholdForm();
$model->scenario = 'add';
if (Yii::$app->request->isPost) {
$data = Yii::$app->request->post();
if ($model->load($data, '') && $model->validate()) {
$coin = Yii::createObject(CoinPlatformWithHold::className());
$result = $coin->addOne($data);
if ($result === true) {
$this->success('添加成功', '/admin/coin-platform-withhold/index');
}
}
//表单验证失败
$errors = $model->errors;
if ($errors) {
foreach ($errors as $key => $item) {
$errors = $item[0];
break;
}
} elseif (isset($result) && $result['code'] != 0) {
$errors = $result['message'];
}
$this->error($errors, Yii::$app->request->getReferrer());
}
return $this->render('add', ['model' => $model]);
}
public function actionEdit()
{
if (Yii::$app->request->isPost) {
$model = new CoinPlatformWithholdForm();
$model->scenario = 'update';
$data = Yii::$app->request->post();
Yii::$app->response->format = 'json';
if ($model->load($data, '') && $model->validate()) {
$coin = Yii::createObject(CoinPlatformWithHold::className());
$result = $coin->updateOne($data);
if ($result === true) {
return ['code' => 0, 'msg' => 'succeed'];
}
}
$errors = $model->errors;
if ($errors) {
foreach ($errors as $key => $item) {
$errors = $item[0];
break;
}
} elseif (isset($result) && $result['code'] != 0) {
$errors = $result['message'];
}
return ['code' => 1, 'msg' => $errors];
} elseif (Yii::$app->request->isGet) {
$id = Yii::$app->request->get('id', null);
if ($id) {
$coin = CoinPlatformWithHold::findOne(['id' => $id]);
$this->layout = false;
return $this->render('edit', ['model' => $coin]);
}
}
}
}
\ No newline at end of file
<?php
namespace backend\controllers;
use backend\models\coin\CoinSupportedSymbolForm;
use common\models\psources\CoinSupportedSymbol;
use Yii;
class CoinSupportedSymbolController extends BaseController
{
public function actionList()
{
$platform_withhold_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_withhold_id' => $id];
}
$data = CoinSupportedSymbol::getList($page, $limit, $where);
$data['code'] = 0;
Yii::$app->response->format = 'json';
return $data;
}
return $this->render('index', ['platform_withhold_id' => $platform_withhold_id]);
}
public function actionAdd()
{
$model = new CoinSupportedSymbolForm();
$model->scenario = 'add';
if (Yii::$app->request->isPost) {
$data = Yii::$app->request->post();
if ($model->load($data, '') && $model->validate()) {
$coinSupportedSymbol = new CoinSupportedSymbol();
$coinSupportedSymbol->platform_withhold_id = $data['platform_withhold_id'];
$coinSupportedSymbol->symbol = $data['symbol'];
$result = $coinSupportedSymbol->save();
if ($result === true) {
$this->success('添加成功', '/admin/coin-supported-symbol/list?id=' . $data['platform_withhold_id']);
}
}
//表单验证失败
$errors = $model->errors;
if ($errors) {
foreach ($errors as $key => $item) {
$errors = $item[0];
break;
}
} elseif (isset($result) && $result['code'] != 0) {
$errors = $result['message'];
}
$this->error($errors, Yii::$app->request->getReferrer());
}
$platform_withhold_id = Yii::$app->request->get('platform_withhold_id');
return $this->render('add', ['model' => $model, 'platform_withhold_id' => $platform_withhold_id]);
}
public function actionDelete()
{
Yii::$app->response->format = 'json';
$id = Yii::$app->request->get('id', 0);
if ($id) {
$model = CoinSupportedSymbol::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
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/12/17
* Time: 10:13
*/
namespace backend\controllers;
use backend\models\coin\CoinPlatformForm;
use common\models\psources\CoinPlatform;
use common\models\psources\CoinPlatformCoins;
use Yii;
class PlatformCoinsController extends BaseController
{
public function actionList()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$coins_address = $request->get('coins_address', '**');
$where = [];
if ($coins_address) {
$where[] = ['coins_address' => $coins_address];
}
$data = CoinPlatformCoins::getList($page, $limit, $where);
foreach ($data['data'] as &$val){
unset($val['id']);
unset($val['coins_name']);
unset($val['type']);
unset($val['platform_id']);
unset($val['update_time']);
}
$data['code'] = 0;
Yii::$app->response->format = 'json';
return $data;
}
return $this->render('index');
}
}
\ No newline at end of file
<?php
namespace backend\models\coin;
use yii\base\Model;
class CoinPlatformWithholdForm extends Model
{
public $id;
public $platform;
public $address;
public $private_key;
public $exer;
public $fee;
public function formName()
{
return '';
}
public function rules()
{
return [
[['platform', 'address', 'private_key', 'exer', 'fee'], 'required', 'on' => 'add'],
[['id', 'platform', 'address', 'private_key', 'exer', 'fee'], 'required', 'on' => 'update'],
];
}
public function scenarios()
{
return [
'add' => ['platform', 'address', 'private_key', 'exer', 'fee'],
'update' => ['id', 'platform', 'address', 'private_key', 'exer', 'fee'],
];
}
}
\ No newline at end of file
<?php
namespace backend\models\coin;
use yii\base\Model;
class CoinSupportedSymbolForm extends Model
{
public $id;
public $platform_withhold_id;
public $symbol;
public function formName()
{
return '';
}
public function rules()
{
return [
[['platform_withhold_id', 'symbol'], 'required', 'on' => 'add'],
[['id', 'platform_withhold_id', 'symbol'], 'required', 'on' => 'update'],
];
}
public function attributeLabels()
{
return [
'id' => 'ID',
'platform_withhold_id' => '对应链',
'symbol' => '货币对',
];
}
public function scenarios()
{
return [
'add' => [
'platform_withhold_id',
'symbol'
],
'update' => [
'id',
'platform_withhold_id',
'symbol'
],
];
}
}
\ No newline at end of file
<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="to_address" type="text" class="form-control" lay-verify="required">
</div>
<div class="input-group my-group">
<span class="input-group-addon">打币数量</span>
<input name="amount" type="text" class="form-control" lay-verify="required">
</div>
<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>
</form>
</div>
\ No newline at end of file
<?php
use backend\assets\airDrop\IndexAsset;
IndexAsset::register($this);
?>
<div class="layui-row">
<button class="layui-btn layui-btn-sm" lay-event="import" id="import">名单导入</button>
<button class="layui-btn layui-btn-sm" lay-event="add" id="add">单笔添加</button>
<!-- <button class="layui-btn layui-btn-sm" lay-event="transfer" id="transfer">批量打币</button>-->
</div>
<div class="layui-row">
<table class="layui-table" id="table1"></table>
</div>
......@@ -23,6 +23,26 @@ IndexAsset::register($this);
<button class="layui-btn layui-btn-default" id="add">添加应用分类</button>
</a>
</div>
<?php
if (1 == $user_platform_id) {
?>
<form class="layui-form" method="get" action="">
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">钱包</label>
<div class="layui-input-inline">
<select name="platform" id = "platform">
<?php foreach ($platforms as $key => $platform): ?>
<option value="<?= $platform['id'] ?>"><?= $platform['name'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="form1">搜索</button>
</div>
</form>
<?php
} ?>
</div>
<div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table>
......@@ -44,13 +64,15 @@ IndexAsset::register($this);
<script type="text/html" id="operationTpl">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/application/list?id={{d.id}}" >应用列表</a>
<a class="layui-btn layui-btn-normal layui-btn-xs" href="/admin/application-category/banner-index?id={{d.id}}" >banner图管理</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/application/list?id={{d.id}}">应用列表</a>
<a class="layui-btn layui-btn-normal layui-btn-xs" href="/admin/application-category/banner-index?id={{d.id}}">banner图管理</a>
</script>
<script type="text/html" id="recommendTpl">
<input type="checkbox" name="isrecommend" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="recommendDemo" {{ d.isrecommend == 1 ? 'checked' : '' }}>
<input type="checkbox" name="isrecommend" value="{{d.id}}" lay-skin="switch" lay-text="是|否"
lay-filter="recommendDemo" {{ d.isrecommend== 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="enableTpl">
<input type="checkbox" name="isenable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="enableDemo" {{ d.enable == 1 ? 'checked' : '' }}>
<input type="checkbox" name="isenable" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="enableDemo"
{{ d.enable== 1 ? 'checked' : '' }}>
</script>
<style>
.layui-form-label {
width: 100px;
}
</style>
<h4>banner管理列表</h4>
<div class="layui-row">
<div class="layui-col-md1">
<button class="layui-btn layui-btn-default" id="add">添加banner图</button>
</div>
</div>
<div class="layui-col-md9">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<div class="layui-row add" style="display: none;padding: 50px;" id="_form">
<div class="layui-col-xs6 layui-col-sm6 layui-col-md11">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图片</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon1">
</div>
<input type="hidden" name="image_url" value="">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload1" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图片类型</label>
<div class="layui-input-block">
<select name="banner_type">
<option value="1">banner</option>
<option value="2">海报</option>
</select>
</div>
</div>
</form>
</div>
</div>
<script type="text/html" id="operationTpl">
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/javascript">
var table = layui.table;
table.render({
elem: '#table1',
url: '/admin/coin-platform-banner/index',
cols: [[
{
field: 'id',
title: '编号'
},
{
field: 'coin_name',
title: '钱包',
},
{
field: 'image_url',
title: '图片地址',
width: 600
},
{
title: '操作',
templet: '#operationTpl',
width: 200
}
]],
});
var form = layui.form;
form.render();
table.on('tool(table1)', function(obj) {
var event = obj.event;
var data = obj.data;
if (event === 'del') {
var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () {
$.get('/admin/coin-platform-banner/delete', {id: data.id}, function (rev) {
layer.msg(rev.msg);
if (0==rev.code) {
table.reload('table1');
}
});
});
}
});
$('#add').click(function () {
var index = layer.open({
title: '添加banner',
area: '750px',
type: 1,
content: $("#_form"),
btn: ['保存', '取消'],
success: function() {
clearForm();
},
btn1: function() {
$.post('/admin/coin-platform-banner/add', $("#form1").serialize(), function(rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
layer.close(index);
$("#_form").css('display', 'none');
clearForm();
table.reload('table1');
}
});
},
btn2: function() {
layer.close(index);
$("#_form").css('display', 'none');
},
cancel: function() {
layer.close(index);
$("#_form").css('display', 'none');
}
});
})
function clearForm(){
form.val("form1", {
image_url: '',
banner_url: ''
});
$("#icon1").attr('src', '');
}
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:2},
done: function (res) {
if(res.code == 0){
$("input[name='image_url']").val(res.data.image_src);
$("#icon1").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
</script>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<h4>添加应用分类</h4>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-form" method="post" action="" id="application-category-edit">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<div class="layui-inline">
<label class="layui-form-label">名称</label>
<div class="layui-input-block">
<input class="layui-input" name="platform" 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="address" ">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">私钥</label>
<div class="layui-input-block" style="width: auto">
<input class="layui-input" name="private_key"">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">执行器</label>
<div class="layui-input-block">
<input class="layui-input" name="exer"">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">手续费</label>
<div class="layui-input-block">
<input class="layui-input" name="fee"">
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn">提交</button>
</div>
</form>
</div>
</div>
<script>
var laydate = layui.laydate;
laydate.render({
elem: "#time1"
});
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf},
done: function (res) {
if (res.code == 0) {
$("input[name='icon']").val(res.data.image_id);
$("#icon1").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf, image_type: 2},
done: function (res) {
if (res.code == 0) {
$("input[name='banner']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
//form render
var form = layui.form;
form.render();
</script>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-form" method="post" action="" id="platformEdit">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input name="id" type="hidden" value="<?= $model->id ?>">
<div class="layui-inline">
<label class="layui-form-label">名称</label>
<div class="layui-input-block">
<input class="layui-input" name="platform" value="<?= $model->platform ?>" 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="address" value="<?= $model->address ?>">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">私钥</label>
<div class="layui-input-block" style="width: auto">
<input class="layui-input" name="private_key" value="<?= $model->private_key ?>">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">执行器</label>
<div class="layui-input-block">
<input class="layui-input" name="exer" value="<?= $model->exer ?>">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">手续费</label>
<div class="layui-input-block">
<input class="layui-input" name="fee" value="<?= $model->fee ?>">
</div>
</div>
</form>
</div>
</div>
<?php
use backend\assets\coinPlatformWithhold\IndexAsset;
IndexAsset::register($this);
?>
<style>
.layui-table-tips-c {
padding: 0px;
}
</style>
<h4>平行链列表</h4>
<div class="layui-row">
<div class="layui-col-md1">
<a href="/admin/coin-platform-withhold/add">
<button class="layui-btn layui-btn-default" id="add">添加平行链</button>
</a>
</div>
</div>
<div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<script type="text/html" id="operationTpl">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/coin-supported-symbol/list?id={{d.id}}" >所支持货币对</a>
</script>
<h4>添加货币对</h4>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md6">
<form class="layui-form" method="post" action="">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<div class="layui-inline">
<label class="layui-form-label">货币对</label>
<div class="layui-input-block">
<input class="layui-input" name="symbol" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn">提交</button>
</div>
<input class="layui-input" name="platform_withhold_id" type="hidden" value="<?= $platform_withhold_id ?>"
lay-verify="required">
</form>
</div>
</div>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-form" method="post" action="" id="walletEdit">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input name="id" type="hidden" value="<?= $model->id ?>">
<div class="layui-inline">
<label class="layui-form-label">简称</label>
<div class="layui-input-block">
<input class="layui-input" name="name" value="<?= $model->name ?>" 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="download_url" value="<?= $model->download_url ?>">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce"><?= $model->introduce?></textarea>
</div>
</div>
</form>
</div>
</div>
<script>
var laydate = layui.laydate;
laydate.render({
elem: "#time1"
});
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/coin/upload',
data: {_csrf: $_csrf},
done: function (res) {
console.log(res.data.src);
$("input[name='icon']").val(res.data.src);
$("#icon1").attr('src', res.data.src);
},
error: function (res) {
}
});
//form render
var form = layui.form;
form.render();
</script>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use backend\assets\coinSupportedSymbol\IndexAsset;
IndexAsset::register($this);
?>
<style>
.layui-table-tips-c {
padding: 0px;
}
</style>
<h4>货币对列表</h4>
<div class="layui-row">
<div class="layui-col-md1">
<a href="/admin/coin-supported-symbol/add?platform_withhold_id=<?= $platform_withhold_id ?>"">
<button class="layui-btn layui-btn-default" id="add">添加货币对</button>
</a>
</div>
</div>
<input id="platform_withhold_id" type="hidden" value="<?= $platform_withhold_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>
<?php
use backend\assets\coinTransfer\IndexAsset;
IndexAsset::register($this);
?>
<div class="layui-row">
<button class="layui-btn layui-btn-sm" lay-event="implode" id="implode">名单导入</button>
<button class="layui-btn layui-btn-sm" lay-event="transfer" id="transfer">批量打币</button>
</div>
<div class="layui-row">
<div class="layui-col-md8">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
</div>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use backend\assets\platformCoins\IndexAsset;
IndexAsset::register($this);
?>
<style>
.layui-table-tips-c {
padding: 0px;
}
</style>
<div class="layui-row">
<div class="layui-col-md8">
<form class="layui-form" method="get" action="">
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">按地址搜索</label>
<div class="layui-input-inline">
<input class="layui-input" name="coins_address" style="width: 400px;">
</div>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="form1">搜索</button>
</div>
</form>
</div>
</div>
<div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</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>
</script>
var table = layui.table;
var upload = layui.upload;
table.render({
elem: "#table1",
url: '/admin/air-drop/list',
page: 1,
limit: 10,
cols: [[
{field:'id', width:100, title: 'ID', sort: true},
{field: 'to_address', width:400, title: '地址'},
{field: 'amount', title: '数量'},
{field: 'coin_name', title: '币种名称'},
{field: 'txhash', width:400,title: 'hash'},
{field: 'msg', width:200, title: '返回结果'},
{field: 'create_time', title: '添加时间'},
{field: 'update_time', title: '处理时间'}
]]
,done: function () {
//$("[data-field='id']").css('display','none');
}
});
$('#add').click(function () {
//打开弹窗
$.get('/admin/air-drop/add', {}, 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/air-drop/add', $("#addData").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
layer.close(index);
table.reload("table1", {});
}
});
}
});
layui.form.render();
});
return false;
});
upload.render({
elem: "#import",
url: "/admin/air-drop/load-file",
accept: 'file',
exts: 'csv',
done: function (res) {
if(res.code == 0){
layer.msg(res.msg);
table.reload('table1', {curr: 1});
}else{
layer.msg(res.msg);
}
},
before: function (obj) { //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer.load(); //上传loading
}
});
$('#transfer').click(function () {
//var data = obj.data; //得到所在行所有键值
$.get('/admin/air-drop/batch-transfer', {}, function (rev) {
layer.msg(rev.msg);
if (0==rev.code) {
table.reload('table1', {
page: {
curr: 1
}
});
}
});
});
\ No newline at end of file
......@@ -13,12 +13,13 @@ var tableIns = table.render({
loading: true,
cols: [[
{
field: 'coin_name', title: '名称', templet: function (data) {
field: 'name', title: '名称', templet: function (data) {
var name = JSON.parse(data.name);
console.log(typeof (data.name), name.zh);
return name.zh
}
},
{field: 'coin_name',title: '钱包'},
{field: 'icon_url', title: '图标', templet: '#iconTpl'},
{field: 'isrecommend', title: '首页推荐', templet: '#recommendTpl', width: 100},
{field: 'enable', title: '状态', templet: '#enableTpl', width: 100},
......
/**
* @author rlgyzhcn@qq.com
*/
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
var tableIns = table.render({
elem: "#table1",
url: '/admin/coin-platform-withhold/index',
limit: 10,
page: 1,
loading: true,
cols: [[
{field: 'platform', title: '名称'},
{field: 'address', title: '地址'},
{field: 'exer', title: '执行器'},
{field: 'fee', 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.platform + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.close(index);
//向服务端发送删除指令
$.get('/admin/coin-platform-withhold/delete?id=' + obj.data.id, function (data, status) {
if (data.code == 0) {
obj.del(); //删除对应行(tr)的DOM结构
}
layer.msg(data.msg);
});
});
} else if (obj.event == 'edit') {
$.get('/admin/coin-platform-withhold/edit', {id: data.id}, function (str) {
var editIndex = layer.open({
type: 1,
title: '编辑: ' + data.platform,
area: '700px',
content: str,
btn: ['保存', '取消'],
btn1: function () {
// console.log();
$.post('/admin/coin-platform-withhold/edit', $("#platformEdit").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
table.reload("table1", {
where: data.field,
});
layer.close(editIndex);
}
});
}
});
});
}
});
\ No newline at end of file
/**
* @author rlgyzhcn@qq.com
*/
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
var platform_withhold_id = $("#platform_withhold_id").val();
var tableIns = table.render({
elem: "#table1",
url: '/admin/coin-supported-symbol/list?id=' + platform_withhold_id,
limit: 10,
page: 1,
loading: true,
cols: [[
{field: 'id', title: 'ID'},
{field: 'symbol', 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.symbol + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.close(index);
//向服务端发送删除指令
$.get('/admin/coin-supported-symbol/delete?id=' + obj.data.id, function (data, status) {
if (data.code == 0) {
obj.del(); //删除对应行(tr)的DOM结构
}
layer.msg(data.msg);
});
});
}
});
\ No newline at end of file
/**
* @author rlgyzhcn@qq.com
*/
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
var tableIns = table.render({
elem: "#table1",
url: '/admin/platform-coins/list',
limit: 10,
page: 1,
loading: true,
cols: [[
{field: 'coins_address', title: '地址'},
{field: 'deviceCode', title: '设备唯一码'},
{field: 'create_time', title: '添加时间'},
]],
});
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.name + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.close(index);
//向服务端发送删除指令
$.get('/admin/wallet/delete?id=' + obj.data.id, function (data, status) {
if (data.code == 0) {
obj.del(); //删除对应行(tr)的DOM结构
}
layer.msg(data.msg);
});
});
} else if (obj.event == 'edit') {
$.get('/admin/wallet/edit', {id: data.id}, function (str) {
var editIndex = layer.open({
type: 1,
title: '编辑: ' + data.name,
area: '625px',
content: str,
btn: ['保存', '取消'],
btn1: function () {
// console.log();
$.post('/admin/wallet/edit', $("#walletEdit").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
table.reload("table1", {
where: data.field,
});
layer.close(editIndex);
}
});
}
});
});
}
});
\ No newline at end of file
......@@ -39,7 +39,11 @@ class ExchangeBusiness
10 => 'Zhaobi',
11 => 'Gdpro',
12 => 'Boc',
13 => 'Ex'
13 => 'Ex',
14 => 'Zt',
15 => 'Tsc',
16 => 'Binance',
17 => 'Ceohk'
];
/**
......@@ -82,7 +86,7 @@ class ExchangeBusiness
goto doEnd;
}
if (strtoupper($tag) == 'TSC' || strtoupper($tag) == 'WL' || strtoupper($tag) == 'ETS' || strtoupper($tag) == 'LIMS' || strtoupper($tag) == 'AT' || strtoupper($tag) == 'BTJ') {
if (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,
......@@ -150,6 +154,33 @@ class ExchangeBusiness
goto doEnd;
}
if (in_array(strtoupper($tag), ['SUSD'])) {
$exchange = ExchangeFactory::createExchange("Go");
$quotation = $exchange->getTicker('CNY', 'USD');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['CIC'])) {
$exchange = ExchangeFactory::createExchange("Zt");
$quotation = $exchange->getTicker('CIC', 'USDT');
goto doEnd;
}
if (in_array(strtoupper($tag), ['TSC'])) {
$exchange = ExchangeFactory::createExchange("Tsc");
$quotation = $exchange->getTicker('TSC', 'CNDT');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['TIX'])) {
$exchange = ExchangeFactory::createExchange("Ceohk");
$quotation = $exchange->getTicker('TIX', 'QC');
$quotation['rmb'] = $quotation['last'];
goto doEnd;
}
if (in_array(strtoupper($tag), ['SJPY'])) {
$exchange = ExchangeFactory::createExchange("Boc");
$quotation = $exchange->getTicker('CNY', 'JPY');
......@@ -219,9 +250,11 @@ class ExchangeBusiness
$exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD");
$cny_usd_rate = 1 / $rate['last'];
if (in_array(strtoupper($tag), ['FOLI'])) {
if (in_array(strtoupper($tag), ['FOLI', 'CIC'])) {
$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'])) {
$quotation['usd'] = (float)sprintf("%0.4f", 1);
} else {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['rmb'] * $cny_usd_rate);
}
......@@ -255,8 +288,11 @@ class ExchangeBusiness
/**
* @var $exchange \common\service\exchange\ExchangeInterface
*/
$exchange = ExchangeFactory::createExchange($exchange);
$exchange->setQuotation();
go(function () use ($exchange) {
\Co::sleep(0.5);
$exchange = ExchangeFactory::createExchange($exchange);
$exchange->setQuotation();
});
}
}
......@@ -271,20 +307,20 @@ class ExchangeBusiness
if (count($condition[0]) > 1) {
foreach ($condition as $val) {
if ('null' == $val[1] || 'coin' == $val[1]) {
$data[] = Coin::find()->select('id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty')
$data[] = Coin::find()->select('id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty')
->where(['name' => $val[0]])
->asArray()
->one();
continue;
}
$data[] = Coin::find()->select('id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty')
$data[] = Coin::find()->select('id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty')
->where(['name' => $val[0]])
->andWhere(['platform' => $val[1]])
->asArray()
->one();
}
} else {
$data = Coin::find()->select('id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty')
$data = Coin::find()->select('id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty')
->where(['in', 'name', $condition])
->asArray()->all();
}
......
<?php
namespace common\models\psources;
use common\core\BaseActiveRecord;
use Yii;
/**
* CoinReleaseMember
*
* @property int $id
* @property int $status
* @property string $address
* @property string $amount
*/
class CoinTransfer extends BaseActiveRecord
{
const SCENARIOS_ADD = 'add';
const SCENARIOS_UPDATE = 'update';
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_transfer}}';
}
public function attributeLabels()
{
return [
'id' => 'ID',
'address' => '地址',
'amount' => '数量',
'hash' => '交易hash',
'status' => '状态',
];
}
public function rules()
{
return [
[['address', 'amount', 'hash'], 'string'],
];
}
public function sercians()
{
return [
self::SCENARIOS_ADD => ['address', 'amount', 'hash', 'status'],
self::SCENARIOS_UPDATE => ['address', 'amount', 'hash', 'status'],
];
}
/**
* 批量返回用户
*
* @param integer|array $ids
* @return array
*/
public static function getMemberByRuleIds($ids)
{
return CoinReleaseMember::find()->where(['rule_id' => $ids])->andWhere(['>', 'freeze', 0])->asArray()->all();
}
public static function loadArray(array $data)
{
return self::getDb()->createCommand()->batchInsert(self::tableName(),
['address', 'amount'],
$data)->execute();
}
}
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinAirDropTransfer extends BaseActiveRecord
{
const ORIGIN_IMPORT = 1;
const ORIGIN_ADD = 2;
const ORIGIN_API = 3;
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_airdrop_transfer}}';
}
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public function rules() {
return [
[['to_address', 'amount', 'coin_name'], 'required','message'=>"请输入{attribute}"],
[['origin', 'txhash', 'msg', 'balance'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'to_address' => '钱包地址',
'amount' => '数量',
'coin_name' => '币种名称',
'origin' => '来源',
'txhash' => '返回hash',
'msg' => '返回结果',
'balance' => '钱包余额',
];
}
public function scenarios() {
$scenarios = [
self:: SCENARIOS_CREATE => ['to_address', 'amount','coin_name', 'origin'],
];
return array_merge( parent:: scenarios(), $scenarios);
}
public static function loadArray(array $data)
{
return self::getDb()->createCommand()->batchInsert(self::tableName(),
['to_address', 'coin_name', 'amount', 'origin', 'txhash', 'msg', 'balance'],
$data)->execute();
}
public static function getOrigin()
{
return [
self::ORIGIN_IMPORT => '批量导入',
self::ORIGIN_ADD => '单独添加',
self::ORIGIN_API => '接口导入',
];
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinCrossChain extends BaseActiveRecord
{
const WITHDRAW = 0;
const RECHARGE = 1;
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_cross_chain_transfer}}';
}
//定义场景
const SCENARIOS_CREATE = 'create';
public function rules()
{
return [
[['is_with_draw', 'address', 'txhex', 'transfer_url'], 'required'],
['transfer_number', 'safe']
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['is_with_draw', 'address', 'txhex', 'transfer_url', 'transfer_number'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
}
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinPlatformBanner extends BaseActiveRecord
{
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{coin_platform_banner}}';
}
public static function getBanner($id)
{
return self::find()->where(['id' => $id])->one();
}
public static function getItems($condition = [])
{
return self::find()->joinWith('platform')->where($condition)->asArray()->all();
}
public function getPlatform()
{
return $this->hasOne(CoinPlatform::className(), ['id'=>'platform_id']);
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
* Date: 2019/3/1
* Time: 17:37
*/
namespace common\models\psources;
class CoinPlatformWithHold extends BaseActiveRecord
......@@ -14,11 +15,59 @@ class CoinPlatformWithHold extends BaseActiveRecord
return 'coin_platform_withhold';
}
public static function getRecord($platform)
{
return self::find()->where(['platform' => $platform])->asArray()->one();
}
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);
$data = $data->asArray()->all();
return ['count' => $count, 'data' => $data, 'code' => 0];
}
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()];
}
}
public function updateOne($params)
{
$params = array_filter($params, function ($value) {
if (null === $value) {
return false;
}
return true;
});
if (isset($params['id']) && !empty($params['id'])) {
$coin = self::findOne(['id' => $params['id']]);
if ($coin === null) {
return ['code' => 1, 'msg' => '平台不存在'];
}
unset($params['id']);
}
$coin->setAttributes($params, false);
try {
return (bool)$coin->save();
} catch (\Exception $exception) {
return ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
}
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
class CoinSupportedSymbol extends BaseActiveRecord
{
public static function tableName()
{
return '{{%coin_supported_symbol}}';
}
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()];
}
}
}
......@@ -234,6 +234,14 @@ class Chain33Service
return $this->send($params, 'Chain33.SendTransaction');
}
public function QueryTransaction($data)
{
$params = [
'hash' => $data
];
return $this->send($params, 'Chain33.QueryTransaction');
}
public function getBalance($address, $execer)
{
$params = [
......
<?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 Binance extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_binance';
protected $quotation_prefix = 'quotation_binance_';
protected $base_url = 'https://api.binance.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 . '/api/v1/ticker/24hr';
$res = $curl->get($api, false);
if (is_array($res)) {
foreach ($res as $item) {
$key = $this->quotation_prefix . strtolower($item['symbol']);
$this->redis->hmset($key, 'low', $item['lowPrice'], 'high', $item['highPrice'], 'last', $item['lastPrice'], 'open', $item['openPrice']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
}
}
}
}
\ No newline at end of file
<?php
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Ceohk extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_ceohk';
protected $quotation_prefix = 'quotation_ceohk_';
protected $base_url = 'https://ceohk.bi/api/market/ticker?market=tix_qc';
public function symbolExists($tag = 'TIX', $aim = "QC")
{
$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 = 'TIX', $aim = 'QC')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'TIX_QC');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['data'])) {
$data = $content['data'];
$key = $this->quotation_prefix . 'TIX_QC';
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last']);
$this->redis->sadd($this->supported_symbol, 'TIX_QC');
}
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ class HuoBi extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_huobi';
protected $quotation_prefix = 'quotation_huobi_';
protected $base_url = 'https://api.huobi.pro';
protected $base_url = 'https://api.huobi.pro';
public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{
......@@ -45,7 +45,7 @@ class HuoBi extends Exchange implements ExchangeInterface
$datas = $res['data'];
foreach ($datas as $item) {
$key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $item['low'], 'high', $item['high'], 'last', $item['close']);
$this->redis->hmset($key, 'low', $item['low'], 'high', $item['high'], 'last', $item['close'], 'open', $item['open']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
}
}
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Tsc extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_tsc';
protected $quotation_prefix = 'quotation_tsc_';
protected $base_url = 'https://api.tsc100.vip/openapi/quote/v1/ticker/24hr';
public function symbolExists($tag = 'TSC', $aim = "CNDT")
{
$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 = 'TSC', $aim = 'CNDT')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'TSC_CNDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content)) {
foreach ($content as $item) {
if (in_array($item['symbol'], ['TSCCNDT'])) {
$data = $item;
$key = $this->quotation_prefix .'TSC_CNDT';
$this->redis->hmset($key, 'low', $data['lowPrice'], 'high', $data['highPrice'], 'last', $data['lastPrice']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
}
}
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Zt extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_zt';
protected $quotation_prefix = 'quotation_zt_';
protected $base_url = 'https://www.zt.com/api/v1/tickers';
public function symbolExists($tag = 'CIC', $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 = 'CIC', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'CICUSDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['ticker'])) {
$data = $content['ticker'];
foreach ($data as $item) {
if (in_array($item['symbol'], ['CIC_USDT'])) {
$data = $item;
$key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
}
}
}
}
}
\ No newline at end of file
<?php
namespace console\controllers;
use Yii;
use yii\console\Controller;
use common\service\chain33\Chain33Service;
use common\models\psources\CoinAirDropTransfer;
class AirDropController extends Controller
{
/**
* 获取游戏状态
*
* @return array
*/
public function actionAutoAirDrop()
{
$model = CoinAirDropTransfer::find()->where(['txhash' => "0", 'msg' => ''])->limit(20)->asArray()->all();
if (empty($model)) {
echo date('Y-m-d H:i:s') . '暂无空投计划' . PHP_EOL;
return 0;
}
foreach ($model as $key => $val) {
go(function () use ($val) {
\Co::sleep(0.5);
$id = $val['id'];
$to = $val['to_address'];
$amount = $val['amount'] * 1e8;
$fee = 100000;
$note = '';
$execer = isset(Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']) ? Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet']['execer'] : null;
$node_params = Yii::$app->params['chain_parallel']['wasm'][$val['coin_name'] . '_wallet'];
$service = new Chain33Service($node_params);
$createRawTransaction = $service->createRawTransaction($to, $amount, $fee, $note, $execer);
if (0 != $createRawTransaction['code']) {
$txhash = '0';
$msg = $createRawTransaction['msg'];
goto doEnd;
}
$txHex = $createRawTransaction['result'];
$privkey = '72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e21';
$expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire);
if (0 != $signRawTx['code']) {
$txhash = '0';
$msg = $signRawTx['msg'];
goto doEnd;
}
$sign_str = $signRawTx['result'];
$result = $service->sendTransaction($sign_str);
if (0 != $result['code']) {
$txhash = '0';
$msg = $result['msg'];
goto doEnd;
}
$txhash = $result['result'];
$msg = 'success';
doEnd :
$currentModel = CoinAirDropTransfer::findOne($id);
$currentModel->txhash = $txhash;
$currentModel->msg = $msg;
$currentModel->save();
});
}
return 0;
}
}
\ No newline at end of file
<?php
namespace console\controllers;
use common\models\psources\CoinCrossChain;
use Yii;
use yii\console\Controller;
use common\service\chain33\Chain33Service;
class CrossChainController extends Controller
{
/**
* 自动交易
*
* @return array
*/
public function actionAutoTransfer()
{
$model = CoinCrossChain::find()->where(['send_result' => "0"])->limit(20)->groupBy('transfer_number')->orderBy('id')->asArray()->all();
if (empty($model)) {
echo date('Y-m-d H:i:s') . '暂无跨链交易计划' . PHP_EOL;
return 0;
}
foreach ($model as $val) {
$isExist = CoinCrossChain::find()
->where(['transfer_number' => $val['transfer_number']])
->andWhere(['<', 'id', (int)$val['id']])
->orderBy('id desc')
->asArray()
->one();
//上一步发送成功,未查询
if ('success' != $isExist['query_result'] && !empty($isExist)) {
continue;
}
//go(function () use ($val) {
// \Co::sleep(0.5);
$transfer_url = $val['transfer_url'];
$transfer_url = explode(':', $transfer_url);
$node_params = [
'scheme' => $transfer_url[0],
'host' => str_replace('//', '', $transfer_url[1]),
'port' => isset($transfer_url[2]) ? $transfer_url[2] : ''
];
$service = new Chain33Service($node_params);
$sign_str = $val['txhex'];
$result = $service->sendTransaction($sign_str);
if (0 != $result['code']) {
$msg = $result['msg'];
goto doEnd;
}
$send_result = $result['result'];
doEnd :
$currentModel = CoinCrossChain::findOne($val['id']);
if (isset($msg)) {
$currentModel->msg = $msg;
}
if (isset($send_result)) {
$currentModel->send_result = $send_result;
}
$currentModel->save();
//});
}
echo date('Y-m-d H:i:s') . '跨链交易成功' . PHP_EOL;
return 0;
}
public function actionQueryTransaction()
{
$model = CoinCrossChain::find()->where(['<>', 'send_result', '0'])->andWhere(['msg' => '0'])->limit(20)->asArray()->all();
if (empty($model)) {
echo date('Y-m-d H:i:s') . '暂无跨链交易计划' . PHP_EOL;
return 0;
}
foreach ($model as $val) {
$node_params = $val['transfer_url'];
$node_params = explode(':', $node_params);
$node_params = [
'scheme' => $node_params[0],
'host' => str_replace('//', '', $node_params[1]),
'port' => isset($node_params[2]) ? $node_params[2] : ''
];
$service = new Chain33Service($node_params);
$send_result = $val['send_result'];
$result = $service->QueryTransaction($send_result);
if (-1 == $result['code']) {
if('tx not exist' == $result['msg']) continue;
$msg = $result['msg'];
$query_result = $result['code'];
goto doEnd;
// echo date('Y-m-d H:i:s') . 'ID:' . $val['id'] . '查询错误' . PHP_EOL;
// continue;
}
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$query_result = 'success';
$msg = 'success';
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
$query_result = 'success';
$msg = 'success';
} else {
$query_result = 'fail';
foreach ($result['result']['receipt']['logs'] as $log) {
if (is_array($log['log'])) continue;
$msg = isset($log['log']) ? $log['log'] : '查询错误';
}
}
doEnd :
$currentModel = CoinCrossChain::findOne($val['id']);
$currentModel->query_result = $query_result;
$currentModel->msg = $msg;
$currentModel->save();
$count = CoinCrossChain::find()->where(['transfer_number' => $val['transfer_number']])->andWhere(['query_result' => 'success'])->count();
if (3 == $count) {
$redis = Yii::$app->redis;
$key = $val['address'] . '_' . $val['is_with_draw'];
if ($redis->exists($key)) {
$redis->del($key);
}
}
}
echo date('Y-m-d H:i:s') . '查询完毕' . PHP_EOL;
return 0;
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ class CoinController extends BaseController
public function actionGetIconByNames()
{
$response_ = new ResponseBuild();
$names = Yii::$app->request->POST('names');
$names = Yii::$app->request->POST('names');
if (empty($names)) {
$response_->build(ResponseBuild::STATUS_PARAMS_NOT_VALIDATE);
return $response_;
......@@ -38,7 +38,7 @@ class CoinController extends BaseController
$names = [$names];
}
$infos = Coin::getInfoByNames($names);
$data = [];
$data = [];
if ($infos) {
$data = array_column($infos, 'icon', 'name');
}
......@@ -53,7 +53,7 @@ class CoinController extends BaseController
public function actionCoinInfoByNames()
{
$response_ = new ResponseBuild();
$names = Yii::$app->request->POST('names');
$names = Yii::$app->request->POST('names');
if (empty($names)) {
$response_->build(ResponseBuild::STATUS_PARAMS_NOT_VALIDATE);
return $response_;
......@@ -61,12 +61,19 @@ class CoinController extends BaseController
if (!is_array($names)) {
$names = [$names];
}
$condition = [['in', 'name', $names]];
$fields = ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain','address as contract_address','introduce'];
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition,$fields);
$condition = $names;
$platform = Yii::$app->request->POST('platform', '');
if (!empty($platform)) {
$condition = [];
foreach ($names as $val) {
$condition[] = [$val, $platform];
}
}
$fields = ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain', 'address as contract_address', 'introduce'];
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition, $fields);
if ($result) {
$response_->build(ResponseBuild::STATUS_SUCCEED, '', $result['data']);
}else{
} else {
$response_->build(ResponseBuild::STATUS_SUCCEED, '', []);
}
return $response_;
......
#!/bin/bash
while true; do php /var/www/html/token_pwallet/yii cross-chain/auto-transfer >> /var/www/html/auto-transfer.log 2>&1; sleep 15; done &
\ No newline at end of file
#!/bin/bash
while true; do php /var/www/html/token_pwallet/yii cross-chain/query-transaction >> /var/www/html/query-transaction.log 2>&1; sleep 20; done &
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment