diff --git a/api/controllers/CoinController.php b/api/controllers/CoinController.php index e33f9c9275ee398f8482bb420306a2fde28544bc..1b893d45fd61ecd3c0e46825fc913aefd145ac36 100644 --- a/api/controllers/CoinController.php +++ b/api/controllers/CoinController.php @@ -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']) { diff --git a/api/controllers/CoinPlatformBannerController.php b/api/controllers/CoinPlatformBannerController.php new file mode 100644 index 0000000000000000000000000000000000000000..3378e494c45aea914393b5cba60ab5ca85bdd6dc --- /dev/null +++ b/api/controllers/CoinPlatformBannerController.php @@ -0,0 +1,29 @@ +<?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 diff --git a/api/controllers/CrossChainController.php b/api/controllers/CrossChainController.php new file mode 100644 index 0000000000000000000000000000000000000000..cc098cf8cddc16f7ea09564ec75abe3978ae0d4b --- /dev/null +++ b/api/controllers/CrossChainController.php @@ -0,0 +1,148 @@ +<?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 diff --git a/api/controllers/SupportedSymbolController.php b/api/controllers/SupportedSymbolController.php new file mode 100644 index 0000000000000000000000000000000000000000..3f0107665839cf3efb2414832de31930ff432962 --- /dev/null +++ b/api/controllers/SupportedSymbolController.php @@ -0,0 +1,32 @@ +<?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 diff --git a/backend/assets/coinTransfer/IndexAsset.php b/backend/assets/airDrop/IndexAsset.php similarity index 69% rename from backend/assets/coinTransfer/IndexAsset.php rename to backend/assets/airDrop/IndexAsset.php index 94d3dda1cf0c3352c44c4fde344afacee59a5fbf..6954e9669f2553757e64fc00a2371019cfb56799 100644 --- a/backend/assets/coinTransfer/IndexAsset.php +++ b/backend/assets/airDrop/IndexAsset.php @@ -1,13 +1,13 @@ <?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', ]; diff --git a/backend/assets/coinPlatformWithhold/IndexAsset.php b/backend/assets/coinPlatformWithhold/IndexAsset.php new file mode 100644 index 0000000000000000000000000000000000000000..f39b5e42c3feda403f53eb47cc36a558d2e02257 --- /dev/null +++ b/backend/assets/coinPlatformWithhold/IndexAsset.php @@ -0,0 +1,17 @@ +<?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 diff --git a/backend/assets/coinSupportedSymbol/IndexAsset.php b/backend/assets/coinSupportedSymbol/IndexAsset.php new file mode 100644 index 0000000000000000000000000000000000000000..1de508ea28903afb1ba1bef31f85aac5d9fc4b8c --- /dev/null +++ b/backend/assets/coinSupportedSymbol/IndexAsset.php @@ -0,0 +1,24 @@ +<?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 diff --git a/backend/assets/platformCoins/IndexAsset.php b/backend/assets/platformCoins/IndexAsset.php new file mode 100644 index 0000000000000000000000000000000000000000..b2833d746f31d65ad3de7067e40f261b5bfed8eb --- /dev/null +++ b/backend/assets/platformCoins/IndexAsset.php @@ -0,0 +1,24 @@ +<?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 diff --git a/backend/controllers/AirDropController.php b/backend/controllers/AirDropController.php new file mode 100644 index 0000000000000000000000000000000000000000..65516771e1b13d10e6d0cfbf3e0f2b527093e1c2 --- /dev/null +++ b/backend/controllers/AirDropController.php @@ -0,0 +1,89 @@ +<?php + +namespace backend\controllers; + +use common\service\chain33\Chain33Service; +use Yii; +use yii\web\UploadedFile; +use common\models\psources\CoinAirDropTransfer; + +class AirDropController extends BaseController +{ + public $enableCsrfValidation = false; + + public function actionList() + { + $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 = CoinAirDropTransfer::getList($page, $limit, $condition); + return $data; + } + return $this->render('list'); + } + + /** + * 瀵煎叆cvs + */ + public function actionLoadFile() + { + Yii::$app->response->format = 'json'; + + $file = UploadedFile::getInstanceByName('file'); + try { + $fd = fopen($file->tempName, 'r'); + $data = []; + while (($row = fgetcsv($fd)) !== false) { + $data[] = $row; + } + if (ctype_digit($data[0][0])) { + array_shift($data); + } + foreach ($data as $key => &$value) { + $value[0] = trim($value[0]); + $value[1] = trim($value[1]); + } + + if ($data) { + $additional = [1, '0', ' ', 0]; + foreach ($data as $key => &$val) { + $val = array_merge($val, $additional); + } + if (CoinAirDropTransfer::loadArray($data)) { + return ['code' => 0, 'msg' => 'succeed']; + } + } + return ['code' => 1, 'msg' => '鏁版嵁涓虹┖']; + } catch (\Exception $e) { + return ['code' => $e->getCode(), 'msg' => $e->getMessage()]; + } + } + + public function actionAdd() + { + $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']; + } + $error = $model->errors; + if ($error) { + return ['code' => -1, 'msg' => current($model->firstErrors)]; + } + } else { + return $this->render('add'); + } + } +} \ No newline at end of file diff --git a/backend/controllers/ApplicationCategoryController.php b/backend/controllers/ApplicationCategoryController.php index 43558eb107736f52e6aa827446e0fe98fbb592ea..5f0d22a0634a0e714bbc0ef93239c937cb1809a5 100644 --- a/backend/controllers/ApplicationCategoryController.php +++ b/backend/controllers/ApplicationCategoryController.php @@ -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]); } /** diff --git a/backend/controllers/CoinPlatformBannerController.php b/backend/controllers/CoinPlatformBannerController.php new file mode 100644 index 0000000000000000000000000000000000000000..62046de392f7d36f4b45fc701346e4a6c02d1e78 --- /dev/null +++ b/backend/controllers/CoinPlatformBannerController.php @@ -0,0 +1,75 @@ +<?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 diff --git a/backend/controllers/CoinPlatformWithholdController.php b/backend/controllers/CoinPlatformWithholdController.php new file mode 100644 index 0000000000000000000000000000000000000000..60ff28f438821e4fb375fc0fa9c42ccfda30c58e --- /dev/null +++ b/backend/controllers/CoinPlatformWithholdController.php @@ -0,0 +1,91 @@ +<?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 diff --git a/backend/controllers/CoinSupportedSymbolController.php b/backend/controllers/CoinSupportedSymbolController.php new file mode 100644 index 0000000000000000000000000000000000000000..0e03fac8b44ea34ddeebecda035dc89888013cf8 --- /dev/null +++ b/backend/controllers/CoinSupportedSymbolController.php @@ -0,0 +1,83 @@ +<?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 diff --git a/backend/controllers/CoinTransferController.php b/backend/controllers/CoinTransferController.php deleted file mode 100644 index 5b3f2b9a6f3b68b8abb63ab1e95fbb7fa9f8c4b7..0000000000000000000000000000000000000000 --- a/backend/controllers/CoinTransferController.php +++ /dev/null @@ -1,112 +0,0 @@ -<?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; - -class CoinTransferController extends BaseController -{ - public $enableCsrfValidation = false; - - public function actionList() - { - $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); - return $data; - } - return $this->render('list'); - } - - /** - * 瀵煎叆cvs - */ - public function actionLoadFile() - { - Yii::$app->response->format = 'json'; - - $file = UploadedFile::getInstanceByName('file'); - try { - $fd = fopen($file->tempName, 'r'); - $data = []; - while (($row = fgetcsv($fd)) !== false) { - $data[] = $row; - } - if (ctype_digit($data[0][0])) { - array_shift($data); - } - foreach ($data as $key => &$value){ - $value[0] = trim($value[0]); - $value[1] = trim($value[1]); - } - if ($data) { - if (CoinTransfer::loadArray($data)) { - return ['code' => 0, 'msg' => 'succeed']; - } - } - return ['code' => 1, 'msg' => '鏁版嵁涓虹┖']; - } catch (\Exception $e) { - return ['code' => $e->getCode(), 'msg' => $e->getMessage()]; - } - } - - public function actionBatchTransfer() - { - $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; - } - $sign_str = $signRawTx['result']; - $result = $service->sendTransaction($sign_str); - if(0 != $result['code']){ - continue; - } - - $hash = $result['result']; - $current_model = CoinTransfer::findOne($id); - $current_model->hash = $hash; - $current_model->status = 1; - $current_model->save(); - echo $val->address."-----".$hash."<br/>"; - } - - } -} \ No newline at end of file diff --git a/backend/controllers/PlatformCoinsController.php b/backend/controllers/PlatformCoinsController.php new file mode 100644 index 0000000000000000000000000000000000000000..69dab5af3a5bdb1db4fc99d0223d831d93bbcffa --- /dev/null +++ b/backend/controllers/PlatformCoinsController.php @@ -0,0 +1,45 @@ +<?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 diff --git a/backend/models/coin/CoinPlatformWithholdForm.php b/backend/models/coin/CoinPlatformWithholdForm.php new file mode 100644 index 0000000000000000000000000000000000000000..e855a653e30cfb0c3a522ecc6110969cf99cb70b --- /dev/null +++ b/backend/models/coin/CoinPlatformWithholdForm.php @@ -0,0 +1,38 @@ +<?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 diff --git a/backend/models/coin/CoinSupportedSymbolForm.php b/backend/models/coin/CoinSupportedSymbolForm.php new file mode 100644 index 0000000000000000000000000000000000000000..ba0a622aa80b9c83b97b3daaaa6f11a470a4a909 --- /dev/null +++ b/backend/models/coin/CoinSupportedSymbolForm.php @@ -0,0 +1,51 @@ +<?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 diff --git a/backend/views/air-drop/add.php b/backend/views/air-drop/add.php new file mode 100644 index 0000000000000000000000000000000000000000..2051848fa426c108dcb49e0b91aa9e4420e8e436 --- /dev/null +++ b/backend/views/air-drop/add.php @@ -0,0 +1,18 @@ +<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 diff --git a/backend/views/coin-transfer/form.php b/backend/views/air-drop/form.php similarity index 100% rename from backend/views/coin-transfer/form.php rename to backend/views/air-drop/form.php diff --git a/backend/views/air-drop/list.php b/backend/views/air-drop/list.php new file mode 100644 index 0000000000000000000000000000000000000000..39e671757ce46f8499d3a0269dd58de76dc70be7 --- /dev/null +++ b/backend/views/air-drop/list.php @@ -0,0 +1,14 @@ +<?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> diff --git a/backend/views/application-category/index.php b/backend/views/application-category/index.php index c0f774cc85924518994208ed9d766def40fe9629..e2e44233bc0661b0b3aa77eb48f6c8837a63594e 100644 --- a/backend/views/application-category/index.php +++ b/backend/views/application-category/index.php @@ -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> diff --git a/backend/views/coin-platform-banner/index.php b/backend/views/coin-platform-banner/index.php new file mode 100644 index 0000000000000000000000000000000000000000..4df3a2b2348c4b0dac3338cf1c3f4a09b55282f8 --- /dev/null +++ b/backend/views/coin-platform-banner/index.php @@ -0,0 +1,153 @@ +<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"></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 diff --git a/backend/views/coin-platform-withhold/add.php b/backend/views/coin-platform-withhold/add.php new file mode 100644 index 0000000000000000000000000000000000000000..a1590d314e02d97bbd49cfafd8980855540f3636 --- /dev/null +++ b/backend/views/coin-platform-withhold/add.php @@ -0,0 +1,95 @@ +<?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> diff --git a/backend/views/coin-platform-withhold/edit.php b/backend/views/coin-platform-withhold/edit.php new file mode 100644 index 0000000000000000000000000000000000000000..6f710b172274971ef64d20e87745b2f3d1d58e82 --- /dev/null +++ b/backend/views/coin-platform-withhold/edit.php @@ -0,0 +1,44 @@ +<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> + diff --git a/backend/views/coin-platform-withhold/index.php b/backend/views/coin-platform-withhold/index.php new file mode 100644 index 0000000000000000000000000000000000000000..25a0b601e01d472c93ef1b545841df3c4ef2b63a --- /dev/null +++ b/backend/views/coin-platform-withhold/index.php @@ -0,0 +1,27 @@ +<?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> diff --git a/backend/views/coin-supported-symbol/add.php b/backend/views/coin-supported-symbol/add.php new file mode 100644 index 0000000000000000000000000000000000000000..83ef6e1c47cc795d07c0347b9c2cdf0f2d18a47c --- /dev/null +++ b/backend/views/coin-supported-symbol/add.php @@ -0,0 +1,24 @@ +<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> diff --git a/backend/views/coin-supported-symbol/edit.php b/backend/views/coin-supported-symbol/edit.php new file mode 100644 index 0000000000000000000000000000000000000000..fd3d46fb7b2a55e6d111b5d5a9622685ce1b71d9 --- /dev/null +++ b/backend/views/coin-supported-symbol/edit.php @@ -0,0 +1,65 @@ +<?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> diff --git a/backend/views/coin-supported-symbol/index.php b/backend/views/coin-supported-symbol/index.php new file mode 100644 index 0000000000000000000000000000000000000000..bef05bc9f6f75062d7e7103dbc26b6213203fe5f --- /dev/null +++ b/backend/views/coin-supported-symbol/index.php @@ -0,0 +1,36 @@ +<?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"></i></button> + </a> +</script> diff --git a/backend/views/coin-transfer/list.php b/backend/views/coin-transfer/list.php deleted file mode 100644 index 48209dfc3dd6cde34121ebe216f615c56cd88ceb..0000000000000000000000000000000000000000 --- a/backend/views/coin-transfer/list.php +++ /dev/null @@ -1,15 +0,0 @@ -<?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> diff --git a/backend/views/platform-coins/index.php b/backend/views/platform-coins/index.php new file mode 100644 index 0000000000000000000000000000000000000000..1507f33b0184c08978defb41cb3f5ec8d95a1cd7 --- /dev/null +++ b/backend/views/platform-coins/index.php @@ -0,0 +1,45 @@ +<?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"></i></button> + </a> + <a lay-event="delete"> + <button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon"></i></button> + </a> +</script> diff --git a/backend/web/js/air-drop/list.js b/backend/web/js/air-drop/list.js new file mode 100644 index 0000000000000000000000000000000000000000..40d6ca06c1348cc299d124570d57040a50d368da --- /dev/null +++ b/backend/web/js/air-drop/list.js @@ -0,0 +1,82 @@ +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 diff --git a/backend/web/js/application-category/index.js b/backend/web/js/application-category/index.js index 115b84875d602f854c1fb9cfb2c1254595e6ac21..42c24613a4e351a58e7354fa1e43a560dcf9d9a6 100644 --- a/backend/web/js/application-category/index.js +++ b/backend/web/js/application-category/index.js @@ -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}, diff --git a/backend/web/js/coin-platform-withhold/index.js b/backend/web/js/coin-platform-withhold/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8eaf15abb0544318e830c07ab5449cbef556060e --- /dev/null +++ b/backend/web/js/coin-platform-withhold/index.js @@ -0,0 +1,66 @@ +/** + * @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 diff --git a/backend/web/js/coin-supported-symbol/index.js b/backend/web/js/coin-supported-symbol/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ff0c105b4325fe3944be8022ff54a02719aa625f --- /dev/null +++ b/backend/web/js/coin-supported-symbol/index.js @@ -0,0 +1,44 @@ +/** + * @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 diff --git a/backend/web/js/platform-coins/index.js b/backend/web/js/platform-coins/index.js new file mode 100644 index 0000000000000000000000000000000000000000..f68f5aaea0804c028554315c25dc1eab6a233db9 --- /dev/null +++ b/backend/web/js/platform-coins/index.js @@ -0,0 +1,64 @@ +/** + * @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 diff --git a/common/business/ExchangeBusiness.php b/common/business/ExchangeBusiness.php index fb24f93b91eaa728a2c983ef9e596fd7f0e85e21..8869c56990bc6f40fc02033f6ebf436972c33584 100644 --- a/common/business/ExchangeBusiness.php +++ b/common/business/ExchangeBusiness.php @@ -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(); } diff --git a/common/models/psources/CoinAirDropTransfer.php b/common/models/psources/CoinAirDropTransfer.php new file mode 100644 index 0000000000000000000000000000000000000000..0375cfd83032a257036b7deafaae3f6df3e5edd7 --- /dev/null +++ b/common/models/psources/CoinAirDropTransfer.php @@ -0,0 +1,74 @@ +<?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 diff --git a/common/models/psources/CoinCrossChain.php b/common/models/psources/CoinCrossChain.php new file mode 100644 index 0000000000000000000000000000000000000000..24fe2d7dafca46566965b4ef4e2be2c1399850d0 --- /dev/null +++ b/common/models/psources/CoinCrossChain.php @@ -0,0 +1,42 @@ +<?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); + } +} diff --git a/common/models/psources/CoinPlatformBanner.php b/common/models/psources/CoinPlatformBanner.php new file mode 100644 index 0000000000000000000000000000000000000000..b60f76725f16fa84f1289b78670d8f3c4a9709e1 --- /dev/null +++ b/common/models/psources/CoinPlatformBanner.php @@ -0,0 +1,34 @@ +<?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 diff --git a/common/models/psources/CoinPlatformWithHold.php b/common/models/psources/CoinPlatformWithHold.php index c4aac2e9b3e3af20eae3073be6fb1eeafbee9a1e..dac37be2a5e787d03ea1772da5c82422350fb3ec 100644 --- a/common/models/psources/CoinPlatformWithHold.php +++ b/common/models/psources/CoinPlatformWithHold.php @@ -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 diff --git a/common/models/psources/CoinSupportedSymbol.php b/common/models/psources/CoinSupportedSymbol.php new file mode 100644 index 0000000000000000000000000000000000000000..037bfab3b15a43e7aeb8ba585680687bf623d88b --- /dev/null +++ b/common/models/psources/CoinSupportedSymbol.php @@ -0,0 +1,39 @@ +<?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()]; + } + } +} diff --git a/common/models/psources/CoinTransfer.php b/common/models/psources/CoinTransfer.php deleted file mode 100644 index faa995b904170d7987637d3b494297a73bf68228..0000000000000000000000000000000000000000 --- a/common/models/psources/CoinTransfer.php +++ /dev/null @@ -1,75 +0,0 @@ -<?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(); - } -} diff --git a/common/service/chain33/Chain33Service.php b/common/service/chain33/Chain33Service.php index 7ba8d442d3b2259021dcd4dfad732d2b283ca828..b0426e049c6e7f3a1345fde5572dc18c9f2206be 100644 --- a/common/service/chain33/Chain33Service.php +++ b/common/service/chain33/Chain33Service.php @@ -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 = [ diff --git a/common/service/exchange/Binance.php b/common/service/exchange/Binance.php new file mode 100644 index 0000000000000000000000000000000000000000..54a39f6392f27d6888934579ff7fedcbd2f62b9a --- /dev/null +++ b/common/service/exchange/Binance.php @@ -0,0 +1,51 @@ +<?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 diff --git a/common/service/exchange/Ceohk.php b/common/service/exchange/Ceohk.php new file mode 100644 index 0000000000000000000000000000000000000000..2252a02d75392908126ac4313af865d220dd1ad1 --- /dev/null +++ b/common/service/exchange/Ceohk.php @@ -0,0 +1,61 @@ +<?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); + } + + /** + * 淇濆瓨鏀寔鐨勪氦鏄撳鍒皉edis鏁版嵁搴擄紝浣跨敤crontab瀹氭椂鏇存柊 + * + * @return mixed|void + */ + public function setSupportedSymbol() + { + $this->redis->sadd($this->supported_symbol, 'TIX_QC'); + } + + /** + * 鏇存柊浜ゆ槗瀵硅鎯呬繚瀛樺埌redis锛屼娇鐢╟rontab瀹氭椂鏇存柊 + * + * @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 diff --git a/common/service/exchange/HuoBi.php b/common/service/exchange/HuoBi.php index e4b655efed8e0e4fac6a379c70c043daebcf49d2..4f6c45352825d6add6bfb14546d33ca2e3bf36f5 100644 --- a/common/service/exchange/HuoBi.php +++ b/common/service/exchange/HuoBi.php @@ -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']); } } diff --git a/common/service/exchange/Tsc.php b/common/service/exchange/Tsc.php new file mode 100644 index 0000000000000000000000000000000000000000..52d19ef5dc0bd52bc24f285a8312eb7660b58a73 --- /dev/null +++ b/common/service/exchange/Tsc.php @@ -0,0 +1,70 @@ +<?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); + } + + /** + * 淇濆瓨鏀寔鐨勪氦鏄撳鍒皉edis鏁版嵁搴擄紝浣跨敤crontab瀹氭椂鏇存柊 + * + * @return mixed|void + */ + public function setSupportedSymbol() + { + $this->redis->sadd($this->supported_symbol, 'TSC_CNDT'); + } + + /** + * 鏇存柊浜ゆ槗瀵硅鎯呬繚瀛樺埌redis锛屼娇鐢╟rontab瀹氭椂鏇存柊 + * + * @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 diff --git a/common/service/exchange/Zt.php b/common/service/exchange/Zt.php new file mode 100644 index 0000000000000000000000000000000000000000..837af217339e3637523847686e6131c2853e0b20 --- /dev/null +++ b/common/service/exchange/Zt.php @@ -0,0 +1,72 @@ +<?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); + } + + /** + * 淇濆瓨鏀寔鐨勪氦鏄撳鍒皉edis鏁版嵁搴擄紝浣跨敤crontab瀹氭椂鏇存柊 + * + * @return mixed|void + */ + public function setSupportedSymbol() + { + $this->redis->sadd($this->supported_symbol, 'CICUSDT'); + } + + /** + * 鏇存柊浜ゆ槗瀵硅鎯呬繚瀛樺埌redis锛屼娇鐢╟rontab瀹氭椂鏇存柊 + * + * @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 diff --git a/console/controllers/AirDropController.php b/console/controllers/AirDropController.php new file mode 100644 index 0000000000000000000000000000000000000000..7dba8b75a8f168d73c7b3b21d1592ca133cd471e --- /dev/null +++ b/console/controllers/AirDropController.php @@ -0,0 +1,73 @@ +<?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 diff --git a/console/controllers/CrossChainController.php b/console/controllers/CrossChainController.php new file mode 100644 index 0000000000000000000000000000000000000000..37a52d5d4e85bc35787cf06c84f5c9a6b9a71ebc --- /dev/null +++ b/console/controllers/CrossChainController.php @@ -0,0 +1,135 @@ +<?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 diff --git a/h5/controllers/CoinController.php b/h5/controllers/CoinController.php index 9e1987140def0af27b949417eb1258b1596b148a..965f7e0b5ac3eb991afff0250008d6c574d96f57 100644 --- a/h5/controllers/CoinController.php +++ b/h5/controllers/CoinController.php @@ -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_; diff --git a/shell/AutoTransfer.sh b/shell/AutoTransfer.sh new file mode 100644 index 0000000000000000000000000000000000000000..862396666cefbbc58801b727e9846f39871f865c --- /dev/null +++ b/shell/AutoTransfer.sh @@ -0,0 +1,2 @@ +#!/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 diff --git a/shell/QueryTransaction.sh b/shell/QueryTransaction.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4cf814fcb12ce0578c595751f85496f22676a36 --- /dev/null +++ b/shell/QueryTransaction.sh @@ -0,0 +1,2 @@ +#!/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