Commit ae9f58a8 authored by rlgyzhcn's avatar rlgyzhcn

国盾锁仓

parent f176d299
<?php
/**
* Created By Sublime Text 3
*
* @date 2018-09-07 17:31:23
* @authors rlgy <rlgyzhcn@qq.com>
*/
namespace backend\assets\coinPublish;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-publish';
public $js = [
'list.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
<?php
/**
* Created By Sublime Text 3
*
* @date 2018-09-07 17:31:23
* @authors rlgy <rlgyzhcn@qq.com>
*/
namespace backend\assets\coinPublishRule;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-publish-rule';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
<?php
/**
* Created By Sublime Text 3
*
* @date 2018-09-07 17:31:23
* @authors rlgy <rlgyzhcn@qq.com>
*/
namespace backend\assets\coinPublishRule;
use yii\web\AssetBundle;
use yii\web\View;
class ListAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-publish-rule';
public $js = [
'list.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
<?php
/**
* Created By Sublime Text 3
*
* @date 2018-09-07 17:31:23
* @authors rlgy <rlgyzhcn@qq.com>
*/
namespace backend\assets\coinReleaseCheck;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-release-check';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
<?php
/**
* Created By Sublime Text 3
*
* @date 2018-09-07 17:31:23
* @authors rlgy <rlgyzhcn@qq.com>
*/
namespace backend\assets\coinReleaseMember;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/coin-release-member';
public $js = [
'list.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
......@@ -65,21 +65,21 @@ class AuthController extends BaseController
if (Yii::$app->request->isPost) {
$auth = Yii::$app->authManager;
$self_role = current($auth->getRolesByUser(Yii::$app->user->id));
$data = Yii::$app->request->post('param');
$data = Yii::$app->request->post('param');
$data['name'] = trim($data['name']);
if (!$data['name']) {
$this->error('请输入要添加的角色名!');
} else {
$role_name = $self_role->name . '.' . $data['name'];
$role_name = $data['name'];
if (Yii::$app->authManager->getRole($role_name) != null) {
$this->error('该角色名已存在!');
} else {
/* 创建角色 */
$role = Yii::$app->authManager->createRole($role_name);
$role->type = 1;
$role = Yii::$app->authManager->createRole($role_name);
$role->type = 1;
$role->description = $data['description'];
if (Yii::$app->authManager->add($role)) {
$auth = Yii::$app->authManager;
$auth = Yii::$app->authManager;
$auth->addChild($self_role, $role);
$this->success('添加成功!', $this->getForward());
}
......@@ -105,7 +105,7 @@ class AuthController extends BaseController
$role = Yii::$app->authManager->getRole($item_name);
if (Yii::$app->request->isPost) {
$data = Yii::$app->request->post('param');
$data = Yii::$app->request->post('param');
$data['name'] = trim($data['name']);
if (!$data['name']) {
......@@ -114,7 +114,7 @@ class AuthController extends BaseController
if (Yii::$app->authManager->getRole($data['name']) != null) {
$this->error('该角色名已存在!');
} else {
$role->name = $data['name'];
$role->name = $data['name'];
$role->description = $data['description'];
if (Yii::$app->authManager->update($item_name, $role)) {
$this->success('更新成功!', $this->getForward());
......@@ -197,14 +197,14 @@ class AuthController extends BaseController
}
/* 获取栏目节点 */
$node_list = Menu::returnNodes();
$node_list = Menu::returnNodes();
$auth_rules = Yii::$app->authManager->getChildren($role);
$auth_rules = array_keys($auth_rules);
return $this->render('auth', [
'node_list' => $node_list,
'node_list' => $node_list,
'auth_rules' => $auth_rules,
'role' => $role,
'role' => $role,
]);
}
......@@ -230,7 +230,7 @@ class AuthController extends BaseController
return $this->render('user', [
'dataProvider' => $this->lists1(new Admin(), $_where),
'role' => Yii::$app->request->get('role', 'administrator'),
'role' => Yii::$app->request->get('role', 'administrator'),
]);
}
......
......@@ -2,18 +2,20 @@
namespace backend\controllers;
use Yii;
use common\core\Controller;
use yii\helpers\Url;
use yii\data\Pagination;
use Yii;
use yii\data\ActiveDataProvider;
use yii\data\Pagination;
use yii\helpers\Url;
use common\modelsgii\Admin;
/**
* ---------------------------------------
* 后台父类控制器
* 后台所有控制器都继承自该类
* @author longfei phphome@qq.com
* ---------------------------------------
* @author longfei phphome@qq.com
*/
class BaseController extends Controller
{
......@@ -26,13 +28,13 @@ class BaseController extends Controller
{
/* 判断是否登录 */
/*if (\Yii::$app->user->getIsGuest()) {
$this->redirect(Url::toRoute(['/login/login']));
Yii::$app->end();
$this->redirect(Url::toRoute(['/login/login']));
Yii::$app->end();
}*/
/*if (!Yii::$app->request->isGet) {
AdminLog::saveLog($this);
}*/
AdminLog::saveLog($this);
}*/
}
/**
......@@ -48,9 +50,9 @@ class BaseController extends Controller
/**
* ---------------------------------------
* 获取之前标记的cookie位置
* @param string $default
* @return mixed
* ---------------------------------------
* @param string $default
* @return mixed
*/
public function getForward($default = '')
{
......@@ -65,11 +67,11 @@ class BaseController extends Controller
/**
* ---------------------------------------
* 传统分页列表数据集获取方法
* @param \yii\db\ActiveRecord $model 模型名或模型实例
* @param array $where where查询条件
* @param array|string $order 排序条件
* @return array|false
* ---------------------------------------
* @param \yii\db\ActiveRecord $model 模型名或模型实例
* @param array $where where查询条件
* @param array|string $order 排序条件
* @return array|false
*/
public function lists($model, $where = [], $order = '')
{
......@@ -79,7 +81,7 @@ class BaseController extends Controller
'totalCount' => $countQuery->count(),
'defaultPageSize' => 10,
]);
$data = $query->orderBy($order)->offset($pages->offset)
$data = $query->orderBy($order)->offset($pages->offset)
->limit($pages->limit)
->all();
......@@ -89,11 +91,11 @@ class BaseController extends Controller
/**
* ---------------------------------------
* dataProvider列表数据集获取方法
* @param \yii\db\ActiveRecord $model 模型名或模型实例
* @param array $where where查询条件
* @param array|string $order 排序条件
* @return \yii\data\ActiveDataProvider
* ---------------------------------------
* @param \yii\db\ActiveRecord $model 模型名或模型实例
* @param array $where where查询条件
* @param array|string $order 排序条件
* @return \yii\data\ActiveDataProvider
*/
public function lists1($model, $where = [], $order = '')
{
......@@ -111,10 +113,10 @@ class BaseController extends Controller
/**
* ---------------------------------------
* 修改数据表一条记录的一条值
* @param \yii\db\ActiveRecord $model 模型名称
* @param array $data 数据
* @return \yii\db\ActiveRecord|boolean
* ---------------------------------------
* @param \yii\db\ActiveRecord $model 模型名称
* @param array $data 数据
* @return \yii\db\ActiveRecord|boolean
*/
public function saveRow($model, $data)
{
......@@ -136,15 +138,15 @@ class BaseController extends Controller
/**
* ---------------------------------------
* 由表主键删除数据表中的多条记录
* @param \yii\db\ActiveRecord $model 模型名称,供M函数使用的参数
* @param string $pk 修改的数据
* @return boolean
* ---------------------------------------
* @param \yii\db\ActiveRecord $model 模型名称,供M函数使用的参数
* @param string $pk 修改的数据
* @return boolean
*/
public function delRow($model, $pk = 'id')
{
$ids = Yii::$app->request->param($pk, 0);
$ids = implode(',', array_unique((array)$ids));
$ids = implode(',', array_unique((array) $ids));
if (empty($ids)) {
return false;
......@@ -162,11 +164,11 @@ class BaseController extends Controller
* ----------------------------------------------
* 操作错误跳转的快捷方法
* @access protected
* @param string $message 错误信息
* @param string $jumpUrl 页面跳转地址
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
* @return void
* -----------------------------------------------
* @param string $message 错误信息
* @param string $jumpUrl 页面跳转地址
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
* @return void
*/
protected function error($message = '', $jumpUrl = '', $ajax = false)
{
......@@ -177,11 +179,11 @@ class BaseController extends Controller
* ----------------------------------------------
* 操作成功跳转的快捷方法
* @access protected
* @param string $message 提示信息
* @param string $jumpUrl 页面跳转地址
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
* @return void
* ----------------------------------------------
* @param string $message 提示信息
* @param string $jumpUrl 页面跳转地址
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
* @return void
*/
protected function success($message = '', $jumpUrl = '', $ajax = false)
{
......@@ -193,18 +195,19 @@ class BaseController extends Controller
* 默认跳转操作 支持错误导向和正确跳转
* 调用模板显示 默认为public目录下面的success页面
* 提示页面为可配置 支持模板标签
* @param string $message 提示信息
* @param int $status 状态
* @param string $jumpUrl 页面跳转地址
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
* @access private
* @return void
* ----------------------------------------------
* @param string $message 提示信息
* @param int $status 状态
* @param string $jumpUrl 页面跳转地址
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
* @return void
*/
private function dispatchJump($message, $status = 1, $jumpUrl = '', $ajax = false)
{
$jumpUrl = !empty($jumpUrl) ? (is_array($jumpUrl) ? Url::toRoute($jumpUrl) : $jumpUrl) : '';
if (true === $ajax || Yii::$app->request->isAjax) {// AJAX提交
if (true === $ajax || Yii::$app->request->isAjax) {
// AJAX提交
$data = is_array($ajax) ? $ajax : array();
$data['info'] = $message;
$data['status'] = $status;
......@@ -214,8 +217,9 @@ class BaseController extends Controller
// 成功操作后默认停留1秒
$waitSecond = 3;
if ($status) { //发送成功信息
$message = $message ? $message : '提交成功';// 提示信息
if ($status) {
//发送成功信息
$message = $message ? $message : '提交成功'; // 提示信息
// 默认操作成功自动返回操作前页面
echo $this->renderFile(Yii::$app->params['action_success'], [
'message' => $message,
......@@ -223,7 +227,7 @@ class BaseController extends Controller
'jumpUrl' => $jumpUrl,
]);
} else {
$message = $message ? $message : '发生错误了';// 提示信息
$message = $message ? $message : '发生错误了'; // 提示信息
// 默认发生错误的话自动返回上页
$jumpUrl = "javascript:history.back(-1);";
echo $this->renderFile(Yii::$app->params['action_error'], [
......@@ -241,9 +245,9 @@ class BaseController extends Controller
* ------------------------------------------------
* Ajax方式返回数据到客户端
* @access protected
* @param mixed $data 要返回的数据
* @return void
* ------------------------------------------------
* @param mixed $data 要返回的数据
* @return void
*/
protected function ajaxReturn($data)
{
......@@ -254,4 +258,25 @@ class BaseController extends Controller
exit;
}
/**
* 获取所有可以访问action的用户
*
* @return array
*/
public function getAccessAdmins($permission_name = '')
{
//获取所有管理员
if (empty($permission_name)) {
$permission_name = Yii::$app->controller->module->requestedRoute;
}
$auth = Yii::$app->authManager;
$admins = Admin::find()->select(['uid', 'username'])->asArray()->all();
foreach ($admins as $key => $value) {
if (!$auth->checkAccess($value['uid'], $permission_name)) {
unset($admins[$key]);
}
}
$admins = array_column($admins, 'username', 'uid');
return $admins;
}
}
<?php
/**
* Created By Sublime Text 3
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
namespace backend\controllers;
use Yii;
use backend\models\coin\CoinPublishForm;
use common\models\psources\CoinPublish;
use common\models\psources\Coin;
class CoinPublishController extends BaseController
{
public function actionList()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$get = Yii::$app->request->get();
$page = $get['page'] ?? 1;
$limit = $get['limit'] ?? 10;
$auth = Yii::$app->authManager;
$role_self = current($auth->getRolesByUser(Yii::$app->user->id));
$child_roles = $auth->getChildRoles($role_self->name);
$userful_roles = array_keys($child_roles);
// var_dump($userful_roles);die();
$condition[] = ['in', 'owner', $userful_roles];
$data = CoinPublish::getList($page, $limit, $condition);
return $data;
}
return $this->render('list');
}
public function actionAdd()
{
if (Yii::$app->request->isGet) {
$this->layout = false;
$id = Yii::$app->request->get('id', null);
if ($id) {
$model = CoinPublish::findOne($id);
} else {
$model = new CoinPublishForm();
}
$auth = Yii::$app->authManager;
$role = current($auth->getRolesByUser(Yii::$app->user->id));
$childRoles = array_keys($auth->getChildRoles($role->name));
// $coins = Coin::getAllByPlatformId(Yii::$app->user->identity->platform_id, 0, 999);
return $this->render('form', ['model' => $model, 'roles' => $childRoles]);
} elseif (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$post = Yii::$app->request->post();
$model = new CoinPublishForm();
if (isset($post['id']) && !empty($post['id'])) {
$model->scenario = CoinPublishForm::SCENARIOS_UPDATE;
} else {
$model->scenario = CoinPublishForm::SCENARIOS_ADD;
}
if ($model->load($post) && $model->validate()) {
if ($model->id) {
$CoinPublish = CoinPublish::findOne($model->id);
} else {
$CoinPublish = new CoinPublish();
}
$CoinPublish->company_name = $model->company_name;
$CoinPublish->coin_name_zh = $model->coin_name_zh;
$CoinPublish->coin_name_en = $model->coin_name_en;
$CoinPublish->address = $model->address;
$CoinPublish->owner = $model->owner;
$CoinPublish->platform_id = Yii::$app->user->identity->platform_id;
if ($CoinPublish->save(false)) {
return ['code' => 0, 'msg' => 'succeed', 'data' => ''];
} else {
return ['code' => -1, 'msg' => 'failed'];
}
} else {
return ['code' => -1, 'msg' => current($model->firstErrors)];
}
}
}
public function actionDel()
{
Yii::$app->response->format = 'json';
$id = Yii::$app->request->get('id', null);
if ($id) {
$model = CoinPublish::findOne(['id' => $id]);
if ($model->delete()) {
return ['code' => 0, 'msg' => 'succeed'];
}
}
return ['code' => -1, 'msg' => 'failed'];
}
}
\ No newline at end of file
<?php
/**
* Created By Sublime Test 3
*
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
namespace backend\controllers;
use backend\jobs\FreezeJob;
use common\models\psources\CoinPublish;
use common\models\psources\CoinPublishRule;
use common\models\psources\CoinReleaseMember;
use Yii;
class CoinPublishRuleController extends BaseController
{
const DATE_FORMAT = [
'Y-m-d H:i:s',
'm月d号 H:i:s', //每年
'd号 H:i:s', //每月
];
const SHOW_FORMAT = [
'Y-m-d H:i:s',
'm月d号 H:i:s', //每年
'd号 H:i:s', //每月
];
public function actionIndex()
{
if (Yii::$app->request->isAjax) {
$auth = Yii::$app->authManager;
$user_identity = Yii::$app->user->identity;
$get = Yii::$app->request->get();
$page = $get['page'] ?? 1;
$limit = $page['limit'] ?? 10;
$role = current($auth->getRolesByUser($user_identity->id));
Yii::$app->response->format = 'json';
// 获取用户组的所有锁仓规则
if (!$role) {
return ['code' => -1, 'msg' => 'failed'];
}
$condition = [['owner' => $role->name]];
$datas = CoinPublish::getList($page, $limit, $condition);
return $datas;
}
return $this->render('index');
}
public function actionList()
{
$get = Yii::$app->request->get();
$page = $get['page'] ?? 1;
$limit = $get['limit'] ?? 10;
$id = $get['id'] ?? null;
$pid = $get['pid'] ?? $this->getPid();
$condition = [];
if ($pid) {
$condition[] = ['pid' => $pid];
}
if ($id) {
$condition[] = ['id' => $id];
}
if (Yii::$app->request->isAjax) {
$data = CoinPublishRule::getList($page, $limit, $condition);
Yii::$app->response->format = 'json';
$models = $data['data'];
// 获取锁仓人数
$ids = array_column($models, 'id');
$member_count = CoinReleaseMember::getCountByRuleIds($ids);
foreach ($models as $key => &$model) {
$model['release_time'] = date(self::SHOW_FORMAT[$model['repeat']], strtotime($model['release_time']));
$model['amount'] = $member_count[$model['id']] ?? 0;
}
$data['data'] = $models;
return $data;
}
$coin = CoinPublish::findOne($pid);
return $this->render('list',
[
'coin_name' => $coin->coin_name_en ?? '',
'amount' => 100090000,
'release_amount' => CoinPublishRule::getReleaseAmountThisMonthById($pid),
'address' => $coin->address ?? '',
]);
}
public function actionSet()
{
if (Yii::$app->request->isGet) {
$this->layout = false;
return $this->render('form');
} elseif (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$post = Yii::$app->request->post();
if (isset($post['id']) && !empty($post['id'])) {
$model = CoinPublishRule::findOne($post['id']);
$model->scenario = CoinPublishRule::SCENARIOS_UPDAET;
unset($post['id']);
} else {
$model = new CoinPublishRule();
$model->scenario = CoinPublishRule::SCENARIOS_ADD;
// 编号
$prefix = date('Ymd', time());
$form_database = CoinPublishRule::find()
->where(['like', 'sid', $prefix])
->orderBy(['sid' => SORT_DESC])
->asArray()
->One();
if ($form_database) {
$sid = (int) $form_database['sid'] + 1;
} else {
$sid = $prefix . '001';
}
$model->platform_id = 3;
}
if ($model->load($post) && $model->validate()) {
if (CoinPublishRule::SCENARIOS_ADD == $model->scenario) {
$model->sid = (string) $sid;
}
$model->release_time = date_create_from_format(self::DATE_FORMAT[$model->repeat],
$model->release_time)->format('Y-m-d H:i:s');
$model->pid = $this->getPid();
if ($model->save()) {
if ($model->qid) {
//删除原有的任务
Yii::$app->queue->remove($model->qid);
}
// 计算延时
$now = time();
$delay_time = CoinPublishRule::getDelay($now, $model->repeat, strtotime($model->release_time));
// 保存数据到任务队列
$id = Yii::$app->queue->delay($delay_time)->push(new FreezeJob(['id' => $model->id]));
if (!$id) {
$model->delete();
Yii::info("CoinPublishRule_id[{$model->id}]: queue id[$id] , push failed!", __CLASS__);
return ['code' => -1, 'msg' => '保存失败'];
} else {
$model->qid = $id;
$model->save();
Yii::info("CoinPublishRule_id[{$model->id}]: queue id[$id] , push succeed!", __CLASS__);
}
return ['code' => 0, 'msg' => 'succeed'];
}
} else {
return ['code' => -1, 'msg' => current($model->firstErrors)];
}
return ['code' => -1, 'msg' => '保存失败'];
}
}
public function actionDel()
{
$id = Yii::$app->request->get('id', null);
Yii::$app->response->format = 'json';
if ($id) {
$model = CoinPublishRule::findOne($id);
if ($model) {
if ($model->getMemberCount() > 0) {
return ['code' => -1, 'msg' => '规则内有用户,不能删除!'];
} else {
// 删除队列任务
Yii::$app->queue->remove($model->qid);
if ($model->delete()) {
return ['code' => 0, 'msg' => 'succeed'];
}
}
}
}
return ['code' => -1, 'msg' => '删除失败'];
}
/**
* 获取id
* @return int
*/
private function getPid()
{
$referer = Yii::$app->request->getReferrer();
$referer = parse_url($referer, PHP_URL_QUERY);
parse_str($referer, $query);
if (!isset($query['pid']) || empty($query['pid'])) {
return false;
}
return $query['pid'];
}
}
<?php
/**
* Created By Sublime Text 3
*
* @date 2018-09-05 17:13:46
* @authors rlgy <rlgyzhcn@qq.com>
*/
namespace backend\controllers;
use common\models\psources\CoinExtract;
use common\models\psources\CoinPublish;
use common\models\psources\CoinReleaseCheck;
use Yii;
class CoinReleaseCheckController extends BaseController
{
const STEP_CHECK_FIRST = 1; //初审
const STEP_CHECK_SECOND = 2; //复核
const STEP_CANCEL = 3; //撤提
public $enableCsrfValidation = false;
public function actionIndex()
{
$admins = $this->getAccessAdmins();
//获取所有币种
$coins = CoinPublish::find()->select('coin_name_en')->asArray()->all();
$coins = array_column(array_unique($coins), 'coin_name_en');
return $this->render('index', [
'coins' => $coins,
'check_firsts' => $admins,
'check_seconds' => $admins,
]);
}
public function actionCheckList()
{
Yii::$app->response->format = 'json';
$get = Yii::$app->request->get();
$model = new CoinReleaseCheck();
$model->scenario = CoinReleaseCheck::SCENARIOS_CHECK;
if ($model->load($get) && $model->validate()) {
$page = $get['page'] ?? 1;
$limit = $page['limit'] ?? 10;
$datas = CoinReleaseCheck::find()
->andFilterWhere(['status' => 0, 'coin' => $model->coin, 'mobile' => $model->mobile]);
if ($model->start_time) {
$datas = $datas->andFilterWhere(['>=', 'create_time', $model->start_time]);
}
if ($model->end_time) {
$datas = $datas->andFilterWhere(['<=', 'create_time', $model->end_time]);
}
$count = $datas->count();
$datas = $datas->limit($limit)
->offset(($page - 1) * $limit)
->asArray()
->all();
//获取操作次数
//提出地址
$addresses = array_values(array_unique(array_column($datas, 'to_address')));
$address_datas = CoinExtract::getAllByAddress($addresses);
foreach ($datas as $key => &$value) {
$value['today'] = $address_datas[$value['to_address']]['today'];
$value['total'] = $address_datas[$value['to_address']]['total'];
}
return ['code' => 0, 'count' => $count, 'data' => $datas];
} else {
return ['code' => -1, 'msg' => current($model->firstErrors)];
}
}
public function actionSearchList()
{
Yii::$app->response->format = 'json';
$get = Yii::$app->request->get();
$model = new CoinReleaseCheck();
$model->scenario = CoinReleaseCheck::SCENARIOS_SEARCH;
if ($model->load($get) && $model->validate()) {
$page = $get['page'] ?? 1;
$limit = $page['limit'] ?? 10;
$query = CoinReleaseCheck::find()
->andFilterWhere(['!=', 'status', 0])
->andFilterWhere([
'status' => $model->status,
'coin' => $model->coin,
'check_first_uid' => $model->check_first_uid,
'check_second_uid' => $model->check_second_uid,
]);
if ($model->start_time) {
$query = $query->andFilterWhere(['>=', 'create_time', $model->start_time]);
}
if ($model->end_time) {
$query = $query->andFilterWhere(['<=', 'create_time', $model->end_time]);
}
$count = $query->count();
$datas = $query->limit($limit)->offset(($page - 1) * $limit)->asArray()->all();
//获取审核员id
$check_ids = array_column($datas, 'check_first_uid');
$check_ids = array_unique(array_values(array_merge($check_ids, array_column($datas, 'check_second_uid'))));
//获取所有管理员
$admins = $this->getAccessAdmins();
foreach ($datas as $key => &$value) {
$value['check_first_uid'] = $admins[$value['check_first_uid']];
$value['check_second_uid'] = $admins[$value['check_second_uid']];
}
return ['code' => 0, 'count' => $count, 'data' => $datas];
} else {
return ['code' => -1, 'msg' => current($model->firstErrors)];}
}
public function actionCheck()
{
Yii::$app->response->format = 'json';
$id = Yii::$app->request->get('id', null);
$status = Yii::$app->request->get('status', null);
$step = Yii::$app->request->get('step', null);
if (!empty($id) && !empty($status) && !empty($step)) {
if (ctype_digit($id) && ctype_digit($status) && ctype_digit($step)) {
if (($status == 2 || $status == 3) && ($step >= 1 || $step <= 3)) {
$model = CoinReleaseCheck::findOne($id);
if ($model) {
if (CoinReleaseCheck::STATUS_NORMAL != $model->status) {
return ['code' => -1, 'msg' => '不允许进行审核!'];
}
if (self::STEP_CHECK_FIRST == $step) {
if ($model->check_second_status != CoinReleaseCheck::CHECK_SECOND_STATUS_NORMAL) {
return ['code' => -1, 'msg' => '已经复核的申请不允许初审!'];
}
$model->check_first_uid = Yii::$app->user->id;
$model->check_first_status = $status;
} elseif (self::STEP_CHECK_SECOND == $step) {
if (CoinReleaseCheck::CHECK_FIRST_STATUS_SUCCEED == $model->check_first_status) {
$model->check_second_uid = Yii::$app->user->id;
$model->check_second_status = $status;
//改变status
$model->status = CoinReleaseCheck::STATUS_PADDING;
} else {
return ['code' => -1, 'msg' => '初审未通过'];
}
} elseif (self::STEP_CANCEL == $step) {
$model->status = CoinReleaseCheck::STATUS_CANCEL;
}
if ($model->save(false)) {
if ($step == self::STEP_CHECK_SECOND && CoinReleaseCheck::CHECK_SECOND_STATUS_SUCCEED == $model->check_second_status) {
//TODO 提币
}
return ['code' => 0, 'msg' => '操作成功'];
}
}
}
}
}
return ['code' => 0, 'msg' => '操作失败'];
}
}
<?php
/**
* Created By Sublime Test 3
*
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
namespace backend\controllers;
use Yii;
use yii\web\UploadedFile;
use common\models\psources\CoinReleaseMember;
use common\models\psources\CoinPublishRule;
/**
* CoinReleaseMember
*/
class CoinReleaseMemberController extends BaseController
{
public $enableCsrfValidation = false;
public function actionList()
{
$get = Yii::$app->request->get();
$page = $get['page'] ?? 1;
$limit = $get['limit'] ?? 10;
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
// 获取rule_id
$rule_id = $this->getRuleId();
if (empty($rule_id)) {
return ['code' => -1, 'msg' => 'failed'];
}
$condition = [['rule_id' => $rule_id]];
$datas = CoinReleaseMember::getList($page, $limit, $condition);
return $datas;
}
return $this->render('list');
}
public function actionSet()
{
if (Yii::$app->request->isGet) {
$this->layout = false;
return $this->render('form');
} else {
if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$post = Yii::$app->request->post();
// 获取rule_id
$rule_id = $this->getRuleId();
if ($rule_id) {
$post['rule_id'] = $rule_id;
$coin_publish_rule = CoinPublishRule::findOne($rule_id);
if ($coin_publish_rule) {
$post['release'] = $post['amount'] * (100 - $coin_publish_rule->lock) / 100;
$post['freeze'] = $post['amount'] * $coin_publish_rule->lock / 100;
} else {
return ['code' => -1, 'msg' => '规则不存在'];
}
} else {
return ['code' => -1, 'msg' => '规则不存在'];
}
if (isset($post['id']) && !empty($post['id'])) {
$model = CoinReleaseMember::findOne($post['id']);
$model->scenario = CoinReleaseMember::SCENARIOS_UPDATE;
} else {
$model = new CoinReleaseMember();
$model->scenario = CoinReleaseMember::SCENARIOS_ADD;
}
if ($model->load($post) && $model->validate()) {
if ($model->save()) {
return ['code' => 0, 'msg' => '添加成功'];
}
} else {
return ['code' => -1, 'msg' => current($model->firstErrors)];
}
return ['code' => -1, 'msg' => '添加失败'];
}
}
}
/**
* 名单导入
*/
public function actionImplode()
{
Yii::$app->response->format = 'json';
$file = UploadedFile::getInstanceByName('file');
try {
$fd = fopen($file->tempName, 'r');
$data = [];
$rule_id = $this->getRuleId();
if ($rule_id) {
$coin_publish_rule = CoinPublishRule::findOne($rule_id);
$present = $coin_publish_rule->lock;
if (!$coin_publish_rule) {
return ['code' => -1, 'msg' => '规则不存在'];
}
while (($row = fgetcsv($fd)) !== false) {
array_unshift($row, $rule_id);
$data[] = $row;
}
if (empty($data)) {
return ['code' => -1, 'msg' => '导入失败'];
}
if (ctype_digit($data[0][0])) {
array_shift($data);
}
foreach ($data as $key => &$value) {
$value[] = $value[3] * (100 - $present) / 100;
$value[] = $value[3] * $present / 100;
}
$result = CoinReleaseMember::implode($data);
if ($result) {
return ['code' => 0, 'msg' => '导入成功'];
}
} else {
return ['code' => -1, 'msg' => '规则不存在'];
}
} catch (\Exception $e) {
return ['code' => $e->getCode(), 'msg' => $e->getMessage()];
}
return ['code' => 0, 'msg' => '导入失败'];
}
/**
* 获取rule_id
* @return int
*/
private function getRuleId()
{
$referer = Yii::$app->request->getReferrer();
$referer = parse_url($referer, PHP_URL_QUERY);
parse_str($referer, $query);
if (!isset($query['rid']) || empty($query['rid'])) {
return false;
}
return $query['rid'];
}
}
\ No newline at end of file
<?php
/**
* Created By Sublime Text 3
*
* @date 2018-09-04 10:43:18
* @authors rlgy <rlgyzhcn@qq.com>
*/
namespace backend\jobs;
use common\models\psources\CoinPublishRule;
use common\models\psources\CoinReleaseMember;
use Yii;
use yii\base\BaseObject;
use yii\queue\JobInterface;
use yii\queue\Queue;
class FreezeJob extends BaseObject implements JobInterface
{
public $id;
/**
* @param Queue $queue which pushed and is handling the job
* @return integer
*/
public function execute($queue)
{
$coin_publish_rule = CoinPublishRule::findOne($this->id);
if (!$coin_publish_rule) {
// 计划任务已经被删除
return 0;
}
//修改用户的币种冻结信息
$members = CoinReleaseMember::getMemberByRuleIds($this->id);
foreach ($members as $key => &$value) {
//获取改的币种数量
$change = CoinPublishRule::calReleaseAmount($coin_publish_rule->lock, $coin_publish_rule->release, $coin_publish_rule->type, $value['amount'], $value['freeze'], 0);
if ($change > $value['freeze']) {
$change = $value['freeze'];
}
$value['release'] += $change;
$value['freeze'] -= $change;
}
unset($key, $value);
// 记录解冻操作
Yii::info(sprintf('Coin Freeze Job Start: sid[%s] lock[%s] release[%s]',
$coin_publish_rule->sid, $coin_publish_rule->lock, $coin_publish_rule->release), __CLASS__);
foreach ($members as $key => $value) {
$models = CoinReleaseMember::findOne($value['id']);
$models->release = $value['release'];
$models->freeze = $value['freeze'];
$models->save();
// 记录解冻操作
Yii::info(sprintf('member[Id=%s] release amount: %s, freeze still: %s', $value['id'], $change, $value['freeze']), __CLASS__);
}
// 执行下一次任务
if ($coin_publish_rule->repeat) {
$delay_time = CoinPublishRule::getDelay('', $coin_publish_rule->repeat, strtotime($coin_publish_rule->release_time));
$qid = Yii::$app->queue->delay($delay_time)->push(new FreezeJob(['id' => $this->id]));
$coin_publish_rule->qid = $qid;
$coin_publish_rule->save();
}
// 记录解冻操作
Yii::info(sprintf('Coin Freeze Job Finished: sid[%s] lock[%s] release[%s]',
$coin_publish_rule->sid, $coin_publish_rule->lock, $coin_publish_rule->release), __CLASS__);
return 0;
}
}
<?php
/**
* Created By Sublime Text 3
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
namespace backend\models\coin;
use yii\base\Model;
use Yii;
class CoinPublishForm extends Model
{
const SCENARIOS_ADD = 'add';
const SCENARIOS_UPDATE = 'update';
public $id;
public $company_name;
public $coin_name_en;
public $coin_name_zh;
public $address;
public $owner;
public $platform_id;
public function rules()
{
return [
[['company_name', 'coin_name_zh', 'coin_name_en', 'address'], 'string', 'max' => 255],
[['owner'], 'ownerValidate'],
[['id', 'platform_id'], 'integer', 'min' => 0],
[
['id', 'company_name', 'coin_name_zh', 'coin_name_en'],
'required',
'on' => self::SCENARIOS_UPDATE
],
[['company_name', 'coin_name_zh', 'coin_name_en'], 'required', 'on' => self::SCENARIOS_ADD],
];
}
public function attributeLabels()
{
return [
'id' => 'ID',
'company_name' => '公司名称',
'coin_name_zh' => '币种中文名',
'coin_name_en' => '币种英文名',
'address' => '热钱包地址',
'platform_id' => '平台id',
'owner' => '企业用户组',
];
}
public function scenarios()
{
return [
self::SCENARIOS_ADD => ['company_name', 'coin_name_zh', 'coin_name_en', 'address', 'owner'],
self::SCENARIOS_UPDATE => [
'id',
'company_name',
'coin_name_zh',
'coin_name_en',
'address',
'owner'
],
];
}
public function formName()
{
return '';
}
public function ownerValidate($attribute, $params)
{
$roleName = $this->$attribute;
$auth = Yii::$app->authManager;
$child_role = $auth->getRole($roleName);
if (!$child_role) {
$this->addError($attribute, '企业用户组不存在');
}
return true;
}
}
\ No newline at end of file
......@@ -26,11 +26,6 @@ $columns = [
'headerOptions'=>['style'=>'width:10px'], 'contentOptions' => ['style' => 'white-space: nowrap;']
],
[
'label' => 'UID',
'attribute' => 'bind_uid',
'options' => ['width' => '70px'],
],
[
'label' => '真实姓名',
'attribute' => 'name.name',
'options' => ['width' => '80px'],
......
<?php
/**
* Created By Sublime Test 3
*
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
?>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form id="form_data" class="layui-form" lay-filter="form_data">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>" />
<input type="hidden" name="id" />
<div class="layui-inline">
<label class="layui-form-label" style="width: 110px;">锁仓编号</label>
<div class="layui-input-block">
<input name="sid" type="text" class="layui-input" lay-verify="required" readonly="readonly" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 110px;">锁仓比例(%)</label>
<div class="layui-input-block">
<input name="lock" type="text" class="layui-input" lay-verify="required" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 110px;">类型</label>
<div class="layui-input-block">
<select name="type" class="layui-input">
<option value="0"></option>
<option value="1">按锁仓总量释放</option>
<option value="2">按锁仓余量释放</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 110px;">释放比例(%)</label>
<div class="layui-input-block">
<input name="release" type="text" class="layui-input" lay-verify="required" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 110px;">重复</label>
<div class="layui-input-block">
<select name="repeat" class="layui-input" lay-filter="form_data">
<option value="0">不重复</option>
<option value="1">每年</option>
<option value="2">每月</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 110px;">释放时间</label>
<div class="layui-input-block">
<input name="release_time" type="text" class="layui-input" lay-verify="required" id="release_time" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 110px;">备注</label>
<div class="layui-input-block">
<textarea name="notice" class="layui-textarea"></textarea>
</div>
</div>
</form>
</div>
</div>
<?php
/**
* Created By Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-04 10:11:49
*/
use backend\assets\coinPublishRule\IndexAsset;
IndexAsset::register($this);
?>
<div>
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<script type="text/html" id="toolbar">
<a class="layui-btn layui-btn-sm" href="/admin/coin-publish-rule/list?pid={{d.id}}">查看详情</a>
</script>
\ No newline at end of file
<?php
/**
* Created By Sublime Test 3
*
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
use backend\assets\coinPublishRule\ListAsset;
ListAsset::register($this);
?>
<div class="layui-row">
<div class="layui-col-md6">
<table class="layui-table">
<thead>
<th>币种</th>
<th>热钱包数量</th>
<th>当月解冻总量</th>
<th>热钱包地址</th>
</thead>
<tbody>
<tr>
<td><?= $coin_name ?></td>
<td><?= $amount ?></td>
<td><?= $release_amount ?></td>
<td><?= $address ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="layui-row">
<table class="layui-hide" id="table1" lay-filter="table1"></table>
</div>
<script type="text/html" id="toolBarTop">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="add">创建锁仓规则</button>
</div>
</script>
<script type="text/html" id="toolbar">
<button class="layui-btn layui-btn-xs" lay-event="update">编辑</button>
<a class="layui-btn layui-btn-xs" href="/admin/coin-release-member/list?rid={{d.id}}">详情</a>
<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button>
</script>
<script type="text/html" id="form_type">
{{# if (1 == d.type) { }}
按锁仓总量释放
{{# } else if (2 == d.type) { }}
按锁仓余量释放
{{# } }}
</script>
<script type="text/html" id="form_release_time">
{{# if (d.repeat == 0) { }}
{{d.release_time}}
{{# } else if (d.repeat == 1) { }}
每年 {{d.release_time}}
{{# } else if (d.repeat == 2) { }}
每月 {{d.release_time}}
{{# } else if (d.repeat == 3) { }}
每天 {{d.release_time}}
{{# } }}
</script>
\ No newline at end of file
<?php
/**
* Created By Sublime text 3
* @author rlgzyhcn <rlgyzhcn@qq.com>
*/
/**
* @var \commom\models\psources\CoinPublish $model
* @var array $roles
*/
?>
<style type="text/css">
.layui-form-label {
width: 100px;
}
</style>
<div style="padding: 5px 20px;">
<form id="addData" class="layui-form">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input type="hidden" name="id" value="<?= $model->id ?>">
<div class="layui-inline">
<span class="layui-form-label" style="width: 100px;">公司名称</span>
<div class="layui-input-block">
<input name="company_name" type="text" class="layui-input" lay-verify="required" value="<?= $model->company_name ?>">
</div>
</div>
<div class="layui-inline">
<span class="layui-form-label" style="width: 100px;">发行币种</span>
<div class="layui-input-block">
<input name="coin_name_zh" type="text" class="layui-input" lay-verify="required" value="<?= $model->coin_name_zh ?>">
</div>
</div>
<div class="layui-inline">
<span class="layui-form-label" style="width: 100px;">简称</span>
<div class="layui-input-block">
<input name="coin_name_en" type="text" class="layui-input" lay-verify="required" value="<?= $model->coin_name_en ?>">
</div>
</div>
<div class="layui-inline">
<span class="layui-form-label" style="width: 100px;">热钱包地址</span>
<div class="layui-input-block">
<input name="address" type="text" class="layui-input" lay-verify="required" value="<?= $model->address ?>">
</div>
</div>
<div class="layui-inline">
<span class="layui-form-label" style="width: 100px;">企业用户组</span>
<div class="layui-input-block">
<select name="owner" class="layui-select">
<?php if (is_array($roles)): ?>
<?php foreach($roles as $role): ?>
<option value="<?= $role ?>"><?= $role ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
</div>
</form>
</div>
\ No newline at end of file
<?php
/**
* Created By Sublime text 3
* @author rlgzyhcn <rlgyzhcn@qq.com>
*/
use backend\assets\coinPublish\IndexAsset;
IndexAsset::register($this);
?>
<h4>发币管理</h4>
<div class="layui-row">
<button class="layui-btn" id="add">添加币种监控</button>
</div>
<div class="layui-row">
<div class="layui-table" id="table1" lay-filter="table1"></div>
</div>
<script type="text/html" id="toolbar">
<a class="layui-btn layui-btn-xs" lay-event="update">编辑</a>
<a class="layui-btn layui-btn-xs" href="/admin/coin-publish-rule/list?pid={{d.id}}">查看配置</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
\ No newline at end of file
This diff is collapsed.
<?php
/**
* Created By Sublime Test 3
*
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
?>
<style type="text/css">
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-table" id="form_data" lay-filter="form_data">
<input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>">
<div class="layui-inline">
<label class="layui-form-label">手机号码</label>
<div class="layui-input-block">
<input type="text" name="mobile" class="layui-input" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">币种</label>
<div class="layui-input-block">
<input type="text" name="coin" class="layui-input" />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">总量</label>
<div class="layui-input-block">
<input type="text" name="amount" class="layui-input" />
</div>
</div>
</form>
</div>
</div>
\ No newline at end of file
<?php
/**
* Created By Sublime Test 3
*
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
use backend\assets\coinReleaseMember\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="add" id="add">添加人员</button>
</div>
<div class="layui-row">
<div class="layui-col-md8">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
</div>
\ No newline at end of file
/**
* Created By Sublime Text 3
*
* @authors rlgy (rlgyzhcn@qq.com)
* @date 2018-09-04 10:24:52
*/
var table = layui.table;
table.render({
elem: '#table1',
url: '/admin/coin-publish-rule/index',
page: 1,
limit: 10,
cols: [[
{field: "id", title: "ID"},
{field: "coin_name_en", title: '币种中文名'},
{field: "coin_name_zh", title: "币种英文名"},
{field: "address", title: "热钱包地址"},
{title: "操作", toolbar: "#toolbar"}
]]
});
\ No newline at end of file
var table = layui.table;
var form = layui.form;
var laydate = layui.laydate;
var format = [
'yyyy-MM-dd HH:mm:ss',// 不重复
'MM月dd号 HH:mm:ss', //每年
'dd号 HH:mm:ss', //每月
];
var laydate1;
table.render({
elem: '#table1',
url: '/admin/coin-publish-rule/list',
limit: 10,
page: 1,
toolbar: '#toolBarTop',
cols: [[
{field: 'sid', title: '锁仓编号'},
{field: 'amount', title: '锁仓人数'},
{field: 'release_time', title: '释放时间', templet: "#form_release_time"},
{field: 'lock', title: '锁仓比例'},
{field: 'type', title: '释放类型', templet: "#form_type"},
{field: 'release', title: '释放比例'},
{field: 'notice', title: '备注'},
{title: '操作', toolbar: '#toolbar'}
]]
});
table.on('tool(table1)', function (obj) {
var event = obj.event;
var data = obj.data;
if ('update' == event) {
$.get('/admin/coin-publish-rule/set', {id: data.id}, function (rev) {
var index = layer.open({
type: 1,
title: '编辑',
id: 'update_one',
skin: 'layer-skin-lan',
content: rev,
btn: ['保存', '取消'],
btn1: function () {
$btn = $('.layui-layer-btn0').button('loading');
$.post('/admin/coin-publish-rule/set', $("#form_data").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
layer.close(index);
table.reload("table1", {});
}
});
$btn.button('reset');
}
});
form.render();
$.get('/admin/coin-publish-rule/list', {id: data.id, page: 1, limit: 1}, function (rev) {
if (0 == rev.code) {
var data = rev.data[0];
form.val("form_data", {
id: data.id,
sid: data.sid,
lock: data.lock,
type: data.type,
release: data.release,
repeat: data.repeat,
release_time: "",
notice: data.notice,
});
laydate1 = laydate.render({
elem: '#release_time',
type: 'datetime',
format: format[data.repeat],
value: data.release_time
});
}
});
});
} else if ('del' == event) {
layer.confirm('确定删除锁仓规则(' + data.sid + ')', {title: '删除'}, function (index) {
$.get('/admin/coin-publish-rule/del', {id: data.id}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
obj.del();
layer.close(index);
}
});
});
}
});
table.on('toolbar(table1)', function (obj) {
var checkStatus = table.checkStatus(obj.config.id);
var event = obj.event;
if ('add' == event) {
$.get('/admin/coin-publish-rule/set', {}, function (rev) {
var index = layer.open({
type: 1,
title: '添加锁仓规则',
id: 'add_one',
skin: 'layer-skin-lan',
content: rev,
// area: ['500px', 'auto'],
btn: ['确认', '取消'],
btn1: function () {
$btn = $('.layui-layer-btn0').button('loading');
$.post('/admin/coin-publish-rule/set', $("#form_data").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
layer.close(index);
table.reload("table1", {});
}
});
$btn.button('reset');
}
});
form.render();
laydate1 = laydate.render({
elem: '#release_time',
type: 'datetime',
});
});
}
});
form.on('select(form_data)', function (data) {
var index = $('#form_data select[name="repeat"]').val();
var clone = $("#release_time").clone();
var parent = $("#release_time").parent("div");
$("#release_time").remove();
clone.removeAttr('lay-key');
parent.append(clone);
laydate.render({
elem: '#release_time',
type: 'datetime',
format: format[index]
});
});
var table = layui.table;
table.render({
elem: "#table1",
url: '/admin/coin-publish/list',
limit: 10,
page: 1,
loading: true,
cols: [[
{field: 'id', title: 'ID'},
{field: 'company_name', title: '公司名称'},
{field: 'coin_name_zh', title: '币种中文名'},
{field: 'coin_name_en', title: '币种英文名'},
{field: 'address', title: '热钱包地址'},
{field: 'amount', title: '热钱包数量'},
{toolbar: '#toolbar', title: '操作'}
]],
});
table.on('tool(table1)', function(obj){
var event = obj.event;
var data = obj.data;
if ('update' == event) {
$.get('/admin/coin-publish/add', {id: data.id}, function (str) {
var index = layer.open({
type: 1,
title: '编辑',
id: 'add-one',
skin: 'layui-layer-lan',
area: ['320px', 'auto'],
content: str,
btn: ['确认', '取消'],
btn1: function () {
var company_name = $('#addData input[name="company_name"]').val();
var coin_name_zh = $('#addData input[name="coin_name_zh"]').val();
var coin_name_en = $('#addData input[name="coin_name_en"]').val();
if (company_name !== "" && company_name !== "" && coin_name_en !== "") {
$btn = $('.layui-layer-btn0').button('loading');
$.post('/admin/coin-publish/add', $("#addData").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
layer.close(index);
table.reload("table1", {});
}
});
$btn.button('reset');
} else {
layer.msg("请输入完整!");
}
return false;
}
});
layui.form.render();
});
}else if('del' == event){
layer.confirm('确定删除此币种监控吗?', {title: '删除币种'}, function(index){
$.get('/admin/coin-publish/del', {id: data.id}, function(rev) {
if (rev.code == 0) {
obj.del();
layer.close(index);
}
});
});
}
});
$('#add').click(function () {
//打开弹窗
$.get('/admin/coin-publish/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 () {
var company_name = $('#addData input[name="company_name"]').val();
var coin_name_zh = $('#addData input[name="coin_name_zh"]').val();
var coin_name_en = $('#addData input[name="coin_name_en"]').val();
if (company_name !== "" && company_name !== "" && coin_name_en !== "") {
$btn = $('.layui-layer-btn0').button('loading');
$.post('/admin/coin-publish/add', $("#addData").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
layer.close(index);
table.reload("table1", {});
}
});
$btn.button('reset');
} else {
layer.msg("请输入完整!");
}
return false;
}
});
layui.form.render();
});
return false;
});
\ No newline at end of file
/**
*
* @authors rlgy (rlgyzhcn@qq.com)
* @date 2018-09-05 19:33:56
*/
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
form.render();
var table_check = table.render({
elem: '#table_check',
page: true,
limit: 10,
url: '/admin/coin-release-check/check-list',
cols: [[
{field: 'id', title: '流水编号'},
{field: 'mobile', title: '手机号'},
{field: 'coin', title: '币种'},
{field: 'amount', title: '数量'},
{field: 'to_address', title: '对方地址'},
{field: 'today', title: '该地址今日提币次数'},
{field: 'total', title: '该地址总操作数'},
{field: 'create_time', title: '提交时间'},
{title: '操作', toolbar: '#toolbar_check'}
]]
});
var table_search = table.render({
elem: '#table_search',
page: true,
limit: 10,
url: '/admin/coin-release-check/search-list',
cols: [[
{field: 'id', title: '流水编号'},
{field: 'mobile', title: '手机号'},
{field: 'coin', title: '币种'},
{field: 'amount', title: '数量'},
{field: 'to_address', title: '对方地址'},
{field: 'create_time', title: '提交时间'},
{field: 'create_time', title: '完成时间'},
{field: 'status', title: '状态', templet: '#search_status'},
{field: 'check_first_uid', title: '初审员'},
{field: 'check_second_uid', title: '复审员'},
]]
});
laydate.render({
elem: '#date_check_start',
});
laydate.render({
elem: '#date_check_end',
});
laydate.render({
elem: '#date_search_start',
});
laydate.render({
elem: '#date_search_end',
});
form.on('submit(submit_check)', function (data) {
table.reload('table_check', {
page:{
curr:1
},
where: data.field
});
return false;
});
form.on('submit(submit_search)', function (data) {
table.reload('table_search', {
page: {
curr: 1,
},
where: data.field
});
return false;
});
//工具栏点击事件
table.on('tool(table_check)',function (obj) {
var event = obj.event;
var data = obj.data;
if (event=='check_first') {
var index = layer.msg('审核通过?',{
title: '审核',
btn: ['通过', '不通过', '取消'],
btn1: function (index, layero) {
$.get('/admin/coin-release-check/check', {id: data.id, status: 2, step: 1}, function(rev){
layer.msg(rev.msg);
if (0==rev.code) {
table_check.reload();
layer.close(index);
}
});
},
btn2: function (index, layero) {
$.get('/admin/coin-release-check/check', {id: data.id, status: 3, step: 1}, function(rev){
layer.msg(rev.msg);
if (0==rev.code) {
table_check.reload();
layer.close(index);
}
});
}
});
} else if('check_second'==event){
var index = layer.msg('复核通过?',{
title: '复核',
btn: ['通过', '不通过', '取消'],
btn1: function (index, layero) {
$.get('/admin/coin-release-check/check', {id: data.id, status: 2, step: 2}, function(rev){
layer.msg(rev.msg);
if (0==rev.code) {
table_check.reload();
table_search.reload();
layer.close(index);
}
});
},
btn2: function (index, layero) {
$.get('/admin/coin-release-check/check', {id: data.id, status: 3, step: 2}, function(rev){
layer.msg(rev.msg);
if (0==rev.code) {
table_check.reload();
layer.close(index);
}
});
}
});
} else if('extract_cancel' == event){
var index = layer.msg('撤提该申请?',{
title: '撤提',
btn: ['撤提', '取消'],
btn1: function (index, layero) {
$.get('/admin/coin-release-check/check', {id: data.id, status: 2, step: 3}, function(rev){
layer.msg(rev.msg);
if (0==rev.code) {
table_check.reload();
table_search.reload();
layer.close(index);
}
});
}
});
}
});
var table = layui.table;
var upload = layui.upload;
table.render({
elem: "#table1",
url: '/admin/coin-release-member/list',
page: 1,
limit: 10,
cols: [[
{field: 'mobile', title: '手机号'},
{field: 'coin', title: '币种'},
{field: 'amount', title: '总量'},
{field: 'release', title: '已解冻'},
{field: 'freeze', title: '已冻结'},
]]
});
upload.render({
elem: "#implode",
url: "/admin/coin-release-member/implode",
accept: 'file',
exts: 'csv',
done: function (res) {
layer.closeAll('loading');
layer.msg(res.msg);
table.reload('table1', {
page: {
curr: 1
}
});
},
before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer.load(); //上传loading
}
});
$("#add").click(function () {
$.get('/admin/coin-release-member/set', {}, function (rev) {
var index = layer.open({
type: 1,
title: "添加人员",
id: 'add_one',
skin: 'layui-skin-lan',
content: rev,
btn: ['保存', '取消'],
btn1: function () {
$.post('/admin/coin-release-member/set', $("#form_data").serialize(), function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
layer.close(index);
table.reload('table1', {
page: {
curr: 1
}
});
}
});
}
});
});
});
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
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.
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
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