Commit 647b1c0b authored by shajiaiming's avatar shajiaiming

merge master

parents fa1c9738 3feb1957
<?php
namespace api\base;
class BaseConstant
{
const ERROR = 'error';
const MSG = 'msg';
const MESSAGE = 'message';
const CODE = 'code';
const VAL = 'val';
const DATA = 'data';
const OK = 'ok';
const FINALTAG = 'finaltag';
}
......@@ -33,6 +33,9 @@ class BaseController extends Controller
public function fzmCrossHeader()
{
$this->lang = \Yii::$app->request->headers->get('lang') ?? 'zh-CN';
if ('en' == strtolower($this->lang)){
$this->lang = 'en-US';
}
}
public function beforeAction($action)
......
......@@ -37,7 +37,7 @@ class BaseResponse extends Response
$return = $data;
}
if (YII_ENV_DEV) {
$return['time'] = \Yii::$app->controller->end - \Yii::$app->controller->start;
#$return['time'] = \Yii::$app->controller->end - \Yii::$app->controller->start;
}
\Yii::$app->response->data = $return;
parent::send();
......
<?php
namespace api\base;
use yii\helpers\Html;
use yii\web\Response;
class ResponseMsg
{
public $is_support_jsonp = false;
public $header_list = [];
private static $default_header_list = [];
public function __construct()
{
// if ('cli' !== php_sapi_name()){
// $this->header_list = self::$default_header_list;
// $this->fzmCrossHeader();
// }
}
public function fzmCrossHeader()
{
$allow_list = \Yii::$app->params['allow_options_domain']['common'];
$origin = \Yii::$app->request->headers->get('Origin');
if (!in_array($origin, $allow_list)) {
$origin = implode(',', $allow_list);
}
$this->header('Access-Control-Allow-Origin', $origin);
$this->header('Access-Control-Allow-Methods', 'POST,GET,OPTIONS');
$this->header('Access-Control-Allow-Credentials', 'true');
$this->header('Access-Control-Allow-Headers', 'Authorization,FZM-REQUEST-OS,FZM-USER-IP,FZM-REQUEST-UUID,Content-Type,Content-Length');
}
public static function setDefaultHeader($default_header_list)
{
foreach ($default_header_list as $key => $header) {
self::$default_header_list[$key] = $header;
}
}
public static function getDefaultHeader()
{
return self::$default_header_list;
}
public function arrSuccess($data = BaseConstant::OK, $code = 200)
{
return [BaseConstant::ERROR => false, BaseConstant::MESSAGE => $data, BaseConstant::CODE => $code];
}
public function arrFail($data, $code = -1)
{
return [BaseConstant::ERROR => true, BaseConstant::MESSAGE => $data, BaseConstant::CODE => $code];
}
/**
* 失败返回接口
* @param string $msg
* @param int $code
* @return string
*/
public function jsonError($msg = '', $code = -1)
{
if (empty($msg)) {
$msg = 'unknown error';
}
$view = [
BaseConstant::CODE => $code,
BaseConstant::MSG => $msg,
BaseConstant::DATA => null,
];
$json = json_encode($view);
return $this->dumpJsonData($json);
}
/**
* 成功返回接口
* @param string $msg
* @param int $code
* @return string
*/
public function jsonSuccess($data = '', $code = 200)
{
$view = [
BaseConstant::CODE => $code,
BaseConstant::MESSAGE => BaseConstant::OK,
BaseConstant::DATA => $data
];
$json = json_encode($view);
return $this->dumpJsonData($json);
}
/**
* 直接处理接口数据
* @param $ret
*/
public function dealRet($ret)
{
if (true === $ret[BaseConstant::ERROR]) {
$this->jsonError($ret[BaseConstant::MESSAGE] ? : 'unknown error');
} else {
$this->jsonSuccess($ret[BaseConstant::MESSAGE] ? : BaseConstant::OK);
}
}
/**
* 根据是否为JSONP做特殊处理输出
* @param $json
* @return string
*/
public function dumpJsonData($json)
{
$callback = '';
if (true === $this->is_support_jsonp) {
if (!$this->isDebug()) {
$this->header('Content-type', 'application/javascript');
}
$callback_key = 'jsonpcallback';
$callback = $_GET[$callback_key];
if ($callback) {
$callback = Html::encode($callback_key);
$json = $callback . '(' . $json . ')';
}
}
if (!$callback && !$this->isDebug()) {
$this->header('Content-type', 'application/json');
}
return $json;
}
/**
* @param $json_str
* @param string $callback_key
* @return string
*/
public function printByJson($json_str, $callback_key = '')
{
$callback = '';
if ($callback_key) {
$callback = $_GET[$callback_key] ?? '';
}
if ($callback) {
$callback = Html::encode($callback_key);
if (!$this->isDebug()) {
$this->header('Content-type', 'application/javascript');
}
return $callback . '(' . $json_str . ')';
} else {
if (!$this->isDebug()) {
$this->header('Content-type', 'application/json');
}
return $json_str;
}
}
/**
* @param $arr
* @param string $callback_key
* @return string
*/
public function printByArr($arr, $callback_key = '')
{
$callback = '';
if ($callback_key) {
$callback = $_GET[$callback_key] ?? '';
}
if ($callback) {
$callback = Html::encode($callback_key);
if (!$this->isDebug()) {
$this->header('Content-type', 'application/javascript');
}
return $callback . '(' . json_encode($arr) . ')';
} else {
if (!$this->isDebug()) {
$this->header('Content-type', 'application/json');
}
return json_encode($arr);
}
}
public function printOldFail($code, $code_msg, $detail_code, $detail_msg, $callback_key = '')
{
$this->fzmCrossHeader();
$callback = '';
if ($callback_key) {
$callback = $_GET[$callback_key] ?? '';
}
$arr = ['code' => $code, 'error' => $code_msg, 'ecode' => $detail_code, 'message' => $detail_msg, 'data' => []];
if ($callback) {
$callback = Html::encode($callback_key);
if (!$this->isDebug()) {
$this->header('Content-type', 'application/javascript');
}
return $callback . '(' . json_encode($arr) . ')';
} else {
if (!$this->isDebug()) {
$this->header('Content-type', 'application/json');
}
return json_encode($arr);
}
}
/**
* @param $success_data
* @param string $callback_key
* @return string
*/
public function printOldSuccess($success_data, $callback_key = '')
{
$this->fzmCrossHeader();
$callback = '';
if ($callback_key) {
$callback = $_GET[$callback_key] ?? '';
}
$arr = ['code' => 200, 'ecode' => 200, 'error' => 'OK', 'message' => 'OK', 'data' => $success_data];
if ($callback) {
$callback = Html::encode($callback_key);
if (!$this->isDebug()) {
$this->header('Content-type', 'application/javascript');
}
return $callback . '(' . json_encode($arr) . ')';
} else {
if (!$this->isDebug()) {
$this->header('Content-type', 'application/json');
}
return json_encode($arr);
}
}
/**
* 解决xdebug cookie设置不了的问题
*/
private function isDebug()
{
if (defined('SERVICE_ENV') && (SERVICE_ENV === 'test' || SERVICE_ENV === 'local') && isset($_GET['debug'])) {
return true;
}
return false;
}
public function header($key, $value)
{
$this->header_list[$key] = $value;
}
public function getHeaders()
{
return $this->header_list;
}
public function withHeaders($header_arr)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
foreach ($header_arr as $key => $val) {
\Yii::$app->response->headers->add($key, $val);
}
return $this;
}
public function withContent($content)
{
return $content;
}
}
......@@ -60,15 +60,17 @@ class AppController extends BaseController
$platform_id = \Yii::$app->request->post('platform_id', 1);
$data = CoinAppVersion::getLastStable($type,$platform_id);
if ($data) {
$logItems = json_decode($data['log']);
$logstr = '';
foreach($logItems as $item){
if($logstr){
$logstr .="\n".$item;
}else{
$logstr = $item;
if(!empty($data['log'])){
$logItems = json_decode($data['log']);
$logstr = '';
foreach($logItems as $item){
if($logstr){
$logstr .="\n".$item;
}else{
$logstr = $item;
}
}
}
$data['log'] = $logstr;
$data['id']=(integer)$data['id'];
......
......@@ -31,8 +31,22 @@ class ApplicationController extends BaseController
}
$recommendData = ApplicationBusiness::getRecommendList($condition);
foreach($recommendData as $j => &$val){
$name_arr = json_decode($val['name'], true);
$val['name'] = $name_arr[$this->lang];
}
$data['recommend'] =$recommendData;
$cate_app_data = ApplicationBusiness::getCategoryAppList($condition);
foreach ($cate_app_data as $key => &$val){
$name = json_decode($val['name'], true);
$val['name'] = $name[$this->lang];
if(!empty($val['apps'])){
foreach($val['apps'] as $j => &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
}
}
}
$data['cate_app_data'] = $cate_app_data;
$data['banner'] = ApplicationBusiness::getBannerList($condition);
$result['code'] = 0;
......@@ -48,6 +62,16 @@ class ApplicationController extends BaseController
{
$result['code'] = 0;
$result['data'] = ApplicationBusiness::getCategoryAppList();
foreach ($result['data'] as $key => &$val){
$name = json_decode($val['name'], true);
$val['name'] = $name[$this->lang];
if(!empty($val['apps'])){
foreach($val['apps'] as $j => &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
}
}
}
return $result;
}
......@@ -59,7 +83,11 @@ class ApplicationController extends BaseController
$request = Yii::$app->request;
$id = $request->post('id',0);
if($id){
return ApplicationBusiness::appInfo($id);
$result = ApplicationBusiness::appInfo($id);
$data = $result['data'];
$name = json_decode($data['name'], true);
$data['name'] = $name[$this->lang];
return ['code' => 0,'data' => $data];
}else{
return ['code' => 1,'data' => [],'msg' => 'id不能为空'];
}
......@@ -126,6 +154,8 @@ class ApplicationController extends BaseController
$icon_Items = array_column($appItems,'icon');
$icon_Infos = CoinImage::getItemsByIds($icon_Items);
foreach($appItems as &$value){
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
if($value['icon']){
$value['icon'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'];
}else{
......@@ -138,7 +168,9 @@ class ApplicationController extends BaseController
$cate_id = $item['cate_id'];
$app_id = $item['app_id'];
$cate_app_items[$cate_id]['cate_id'] = $cate_id;
$cate_app_items[$cate_id]['name'] = $item['name'];
$name_arr = json_decode($item['name'], true);
$name = $name_arr[$this->lang];
$cate_app_items[$cate_id]['name'] = $name;
$cate_app_items[$cate_id]['apps'][] = $appItems[$app_id];
}
foreach ($cate_app_items as $item){
......@@ -159,13 +191,16 @@ class ApplicationController extends BaseController
$cate_id = $request->get('cate_id','');
if($cate_id){
$cate_info = CoinApplicationCategory::getCategoryById($cate_id);
$name = $cate_info->name[$this->lang];
$cate_info_data['id'] = $cate_info->id;
$cate_info_data['name'] = $cate_info->name;
$cate_info_data['name'] = $name;
$appItems = ApplicationBusiness::getCateAppInfo(0,[['cate_id' => $cate_id]]);
if($appItems){
$appItems = array_shift($appItems);
foreach($appItems as &$value){
$value['app_user_num'] = ApplicationBusiness::getAppUserNum($value['app_id']);
$name_arr = json_decode($value['name'], true);
$value['name'] = $name_arr[$this->lang];
}
$cate_info_data['apps'] = $appItems;
return ['code' => 0,'data' => $cate_info_data];
......
This diff is collapsed.
<?php
namespace api\controllers;
use linslin\yii2\curl\Curl;
use Yii;
use api\base\BaseController;
class CoinDogController extends BaseController
{
public function actionArticle()
{
$coindog = Yii::$app->params['coindog'];
$accessKey = $coindog['accessKey'];
$secretKey = $coindog['secretKey'];
$httpParams = array(
'access_key' => $accessKey,
'date' => time()
);
$signParams = array_merge($httpParams, array('secret_key' => $secretKey));
ksort($signParams);
$signString = http_build_query($signParams);
$httpParams['sign'] = strtolower(md5($signString));
$url = $coindog['article'] . '?' . http_build_query($httpParams);
$curl = new Curl();
$resp = $curl->get($url, false);
return ['code' => 200, 'data' => $resp, 'msg' => 'ok'];
}
public function actionLive()
{
$limit = Yii::$app->request->get('limit', 20);
$id = Yii::$app->request->get('id', 0);
$flag = Yii::$app->request->get('flag', 'down');
$coindog = Yii::$app->params['coindog'];
$accessKey = $coindog['accessKey'];
$secretKey = $coindog['secretKey'];
$httpParams = array(
'access_key' => $accessKey,
'date' => time()
);
$signParams = array_merge($httpParams, array('secret_key' => $secretKey));
ksort($signParams);
$signString = http_build_query($signParams);
$httpParams = [
'sign' => strtolower(md5($signString)),
'limit' => $limit,
'id' => $id,
'flag' => $flag
];
$url = $coindog['live'] . '?' . http_build_query($httpParams);
$curl = new Curl();
$resp = $curl->get($url, false);
if (!isset($resp['list'])) {
$msg = '数据不存在';
$code = -1;
$data = null;
goto doEnd;
}
$list = $resp['list'][0]['lives'];
foreach ($list as &$item) {
preg_match_all("/\【(.+?)\】/", $item['content'], $match);
$item['title'] = $match[1][0];
}
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'data' => $list, 'msg' => $msg];
}
}
\ No newline at end of file
<?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'];
$data['step'] = $val['step'];
$data['amount'] = isset($val['amount']) ? $val['amount'] : 0;
$model->load($data, '');
$model->save();
}
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg];
}
public function actionFixTransfer()
{
$code = -1;
$request = Yii::$app->request;
if (!$request->isPost) {
$msg = '请求错误!';
goto doEnd;
}
$post = $request->post();
$data['is_with_draw'] = (false == $post['isWithdraw']) ? 0 : 1;
$data['address'] = $post['address'];
foreach ($post['txs'] as $key => $val) {
$model = CoinCrossChain::find()->where(['is_with_draw' => $data['is_with_draw']])
->andWhere(['address' => $data['address']])
->andWhere(['step' => $val['step']])
->andWhere(['<>', 'msg', 'success'])
->one();
if(false == $model) continue;
$node_params = $model->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 = $model->send_result;
$result = $service->QueryTransaction($send_result);
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$model->query_result = 'success';
$model->msg = 'success';
$model->save();
continue;
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
$model->query_result = 'success';
$model->msg = 'success';
$model->save();
continue;
} else {
$model->txhex = $val['tx'];
$model->transfer_url = $val['url'];
$model->send_result = 0;
$model->query_result = 0;
$model->msg = 0;
$model->save();
continue;
}
}
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg];
}
public function actionTransferStatus()
{
$code = -1;
$msg = 'fail';
$data = null;
$step = $amount = 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 = '数据不存在!';
$code = 0;
goto doEnd;
}
sort($model);
foreach ($model as $key => $val) {
$amount = $val['amount'];
//未交易
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'] && 'success' != $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,
'amount' => (int)$amount
];
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
......@@ -10,61 +10,12 @@ use yii\data\Pagination;
class GameBetController extends BaseController
{
/**
* 获取游戏状态
*
* @return array
*/
public function actionGameStatus()
{
$service = new Chain33Business();
$result = $service->getGameStatus();
if( 0 !== $result['code']){
return ['code' => -1,'data' => [], 'msg' => $result['msg']];
}
$queryResultItems = $result['result'] ?? [];
if(empty($queryResultItems)){
return ['code' => -1,'data' => [], 'msg' => 'error'];
}
$resultJSON = json_decode($queryResultItems['queryResultItems'][0]['resultJSON'],true);
$current_round = $resultJSON['current_round'];
$cache_current_round = Yii::$app->redis->get('chain33_game_status');
if(empty($cache_current_round)){
$cache_current_round = CoinGameBet::find()->max('round');
Yii::$app->redis->set('chain33_game_status',$cache_current_round,'EX',300);
}
$cache_current_round = (false == $cache_current_round ? 0 : $cache_current_round);
if($cache_current_round >= $current_round){
return ['code' => -1,'data' => [], 'msg' => '数据已为最新'];
}
Yii::$app->redis->set('chain33_game_status',$current_round,'EX',300);
$result = $service->getBetStatus($cache_current_round, $current_round);
if( 0 !== $result['code']){
return ['code' => -1,'data' => [], 'msg' => '数据错误'];
}
$queryResultItems = $result['result'] ?? [];
if(empty($queryResultItems)){
return ['code' => -1,'data' => [], 'msg' => '数据错误'];
}
foreach ($queryResultItems['queryResultItems'] as $key => $val){
if( false == $val['found'] ) continue;
$resultArr = json_decode($val['resultJSON'],true);
$datas[] = [
$resultArr['round'], $resultArr['player'], $resultArr['amount'], $resultArr['height'], $resultArr['guess_num'], $resultArr['rand_num'], $resultArr['player_win']
];
}
CoinGameBet::loadArray($datas);
return ['code' => 1,'data' => [], 'msg' => '数据更新成功'];
}
public function actionBetStatus()
{
$platform = Yii::$app->request->get('platform', 'ts_wallet');
$player = Yii::$app->request->get('player', '');
$page = Yii::$app->request->get('page', 1);
if(empty($player)){
if(empty($player) || empty($platform)){
$msg = '请求参数错误';
$code = -1;
$data = null;
......@@ -72,9 +23,10 @@ class GameBetController extends BaseController
}
$query = CoinGameBet::find()
->select('round, player, amount, height, guess_num, guess_num, rand_num, player_win')
->select('round, player, amount, height, guess_num, valid, rand_num, player_win, platform')
->where('player= :player',[':player' => $player])
#->andWhere(['valid' => CoinGameBet::VAILD_TRUE])
->andWhere(['platform' => $platform])
//->andWhere(['valid' => CoinGameBet::VAILD_TRUE])
->orderBy('update_time desc');
$count = $query->count();
......
......@@ -11,46 +11,90 @@ namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\pwallet\GameUser;
use common\models\pwallet\GameUserAddress;
class GameController extends BaseController {
/**
* 保存地址与昵称
*/
public function actionSaveAddressAndNickname(){
$post = Yii::$app->request->post();
$address = $post['address']??'';
$nickname = $post['nickname']??'';
if (empty($address) || empty($nickname)) {
return ['code' => -1, 'msg' => '地址和昵称不能为空', 'data' => ''];
}
//判断重复
$count = GameUser::find()->where(['nickname' => $nickname])->count();
if ($count > 0) {
return ['code' => -1, 'msg' => '昵称重复'];
}
// todo 保存
$models = new GameUser();
$models->nickname = $nickname;
$models->address = $address;
if ($models->save()) {
return ['code' => 0, 'msg' => 'Succeed', 'data' => $models->id];
}
return ['code' => -1, 'msg' => 'Failed'];
}
class GameController extends BaseController
{
/**
* 保存地址与昵称
*/
public function actionSaveAddressAndNickname()
{
$post = Yii::$app->request->post();
$address = $post['address'] ?? '';
$nickname = $post['nickname'] ?? '';
if (empty($address) || empty($nickname)) {
return ['code' => -1, 'msg' => '地址和昵称不能为空', 'data' => null];
}
//判断重复
$count = GameUser::find()->where(['nickname' => $nickname])->count();
if ($count > 0) {
return ['code' => -1, 'msg' => '昵称重复'];
}
// todo 保存
$models = new GameUser();
$models->nickname = $nickname;
$models->address = $address;
if ($models->save()) {
return ['code' => 0, 'msg' => 'Succeed', 'data' => $models->id];
}
return ['code' => -1, 'msg' => 'Failed'];
}
/**
* 根据地址获取昵称
*/
public function actionGetNicknameByAddress(){
$address = Yii::$app->request->post('address', '');
if (empty($address)) {
return ['code' => -1, 'msg' => '地址不能为空', 'data' => ''];
}
//todo 获取地址
$address = GameUser::find()->select(['nickname'])->where(['address' => $address])->one();
if (!empty($address)) {
return ['code' => 0, 'msg'=> 'Succeed', 'data' => $address];
}
return ['code' => -1, 'msg' => 'Failed'];
}
/**
* 根据地址获取昵称
*/
public function actionGetNicknameByAddress()
{
$address = Yii::$app->request->post('address', '');
if (empty($address)) {
return ['code' => -1, 'msg' => '地址不能为空', 'data' => null];
}
//todo 获取地址
$address = GameUser::find()->select(['nickname'])->where(['address' => $address])->one();
if (!empty($address)) {
return ['code' => 0, 'msg' => 'Succeed', 'data' => $address];
}
return ['code' => -1, 'msg' => 'Failed'];
}
public function actionSaveGameInfo()
{
$post = Yii::$app->request->post();
$address = $post['address'] ?? '';
$nickname = $post['nickname'] ?? '';
if (empty($address) || empty($nickname)) {
return ['code' => -1, 'msg' => '地址和昵称不能为空', 'data' => null];
}
//判断重复
$count = GameUserAddress::find()->where(['address' => $address])->count();
if ($count > 0) {
return ['code' => -1, 'msg' => '地址已存在', 'data' => null];
}
// todo 保存
$models = new GameUserAddress();
$models->nickname = $nickname;
$models->address = $address;
if ($models->save()) {
return ['code' => 0, 'msg' => 'Succeed', 'data' => $models->id];
}
return ['code' => -1, 'msg' => 'Failed', 'data' => null];
}
public function actionGetNicknameByAddressArr()
{
$address = Yii::$app->request->post('address', '');
if (empty($address)) {
return ['code' => -1, 'msg' => '地址不能为空', 'data' => null];
}
//todo 获取地址
$address = GameUserAddress::find()
->select(['nickname', 'address'])
->where(['in', 'address', $address])
->asArray()->all();
if (!empty($address)) {
return ['code' => 0, 'msg' => 'Succeed', 'data' => $address];
}
return ['code' => -1, 'msg' => '数据为空', 'data' => null];
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
namespace api\controllers;
use common\service\exchange\ExchangeBuilderFactory;
use Yii;
use api\base\BaseController;
use common\models\pwallet\Notice;
......@@ -29,10 +30,10 @@ class NoticeController extends BaseController
*/
public function actionList()
{
$request = Yii::$app->request;
$page = $request->post('page', 1);
$limit = $request->post('limit', 10);
$post = $request->post();
$request = Yii::$app->request;
$page = $request->post('page', 1);
$limit = $request->post('limit', 10);
$post = $request->post();
$condition = [];
$post = array_filter($post, function ($value, $key) {
......@@ -65,4 +66,32 @@ class NoticeController extends BaseController
$data = Notice::getList($page, $limit, $condition);
return $data;
}
public function actionIndex()
{
$id = Yii::$app->request->get('id', '');
$page = Yii::$app->request->get('page', 1);
$size = Yii::$app->request->get('size', 10);
$exchange = Yii::$app->request->get('exchange', 'zhaobi');
$exchange_arr = ['huobi', 'binance', 'okex', 'zhaobi'];
if (!in_array($exchange, $exchange_arr)) {
$msg = '不存在的交易平台';
$code = -1;
$data = [];
goto doEnd;
}
$params = [
'id' => $id,
'page' => $page,
'size' => $size
];
$builder = ExchangeBuilderFactory::create($exchange);
$result = $builder->getNotice($params);
$code = $result['code'];
$data = $result['notice'];
$msg = isset($result['msg']) ? $result['msg'] : 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
* Date: 2018/12/29
* Time: 16:26
*/
namespace api\controllers;
use api\base\BaseController;
......@@ -33,23 +34,23 @@ class ServiceController extends BaseController
public function actionCoinTickers()
{
$request = Yii::$app->request;
$coinItems = $request->post('names');
if(!$coinItems){
return ['code' => 1,'data' => [],'msg' => '币种不能为空'];
$coinItems = $request->post('names');
if (!$coinItems) {
return ['code' => 1, 'data' => [], 'msg' => '币种不能为空'];
}
if(!is_array($coinItems)){
if (!is_array($coinItems)) {
$coinItems = [$coinItems];
}
$tol_coins = ['ETC'];
$tickerData = [];
if($coinItems){
foreach($coinItems as $item){
if ($coinItems) {
foreach ($coinItems as $item) {
$item = strtoupper($item);
if(in_array($item,$tol_coins)){
if (in_array($item, $tol_coins)) {
$exchange = ExchangeFactory::createExchange('HuoBi');
if ($exchange->symbolExists($item)) {
$quotation = $exchange->getTicker($item);
if($quotation){
if ($quotation) {
//格式化行情数据
foreach ($quotation as $key => $value) {
$quotation[$key] = (float)sprintf("%0.4f", (double)$value);
......@@ -58,30 +59,34 @@ class ServiceController extends BaseController
$quotation['rmb'] = (float)sprintf("%0.4f", $rate * $quotation['last']);
}
}
}else{
$quotation = ExchangeBusiness::getquatation($item);
} else {
$quotation = ExchangeBusiness::getquatation($item);
}
if (!$quotation) {
//使用Coin服务
try {
$coinServer = CoinFactory::createCoin($item, '', '');
$tickerData[$item]['rmb'] = $coinServer->getPrice();
$coinServer = CoinFactory::createCoin($item, '', '');
$tickerData[$item]['rmb'] = $coinServer->getPrice();
$tickerData[$item]['last'] = $coinServer->getDollar();
$tickerData[$item]['low'] = $coinServer->getLow();
$tickerData[$item]['low'] = $coinServer->getLow();
$tickerData[$item]['high'] = $coinServer->getHigh();
$tickerData[$item]['open'] = $coinServer->getDollar();
$tickerData[$item]['usd'] = $coinServer->getDollar();
$coinServer->__destruct();
} catch (\Exception $exception) {
$tickerData[$item]['rmb'] = 0;
$tickerData[$item]['rmb'] = 0;
$tickerData[$item]['last'] = 0;
$tickerData[$item]['low'] = 0;
$tickerData[$item]['low'] = 0;
$tickerData[$item]['high'] = 0;
$tickerData[$item]['open'] = 0;
$tickerData[$item]['usd'] = 0;
\Yii::error($exception->getMessage());
}
}else{
} else {
$tickerData[$item] = $quotation;
}
}
return ['code' => 0,'data' => $tickerData,'msg' => '行情获取成功'];
return ['code' => 0, 'data' => $tickerData, 'msg' => '行情获取成功'];
}
}
......@@ -94,13 +99,13 @@ class ServiceController extends BaseController
$platform_id = Yii::$app->request->get('platform_id', 6);
$type = Yii::$app->request->get('type', 1);
$coin_recommendItems = $this->coinRecommendList($platform_id, $type);
$fields =['id', 'sid', 'icon', 'name', 'nickname','chain','platform'];
$rows = Coin::getSelectList(1, 999, $fields,[['in','id',$coin_recommendItems]]);
$fields = ['id', 'sid', 'icon', 'name', 'nickname', 'chain', 'platform'];
$rows = Coin::getSelectList(1, 999, $fields, [['in', 'id', $coin_recommendItems]]);
foreach ($rows['data'] as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = $nickname[$this->lang];
}
return ['code' => 0,'data' => $rows,'msg' => '币种列表获取成功'];
return ['code' => 0, 'data' => $rows, 'msg' => '币种列表获取成功'];
}
/**
......@@ -109,9 +114,9 @@ class ServiceController extends BaseController
*/
private function coinRecommendList($platform_id, $type = 1)
{
$recommend_list = CoinRecommend::find()->select('cid')->where(['platform_id' => $platform_id ,'type' => $type])->all();
if($recommend_list){
$coin_ids = array_column($recommend_list,'cid');
$recommend_list = CoinRecommend::find()->select('cid')->where(['platform_id' => $platform_id, 'type' => $type])->all();
if ($recommend_list) {
$coin_ids = array_column($recommend_list, 'cid');
return $coin_ids;
}
return [];
......@@ -124,15 +129,15 @@ class ServiceController extends BaseController
public function actionFee()
{
$request = Yii::$app->request;
$coin = $request->post('name');
if(!$coin){
return ['code' => 1,'data' => [],'msg' => '币种不能为空'];
$coin = $request->post('name');
if (!$coin) {
return ['code' => 1, 'data' => [], 'msg' => '币种不能为空'];
}
$fee = MinerFee::find()->where(['platform' => $coin,'type' => 2])->select('id,platform,type,fee,create_at,update_at')->asArray()->one();
if(!$fee){
return ['code' => 1,'data' => [],'msg' => '旷工费未设置'];
$fee = MinerFee::find()->where(['platform' => $coin, 'type' => 2])->select('id,platform,type,fee,create_at,update_at')->asArray()->one();
if (!$fee) {
return ['code' => 1, 'data' => [], 'msg' => '旷工费未设置'];
}
return ['code' => 0,'data' => $fee,'msg' => '旷工费获取成功'];
return ['code' => 0, 'data' => $fee, 'msg' => '旷工费获取成功'];
}
/**
......@@ -141,8 +146,8 @@ class ServiceController extends BaseController
*/
private function getRate()
{
$exchange = ExchangeFactory::createExchange("Bty");
$rate = $exchange->getTicker("BTY", "USDT");
$exchange = ExchangeFactory::createExchange("Bty");
$rate = $exchange->getTicker("BTY", "USDT");
return (float)$rate['rmb'] / $rate['last'];
}
......@@ -153,12 +158,12 @@ class ServiceController extends BaseController
public function actionChain()
{
$request = Yii::$app->request;
$currency = $request->post('currency','');
$currency = $request->post('currency', '');
$coin = Coin::find()->where(['name' => $currency])->select('name,nickname,chain')->asArray()->one();
if($coin){
return ['code' => 0,'data' => $coin];
if ($coin) {
return ['code' => 0, 'data' => $coin];
}
return ['code' => -1,'msg' => '币种不存在'];
return ['code' => -1, 'msg' => '币种不存在'];
}
}
<?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 api\controllers;
use linslin\yii2\curl\Curl;
use Yii;
use api\base\BaseController;
use common\models\psources\CoinOptional;
use common\service\exchange\ExchangeFactory;
use common\service\exchange\ExchangeBuilderFactory;
use yii\helpers\ArrayHelper;
class TickerController extends BaseController
{
protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY'];
protected $basic_price = [];
public function actionIndex()
{
$device_code = Yii::$app->request->get('device_code', '');
$exchange = Yii::$app->request->get('exchange', 'zhaobi');
$exchange_arr = ['huobi', 'binance', 'okex', 'zhaobi'];
if (!in_array($exchange, $exchange_arr)) {
$msg = '不存在的交易平台';
$code = -1;
$data = [];
goto doEnd;
}
$builder = ExchangeBuilderFactory::create($exchange);
$result = $builder->getTickerFromCache();
$code = $result['code'];
$data = $result['ticker'];
if (false != $device_code) {
$coin_optional = CoinOptional::find()->select('symbol')->where(['platform' => $exchange, 'device_code' => $device_code])->asArray()->all();
$coin_optional = ArrayHelper::getColumn($coin_optional, 'symbol');
foreach ($data as &$val) {
if (in_array($val['symbol'], $coin_optional)) {
$val['optional'] = true;
}
}
}
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionOptional()
{
$curl = new Curl();
$data = [
"names" => [
"eth,ethereum",
"btc,btc",
"usdt,ethereum",
"bty,bty",
]
];
$params = json_encode($data);
$curl->setHeader('Content-Type', 'application/json');
$curl->setRawPostData($params);
$res = $curl->post('https://b.biqianbao.net/interface/coin/coin-index', true);
$res = json_decode($res, true);
foreach ($res['data'] as $val) {
$this->basic_price[$val['name']] = $val['rmb'];
}
$code = -1;
$msg = 'fail';
$data = null;
$request = Yii::$app->request;
if ($request->isPost) {
$symbol = $request->post('symbol', '');
$platform = $request->post('platform', '');
$device_code = $request->post('device_code', '');
if (empty($symbol) || empty($platform) || empty($device_code)) {
$msg = '参数错误';
goto doEnd;
}
$model = CoinOptional::find()->where(['device_code' => $device_code, 'symbol' => $symbol])->one();
if ($model) {
$msg = '数据已存在!';
goto doEnd;
}
$model = new CoinOptional();
$model->setScenario(CoinOptional::SCENARIOS_CREATE);
if ($model->load(Yii::$app->request->post(), '') && $model->save()) {
$msg = 'success';
$code = 0;
} else {
$msg = current($model->firstErrors);
}
goto doEnd;
}
if ($request->isGet) {
$device_code = $request->get('device_code', '');
if (empty($device_code)) {
$msg = '参数错误';
goto doEnd;
}
$data = $temp = [];
$model = CoinOptional::find()->select('symbol, platform')->where(['device_code' => $device_code])->asArray()->all();
foreach ($model as $val) {
if ('huobi' == $val['platform']) {
$exchange = 'HuoBi';
} else if ('binance' == $val['platform']) {
$exchange = 'Binance';
} else if ('zhaobi' == $val['platform']) {
$exchange = 'Zhaobi';
} else {
}
$symbol = explode('/', $val['symbol']);
$tag_first = $symbol[0];
$tag_second = $symbol[1];
$exchange = ExchangeFactory::createExchange($exchange);
$quotation = $exchange->getTicker(strtolower($tag_first), strtolower($tag_second));
$temp['symbol'] = $val['symbol'];
$temp['currency'] = strtoupper($tag_first);
$temp['base_currency'] = strtoupper($tag_second);
$temp['close'] = (float)sprintf("%0.6f", $quotation['last']);
$temp['close_usd'] = (float)sprintf("%0.6f", $quotation['last'] * $this->basic_price[$tag_second]['usd']);
$temp['close_rmb'] = (float)sprintf("%0.4f", $quotation['last'] * $this->basic_price[$tag_second]['rmb']);
$temp['change'] = (0 == $quotation['open']) ? 0 : (float)sprintf("%0.4f", ($quotation['last'] - $quotation['open']) / $quotation['open'] * 100);
$temp['high_usd'] = (float)sprintf("%0.4f", $quotation['high'] * $this->basic_price[$tag_second]['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $quotation['high'] * $this->basic_price[$tag_second]['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['rmb']);
$temp['platform_us'] = $val['platform'];
if ('ZHAOBI' == strtoupper($val['platform'])) {
$temp['platform_zh'] = '找币';
$temp['platform_us'] = 'zhaobi';
}
if ('HUOBI' == strtoupper($val['platform'])) {
$temp['platform_zh'] = '火币';
$temp['platform_us'] = 'huobi';
}
if ('BINANCE' == strtoupper($val['platform'])) {
$temp['platform_zh'] = '币安';
$temp['platform_us'] = 'binance';
}
array_push($data, $temp);
}
$msg = 'success';
$code = 0;
}
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionRemoveOptional()
{
$code = -1;
$msg = 'fail';
$data = null;
$request = Yii::$app->request;
if (!$request->isPost) {
$msg = '请求错误!';
goto doEnd;
}
$symbol = $request->post('symbol', '');
$platform = $request->post('platform', '');
$device_code = $request->post('device_code', '');
if (empty($symbol) || empty($device_code) || empty($platform)) {
$msg = '请求参数错误!';
goto doEnd;
}
$model = CoinOptional::find()->where(['symbol' => $symbol, 'platform' => $platform, 'device_code' => $device_code])->one();
if (empty($model)) {
$msg = '数据不存在!';
goto doEnd;
}
if (!$model->delete()) {
$msg = '删除失败!';
goto doEnd;
}
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionHotTicker()
{
$builder = ExchangeBuilderFactory::create('huobi');
$result = $builder->getHotTicker();
$code = $result['code'];
$data = $result['ticker'];
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
}
\ No newline at end of file
......@@ -5,9 +5,11 @@
* Date: 2018/11/14
* Time: 18:53
*/
namespace api\controllers;
use api\base\BaseController;
use common\models\psources\CoinHashMemo;
use common\models\psources\CoinTokenTransfer;
use common\service\chain33\Chain33Service;
use Yii;
......@@ -16,47 +18,101 @@ use Yii;
class TradeController extends BaseController
{
/**
* 添加本地备注
*/
* 添加本地备注
*/
public function actionAddMemo()
{
$request = Yii::$app->request;
$hash = $request->post('hash');
$memo = $request->post('memo');
if($hash && $memo){
Yii::$app->redis->hset('trade_hash_memo',$hash,$memo);
return ['code' => 0,'data' => [], 'msg' => '本地备注添加成功'];
}else{
return ['code' => 1,'data' => [],'msg' => '交易hash值或者本地备注不能为空'];
$request = Yii::$app->request;
$hash = $request->post('hash');
if (empty($hash)) {
return ['code' => 1, 'data' => [], 'msg' => '交易hash值不能为空'];
}
$model = new CoinHashMemo();
$model->setScenario(CoinHashMemo::SCENARIOS_CREATE);
if ($model->load(Yii::$app->request->post(), '') && $model->save()) {
return ['code' => 0, 'data' => [], 'msg' => '本地备注添加成功'];
} else {
return ['code' => 1, 'data' => [], 'msg' => current($model->firstErrors)];
}
}
public function actionUpdateMemo()
{
$request = Yii::$app->request;
$hash = $request->post('hash');
$memo = $request->post('memo');
if (empty($hash)) {
return ['code' => 1, 'data' => [], 'msg' => '交易hash值不能为空'];
}
$model = CoinHashMemo::find()->where(['hash' => $hash])->one();
if (empty($model)) {
return ['code' => 1, 'data' => [], 'msg' => '记录不存在'];
}
CoinHashMemo::updateAll(['memo' => $memo], 'hash = :hash', [':hash' => $hash]);
return ['code' => 0, 'data' => [], 'msg' => '本地备注更新成功'];
}
/**
* 查看本地备注
*/
public function actionGetMemo()
{
$request = Yii::$app->request;
$hash = $request->post('hash');
if($hash){
$memo = Yii::$app->redis->hget('trade_hash_memo',$hash);
return ['code' => 0,'data' => $memo];
}else{
return ['code' => 1,'data' => [],'msg' => '交易hash值不能为空'];
$request = Yii::$app->request;
$hash = $request->post('hash');
$version = $request->post('version', '');
if (empty($hash)) {
return ['code' => 1, 'data' => [], 'msg' => '交易hash值不能为空'];
}
$model = CoinHashMemo::find()->where(['hash' => $hash])->asArray()->one();
if (empty($version)) {
if (empty($model)) {
return ['code' => 1, 'data' => '', 'msg' => '记录不存在'];
}
return ['code' => 0, 'data' => $model['memo']];
} else {
if (empty($model)) {
return ['code' => 0, 'data' => ['memo' => '', 'coins_fee' => ''], 'msg' => '记录不存在'];
}
return ['code' => 0, 'data' => [
'memo' => $model['memo'],
'coins_fee' => $model['coins_fee']
]];
}
}
public function actionSyncToDb()
{
$data = [];
$result = Yii::$app->redis->HGETALL('trade_hash_memo');
foreach ($result as $key => $val) {
if (($key + 2) % 2 == 0) {
$data[] = [
'hash' => $val,
'memo' => $result[$key + 1]
];
}
}
foreach ($data as $val) {
if ('0xc080c6a0937f25d1017e5e88bdcff5c3979810c8a6cc1f3a64cf50970da28fc9' == $val['hash']) continue;
$coin_memo_hash = new CoinHashMemo();
$coin_memo_hash->hash = $val['hash'];
$coin_memo_hash->memo = $val['memo'];
$coin_memo_hash->save();
}
exit;
}
public function actionAddressIsExist()
{
$get = Yii::$app->request->get();
$to = $get['coin_address'] ?? '';
if(empty($to)){
if (empty($to)) {
return ['code' => -1, 'msg' => '参数不能为空'];
}
$coinTokenTransfer = CoinTokenTransfer::find()->where(['coin_address' => $to, 'code' => 1])->one();
if(!$coinTokenTransfer){
if (!$coinTokenTransfer) {
return ['code' => 0, 'msg' => 'record does not exist'];
}
......@@ -68,12 +124,12 @@ class TradeController extends BaseController
{
$get = Yii::$app->request->get();
$to = $get['coin_address'] ?? '';
if(empty($to)){
if (empty($to)) {
return ['code' => -1, 'msg' => '参数不能为空'];
}
$coinTokenTransfer = CoinTokenTransfer::find()->where(['coin_address' => $to, 'code' => 1])->one();
if($coinTokenTransfer){
if ($coinTokenTransfer) {
return ['code' => -1, 'msg' => 'record already exists'];
}
......@@ -86,8 +142,8 @@ class TradeController extends BaseController
$service = new Chain33Service();
$createRawTransaction = $service->createTokenRawTransaction($to, $amount, $isToken, $tokenSymbol, $fee, $note, $execer);
if(0 != $createRawTransaction['code']){
$createRawTransaction = $service->createTokenRawTransaction($to, $amount, $isToken, $tokenSymbol, $fee, $note, $execer);
if (0 != $createRawTransaction['code']) {
$msg = $createRawTransaction['msg'];
$code = -1;
goto doEnd;
......@@ -98,7 +154,7 @@ class TradeController extends BaseController
$expire = '1m';
$signRawTx = $service->signRawTx($privkey, $txHex, $expire);
if(0 != $signRawTx['code']){
if (0 != $signRawTx['code']) {
$msg = $signRawTx['msg'];
$code = -1;
goto doEnd;
......@@ -106,7 +162,7 @@ class TradeController extends BaseController
$sign_str = $signRawTx['result'];
$result = $service->sendTransaction($sign_str);
if(0 != $result['code']){
if (0 != $result['code']) {
$msg = $result['msg'];
$code = -1;
goto doEnd;
......
<?php
namespace api\controllers;
use api\base\BaseController;
use common\models\psources\CoinAirDropTrade;
use common\models\psources\CoinPlatform;
use common\service\chain33\Chain33Service;
use Yii;
class WalletController extends BaseController
{
public function actionInfo()
{
$code = 0;
$msg = 'success';
$platform_id = Yii::$app->request->get('platform_id', '');
if(empty($platform_id)){
$msg = '参数不能为空';
$code = -1;
$data = null;
goto doEnd;
}
$data = CoinPlatform::find()->select("name, download_url, introduce")->where(['id' => $platform_id])->asArray()->one();
if(empty($data)){
$msg = '数据不存在';
$data = null;
$code = -1;
goto doEnd;
}
$data['title'] = $data['name'];
unset($data['name']);
doEnd :
return ['code' => $code, 'data' => $data, 'msg' => $msg];
}
public function actionGameTradeUpdate()
{
$coinAirDropTrade = CoinAirDropTrade::find()->where(['attach' => 2 ,'msg' => '0'])->limit(30)->all();
foreach ($coinAirDropTrade as $val){
$fee = 100000;
$amount = 1 * 1e8;
$execer = 'coins';
$note = '';
$service = new Chain33Service();
$createRawTransaction = $service->createRawTransaction($val->coins_address, $amount, $fee, $note, $execer);
if(0 != $createRawTransaction['code']){
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;
}
$currentModel = CoinAirDropTrade::findOne($val->id);
$currentModel->attach = 2;
$currentModel->balance = 0;
$currentModel->msg = $result['result'];
$currentModel->save();
}
return ['code' => 1, 'msg' => 'ok'];
}
public function actionGetBalance()
{
$coinAirDropTrade = CoinAirDropTrade::find()->where(['balance' => 0])->limit(60)->all();
$address = [];
foreach ($coinAirDropTrade as $val){
$address[] = $val->coins_address;
}
$service = new Chain33Service();
$execer = 'coins';
$result = $service->getBalance($address, $execer);
if(0 == $result['code']){
$result_balance = $result['result'];
foreach ($result_balance as $val){
$coinAirDropTrade = CoinAirDropTrade::find()->where(['coins_address' => $val['addr']])->one();
if(empty($coinAirDropTrade)) continue;
$coinAirDropTrade->balance = $val['balance'];
$coinAirDropTrade->save();
}
}
return ['code' => 1, 'msg' => 'ok'];
}
}
\ 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
/**
* Created By Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-07 17:41:04
*/
namespace backend\assets\applicationCategory;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/application-category';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
\ No newline at end of file
<?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 Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-07 17:41:04
*/
namespace backend\assets\wallet;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/wallet';
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
This diff is collapsed.
<?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
......@@ -71,7 +71,6 @@ class CoinRecommendController extends BaseController
$platform_id = empty($get['platform_id']) ? 1 : $get['platform_id'];
$user_platform_id = Yii::$app->user->identity->platform_id;
#var_dump($platform_id, $user_platform_id);exit;
if (1 != $user_platform_id && $user_platform_id != $platform_id) {
return ['code' => -1, 'msg' => '没有权限修改'];
}
......
<?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
......@@ -12,6 +12,7 @@ use common\service\trusteeship\Trusteeship;
use Yii;
use common\models\psources\MinerFee;
use backend\models\coin\MinerFeeForm;
use common\models\psources\Coin;
use \Exception;
class MinerFeeController extends BaseController
......@@ -23,18 +24,18 @@ class MinerFeeController extends BaseController
{
if (Yii::$app->request->isAjax) {
$request = Yii::$app->request;
$type = $request->get('type',1);
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$type = $request->get('type', 1);
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$data = MinerFee::getList($page, $limit, [['type' => $type]]);//数据不多
if ($data['count'] > 0) {
$data['code'] = 0;
} else {
$data['code'] = 1;
$data['msg'] = '数据为空';
$data['msg'] = '数据为空';
}
Yii::$app->response->format = 'json';
Yii::$app->response->data = $data;
Yii::$app->response->data = $data;
Yii::$app->response->send();
}
return $this->render('index');
......@@ -45,27 +46,32 @@ class MinerFeeController extends BaseController
*/
public function actionAdd()
{
$model = new MinerFeeForm();
$model->scenario = 'add';
$type = Yii::$app->request->get('type',1);
$model = new MinerFeeForm();
$type = Yii::$app->request->get('type', 1);
if (MinerFeeForm::TYPE_WALLET == $type) {
$model->setScenario(MinerFeeForm::SCENARIOS_WALLET_CREATE);
} else {
$model->setScenario(MinerFeeForm::SCENARIOS_TRUSTEESHIP_CREATE);
}
$platforms = Coin::getChainList();
if (Yii::$app->request->isPost) {
$request = Yii::$app->request;
if ($model->load($request->post()) && $model->validate()) {
$minerFee = new MinerFee();
$minerFee->platform = $model->platform;
$minerFee->min = $model->min;
$minerFee->max = $model->max;
$minerFee->level = $model->level;
$minerFee->type = $type;
$minerFee = new MinerFee();
$minerFee->platform = $model->platform;
if (MinerFeeForm::TYPE_WALLET == $type) {
$minerFee->min = $model->min;
$minerFee->max = $model->max;
$minerFee->level = $model->level;
} else {
$minerFee->fee = $model->fee;
}
$minerFee->type = $type;
$minerFee->create_at = date('Y-m-d H:i:s');
$minerFee->update_at = date('Y-m-d H:i:s');
try {
$minerFee->save();
$this->success('添加成功', '/admin/miner-fee/cost');
} catch (Exception $exception) {
$this->error($exception->getMessage(), '/admin/miner-fee/add');
}
$minerFee->save();
$this->success('添加成功', '/admin/miner-fee/cost');
}
//表单验证失败
$errors = $model->errors;
......@@ -77,7 +83,7 @@ class MinerFeeController extends BaseController
}
$this->error($errors, Yii::$app->request->getReferrer());
}
return $this->render('add', ['model' => $model]);
return $this->render('add', ['model' => $model, 'platforms' => $platforms, 'type' => $type]);
}
/**
......@@ -86,24 +92,30 @@ class MinerFeeController extends BaseController
*/
public function actionEdit()
{
$model = new MinerFeeForm();
$model->scenario = 'edit';
$id = Yii::$app->request->get('id', null);
$model = new MinerFeeForm();
$id = Yii::$app->request->get('id', null);
$type = Yii::$app->request->get('type', 1);
if (MinerFeeForm::TYPE_WALLET == $type) {
$model->setScenario(MinerFeeForm::SCENARIOS_WALLET_UPDATE);
} else {
$model->setScenario(MinerFeeForm::SCENARIOS_TRUSTEESHIP_UPDATE);
}
if ($id) {
$minerFee = MinerFee::findOne(['id' => $id]);
$platforms = Coin::getChainList();
if ($minerFee) {
if (Yii::$app->request->isPost) {
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$minerFee->min = $model->min;
$minerFee->max = $model->max;
$minerFee->level = $model->level;
$minerFee->update_at = date('Y-m-d H:i:s');
try {
$minerFee->save();
$this->success('更新成功', '/admin/miner-fee/cost');
} catch (Exception $exception) {
$this->error($exception->getMessage(), Yii::$app->request->getReferrer());
if (MinerFeeForm::TYPE_WALLET == $type) {
$minerFee->min = $model->min;
$minerFee->max = $model->max;
$minerFee->level = $model->level;
} else {
$minerFee->fee = $model->fee;
}
$minerFee->update_at = date('Y-m-d H:i:s');
$minerFee->save();
$this->success('更新成功', '/admin/miner-fee/cost');
}
$errors = $model->errors;
if ($errors) {
......@@ -114,7 +126,7 @@ class MinerFeeController extends BaseController
}
$this->error($errors, Yii::$app->request->getReferrer());
}
return $this->render('edit', ['model' => $minerFee]);
return $this->render('edit', ['model' => $minerFee, 'platforms' => $platforms, 'type' => $type]);
}
}
$this->error('公告不存在', Yii::$app->request->getReferrer());
......@@ -149,24 +161,24 @@ class MinerFeeController extends BaseController
Yii::$app->response->format = 'json';
$trusteeship = new Trusteeship();
$data = $trusteeship->getSupportCoin();
if($data['code'] != 0){
if ($data['code'] != 0) {
return ['code' => -1, 'msg' => $data['msg']];
}else{
$trusteeship_coins = array_column($data['data'],'currency');
} else {
$trusteeship_coins = array_column($data['data'], 'currency');
$list = MinerFee::getList(1, 999, [['type' => 2]]);
if($list){
$local_coins = array_column($list['data'],'platform');
}else{
if ($list) {
$local_coins = array_column($list['data'], 'platform');
} else {
$local_coins = [];
}
$need_add_coins = array_diff($trusteeship_coins,$local_coins);
if(!$need_add_coins){
return ['code' => 0,'msg' => '币种库已经最新'];
$need_add_coins = array_diff($trusteeship_coins, $local_coins);
if (!$need_add_coins) {
return ['code' => 0, 'msg' => '币种库已经最新'];
}
foreach($need_add_coins as $item){
$minerFee = new MinerFee();
$minerFee->platform = $item;
$minerFee->type = 2;
foreach ($need_add_coins as $item) {
$minerFee = new MinerFee();
$minerFee->platform = $item;
$minerFee->type = 2;
$minerFee->create_at = date('Y-m-d H:i:s');
$minerFee->update_at = date('Y-m-d H:i:s');
$minerFee->save();
......@@ -184,19 +196,19 @@ class MinerFeeController extends BaseController
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$fee = $request->get('fee',0);
if($id){
$id = $request->get('id', '');
$fee = $request->get('fee', 0);
if ($id) {
$minerFee = MinerFee::find()->where(['id' => $id])->one();
if(!$minerFee){
return ['code' => 1,'msg' =>'币种旷工费异常'];
if (!$minerFee) {
return ['code' => 1, 'msg' => '币种旷工费异常'];
}
$minerFee->fee = $fee;
$minerFee->update_at = date('Y-m-d H:i:s');
$minerFee->save();
return ['code' => 0,'msg' => '旷工费设置成功'];
}else{
return ['code' => 1 ,'msg' => '旷工费设置失败'];
return ['code' => 0, 'msg' => '旷工费设置成功'];
} else {
return ['code' => 1, 'msg' => '旷工费设置失败'];
}
}
}
......
<?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
......@@ -5,14 +5,116 @@
* Date: 2018/12/17
* Time: 10:13
*/
namespace backend\controllers;
use common\models\psources\CoinApplicationCategory;
use backend\models\coin\CoinPlatformForm;
use common\models\psources\CoinPlatform;
use Yii;
class WalletController 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);
$name = $request->get('name', '');
$where = [];
if ($name) {
$where[] = ['name' => $name];
}
$data = CoinPlatform::getList($page, $limit, $where);
$data['code'] = 0;
Yii::$app->response->format = 'json';
return $data;
}
return $this->render('index');
}
public function actionAdd()
{
$model = new CoinPlatformForm();
$model->scenario = 'add';
if (Yii::$app->request->isPost) {
$data = Yii::$app->request->post();
if ($model->load($data, '') && $model->validate()) {
$coin = Yii::createObject(CoinPlatform::className());
$result = $coin->addOne($data);
if ($result === true) {
$this->success('添加成功', '/admin/wallet/list');
}
}
//表单验证失败
$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 CoinPlatformForm();
$model->scenario = 'update';
$data = Yii::$app->request->post();
Yii::$app->response->format = 'json';
if ($model->load($data, '') && $model->validate()) {
$coin = Yii::createObject(CoinPlatform::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 = CoinPlatform::findOne(['id' => $id]);
$this->layout = false;
return $this->render('edit', ['model' => $coin]);
}
}
}
public function actionDelete()
{
Yii::$app->response->format = 'json';
$id = Yii::$app->request->get('id', 0);
if ($id) {
$model = CoinPlatform::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' => '删除失败'];
}
/**
* @return string
* 设置钱包密码
......@@ -24,23 +126,21 @@ class WalletController extends BaseController
$new_passwd = Yii::$app->request->post('new_passwd');
$confirm_passwd = Yii::$app->request->post('confirm_passwd');
$passwd = Yii::$app->redis->get('wallet_passwd');
if(!$passwd){
Yii::$app->redis->set('wallet_passwd',$new_passwd);
if (!$passwd) {
Yii::$app->redis->set('wallet_passwd', $new_passwd);
$this->success('钱包密码设置成功', Yii::$app->request->getReferrer());
}
if($passwd != $old_passwd){
if ($passwd != $old_passwd) {
$this->error('原始密码错误', Yii::$app->request->getReferrer());
}
if($new_passwd != $confirm_passwd){
if ($new_passwd != $confirm_passwd) {
$this->error('确认密码和设置的密码不一致', Yii::$app->request->getReferrer());
}
Yii::$app->redis->set('wallet_passwd',$new_passwd);
Yii::$app->redis->set('wallet_passwd', $new_passwd);
$this->success('钱包密码设置成功', Yii::$app->request->getReferrer());
}
return $this->render('set-passwd');
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -14,6 +14,7 @@ class CoinForm extends Model
{
public $id;
public $name;
public $optional_name;
public $nickname;
public $sid;
public $icon;
......@@ -49,6 +50,7 @@ class CoinForm extends Model
return [
'id' => 'ID',
'name' => '名称',
'optional_name' => '可选简称',
'nickname' => '别称',
'sid' => '全称',
'icon' => '图标',
......@@ -74,6 +76,7 @@ class CoinForm extends Model
'add' => [
'id',
'name',
'optional_name',
'nickname',
'sid',
'icon',
......@@ -92,6 +95,7 @@ class CoinForm extends Model
'update' => [
'id',
'name',
'optional_name',
'nickname',
'sid',
'icon',
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午4:05
*/
namespace backend\models\coin;
use yii\base\Model;
class CoinPlatformForm extends Model
{
public $id;
public $name;
public $download_url;
public $introduce;
public function formName()
{
return '';
}
public function rules()
{
return [
[['name'], 'required', 'on' => 'add'],
[['id', 'name'], 'required', 'on' => 'update'],
];
}
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => '名称',
'download_url' => '下载链接',
'introduce' => '介绍'
];
}
public function scenarios()
{
return [
'add' => [
'id',
'name',
],
'update' => [
'id',
'name',
],
];
}
}
\ 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
......@@ -8,6 +8,7 @@
namespace backend\models\coin;
use common\models\psources\MinerFee;
use yii\base\Model;
class MinerFeeForm extends Model
......@@ -18,6 +19,17 @@ class MinerFeeForm extends Model
public $min;
public $level;
public $type;
public $fee;
//定义场景
const SCENARIOS_WALLET_CREATE = 'wallet_create';
const SCENARIOS_WALLET_UPDATE = 'wallet_update';
const SCENARIOS_TRUSTEESHIP_CREATE = 'trusteeship_create';
const SCENARIOS_TRUSTEESHIP_UPDATE = 'trusteeship_update';
const TYPE_WALLET = 1; //币钱包
const TYPE_TRUSTEESHIP = 2; //托管钱包
public function formName()
{
......@@ -27,27 +39,39 @@ class MinerFeeForm extends Model
public function rules()
{
return [
[['id', 'min', 'max', 'level'], 'required', 'on' => 'edit'],
[['platform', 'min', 'max', 'level'], 'required', 'on' => 'add'],
[['platform', 'min', 'max', 'level', 'fee'], 'required'],
[['id', 'max', 'min', 'level'], 'number'],
['platform', 'isExist','on' => [self:: SCENARIOS_TRUSTEESHIP_CREATE]]
];
}
public function isExist($attribute, $params)
{
$count = MinerFee::find()->where(['platform' => $this->platform, 'type' => self::TYPE_TRUSTEESHIP])->count();
if($count > 0) {
$this->addError('platform', '该平台已存在');
}
}
public function scenarios()
{
return [
'add' => ['platform', 'min', 'max', 'level'],
'edit' => ['id', 'min', 'max', 'level'],
$scenarios = [
self:: SCENARIOS_WALLET_CREATE => ['platform', 'min', 'max', 'level'],
self:: SCENARIOS_WALLET_UPDATE => ['platform', 'min', 'max', 'level'],
self:: SCENARIOS_TRUSTEESHIP_CREATE => ['platform', 'type', 'fee'],
self:: SCENARIOS_TRUSTEESHIP_UPDATE => ['platform', 'type', 'fee'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function attributeLabels()
{
return [
'platform' => '平台',
'min' => '最小值',
'max' => '最大值',
'level' => '分档',
'min' => '最小值',
'max' => '最大值',
'level' => '分档',
'fee' => '手续费'
];
}
}
\ 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>
<?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() ?>">
<input name="id" type="hidden" value="">
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">排序</label>
<div class="layui-input-block" style="width: 250px">
<input type="text" name="sort" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
</div>
</div>
<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="icon" 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">
<div class="layui-inline">
<label class="layui-form-label">banner</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px" id="icon2">
</div>
<input type="hidden" name="banner" value="">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload2" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">banner链接</label>
<div class="layui-input-block" style="width: 500px">
<input type="text" name="banner_url" required lay-verify="required" placeholder=""
autocomplete="off" class="layui-input" value="">
</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>
......@@ -11,7 +11,7 @@
width: 100px;
}
</style>
<h4>所属分类---<?= $applicate_category->name ?></h4>
<h4>所属分类---<?= $applicate_category->name["zh-CN"] ?></h4>
<div class="layui-row" style="padding: 5px;">
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
......
<?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="application-category-edit">
<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" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_zh'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_en'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name[]" value="<?= $model['name_ja'] ?>">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">排序</label>
<div class="layui-input-block" style="width: 250px">
<input type="text" name="sort" required lay-verify="required" placeholder=""
autocomplete="off" value="<?= $model['sort'] ?>"
class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图标</label>
<div class="layui-input-block">
<img src="<?= $model['icon_url'] ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon1">
</div>
<input type="hidden" name="icon" value="<?= $model['icon'] ?>">
</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">
<div class="layui-inline">
<label class="layui-form-label">banner</label>
<div class="layui-input-block">
<img src="<?= $model['banner_image_url'] ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px" id="icon2">
</div>
<input type="hidden" name="banner" value="<?= $model['banner'] ?>">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload2" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">banner链接</label>
<div class="layui-input-block">
<input type="text" name="banner_url" required lay-verify="required" placeholder=""
autocomplete="off" class="layui-input" value="<?= $model['banner_url'] ?>">
</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/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>
......@@ -46,9 +46,21 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">应用名称</label>
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name" value="" lay-verify="required">
<input class="layui-input" name="name[]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
......@@ -48,9 +48,21 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">应用名称</label>
<label class="layui-form-label">中文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name" value="<?= $item['name'] ?>" lay-verify="required">
<input class="layui-input" name="name[]" value="<?= $item['name_zh'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_en'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block">
<input class="layui-input" name="name[]" value="<?= $item['name_ja'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
......
This diff is collapsed.
<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>
......@@ -19,25 +19,33 @@
<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" placeholder="请填写大写字母" value="<?= $model->name ?>" lay-verify="required">
<div class="layui-input-block" style="width: 250px">
<input class="layui-input" name="name" placeholder="请填写大写字母" value="<?= $model->name ?>"
lay-verify="required">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">可选简称</label>
<div class="layui-input-block"style="width: 250px">
<input class="layui-input" name="optional_name" placeholder="请填写大写字母"
value="<?= $model->optional_name ?>" lay-verify="required">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">中文名</label>
<div class="layui-input-block" style="width: 250px">
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['zh-CN'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">英文名</label>
<div class="layui-input-block" style="width: 250px">
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['en-US'] ?>">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日文名</label>
<div class="layui-input-block" style="width: 250px">
<div class="layui-input-block" style="width: 190px">
<input class="layui-input" name="nickname[]" value="<?= $model->nickname['ja'] ?>">
</div>
</div>
......
......@@ -20,7 +20,15 @@
<div class="layui-inline">
<label class="layui-form-label">简称</label>
<div class="layui-input-block">
<input class="layui-input" name="name" placeholder="请填写大写字母" value="<?= $model->name ?>" lay-verify="required">
<input class="layui-input" name="name" placeholder="请填写大写字母" value="<?= $model->name ?>"
lay-verify="required">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">可选简称</label>
<div class="layui-input-block">
<input class="layui-input" name="optional_name" placeholder="请填写大写字母" value="<?= $model->optional_name ?>"
lay-verify="required">
</div>
</div>
<div class="layui-inline">
......@@ -76,7 +84,7 @@
<div class="layui-input-block">
<input type="text" class="layui-input" name="address" value="<?= $model->address ?>">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">精度</label>
<div class="layui-input-block">
......@@ -121,10 +129,12 @@
<select name="treaty">
<option value="1" <?php if ($model->treaty == 1) {
echo "selected";
} ?>>token</option>
} ?>>token
</option>
<option value="2" <?php if ($model->treaty == 2) {
echo "selected";
} ?>>coins</option>
} ?>>coins
</option>
</select>
</div>
</div>
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use backend\assets\coin\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/add">
<button class="layui-btn layui-btn-default" id="add">添加币种</button>
</a>
</div>
<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="name">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">平台</label>
<div class="layui-input-inline">
<select name="platform">
<option value="">全部</option>
<?php foreach ($platforms as $platform): ?>
<option value="<?= $platform ?>"><?= $platform ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">类型</label>
<div class="layui-input-inline">
<select name="chain">
<option value="">全部</option>
<?php foreach ($chains as $chain): ?>
<option value="<?= $chain ?>"><?= $chain ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">推介币种</label>
<div class="layui-input-inline">
<select name="recommend">
<option value="">全部</option>
<option value="0"></option>
<option value="1"></option>
</select>
</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="iconTpl">
<a href="{{d.icon}}" target="_blank"><img src="{{d.icon}}" style="max-width: 32px; max-height: 32px;"/></a>
</script>
<script type="text/html" id="officialTpl">
{{# if(d.official){ }}
{{# layui.each(d.official.split(';'),function(index,item){ }}
{{# if(item){ }}
<a href="{{ item }}" class="layui-table-link" target="_blank">官网{{# if(index){ }}{{index}}{{# } }}</a>
{{# } }}
{{# }); }}
{{# }else{ }}
-
{{# } }}
</script>
<script type="text/html" id="paperTpl">
{{# if(d.paper){ }}
<a href="{{d.paper}}" class="layui-table-link" target="_blank">白皮书</a>
{{# }else{ }}
-
{{# } }}
</script>
<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>
<script type="text/html" id="exchangeTpl">
{{d.exchange}}
</script>
<script type="text/html" id="recommendTpl">
{{# if(d.recommend==0){ }}
{{# }else if(d.recommend==1){ }}
首页推荐
{{# }else{ }}
次页推荐
{{# } }}
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use backend\assets\coin\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/add">
<button class="layui-btn layui-btn-default" id="add">添加币种</button>
</a>
</div>
<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="name">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">平台</label>
<div class="layui-input-inline">
<select name="platform">
<option value="">全部</option>
<?php foreach ($platforms as $platform): ?>
<option value="<?= $platform ?>"><?= $platform ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">类型</label>
<div class="layui-input-inline">
<select name="chain">
<option value="">全部</option>
<?php foreach ($chains as $chain): ?>
<option value="<?= $chain ?>"><?= $chain ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">推介币种</label>
<div class="layui-input-inline">
<select name="recommend">
<option value="">全部</option>
<option value="0"></option>
<option value="1"></option>
</select>
</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="iconTpl">
<a href="{{d.icon}}" target="_blank"><img src="{{d.icon}}" style="max-width: 32px; max-height: 32px;"/></a>
</script>
<script type="text/html" id="officialTpl">
{{# if(d.official){ }}
{{# layui.each(d.official.split(';'),function(index,item){ }}
{{# if(item){ }}
<a href="{{ item }}" class="layui-table-link" target="_blank">官网{{# if(index){ }}{{index}}{{# } }}</a>
{{# } }}
{{# }); }}
{{# }else{ }}
-
{{# } }}
</script>
<script type="text/html" id="paperTpl">
{{# if(d.paper){ }}
<a href="{{d.paper}}" class="layui-table-link" target="_blank">白皮书</a>
{{# }else{ }}
-
{{# } }}
</script>
<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>
<script type="text/html" id="exchangeTpl">
{{d.exchange}}
</script>
<script type="text/html" id="recommendTpl">
{{# if(d.recommend==0){ }}
{{# }else if(d.recommend==1){ }}
首页推荐
{{# }else{ }}
次页推荐
{{# } }}
</script>
\ No newline at end of file
......@@ -8,4 +8,4 @@
?>
<h4>添加币种</h4>
<?= $this->render('form', ['model' => $model]) ?>
\ No newline at end of file
<?= $this->render('form', ['model' => $model, 'platforms' => $platforms, 'type' => $type]) ?>
\ No newline at end of file
......@@ -8,4 +8,4 @@
?>
<h4>修改信息</h4>
<?= $this->render('form', ['model' => $model]) ?>
<?= $this->render('form', ['model' => $model, 'platforms' => $platforms, 'type' => $type]) ?>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午3:28
*/
/**
* @var $model backend\models\coin\CoinForm;
*/
use common\models\psources\Coin;
$platforms = Coin::getChainList();
?>
<style>
.layui-form-label {
width: 100px;
......@@ -24,46 +8,51 @@ $platforms = Coin::getChainList();
<form class="layui-form" method="post" action="">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input name="id" type="hidden" value="<?= $model->id ?>">
<?php if($model->type == 2) :?>
<div class="layui-form-item">
<label class="layui-form-label">币种</label>
<div class="layui-input-block">
<input class="layui-input" name="platform" value="<?= $model->platform ?>">
<?php if ($type == 2) : ?>
<div class="layui-form-item">
<label class="layui-form-label">币种</label>
<div class="layui-input-block">
<input class="layui-input" name="platform" value="<?= $model->platform ?>">
</div>
</div>
</div>
<?php else :?>
<div class="layui-form-item">
<label class="layui-form-label">平台</label>
<div class="layui-input-block">
<select name="platform">
<?php foreach ($platforms as $platform): ?>
<option value="<?= $platform ?>" <?php if ($model->platform == $platform) {
echo "selected";
} ?>><?= $platform ?></option>
<?php endforeach; ?>
</select>
<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>
</div>
<?php endif;?>
<div class="layui-form-item">
<label class="layui-form-label">最小值</label>
<div class="layui-input-block">
<input class="layui-input" name="min" value="<?= $model->min ?>">
<?php else : ?>
<div class="layui-form-item">
<label class="layui-form-label">平台</label>
<div class="layui-input-block">
<select name="platform">
<?php foreach ($platforms as $platform): ?>
<option value="<?= $platform ?>" <?php if ($model->platform == $platform) {
echo "selected";
} ?>><?= $platform ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">最大值</label>
<div class="layui-input-block">
<input class="layui-input" name="max" value="<?= $model->max ?>">
<div class="layui-form-item">
<label class="layui-form-label">最小值</label>
<div class="layui-input-block">
<input class="layui-input" name="min" value="<?= $model->min ?>">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">分档</label>
<div class="layui-input-block">
<input class="layui-input" name="level" value="<?= $model->level ?>">
<div class="layui-form-item">
<label class="layui-form-label">最大值</label>
<div class="layui-input-block">
<input class="layui-input" name="max" value="<?= $model->max ?>">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">分档</label>
<div class="layui-input-block">
<input class="layui-input" name="level" value="<?= $model->level ?>">
</div>
</div>
<?php endif; ?>
<div class="layui-form-item">
<button class="layui-btn">提交</button>
</div>
......
......@@ -25,8 +25,12 @@
</div>
<div class="layui-tab-item">
<button class="layui-btn layui-btn-default" id="update-coin">更新币种库</button>
<table class="layui-table" id="table2" lay-filter="table2" ></table>
<a href="/admin/miner-fee/add?type=2">
<button class="layui-btn">添加矿工费</button>
</a>
<div class="layui-row">
<table class="layui-table" id="table2" lay-filter="table2"></table>
</div>
</div>
</div>
......@@ -56,9 +60,10 @@
cols: [[
{field: 'id', title: 'ID'},
{field: 'platform', title: '币种'},
{field: 'fee', title: '旷工费' ,edit: 'text'},
{field: 'fee', title: '旷工费', edit: 'text'},
{field: 'create_at', title: '创建时间'},
{field: 'update_at', title: '更新时间'},
{field: 'id', title: '操作', templet: "#operatorTpl"}
]],
url: '/admin/miner-fee/cost?type=2'
});
......@@ -66,7 +71,7 @@
$('#update-coin').click(function () {
$.get('/admin/miner-fee/update-coin', {}, function (rev) {
layer.msg(rev.msg);
if (0==rev.code) {
if (0 == rev.code) {
table.reload('table2', {
page: {
curr: 1
......@@ -76,14 +81,14 @@
});
});
//监听单元格编辑
table.on('edit(table2)', function(obj){
table.on('edit(table2)', function (obj) {
var value = obj.value; //得到修改后的值
var data = obj.data; //得到所在行所有键值
$.get('/admin/miner-fee/set-fee', {id:data.id,fee:value}, function(rev) {
$.get('/admin/miner-fee/set-fee', {id: data.id, fee: value}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table2',{});
}else{
table.reload('table2', {});
} else {
}
});
......
<?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>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午3:31
*/
?>
<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="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>
<div class="layui-form-item">
<button class="layui-btn">提交</button>
</div>
</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\wallet\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/wallet/add">
<button class="layui-btn layui-btn-default" id="add">添加钱包</button>
</a>
</div>
<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="name">
</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
/**
* @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/application-category/index',
limit: 10,
page: 1,
loading: true,
cols: [[
{
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},
{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 ('del' === obj.event) {
var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () {
$.get('/admin/application-category/delete', {id: data.id}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table1', {
page: {curr: 1}
});
}
});
});
} else if (obj.event == 'edit') {
$.get('/admin/application-category/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/application-category/edit', $("#application-category-edit").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
table.reload("table1", {
where: data.field,
});
layer.close(editIndex);
}
});
}
});
});
}
});
form.on('switch(recommendDemo)', function (obj) {
//layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return;
if (obj.elem.checked) {
$.get('/admin/applicate-recommend/add', {id: this.value, type: 1}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
} else {
}
});
} else {
$.get('/admin/applicate-recommend/delete', {id: this.value, type: 1}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
} else {
}
});
}
});
form.on('switch(enableDemo)', function (obj) {
var enable = 1;
if (obj.elem.checked) {
enable = 1
} else {
enable = 0;
}
$.get('/admin/application-category/set-enable', {id: this.value, enable: enable}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
} else {
}
});
});
\ 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/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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment