初始化
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Users;
|
||||
use think\captcha\Captcha;
|
||||
|
||||
class Auth extends Admin
|
||||
{
|
||||
|
||||
public function login(){
|
||||
|
||||
if((new Users)->login_auth('admin')){
|
||||
return redirect('index/index');
|
||||
}
|
||||
|
||||
if($this->request->isPost()){
|
||||
$username = input('post.username');
|
||||
$password = input('post.password');
|
||||
$captcha = input('post.captcha');
|
||||
try {
|
||||
if(!captcha_check($captcha)){
|
||||
throw new \Exception('验证码错误');
|
||||
}
|
||||
|
||||
(new Users)->login($username,$password,'admin');
|
||||
|
||||
return json(['code' => 200,'msg' => '登录成功,正在跳转后台..']);
|
||||
}catch (\Throwable $e){
|
||||
return json(['code' => 502,'msg' => '登录失败:' . $e->getMessage()]);
|
||||
}
|
||||
}else{
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function logout(){
|
||||
(new Users)->logout('admin');
|
||||
return json(['code' => 200,'msg' => '退出登录成功']);
|
||||
}
|
||||
|
||||
public function verify(){
|
||||
$config = [
|
||||
'length' => 4
|
||||
];
|
||||
$captcha = new Captcha($config);
|
||||
return $captcha->entry();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Certify as CertifyModel;
|
||||
use app\common\model\Users;
|
||||
|
||||
class Certify extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',20);
|
||||
$list = CertifyModel::order('create_time desc')
|
||||
->page($page,$limit)
|
||||
->field('id,uid,name,idcard,status,create_time')
|
||||
->select()->each(function($item){
|
||||
$item['create_time'] = date('Y-m-d H:i',$item['create_time']);
|
||||
$item['uid'] = Users::where('id',$item['uid'])->value('username');
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = CertifyModel::count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => $list->toArray(),
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$id = input('get.id');
|
||||
|
||||
$info = CertifyModel::where('id',$id)->find();
|
||||
|
||||
if(empty($info)){
|
||||
return json(['code' => 502,'msg' => '数据不存在']);
|
||||
}
|
||||
|
||||
$info['status'] = 1;
|
||||
|
||||
$info->save();
|
||||
|
||||
Users::where('id',$info['uid'])->update(['is_auth' => 1]);
|
||||
|
||||
return json(['code' => 200,'msg' => '处理成功']);
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$id = input('get.id');
|
||||
|
||||
CertifyModel::where('id',$id)->delete();
|
||||
|
||||
return json(['code' => 200,'msg' => '删除成功']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Profit;
|
||||
use app\common\model\Stores;
|
||||
use app\common\model\Users;
|
||||
|
||||
class Dashboard extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
// 获取当月所有时间
|
||||
$month_time = [];
|
||||
$time_type = [];
|
||||
|
||||
for ($i = 0;$i < 30;$i++){
|
||||
$month_time[] = strtotime('-'.$i.' day');
|
||||
$time_type[] = "'".date('m-d',strtotime('-'.$i.' day'))."'";
|
||||
}
|
||||
|
||||
$time_type = array_reverse($time_type);
|
||||
$time_type = implode(',',$time_type);
|
||||
|
||||
// 获取当月间隔时间
|
||||
$start_time = strtotime(date('Y-m-d',strtotime('-29 day')));
|
||||
$end_time = strtotime('now');
|
||||
|
||||
// 获取30天的统计记录
|
||||
$profit = Profit::whereTime('create_time','>=',$start_time)
|
||||
->whereTime('create_time','<=',$end_time)
|
||||
->order('create_time desc')
|
||||
->select();
|
||||
|
||||
|
||||
// 图表统计
|
||||
$series_reg = str_split(str_repeat('0',30),1);
|
||||
$series_order = str_split(str_repeat('0',30),1);
|
||||
$series_money = str_split(str_repeat('0',30),1);
|
||||
|
||||
foreach ($month_time as $key => $item){
|
||||
$item_time = date('Y-m-d',$item);
|
||||
foreach ($profit as $profit_item){
|
||||
$profit_time = date('Y-m-d',$profit_item['create_time']);
|
||||
if($item_time == $profit_time){
|
||||
$series_reg[$key] = $profit_item['count_reg'];
|
||||
$series_order[$key] = $profit_item['count_order_yes'];
|
||||
$series_money[$key] = $profit_item['count_money'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$series_reg = array_reverse($series_reg);
|
||||
$series_reg = implode(',',$series_reg);
|
||||
|
||||
$series_order = array_reverse($series_order);
|
||||
$series_order = implode(',',$series_order);
|
||||
|
||||
$series_money = array_reverse($series_money);
|
||||
$series_money = implode(',',$series_money);
|
||||
|
||||
// 用户数量统计
|
||||
|
||||
$default_group = config('register.default_group');
|
||||
$vip_group = config('vip.vip_group');
|
||||
|
||||
$default_user = Users::where('group',$default_group)->count();
|
||||
$vip_user = Users::where('group',$vip_group)->count();
|
||||
|
||||
$file = Stores::count();
|
||||
$size = Stores::sum('size');
|
||||
|
||||
$this->assign('count',[
|
||||
'user' => $default_user,
|
||||
'vip' => $vip_user,
|
||||
'file' => $file,
|
||||
'size' => countSize($size)
|
||||
]);
|
||||
|
||||
$this->assign('profit',$profit);
|
||||
|
||||
$this->assign('series_reg',$series_reg);
|
||||
$this->assign('series_order',$series_order);
|
||||
$this->assign('series_money',$series_money);
|
||||
$this->assign('time_type',$time_type);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\driver\AliyunOss;
|
||||
use app\common\model\driver\Local;
|
||||
use app\common\model\driver\TxyunOss;
|
||||
use app\common\model\Policys;
|
||||
use app\common\model\Stores;
|
||||
use app\common\model\Users;
|
||||
use think\response\Download;
|
||||
|
||||
class File extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',10);
|
||||
$map = [];
|
||||
|
||||
// 获取筛选条件
|
||||
$start_time = input('get.start_time','');
|
||||
$end_time = input('get.end_time','');
|
||||
$policy_id = input('get.policy','');
|
||||
$ext = input('get.ext','');
|
||||
$uid = input('get.uid','');
|
||||
$origin_name = input('get.origin_name','');
|
||||
|
||||
if(!empty($start_time) && !empty($end_time)){
|
||||
$map[] = ['create_time','between time',[$start_time,$end_time]];
|
||||
}
|
||||
|
||||
if(!empty($policy_id)){
|
||||
$map[] = ['policy_id','=',$policy_id];
|
||||
}
|
||||
|
||||
if(!empty($ext)){
|
||||
$map[] = ['ext','=',$ext];
|
||||
}
|
||||
|
||||
if(!empty($uid)){
|
||||
$map[] = ['uid','=',$uid];
|
||||
}
|
||||
|
||||
if(!empty($origin_name)){
|
||||
$map[] = ['origin_name','like','%'.$origin_name.'%'];
|
||||
}
|
||||
|
||||
//获取排序条件
|
||||
$sort_key = input('get.sort_key','create_time');
|
||||
$sort = input('get.sort',0);
|
||||
|
||||
$order_type = empty($sort) ? 'desc' : 'asc';
|
||||
|
||||
$list = Stores::where($map)->page($page,$limit)->order($sort_key,$order_type)->select()->each(function($item){
|
||||
$item['icon'] = getFileIcon($item['ext'],'admin');
|
||||
$item['size'] = countSize($item['size']);
|
||||
$item['uid'] = Users::where('id',$item['uid'])->value('nickname');
|
||||
$item['policy_id'] = Policys::where('id',$item['policy_id'])->value('name');
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = Stores::where($map)->count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '加载成功',
|
||||
'count' => $count,
|
||||
'data' => $list->toArray()
|
||||
]);
|
||||
}else{
|
||||
|
||||
$policy = Policys::field('id,name')->select();
|
||||
$this->assign('policy',$policy);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$ids = input('get.ids');
|
||||
$store = Stores::withTrashed()->where('id','in',$ids)->select();
|
||||
if(empty($store)){
|
||||
$this->returnError('数据不存在');
|
||||
}
|
||||
|
||||
$succ = 0;
|
||||
|
||||
foreach ($store as $item){
|
||||
$item->delete();
|
||||
$succ++;
|
||||
}
|
||||
|
||||
$this->returnSuccess('成功删除'.$succ.'个文件');
|
||||
}
|
||||
|
||||
public function download(){
|
||||
$id = input('get.id',0);
|
||||
$info = Stores::get($id);
|
||||
if(empty($info)){
|
||||
$this->error('数据不存在');
|
||||
}
|
||||
|
||||
$policy = Policys::get($info['policy_id']);
|
||||
|
||||
if(empty($policy)){
|
||||
$this->error('存储策略不存在');
|
||||
}
|
||||
|
||||
// 远程文件下载
|
||||
if($policy['type'] == 'remote'){
|
||||
$down_url = getDownloadRemote($info['file_name'],$info['origin_name'],$policy->config['server_uri'],"",$policy->config['access_token']);
|
||||
$this->redirect($down_url);
|
||||
}
|
||||
|
||||
// 存储驱动下载
|
||||
switch ($policy['type']){
|
||||
case 'aliyunoss':
|
||||
$driver = new AliyunOss(0,0,0);
|
||||
break;
|
||||
case 'txyunoss':
|
||||
$driver = new TxyunOss(0,0,0);
|
||||
break;
|
||||
default:
|
||||
$driver = new Local(0,0,0);
|
||||
break;
|
||||
}
|
||||
|
||||
// 下载
|
||||
return $driver->download($info,"",$policy);
|
||||
}
|
||||
|
||||
public function info(){
|
||||
$id = input('get.id',0);
|
||||
$info = Stores::get($id);
|
||||
if(empty($info)){
|
||||
$this->error('数据不存在');
|
||||
}
|
||||
|
||||
$username = Users::where('id',$info['uid'])->value('username');
|
||||
$policy_name = Policys::where('id',$info['policy_id'])->value('name');
|
||||
$file_path = $info['file_name'];
|
||||
|
||||
$this->assign('username',$username);
|
||||
$this->assign('policy_name',$policy_name);
|
||||
$this->assign('file_path',$file_path);
|
||||
$this->assign('info',$info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Groups;
|
||||
use app\common\model\Policys;
|
||||
use app\common\model\Users;
|
||||
|
||||
class Group extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',10);
|
||||
|
||||
$list = Groups::page($page,$limit)->select()->each(function($item){
|
||||
$item['max_storage'] = countSize($item['max_storage']);
|
||||
$item['is_sys'] = $item['is_sys'] ? '<span class="layui-badge-rim">系统</span>' : '自定义';
|
||||
$item['user_num'] = Users::where('group',$item['id'])->count();
|
||||
$item['policy_id'] = Policys::where('id',$item['policy_id'])->value('name');
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = Groups::count();
|
||||
$this->returnSuccessLayTable($count,$list->toArray());
|
||||
}
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function add(){
|
||||
if($this->request->isPost()){
|
||||
$this->callModelMethods('Groups','addGroup',input('post.'));
|
||||
$this->returnSuccess();
|
||||
}
|
||||
$policy = Policys::getPolicyAll();
|
||||
$this->assign('policy',$policy);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$id = input('get.id');
|
||||
$info = Groups::get($id);
|
||||
|
||||
if(empty($info)){
|
||||
$this->error('用户组数据不存在');
|
||||
}
|
||||
|
||||
if($this->request->isPost()){
|
||||
$this->callModelMethods('Groups','editGroup',$id,input('post.'));
|
||||
$this->returnSuccess();
|
||||
}
|
||||
|
||||
$policy = Policys::getPolicyAll();
|
||||
$this->assign('policy',$policy);
|
||||
$this->assign('info',$info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$id = input('get.id');
|
||||
$info = Groups::get($id);
|
||||
|
||||
if(empty($info)){
|
||||
$this->returnError('用户组不存在');
|
||||
}
|
||||
|
||||
if($info['is_sys'] == 1){
|
||||
$this->returnError('系统用户组,不可删除');
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户组下是否存在用户
|
||||
*/
|
||||
|
||||
Groups::where('id',$id)->delete();
|
||||
|
||||
$this->returnSuccess('删除成功');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
|
||||
class Index extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
|
||||
$theme = [
|
||||
// 标题
|
||||
'title' => 'SkPan网盘',
|
||||
// logo
|
||||
'logo' => '/static/admin/images/logo.png',
|
||||
// 菜单
|
||||
'menu' => json_encode(config('menu.')),
|
||||
// 管理员
|
||||
'admin' => [
|
||||
'avatar' => '/static/admin/images/avatar.jpg',
|
||||
'nickname' => $this->adminInfo['nickname']
|
||||
],
|
||||
// 激活菜单
|
||||
'menu_select' => 1,
|
||||
// 首页url
|
||||
'home_url' => url('dashboard/index'),
|
||||
// 后台url
|
||||
'index_url' => url('index/index'),
|
||||
// 退出登录url
|
||||
'logout_url' => url('auth/logout'),
|
||||
// 修改密码url
|
||||
'pass_url' => url('auth/pass'),
|
||||
// 清除缓存
|
||||
'clear_cache_url' => url('index/cache')
|
||||
];
|
||||
|
||||
$this->assign('theme',$theme);
|
||||
return $this->fetch();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Order as OrderModel;
|
||||
use app\common\model\Users;
|
||||
|
||||
class Order extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',10);
|
||||
|
||||
$search_type = input('get.search_type','');
|
||||
$search_value = input('get.search_value','');
|
||||
$status = input('get.status','');
|
||||
$map = [];
|
||||
|
||||
if(!empty($search_type) && !empty($search_value)){
|
||||
$map[] = [$search_type,'like','%'.$search_value.'%'];
|
||||
}
|
||||
|
||||
if(!empty($status)){
|
||||
$map[] = ['status','=',$status];
|
||||
}
|
||||
|
||||
$pay_types = [
|
||||
'alipay' => '支付宝',
|
||||
'wxpay' => '微信'
|
||||
];
|
||||
|
||||
$list = OrderModel::where($map)
|
||||
->page($page,$limit)
|
||||
->select()->each(function ($item) use($pay_types){
|
||||
$item['uid'] = Users::where('id',$item['uid'])->value('username');
|
||||
$item['type'] = $pay_types[$item['type']] ?? '';
|
||||
$item['money'] = number_format($item['money'],2).'¥';
|
||||
$item['vip_day'] = $item['vip_day'].'天';
|
||||
$item['out_trade_no'] = empty($item['out_trade_no']) ? '-' : $item['out_trade_no'];
|
||||
$item['create_time'] = date('Y-m-d H:i',$item['create_time']);
|
||||
$item['pay_time'] = empty($item['pay_time']) ? '-' : date('Y-m-d H:i',$item['pay_time']);
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = OrderModel::count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '加载成功',
|
||||
'count' => $count,
|
||||
'data' => $list->toArray()
|
||||
]);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$ids = input('get.ids');
|
||||
|
||||
OrderModel::where('id','in',$ids)->delete();
|
||||
|
||||
$this->returnSuccess('删除订单成功');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Policys;
|
||||
use app\common\model\Stores;
|
||||
|
||||
class Policy extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',10);
|
||||
|
||||
|
||||
$list = Policys::page($page,$limit)->field('id,name,type,max_size')->select()->each(function($item){
|
||||
$item['max_size'] = countSize($item['max_size']);
|
||||
$item['type'] = PolicyType($item['type']);
|
||||
$item['file_num'] = Stores::where('policy_id',$item['id'])->count();
|
||||
$item['store_num'] = countSize(Stores::where('policy_id',$item['id'])->sum('size'));
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = Policys::count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '加载成功',
|
||||
'count' => $count,
|
||||
'data' => $list->toArray()
|
||||
]);
|
||||
}else{
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function add(){
|
||||
if($this->request->isPost()){
|
||||
$this->callModelMethods('Policys','addPolicy',input('post.'));
|
||||
$this->returnSuccess();
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$id = input('get.id');
|
||||
$info = Policys::get($id);
|
||||
|
||||
if(empty($info)){
|
||||
$this->error('存储策略数据不存在');
|
||||
}
|
||||
|
||||
if($this->request->isPost()){
|
||||
$this->callModelMethods('Policys','editPolicy',$id,input('post.'));
|
||||
$this->returnSuccess();
|
||||
}
|
||||
|
||||
$this->assign('info',$info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$id = input('get.id');
|
||||
$info = Policys::get($id);
|
||||
|
||||
if(empty($info)){
|
||||
$this->returnError('存储策略不存在');
|
||||
}
|
||||
|
||||
Policys::where('id',$id)->delete();
|
||||
|
||||
$this->returnSuccess('删除成功');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Policys;
|
||||
use app\common\model\Profit;
|
||||
use app\common\model\Stores;
|
||||
use app\common\model\Users;
|
||||
|
||||
class Recycle extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',10);
|
||||
$map = [];
|
||||
|
||||
// 获取筛选条件
|
||||
$start_time = input('get.start_time','');
|
||||
$end_time = input('get.end_time','');
|
||||
$policy_id = input('get.policy','');
|
||||
$ext = input('get.ext','');
|
||||
$uid = input('get.uid','');
|
||||
$origin_name = input('get.origin_name','');
|
||||
|
||||
if(!empty($start_time) && !empty($end_time)){
|
||||
$map[] = ['delete_time','between time',[$start_time,$end_time]];
|
||||
}
|
||||
|
||||
if(!empty($policy_id)){
|
||||
$map[] = ['policy_id','=',$policy_id];
|
||||
}
|
||||
|
||||
if(!empty($ext)){
|
||||
$map[] = ['ext','=',$ext];
|
||||
}
|
||||
|
||||
if(!empty($uid)){
|
||||
$map[] = ['uid','=',$uid];
|
||||
}
|
||||
|
||||
if(!empty($origin_name)){
|
||||
$map[] = ['origin_name','like','%'.$origin_name.'%'];
|
||||
}
|
||||
|
||||
//获取排序条件
|
||||
$sort_key = input('get.sort_key','delete_time');
|
||||
$sort = input('get.sort',0);
|
||||
|
||||
$order_type = empty($sort) ? 'desc' : 'asc';
|
||||
|
||||
$list = Stores::onlyTrashed()->where($map)->page($page,$limit)->order($sort_key,$order_type)->select()->each(function($item){
|
||||
$item['icon'] = getFileIcon($item['ext'],'admin');
|
||||
$item['size'] = countSize($item['size']);
|
||||
$item['uid'] = Users::where('id',$item['uid'])->value('nickname');
|
||||
$item['policy_id'] = Policys::where('id',$item['policy_id'])->value('name');
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = Stores::onlyTrashed()->where($map)->count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '加载成功',
|
||||
'count' => $count,
|
||||
'data' => $list->toArray()
|
||||
]);
|
||||
}
|
||||
$policy = Policys::field('id,name')->select();
|
||||
$this->assign('policy',$policy);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function restore(){
|
||||
$ids = input('get.ids');
|
||||
$store = Stores::onlyTrashed()->where('id','in',$ids)->select();
|
||||
if(empty($store)){
|
||||
$this->returnError('数据不存在');
|
||||
}
|
||||
|
||||
$succ = 0;
|
||||
|
||||
foreach ($store as $item){
|
||||
$item->restore();
|
||||
$succ++;
|
||||
}
|
||||
|
||||
$this->returnSuccess('处理完成,共恢复'.$succ.'个文件');
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$ids = input('get.ids');
|
||||
$store = Stores::onlyTrashed()->where('id','in',$ids)->select();
|
||||
if(empty($store)){
|
||||
$this->returnError('数据不存在');
|
||||
}
|
||||
|
||||
$succ = 0;
|
||||
|
||||
foreach ($store as $item){
|
||||
$item->delete(true);
|
||||
|
||||
// 删除分享信息
|
||||
Profit::where('file_id',$item['id'])
|
||||
->where('uid',$item['uid'])
|
||||
->delete();
|
||||
|
||||
$succ++;
|
||||
}
|
||||
|
||||
$this->returnSuccess('成功删除'.$succ.'个文件');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Reports;
|
||||
|
||||
class Report extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',20);
|
||||
$list = Reports::order('create_time desc')
|
||||
->page($page,$limit)
|
||||
->field('id,source_name,source_url,source_username,type,contact,real_ip,status,create_time')
|
||||
->select()->each(function($item){
|
||||
$item['create_time'] = date('Y-m-d H:i',$item['create_time']);
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = Reports::count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => $list->toArray(),
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$id = input('get.id');
|
||||
|
||||
$info = Reports::where('id',$id)->find();
|
||||
|
||||
if(empty($info)){
|
||||
$this->error('数据不存在');
|
||||
}
|
||||
|
||||
if($this->request->isPost()){
|
||||
|
||||
$status = input('post.status');
|
||||
|
||||
$info['status'] = $status;
|
||||
|
||||
$info->save();
|
||||
|
||||
return json(['code' => 200,'msg' => '处理成功']);
|
||||
}
|
||||
|
||||
$this->assign('info',$info);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$id = input('get.id');
|
||||
|
||||
Reports::where('id',$id)->delete();
|
||||
|
||||
return json(['code' => 200,'msg' => '删除成功']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Groups;
|
||||
use app\common\model\Setting as SettingModel;
|
||||
use think\facade\Cache;
|
||||
|
||||
class Setting extends Admin
|
||||
{
|
||||
|
||||
|
||||
public function basic(){
|
||||
$this->saveOptions();
|
||||
$this->assign('option',$this->getOptions());
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
public function register(){
|
||||
$this->saveOptions();
|
||||
$group = Groups::field('id,group_name')->select()->toArray();
|
||||
$this->assign('group',$group);
|
||||
$this->assign('option',$this->getOptions());
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function pay(){
|
||||
$this->saveOptions();
|
||||
$this->assign('option',$this->getOptions());
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function vip(){
|
||||
$this->saveOptions();
|
||||
$group = Groups::field('id,group_name')->select()->toArray();
|
||||
$this->assign('group',$group);
|
||||
$this->assign('option',$this->getOptions());
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function email(){
|
||||
$this->saveOptions();
|
||||
$this->assign('option',$this->getOptions());
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
protected function saveOptions(){
|
||||
if($this->request->isPost()){
|
||||
$type = $this->request->action();
|
||||
$post = input('post.');
|
||||
|
||||
try {
|
||||
// 更新数据库
|
||||
foreach ($post as $key => $item){
|
||||
SettingModel::where('set_name',$key)
|
||||
->where('set_type',$type)
|
||||
->update(['set_value' => $item]);
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->returnError($e->getMessage());
|
||||
}
|
||||
|
||||
// 更新缓存
|
||||
$setting = SettingModel::select()->toArray();
|
||||
Cache::set('_setting_config',$setting);
|
||||
|
||||
$this->returnSuccess('保存成功');
|
||||
}
|
||||
}
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
$type = $this->request->action();
|
||||
$settings = SettingModel::where('set_type',$type)->select();
|
||||
$options = [];
|
||||
foreach ($settings as $item){
|
||||
$options[$item['set_name']] = $item['set_value'];
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Groups;
|
||||
use app\common\model\Users;
|
||||
use think\Exception;
|
||||
|
||||
class User extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',10);
|
||||
$search_type = input('get.search_type','');
|
||||
$search_value = input('get.search_value','');
|
||||
$map = [];
|
||||
|
||||
if(!empty($search_type) && !empty($search_value)){
|
||||
$map[] = [$search_type,'like','%'.$search_value.'%'];
|
||||
}
|
||||
|
||||
$groups = Groups::column('group_name','id');
|
||||
$default_group = config('register.default_group');
|
||||
|
||||
$list = Users::where($map)
|
||||
->page($page,$limit)
|
||||
->field('id,nickname,username,group,is_auth,amount,email,avatar,status,create_time')
|
||||
->select()->each(function ($item) use ($groups,$default_group){
|
||||
$group_name = $groups[$item['group']] ?? '未知';
|
||||
|
||||
if($item['group'] == 1){
|
||||
$item['group'] = '<span class="layui-badge layui-bg-blue">'. $group_name .'</span>';
|
||||
}elseif ($item['group'] == $default_group){
|
||||
$item['group'] = '<span class="layui-badge layui-bg-gray">'. $group_name .'</span>';
|
||||
}else{
|
||||
$item['group'] = '<span class="layui-badge layui-bg-red">'. $group_name .'</span>';
|
||||
}
|
||||
|
||||
$item['avatar'] = getUserHead($item['avatar']);
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = Users::count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '加载成功',
|
||||
'count' => $count,
|
||||
'data' => $list->toArray()
|
||||
]);
|
||||
}else{
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function add(){
|
||||
|
||||
$default_group = config('register.default_group');
|
||||
|
||||
if($this->request->isPost()){
|
||||
$data = input('post.');
|
||||
$result = $this->validate($data,[
|
||||
'username|用户帐号' => 'require|alphaNum|length:6,26',
|
||||
'group|用户组' => 'require|number',
|
||||
'password|登录密码' => 'require|alphaNum|length:6,18',
|
||||
'repassword|重复密码' => 'require|confirm:password',
|
||||
'email|安全邮箱' => 'require|email'
|
||||
]);
|
||||
|
||||
if($result !== true) return json(['code' => 502,'msg' => $result]);
|
||||
|
||||
if(empty($data['group'])){
|
||||
$data['group'] = $default_group;
|
||||
}
|
||||
|
||||
//处理用户的VIP时间
|
||||
if(!empty($data['group_expire'])){
|
||||
$group_expire = strtotime($data['group_expire']);
|
||||
}
|
||||
|
||||
try {
|
||||
(new Users)->register($data['username'],$data['email'],$data['password'],$data['group'],[],$group_expire);
|
||||
return json(['code' => 200,'msg' => '账号新增成功']);
|
||||
}catch (Exception $e){
|
||||
return json(['code' => 503,'msg' => $e->getMessage()]);
|
||||
}
|
||||
}else{
|
||||
$group = Groups::field('id,group_name')->select()->toArray();
|
||||
$this->assign('default_group',$default_group);
|
||||
$this->assign('group',$group);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$ids = input('get.ids');
|
||||
|
||||
if(count(explode(',',$ids)) > 20){
|
||||
$this->returnError('删除失败,不能一次删除20条以上的数据');
|
||||
}
|
||||
|
||||
$delete_users = Users::where('id','in',$ids)->field('id,group')->select()->toArray();
|
||||
|
||||
foreach ($delete_users as $item){
|
||||
if($item['id'] == 1){
|
||||
$this->returnError('删除失败,删除帐号中包含总管理员帐号');
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* 待完成功能:删除用户后删除相关数据,如:上传储存的数据,订单数据,目录数据,分享数据等
|
||||
*/
|
||||
|
||||
Users::where('id',$item['id'])->delete();
|
||||
}
|
||||
|
||||
return json(['code' => 200,'msg' => '删除成功']);
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$id = input('get.id');
|
||||
$info = Users::get($id);
|
||||
|
||||
if(empty($info)){
|
||||
$this->error('用户数据不存在');
|
||||
}
|
||||
|
||||
if($this->request->isPost()){
|
||||
$data = input('post.');
|
||||
$result = $this->validate($data,[
|
||||
'email|安全邮箱' => 'email',
|
||||
'password|登录密码' => 'alphaNum|length:6,18',
|
||||
'group|用户组' => 'require|number'
|
||||
]);
|
||||
|
||||
if($result !== true) return json(['code' => 502,'msg' => $result]);
|
||||
|
||||
$update = [];
|
||||
|
||||
if(!empty($data['email'])){
|
||||
$update['email'] = $data['email'];
|
||||
}
|
||||
|
||||
if(!empty($data['password'])){
|
||||
$en_password = md5($data['password'] . config('app.pass_salt'));
|
||||
$update['password'] = $en_password;
|
||||
}
|
||||
|
||||
if($info['group'] == 1 && $info['id'] != $this->adminInfo['id'] && !empty($data['password']) && $this->adminInfo['id'] != 1){
|
||||
$this->returnError('操作失败,您不能更改其他管理员组用户的密码');
|
||||
}
|
||||
|
||||
if($info['id'] == $this->adminInfo['id'] && $data['group'] != $info['group']){
|
||||
$this->returnError('操作失败,您不能更改自己的用户组');
|
||||
}
|
||||
|
||||
if($info['id'] == 1 && $data['group'] != $info['group']){
|
||||
$this->returnError('操作失败,您不能更改总管理员的用户组');
|
||||
}
|
||||
|
||||
$update['group'] = $data['group'];
|
||||
|
||||
//处理用户的VIP时间
|
||||
if($info['group_expire']<time()&&strtotime($data['group_expire'])>$info['group_expire']){
|
||||
$update['group_expire'] = strtotime($data['group_expire']);
|
||||
}
|
||||
Users::where('id',$id)->update($update);
|
||||
|
||||
return json(['code' => 200,'msg' => '用户信息修改成功']);
|
||||
|
||||
}else{
|
||||
$group = Groups::field('id,group_name')->select()->toArray();
|
||||
$this->assign('group',$group);
|
||||
$this->assign('info',$info);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function change_status(){
|
||||
$id = input('get.id');
|
||||
$status = input('get.status');
|
||||
|
||||
$info = Users::get($id);
|
||||
|
||||
if($info->isEmpty()){
|
||||
$this->returnError('用户数据不存在');
|
||||
}
|
||||
|
||||
if($info['id'] == 1){
|
||||
$this->returnError('操作失败,您不能封禁总管理员的帐号');
|
||||
}
|
||||
|
||||
if($info['id'] == $this->adminInfo['id']){
|
||||
$this->returnError('操作失败,您不能封禁自己的帐号');
|
||||
}
|
||||
|
||||
Users::where('id',$id)->update(['status' => $status]);
|
||||
|
||||
return json(['code' => 200,'msg' => '用户状态切换成功']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
use app\common\model\Record;
|
||||
use app\common\model\Users;
|
||||
use app\common\model\Withdraw as WithdrawModel;
|
||||
|
||||
class Withdraw extends Admin
|
||||
{
|
||||
|
||||
public function index(){
|
||||
if($this->request->isAjax()){
|
||||
$page = input('get.page',1);
|
||||
$limit = input('get.limit',20);
|
||||
$list = WithdrawModel::order('create_time desc')
|
||||
->page($page,$limit)
|
||||
->field('id,uid,money,alipay_account,alipay_name,create_time,status')
|
||||
->select()->each(function($item){
|
||||
$item['uid'] = Users::where('id',$item['uid'])->value('username');
|
||||
$item['create_time'] = date('Y-m-d H:i',$item['create_time']);
|
||||
return $item;
|
||||
});
|
||||
|
||||
$count = WithdrawModel::count();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => $list->toArray(),
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$id = input('get.id');
|
||||
|
||||
WithdrawModel::where('id',$id)->delete();
|
||||
|
||||
return json(['code' => 200,'msg' => '删除成功']);
|
||||
}
|
||||
|
||||
public function change(){
|
||||
$id = input('get.id');
|
||||
$status = input('get.status');
|
||||
|
||||
$info = WithdrawModel::where('id',$id)->find();
|
||||
|
||||
if(empty($info)){
|
||||
return json(['code' => 502,'msg' => '数据记录不存在']);
|
||||
}
|
||||
|
||||
$info['status'] = $status;
|
||||
|
||||
$info->save();
|
||||
|
||||
if($status == 2){
|
||||
// 退回金额
|
||||
Record::addRecord($info['uid'],0,'提现退回',$info['money'],'提现系统退回金额');
|
||||
}
|
||||
|
||||
return json(['code' => 200,'msg' => '操作成功']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user