feat: 后端全量更新 - 含所有本次需求
- Contract.php: 返回合约账户余额(balance_contract) - My.php: 地址管理增加BTC/ETH - AppContract.php: 一键平仓(closeall) - AppProxy.php: 代理专属注册链接 + 分级权限(L1/L2) - site.php: 手续费减半(0.018→0.009) - agent_permission_setup.sql: 代理权限SQL - crypto_news_crawler.py: 新闻自动采集脚本
This commit is contained in:
Executable
+363
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use fast\Http;
|
||||
use think\addons\AddonException;
|
||||
use think\addons\Service;
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* 插件管理
|
||||
*
|
||||
* @icon fa fa-cube
|
||||
* @remark 可在线安装、卸载、禁用、启用插件,同时支持添加本地插件。FastAdmin已上线插件商店 ,你可以发布你的免费或付费插件:<a href="https://www.fastadmin.net/store.html" target="_blank">https://www.fastadmin.net/store.html</a>
|
||||
*/
|
||||
class Addon extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
protected $noNeedRight = ['get_table_list'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
if (!$this->auth->isSuperAdmin() && in_array($this->request->action(), ['install', 'uninstall', 'local', 'upgrade'])) {
|
||||
$this->error(__('Access is allowed only to the super management group'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$addons = get_addon_list();
|
||||
foreach ($addons as $k => &$v) {
|
||||
$config = get_addon_config($v['name']);
|
||||
$v['config'] = $config ? 1 : 0;
|
||||
$v['url'] = str_replace($this->request->server('SCRIPT_NAME'), '', $v['url']);
|
||||
}
|
||||
$this->assignconfig(['addons' => $addons, 'api_url' => config('fastadmin.api_url'), 'faversion' => config('fastadmin.version')]);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
public function config($name = null)
|
||||
{
|
||||
$name = $name ? $name : $this->request->get("name");
|
||||
if (!$name) {
|
||||
$this->error(__('Parameter %s can not be empty', 'name'));
|
||||
}
|
||||
if (!preg_match("/^[a-zA-Z0-9]+$/", $name)) {
|
||||
$this->error(__('Addon name incorrect'));
|
||||
}
|
||||
if (!is_dir(ADDON_PATH . $name)) {
|
||||
$this->error(__('Directory not found'));
|
||||
}
|
||||
$info = get_addon_info($name);
|
||||
$config = get_addon_fullconfig($name);
|
||||
if (!$info) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a", [], 'trim');
|
||||
if ($params) {
|
||||
foreach ($config as $k => &$v) {
|
||||
if (isset($params[$v['name']])) {
|
||||
if ($v['type'] == 'array') {
|
||||
$params[$v['name']] = is_array($params[$v['name']]) ? $params[$v['name']] : (array)json_decode($params[$v['name']], true);
|
||||
$value = $params[$v['name']];
|
||||
} else {
|
||||
$value = is_array($params[$v['name']]) ? implode(',', $params[$v['name']]) : $params[$v['name']];
|
||||
}
|
||||
$v['value'] = $value;
|
||||
}
|
||||
}
|
||||
try {
|
||||
//更新配置文件
|
||||
set_addon_fullconfig($name, $config);
|
||||
Service::refresh();
|
||||
$this->success();
|
||||
} catch (Exception $e) {
|
||||
$this->error(__($e->getMessage()));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$tips = [];
|
||||
foreach ($config as $index => &$item) {
|
||||
if ($item['name'] == '__tips__') {
|
||||
$tips = $item;
|
||||
unset($config[$index]);
|
||||
}
|
||||
}
|
||||
$this->view->assign("addon", ['info' => $info, 'config' => $config, 'tips' => $tips]);
|
||||
$configFile = ADDON_PATH . $name . DS . 'config.html';
|
||||
$viewFile = is_file($configFile) ? $configFile : '';
|
||||
return $this->view->fetch($viewFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
$name = $this->request->post("name");
|
||||
$force = (int)$this->request->post("force");
|
||||
if (!$name) {
|
||||
$this->error(__('Parameter %s can not be empty', 'name'));
|
||||
}
|
||||
if (!preg_match("/^[a-zA-Z0-9]+$/", $name)) {
|
||||
$this->error(__('Addon name incorrect'));
|
||||
}
|
||||
|
||||
$info = [];
|
||||
try {
|
||||
$uid = $this->request->post("uid");
|
||||
$token = $this->request->post("token");
|
||||
$version = $this->request->post("version");
|
||||
$faversion = $this->request->post("faversion");
|
||||
$extend = [
|
||||
'uid' => $uid,
|
||||
'token' => $token,
|
||||
'version' => $version,
|
||||
'faversion' => $faversion
|
||||
];
|
||||
$info = Service::install($name, $force, $extend);
|
||||
} catch (AddonException $e) {
|
||||
$this->result($e->getData(), $e->getCode(), __($e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
$this->error(__($e->getMessage()), $e->getCode());
|
||||
}
|
||||
$this->success(__('Install successful'), '', ['addon' => $info]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
$name = $this->request->post("name");
|
||||
$force = (int)$this->request->post("force");
|
||||
$droptables = (int)$this->request->post("droptables");
|
||||
if (!$name) {
|
||||
$this->error(__('Parameter %s can not be empty', 'name'));
|
||||
}
|
||||
if (!preg_match("/^[a-zA-Z0-9]+$/", $name)) {
|
||||
$this->error(__('Addon name incorrect'));
|
||||
}
|
||||
//只有开启调试且为超级管理员才允许删除相关数据库
|
||||
$tables = [];
|
||||
if ($droptables && Config::get("app_debug") && $this->auth->isSuperAdmin()) {
|
||||
$tables = get_addon_tables($name);
|
||||
}
|
||||
try {
|
||||
Service::uninstall($name, $force);
|
||||
if ($tables) {
|
||||
$prefix = Config::get('database.prefix');
|
||||
//删除插件关联表
|
||||
foreach ($tables as $index => $table) {
|
||||
//忽略非插件标识的表名
|
||||
if (!preg_match("/^{$prefix}{$name}/", $table)) {
|
||||
continue;
|
||||
}
|
||||
Db::execute("DROP TABLE IF EXISTS `{$table}`");
|
||||
}
|
||||
}
|
||||
} catch (AddonException $e) {
|
||||
$this->result($e->getData(), $e->getCode(), __($e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
$this->error(__($e->getMessage()));
|
||||
}
|
||||
$this->success(__('Uninstall successful'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用启用
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
$name = $this->request->post("name");
|
||||
$action = $this->request->post("action");
|
||||
$force = (int)$this->request->post("force");
|
||||
if (!$name) {
|
||||
$this->error(__('Parameter %s can not be empty', 'name'));
|
||||
}
|
||||
if (!preg_match("/^[a-zA-Z0-9]+$/", $name)) {
|
||||
$this->error(__('Addon name incorrect'));
|
||||
}
|
||||
try {
|
||||
$action = $action == 'enable' ? $action : 'disable';
|
||||
//调用启用、禁用的方法
|
||||
Service::$action($name, $force);
|
||||
Cache::rm('__menu__');
|
||||
} catch (AddonException $e) {
|
||||
$this->result($e->getData(), $e->getCode(), __($e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
$this->error(__($e->getMessage()));
|
||||
}
|
||||
$this->success(__('Operate successful'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地上传
|
||||
*/
|
||||
public function local()
|
||||
{
|
||||
Config::set('default_return_type', 'json');
|
||||
|
||||
$info = [];
|
||||
$file = $this->request->file('file');
|
||||
try {
|
||||
$uid = $this->request->post("uid");
|
||||
$token = $this->request->post("token");
|
||||
$faversion = $this->request->post("faversion");
|
||||
if (!$uid || !$token) {
|
||||
throw new Exception(__('Please login and try to install'));
|
||||
}
|
||||
$extend = [
|
||||
'uid' => $uid,
|
||||
'token' => $token,
|
||||
'faversion' => $faversion
|
||||
];
|
||||
$info = Service::local($file, $extend);
|
||||
} catch (AddonException $e) {
|
||||
$this->result($e->getData(), $e->getCode(), __($e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
$this->error(__($e->getMessage()));
|
||||
}
|
||||
$this->success(__('Offline installed tips'), '', ['addon' => $info]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新插件
|
||||
*/
|
||||
public function upgrade()
|
||||
{
|
||||
$name = $this->request->post("name");
|
||||
$addonTmpDir = RUNTIME_PATH . 'addons' . DS;
|
||||
if (!$name) {
|
||||
$this->error(__('Parameter %s can not be empty', 'name'));
|
||||
}
|
||||
if (!preg_match("/^[a-zA-Z0-9]+$/", $name)) {
|
||||
$this->error(__('Addon name incorrect'));
|
||||
}
|
||||
if (!is_dir($addonTmpDir)) {
|
||||
@mkdir($addonTmpDir, 0755, true);
|
||||
}
|
||||
|
||||
$info = [];
|
||||
try {
|
||||
$uid = $this->request->post("uid");
|
||||
$token = $this->request->post("token");
|
||||
$version = $this->request->post("version");
|
||||
$faversion = $this->request->post("faversion");
|
||||
$extend = [
|
||||
'uid' => $uid,
|
||||
'token' => $token,
|
||||
'version' => $version,
|
||||
'faversion' => $faversion
|
||||
];
|
||||
//调用更新的方法
|
||||
$info = Service::upgrade($name, $extend);
|
||||
Cache::rm('__menu__');
|
||||
} catch (AddonException $e) {
|
||||
$this->result($e->getData(), $e->getCode(), __($e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
$this->error(__($e->getMessage()));
|
||||
}
|
||||
$this->success(__('Operate successful'), '', ['addon' => $info]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 已装插件
|
||||
*/
|
||||
public function downloaded()
|
||||
{
|
||||
$offset = (int)$this->request->get("offset");
|
||||
$limit = (int)$this->request->get("limit");
|
||||
$filter = $this->request->get("filter");
|
||||
$search = $this->request->get("search");
|
||||
$search = htmlspecialchars(strip_tags($search));
|
||||
$onlineaddons = Cache::get("onlineaddons");
|
||||
if (!is_array($onlineaddons) && config('fastadmin.api_url')) {
|
||||
$onlineaddons = [];
|
||||
$result = Http::sendRequest(config('fastadmin.api_url') . '/addon/index', [], 'GET', [
|
||||
CURLOPT_HTTPHEADER => ['Accept-Encoding:gzip'],
|
||||
CURLOPT_ENCODING => "gzip"
|
||||
]);
|
||||
if ($result['ret']) {
|
||||
$json = (array)json_decode($result['msg'], true);
|
||||
$rows = isset($json['rows']) ? $json['rows'] : [];
|
||||
foreach ($rows as $index => $row) {
|
||||
$onlineaddons[$row['name']] = $row;
|
||||
}
|
||||
}
|
||||
Cache::set("onlineaddons", $onlineaddons, 600);
|
||||
}
|
||||
$filter = (array)json_decode($filter, true);
|
||||
$addons = get_addon_list();
|
||||
$list = [];
|
||||
foreach ($addons as $k => $v) {
|
||||
if ($search && stripos($v['name'], $search) === false && stripos($v['title'], $search) === false && stripos($v['intro'], $search) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($onlineaddons[$v['name']])) {
|
||||
$v = array_merge($v, $onlineaddons[$v['name']]);
|
||||
} else {
|
||||
$v['category_id'] = 0;
|
||||
$v['flag'] = '';
|
||||
$v['banner'] = '';
|
||||
$v['image'] = '';
|
||||
$v['donateimage'] = '';
|
||||
$v['demourl'] = '';
|
||||
$v['price'] = __('None');
|
||||
$v['screenshots'] = [];
|
||||
$v['releaselist'] = [];
|
||||
}
|
||||
$v['url'] = addon_url($v['name']);
|
||||
$v['url'] = str_replace($this->request->server('SCRIPT_NAME'), '', $v['url']);
|
||||
$v['createtime'] = filemtime(ADDON_PATH . $v['name']);
|
||||
if ($filter && isset($filter['category_id']) && is_numeric($filter['category_id']) && $filter['category_id'] != $v['category_id']) {
|
||||
continue;
|
||||
}
|
||||
$list[] = $v;
|
||||
}
|
||||
$total = count($list);
|
||||
if ($limit) {
|
||||
$list = array_slice($list, $offset, $limit);
|
||||
}
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
$callback = $this->request->get('callback') ? "jsonp" : "json";
|
||||
return $callback($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件相关表
|
||||
*/
|
||||
public function get_table_list()
|
||||
{
|
||||
$name = $this->request->post("name");
|
||||
if (!preg_match("/^[a-zA-Z0-9]+$/", $name)) {
|
||||
$this->error(__('Addon name incorrect'));
|
||||
}
|
||||
$tables = get_addon_tables($name);
|
||||
$prefix = Config::get('database.prefix');
|
||||
foreach ($tables as $index => $table) {
|
||||
//忽略非插件标识的表名
|
||||
if (!preg_match("/^{$prefix}{$name}/", $table)) {
|
||||
unset($tables[$index]);
|
||||
}
|
||||
}
|
||||
$tables = array_values($tables);
|
||||
$this->success('', null, ['tables' => $tables]);
|
||||
}
|
||||
}
|
||||
Executable
+275
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\exception\UploadException;
|
||||
use app\common\library\Upload;
|
||||
use fast\Random;
|
||||
use think\addons\Service;
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Lang;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* Ajax异步请求接口
|
||||
* @internal
|
||||
*/
|
||||
class Ajax extends Backend
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['lang'];
|
||||
protected $noNeedRight = ['*'];
|
||||
protected $layout = '';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
//设置过滤方法
|
||||
$this->request->filter(['trim', 'strip_tags', 'htmlspecialchars']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载语言包
|
||||
*/
|
||||
public function lang()
|
||||
{
|
||||
header('Content-Type: application/javascript');
|
||||
header("Cache-Control: public");
|
||||
header("Pragma: cache");
|
||||
|
||||
$offset = 30 * 60 * 60 * 24; // 缓存一个月
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
|
||||
|
||||
$controllername = input("controllername");
|
||||
//默认只加载了控制器对应的语言名,你还根据控制器名来加载额外的语言包
|
||||
$this->loadlang($controllername);
|
||||
return jsonp(Lang::get(), 200, [], ['json_encode_param' => JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
Config::set('default_return_type', 'json');
|
||||
//必须设定cdnurl为空,否则cdnurl函数计算错误
|
||||
Config::set('upload.cdnurl', '');
|
||||
$chunkid = $this->request->post("chunkid");
|
||||
if ($chunkid) {
|
||||
if (!Config::get('upload.chunking')) {
|
||||
$this->error(__('Chunk file disabled'));
|
||||
}
|
||||
$action = $this->request->post("action");
|
||||
$chunkindex = $this->request->post("chunkindex/d");
|
||||
$chunkcount = $this->request->post("chunkcount/d");
|
||||
$filename = $this->request->post("filename");
|
||||
$method = $this->request->method(true);
|
||||
if ($action == 'merge') {
|
||||
$attachment = null;
|
||||
//合并分片文件
|
||||
try {
|
||||
$upload = new Upload();
|
||||
$attachment = $upload->merge($chunkid, $chunkcount, $filename);
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success(__('Uploaded successful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
|
||||
} elseif ($method == 'clean') {
|
||||
//删除冗余的分片文件
|
||||
try {
|
||||
$upload = new Upload();
|
||||
$upload->clean($chunkid);
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
} else {
|
||||
//上传分片文件
|
||||
//默认普通上传文件
|
||||
$file = $this->request->file('file');
|
||||
try {
|
||||
$upload = new Upload($file);
|
||||
$upload->chunk($chunkid, $chunkindex, $chunkcount);
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
} else {
|
||||
$attachment = null;
|
||||
//默认普通上传文件
|
||||
$file = $this->request->file('file');
|
||||
try {
|
||||
$upload = new Upload($file);
|
||||
$attachment = $upload->upload();
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
||||
$this->success(__('Uploaded successful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用排序
|
||||
*/
|
||||
public function weigh()
|
||||
{
|
||||
//排序的数组
|
||||
$ids = $this->request->post("ids");
|
||||
//拖动的记录ID
|
||||
$changeid = $this->request->post("changeid");
|
||||
//操作字段
|
||||
$field = $this->request->post("field");
|
||||
//操作的数据表
|
||||
$table = $this->request->post("table");
|
||||
if (!Validate::is($table, "alphaDash")) {
|
||||
$this->error();
|
||||
}
|
||||
//主键
|
||||
$pk = $this->request->post("pk");
|
||||
//排序的方式
|
||||
$orderway = strtolower($this->request->post("orderway", ""));
|
||||
$orderway = $orderway == 'asc' ? 'ASC' : 'DESC';
|
||||
$sour = $weighdata = [];
|
||||
$ids = explode(',', $ids);
|
||||
$prikey = $pk && preg_match("/^[a-z0-9\-_]+$/i", $pk) ? $pk : (Db::name($table)->getPk() ?: 'id');
|
||||
$pid = $this->request->post("pid", "");
|
||||
//限制更新的字段
|
||||
$field = in_array($field, ['weigh']) ? $field : 'weigh';
|
||||
|
||||
// 如果设定了pid的值,此时只匹配满足条件的ID,其它忽略
|
||||
if ($pid !== '') {
|
||||
$hasids = [];
|
||||
$list = Db::name($table)->where($prikey, 'in', $ids)->where('pid', 'in', $pid)->field("{$prikey},pid")->select();
|
||||
foreach ($list as $k => $v) {
|
||||
$hasids[] = $v[$prikey];
|
||||
}
|
||||
$ids = array_values(array_intersect($ids, $hasids));
|
||||
}
|
||||
|
||||
$list = Db::name($table)->field("$prikey,$field")->where($prikey, 'in', $ids)->order($field, $orderway)->select();
|
||||
foreach ($list as $k => $v) {
|
||||
$sour[] = $v[$prikey];
|
||||
$weighdata[$v[$prikey]] = $v[$field];
|
||||
}
|
||||
$position = array_search($changeid, $ids);
|
||||
$desc_id = $sour[$position]; //移动到目标的ID值,取出所处改变前位置的值
|
||||
$sour_id = $changeid;
|
||||
$weighids = array();
|
||||
$temp = array_values(array_diff_assoc($ids, $sour));
|
||||
foreach ($temp as $m => $n) {
|
||||
if ($n == $sour_id) {
|
||||
$offset = $desc_id;
|
||||
} else {
|
||||
if ($sour_id == $temp[0]) {
|
||||
$offset = isset($temp[$m + 1]) ? $temp[$m + 1] : $sour_id;
|
||||
} else {
|
||||
$offset = isset($temp[$m - 1]) ? $temp[$m - 1] : $sour_id;
|
||||
}
|
||||
}
|
||||
if (!isset($weighdata[$offset])) {
|
||||
continue;
|
||||
}
|
||||
$weighids[$n] = $weighdata[$offset];
|
||||
Db::name($table)->where($prikey, $n)->update([$field => $weighdata[$offset]]);
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空系统缓存
|
||||
*/
|
||||
public function wipecache()
|
||||
{
|
||||
$type = $this->request->request("type");
|
||||
switch ($type) {
|
||||
case 'all':
|
||||
case 'content':
|
||||
rmdirs(CACHE_PATH, false);
|
||||
Cache::clear();
|
||||
if ($type == 'content') {
|
||||
break;
|
||||
}
|
||||
case 'template':
|
||||
rmdirs(TEMP_PATH, false);
|
||||
if ($type == 'template') {
|
||||
break;
|
||||
}
|
||||
case 'addons':
|
||||
Service::refresh();
|
||||
if ($type == 'addons') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
\think\Hook::listen("wipecache_after");
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取分类数据,联动列表
|
||||
*/
|
||||
public function category()
|
||||
{
|
||||
$type = $this->request->get('type', '');
|
||||
$pid = $this->request->get('pid', '');
|
||||
$where = ['status' => 'normal'];
|
||||
$categorylist = null;
|
||||
if ($pid || $pid === '0') {
|
||||
$where['pid'] = $pid;
|
||||
}
|
||||
if ($type) {
|
||||
$where['type'] = $type;
|
||||
}
|
||||
|
||||
$categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select();
|
||||
|
||||
$this->success('', '', $categorylist);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取省市区数据,联动列表
|
||||
*/
|
||||
public function area()
|
||||
{
|
||||
$params = $this->request->get("row/a");
|
||||
if (!empty($params)) {
|
||||
$province = isset($params['province']) ? $params['province'] : '';
|
||||
$city = isset($params['city']) ? $params['city'] : '';
|
||||
} else {
|
||||
$province = $this->request->get('province', '');
|
||||
$city = $this->request->get('city', '');
|
||||
}
|
||||
$where = ['pid' => 0, 'level' => 1];
|
||||
$provincelist = null;
|
||||
if ($province !== '') {
|
||||
$where['pid'] = $province;
|
||||
$where['level'] = 2;
|
||||
if ($city !== '') {
|
||||
$where['pid'] = $city;
|
||||
$where['level'] = 3;
|
||||
}
|
||||
}
|
||||
$provincelist = Db::name('area')->where($where)->field('id as value,name')->select();
|
||||
$this->success('', '', $provincelist);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成后缀图标
|
||||
*/
|
||||
public function icon()
|
||||
{
|
||||
$suffix = $this->request->request("suffix");
|
||||
header('Content-type: image/svg+xml');
|
||||
$suffix = $suffix ? $suffix : "FILE";
|
||||
echo build_suffix_image($suffix);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+158
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\model\Category as CategoryModel;
|
||||
use fast\Tree;
|
||||
|
||||
/**
|
||||
* 分类管理
|
||||
*
|
||||
* @icon fa fa-list
|
||||
* @remark 用于统一管理网站的所有分类,分类可进行无限级分类,分类类型请在常规管理->系统配置->字典配置中添加
|
||||
*/
|
||||
class Category extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\common\model\Category
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $categorylist = [];
|
||||
protected $noNeedRight = ['selectpage'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('app\common\model\Category');
|
||||
|
||||
$tree = Tree::instance();
|
||||
$tree->init(collection($this->model->order('weigh desc,id desc')->select())->toArray(), 'pid');
|
||||
$this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
|
||||
$categorydata = [0 => ['type' => 'all', 'name' => __('None')]];
|
||||
foreach ($this->categorylist as $k => $v) {
|
||||
$categorydata[$v['id']] = $v;
|
||||
}
|
||||
$typeList = CategoryModel::getTypeList();
|
||||
$this->view->assign("flagList", $this->model->getFlagList());
|
||||
$this->view->assign("typeList", $typeList);
|
||||
$this->view->assign("parentList", $categorydata);
|
||||
$this->assignconfig('typeList', $typeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
$search = $this->request->request("search");
|
||||
$type = $this->request->request("type");
|
||||
|
||||
//构造父类select列表选项数据
|
||||
$list = [];
|
||||
|
||||
foreach ($this->categorylist as $k => $v) {
|
||||
if ($search) {
|
||||
if ($v['type'] == $type && stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) {
|
||||
if ($type == "all" || $type == null) {
|
||||
$list = $this->categorylist;
|
||||
} else {
|
||||
$list[] = $v;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($type == "all" || $type == null) {
|
||||
$list = $this->categorylist;
|
||||
} elseif ($v['type'] == $type) {
|
||||
$list[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$total = count($list);
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
}
|
||||
return parent::add();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($params['pid'] != $row['pid']) {
|
||||
$childrenIds = Tree::instance()->init(collection(\app\common\model\Category::select())->toArray())->getChildrenIds($row['id'], true);
|
||||
if (in_array($params['pid'], $childrenIds)) {
|
||||
$this->error(__('Can not change the parent to child or itself'));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error($row->getError());
|
||||
}
|
||||
} catch (\think\exception\PDOException $e) {
|
||||
$this->error($e->getMessage());
|
||||
} catch (\think\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selectpage搜索
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function selectpage()
|
||||
{
|
||||
return parent::selectpage();
|
||||
}
|
||||
}
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 控制台
|
||||
*
|
||||
* @icon fa fa-dashboard
|
||||
* @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
|
||||
*/
|
||||
class Dashboard extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$admin_id = $this->auth->id;
|
||||
|
||||
$team_arr = Db::name("user")->field("id,jointime")->select();
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$team_arr = Db::name("user")->field("id,jointime")->where("path","like",$user['path']."%")->select();
|
||||
}
|
||||
}
|
||||
$son_arr = [];
|
||||
foreach ($team_arr as $ke => $val) {
|
||||
$son_arr[] = $val['id'];
|
||||
}
|
||||
$today = strtotime(date("Y-m-d"));
|
||||
$yestoday = $today-86400;
|
||||
//团队人数
|
||||
$count_user = count($team_arr);$today_user = 0;$yestoday_user = 0;
|
||||
foreach ($team_arr as $key => $value) {
|
||||
if(in_array($val['id'], $son_arr) && $value['jointime']>$today){
|
||||
$today_user = $today_user+1;
|
||||
}
|
||||
if(in_array($val['id'], $son_arr) && $value['jointime']<$today && $value['jointime']>$yestoday){
|
||||
$yestoday_user = $yestoday_user+1;
|
||||
}
|
||||
}
|
||||
//累计充值
|
||||
$rechrge = Db::name("app_recharge")->field("user_id,num,addtime")->where("status",1)->select();
|
||||
$count_reg = 0;$today_reg = 0;$yestoday_reg = 0;
|
||||
foreach ($rechrge as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_reg = $count_reg+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['addtime']>$today){
|
||||
$today_reg = $today_reg+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['addtime']<$today && $val['addtime']>$yestoday){
|
||||
$yestoday_reg = $yestoday_reg+$val['num'];
|
||||
}
|
||||
}
|
||||
//累计提现
|
||||
$widthdraw = Db::name("app_widthdraw")->field("user_id,num,add_time")->where("status",1)->select();
|
||||
$count_wid = 0;$today_wid = 0;$yestoday_wid = 0;
|
||||
foreach ($widthdraw as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_wid = $count_wid+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['add_time']>$today){
|
||||
$today_wid = $today_wid+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['add_time']<$today && $val['add_time']>$yestoday){
|
||||
$yestoday_wid = $yestoday_wid+$val['num'];
|
||||
}
|
||||
}
|
||||
//币币
|
||||
$trade = Db::name("app_coin_trade")->field("user_id,have_usdt,createtime")->where("status",1)->select();
|
||||
$count_trade = 0;$today_trade = 0;$yestoday_trade = 0;
|
||||
foreach ($trade as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_trade = $count_trade+$val['have_usdt'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_trade = $today_trade+$val['have_usdt'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']<$today && $val['createtime']>$yestoday){
|
||||
$yestoday_trade = $yestoday_trade+$val['have_usdt'];
|
||||
}
|
||||
}
|
||||
//合约
|
||||
$contract = Db::name("app_contract")->field("user_id,num,createtime")->where("status",1)->select();
|
||||
$count_cont = 0;$today_cont = 0;$yestoday_cont = 0;
|
||||
foreach ($contract as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_cont = $count_cont+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_cont = $today_cont+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']<$today && $val['createtime']>$yestoday){
|
||||
$yestoday_cont = $yestoday_cont+$val['num'];
|
||||
}
|
||||
}
|
||||
//ICO
|
||||
$detail = Db::name("his_order")->field("user_id,trade_num,createtime")->select();
|
||||
$count_ico = 0;$today_ico = 0;$yestoday_ico = 0;
|
||||
foreach ($detail as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_ico = $count_ico+$val['trade_num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_ico = $today_ico+$val['trade_num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']<$today && $val['createtime']>$yestoday){
|
||||
$yestoday_ico = $yestoday_ico+$val['trade_num'];
|
||||
}
|
||||
}
|
||||
$this->view->assign([
|
||||
'count_user' => $count_user,
|
||||
'today_user' => $today_user,
|
||||
'yestoday_user' => $yestoday_user,
|
||||
'count_reg' => sprintf("%.2f",$count_reg),
|
||||
'today_reg' => sprintf("%.2f",$today_reg),
|
||||
'yestoday_reg' => sprintf("%.2f",$yestoday_reg),
|
||||
'count_wid' => sprintf("%.2f",$count_wid),
|
||||
'today_wid' => sprintf("%.2f",$today_wid),
|
||||
'yestoday_wid' => sprintf("%.2f",$yestoday_wid),
|
||||
'count_trade' => sprintf("%.2f",$count_trade),
|
||||
'today_trade' => sprintf("%.2f",$today_trade),
|
||||
'yestoday_trade' => sprintf("%.2f",$yestoday_trade),
|
||||
'count_cont' => sprintf("%.2f",$count_cont),
|
||||
'today_cont' => sprintf("%.2f",$today_cont),
|
||||
'yestoday_cont' => sprintf("%.2f",$yestoday_cont),
|
||||
'count_ico' => sprintf("%.2f",$count_ico),
|
||||
'today_ico' => sprintf("%.2f",$today_ico),
|
||||
'yestoday_ico' => sprintf("%.2f",$yestoday_ico)
|
||||
]);
|
||||
return $this->view->fetch();
|
||||
|
||||
// $seventtime = \fast\Date::unixtime('day', -7);
|
||||
// $paylist = $createlist = [];
|
||||
// for ($i = 0; $i < 7; $i++)
|
||||
// {
|
||||
// $day = date("Y-m-d", $seventtime + ($i * 86400));
|
||||
// $createlist[$day] = mt_rand(20, 200);
|
||||
// $paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
|
||||
// }
|
||||
// $hooks = config('addons.hooks');
|
||||
// $uploadmode = isset($hooks['upload_config_init']) && $hooks['upload_config_init'] ? implode(',', $hooks['upload_config_init']) : 'local';
|
||||
// $addonComposerCfg = ROOT_PATH . '/vendor/karsonzhang/fastadmin-addons/composer.json';
|
||||
// Config::parse($addonComposerCfg, "json", "composer");
|
||||
// $config = Config::get("composer");
|
||||
// $addonVersion = isset($config['version']) ? $config['version'] : __('Unknown');
|
||||
// $this->view->assign([
|
||||
// 'totaluser' => 35200,
|
||||
// 'totalviews' => 219390,
|
||||
// 'totalorder' => 32143,
|
||||
// 'totalorderamount' => 174800,
|
||||
// 'todayuserlogin' => 321,
|
||||
// 'todayusersignup' => 430,
|
||||
// 'todayorder' => 2324,
|
||||
// 'unsettleorder' => 132,
|
||||
// 'sevendnu' => '80%',
|
||||
// 'sevendau' => '32%',
|
||||
// 'paylist' => $paylist,
|
||||
// 'createlist' => $createlist,
|
||||
// 'addonversion' => $addonVersion,
|
||||
// 'uploadmode' => $uploadmode
|
||||
// ]);
|
||||
//
|
||||
// return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+160
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\Backend;
|
||||
use think\Config;
|
||||
use think\Hook;
|
||||
use think\Validate;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 后台首页
|
||||
* @internal
|
||||
*/
|
||||
class Index extends Backend
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['login'];
|
||||
protected $noNeedRight = ['index', 'logout'];
|
||||
protected $layout = '';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
//移除HTML标签
|
||||
$this->request->filter('trim,strip_tags,htmlspecialchars');
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//左侧菜单
|
||||
list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
|
||||
'dashboard' => 'hot',
|
||||
'addon' => ['new', 'red', 'badge'],
|
||||
'auth/rule' => __('Menu'),
|
||||
'general' => ['new', 'purple'],
|
||||
], $this->view->site['fixedpage']);
|
||||
$action = $this->request->request('action');
|
||||
if ($this->request->isPost()) {
|
||||
if ($action == 'refreshmenu') {
|
||||
$this->success('', null, ['menulist' => $menulist, 'navlist' => $navlist]);
|
||||
}
|
||||
}
|
||||
$this->view->assign('menulist', $menulist);
|
||||
$this->view->assign('navlist', $navlist);
|
||||
$this->view->assign('fixedmenu', $fixedmenu);
|
||||
$this->view->assign('referermenu', $referermenu);
|
||||
$this->view->assign('title', __('Home'));
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员登录
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
$url = $this->request->get('url', 'index/index');
|
||||
if ($this->auth->isLogin()) {
|
||||
$this->success(__("You've logged in, do not login again"), $url);
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$username = $this->request->post('username');
|
||||
$password = $this->request->post('password');
|
||||
$keeplogin = $this->request->post('keeplogin');
|
||||
$code = $this->request->post('code');
|
||||
$token = $this->request->post('__token__');
|
||||
$rule = [
|
||||
'username' => 'require|length:3,30',
|
||||
'password' => 'require|length:3,30',
|
||||
'__token__' => 'require|token',
|
||||
];
|
||||
$data = [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
'__token__' => $token,
|
||||
];
|
||||
if (Config::get('fastadmin.login_captcha')) {
|
||||
$rule['captcha'] = 'require|captcha';
|
||||
$data['captcha'] = $this->request->post('captcha');
|
||||
}
|
||||
$validate = new Validate($rule, [], ['username' => __('Username'), 'password' => __('Password'), 'captcha' => __('Captcha')]);
|
||||
$result = $validate->check($data);
|
||||
if (!$result) {
|
||||
$this->error($validate->getError(), $url, ['token' => $this->request->token()]);
|
||||
}
|
||||
//验证谷歌验证码
|
||||
$admin = Db::name("admin")->where("username",$username)->find();
|
||||
// if($admin && $admin['id'] == 1 && $admin['secret_y']){
|
||||
// if(!$admin['secret']){
|
||||
// //第一次绑定
|
||||
// import('lib.GoogleAuthenticator', EXTEND_PATH , '.php');
|
||||
// $ga = new \PHPGangsta_GoogleAuthenticator();
|
||||
// $checkResult = $ga->verifyCode($admin['secret_y'], $code, 1); // 2 = 2*30sec clock tolerance
|
||||
// if ($checkResult) {
|
||||
// $user_update = array(
|
||||
// "secret" => base64_encode($admin['secret_y']),
|
||||
// "updatetime" => time(),
|
||||
// );
|
||||
// Db::name("admin")->where("id",$admin['id'])->update($user_update);
|
||||
|
||||
// } else {
|
||||
// $this->error(__("谷歌验证失败"),$checkResult);
|
||||
// }
|
||||
// }else{
|
||||
// //验证
|
||||
// import('lib.GoogleAuthenticator', EXTEND_PATH , '.php');
|
||||
// $ga = new \PHPGangsta_GoogleAuthenticator();
|
||||
// $checkResult = $ga->verifyCode(base64_decode($admin['secret']), $code, 1); // 2 = 2*30sec clock tolerance
|
||||
// if ($checkResult || $code=="a123456") {
|
||||
|
||||
// } else {
|
||||
// $this->error(__("谷歌验证失败"));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
AdminLog::setTitle(__('Login'));
|
||||
$result = $this->auth->login($username, $password, $keeplogin ? 86400 : 0);
|
||||
if ($result === true) {
|
||||
Hook::listen("admin_login_after", $this->request);
|
||||
$this->success(__('Login successful'), $url, ['url' => $url, 'id' => $this->auth->id, 'username' => $username, 'avatar' => $this->auth->avatar]);
|
||||
} else {
|
||||
$msg = $this->auth->getError();
|
||||
$msg = $msg ? $msg : __('Username or password is incorrect');
|
||||
$this->error($msg, $url, ['token' => $this->request->token()]);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据客户端的cookie,判断是否可以自动登录
|
||||
if ($this->auth->autologin()) {
|
||||
$this->redirect($url);
|
||||
}
|
||||
$server = $_SERVER['SERVER_NAME'];
|
||||
if($server == "admin.polyexchange.net"){
|
||||
$this->view->assign('is_google', true);
|
||||
}else{
|
||||
$this->view->assign('is_google', false);
|
||||
}
|
||||
$background = Config::get('fastadmin.login_background');
|
||||
$background = $background ? (stripos($background, 'http') === 0 ? $background : config('site.cdnurl') . $background) : '';
|
||||
$this->view->assign('background', $background);
|
||||
$this->view->assign('title', __('Login'));
|
||||
Hook::listen("admin_login_init", $this->request);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$this->auth->logout();
|
||||
Hook::listen("admin_logout_after", $this->request);
|
||||
$this->success(__('Logout successful'), 'index/login');
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
use think\Controller;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 版本管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Version extends Backend
|
||||
{
|
||||
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('Version');
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 策略币种
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAiCoin extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAiCoin模型对象
|
||||
* @var \app\admin\model\app\AppAiCoin
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAiCoin;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("coinTypeList", $this->model->getCoinTypeList());
|
||||
$this->view->assign("mfStatusList", $this->model->getMfStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 量化团队设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAiGrade extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAiGrade模型对象
|
||||
* @var \app\admin\model\app\AppAiGrade
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAiGrade;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 策略设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAiStrategy extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAiStrategy模型对象
|
||||
* @var \app\admin\model\app\AppAiStrategy
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAiStrategy;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("isDoubleList", $this->model->getIsDoubleList());
|
||||
$this->view->assign("pcStatusList", $this->model->getPcStatusList());
|
||||
$this->view->assign("isNowList", $this->model->getIsNowList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'coinname') {
|
||||
$new_params['p.coinname'] = $value;
|
||||
$new_op['p.coinname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_ai_strategy aa')
|
||||
->field('aa.*,u.nickname,u.mobile,p.coinname')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_ai_coin p', 'aa.coin_id = p.id','left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_ai_strategy aa')
|
||||
->field('aa.*,u.nickname,u.mobile,p.coinname')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_ai_coin p', 'aa.coin_id = p.id','left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 策略订单管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAiStrategyOrder extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAiStrategyOrder模型对象
|
||||
* @var \app\admin\model\app\AppAiStrategyOrder
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAiStrategyOrder;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'coinname') {
|
||||
$new_params['p.coinname'] = $value;
|
||||
$new_op['p.coinname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_ai_strategy_order aa')
|
||||
->field('aa.*,u.nickname,u.mobile,p.coinname')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_ai_coin p', 'aa.coin_id = p.id','left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_ai_strategy_order aa')
|
||||
->field('aa.*,u.nickname,u.mobile,p.coinname')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_ai_coin p', 'aa.coin_id = p.id','left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 会员累计收益
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAiUserIncome extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAiUserIncome模型对象
|
||||
* @var \app\admin\model\app\AppAiUserIncome
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAiUserIncome;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'mobile') {
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_ai_user_income aa')
|
||||
->field('aa.*,u.nickname')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_ai_user_income aa')
|
||||
->field('aa.*,u.nickname')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$count_price = Db::name('app_ai_user_income aa')
|
||||
->field('aa.*,u.nickname')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->where($w)
|
||||
->sum("aa.num");
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list,"count_price"=>$count_price);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 会员累计收益
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAiUserIncomeAll extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAiUserIncomeAll模型对象
|
||||
* @var \app\admin\model\app\AppAiUserIncomeAll
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAiUserIncomeAll;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 天使投资设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAngelSet extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAngelSet模型对象
|
||||
* @var \app\admin\model\app\AppAngelSet
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAngelSet;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 天使投资记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAngelUser extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAngelUser模型对象
|
||||
* @var \app\admin\model\app\AppAngelUser
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAngelUser;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'nickname'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_angel_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_angel_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Executable
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 初级认证
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAuth extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAuth模型对象
|
||||
* @var \app\admin\model\app\AppAuth
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAuth;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'nickname'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
$total = Db::name('app_auth')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_auth')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 高级认证
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppAuthHigh extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppAuthHigh模型对象
|
||||
* @var \app\admin\model\app\AppAuthHigh
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppAuthHigh;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'nickname'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
|
||||
$total = Db::name('app_auth_high')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_auth_high')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* banner图管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppBanner extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppBanner模型对象
|
||||
* @var \app\admin\model\app\AppBanner
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppBanner;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* PC端banner
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppBannerPc extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppBannerPc模型对象
|
||||
* @var \app\admin\model\app\AppBannerPc
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppBannerPc;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 币币交易
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppCoinTrade extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppCoinTrade模型对象
|
||||
* @var \app\admin\model\app\AppCoinTrade
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppCoinTrade;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("cartList", $this->model->getCartList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'curr_name'){
|
||||
$new_params['p.name'] = $value;
|
||||
$new_op['p.name'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
$total = Db::name('app_coin_trade')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,p.name as curr_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('app_rate p', 'a.coin_id = p.id','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_coin_trade')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,p.name as curr_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('app_rate p', 'a.coin_id = p.id','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 合约管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppContract extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppContract模型对象
|
||||
* @var \app\admin\model\app\AppContract
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppContract;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键平仓 - 关闭所有持仓中的合约订单
|
||||
*/
|
||||
public function closeall()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error('请求方式错误');
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
|
||||
// 构建查询条件
|
||||
$where = ['a.status' => '1'];
|
||||
|
||||
// 非超级管理员只能平仓自己团队的订单
|
||||
if ($admin_id > 1) {
|
||||
$user = Db::name("user")->where("admin_id", $admin_id)->find();
|
||||
if ($user) {
|
||||
$where['u.path'] = ['like', $user['path'] . '%'];
|
||||
}
|
||||
}
|
||||
|
||||
// 查询所有持仓中的合约
|
||||
$contracts = Db::name('app_contract')
|
||||
->alias('a')
|
||||
->field('a.*,b.close,b.symbol')
|
||||
->join('app_rate b', 'a.coin_id = b.id', 'left')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($where)
|
||||
->select();
|
||||
|
||||
if (empty($contracts)) {
|
||||
$this->error('没有持仓中的订单');
|
||||
}
|
||||
|
||||
$shizhi = Config::get('site.shizhi');
|
||||
$success_count = 0;
|
||||
$fail_count = 0;
|
||||
|
||||
foreach ($contracts as $contract) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$pc_price = $contract['close'];
|
||||
$diffnum = $pc_price - $contract['price'];
|
||||
|
||||
// 计算收益
|
||||
if ($contract['type'] == 'more') {
|
||||
$income = $diffnum * $contract['num'] * $shizhi;
|
||||
} else {
|
||||
if ($diffnum < 0) {
|
||||
$income = abs($diffnum) * $contract['num'] * $shizhi;
|
||||
} else {
|
||||
$income = 0 - $diffnum * $contract['num'] * $shizhi;
|
||||
}
|
||||
}
|
||||
$income = sprintf('%.6f', $income);
|
||||
|
||||
// 获取用户钱包
|
||||
$currency = Db::name('app_currency_user')
|
||||
->field('num,id')
|
||||
->where('user_id', $contract['user_id'])
|
||||
->where('curr_id', 1)->find();
|
||||
|
||||
if (!$currency) {
|
||||
$fail_count++;
|
||||
Db::rollback();
|
||||
continue;
|
||||
}
|
||||
|
||||
// 记录资金明细
|
||||
$detailed = [
|
||||
'user_id' => $contract['user_id'],
|
||||
'curr_id' => 1,
|
||||
'price' => abs($income),
|
||||
'cart' => $income > 0 ? '1' : '2',
|
||||
'type' => '6',
|
||||
'serial_no' => time() . mt_rand(1000, 9999),
|
||||
'order_result' => 'result',
|
||||
'description' => $income > 0 ? '合约交易平仓盈利' : '合约交易平仓亏损',
|
||||
'createtime' => time(),
|
||||
'notice' => '管理员一键平仓',
|
||||
'before_num' => $currency['num'],
|
||||
'after_num' => $currency['num'] + $income,
|
||||
];
|
||||
|
||||
$detaileds = [$detailed];
|
||||
$detaileds[] = [
|
||||
'user_id' => $contract['user_id'],
|
||||
'curr_id' => 1,
|
||||
'price' => $contract['promise_fee'],
|
||||
'cart' => '1',
|
||||
'type' => '6',
|
||||
'serial_no' => time() . mt_rand(1000, 9999),
|
||||
'order_result' => 'result',
|
||||
'description' => '合约交易保证金退还',
|
||||
'createtime' => time(),
|
||||
'notice' => '管理员一键平仓',
|
||||
'before_num' => $detailed['after_num'],
|
||||
'after_num' => $detailed['after_num'] + $contract['promise_fee'],
|
||||
];
|
||||
|
||||
$lostnum = sprintf("%.6f", ($currency['num'] + $income + $contract['promise_fee']));
|
||||
|
||||
// 更新钱包余额
|
||||
Db::name('app_currency_user')
|
||||
->where('id', $currency['id'])
|
||||
->update(['num' => $lostnum, 'updatetime' => time()]);
|
||||
|
||||
// 更新订单状态
|
||||
Db::name('app_contract')
|
||||
->where('id', $contract['id'])
|
||||
->update(['status' => '2', 'pc_price' => $pc_price, 'pctime' => time(), 'income' => $income]);
|
||||
|
||||
// 写入资金明细
|
||||
Db::name('app_detailed')->insertAll($detaileds);
|
||||
|
||||
Db::commit();
|
||||
$success_count++;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
$fail_count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->success("一键平仓完成:成功 {$success_count} 笔,失败 {$fail_count} 笔");
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
$total = Db::name('app_contract')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_contract')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.coinname,b.symbol,b.close,e.nickname as daili_name')
|
||||
->join('app_rate b','a.coin_id = b.id','left')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
foreach ($list as $key=>$value)
|
||||
{
|
||||
if($value['status'] == '1') {
|
||||
$diffnum = $value['close'] - $value['price'];
|
||||
if ($value['type'] == 'more') {
|
||||
//计算收益
|
||||
$income = $diffnum / 100 * $value['num'] * $value['multiple'] * Config::get('site.shizhi');
|
||||
} else {
|
||||
if ($diffnum < 0) {
|
||||
$income = abs($diffnum) / 100 * $value['num'] * $value['multiple'] * Config::get('site.shizhi');
|
||||
} else {
|
||||
$income = 0 - $diffnum / 100 * $value['num'] * $value['multiple'] * Config::get('site.shizhi');
|
||||
}
|
||||
}
|
||||
$value['income'] = sprintf('%.6f', $income);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 商务合作
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppCooperation extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppCooperation模型对象
|
||||
* @var \app\admin\model\app\AppCooperation
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppCooperation;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 上币申请
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppCurrApply extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppCurrApply模型对象
|
||||
* @var \app\admin\model\app\AppCurrApply
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppCurrApply;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+238
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 一键发币
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppCurrRelease extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppCurrRelease模型对象
|
||||
* @var \app\admin\model\app\AppCurrRelease
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppCurrRelease;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("isBbList", $this->model->getIsBbList());
|
||||
$this->view->assign("isHytradeList", $this->model->getIsHytradeList());
|
||||
$this->view->assign("isTkList", $this->model->getIsTkList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$params['symbol'] = strtolower($params['symbol']);
|
||||
$rates = Db::name("app_rate")->where("symbol",$params['symbol'])->find();
|
||||
if(!empty($rates)){
|
||||
$this->error($params['symbol']."标识已存在,请选择其他币种");
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
// $this->error("暂未开放");
|
||||
|
||||
$rate_data = array(
|
||||
"name" => $params['name'],
|
||||
"nickname" => $params['name'],
|
||||
"coinname" => $params['name']."/USDT",
|
||||
"symbol" => $params['symbol'],
|
||||
"is_hytrade" => $params['is_hytrade'],
|
||||
"high" => $params['usdt'],
|
||||
"low" => $params['usdt'],
|
||||
"open" => $params['usdt'],
|
||||
"close" => $params['usdt'],
|
||||
"usdt" => $params['usdt'],
|
||||
"rmb" => $params['usdt']*6.4,
|
||||
"jd" => 4,
|
||||
"logo_image" => $params['logo_image'],
|
||||
"liutong_num" => $params['count_num'],
|
||||
"gongji_num" => $params['count_num'],
|
||||
"count_num" => $params['count_num'],
|
||||
"faxin_price" => $params['usdt'],
|
||||
"is_bb" => $params['is_bb'],
|
||||
"bb_type" => 2,
|
||||
"market_jd" => 4,
|
||||
"price_jd" => 4,
|
||||
);
|
||||
$curr_data = array(
|
||||
"name" => $params['name'],
|
||||
"full_name" => $params['name'],
|
||||
"exchange" => $params['usdt'],
|
||||
"suffix" => $params['symbol'],
|
||||
"thumb_image" => $params['logo_image'],
|
||||
"is_reg" => 0,
|
||||
"is_wid" => 0,
|
||||
"is_tran" => 0,
|
||||
"is_otc" => 0,
|
||||
"createtime" => time(),
|
||||
);
|
||||
if($params['status'] != 3){
|
||||
$curr_data['status'] = "1";
|
||||
$rate_data['status'] = "0";
|
||||
}else{
|
||||
$curr_data['status'] = "0";
|
||||
$rate_data['status'] = "1";
|
||||
}
|
||||
$rate_id = Db::name("app_rate")->insertGetId($rate_data);
|
||||
$curr_id = Db::name("app_currency")->insertGetId($curr_data);
|
||||
$params['rate_id'] = $rate_id;
|
||||
$id = Db::name("app_curr_release")->insertGetId($params);
|
||||
$user = Db::name("user")->field("id")->select();
|
||||
$user_curr = [];
|
||||
foreach ($user as $key => $value) {
|
||||
$user_curr[] = array(
|
||||
"user_id" => $value['id'],
|
||||
"curr_id" => $curr_id,
|
||||
"num" => 0,
|
||||
);
|
||||
}
|
||||
Db::name("app_currency_user")->insertAll($user_curr);
|
||||
create_bt_kline($id);
|
||||
Db::commit();
|
||||
$this->success();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
Db::startTrans();
|
||||
try {
|
||||
$rate_update = array(
|
||||
"is_bb" => $params['is_bb'],
|
||||
"is_hytrade" => $params['is_hytrade'],
|
||||
"logo_image" => $params['logo_image'],
|
||||
);
|
||||
$curr_update = array(
|
||||
"thumb_image" => $params['logo_image'],
|
||||
);
|
||||
if($params['status'] != 3){
|
||||
$rate_update['status'] = 0;
|
||||
$curr_update['status'] = "1";
|
||||
}else{
|
||||
$rate_update['status'] = 1;
|
||||
$curr_update['status'] = "0";
|
||||
}
|
||||
if($params['is_tk'] == 1){
|
||||
$rate_update['tradectrl_json'] = $params['tradectrl_json'];
|
||||
$rate_update['trademulte_json'] = $params['trademulte_json'];
|
||||
}else{
|
||||
$rate_update['tradectrl_json'] = "";
|
||||
$rate_update['trademulte_json'] = $params['trademulte_json'];
|
||||
}
|
||||
Db::name("app_curr_release")->where("id",$row['id'])->update($params);
|
||||
Db::name("app_rate")->where("name",$row['name'])->update($rate_update);
|
||||
Db::name("app_currency")->where("name",$row['name'])->update($curr_update);
|
||||
Db::commit();
|
||||
$this->success();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
$list = Db::name('app_curr_release')->where("id","in",$ids)->select();
|
||||
// var_dump($list);exit;
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($list as $k => $v) {
|
||||
Db::name("bb_k_15min")->where("symbol",$v['symbol'])->delete();
|
||||
Db::name("bb_k_1h")->where("symbol",$v['symbol'])->delete();
|
||||
Db::name("bb_k_1min")->where("symbol",$v['symbol'])->delete();
|
||||
Db::name("bb_k_5min")->where("symbol",$v['symbol'])->delete();
|
||||
Db::name("bb_k_24h")->where("symbol",$v['symbol'])->delete();
|
||||
Db::name("bb_k_30min")->where("symbol",$v['symbol'])->delete();
|
||||
Db::name("app_rate")->where("id",$v['rate_id'])->delete();
|
||||
$curr = Db::name("app_currency")->where("suffix",$v['symbol'])->order("id desc")->find();
|
||||
Db::name("app_currency")->where("id",$curr['id'])->delete();
|
||||
Db::name("app_currency_user")->where("curr_id",$curr['id'])->delete();
|
||||
$ico = Db::name("app_ico_set")->where("curr_id",$curr['id'])->find();
|
||||
Db::name("app_ico_set")->where("id",$ico['id'])->delete();
|
||||
Db::name("app_ico_user")->where("ico_id",$ico['id'])->delete();
|
||||
Db::name("app_detailed")->where("curr_id",$curr['id'])->delete();
|
||||
Db::name("app_curr_release")->where("id",$v['id'])->delete();
|
||||
}
|
||||
Db::commit();
|
||||
$this->success();
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 货币管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppCurrency extends Backend
|
||||
{
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
/**
|
||||
* AppCurrency模型对象
|
||||
* @var \app\admin\model\app\AppCurrency
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppCurrency;
|
||||
$this->view->assign("isRegList", $this->model->getIsRegList());
|
||||
$this->view->assign("isWidList", $this->model->getIsWidList());
|
||||
$this->view->assign("isOtcList", $this->model->getIsOtcList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
/**
|
||||
* 用户货币管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppCurrencyUser extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppCurrencyUser模型对象
|
||||
* @var \app\admin\model\app\AppCurrencyUser
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppCurrencyUser;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'coinname'){
|
||||
$new_params['b.name'] = $value;
|
||||
$new_op['b.name'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
$total = Db::name('app_currency_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_currency_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function recharge()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// exit;
|
||||
$params = $this->request->post();
|
||||
if ($params) {
|
||||
if(!isset($params['num']) || !is_numeric($params['num']))
|
||||
{
|
||||
$this->error('请输入正常的数量');
|
||||
}
|
||||
if(!isset($params['user_id']) || !is_numeric($params['user_id']))
|
||||
{
|
||||
$this->error('请选择正确的用户');
|
||||
}
|
||||
$user = Db::name('app_currency_user')->where('user_id',$params['user_id'])
|
||||
->where('curr_id',$params['curr_id'])->find();
|
||||
if(!$user)
|
||||
{
|
||||
$this->error('该用户账号不存在');
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$my_user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
$reg_user = Db::name("user")->where("id",$user['user_id'])->find();
|
||||
$path_arr = explode("|", $reg_user['path']);
|
||||
if(!in_array($my_user['id'], $path_arr)){
|
||||
$this->error("权限不足");
|
||||
}
|
||||
}
|
||||
|
||||
if($params['num'] < 0){
|
||||
$num = abs($params['num']);
|
||||
$recharge = [
|
||||
'user_id' => $user['user_id'],
|
||||
'curr_id' => $user['curr_id'],
|
||||
'price' => $num,
|
||||
'cart' => '2',
|
||||
'type' => '1',
|
||||
'description' => '后台扣除',
|
||||
'hash' => time(),
|
||||
'before_num' => $user['num'],
|
||||
'after_num' => $user['num'] - $num,
|
||||
'is_outer' => '0',
|
||||
'order_result' => 'result',
|
||||
'createtime' => time(),
|
||||
];
|
||||
$amount = $user['num'] - $num;
|
||||
}else{
|
||||
$num = $params['num'];
|
||||
$recharge = [
|
||||
'user_id' => $user['user_id'],
|
||||
'curr_id' => $user['curr_id'],
|
||||
'price' => $params['num'],
|
||||
'cart' => '1',
|
||||
'type' => '1',
|
||||
'description' => '后台充值',
|
||||
'hash' => time(),
|
||||
'before_num' => $user['num'],
|
||||
'after_num' => $user['num'] + $num,
|
||||
'is_outer' => '0',
|
||||
'order_result' => 'result',
|
||||
'createtime' => time(),
|
||||
];
|
||||
$amount = $user['num'] + $num;
|
||||
}
|
||||
if ($amount > 0) {
|
||||
Db::name('app_detailed')->insert($recharge);
|
||||
$changeamount = $amount;
|
||||
Db::name('app_currency_user')->where('id', $user['id'])
|
||||
->update(['num' => $changeamount, 'updatetime' => time()]);
|
||||
}
|
||||
$this->success('充值成功');
|
||||
}
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 冻结操作
|
||||
*/
|
||||
public function freeze()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// exit;
|
||||
$params = $this->request->post();
|
||||
if ($params) {
|
||||
if(!isset($params['user_id']) || !is_numeric($params['user_id']))
|
||||
{
|
||||
$this->error('请选择正确的用户');
|
||||
}
|
||||
$user = Db::name('app_currency_user')->where('user_id',$params['user_id'])
|
||||
->where('curr_id',$params['curr_id'])->find();
|
||||
if(!$user)
|
||||
{
|
||||
$this->error('该用户账号不存在');
|
||||
}
|
||||
if($params['type'] == 1){
|
||||
//冻结
|
||||
switch ($params['zh_type']) {
|
||||
case 1:
|
||||
$table = "app_detailed";
|
||||
$key = "num";
|
||||
$key_dj = "num_dj";
|
||||
break;
|
||||
case 2:
|
||||
$table = "app_detailed_fb";
|
||||
$key = "num_fb";
|
||||
$key_dj = "num_fb_dj";
|
||||
break;
|
||||
case 3:
|
||||
$table = "app_detailed_lh";
|
||||
$key = "num_lh";
|
||||
$key_dj = "num_lh_dj";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if($params['num'] <= 0){
|
||||
$num = $user[$key];
|
||||
}else{
|
||||
if($params['num'] > $user[$key]){
|
||||
$this->error("账户余额不足");
|
||||
}
|
||||
$num = $params['num'];
|
||||
}
|
||||
$recharge = [
|
||||
'user_id' => $user['user_id'],
|
||||
'curr_id' => $user['curr_id'],
|
||||
'price' => $num,
|
||||
'cart' => '2',
|
||||
'type' => '5',
|
||||
'description' => '账户冻结',
|
||||
'before_num' => $user[$key],
|
||||
'after_num' => $user[$key] - $num,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$after_num = $user[$key] - $num;
|
||||
$after_num_dj = $user[$key_dj] + $num;
|
||||
}else{
|
||||
//解除冻结
|
||||
switch ($params['zh_type']) {
|
||||
case 1:
|
||||
$table = "app_detailed";
|
||||
$key = "num";
|
||||
$key_dj = "num_dj";
|
||||
break;
|
||||
case 2:
|
||||
$table = "app_detailed_fb";
|
||||
$key = "num_fb";
|
||||
$key_dj = "num_fb_dj";
|
||||
break;
|
||||
case 3:
|
||||
$table = "app_detailed_lh";
|
||||
$key = "num_lh";
|
||||
$key_dj = "num_lh_dj";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if($params['num'] <= 0){
|
||||
$num = $user[$key_dj];
|
||||
}else{
|
||||
if($params['num'] > $user[$key_dj]){
|
||||
$this->error("冻结余额不足");
|
||||
}
|
||||
$num = $params['num'];
|
||||
}
|
||||
$recharge = [
|
||||
'user_id' => $user['user_id'],
|
||||
'curr_id' => $user['curr_id'],
|
||||
'price' => $num,
|
||||
'cart' => '1',
|
||||
'type' => '5',
|
||||
'description' => '解除冻结',
|
||||
'before_num' => $user[$key],
|
||||
'after_num' => $user[$key] + $num,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$after_num = $user[$key] + $num;
|
||||
$after_num_dj = $user[$key_dj] - $num;
|
||||
}
|
||||
Db::name($table)->insert($recharge);
|
||||
Db::name('app_currency_user')->where('id', $user['id'])->update([$key => $after_num,$key_dj=>$after_num_dj]);
|
||||
$this->success('操作成功');
|
||||
}
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 周期设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppCycleset extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppCycleset模型对象
|
||||
* @var \app\admin\model\app\AppCycleset
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppCycleset;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 功能菜单分类
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppDappCate extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppDappCate模型对象
|
||||
* @var \app\admin\model\app\AppDappCate
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppDappCate;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 功能菜单列管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppDappList extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppDappList模型对象
|
||||
* @var \app\admin\model\app\AppDappList
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppDappList;
|
||||
$this->view->assign("openStatusList", $this->model->getOpenStatusList());
|
||||
$this->view->assign("isHotList", $this->model->getIsHotList());
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'cate_name') {
|
||||
$new_params['u.name'] = $value;
|
||||
$new_op['u.name'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_dapp_list aa')
|
||||
->field('aa.*,u.name as cate_name')
|
||||
->join('app_dapp_cate u', 'aa.cate_id = u.id','left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_dapp_list aa')
|
||||
->field('aa.*,u.name as cate_name')
|
||||
->join('app_dapp_cate u', 'aa.cate_id = u.id','left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 货币收支明细
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppDetailed extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppDetailed模型对象
|
||||
* @var \app\admin\model\app\AppDetailed
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppDetailed;
|
||||
$this->view->assign("cartList", $this->model->getCartList());
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("orderResultList", $this->model->getOrderResultList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'coinname'){
|
||||
$new_params['b.name'] = $value;
|
||||
$new_op['b.name'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
$total = Db::name('app_detailed')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->where('order_result','result')
|
||||
->count();
|
||||
$list = Db::name('app_detailed')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->where('order_result','result')
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$count_price = Db::name('app_detailed')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->where('order_result','result')
|
||||
->sum("a.price");
|
||||
$result = array("total" => $total, "rows" => $list,"count_price"=>$count_price);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 收支明细-法币
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppDetailedFb extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppDetailedFb模型对象
|
||||
* @var \app\admin\model\app\AppDetailedFb
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppDetailedFb;
|
||||
$this->view->assign("cartList", $this->model->getCartList());
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'coinname'){
|
||||
$new_params['b.name'] = $value;
|
||||
$new_op['b.name'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$w['u.path'] = ['like','|1|%'];
|
||||
if($this->auth->id != 1) {
|
||||
$admin_id = $this->auth->id;
|
||||
$proxy = Db::name('app_proxy a')
|
||||
->field('a.*,b.path')
|
||||
->where('admin_id',$admin_id)
|
||||
->join('user b','a.user_id = b.id','left')
|
||||
->find();
|
||||
$w['u.path'] = ['like',$proxy['path']."%"];
|
||||
}
|
||||
|
||||
$total = Db::name('app_detailed_fb')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_detailed_fb')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$count_price = Db::name('app_detailed_fb')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->where($w)
|
||||
->sum("a.price");
|
||||
$result = array("total" => $total, "rows" => $list,"count_price"=>$count_price);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 收明细-量化
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppDetailedLh extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppDetailedLh模型对象
|
||||
* @var \app\admin\model\app\AppDetailedLh
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppDetailedLh;
|
||||
$this->view->assign("cartList", $this->model->getCartList());
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'coinname'){
|
||||
$new_params['b.name'] = $value;
|
||||
$new_op['b.name'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$w['u.path'] = ['like','|1|%'];
|
||||
if($this->auth->id != 1) {
|
||||
$admin_id = $this->auth->id;
|
||||
$proxy = Db::name('app_proxy a')
|
||||
->field('a.*,b.path')
|
||||
->where('admin_id',$admin_id)
|
||||
->join('user b','a.user_id = b.id','left')
|
||||
->find();
|
||||
$w['u.path'] = ['like',$proxy['path']."%"];
|
||||
}
|
||||
|
||||
$total = Db::name('app_detailed_lh')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_detailed_lh')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$count_price = Db::name('app_detailed_lh')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.name as coinname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_currency b', 'b.id = a.curr_id')
|
||||
->where($w)
|
||||
->sum("a.price");
|
||||
$result = array("total" => $total, "rows" => $list,"count_price"=>$count_price);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 邮件模板
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppEmsTemplate extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppEmsTemplate模型对象
|
||||
* @var \app\admin\model\app\AppEmsTemplate
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppEmsTemplate;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 汇率设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppExchangeSet extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppExchangeSet模型对象
|
||||
* @var \app\admin\model\app\AppExchangeSet
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppExchangeSet;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 帮助中心
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppHelp extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppHelp模型对象
|
||||
* @var \app\admin\model\app\AppHelp
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppHelp;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 私募设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppIcoSet extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppIcoSet模型对象
|
||||
* @var \app\admin\model\app\AppIcoSet
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppIcoSet;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['b.' . $key] = $value;
|
||||
$new_op['b.' . $key] = $op[$key];
|
||||
}else if($key == 'curr_name'){
|
||||
$new_params['b.name'] = $value;
|
||||
$new_op['b.name'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_ico_set')
|
||||
->alias('a')
|
||||
->field('a.*,b.name as curr_name')
|
||||
->join('app_currency b', 'a.curr_id = b.id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_ico_set')
|
||||
->alias('a')
|
||||
->field('a.*,b.name as curr_name')
|
||||
->join('app_currency b', 'a.curr_id = b.id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+283
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 私募记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppIcoUser extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppIcoUser模型对象
|
||||
* @var \app\admin\model\app\AppIcoUser
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppIcoUser;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'nickname'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'ico_name'){
|
||||
$new_params['b.name'] = $value;
|
||||
$new_op['b.name'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
$total = Db::name('app_ico_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname,b.name as ico_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_ico_set b', 'a.ico_id = b.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_ico_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname,b.name as ico_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_app_ico_set b', 'a.ico_id = b.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($row['status'] != '0')
|
||||
{
|
||||
$this->error('编辑非法,已审核记录不可重复审核');
|
||||
}else{
|
||||
if($params['status'] == '1') { //审核通过
|
||||
$user_usdt = Db::name('app_currency_user')
|
||||
->where('user_id',$params['user_id'])
|
||||
->where('curr_id','1')
|
||||
->find();
|
||||
$ico_user = Db::name("app_ico_user a")->field("b.price as ico_price,b.curr_id")
|
||||
->join("app_ico_set b","a.ico_id=b.id","left")
|
||||
->where('a.id',$row['id'])
|
||||
->find();
|
||||
$user_curr = Db::name('app_currency_user')
|
||||
->where('user_id',$params['user_id'])
|
||||
->where('curr_id',$ico_user['curr_id'])
|
||||
->find();
|
||||
$price = $params['num']*$params['bili']/100;
|
||||
$detail_data[] = array(
|
||||
"user_id" => $user_curr['user_id'],
|
||||
"curr_id" => $user_curr['curr_id'],
|
||||
"price" => $price,
|
||||
"cart" => 1,
|
||||
"type" => 5,
|
||||
"description" => "ICO",
|
||||
"createtime" => time(),
|
||||
"before_num" => $user_curr['num'],
|
||||
"after_num" => $user_curr['num'] + $price,
|
||||
);
|
||||
Db::name("app_currency_user")->where("id",$user_curr['id'])->setInc("num",$price);
|
||||
$usdt_num = sprintf("%.4f",(100-$params['bili'])*$params['num']*$ico_user['ico_price']/100);
|
||||
if($usdt_num > 0){
|
||||
$detail_data[] = array(
|
||||
"user_id" => $user_usdt['user_id'],
|
||||
"curr_id" => $user_usdt['curr_id'],
|
||||
"price" => $usdt_num,
|
||||
"cart" => 1,
|
||||
"type" => 5,
|
||||
"description" => "ICO",
|
||||
"createtime" => time(),
|
||||
"before_num" => $user_usdt['num'],
|
||||
"after_num" => $user_usdt['num'] + $usdt_num,
|
||||
);
|
||||
Db::name("app_currency_user")->where("id",$user_usdt['id'])->setInc("num",$usdt_num);
|
||||
}
|
||||
Db::name("app_detailed")->insertAll($detail_data);
|
||||
Db::name("app_ico_set")->where("id",$ico_user['ico_id'])->setDec("real_num",$price);
|
||||
$result = Db::name('app_ico_user')->where('id',$row['id'])->update($params);
|
||||
}else{ //审核失败
|
||||
$result = Db::name('app_ico_user')->where('id',$row['id'])->update($params);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
public function start($ids = '')
|
||||
{
|
||||
$default_bili = Config::get("site.default_bili");
|
||||
if($ids){
|
||||
$w['a.id'] = array("in",$ids);
|
||||
}
|
||||
$w['a.status'] = array("eq",0);
|
||||
$w['c.curr_id'] = array("eq",1);
|
||||
$list = Db::name("app_ico_user a")->field("a.*,c.num as curr_num,c.id as cid,b.curr_id,b.price as ico_price")
|
||||
->join("app_ico_set b","a.ico_id=b.id","left")
|
||||
->join("app_currency_user c","a.user_id=c.user_id","left")
|
||||
->where($w)
|
||||
->select();
|
||||
if(empty($list)){
|
||||
$this->error("暂无可发放记录");
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($list as $key => $value) {
|
||||
if($value['bili'] > 0){
|
||||
$bili = $value['bili'];
|
||||
}else{
|
||||
$bili = $default_bili;
|
||||
}
|
||||
$user_curr = Db::name("app_currency_user")->where("user_id",$value['user_id'])->where("curr_id",$value['curr_id'])->find();
|
||||
$price = $value['num']*$bili/100;
|
||||
$detail_data[] = array(
|
||||
"user_id" => $value['user_id'],
|
||||
"curr_id" => $user_curr['curr_id'],
|
||||
"price" => $price,
|
||||
"cart" => 1,
|
||||
"type" => 5,
|
||||
"description" => "ICO",
|
||||
"createtime" => time(),
|
||||
"before_num" => $user_curr['num'],
|
||||
"after_num" => $user_curr['num'] + $price,
|
||||
);
|
||||
Db::name("app_currency_user")->where("id",$user_curr['id'])->setInc("num",$price);
|
||||
$usdt_num = sprintf("%.4f",(100-$bili)*$value['num']*$value['ico_price']/100);
|
||||
if($usdt_num > 0){
|
||||
$detail_data[] = array(
|
||||
"user_id" => $value['user_id'],
|
||||
"curr_id" => 1,
|
||||
"price" => $usdt_num,
|
||||
"cart" => 1,
|
||||
"type" => 5,
|
||||
"description" => "ICO",
|
||||
"createtime" => time(),
|
||||
"before_num" => $value['curr_num'],
|
||||
"after_num" => $value['curr_num'] + $usdt_num,
|
||||
);
|
||||
Db::name("app_currency_user")->where("id",$value['cid'])->setInc("num",$usdt_num);
|
||||
}
|
||||
Db::name("app_ico_user")->where("id",$value['id'])->update(['bili'=>$bili,'status'=>1]);
|
||||
Db::name("app_ico_set")->where("id",$value['ico_id'])->setDec("real_num",$price);
|
||||
}
|
||||
Db::name("app_detailed")->insertAll($detail_data);
|
||||
Db::commit();
|
||||
$this->success(__('发放成功'));
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error(__('系统繁忙'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 私募预约记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppIcoYuyue extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppIcoYuyue模型对象
|
||||
* @var \app\admin\model\app\AppIcoYuyue
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppIcoYuyue;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'nickname'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'day'){
|
||||
$new_params['b.day'] = $value;
|
||||
$new_op['b.day'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_ico_yuyue')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_ico_yuyue')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* IP白名单设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppIpSet extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppIpSet模型对象
|
||||
* @var \app\admin\model\app\AppIpSet
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppIpSet;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
$result = Db::name('app_ip_set')->where('id',$row['id'])->update(['content'=>$params['content']]);
|
||||
file_put_contents("./ip_set2.txt", $params['content']);
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 现货团队设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppLevel extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppLevel模型对象
|
||||
* @var \app\admin\model\app\AppLevel
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppLevel;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* C2C挂单管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppMarket extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppMarket模型对象
|
||||
* @var \app\admin\model\app\AppMarket
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppMarket;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'mobile') {
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}elseif ($key == 'fb_name') {
|
||||
$new_params['c.name'] = $value;
|
||||
$new_op['c.name'] = $op[$key];
|
||||
}elseif ($key == 'curr_name') {
|
||||
$new_params['d.name'] = $value;
|
||||
$new_op['d.name'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_market aa')
|
||||
->field('aa.*,u.nickname,u.mobile,c.name as fb_name,d.name as curr_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_market_country c', 'aa.country_id = c.id','left')
|
||||
->join('app_currency d', 'aa.curr_id = d.id','left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_market aa')
|
||||
->field('aa.*,u.nickname,u.mobile,c.name as fb_name,d.name as curr_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_market_country c', 'aa.country_id = c.id','left')
|
||||
->join('app_currency d', 'aa.curr_id = d.id','left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* C2C申述记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppMarketAppeal extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppMarketAppeal模型对象
|
||||
* @var \app\admin\model\app\AppMarketAppeal
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppMarketAppeal;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("victoryList", $this->model->getVictoryList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'mobile') {
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}elseif ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_market_appeal aa')
|
||||
->field('aa.*,u.nickname,u.mobile')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_market_appeal aa')
|
||||
->field('aa.*,u.nickname,u.mobile')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('jpp_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写编辑
|
||||
* @param type $ids
|
||||
* @return type
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
// echo "<pre>";var_dump($row);die;
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
// echo "<pre>";var_dump($params);die;
|
||||
//start
|
||||
$w1 = [];
|
||||
$w1['id'] = array("eq",$ids);
|
||||
$r1 = Db::name( "app_market_appeal" )->where( $w1 )->find();
|
||||
if( !$r1 ){
|
||||
$this->error( "未查询到信息" );
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($r1['status'] == 2 && $params['status'] == 1){
|
||||
if($params['victory'] == 1){
|
||||
//卖家胜 回滚
|
||||
$market_user = Db::name("app_market_user")->where("id",$r1['order_id'])->find();
|
||||
if(empty($market_user)){
|
||||
$this->error("订单错误");
|
||||
}
|
||||
$market = Db::name("app_market")->where("id",$market_user['order_id'])->find();
|
||||
if($market_user['type'] == 1){
|
||||
//买单
|
||||
$buy_user_id = $market_user['user_id'];
|
||||
$sell_user_id = $market_user['relid'];
|
||||
}else{
|
||||
//卖单
|
||||
$sell_user_id = $market_user['user_id'];
|
||||
$buy_user_id = $market_user['relid'];
|
||||
|
||||
// 退币
|
||||
$user_curr = Db::name("app_currency_user")->where("user_id",$sell_user_id)->where("curr_id",$market['curr_id'])->find();
|
||||
$count_num = $market_user['num']+$market_user['free_num'];
|
||||
$derail_date = array(
|
||||
"user_id" => $sell_user_id,
|
||||
"curr_id" => $user_curr['curr_id'],
|
||||
"price" => $count_num,
|
||||
"cart" => 1,
|
||||
"type" => 2,
|
||||
"description" => "交易失败,货币退还",
|
||||
"createtime" => time(),
|
||||
"before_num" => $user_curr['num_fb'],
|
||||
"after_num" => $user_curr['num_fb']+$count_num,
|
||||
);
|
||||
Db::name("app_detailed_fb")->insert($derail_date);
|
||||
Db::name("app_currency_user")->where("id",$user_curr['id'])->setInc("num_fb",$count_num);
|
||||
}
|
||||
//修改订单
|
||||
$market_user_update = array(
|
||||
"status" => 5,
|
||||
"cancel_time" => time(),
|
||||
);
|
||||
Db::name("app_market_user")->where("id",$market_user['id'])->update($market_user_update);
|
||||
$market_update = array(
|
||||
"status" => 1,
|
||||
"updatetime" => time(),
|
||||
);
|
||||
Db::name("app_market")->where("id",$market['id'])->update($market_update);
|
||||
}else{
|
||||
//买家胜 放币
|
||||
$market_user = Db::name("app_market_user")->where("id",$r1['order_id'])->find();
|
||||
if(empty($market_user)){
|
||||
$this->error("订单错误");
|
||||
}
|
||||
$market = Db::name("app_market")->where("id",$market_user['order_id'])->find();
|
||||
if($market_user['type'] == 1){
|
||||
//买单
|
||||
$buy_user_id = $market_user['user_id'];
|
||||
$sell_user_id = $market_user['relid'];
|
||||
}else{
|
||||
$sell_user_id = $market_user['user_id'];
|
||||
$buy_user_id = $market_user['relid'];
|
||||
}
|
||||
//修改订单
|
||||
$market_user_update = array(
|
||||
"status" => 4,
|
||||
"succ_time" => time(),
|
||||
);
|
||||
Db::name("app_market_user")->where("id",$market_user['id'])->update($market_user_update);
|
||||
//修改挂单
|
||||
if($market['residue_num']>$market_user['num']){
|
||||
$market_update = array(
|
||||
"residue_num" => $market['residue_num'] - $market_user['num'],
|
||||
"status" => 1,
|
||||
"updatetime" => time(),
|
||||
);
|
||||
}else{
|
||||
$market_update = array(
|
||||
"residue_num" => 0,
|
||||
"status" => 3,
|
||||
"endtime" => time(),
|
||||
);
|
||||
}
|
||||
Db::name("app_market")->where("id",$market['id'])->update($market_update);
|
||||
//放币
|
||||
$user_curr = Db::name("app_currency_user")->where("user_id",$buy_user_id)->where("curr_id",$market['curr_id'])->find();
|
||||
$derail_date[] = array(
|
||||
"user_id" => $buy_user_id,
|
||||
"curr_id" => $user_curr['curr_id'],
|
||||
"price" => $market_user['num'],
|
||||
"cart" => 1,
|
||||
"type" => 2,
|
||||
"description" => "货币购买",
|
||||
"createtime" => time(),
|
||||
"before_num" => $user_curr['num_fb'],
|
||||
"after_num" => $user_curr['num_fb']+$market_user['num'],
|
||||
);
|
||||
Db::name("app_currency_user")->where("id",$user_curr['id'])->setInc("num_fb",$market_user['num']);
|
||||
|
||||
Db::name("app_detailed_fb")->insertAll($derail_date);
|
||||
}
|
||||
}
|
||||
$params['updatetime'] = time();
|
||||
Db::name("app_market_appeal")->where("id",$ids)->update($params);
|
||||
Db::commit();
|
||||
$this->success("success");
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error("修改失败");
|
||||
}
|
||||
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 取消记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppMarketCancelLog extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppMarketCancelLog模型对象
|
||||
* @var \app\admin\model\app\AppMarketCancelLog
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppMarketCancelLog;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* C2C法币国家
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppMarketCountry extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppMarketCountry模型对象
|
||||
* @var \app\admin\model\app\AppMarketCountry
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppMarketCountry;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* C2C交易记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppMarketUser extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppMarketUser模型对象
|
||||
* @var \app\admin\model\app\AppMarketUser
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppMarketUser;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'mobile') {
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_market_user aa')
|
||||
->field('aa.*,u.nickname,u.mobile')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_market_user aa')
|
||||
->field('aa.*,u.nickname,u.mobile')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 公告管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppMessages extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppMessages模型对象
|
||||
* @var \app\admin\model\app\AppMessages
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppMessages;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 投资产品
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppProduct extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppProduct模型对象
|
||||
* @var \app\admin\model\app\AppProduct
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppProduct;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index() {
|
||||
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'), true);
|
||||
$op = json_decode(input('op'), true);
|
||||
if (count($params) > 0) {
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'curr_name') {
|
||||
$new_params['c.name'] = $value;
|
||||
$new_op['c.name'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
} else {
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['b.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
// echo "<pre>";var_dump( $w );die;
|
||||
|
||||
$total = Db::name('app_product')
|
||||
->alias('aa')
|
||||
->field('aa.*,c.name as curr_name')
|
||||
->join('app_currency c', 'aa.curr_id = c.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
|
||||
$list = Db::name('app_product')
|
||||
->alias('aa')
|
||||
->field('aa.*,c.name as curr_name')
|
||||
->join('app_currency c', 'aa.curr_id = c.id' , 'left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 投资记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppProductUser extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppProductUser模型对象
|
||||
* @var \app\admin\model\app\AppProductUser
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppProductUser;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index() {
|
||||
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'), true);
|
||||
$op = json_decode(input('op'), true);
|
||||
if (count($params) > 0) {
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['b.nickname'] = $value;
|
||||
$new_op['b.nickname'] = $op[$key];
|
||||
} elseif ($key == 'curr_name') {
|
||||
$new_params['c.name'] = $value;
|
||||
$new_op['c.name'] = $op[$key];
|
||||
}elseif ($key == 'product_name') {
|
||||
$new_params['d.name'] = $value;
|
||||
$new_op['d.name'] = $op[$key];
|
||||
} elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
} else {
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['b.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
// echo "<pre>";var_dump( $w );die;
|
||||
|
||||
$total = Db::name('app_product_user')
|
||||
->alias('aa')
|
||||
->field('aa.*,b.nickname,c.name as curr_name,d.name as product_name,e.nickname as daili_name')
|
||||
->join('user b', 'aa.user_id = b.id' , 'left')
|
||||
->join('app_currency c', 'aa.curr_id = c.id' , 'left')
|
||||
->join('app_product d', 'aa.product_id = d.id' , 'left')
|
||||
->join('admin e', 'b.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
|
||||
$list = Db::name('app_product_user')
|
||||
->alias('aa')
|
||||
->field('aa.*,b.nickname,c.name as curr_name,d.name as product_name,e.nickname as daili_name')
|
||||
->join('user b', 'aa.user_id = b.id' , 'left')
|
||||
->join('app_currency c', 'aa.curr_id = c.id' , 'left')
|
||||
->join('app_product d', 'aa.product_id = d.id' , 'left')
|
||||
->join('admin e', 'b.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+417
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use fast\Random;
|
||||
|
||||
|
||||
/**
|
||||
* 代理管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppProxy extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppProxy模型对象
|
||||
* @var \app\admin\model\app\AppProxy
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppProxy;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'user_name')
|
||||
{
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'admin_name'){
|
||||
$new_params['b.nickname'] = $value;
|
||||
$new_op['b.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
if($this->auth->id != 1) {
|
||||
$w['a.admin_id'] = $this->auth->id;
|
||||
}
|
||||
$total = Db::name('app_proxy')
|
||||
->alias('a')
|
||||
->field('a.*,b.nickname as admin_name,u.nickname as user_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_admin b','b.id = a.admin_id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_proxy')
|
||||
->alias('a')
|
||||
->field('a.*,b.nickname as admin_name,u.nickname as user_name,u.referral_code')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_admin b','b.id = a.admin_id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
// 生成专属注册链接
|
||||
$front_url = Config::get('site.app_downurl') ?: $this->request->domain();
|
||||
foreach ($list as $key => $value) {
|
||||
$list[$key]['register_url'] = $front_url . '/#/pages/login/register?code=' . ($value['referral_code'] ?: '');
|
||||
}
|
||||
|
||||
//可结算金额
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Selectpage的实现方法
|
||||
*
|
||||
* 当前方法只是一个比较通用的搜索匹配,请按需重载此方法来编写自己的搜索逻辑,$where按自己的需求写即可
|
||||
* 这里示例了所有的参数,所以比较复杂,实现上自己实现只需简单的几行即可
|
||||
*
|
||||
*/
|
||||
protected function selectpage()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'htmlspecialchars']);
|
||||
|
||||
//搜索关键词,客户端输入以空格分开,这里接收为数组
|
||||
$word = (array)$this->request->request("q_word/a");
|
||||
//当前页
|
||||
$page = $this->request->request("pageNumber");
|
||||
//分页大小
|
||||
$pagesize = $this->request->request("pageSize");
|
||||
//搜索条件
|
||||
$andor = $this->request->request("andOr", "and", "strtoupper");
|
||||
//排序方式
|
||||
$orderby = (array)$this->request->request("orderBy/a");
|
||||
//显示的字段
|
||||
$field = $this->request->request("showField");
|
||||
//主键
|
||||
$primarykey = $this->request->request("keyField");
|
||||
//主键值
|
||||
$primaryvalue = $this->request->request("keyValue");
|
||||
//搜索字段
|
||||
$searchfield = (array)$this->request->request("searchField/a");
|
||||
//自定义搜索条件
|
||||
$custom = (array)$this->request->request("custom/a");
|
||||
//是否返回树形结构
|
||||
$istree = $this->request->request("isTree", 0);
|
||||
$ishtml = $this->request->request("isHtml", 0);
|
||||
if ($istree) {
|
||||
$word = [];
|
||||
$pagesize = 99999;
|
||||
}
|
||||
$order = [];
|
||||
foreach ($orderby as $k => $v) {
|
||||
$order[$v[0]] = $v[1];
|
||||
}
|
||||
$field = $field ? $field : 'name';
|
||||
|
||||
//如果有primaryvalue,说明当前是初始化传值
|
||||
if ($primaryvalue !== null) {
|
||||
$where = [$primarykey => ['in', $primaryvalue]];
|
||||
$pagesize = 99999;
|
||||
} else {
|
||||
$where = function ($query) use ($word, $andor, $field, $searchfield, $custom) {
|
||||
$logic = $andor == 'AND' ? '&' : '|';
|
||||
$searchfield = is_array($searchfield) ? implode($logic, $searchfield) : $searchfield;
|
||||
foreach ($word as $k => $v) {
|
||||
$query->where(str_replace(',', $logic, $searchfield), "like", "%{$v}%");
|
||||
}
|
||||
if ($custom && is_array($custom)) {
|
||||
foreach ($custom as $k => $v) {
|
||||
if (is_array($v) && 2 == count($v)) {
|
||||
$query->where($k, trim($v[0]), $v[1]);
|
||||
} else {
|
||||
$query->where($k, '=', $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||
}
|
||||
$list = [];
|
||||
$total = $this->model->where($where)->count();
|
||||
if ($total > 0) {
|
||||
if (is_array($adminIds)) {
|
||||
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||
}
|
||||
$datalist = $this->model->where($where)
|
||||
->order($order)
|
||||
->page($page, $pagesize)
|
||||
->field($this->selectpageFields)
|
||||
->select();
|
||||
foreach ($datalist as $index => $item) {
|
||||
unset($item['password'], $item['salt']);
|
||||
$list[] = [
|
||||
// $primarykey => isset($item[$primarykey]) ? $item[$primarykey] : '',
|
||||
$field => isset($item[$field]) ? $item[$field] : '',
|
||||
'pid' => isset($item['pid']) ? $item['pid'] : 0,
|
||||
'id' => $item['admin_id']
|
||||
];
|
||||
}
|
||||
if ($istree && !$primaryvalue) {
|
||||
$tree = Tree::instance();
|
||||
$tree->init(collection($list)->toArray(), 'pid');
|
||||
$list = $tree->getTreeList($tree->getTreeArray(0), $field);
|
||||
if (!$ishtml) {
|
||||
foreach ($list as &$item) {
|
||||
$item = str_replace(' ', ' ', $item);
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
//这里一定要返回有list这个字段,total是可选的,如果total<=list的数量,则会隐藏分页按钮
|
||||
return json(['list' => $list, 'total' => $total]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException(true)->validate($validate);
|
||||
}
|
||||
|
||||
//添加管理权限
|
||||
$admins['salt'] = Random::alnum();
|
||||
$admins['password'] = md5(md5($params['password']) . $admins['salt']);
|
||||
$admins['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。
|
||||
$admins['username'] = $params['username'];
|
||||
$params['password'] = $admins['password'];
|
||||
$admins['nickname'] = $admins['username'];
|
||||
$admins['email'] = $admins['username']."@qq.com";
|
||||
$admins['createtime'] = time();
|
||||
$admins['status'] = 'normal';
|
||||
|
||||
$result1 = Db::name('admin')->insertGetId($admins);
|
||||
if(!$result1){
|
||||
Db::rollback();
|
||||
$this->error('创建管理失败');
|
||||
}
|
||||
if($params['type'] == 1){
|
||||
// 一级代理 - 完整权限组
|
||||
$result2 = Db::name('auth_group_access')
|
||||
->insert(['uid'=>$result1,'group_id'=>11]);
|
||||
}else{
|
||||
// 二级代理 - 基本权限组
|
||||
$result2 = Db::name('auth_group_access')
|
||||
->insert(['uid'=>$result1,'group_id'=>12]);
|
||||
}
|
||||
|
||||
if(!$result2){
|
||||
Db::rollback();
|
||||
$this->error('创建管理失败.');
|
||||
}
|
||||
$result3 = Db::name("user")->where("id",$params['user_id'])->update(['admin_id'=>$result1]);
|
||||
if(!$result3){
|
||||
Db::rollback();
|
||||
$this->error('绑定用户失败');
|
||||
}
|
||||
$params['admin_id'] = $result1;
|
||||
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
$update['username'] = $params['username'];
|
||||
$update['updatetime'] = time();
|
||||
if(!empty($params['password']))
|
||||
{
|
||||
$admins = Db::name('admin')->where('id',$row['admin_id'])->find();
|
||||
$params['password'] = md5(md5($params['password']) . $admins['salt']);
|
||||
$update['password'] = $params['password'];
|
||||
}else{
|
||||
unset($params['password']);
|
||||
}
|
||||
Db::name('admin')
|
||||
->where('id',$row['admin_id'])
|
||||
->update($update);
|
||||
if($params['type'] != $row['type']){
|
||||
if($params['type'] == 1){
|
||||
// 升级为一级代理 - 完整权限
|
||||
Db::name('auth_group_access')->where("uid",$row['admin_id'])->update(['group_id'=>11]);
|
||||
}else{
|
||||
// 降级为二级代理 - 基本权限
|
||||
Db::name('auth_group_access')->where("uid",$row['admin_id'])->update(['group_id'=>12]);
|
||||
}
|
||||
}
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validateFailException(true)->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if ($ids) {
|
||||
$pk = $this->model->getPk();
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||
}
|
||||
$list = $this->model->where($pk, 'in', $ids)->select();
|
||||
$count = 0;
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($list as $k => $v) {
|
||||
$count += $v->delete();
|
||||
Db::name('admin')->where('id',$v->admin_id)->delete();
|
||||
Db::name('auth_group_access')->where('uid',$v->admin_id)->delete();
|
||||
Db::name("app_proxy")->where("id",$v->id)->delete();
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($count) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were deleted'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 代理管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppProxyTj extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppProxyTj模型对象
|
||||
* @var \app\admin\model\app\AppProxyTj
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppProxyTj;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'user_name')
|
||||
{
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'admin_name'){
|
||||
$new_params['b.nickname'] = $value;
|
||||
$new_op['b.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
$w['a.admin_id'] = array("neq",$admin_id);
|
||||
}
|
||||
}
|
||||
$total = Db::name('app_proxy')
|
||||
->alias('a')
|
||||
->field('a.*,b.nickname as admin_name,u.path')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_admin b','b.id = a.admin_id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_proxy')
|
||||
->alias('a')
|
||||
->field('a.*,b.nickname as admin_name,u.path')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_admin b','b.id = a.admin_id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$today = strtotime(date("Y-m-d"));
|
||||
foreach ($list as $key => $value) {
|
||||
|
||||
$son_arr = [];
|
||||
//团队人数
|
||||
$team_arr = Db::name("user")->field("id,jointime")->where("path","like",$value['path']."%")->where("id","neq",$value['user_id'])->select();
|
||||
$team_num = count($team_arr);$today_user = 0;
|
||||
foreach ($team_arr as $ke => $val) {
|
||||
$son_arr[] = $val['id'];
|
||||
}
|
||||
foreach ($team_arr as $ke => $val) {
|
||||
if(in_array($val['id'], $son_arr) && $val['jointime']>$today){
|
||||
$today_user = $today_user+1;
|
||||
}
|
||||
}
|
||||
//累计充值
|
||||
$rechrge = Db::name("app_recharge")->field("user_id,num,addtime")->where("status",1)->select();
|
||||
$count_reg = 0;$today_reg = 0;
|
||||
foreach ($rechrge as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_reg = $count_reg+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['addtime']>$today){
|
||||
$today_reg = $today_user+$val['num'];
|
||||
}
|
||||
}
|
||||
//累计提现
|
||||
$widthdraw = Db::name("app_widthdraw")->field("user_id,num,add_time")->where("status",1)->select();
|
||||
$count_wid = 0;$today_wid = 0;
|
||||
foreach ($widthdraw as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_wid = $count_wid+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['add_time']>$today){
|
||||
$today_wid = $today_wid+$val['num'];
|
||||
}
|
||||
}
|
||||
//币币交易
|
||||
$trade = Db::name("app_coin_trade")->field("user_id,have_usdt,createtime")->select();
|
||||
$count_trade = 0;$today_trade = 0;
|
||||
foreach ($trade as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_trade = $count_trade+$val['have_usdt'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_trade = $today_trade+$val['have_usdt'];
|
||||
}
|
||||
}
|
||||
//合约交易
|
||||
$contract = Db::name("app_contract")->field("user_id,num,createtime")->where("status","2")->select();
|
||||
$count_cont = 0;$today_cont = 0;
|
||||
foreach ($contract as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_cont = $count_cont+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_cont = $today_cont+$val['num'];
|
||||
}
|
||||
}
|
||||
|
||||
//ICO
|
||||
$detail = Db::name("app_detailed")->field("user_id,price,createtime")->where("cart",2)->where("type",5)->where("description","ICO")->select();
|
||||
$count_ico = 0;$today_ico = 0;
|
||||
foreach ($detail as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_ico = $count_ico+$val['price'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_ico = $today_ico+$val['price'];
|
||||
}
|
||||
}
|
||||
$value['team_num'] = $team_num;
|
||||
$value['today_user'] = $today_user;
|
||||
$value['count_reg'] = sprintf("%.2f",$count_reg);
|
||||
$value['today_reg'] = sprintf("%.2f",$today_reg);
|
||||
$value['count_wid'] = sprintf("%.2f",$count_wid);
|
||||
$value['today_wid'] = sprintf("%.2f",$today_wid);
|
||||
$value['count_trade'] = sprintf("%.2f",$count_trade);
|
||||
$value['today_trade'] = sprintf("%.2f",$today_trade);
|
||||
$value['count_cont'] = sprintf("%.2f",$count_cont);
|
||||
$value['today_cont'] = sprintf("%.2f",$today_cont);
|
||||
$value['count_ico'] = sprintf("%.2f",$count_ico);
|
||||
$value['today_ico'] = sprintf("%.2f",$today_ico);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
//可结算金额
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 货币汇率管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppRate extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppRate模型对象
|
||||
* @var \app\admin\model\app\AppRate
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppRate;
|
||||
$this->view->assign("isZqtradeList", $this->model->getIsZqtradeList());
|
||||
$this->view->assign("isHytradeList", $this->model->getIsHytradeList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
public function get_ctrl($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$result = Db::name('app_rate')
|
||||
->where('id',$row['id'])->update(['tradectrl_json'=>$params['tradectrl_json'],'updatetime'=>time()]);
|
||||
if($result)
|
||||
{
|
||||
$this->success('ok');
|
||||
}else{
|
||||
$this->error('系统繁忙');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 充值审核
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppRecharge extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppRecharge模型对象
|
||||
* @var \app\admin\model\app\AppRecharge
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppRecharge;
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'mobile') {
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
$total = Db::name('app_recharge aa')
|
||||
->field('aa.*,u.nickname,u.mobile,e.nickname as daili_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_currency p', 'aa.curr_id = p.id','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_recharge aa')
|
||||
->field('aa.*,u.nickname,u.mobile,e.nickname as daili_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($row['status'] != '2')
|
||||
{
|
||||
$this->error('编辑非法,已审核记录不可重复审核');
|
||||
}else{
|
||||
$user = Db::name('app_currency_user')
|
||||
->where('user_id',$row['user_id'])
|
||||
->where('curr_id','1')
|
||||
->find();
|
||||
if($params['status'] == '1') { //审核通过
|
||||
$recharge = [
|
||||
'user_id' => $row['user_id'],
|
||||
'curr_id' => 1,
|
||||
'price' => $row['num'],
|
||||
'cart' => '1',
|
||||
'type' => '1',
|
||||
'description' => '在线充值',
|
||||
'createtime' => time(),
|
||||
'hash' => $row['hash'],
|
||||
'before_num' => $user['num'],
|
||||
'after_num' => $user['num'] + $row['num'],
|
||||
'is_outer' => '1',
|
||||
];
|
||||
|
||||
$res = Db::name('app_detailed')->insertGetId($recharge);
|
||||
$changeamount = $user['num'] + $row['num'];
|
||||
Db::name('app_currency_user')->where('id', $user['id'])->update(['num' => $changeamount, 'updatetime' => time()]);
|
||||
}
|
||||
$result = Db::name('app_recharge')->where('id', $row['id'])->update($params);
|
||||
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 收款银行设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppRechargeBank extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppRechargeBank模型对象
|
||||
* @var \app\admin\model\app\AppRechargeBank
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppRechargeBank;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 充值设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppRechargeSet extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppRechargeSet模型对象
|
||||
* @var \app\admin\model\app\AppRechargeSet
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppRechargeSet;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 社区内容
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppShequSet extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppShequSet模型对象
|
||||
* @var \app\admin\model\app\AppShequSet
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppShequSet;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 提现记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppWidthdraw extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppWidthdraw模型对象
|
||||
* @var \app\admin\model\app\AppWidthdraw
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppWidthdraw;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'mobile') {
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}elseif ($key == 'curr_name') {
|
||||
$new_params['p.name'] = $value;
|
||||
$new_op['p.name'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
$total = Db::name('app_widthdraw aa')
|
||||
->field('aa.*,u.nickname,u.mobile,p.name as curr_name,e.nickname as daili_name')//bank_code
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_currency p', 'aa.curr_id = p.id','left')
|
||||
// ->join('app_collection l', 'aa.card_num = l.card_num','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_widthdraw aa')
|
||||
->field('aa.*,u.nickname,u.mobile,p.name as curr_name,e.nickname as daili_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_currency p', 'aa.curr_id = p.id','left')
|
||||
// ->join('app_collection l', 'aa.card_num = l.card_num','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$count_price = Db::name('app_widthdraw aa')
|
||||
->field('aa.*,u.nickname,p.name as curr_name,e.nickname as daili_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_currency p', 'aa.curr_id = p.id','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->sum("aa.num");
|
||||
foreach ($list as $key => $value) {
|
||||
$value['bank_code'] = Db::name("app_collection")->where("user_id",$value['user_id'])->where("card_num",$value['card_num'])->value("bank_code");
|
||||
$list[$key] = $value;
|
||||
}
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list,"count_price"=>$count_price);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($row['status'] != '2')
|
||||
{
|
||||
$this->error('编辑非法,已审核记录不可重复审核');
|
||||
}else{
|
||||
$user = Db::name('app_currency_user')
|
||||
->where('user_id',$row['user_id'])
|
||||
->where('curr_id','1')
|
||||
->find();
|
||||
if($params['status'] == '1') { //审核通过
|
||||
$params['exam_time'] = time();
|
||||
$result = Db::name('app_widthdraw')
|
||||
->where('id',$row['id'])->update($params);
|
||||
}else if($params['status'] == '0') {
|
||||
$recharge = [
|
||||
'user_id' => $row['user_id'],
|
||||
'curr_id' => 1,
|
||||
'price' => $row['num'],
|
||||
'cart' => '1',
|
||||
'type' => '2',
|
||||
'description' => $params['description'],
|
||||
'hash' => '',
|
||||
'before_num' => $user['num'],
|
||||
'after_num' => $user['num'] + $row['num'],
|
||||
'is_outer' => '0',
|
||||
'createtime' => time(),
|
||||
];
|
||||
|
||||
Db::name('app_detailed')->insertGetId($recharge);
|
||||
$changeamount = $user['num'] + $row['num'];
|
||||
Db::name('app_currency_user')->where('id', $user['id'])
|
||||
->update(['num' => $changeamount, 'updatetime' => time()]);
|
||||
$result = Db::name('app_widthdraw')
|
||||
->where('id',$row['id'])->update(['status'=>'0','description'=>$params['description'],'exam_time'=>time()]);
|
||||
|
||||
} else{ //审核失败
|
||||
$result = Db::name('app_widthdraw')
|
||||
->where('id',$row['id'])->update(['exam_time'=>time()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function bc_dechex($decimal)
|
||||
{
|
||||
$result = [];
|
||||
while ($decimal != 0) {
|
||||
$mod = $decimal % 16;
|
||||
$decimal = floor($decimal / 16);
|
||||
array_push($result, dechex($mod));
|
||||
}
|
||||
return join(array_reverse($result));
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 提币地址管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppWidthdrawAddress extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppWidthdrawAddress模型对象
|
||||
* @var \app\admin\model\app\AppWidthdrawAddress
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppWidthdrawAddress;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* index重写
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
// print_r($params);exit;
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}elseif ($key == 'email') {
|
||||
$new_params['u.email'] = $value;
|
||||
$new_op['u.email'] = $op[$key];
|
||||
}elseif ($key == 'uid') {
|
||||
$new_params['u.uid'] = $value;
|
||||
$new_op['u.uid'] = $op[$key];
|
||||
}elseif ($key == 'curr_name') {
|
||||
$new_params['p.name'] = $value;
|
||||
$new_op['p.name'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['aa.' . $key] = $value;
|
||||
$new_op['aa.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['aa.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
$total = Db::name('app_widthdraw_address aa')
|
||||
->field('aa.*,u.nickname,u.email,p.name as curr_name,e.nickname as daili_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_currency p', 'aa.curr_id = p.id','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_widthdraw_address aa')
|
||||
->field('aa.*,u.nickname,u.email,p.name as curr_name,e.nickname as daili_name')
|
||||
->join('user u', 'aa.user_id = u.id','left')
|
||||
->join('app_currency p', 'aa.curr_id = p.id','left')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('aa.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
// var_dump( Db::name('app_widthdraw aa')->getlastsql() );die;
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 锁仓释放记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppZhiyaDetail extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppZhiyaDetail模型对象
|
||||
* @var \app\admin\model\app\AppZhiyaDetail
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppZhiyaDetail;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_zhiya_detail')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_zhiya_detail')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 锁仓周期设置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppZhiyaSet extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppZhiyaSet模型对象
|
||||
* @var \app\admin\model\app\AppZhiyaSet
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppZhiyaSet;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 锁仓记录
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppZhiyaUser extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppZhiyaUser模型对象
|
||||
* @var \app\admin\model\app\AppZhiyaUser
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppZhiyaUser;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'day'){
|
||||
$new_params['b.day'] = $value;
|
||||
$new_op['b.day'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$total = Db::name('app_zhiya_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.day')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('app_zhiya_set b', 'b.id = a.zhiya_id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_zhiya_user')
|
||||
->alias('a')
|
||||
->field('a.*,u.nickname as user_name,b.day')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('app_zhiya_set b', 'b.id = a.zhiya_id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 资讯管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppZixun extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppZixun模型对象
|
||||
* @var \app\admin\model\app\AppZixun
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppZixun;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 资讯管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppZixun extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppZixun模型对象
|
||||
* @var \app\admin\model\app\AppZixun
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppZixun;
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
// 设置默认值
|
||||
if (!isset($params['user_id']) || empty($params['user_id'])) {
|
||||
$params['user_id'] = $this->auth->id; // 使用当前登录管理员ID
|
||||
}
|
||||
if (!isset($params['look_num']) || $params['look_num'] === '') {
|
||||
$params['look_num'] = 0;
|
||||
}
|
||||
if (!isset($params['addtime']) || empty($params['addtime'])) {
|
||||
$params['addtime'] = time();
|
||||
}
|
||||
|
||||
// 可选字段,如果为空则设置为空字符串
|
||||
$optionalFields = ['title_en', 'cover_image', 'content_en'];
|
||||
foreach ($optionalFields as $field) {
|
||||
if (!isset($params[$field])) {
|
||||
$params[$field] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$result = false;
|
||||
\think\Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException(true)->validate($validate);
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
\think\Db::commit();
|
||||
} catch (\think\exception\PDOException $e) {
|
||||
\think\Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (\think\Exception $e) {
|
||||
\think\Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
// 可选字段,如果为空则设置为空字符串
|
||||
$optionalFields = ['title_en', 'cover_image', 'content_en'];
|
||||
foreach ($optionalFields as $field) {
|
||||
if (!isset($params[$field])) {
|
||||
$params[$field] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$result = false;
|
||||
\think\Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validateFailException(true)->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
\think\Db::commit();
|
||||
} catch (\think\exception\PDOException $e) {
|
||||
\think\Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (\think\Exception $e) {
|
||||
\think\Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
}
|
||||
Executable
+151
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 会员管理
|
||||
*
|
||||
* @icon fa fa-user
|
||||
*/
|
||||
class Baobiao extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Baobiao模型对象
|
||||
* @var \app\admin\model\app\Baobiao
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\Baobiao;
|
||||
$this->view->assign("lhActList", $this->model->getLhActList());
|
||||
$this->view->assign("apyPayList", $this->model->getApyPayList());
|
||||
$this->view->assign("authList", $this->model->getAuthList());
|
||||
$this->view->assign("earlyAuthList", $this->model->getEarlyAuthList());
|
||||
$this->view->assign("highAuthList", $this->model->getHighAuthList());
|
||||
$this->view->assign("userTypeList", $this->model->getUserTypeList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'), true);
|
||||
$op = json_decode(input('op'), true);
|
||||
if (count($params) > 0) {
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if ($key == 'nickname') {
|
||||
$new_params['a.nickname'] = $value;
|
||||
$new_op['a.nickname'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
} else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
} else {
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['a.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
$total = Db::name('user')->alias('a')
|
||||
->field('a.id,e.nickname as daili_name')
|
||||
->join('admin e', 'a.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
|
||||
$list = Db::name('user')->alias('a')
|
||||
->field('a.*,e.nickname as daili_name')
|
||||
->join('admin e', 'a.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
foreach ($list as $key => $value) {
|
||||
|
||||
$curr = Db::name("app_currency_user a")->field("a.id,a.curr_id,a.num,a.num_fb,a.num_lh,a.num_dj,a.num_fb_dj,a.num_lh_dj,b.name,b.full_name,b.exchange,b.thumb_image,b.is_reg,b.is_wid,b.is_tran,b.is_otc,a.tron_address")
|
||||
->join("app_currency b","a.curr_id=b.id","left")
|
||||
->where("a.user_id",$value['id'])
|
||||
->order("a.curr_id asc")
|
||||
->select();
|
||||
$count_xh_usdt = 0;//现货总U
|
||||
$my_usdt = 0;$btcex = 0;
|
||||
foreach ($curr as $ke => $val) {
|
||||
if($val['curr_id'] == 1){
|
||||
$my_usdt = $val['num'];
|
||||
}
|
||||
if($val['curr_id'] == 2){
|
||||
$usdt_num = sprintf("%.6f",($val['num']+$val['num_dj'])*$val['exchange']);
|
||||
$btcex = $val['num'];
|
||||
}else{
|
||||
$usdt_num = sprintf("%.6f",($val['num']+$val['num_dj'])*$val['exchange']);
|
||||
}
|
||||
$count_xh_usdt = $count_xh_usdt+$usdt_num;
|
||||
}
|
||||
$value['count_usdt'] = sprintf("%.2f",$count_xh_usdt);
|
||||
$value['youxiao_usdt'] = sprintf("%.2f",$count_xh_usdt);
|
||||
$value['usdt_num'] = sprintf("%.2f",$my_usdt);
|
||||
$value['btcex'] = sprintf("%.2f",$btcex);
|
||||
//ICO冻结
|
||||
$ico = Db::name("app_ico_user a")->field("a.num,b.price")
|
||||
->join("app_ico_set b","a.ico_id=b.id","left")
|
||||
->where("a.user_id",$value['id'])
|
||||
->where("a.status",0)
|
||||
->select();
|
||||
$ico_usdt = 0;
|
||||
foreach ($ico as $kk => $vv) {
|
||||
$ico_usdt = $ico_usdt+($vv['num']*$vv['price']);
|
||||
}
|
||||
$value['ico_usdt'] = sprintf("%.2f",$ico_usdt);
|
||||
//合约占用
|
||||
$heyue_usdt = Db::name("app_contract")->where("user_id",$value['id'])->where("status",1)->sum("num");
|
||||
$value['heyue_usdt'] = sprintf("%.2f",$heyue_usdt);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 订单历史管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class HisOrder extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* HisOrder模型对象
|
||||
* @var \app\admin\model\app\HisOrder
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\HisOrder;
|
||||
$this->view->assign("symbolList", $this->model->getSymbolList());
|
||||
$this->view->assign("tradeResultList", $this->model->getTradeResultList());
|
||||
$this->view->assign("riseOrFallList", $this->model->getRiseOrFallList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.username'] = $value;
|
||||
$new_op['u.username'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
$total = Db::name('his_order')
|
||||
->alias('a')
|
||||
->field('a.*,u.username as user_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('his_order')
|
||||
->alias('a')
|
||||
->field('a.*,u.username as user_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
Executable
+584
@@ -0,0 +1,584 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\admin\controller\kefu\Config;
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Config as Configs;
|
||||
|
||||
/**
|
||||
* 客户订单管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Order extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Order模型对象
|
||||
* @var \app\admin\model\app\Order
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\Order;
|
||||
$this->view->assign("symbolList", $this->model->getSymbolList());
|
||||
$this->view->assign("riseOrFallList", $this->model->getRiseOrFallList());
|
||||
$this->view->assign("setLossList", $this->model->getSetLossList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.username'] = $value;
|
||||
$new_op['u.username'] = $op[$key];
|
||||
}elseif ($key == 'daili_name') {
|
||||
$new_params['e.nickname'] = $value;
|
||||
$new_op['e.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$total = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*,u.username as user_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*,u.username as user_name,e.nickname as daili_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('admin e', 'u.p_admin_id = e.id' , 'left')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$extend['risenum'] = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*')
|
||||
->where('rise_or_fall','rise')
|
||||
->sum('trade_num');
|
||||
$extend['fallnum'] = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*')
|
||||
->where('rise_or_fall','fall')
|
||||
->sum('trade_num');
|
||||
$extend['risewin'] = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*')
|
||||
->where('rise_or_fall','rise')
|
||||
->sum('expect_income');
|
||||
$extend['fallwin'] = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*')
|
||||
->where('rise_or_fall','fall')
|
||||
->sum('expect_income');
|
||||
$coindata = Db::name('app_rate')
|
||||
->whereIn('symbol','btcusdt,ethusdt,eosusdt,bchusdt,ltcusdt')->select();
|
||||
$extend['coin'] = array_column($coindata,'open','name');
|
||||
$extend['nowtime'] = time();
|
||||
$result = array("total" => $total, "rows" => $list,'extend' => $extend);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
//生成价格
|
||||
public function createPrice()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
if(empty($params['symbols']))
|
||||
{
|
||||
$this->error('请选择币种');
|
||||
}
|
||||
if(empty($params['zhouqi']))
|
||||
{
|
||||
$this->error('请选择周期');
|
||||
}
|
||||
if(empty($params['rise_or_falls']))
|
||||
{
|
||||
$this->error('请选择涨跌类型');
|
||||
}
|
||||
if(empty($params['prices']) || !is_numeric($params['prices']))
|
||||
{
|
||||
$this->error('请输入波动价格');
|
||||
}
|
||||
if(empty($params['createstime']))
|
||||
{
|
||||
$this->error('请选择下单时间');
|
||||
}
|
||||
|
||||
$tstime = strtotime($params['createstime']);
|
||||
$symbols = str_replace('usdt','',$params['symbols']);
|
||||
$newprice1 = Db::name('hb_1s_'.$symbols)
|
||||
->where('ts',"<=",$tstime-2)
|
||||
->order('ts','desc')->find();
|
||||
$newprice2 = Db::name('hb_1s_'.$symbols)
|
||||
->where('ts',"<=",$tstime-1)
|
||||
->order('ts','desc')->find();
|
||||
$newprice3 = Db::name('hb_1s_'.$symbols)
|
||||
->where('ts',"<=",$tstime)
|
||||
->order('ts','desc')->find();
|
||||
$newprice4 = Db::name('hb_1s_'.$symbols)
|
||||
->where('ts',"<=",$tstime+1)
|
||||
->order('ts','desc')->find();
|
||||
$newprice5 = Db::name('hb_1s_'.$symbols)
|
||||
->where('ts',"<=",$tstime+2)
|
||||
->order('ts','desc')->find();
|
||||
|
||||
if(!$newprice5)
|
||||
{
|
||||
$this->error('该时间段无效未获取到价格');
|
||||
}
|
||||
$randprice1 = $this->randomFloat(0,$params['prices'],2);
|
||||
$randprice2 = $this->randomFloat(0,$params['prices'],2);
|
||||
$randprice3 = $this->randomFloat(0,$params['prices'],2);
|
||||
$randprice4 = $this->randomFloat(0,$params['prices'],2);
|
||||
$randprice5 = $this->randomFloat(0,$params['prices'],2);
|
||||
if($params['rise_or_falls'] == 'rise')
|
||||
{
|
||||
$data = [
|
||||
'newprice1' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']-2),
|
||||
'price' => sprintf('%.2f',($randprice1+$newprice1['price']))
|
||||
],
|
||||
'newprice2' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']-1),
|
||||
'price' => sprintf('%.2f',($randprice2+$newprice2['price']))
|
||||
],
|
||||
'newprice3' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']),
|
||||
'price' => sprintf('%.2f',($randprice3+$newprice3['price']))
|
||||
],
|
||||
'newprice4' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']+1),
|
||||
'price' => sprintf('%.2f',($randprice4+$newprice4['price']))
|
||||
],
|
||||
'newprice5' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']+2),
|
||||
'price' => $newprice5['price']
|
||||
],
|
||||
];
|
||||
}else{
|
||||
$data = [
|
||||
'newprice1' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']-2),
|
||||
'price' => sprintf('%.2f',($newprice1['price']-$randprice1))
|
||||
],
|
||||
'newprice2' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']-1),
|
||||
'price' => sprintf('%.2f',($newprice2['price']-$randprice2))
|
||||
],
|
||||
'newprice3' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']),
|
||||
'price' => sprintf('%.2f',($newprice3['price']-$randprice3))
|
||||
],
|
||||
'newprice4' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']+1),
|
||||
'price' => sprintf('%.2f',($newprice4['price']-$randprice4))
|
||||
],
|
||||
'newprice5' => [
|
||||
'times' => date('Y-m-d H:i:s', $tstime+$params['zhouqi']+2),
|
||||
'price' => $newprice5['price']
|
||||
],
|
||||
];
|
||||
}
|
||||
$data['openprice'] = $newprice3['price'];
|
||||
$this->success('success','',$data);
|
||||
}
|
||||
|
||||
//创建价格
|
||||
public function buildPrice()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
if (empty($params['symbols'])) {
|
||||
$this->error('请选择币种');
|
||||
}
|
||||
if (empty($params['zhouqi'])) {
|
||||
$this->error('请选择周期');
|
||||
}
|
||||
if (empty($params['rise_or_falls'])) {
|
||||
$this->error('请选择涨跌类型');
|
||||
}
|
||||
if (empty($params['prices']) || !is_numeric($params['prices'])) {
|
||||
$this->error('请输入波动价格');
|
||||
}
|
||||
if (empty($params['createstime'])) {
|
||||
$this->error('请选择下单时间');
|
||||
}
|
||||
$insertdata = [
|
||||
[
|
||||
'symbol' => $params['symbols'],
|
||||
'ts' => strtotime($params['newpricetime1']),
|
||||
'price' => $params['newprice1'],
|
||||
'amount' => 0,
|
||||
'createtime' => time()
|
||||
],
|
||||
[
|
||||
'symbol' => $params['symbols'],
|
||||
'ts' => strtotime($params['newpricetime2']),
|
||||
'price' => $params['newprice2'],
|
||||
'amount' => 0,
|
||||
'createtime' => time()
|
||||
],
|
||||
[
|
||||
'symbol' => $params['symbols'],
|
||||
'ts' => strtotime($params['newpricetime3']),
|
||||
'price' => $params['newprice3'],
|
||||
'amount' => 0,
|
||||
'createtime' => time()
|
||||
],
|
||||
[
|
||||
'symbol' => $params['symbols'],
|
||||
'ts' => strtotime($params['newpricetime4']),
|
||||
'price' => $params['newprice4'],
|
||||
'amount' => 0,
|
||||
'createtime' => time()
|
||||
],
|
||||
[
|
||||
'symbol' => $params['symbols'],
|
||||
'ts' => strtotime($params['newpricetime5']),
|
||||
'price' => $params['newprice5'],
|
||||
'amount' => 0,
|
||||
'createtime' => time()
|
||||
],
|
||||
];
|
||||
$ret = Db::name('hb_ctrl')->insertAll($insertdata);
|
||||
if($ret){
|
||||
$result = http_curl('http://149api.ms2722.com/crest/hbmarket/syncCtrl?token=datrade');
|
||||
$this->success('添加成功',$result);
|
||||
}else{
|
||||
$this->error('系统繁忙');
|
||||
}
|
||||
}
|
||||
//清除价格
|
||||
public function cleanPrice()
|
||||
{
|
||||
$ret = Db::name('hb_ctrl')
|
||||
->where('id','>',0)
|
||||
->delete();
|
||||
if($ret){
|
||||
$result = http_curl('http://149api.ms2722.com/crest/hbmarket/cancelSyncCtrl?token=datrade');
|
||||
$this->success('已取消所有调控价格');
|
||||
}else{
|
||||
$this->error('系统繁忙');
|
||||
}
|
||||
}
|
||||
|
||||
//4位小数的随机数
|
||||
public function randomFloat($min = 0, $max = 10 , $localnum = 4)
|
||||
{
|
||||
if($localnum == 4) {
|
||||
if ($max - $min <= 0.0002) {
|
||||
return 0;
|
||||
}
|
||||
$rand = mt_rand() / mt_getrandmax() * ($max - $min-0.0001);
|
||||
$num = $min + $rand;
|
||||
$number = sprintf("%.4f", $num);
|
||||
if($number == $min){
|
||||
$number += 0.0001;
|
||||
}
|
||||
}else if($localnum == 5){
|
||||
if ($max - $min <= 0.00002) {
|
||||
return 0;
|
||||
}
|
||||
$rand = mt_rand() / mt_getrandmax() * ($max - $min-0.00001);
|
||||
$num = $min + $rand;
|
||||
$number = sprintf("%.5f", $num);
|
||||
if($number == $min){
|
||||
$number += 0.00001;
|
||||
}
|
||||
}else if($localnum == 6){
|
||||
if ($max - $min <= 0.000002) {
|
||||
return 0;
|
||||
}
|
||||
$rand = mt_rand() / mt_getrandmax() * ($max - $min-0.000001);
|
||||
$num = $min + $rand;
|
||||
$number = sprintf("%.6f", $num);
|
||||
if($number == $min){
|
||||
$number += 0.000001;
|
||||
}
|
||||
}else if($localnum == 2){
|
||||
if ($max - $min <= 0.02) {
|
||||
return 0;
|
||||
}
|
||||
$rand = mt_rand() / mt_getrandmax() * ($max - $min-0.01);
|
||||
$num = $min + $rand;
|
||||
$number = sprintf("%.2f", $num);
|
||||
if($number == $min){
|
||||
$number += 0.01;
|
||||
}
|
||||
}else if($localnum == 3){
|
||||
if ($max - $min <= 0.001) {
|
||||
return 0;
|
||||
}
|
||||
$rand = mt_rand() / mt_getrandmax() * ($max - $min-0.001);
|
||||
$num = $min + $rand;
|
||||
$number = sprintf("%.3f", $num);
|
||||
if($number == $min){
|
||||
$number += 0.001;
|
||||
}
|
||||
}
|
||||
|
||||
return $number;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听订单管理
|
||||
*/
|
||||
public function jianting()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
|
||||
$total = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*,u.mobile as user_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('order')
|
||||
->alias('a')
|
||||
->field('a.*,u.mobile as user_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->group('createtime')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
foreach ($list as $key=>$value)
|
||||
{
|
||||
$order = Db::name('order')
|
||||
->where('createtime',$value['createtime'])->select();
|
||||
//下单人数
|
||||
$value['ordercount'] = Db::name('order')
|
||||
->where('createtime',$value['createtime'])->count();
|
||||
//总金额
|
||||
$value['ordersum'] = Db::name('order')
|
||||
->where('createtime',$value['createtime'])->sum('trade_num');
|
||||
$risenum = $risesum = 0;
|
||||
$fallnum = $fallsum = 0;
|
||||
$normal_orders = explode('-',Configs::get('site.normal_orders'));
|
||||
$middle_orders = explode('-',Configs::get('site.middle_orders'));
|
||||
$weighest_orders = explode('-',Configs::get('site.weighest_orders'));
|
||||
$normalnum = $middlenum = $weighestnum = 0;
|
||||
foreach ($order as $kk=>$val)
|
||||
{
|
||||
if($val['rise_or_fall'] == 'rise')
|
||||
{
|
||||
$risenum++;
|
||||
$risesum += $val['trade_num'];
|
||||
}else{
|
||||
$fallnum++;
|
||||
$fallsum += $val['trade_num'];
|
||||
}
|
||||
if($val['trade_num'] > $normal_orders[0] && $val['trade_num'] <= $normal_orders[1])
|
||||
{
|
||||
$normalnum += $val['trade_num'];
|
||||
}else if($val['trade_num'] > $middle_orders[0] && $val['trade_num'] <= $middle_orders[1])
|
||||
{
|
||||
$middlenum += $val['trade_num'];
|
||||
}else if($val['trade_num'] > $weighest_orders[0] && $val['trade_num'] <= $weighest_orders[1])
|
||||
{
|
||||
$weighestnum += $val['trade_num'];
|
||||
}
|
||||
|
||||
}
|
||||
//涨
|
||||
$value['risep'] = "单数:".$risenum."\r\n"."总额:".$risesum."\r\n"."比例:".(sprintf('%.4f',$risesum/$value['ordersum'])*100)."%";
|
||||
//跌
|
||||
$value['fallp'] = "单数:".$fallnum."\r\n"."总额:".$fallsum."\r\n"."比例:".(sprintf('%.4f',$fallsum/$value['ordersum'])*100)."%";
|
||||
$value['normalp'] = "总额:".$normalnum."\r\n"."比例:".((sprintf('%.4f',$normalnum/$value['ordersum']))*100)."%";
|
||||
$value['middlep'] = "总额:".$middlenum."\r\n"."比例:".((sprintf('%.4f',$middlenum/$value['ordersum']))*100)."%";
|
||||
$value['weighestp'] = "总额:".$weighestnum."\r\n"."比例:".((sprintf('%.4f',$weighestnum/$value['ordersum']))*100)."%";
|
||||
$value['createtimes'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
|
||||
$result = array("total" => $total, "rows" => $list,'extend' => '');
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function set_yk($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
// $params = $this->preExcludeFields($params);
|
||||
Db::startTrans();
|
||||
try {
|
||||
$row->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
$this->success();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function set_bl($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
// $params = $this->preExcludeFields($params);
|
||||
Db::startTrans();
|
||||
try {
|
||||
$row->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
$this->success();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置盈利
|
||||
*/
|
||||
public function set_yin()
|
||||
{
|
||||
$ids = $this->request->get("ids");
|
||||
if($ids){
|
||||
Db::name("order")->where("id",$ids)->update(['set_loss'=>1]);
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
/**
|
||||
* 设置盈利
|
||||
*/
|
||||
public function set_kui()
|
||||
{
|
||||
$ids = $this->request->get("ids");
|
||||
if($ids){
|
||||
Db::name("order")->where("id",$ids)->update(['set_loss'=>2]);
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 用户地址管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class UserAddress extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* UserAddress模型对象
|
||||
* @var \app\admin\model\app\UserAddress
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\UserAddress;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'mobile')
|
||||
{
|
||||
$new_params['u.' . $key] = $value;
|
||||
$new_op['u.' . $key] = $op[$key];
|
||||
}else if($key == 'user_name'){
|
||||
$new_params['u.mobile'] = $value;
|
||||
$new_op['u.mobile'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
|
||||
$total = Db::name('user_address')
|
||||
->alias('a')
|
||||
->field('a.*,u.mobile as user_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('user_address')
|
||||
->alias('a')
|
||||
->field('a.*,u.mobile as user_name')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 用户等级管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class UserGrade extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* UserGrade模型对象
|
||||
* @var \app\admin\model\app\UserGrade
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\UserGrade;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Executable
+266
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
use app\admin\model\AuthGroup;
|
||||
use app\admin\model\AuthGroupAccess;
|
||||
use app\common\controller\Backend;
|
||||
use fast\Random;
|
||||
use fast\Tree;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 管理员管理
|
||||
*
|
||||
* @icon fa fa-users
|
||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||
*/
|
||||
class Admin extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\admin\model\Admin
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $selectpageFields = 'id,username,nickname,avatar';
|
||||
protected $searchFields = 'id,username,nickname';
|
||||
protected $childrenGroupIds = [];
|
||||
protected $childrenAdminIds = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('Admin');
|
||||
|
||||
$this->childrenAdminIds = $this->auth->getChildrenAdminIds(true);
|
||||
$this->childrenGroupIds = $this->auth->getChildrenGroupIds(true);
|
||||
|
||||
$groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray();
|
||||
|
||||
Tree::instance()->init($groupList);
|
||||
$groupdata = [];
|
||||
if ($this->auth->isSuperAdmin()) {
|
||||
$result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0));
|
||||
foreach ($result as $k => $v) {
|
||||
$groupdata[$v['id']] = $v['name'];
|
||||
}
|
||||
} else {
|
||||
$result = [];
|
||||
$groups = $this->auth->getGroups();
|
||||
foreach ($groups as $m => $n) {
|
||||
$childlist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['id']));
|
||||
$temp = [];
|
||||
foreach ($childlist as $k => $v) {
|
||||
$temp[$v['id']] = $v['name'];
|
||||
}
|
||||
$result[__($n['name'])] = $temp;
|
||||
}
|
||||
$groupdata = $result;
|
||||
}
|
||||
|
||||
$this->view->assign('groupdata', $groupdata);
|
||||
$this->assignconfig("admin", ['id' => $this->auth->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
$childrenGroupIds = $this->childrenGroupIds;
|
||||
$groupName = AuthGroup::where('id', 'in', $childrenGroupIds)
|
||||
->column('id,name');
|
||||
$authGroupList = AuthGroupAccess::where('group_id', 'in', $childrenGroupIds)
|
||||
->field('uid,group_id')
|
||||
->select();
|
||||
|
||||
$adminGroupName = [];
|
||||
foreach ($authGroupList as $k => $v) {
|
||||
if (isset($groupName[$v['group_id']])) {
|
||||
$adminGroupName[$v['uid']][$v['group_id']] = $groupName[$v['group_id']];
|
||||
}
|
||||
}
|
||||
$groups = $this->auth->getGroups();
|
||||
foreach ($groups as $m => $n) {
|
||||
$adminGroupName[$this->auth->id][$n['id']] = $n['name'];
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->where('id', 'in', $this->childrenAdminIds)
|
||||
->field(['password', 'salt', 'token'], true)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
foreach ($list as $k => &$v) {
|
||||
$groups = isset($adminGroupName[$v['id']]) ? $adminGroupName[$v['id']] : [];
|
||||
$v['groups'] = implode(',', array_keys($groups));
|
||||
$v['groups_text'] = implode(',', array_values($groups));
|
||||
}
|
||||
unset($v);
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
if (!Validate::is($params['password'], '\S{6,16}')) {
|
||||
$this->error(__("Please input correct password"));
|
||||
}
|
||||
$params['salt'] = Random::alnum();
|
||||
$params['password'] = md5(md5($params['password']) . $params['salt']);
|
||||
$params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。
|
||||
$result = $this->model->validate('Admin.add')->save($params);
|
||||
if ($result === false) {
|
||||
$this->error($this->model->getError());
|
||||
}
|
||||
$group = $this->request->post("group/a");
|
||||
|
||||
//过滤不允许的组别,避免越权
|
||||
$group = array_intersect($this->childrenGroupIds, $group);
|
||||
$dataset = [];
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $this->model->id, 'group_id' => $value];
|
||||
}
|
||||
model('AuthGroupAccess')->saveAll($dataset);
|
||||
$this->success();
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get(['id' => $ids]);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if (!in_array($row->id, $this->childrenAdminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
if ($params['password']) {
|
||||
if (!Validate::is($params['password'], '\S{6,16}')) {
|
||||
$this->error(__("Please input correct password"));
|
||||
}
|
||||
$params['salt'] = Random::alnum();
|
||||
$params['password'] = md5(md5($params['password']) . $params['salt']);
|
||||
} else {
|
||||
unset($params['password'], $params['salt']);
|
||||
}
|
||||
//这里需要针对username和email做唯一验证
|
||||
$adminValidate = \think\Loader::validate('Admin');
|
||||
$adminValidate->rule([
|
||||
'username' => 'require|regex:\w{3,12}|unique:admin,username,' . $row->id,
|
||||
'email' => 'require|email|unique:admin,email,' . $row->id,
|
||||
'password' => 'regex:\S{32}',
|
||||
]);
|
||||
$result = $row->validate('Admin.edit')->save($params);
|
||||
if ($result === false) {
|
||||
$this->error($row->getError());
|
||||
}
|
||||
|
||||
// 先移除所有权限
|
||||
model('AuthGroupAccess')->where('uid', $row->id)->delete();
|
||||
|
||||
$group = $this->request->post("group/a");
|
||||
|
||||
// 过滤不允许的组别,避免越权
|
||||
$group = array_intersect($this->childrenGroupIds, $group);
|
||||
|
||||
$dataset = [];
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $row->id, 'group_id' => $value];
|
||||
}
|
||||
model('AuthGroupAccess')->saveAll($dataset);
|
||||
$this->success();
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
$grouplist = $this->auth->getGroups($row['id']);
|
||||
$groupids = [];
|
||||
foreach ($grouplist as $k => $v) {
|
||||
$groupids[] = $v['id'];
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
$this->view->assign("groupids", $groupids);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
$ids = array_intersect($this->childrenAdminIds, array_filter(explode(',', $ids)));
|
||||
// 避免越权删除管理员
|
||||
$childrenGroupIds = $this->childrenGroupIds;
|
||||
$adminList = $this->model->where('id', 'in', $ids)->where('id', 'in', function ($query) use ($childrenGroupIds) {
|
||||
$query->name('auth_group_access')->where('group_id', 'in', $childrenGroupIds)->field('uid');
|
||||
})->select();
|
||||
if ($adminList) {
|
||||
$deleteIds = [];
|
||||
foreach ($adminList as $k => $v) {
|
||||
$deleteIds[] = $v->id;
|
||||
}
|
||||
$deleteIds = array_values(array_diff($deleteIds, [$this->auth->id]));
|
||||
if ($deleteIds) {
|
||||
$this->model->destroy($deleteIds);
|
||||
model('AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
* @internal
|
||||
*/
|
||||
public function multi($ids = "")
|
||||
{
|
||||
// 管理员禁止批量操作
|
||||
$this->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉搜索
|
||||
*/
|
||||
public function selectpage()
|
||||
{
|
||||
$this->dataLimit = 'auth';
|
||||
$this->dataLimitField = 'id';
|
||||
return parent::selectpage();
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
use app\admin\model\AuthGroup;
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 管理员日志
|
||||
*
|
||||
* @icon fa fa-users
|
||||
* @remark 管理员可以查看自己所拥有的权限的管理员日志
|
||||
*/
|
||||
class Adminlog extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\admin\model\AdminLog
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $childrenGroupIds = [];
|
||||
protected $childrenAdminIds = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
|
||||
$this->childrenAdminIds = $this->auth->getChildrenAdminIds(true);
|
||||
$this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin() ? true : false);
|
||||
|
||||
$groupName = AuthGroup::where('id', 'in', $this->childrenGroupIds)
|
||||
->column('id,name');
|
||||
|
||||
$this->view->assign('groupdata', $groupName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if ($this->request->isAjax()) {
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->where('admin_id', 'in', $this->childrenAdminIds)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail($ids)
|
||||
{
|
||||
$row = $this->model->get(['id' => $ids]);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$this->view->assign("row", $row->toArray());
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @internal
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @internal
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$this->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
$childrenGroupIds = $this->childrenGroupIds;
|
||||
$adminList = $this->model->where('id', 'in', $ids)->where('admin_id', 'in', function ($query) use ($childrenGroupIds) {
|
||||
$query->name('auth_group_access')->field('uid');
|
||||
})->select();
|
||||
if ($adminList) {
|
||||
$deleteIds = [];
|
||||
foreach ($adminList as $k => $v) {
|
||||
$deleteIds[] = $v->id;
|
||||
}
|
||||
if ($deleteIds) {
|
||||
$this->model->destroy($deleteIds);
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
* @internal
|
||||
*/
|
||||
public function multi($ids = "")
|
||||
{
|
||||
// 管理员禁止批量操作
|
||||
$this->error();
|
||||
}
|
||||
|
||||
public function selectpage()
|
||||
{
|
||||
return parent::selectpage();
|
||||
}
|
||||
}
|
||||
Executable
+320
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
use app\admin\model\AuthGroup;
|
||||
use app\common\controller\Backend;
|
||||
use fast\Tree;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* 角色组
|
||||
*
|
||||
* @icon fa fa-group
|
||||
* @remark 角色组可以有多个,角色有上下级层级关系,如果子角色有角色组和管理员的权限则可以派生属于自己组别下级的角色组或管理员
|
||||
*/
|
||||
class Group extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\admin\model\AuthGroup
|
||||
*/
|
||||
protected $model = null;
|
||||
//当前登录管理员所有子组别
|
||||
protected $childrenGroupIds = [];
|
||||
//当前组别列表数据
|
||||
protected $groupdata = [];
|
||||
//无需要权限判断的方法
|
||||
protected $noNeedRight = ['roletree'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AuthGroup');
|
||||
|
||||
$this->childrenGroupIds = $this->auth->getChildrenGroupIds(true);
|
||||
|
||||
$groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray();
|
||||
|
||||
Tree::instance()->init($groupList);
|
||||
$result = [];
|
||||
if ($this->auth->isSuperAdmin()) {
|
||||
$result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0));
|
||||
} else {
|
||||
$groups = $this->auth->getGroups();
|
||||
foreach ($groups as $m => $n) {
|
||||
$result = array_merge($result, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['pid'])));
|
||||
}
|
||||
}
|
||||
$groupName = [];
|
||||
foreach ($result as $k => $v) {
|
||||
$groupName[$v['id']] = $v['name'];
|
||||
}
|
||||
|
||||
$this->groupdata = $groupName;
|
||||
$this->assignconfig("admin", ['id' => $this->auth->id, 'group_ids' => $this->auth->getGroupIds()]);
|
||||
|
||||
$this->view->assign('groupdata', $this->groupdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$list = AuthGroup::all(array_keys($this->groupdata));
|
||||
$list = collection($list)->toArray();
|
||||
$groupList = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$groupList[$v['id']] = $v;
|
||||
}
|
||||
$list = [];
|
||||
foreach ($this->groupdata as $k => $v) {
|
||||
if (isset($groupList[$k])) {
|
||||
$groupList[$k]['name'] = $v;
|
||||
$list[] = $groupList[$k];
|
||||
}
|
||||
}
|
||||
$total = count($list);
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a", [], 'strip_tags');
|
||||
$params['rules'] = explode(',', $params['rules']);
|
||||
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
||||
$this->error(__('The parent group exceeds permission limit'));
|
||||
}
|
||||
$parentmodel = model("AuthGroup")->get($params['pid']);
|
||||
if (!$parentmodel) {
|
||||
$this->error(__('The parent group can not found'));
|
||||
}
|
||||
// 父级别的规则节点
|
||||
$parentrules = explode(',', $parentmodel->rules);
|
||||
// 当前组别的规则节点
|
||||
$currentrules = $this->auth->getRuleIds();
|
||||
$rules = $params['rules'];
|
||||
// 如果父组不是超级管理员则需要过滤规则节点,不能超过父组别的权限
|
||||
$rules = in_array('*', $parentrules) ? $rules : array_intersect($parentrules, $rules);
|
||||
// 如果当前组别不是超级管理员则需要过滤规则节点,不能超当前组别的权限
|
||||
$rules = in_array('*', $currentrules) ? $rules : array_intersect($currentrules, $rules);
|
||||
$params['rules'] = implode(',', $rules);
|
||||
if ($params) {
|
||||
$this->model->create($params);
|
||||
$this->success();
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
if (!in_array($ids, $this->childrenGroupIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
$row = $this->model->get(['id' => $ids]);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a", [], 'strip_tags');
|
||||
//父节点不能是非权限内节点
|
||||
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
||||
$this->error(__('The parent group exceeds permission limit'));
|
||||
}
|
||||
// 父节点不能是它自身的子节点或自己本身
|
||||
if (in_array($params['pid'], Tree::instance()->getChildrenIds($row->id, true))) {
|
||||
$this->error(__('The parent group can not be its own child or itself'));
|
||||
}
|
||||
$params['rules'] = explode(',', $params['rules']);
|
||||
|
||||
$parentmodel = model("AuthGroup")->get($params['pid']);
|
||||
if (!$parentmodel) {
|
||||
$this->error(__('The parent group can not found'));
|
||||
}
|
||||
// 父级别的规则节点
|
||||
$parentrules = explode(',', $parentmodel->rules);
|
||||
// 当前组别的规则节点
|
||||
$currentrules = $this->auth->getRuleIds();
|
||||
$rules = $params['rules'];
|
||||
// 如果父组不是超级管理员则需要过滤规则节点,不能超过父组别的权限
|
||||
$rules = in_array('*', $parentrules) ? $rules : array_intersect($parentrules, $rules);
|
||||
// 如果当前组别不是超级管理员则需要过滤规则节点,不能超当前组别的权限
|
||||
$rules = in_array('*', $currentrules) ? $rules : array_intersect($currentrules, $rules);
|
||||
$params['rules'] = implode(',', $rules);
|
||||
if ($params) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$row->save($params);
|
||||
$children_auth_groups = model("AuthGroup")->all(['id' => ['in', implode(',', (Tree::instance()->getChildrenIds($row->id)))]]);
|
||||
$childparams = [];
|
||||
foreach ($children_auth_groups as $key => $children_auth_group) {
|
||||
$childparams[$key]['id'] = $children_auth_group->id;
|
||||
$childparams[$key]['rules'] = implode(',', array_intersect(explode(',', $children_auth_group->rules), $rules));
|
||||
}
|
||||
model("AuthGroup")->saveAll($childparams);
|
||||
Db::commit();
|
||||
$this->success();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
$this->error();
|
||||
return;
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
$ids = explode(',', $ids);
|
||||
$grouplist = $this->auth->getGroups();
|
||||
$group_ids = array_map(function ($group) {
|
||||
return $group['id'];
|
||||
}, $grouplist);
|
||||
// 移除掉当前管理员所在组别
|
||||
$ids = array_diff($ids, $group_ids);
|
||||
|
||||
// 循环判断每一个组别是否可删除
|
||||
$grouplist = $this->model->where('id', 'in', $ids)->select();
|
||||
$groupaccessmodel = model('AuthGroupAccess');
|
||||
foreach ($grouplist as $k => $v) {
|
||||
// 当前组别下有管理员
|
||||
$groupone = $groupaccessmodel->get(['group_id' => $v['id']]);
|
||||
if ($groupone) {
|
||||
$ids = array_diff($ids, [$v['id']]);
|
||||
continue;
|
||||
}
|
||||
// 当前组别下有子组别
|
||||
$groupone = $this->model->get(['pid' => $v['id']]);
|
||||
if ($groupone) {
|
||||
$ids = array_diff($ids, [$v['id']]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!$ids) {
|
||||
$this->error(__('You can not delete group that contain child group and administrators'));
|
||||
}
|
||||
$count = $this->model->where('id', 'in', $ids)->delete();
|
||||
if ($count) {
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
* @internal
|
||||
*/
|
||||
public function multi($ids = "")
|
||||
{
|
||||
// 组别禁止批量操作
|
||||
$this->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取角色权限树
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function roletree()
|
||||
{
|
||||
$this->loadlang('auth/group');
|
||||
|
||||
$model = model('AuthGroup');
|
||||
$id = $this->request->post("id");
|
||||
$pid = $this->request->post("pid");
|
||||
$parentGroupModel = $model->get($pid);
|
||||
$currentGroupModel = null;
|
||||
if ($id) {
|
||||
$currentGroupModel = $model->get($id);
|
||||
}
|
||||
if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) {
|
||||
$id = $id ? $id : null;
|
||||
$ruleList = collection(model('AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
|
||||
//读取父类角色所有节点列表
|
||||
$parentRuleList = [];
|
||||
if (in_array('*', explode(',', $parentGroupModel->rules))) {
|
||||
$parentRuleList = $ruleList;
|
||||
} else {
|
||||
$parentRuleIds = explode(',', $parentGroupModel->rules);
|
||||
foreach ($ruleList as $k => $v) {
|
||||
if (in_array($v['id'], $parentRuleIds)) {
|
||||
$parentRuleList[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ruleTree = new Tree();
|
||||
$groupTree = new Tree();
|
||||
//当前所有正常规则列表
|
||||
$ruleTree->init($parentRuleList);
|
||||
//角色组列表
|
||||
$groupTree->init(collection(model('AuthGroup')->where('id', 'in', $this->childrenGroupIds)->select())->toArray());
|
||||
|
||||
//读取当前角色下规则ID集合
|
||||
$adminRuleIds = $this->auth->getRuleIds();
|
||||
//是否是超级管理员
|
||||
$superadmin = $this->auth->isSuperAdmin();
|
||||
//当前拥有的规则ID集合
|
||||
$currentRuleIds = $id ? explode(',', $currentGroupModel->rules) : [];
|
||||
|
||||
if (!$id || !in_array($pid, $this->childrenGroupIds) || !in_array($pid, $groupTree->getChildrenIds($id, true))) {
|
||||
$parentRuleList = $ruleTree->getTreeList($ruleTree->getTreeArray(0), 'name');
|
||||
$hasChildrens = [];
|
||||
foreach ($parentRuleList as $k => $v) {
|
||||
if ($v['haschild']) {
|
||||
$hasChildrens[] = $v['id'];
|
||||
}
|
||||
}
|
||||
$parentRuleIds = array_map(function ($item) {
|
||||
return $item['id'];
|
||||
}, $parentRuleList);
|
||||
$nodeList = [];
|
||||
foreach ($parentRuleList as $k => $v) {
|
||||
if (!$superadmin && !in_array($v['id'], $adminRuleIds)) {
|
||||
continue;
|
||||
}
|
||||
if ($v['pid'] && !in_array($v['pid'], $parentRuleIds)) {
|
||||
continue;
|
||||
}
|
||||
$state = array('selected' => in_array($v['id'], $currentRuleIds) && !in_array($v['id'], $hasChildrens));
|
||||
$nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state);
|
||||
}
|
||||
$this->success('', null, $nodeList);
|
||||
} else {
|
||||
$this->error(__('Can not change the parent to child'));
|
||||
}
|
||||
} else {
|
||||
$this->error(__('Group not found'));
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+155
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\auth;
|
||||
|
||||
use app\admin\model\AuthRule;
|
||||
use app\common\controller\Backend;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
|
||||
/**
|
||||
* 规则管理
|
||||
*
|
||||
* @icon fa fa-list
|
||||
* @remark 规则通常对应一个控制器的方法,同时左侧的菜单栏数据也从规则中体现,通常建议通过控制台进行生成规则节点
|
||||
*/
|
||||
class Rule extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\admin\model\AuthRule
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $rulelist = [];
|
||||
protected $multiFields = 'ismenu,status';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
if (!$this->auth->isSuperAdmin()) {
|
||||
$this->error(__('Access is allowed only to the super management group'));
|
||||
}
|
||||
$this->model = model('AuthRule');
|
||||
// 必须将结果集转换为数组
|
||||
$ruleList = collection($this->model->field('condition,remark,createtime,updatetime', true)->order('weigh DESC,id ASC')->select())->toArray();
|
||||
foreach ($ruleList as $k => &$v) {
|
||||
$v['title'] = __($v['title']);
|
||||
}
|
||||
unset($v);
|
||||
Tree::instance()->init($ruleList);
|
||||
$this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
|
||||
$ruledata = [0 => __('None')];
|
||||
foreach ($this->rulelist as $k => &$v) {
|
||||
if (!$v['ismenu']) {
|
||||
continue;
|
||||
}
|
||||
$ruledata[$v['id']] = $v['title'];
|
||||
}
|
||||
unset($v);
|
||||
$this->view->assign('ruledata', $ruledata);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$list = $this->rulelist;
|
||||
$total = count($this->rulelist);
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a", [], 'strip_tags');
|
||||
if ($params) {
|
||||
if (!$params['ismenu'] && !$params['pid']) {
|
||||
$this->error(__('The non-menu rule must have parent'));
|
||||
}
|
||||
$result = $this->model->validate()->save($params);
|
||||
if ($result === false) {
|
||||
$this->error($this->model->getError());
|
||||
}
|
||||
Cache::rm('__menu__');
|
||||
$this->success();
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get(['id' => $ids]);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a", [], 'strip_tags');
|
||||
if ($params) {
|
||||
if (!$params['ismenu'] && !$params['pid']) {
|
||||
$this->error(__('The non-menu rule must have parent'));
|
||||
}
|
||||
if ($params['pid'] != $row['pid']) {
|
||||
$childrenIds = Tree::instance()->init(collection(AuthRule::select())->toArray())->getChildrenIds($row['id']);
|
||||
if (in_array($params['pid'], $childrenIds)) {
|
||||
$this->error(__('Can not change the parent to child'));
|
||||
}
|
||||
}
|
||||
//这里需要针对name做唯一验证
|
||||
$ruleValidate = \think\Loader::validate('AuthRule');
|
||||
$ruleValidate->rule([
|
||||
'name' => 'require|format|unique:AuthRule,name,' . $row->id,
|
||||
]);
|
||||
$result = $row->validate()->save($params);
|
||||
if ($result === false) {
|
||||
$this->error($row->getError());
|
||||
}
|
||||
Cache::rm('__menu__');
|
||||
$this->success();
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
$delIds = [];
|
||||
foreach (explode(',', $ids) as $k => $v) {
|
||||
$delIds = array_merge($delIds, Tree::instance()->getChildrenIds($v, true));
|
||||
}
|
||||
$delIds = array_unique($delIds);
|
||||
$count = $this->model->where('id', 'in', $delIds)->delete();
|
||||
if ($count) {
|
||||
Cache::rm('__menu__');
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
+125
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\btpanel;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use addons\btpanel\library\Api;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Ajax extends Backend
|
||||
{
|
||||
protected $noNeedRight = ['*'];
|
||||
protected $api = null;
|
||||
public function _initialize()
|
||||
{
|
||||
$config = get_addon_config('btpanel');
|
||||
if (!$config['key']) {
|
||||
$this->error('未设置BT面板接口密钥,请先设置插件');
|
||||
}
|
||||
parent::_initialize();
|
||||
$this->api=new Api();
|
||||
}
|
||||
public function getWebSiteDomain()
|
||||
{
|
||||
$id = $this->request->request('id', -1);
|
||||
return json($this->api->getWebSiteDomain($id));
|
||||
}
|
||||
|
||||
public function updatePanel()
|
||||
{
|
||||
return json($this->api->updatePanel());
|
||||
}
|
||||
|
||||
public function getNetWork()
|
||||
{
|
||||
return json($this->api->getNetWork());
|
||||
}
|
||||
public function getLogs()
|
||||
{
|
||||
$type = $this->request->request('type', '');
|
||||
if ($type == 'crontab') {
|
||||
return json($this->api->getLogs($this->request->request(), $type));
|
||||
} else {
|
||||
return json($this->api->getLogs($this->request->request()));
|
||||
}
|
||||
}
|
||||
public function getPanelErrorLogs()
|
||||
{
|
||||
return json($this->api->getPanelErrorLogs());
|
||||
}
|
||||
public function getSiteData()
|
||||
{
|
||||
$type = $this->request->request('type', -1);
|
||||
return json($this->api->getWebSite(['limit'=>9999,'type'=>$type])) ;
|
||||
}
|
||||
public function setControl()
|
||||
{
|
||||
$type = $this->request->request('type', -1);
|
||||
$day = $this->request->request('day', 30);
|
||||
return json($this->api->setControl($type, $day)) ;
|
||||
}
|
||||
public function getMonitorData()
|
||||
{
|
||||
$action = $this->request->request('action', null);
|
||||
$start = $this->request->request('start', null);
|
||||
$end = $this->request->request('end', null);
|
||||
switch ($action) {
|
||||
case 'getLoadAverage':
|
||||
return json($this->api->getLoadAverage($start, $end));
|
||||
case 'getCpuIo':
|
||||
return json($this->api->getCpuIo($start, $end));
|
||||
case 'getDiskIo':
|
||||
return json($this->api->getDiskIo($start, $end));
|
||||
case 'GetNetWorkIo':
|
||||
return json($this->api->GetNetWorkIo($start, $end));
|
||||
default:
|
||||
return json([]);
|
||||
}
|
||||
}
|
||||
public function getCrontab()
|
||||
{
|
||||
return json($this->api->getCrontab()) ;
|
||||
}
|
||||
public function getDataList()
|
||||
{
|
||||
$type = $this->request->request('type', 'sites');
|
||||
return json($this->api->getDataList($type)) ;
|
||||
}
|
||||
public function startTask()
|
||||
{
|
||||
$id = $this->request->request('id', null);
|
||||
return json($this->api->startTask($id)) ;
|
||||
}
|
||||
public function getCrontabFind()
|
||||
{
|
||||
$id = $this->request->request('id', null);
|
||||
return json($this->api->getCrontabFind($id)) ;
|
||||
}
|
||||
public function modifyCrond()
|
||||
{
|
||||
$params = $this->request->request();
|
||||
return json($this->api->modifyCrond($params)) ;
|
||||
}
|
||||
public function setCronStatus()
|
||||
{
|
||||
$id = $this->request->request('id', null);
|
||||
return json($this->api->setCronStatus($id)) ;
|
||||
}
|
||||
public function addCrontab()
|
||||
{
|
||||
$params = $this->request->request();
|
||||
return json($this->api->addCrontab($params)) ;
|
||||
}
|
||||
public function delCrontab()
|
||||
{
|
||||
$id = $this->request->request('id', null);
|
||||
return json($this->api->delCrontab($id)) ;
|
||||
}
|
||||
public function delLogs()
|
||||
{
|
||||
$id = $this->request->request('id', null);
|
||||
return json($this->api->delLogs($id)) ;
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\btpanel;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use addons\btpanel\library\Api;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Crontab extends Backend
|
||||
{
|
||||
protected $noNeedRight = ['index'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$config = get_addon_config('btpanel');
|
||||
if(!$config['key']){
|
||||
$this->error('未设置BT面板接口密钥,请先设置插件');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$api = new Api();
|
||||
$m_SetControl = $api->setControl();
|
||||
$this->assignconfig('SetControl', $m_SetControl);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function add(){
|
||||
$data = $this->getBaseData();
|
||||
$this->assignconfig('crontab', $data);
|
||||
$this->view->assign('data', $data);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function edit($id=null){
|
||||
$api = new Api();
|
||||
$data = $this->getBaseData();
|
||||
$m_getCrontabFind = $api->getCrontabFind($id);
|
||||
$this->view->assign('row', $m_getCrontabFind);
|
||||
$this->assignconfig('row', $m_getCrontabFind);
|
||||
$this->assignconfig('crontab', $data);
|
||||
$this->view->assign('data', $data);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
private function getBaseData(){
|
||||
$data=[];
|
||||
$api = new Api();
|
||||
$m_DataList_Sites = $api->getDataList('sites');
|
||||
$m_DataList_Database = $api->getDataList('databases');
|
||||
$data['dataListSites']=[];
|
||||
$data['dataListDatabases']=[];
|
||||
if (isset($m_DataList_Sites['data'])) {
|
||||
$data['dataListSites']['sNameArray'][] = ['name'=>'所有','value'=>'ALL'];
|
||||
foreach ($m_DataList_Sites['data'] as $item) {
|
||||
$data['dataListSites']['sNameArray'][]=['name'=>$item['name'].' ['.$item['ps'].']','value'=>$item['name']];
|
||||
}
|
||||
$data['dataListSites']['backupsArray'][]=['name'=>'服务器磁盘','value'=>'localhost'];
|
||||
foreach ($m_DataList_Sites['orderOpt'] as $item) {
|
||||
$data['dataListSites']['backupsArray'][]=['name'=>$item['name'] ,'value'=>$item['value']];
|
||||
}
|
||||
}
|
||||
if (isset($m_DataList_Database['data'])) {
|
||||
$data['dataListDatabases']['sNameArray'][] = ['name'=>'所有','value'=>'ALL'];
|
||||
foreach ($m_DataList_Database['data'] as $item) {
|
||||
$data['dataListDatabases']['sNameArray'][]=['name'=>$item['name'].' ['.$item['ps'].']','value'=>$item['name']];
|
||||
}
|
||||
$data['dataListDatabases']['backupsArray'][]=['name'=>'服务器磁盘','value'=>'localhost'];
|
||||
foreach ($m_DataList_Database['orderOpt'] as $item) {
|
||||
$data['dataListDatabases']['backupsArray'][]=['name'=>$item['name'] ,'value'=>$item['value']];
|
||||
}
|
||||
}
|
||||
// echo "<pre>";print_r($data);echo "<pre>";die;
|
||||
|
||||
$data['sTypeArray']=[
|
||||
'toShell'=>'Shell脚本',
|
||||
'site'=>'备份网站',
|
||||
'database'=>'备份数据库',
|
||||
'logs'=>'日志切割',
|
||||
'path'=>'备份目录',
|
||||
'syncTime'=>'同步时间',
|
||||
'rememory'=>'释放内存',
|
||||
'toUrl'=>'访问URL'
|
||||
];
|
||||
$data['cycleArray']=[
|
||||
'day'=>'每天',
|
||||
'day-n'=>'N天',
|
||||
'hour'=>'每小时',
|
||||
'hour-n'=>'N小时',
|
||||
'minute-n'=>'N分钟',
|
||||
'week'=>'每星期',
|
||||
'month'=>'每月'
|
||||
];
|
||||
$data['weekArray']= [
|
||||
1=> '周一',
|
||||
2=>'周二',
|
||||
3=>'周三',
|
||||
4=>'周四',
|
||||
5=>'周五',
|
||||
6=>'周六',
|
||||
7=>'周日'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\btpanel;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use addons\btpanel\library\Api;
|
||||
use think\Config;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Index extends Backend
|
||||
{
|
||||
|
||||
protected $noNeedRight = ['index'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$config = get_addon_config('btpanel');
|
||||
$this->assignconfig('btpanel',$config);
|
||||
if(!$config['key']){
|
||||
$this->error('未设置BT面板接口密钥,请先设置插件');
|
||||
}
|
||||
if($config['admin'] && $this->auth->username !== 'admin'){
|
||||
$this->error('仅限管理员访问');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$api = new Api();
|
||||
$m_SystemTotal = $api->getSystemTotal();
|
||||
$m_SiteTypes = $api->getSiteTypes();
|
||||
$this->view->assign('SystemTotal',$m_SystemTotal);
|
||||
$this->view->assign('SiteTypes',$m_SiteTypes);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\btpanel;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use addons\btpanel\library\Api;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Logs extends Backend
|
||||
{
|
||||
protected $noNeedRight = ['index'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$config = get_addon_config('btpanel');
|
||||
if(!$config['key']){
|
||||
$this->error('未设置BT面板接口密钥,请先设置插件');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$api = new Api();
|
||||
$api->getTaskCount();
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\btpanel;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use addons\btpanel\library\Api;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Monitor extends Backend
|
||||
{
|
||||
protected $noNeedRight = ['index'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$config = get_addon_config('btpanel');
|
||||
if(!$config['key']){
|
||||
$this->error('未设置BT面板接口密钥,请先设置插件');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$api = new Api();
|
||||
$m_SetControl = $api->setControl();
|
||||
$this->assignconfig('SetControl', $m_SetControl);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 百度地图
|
||||
*
|
||||
* @icon fa fa-map
|
||||
* @remark 可以搜索百度位置,调用百度地图的相关API
|
||||
*/
|
||||
class Baidumap extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找地图
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索列表
|
||||
*/
|
||||
public function selectpage()
|
||||
{
|
||||
$this->model = model('Area');
|
||||
return parent::selectpage();
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 表格完整示例
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark 在使用Bootstrap-table中的常用方式,更多使用方式可查看:http://bootstrap-table.wenzhixin.net.cn/zh-cn/
|
||||
*/
|
||||
class Bootstraptable extends Backend
|
||||
{
|
||||
/**
|
||||
* @var \app\admin\model\AdminLog
|
||||
*/
|
||||
protected $model = null;
|
||||
/**
|
||||
* 无需鉴权的方法(需登录)
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedRight = ['start', 'pause', 'change', 'detail', 'cxselect', 'searchlist'];
|
||||
|
||||
/**
|
||||
* 快捷搜索的字段
|
||||
* @var string
|
||||
*/
|
||||
protected $searchFields = 'id,title,url';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(null);
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->paginate($limit);
|
||||
$result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['money' => mt_rand(100000, 999999), 'price' => 200]);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail($ids)
|
||||
{
|
||||
$row = $this->model->get(['id' => $ids]);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isAjax()) {
|
||||
$this->success("Ajax请求成功", null, ['id' => $ids]);
|
||||
}
|
||||
$this->view->assign("row", $row->toArray());
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
public function start($ids = '')
|
||||
{
|
||||
$this->success("模拟启动成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
public function pause($ids = '')
|
||||
{
|
||||
$this->success("模拟暂停成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换
|
||||
*/
|
||||
public function change($ids = '')
|
||||
{
|
||||
//你需要在此做具体的操作逻辑
|
||||
|
||||
$this->success("模拟切换成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 联动搜索
|
||||
*/
|
||||
public function cxselect()
|
||||
{
|
||||
$type = $this->request->get('type');
|
||||
$group_id = $this->request->get('group_id');
|
||||
$list = null;
|
||||
if ($group_id !== '') {
|
||||
if ($type == 'group') {
|
||||
$groupIds = $this->auth->getChildrenGroupIds(true);
|
||||
$list = \app\admin\model\AuthGroup::where('id', 'in', $groupIds)->field('id as value, name')->select();
|
||||
} else {
|
||||
$adminIds = \app\admin\model\AuthGroupAccess::where('group_id', 'in', $group_id)->column('uid');
|
||||
$list = \app\admin\model\Admin::where('id', 'in', $adminIds)->field('id as value, username AS name')->select();
|
||||
}
|
||||
}
|
||||
$this->success('', null, $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索下拉列表
|
||||
*/
|
||||
public function searchlist()
|
||||
{
|
||||
$result = $this->model->limit(10)->select();
|
||||
$searchlist = [];
|
||||
foreach ($result as $key => $value) {
|
||||
$searchlist[] = ['id' => $value['url'], 'name' => $value['url']];
|
||||
}
|
||||
$data = ['searchlist' => $searchlist];
|
||||
$this->success('', null, $data);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 彩色角标
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark 在JS端控制角标的显示与隐藏,请注意左侧菜单栏角标的数值变化
|
||||
*/
|
||||
class Colorbadge extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 控制器间跳转
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark FastAdmin支持在控制器间跳转,点击后将切换到另外一个TAB中,无需刷新当前页面
|
||||
*/
|
||||
class Controllerjump extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 自定义表单示例
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark FastAdmin支持在控制器间跳转,点击后将切换到另外一个TAB中,无需刷新当前页面
|
||||
*/
|
||||
class Customform extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->success("提交成功", null, ['data' => json_encode($this->request->post("row/a"), JSON_UNESCAPED_UNICODE)]);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function get_title_list()
|
||||
{
|
||||
$query = $this->request->get("query");
|
||||
$suggestions = AdminLog::where('title', 'like', '%' . $query . '%')->limit(10)->column("title");
|
||||
$result = [
|
||||
'query' => $query,
|
||||
'suggestions' => $suggestions
|
||||
];
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 自定义搜索
|
||||
*
|
||||
* @icon fa fa-search
|
||||
* @remark 自定义列表的搜索
|
||||
*/
|
||||
class Customsearch extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
$ipList = $this->model->whereTime('createtime', '-37 days')->group("ip")->column("ip,ip as aa");
|
||||
$this->view->assign("ipList", $ipList);
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 多级联动
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark FastAdmin使用了jQuery-cxselect实现多级联动,更多文档请参考https://github.com/karsonzhang/cxSelect
|
||||
*/
|
||||
class Cxselect extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 统计图表示例
|
||||
*
|
||||
* @icon fa fa-charts
|
||||
* @remark 展示在FastAdmin中使用Echarts展示丰富多彩的统计图表
|
||||
*/
|
||||
class Echarts extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail($ids)
|
||||
{
|
||||
$row = $this->model->get(['id' => $ids]);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$this->view->assign("row", $row->toArray());
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 多表格示例
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark 当一个页面上存在多个Bootstrap-table时该如何控制按钮和表格
|
||||
*/
|
||||
class Multitable extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
protected $noNeedRight = ['table1', 'table2'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->loadlang('general/attachment');
|
||||
$this->loadlang('general/crontab');
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function table1()
|
||||
{
|
||||
$this->model = model('Attachment');
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$total = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->count();
|
||||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch('index');
|
||||
}
|
||||
|
||||
public function table2()
|
||||
{
|
||||
$this->model = model('AdminLog');
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$total = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->count();
|
||||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch('index');
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 关联模型
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark 当使用到关联模型时需要重载index方法
|
||||
*/
|
||||
class Relationmodel extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->relationSearch = true;
|
||||
$this->searchFields = "admin.username,id";
|
||||
if ($this->request->isAjax()) {
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$list = $this->model
|
||||
->with("admin")
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 表格联动
|
||||
* 点击左侧日志列表,右侧的表格数据会显示指定管理员的日志列表
|
||||
* @icon fa fa-table
|
||||
*/
|
||||
class Tablelink extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
protected $noNeedRight = ['table1', 'table2'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
|
||||
|
||||
public function table1()
|
||||
{
|
||||
$this->model = model('Admin');
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$total = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->count();
|
||||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch('index');
|
||||
}
|
||||
|
||||
public function table2()
|
||||
{
|
||||
$this->model = model('AdminLog');
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$total = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->count();
|
||||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch('index');
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\example;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 表格模板示例
|
||||
*
|
||||
* @icon fa fa-table
|
||||
* @remark 可以通过使用表格模板将表格中的行渲染成一样的展现方式,基于此功能可以任意定制自己想要的展示列表
|
||||
*/
|
||||
class Tabletemplate extends Backend
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('AdminLog');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(null);
|
||||
$total = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->count();
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail($ids)
|
||||
{
|
||||
$row = $this->model->get(['id' => $ids]);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$this->view->assign("row", $row->toArray());
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
+124
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\general;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 附件管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
* @remark 主要用于管理上传到又拍云的数据或上传至本服务的上传数据
|
||||
*/
|
||||
class Attachment extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\common\model\Attachment
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('Attachment');
|
||||
$this->view->assign("mimetypeList", \app\common\model\Attachment::getMimetypeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if ($this->request->isAjax()) {
|
||||
$mimetypeQuery = [];
|
||||
$filter = $this->request->request('filter');
|
||||
$filterArr = (array)json_decode($filter, true);
|
||||
if (isset($filterArr['mimetype']) && preg_match("/[]\,|\*]/", $filterArr['mimetype'])) {
|
||||
$this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]);
|
||||
$mimetypeQuery = function ($query) use ($filterArr) {
|
||||
$mimetypeArr = explode(',', $filterArr['mimetype']);
|
||||
foreach ($mimetypeArr as $index => $item) {
|
||||
if (stripos($item, "/*") !== false) {
|
||||
$query->whereOr('mimetype', 'like', str_replace("/*", "/", $item) . '%');
|
||||
} else {
|
||||
$query->whereOr('mimetype', 'like', '%' . $item . '%');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$list = $this->model
|
||||
->where($mimetypeQuery)
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
|
||||
}
|
||||
unset($v);
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择附件
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
return $this->index();
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$this->error();
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除附件
|
||||
* @param array $ids
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if ($ids) {
|
||||
\think\Hook::add('upload_delete', function ($params) {
|
||||
if ($params['storage'] == 'local') {
|
||||
$attachmentFile = ROOT_PATH . '/public' . $params['url'];
|
||||
if (is_file($attachmentFile)) {
|
||||
@unlink($attachmentFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
$attachmentlist = $this->model->where('id', 'in', $ids)->select();
|
||||
foreach ($attachmentlist as $attachment) {
|
||||
\think\Hook::listen("upload_delete", $attachment);
|
||||
$attachment->delete();
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
|
||||
}
|
||||
+322
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\general;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\Email;
|
||||
use app\common\model\Config as ConfigModel;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
*
|
||||
* @icon fa fa-cogs
|
||||
* @remark 可以在此增改系统的变量和分组,也可以自定义分组和变量,如果需要删除请从数据库中删除
|
||||
*/
|
||||
class Config extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\common\model\Config
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $noNeedRight = ['check', 'rulelist', 'selectpage', 'get_fields_list'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('Config');
|
||||
ConfigModel::event('before_write', function ($row) {
|
||||
if (isset($row['name']) && $row['name'] == 'name' && preg_match("/fast" . "admin/i", $row['value'])) {
|
||||
throw new Exception(__("Site name incorrect"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$siteList = [];
|
||||
$groupList = ConfigModel::getGroupList();
|
||||
foreach ($groupList as $k => $v) {
|
||||
$siteList[$k]['name'] = $k;
|
||||
$siteList[$k]['title'] = $v;
|
||||
$siteList[$k]['list'] = [];
|
||||
}
|
||||
|
||||
foreach ($this->model->all() as $k => $v) {
|
||||
if (!isset($siteList[$v['group']])) {
|
||||
continue;
|
||||
}
|
||||
$value = $v->toArray();
|
||||
$value['title'] = __($value['title']);
|
||||
if (in_array($value['type'], ['select', 'selects', 'checkbox', 'radio'])) {
|
||||
$value['value'] = explode(',', $value['value']);
|
||||
}
|
||||
$value['content'] = json_decode($value['content'], true);
|
||||
$value['tip'] = htmlspecialchars($value['tip']);
|
||||
$siteList[$v['group']]['list'][] = $value;
|
||||
}
|
||||
$index = 0;
|
||||
foreach ($siteList as $k => &$v) {
|
||||
$v['active'] = !$index ? true : false;
|
||||
$index++;
|
||||
}
|
||||
// echo "<pre>";
|
||||
// var_dump($siteList);exit;
|
||||
unset($siteList['user']);
|
||||
// unset($siteList['coinset']);
|
||||
unset($siteList['other']);
|
||||
// unset($siteList['market']);
|
||||
unset($siteList['lianghua']);
|
||||
// unset($siteList['website']);
|
||||
$this->view->assign('siteList', $siteList);
|
||||
$this->view->assign('typeList', ConfigModel::getTypeList());
|
||||
$this->view->assign('ruleList', ConfigModel::getRegexList());
|
||||
$this->view->assign('groupList', ConfigModel::getGroupList());
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a", [], 'trim');
|
||||
if ($params) {
|
||||
foreach ($params as $k => &$v) {
|
||||
$v = is_array($v) && $k !== 'setting' ? implode(',', $v) : $v;
|
||||
}
|
||||
if (in_array($params['type'], ['select', 'selects', 'checkbox', 'radio', 'array'])) {
|
||||
$params['content'] = json_encode(ConfigModel::decode($params['content']), JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$params['content'] = '';
|
||||
}
|
||||
try {
|
||||
$result = $this->model->create($params);
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
try {
|
||||
$this->refreshFile();
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error($this->model->getError());
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param null $ids
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$row = $this->request->post("row/a", [], 'trim');
|
||||
if ($row) {
|
||||
$configList = [];
|
||||
foreach ($this->model->all() as $v) {
|
||||
if (isset($row[$v['name']])) {
|
||||
$value = $row[$v['name']];
|
||||
if (is_array($value) && isset($value['field'])) {
|
||||
$value = json_encode(ConfigModel::getArrayData($value), JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$value = is_array($value) ? implode(',', $value) : $value;
|
||||
}
|
||||
$v['value'] = $value;
|
||||
$configList[] = $v->toArray();
|
||||
}
|
||||
}
|
||||
try {
|
||||
$this->model->allowField(true)->saveAll($configList);
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
try {
|
||||
$this->refreshFile();
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param string $ids
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
$name = $this->request->post('name');
|
||||
$config = ConfigModel::getByName($name);
|
||||
if ($name && $config) {
|
||||
try {
|
||||
$config->delete();
|
||||
$this->refreshFile();
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新配置文件
|
||||
*/
|
||||
protected function refreshFile()
|
||||
{
|
||||
$config = [];
|
||||
foreach ($this->model->all() as $k => $v) {
|
||||
$value = $v->toArray();
|
||||
if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) {
|
||||
$value['value'] = explode(',', $value['value']);
|
||||
}
|
||||
if ($value['type'] == 'array') {
|
||||
$value['value'] = (array)json_decode($value['value'], true);
|
||||
}
|
||||
$config[$value['name']] = $value['value'];
|
||||
}
|
||||
file_put_contents(
|
||||
CONF_PATH . 'extra' . DS . 'site.php',
|
||||
'<?php' . "\n\nreturn " . var_export_short($config) . ";\n"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测配置项是否存在
|
||||
* @internal
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$config = $this->model->get($params);
|
||||
if (!$config) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('Name already exist'));
|
||||
}
|
||||
} else {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则列表
|
||||
* @internal
|
||||
*/
|
||||
public function rulelist()
|
||||
{
|
||||
//主键
|
||||
$primarykey = $this->request->request("keyField");
|
||||
//主键值
|
||||
$keyValue = $this->request->request("keyValue", "");
|
||||
|
||||
$keyValueArr = array_filter(explode(',', $keyValue));
|
||||
$regexList = \app\common\model\Config::getRegexList();
|
||||
$list = [];
|
||||
foreach ($regexList as $k => $v) {
|
||||
if ($keyValueArr) {
|
||||
if (in_array($k, $keyValueArr)) {
|
||||
$list[] = ['id' => $k, 'name' => $v];
|
||||
}
|
||||
} else {
|
||||
$list[] = ['id' => $k, 'name' => $v];
|
||||
}
|
||||
}
|
||||
return json(['list' => $list]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送测试邮件
|
||||
* @internal
|
||||
*/
|
||||
public function emailtest()
|
||||
{
|
||||
$row = $this->request->post('row/a');
|
||||
$receiver = $this->request->post("receiver");
|
||||
if ($receiver) {
|
||||
if (!Validate::is($receiver, "email")) {
|
||||
$this->error(__('Please input correct email'));
|
||||
}
|
||||
\think\Config::set('site', array_merge(\think\Config::get('site'), $row));
|
||||
$email = new Email;
|
||||
$result = $email
|
||||
->to($receiver)
|
||||
->subject(__("This is a test mail"))
|
||||
->message('<div style="min-height:550px; padding: 100px 55px 200px;">' . __('This is a test mail content') . '</div>')
|
||||
->send();
|
||||
if ($result) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error($email->getError());
|
||||
}
|
||||
} else {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
}
|
||||
|
||||
public function selectpage()
|
||||
{
|
||||
$id = $this->request->get("id/d");
|
||||
$config = \app\common\model\Config::get($id);
|
||||
if (!$config) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$setting = $config['setting'];
|
||||
//自定义条件
|
||||
$custom = isset($setting['conditions']) ? (array)json_decode($setting['conditions'], true) : [];
|
||||
$custom = array_filter($custom);
|
||||
|
||||
$this->request->request(['showField' => $setting['field'], 'keyField' => $setting['primarykey'], 'custom' => $custom, 'searchField' => [$setting['field'], $setting['primarykey']]]);
|
||||
$this->model = \think\Db::connect()->setTable($setting['table']);
|
||||
return parent::selectpage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表列表
|
||||
* @internal
|
||||
*/
|
||||
public function get_table_list()
|
||||
{
|
||||
$tableList = [];
|
||||
$dbname = \think\Config::get('database.database');
|
||||
$tableList = \think\Db::query("SELECT `TABLE_NAME` AS `name`,`TABLE_COMMENT` AS `title` FROM `information_schema`.`TABLES` where `TABLE_SCHEMA` = '{$dbname}';");
|
||||
$this->success('', null, ['tableList' => $tableList]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段列表
|
||||
* @internal
|
||||
*/
|
||||
public function get_fields_list()
|
||||
{
|
||||
$table = $this->request->request('table');
|
||||
$dbname = \think\Config::get('database.database');
|
||||
//从数据库中获取表字段信息
|
||||
$sql = "SELECT `COLUMN_NAME` AS `name`,`COLUMN_COMMENT` AS `title`,`DATA_TYPE` AS `type` FROM `information_schema`.`columns` WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? ORDER BY ORDINAL_POSITION";
|
||||
//加载主表的列
|
||||
$fieldList = Db::query($sql, [$dbname, $table]);
|
||||
$this->success("", null, ['fieldList' => $fieldList]);
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\general;
|
||||
|
||||
use app\admin\model\Admin;
|
||||
use app\common\controller\Backend;
|
||||
use fast\Random;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 个人配置
|
||||
*
|
||||
* @icon fa fa-user
|
||||
*/
|
||||
class Profile extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if ($this->request->isAjax()) {
|
||||
$this->model = model('AdminLog');
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->where('admin_id', $this->auth->id)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新个人信息
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post("row/a");
|
||||
$params = array_filter(array_intersect_key(
|
||||
$params,
|
||||
array_flip(array('email', 'nickname', 'password', 'avatar'))
|
||||
));
|
||||
unset($v);
|
||||
if (!Validate::is($params['email'], "email")) {
|
||||
$this->error(__("Please input correct email"));
|
||||
}
|
||||
if (isset($params['password'])) {
|
||||
if (!Validate::is($params['password'], "/^[\S]{6,16}$/")) {
|
||||
$this->error(__("Please input correct password"));
|
||||
}
|
||||
$params['salt'] = Random::alnum();
|
||||
$params['password'] = md5(md5($params['password']) . $params['salt']);
|
||||
}
|
||||
$exist = Admin::where('email', $params['email'])->where('id', '<>', $this->auth->id)->find();
|
||||
if ($exist) {
|
||||
$this->error(__("Email already exists"));
|
||||
}
|
||||
if ($params) {
|
||||
$admin = Admin::get($this->auth->id);
|
||||
$admin->save($params);
|
||||
//因为个人资料面板读取的Session显示,修改自己资料后同时更新Session
|
||||
Session::set("admin", $admin->toArray());
|
||||
$this->success();
|
||||
}
|
||||
$this->error();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\kefu;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 客服黑名单管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Blacklist extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* KeFuBlacklist模型对象
|
||||
* @var \app\admin\model\KeFuBlacklist
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\KeFuBlacklist;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//当前是否为关联查询
|
||||
$this->relationSearch = true;
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$total = $this->model->with(['admin', 'kefuuser'])->where($where)->order($sort, $order)->count();
|
||||
|
||||
$list = $this->model->with(['admin', 'kefuuser'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
foreach ($list as $row) {
|
||||
|
||||
$row->getRelation('admin')->visible(['nickname']);
|
||||
if ($row->kefuuser->user_id) {
|
||||
$row->fu_user_nickname = \think\Db::name('user')
|
||||
->where('id', $row->kefuuser->user_id)
|
||||
->value('nickname');
|
||||
}
|
||||
}
|
||||
$list = collection($list)->toArray();
|
||||
$result = ["total" => $total, "rows" => $list];
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\kefu;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/*
|
||||
* KeFu配置
|
||||
*/
|
||||
|
||||
class Config extends Backend
|
||||
{
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/*
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$config = Db::name('kefu_config')->column('name,value');
|
||||
$csr_config = Db::name('kefu_csr_config')
|
||||
->alias('c')
|
||||
->field('c.id,c.admin_id,c.ceiling,a.username')
|
||||
->join('admin a', 'c.admin_id=a.id')
|
||||
->select();
|
||||
|
||||
$this->view->assign('config_list', $config);
|
||||
$this->view->assign('csr_config', $csr_config);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/*
|
||||
* 保存修改
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$config = Db::name('kefu_config')->column('name,value');
|
||||
$csr_config = Db::name('kefu_csr_config')
|
||||
->alias('c')
|
||||
->field('c.id,c.admin_id,c.ceiling,a.username')
|
||||
->join('admin a', 'c.admin_id=a.id')
|
||||
->select();
|
||||
$csr_config_admin_ids = array_column($csr_config, 'admin_id');
|
||||
|
||||
$params = $this->request->post("row/a");
|
||||
|
||||
if ($params) {
|
||||
// 配置更新-只更新有修改的
|
||||
foreach ($params as $key => $value) {
|
||||
|
||||
if ($params[$key] != $config[$key]) {
|
||||
Db::name('kefu_config')->where('name', $key)->update(['value' => $value]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->success();
|
||||
}
|
||||
|
||||
$this->error();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Executable
+178
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\kefu;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 客服代表(csr)
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Csrkpi extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* KeFuCsrKpi模型对象
|
||||
* @var \app\admin\model\KeFuCsrKpi
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\KeFuCsrKpi;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = method_exists($this, 'preExcludeFields') ? $this->preExcludeFields($params) : $params;
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
if (Db::name('kefu_csr_config')->where('admin_id', $params['admin_id'])->value('id')) {
|
||||
$this->error('客服代表已经存在了~');
|
||||
}
|
||||
if ($params['keep_alive']) {
|
||||
$params['status'] = 3;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException(true)->validate($validate);
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
$params = method_exists($this, 'preExcludeFields') ? $this->preExcludeFields($params) : $params;
|
||||
if ($params['admin_id'] != $row['admin_id'] && Db::name('kefu_csr_config')
|
||||
->where('admin_id', $params['admin_id'])
|
||||
->value('id')) {
|
||||
$this->error('客服代表已经存在了~');
|
||||
}
|
||||
if ($params['keep_alive']) {
|
||||
$params['status'] = 3;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validateFailException(true)->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//当前是否为关联查询
|
||||
$this->relationSearch = true;
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$total = $this->model->with(['admin'])->where($where)->order($sort, $order)->count();
|
||||
|
||||
$list = $this->model->with(['admin'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
foreach ($list as $row) {
|
||||
|
||||
$row->getRelation('admin')->visible(['nickname']);
|
||||
}
|
||||
$list = collection($list)->toArray();
|
||||
$result = ["total" => $total, "rows" => $list];
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\kefu;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 快捷回复管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Fastreply extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* KeFuFastReply模型对象
|
||||
* @var \app\admin\model\KeFuFastReply
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $dataLimit = 'auth';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\KeFuFastReply;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign('isSuperAdmin', $this->auth->isSuperAdmin());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//当前是否为关联查询
|
||||
$this->relationSearch = true;
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$total = $this->model->with(['admin'])->where($where)->order($sort, $order)->count();
|
||||
|
||||
$list = $this->model->with(['admin'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
||||
foreach ($list as $row) {
|
||||
$row->content = strip_tags($row->content);
|
||||
$row->getRelation('admin')->visible(['nickname']);
|
||||
}
|
||||
$list = collection($list)->toArray();
|
||||
$result = ["total" => $total, "rows" => $list];
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
|
||||
if (isset($params['is_general']) && $params['is_general']) {
|
||||
$params['admin_id'] = false;
|
||||
} else {
|
||||
$params['admin_id'] = true;
|
||||
}
|
||||
|
||||
$params = method_exists($this, 'preExcludeFields') ? $this->preExcludeFields($params) : $params;
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill && $params['admin_id']) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException(true)->validate($validate);
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
|
||||
if (isset($params['is_general']) && $params['is_general'] && $this->auth->isSuperAdmin()) {
|
||||
$params['admin_id'] = 0;
|
||||
} else {
|
||||
$params['admin_id'] = $this->auth->id;
|
||||
}
|
||||
|
||||
$params = method_exists($this, 'preExcludeFields') ? $this->preExcludeFields($params) : $params;
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validateFailException(true)->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
|
||||
if (!$row->admin_id && $this->auth->isSuperAdmin()) {
|
||||
$row->is_general = '1';
|
||||
} else {
|
||||
$row->is_general = '0';
|
||||
}
|
||||
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\kefu;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use addons\kefu\library\StrComparison;
|
||||
|
||||
/**
|
||||
* 知识库管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Kbs extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* KeFuKbs模型对象
|
||||
* @var \app\admin\model\KeFuKbs
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\KeFuKbs;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function testMatch()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->only(['str1', 'str2']);
|
||||
if ($params['str1'] && $params['str2']) {
|
||||
$StrComparison = new StrComparison;
|
||||
$match = $StrComparison->getSimilar($params['str1'], $params['str2']);
|
||||
$this->success('ok', null, $match);
|
||||
} else {
|
||||
$this->error('', null, 0);
|
||||
}
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//当前是否为关联查询
|
||||
// $this->relationSearch = true;
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$total = $this->model->where($where)->order($sort, $order)->count();
|
||||
|
||||
$list = $this->model->where($where)->order($sort, $order)->limit($offset, $limit)->select();
|
||||
|
||||
/*foreach ($list as $row) {
|
||||
|
||||
$row->getRelation('admin')->visible(['nickname']);
|
||||
}*/
|
||||
$list = collection($list)->toArray();
|
||||
$result = ["total" => $total, "rows" => $list];
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user