代码初始化
This commit is contained in:
11
application/adminapi/common.php
Normal file
11
application/adminapi/common.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 获取二级密码
|
||||
*/
|
||||
|
||||
function secondary_password(){
|
||||
$boss_secondary_password = get_system_config_value('boss_secondary_password');
|
||||
$password = md5($boss_secondary_password);
|
||||
return $password;
|
||||
}
|
||||
6
application/adminapi/config.php
Normal file
6
application/adminapi/config.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
//配置文件
|
||||
return [
|
||||
'exception_handle' => '\\app\\adminapi\\library\\ExceptionHandle',
|
||||
];
|
||||
706
application/adminapi/controller/Activities.php
Normal file
706
application/adminapi/controller/Activities.php
Normal file
@@ -0,0 +1,706 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 盲盒
|
||||
* @internal
|
||||
*/
|
||||
class Activities extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['decorate_list'];
|
||||
|
||||
protected $table = 'vs_gift_bag';
|
||||
|
||||
//1金币2礼物3装扮4钻石
|
||||
public $gift_type =[
|
||||
1=>'金币',
|
||||
2=>'礼物',
|
||||
3=>'装扮',
|
||||
4=>'钻石'
|
||||
];
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
/*
|
||||
* 首充类型列表
|
||||
*/
|
||||
public function first_charge_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where = [];
|
||||
$where['activities_id'] = 1;
|
||||
$where['delete_time'] = 0;
|
||||
$count = db($this->table)->where($where)->count();
|
||||
$lists = db($this->table)->where($where)->page($page, $page_limit)->select();
|
||||
$bag_list = [];
|
||||
foreach ($lists as $key=>$value){
|
||||
$bag_list[$key]['id'] = $value['id'];
|
||||
$bag_list[$key]['name'] = $value['name'];
|
||||
$bag_list[$key]['title'] = $value['title'];
|
||||
$bag_list[$key]['status'] = $value['status'];
|
||||
$bag_list[$key]['status_str'] = $value['status']==1?'开启' : '关闭';
|
||||
$bag_list[$key]['createtime'] = $value['createtime'];
|
||||
$ext = json_decode($value['ext'],true);
|
||||
$bag_list[$key]['title1'] = $ext['title1'];
|
||||
$bag_list[$key]['title2'] = $ext['title2'];
|
||||
$bag_list[$key]['money'] = $ext['money'];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $bag_list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 首充类型添加
|
||||
*/
|
||||
public function add_first_charge_type(){
|
||||
$name = input('name', '');
|
||||
$title = input('title', '');
|
||||
$status = input('status', '');
|
||||
$title1 = input('title1', '');
|
||||
$title2 = input('title2', '');
|
||||
$money = input('money', '');
|
||||
$return_data = [
|
||||
'name' => $name,
|
||||
'title' => $title,
|
||||
'status' => $status,
|
||||
'activities_id' => 1,
|
||||
];
|
||||
$ext = [
|
||||
'title1' => $title1,
|
||||
'title2' => $title2,
|
||||
'money' => $money
|
||||
];
|
||||
$return_data['ext'] = json_encode($ext);
|
||||
$res = db::name($this->table)->insert($return_data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 首充类型修改
|
||||
*/
|
||||
public function update_first_charge(){
|
||||
$name = input('name', '');
|
||||
$title = input('title', '');
|
||||
$status = input('status', '');
|
||||
$title1 = input('title1', '');
|
||||
$title2 = input('title2', '');
|
||||
$money = input('money', '');
|
||||
$id = input('id', '');
|
||||
$gift_bag = db::name($this->table)->find($id);
|
||||
if(!$gift_bag){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$data = [];
|
||||
if($name!=""){
|
||||
$data['name'] = $name;
|
||||
}
|
||||
if($title!=""){
|
||||
$data['title'] = $title;
|
||||
}
|
||||
if($status!=""){
|
||||
$data['status'] = $status;
|
||||
}
|
||||
$gift_bag_ext = json_decode($gift_bag['ext'], true);
|
||||
$ext = [
|
||||
'title1' => $gift_bag_ext['title1'],
|
||||
'title2' => $gift_bag_ext['title2'],
|
||||
'money' => $gift_bag_ext['money'],
|
||||
];
|
||||
if($title1!=""){
|
||||
$ext['title1'] = $title1;
|
||||
}
|
||||
if($title2!=""){
|
||||
$ext['title2'] = $title2;
|
||||
}
|
||||
if($money!=""){
|
||||
$ext['money'] = $money;
|
||||
$data['money'] = $money;
|
||||
}
|
||||
$data['ext'] = json_encode($ext);
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 首充类型删除
|
||||
*/
|
||||
public function del_first_charge(){
|
||||
$id = input('id', '', 'intval');
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update(['status'=>2,'delete_time'=>time()]);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 首充礼包发放记录
|
||||
*/
|
||||
public function first_charge_send_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$user_id = input('user_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$where = [];
|
||||
if($user_id){
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
$gift_bag = db('vs_gift_bag')->where(['activities_id'=>1,'delete_time'=>0])->select();
|
||||
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
}else{
|
||||
$gift_bag_id = array_column($gift_bag,'id');
|
||||
$where['gift_bag_id'] = ['in',$gift_bag_id];
|
||||
}
|
||||
$count = db::name('vs_gift_bag_receive_log')->where($where)->count();
|
||||
$lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['user_id'] = $value['user_id'];
|
||||
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
||||
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
||||
$lists[$key]['money'] = $gift_bag['money'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 礼包列表
|
||||
*/
|
||||
public function gift_bag_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$gift_bag_id = input('gift_bag_id', 0);
|
||||
if($gift_bag_id == 0){
|
||||
return V(0,"请选择礼包");
|
||||
}
|
||||
$where = [];
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
$count = db("vs_gift_bag_detail")->where($where)->count();
|
||||
$lists = db("vs_gift_bag_detail")->where($where)->page($page, $page_limit)->select();
|
||||
$bag_list = [];
|
||||
foreach ($lists as $kk=>$vv){
|
||||
$bag_list[$kk]['id'] = $vv['id'];
|
||||
$bag_list[$kk]['gift_id'] = $vv['foreign_id'];
|
||||
$bag_list[$kk]['gift_bag_id'] = $vv['gift_bag_id'];
|
||||
if($vv['type'] == 1){
|
||||
$bag_list[$kk]['name'] = "金币";
|
||||
$bag_list[$kk]['num'] = $vv['quantity'];
|
||||
$bag_list[$kk]['gold'] = $vv['gold'];
|
||||
$bag_list[$kk]['type'] = 1;
|
||||
$bag_list[$kk]['type_str'] = "金币";
|
||||
$bag_list[$kk]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}elseif ($vv['type'] == 2) {
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$vv['foreign_id']])->find();
|
||||
$bag_list[$kk]['name'] = $gift['gift_name'];
|
||||
$bag_list[$kk]['num'] = $vv['quantity'];
|
||||
$bag_list[$kk]['gold'] = $gift['gift_price'];
|
||||
$bag_list[$kk]['type'] =2;
|
||||
$bag_list[$kk]['type_str'] = "礼物";
|
||||
$bag_list[$kk]['icon'] = $gift['base_image'];
|
||||
} elseif ($vv['type'] == 3) {
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$vv['foreign_id']])->find();
|
||||
if($decorate_price){
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
}
|
||||
$bag_list[$kk]['name'] = $gift['title']??""; //装扮名称
|
||||
$bag_list[$kk]['num'] = $decorate_price['day']??0; //天数
|
||||
$bag_list[$kk]['gold'] = $decorate_price['price']??0; //价格
|
||||
$bag_list[$kk]['type'] =3;
|
||||
$bag_list[$kk]['type_str'] = "装扮";
|
||||
$bag_list[$kk]['icon'] = $gift['base_image']??"";
|
||||
}elseif ($vv['type'] == 4) {
|
||||
$bag_list[$kk]['name'] = "钻石";
|
||||
$bag_list[$kk]['num'] = $vv['quantity'];
|
||||
$bag_list[$kk]['gold'] = $vv['gold'];
|
||||
$bag_list[$kk]['type'] = 4;
|
||||
$bag_list[$kk]['type_str'] = "钻石";
|
||||
$bag_list[$kk]['icon'] = localpath_to_netpath("static/image/icon/diamond.png");
|
||||
}
|
||||
$bag_list[$kk]['createtime'] = date("Y-m-d H:i:s",$vv['createtime']);
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $bag_list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 礼包添加
|
||||
*/
|
||||
public function gift_bag_add(){
|
||||
$type = input('type', "");
|
||||
$num = input('num', 1);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$gift_bag_id = input('gift_bag_id', 1);
|
||||
if($type==""){
|
||||
return V(0,"请选择礼物类型");
|
||||
}
|
||||
if($type == 1){
|
||||
$data = [
|
||||
'type' => 1,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'name' => "金币",
|
||||
'quantity' => $num,
|
||||
'gold' => 1,
|
||||
];
|
||||
}elseif($type == 2){
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$gift_id])->find();
|
||||
if(!$gift){
|
||||
return V(0,"请选择礼物");
|
||||
}
|
||||
$data = [
|
||||
'type' => 2,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'foreign_id' => $gift_id,
|
||||
'name' => $gift['gift_name'],
|
||||
'quantity' => $num,
|
||||
];
|
||||
} elseif($type == 3){
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$gift_id])->find();
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
if(!$decorate_price){
|
||||
return V(0,"请选择装扮");
|
||||
}
|
||||
$data = [
|
||||
'type' => 3,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'foreign_id' => $gift_id,
|
||||
'name' => $gift['title'],
|
||||
'days' => $decorate_price['day'],
|
||||
];
|
||||
} elseif($type == 4){
|
||||
$data = [
|
||||
'type' => 4,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'name' => "钻石",
|
||||
'quantity' => $num,
|
||||
'gold' => 1,
|
||||
];
|
||||
}
|
||||
$data['createtime'] = time();
|
||||
$res = db::name('vs_gift_bag_detail')->insert($data);
|
||||
if(!$res){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 礼包编辑
|
||||
*/
|
||||
public function gift_bag_edit(){
|
||||
$type = input('type', "");
|
||||
$num = input('num', 1);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$gift_bag_id = input('gift_bag_id', 1);
|
||||
$id = input('id', 0);
|
||||
if($id == 0){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$gift_bag = db::name('vs_gift_bag_detail')->where(['id'=>$id])->find();
|
||||
if(!$gift_bag){
|
||||
return V(0,"请选择礼包");
|
||||
}
|
||||
if($type == 1){
|
||||
$data = [
|
||||
'type' => 1,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'name' => "金币",
|
||||
'quantity' => $num,
|
||||
'gold' => 1,
|
||||
];
|
||||
}elseif($type == 2){
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$gift_id])->find();
|
||||
if(!$gift){
|
||||
return V(0,"请选择礼物");
|
||||
}
|
||||
$data = [
|
||||
'type' => 2,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'foreign_id' => $gift_id,
|
||||
'name' => $gift['gift_name'],
|
||||
'quantity' => $num,
|
||||
];
|
||||
} elseif($type == 3){
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$gift_id])->find();
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
if(!$decorate_price){
|
||||
return V(0,"请选择装扮");
|
||||
}
|
||||
$data = [
|
||||
'type' => 3,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'foreign_id' => $gift_id,
|
||||
'name' => $gift['title'],
|
||||
'days' => $decorate_price['day'],
|
||||
];
|
||||
} elseif($type == 4){
|
||||
$data = [
|
||||
'type' => 4,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'name' => "钻石",
|
||||
'quantity' => $num,
|
||||
'gold' => 1,
|
||||
];
|
||||
}
|
||||
$res = db::name('vs_gift_bag_detail')->where('id', $id)->update($data);
|
||||
if(!$res){
|
||||
return V(0,"编辑失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除礼包
|
||||
*/
|
||||
public function gift_bag_list_del(){
|
||||
$id = input('id');
|
||||
$res = db::name('vs_gift_bag_detail')->delete($id);
|
||||
if(!$res){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 天降好礼详情
|
||||
*/
|
||||
public function day_drop_gift(){
|
||||
$where['activities_id'] = 3;
|
||||
$where['delete_time'] = 0;
|
||||
$day_drop_gift = db($this->table)->where($where)->order('id desc')->find();
|
||||
$ext = json_decode($day_drop_gift['ext'],true);
|
||||
$data = [
|
||||
'id' => $day_drop_gift['id'],
|
||||
'name' => $day_drop_gift['name'],
|
||||
'title' => $day_drop_gift['title'],
|
||||
'status' => $day_drop_gift['status'],
|
||||
'counter' => $ext['counter'],
|
||||
'money' => $ext['money'],
|
||||
'money_str' => $ext['money_str'],
|
||||
'diamond' => $ext['diamond'],
|
||||
];
|
||||
return V(1,"成功",$data);
|
||||
}
|
||||
/*
|
||||
* 天降好礼配置
|
||||
*/
|
||||
public function day_drop_gift_site(){
|
||||
$name = input('name', '');
|
||||
$title = input('title', '');
|
||||
$status = input('status', '');
|
||||
$counter = input('counter', '');
|
||||
$money = input('money', '');
|
||||
$money_str = input('money_str', '');
|
||||
$diamond = input('diamond', '');
|
||||
$id = input('id', 6);
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'title' => $title,
|
||||
'status' => $status
|
||||
];
|
||||
$ext = [
|
||||
'counter' => $counter,
|
||||
'money_str' => $money_str,
|
||||
'diamond' => $diamond,
|
||||
'money' => $money
|
||||
];
|
||||
$data['ext'] = json_encode($ext);
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if(!$res){
|
||||
return V(0,"失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 天降好礼礼包发放记录
|
||||
*/
|
||||
public function day_drop_send_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$user_id = input('user_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', 6);
|
||||
$where = [];
|
||||
if($user_id){
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
}
|
||||
$count = db::name('vs_gift_bag_receive_log')->where($where)->count();
|
||||
$lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['user_id'] = $value['user_id'];
|
||||
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
||||
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
||||
$lists[$key]['money'] = $gift_bag['money'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//礼盒管理
|
||||
/*
|
||||
* 规则配置
|
||||
*/
|
||||
public function daily_tasks_box_config_set(){
|
||||
$gift_bag_id = input('gift_bag_id', "");
|
||||
$highest_gain = input('highest_gain', "");
|
||||
$meet = input('meet','');
|
||||
$num = input('num', 0);
|
||||
$content = input('content', 0);
|
||||
if($gift_bag_id==""){
|
||||
return V(0,"请选择礼包类型");
|
||||
}
|
||||
if($highest_gain==""){
|
||||
return V(0,"请填写礼包总价值");
|
||||
}
|
||||
if($num==""){
|
||||
return V(0,"请填写每日可领取数量");
|
||||
}
|
||||
if($meet==""){
|
||||
return V(0,"请填写每天累计购买金币数");
|
||||
}
|
||||
$ext = [
|
||||
'highest_gain' => $highest_gain,
|
||||
'meet' => $meet,
|
||||
'num' => $num
|
||||
];
|
||||
$data['ext'] = json_encode($ext);
|
||||
$res = db::name($this->table)->where(['id'=>$gift_bag_id])->update($data);
|
||||
if(!$res){
|
||||
return V(0,"失败");
|
||||
}
|
||||
if($content){
|
||||
db::name('vs_activities')->where('id',2)->update(['content'=>$content]);
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 规则配置详情
|
||||
*/
|
||||
public function daily_tasks_box_config(){
|
||||
$gift_bag_id = input('gift_bag_id', "");
|
||||
$where['id'] = $gift_bag_id;
|
||||
$where['delete_time'] = 0;
|
||||
$day_drop_gift = db($this->table)->where($where)->order('id desc')->find();
|
||||
$ext = json_decode($day_drop_gift['ext'],true);
|
||||
$activities_content = db::name('vs_activities')->where('id',2)->value('content');
|
||||
$data = [
|
||||
'id' => $day_drop_gift['id'],
|
||||
'name' => $day_drop_gift['name'],
|
||||
'title' => $day_drop_gift['title'],
|
||||
'status' => $day_drop_gift['status'],
|
||||
'highest_gain' => $ext['highest_gain'],
|
||||
'meet' => $ext['meet'],
|
||||
'num' => $ext['num'],
|
||||
'content' => $activities_content,
|
||||
];
|
||||
return V(1,"成功",$data);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 礼盒列表
|
||||
*/
|
||||
public function daily_tasks_box_gift_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$gift_id = input('gift_id', '');
|
||||
$gift_name = input('gift_name', '');
|
||||
$gift_bag_id = input('gift_bag_id', 1);
|
||||
$gift_type = input("gift_type",'');
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择礼盒类型");
|
||||
}
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>2,'status'=>1])->select();
|
||||
foreach ($bag_list as &$v) {
|
||||
$v['default'] = $gift_bag_id == $v['id'] ? 1 : 0;
|
||||
}
|
||||
$where=[];
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
if($gift_id!==''){
|
||||
$where['foreign_id'] =$gift_id;
|
||||
}
|
||||
if($gift_name!==''){
|
||||
$where['name'] = ['like', '%'.$gift_name.'%'];
|
||||
}
|
||||
if($gift_type!==''){
|
||||
$where['type'] = $gift_type;
|
||||
}
|
||||
$count = db::name("vs_gift_bag_detail")->where($where)->count();
|
||||
$lists_data = db::name("vs_gift_bag_detail")->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
$bag_data = db::name("vs_gift_bag")->field('id,name,ext')->where(['id'=>$gift_bag_id])->find();
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['box_name'] = $bag_data['name'];
|
||||
$lists[$key]['gift_type'] = $value['type'];
|
||||
$lists[$key]['gift_type_str'] = $this->gift_type[$value['type']];
|
||||
if ($value['type'] == 2) {
|
||||
$lists[$key]['gift_id'] = $value['foreign_id'];
|
||||
$lists[$key]['gift_name'] = $value['name'];
|
||||
$gift_data = db::name('vs_gift')->where(['gid' => $value['foreign_id']])->find();
|
||||
$lists[$key]['base_image'] = $gift_data['base_image'];
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$lists[$key]['quantity_str'] = $value['quantity']."个";
|
||||
$lists[$key]['gift_price'] = $gift_data['gift_price'];
|
||||
}elseif ($value['type'] == 3){
|
||||
$lists[$key]['gift_id'] = $value['foreign_id'];
|
||||
$lists[$key]['gift_name'] = $value['name'];
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$value['foreign_id']])->find();
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
$lists[$key]['base_image'] = $gift['base_image'];
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$lists[$key]['quantity_str'] = $decorate_price['day']."天";
|
||||
$lists[$key]['gift_price'] = $decorate_price['price'];
|
||||
}else{
|
||||
$lists[$key]['gift_id'] = "--";
|
||||
$lists[$key]['gift_name'] = "--";
|
||||
$lists[$key]['base_image'] = "--";
|
||||
$lists[$key]['quantity'] = 0;
|
||||
$lists[$key]['quantity_str'] = "0";
|
||||
$lists[$key]['gift_price'] = $value['gold'];
|
||||
}
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
|
||||
}
|
||||
//统计
|
||||
$total_data = [];
|
||||
//抽奖次数总计
|
||||
$total_count = db::name("vs_gift_bag_receive_log")
|
||||
->where(['gift_bag_id'=>$gift_bag_id])
|
||||
->count();
|
||||
//抽奖收入总计
|
||||
$total_price = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id])
|
||||
->sum('bag_price');
|
||||
//今日抽奖总次数
|
||||
$today_total_count = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->count();
|
||||
//今日抽奖收入
|
||||
$today_total_price = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->sum('bag_price');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'bag_list' => $bag_list,
|
||||
'total_data' => [
|
||||
'total_count' => $total_count,
|
||||
'total_price' => $total_price,
|
||||
'today_total_count' => $today_total_count,
|
||||
'today_total_price' => $today_total_price,
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 礼盒开奖记录
|
||||
*/
|
||||
public function daily_tasks_box_gift_send_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$user_id = input('user_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', 1);
|
||||
$where = [];
|
||||
if($user_id){
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
}
|
||||
$count = db::name('vs_gift_bag_receive_log')->where($where)->count();
|
||||
$lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['user_id'] = $value['user_id'];
|
||||
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
||||
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
||||
$lists[$key]['money'] = $gift_bag['money'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 装扮列表
|
||||
*/
|
||||
public function decorate_list(){
|
||||
$decorate_list = db::name('vs_decorate_price')->alias('a')
|
||||
->field('a.id,a.did,b.type,a.day,a.price,b.title,b.base_image')
|
||||
->where('b.delete_time',0)
|
||||
->join('vs_decorate b','a.did = b.did')
|
||||
->select();
|
||||
$return_data = [];
|
||||
foreach ($decorate_list as $key => $value) {
|
||||
$return_data[$key]['id'] = $value['id'];
|
||||
$return_data[$key]['name'] = model('api/Decorate')->TypeArray[$value['type']].'-'.$value['day'].'天-'.$value['title'];
|
||||
$return_data[$key]['day'] = $value['day'];
|
||||
}
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
}
|
||||
}
|
||||
313
application/adminapi/controller/Admin.php
Normal file
313
application/adminapi/controller/Admin.php
Normal file
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\command\Menu;
|
||||
use app\admin\model\AuthGroup;
|
||||
use app\admin\model\AuthGroupAccess;
|
||||
use app\common\controller\adminApi;
|
||||
use fast\Random;
|
||||
use fast\Tree;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 管理员管理
|
||||
*
|
||||
* @icon fa fa-users
|
||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||
*/
|
||||
class Admin extends adminApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @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/Admin');
|
||||
$this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin());
|
||||
$this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin());
|
||||
|
||||
$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']);
|
||||
//如果发送的来源是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 V(1,"管理员列表", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* username
|
||||
* email
|
||||
* mobile
|
||||
* nickname
|
||||
* password
|
||||
* status
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->Post();
|
||||
if (empty($params)) {
|
||||
return V(0,"参数错误", []);
|
||||
}
|
||||
if (!Validate::is($params['password'], '\S{6,30}')) {
|
||||
return V(0,"密码长度必须在6-30位之间,不能包含空格", []);
|
||||
}
|
||||
$group = $params['group'];
|
||||
unset($params['group']);
|
||||
unset($params['__token__']);
|
||||
if ($params) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$params['salt'] = Random::alnum();
|
||||
$params['password'] = $this->auth->getEncryptPassword($params['password'], $params['salt']);
|
||||
$params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。
|
||||
$result = $this->model->save($params);
|
||||
if ($result === false) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
//过滤不允许的组别,避免越权
|
||||
$group = array_intersect($this->childrenGroupIds, $group);
|
||||
if (!$group) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
|
||||
$dataset = [];
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $this->model->id, 'group_id' => $value];
|
||||
}
|
||||
model('admin/AuthGroupAccess')->saveAll($dataset);
|
||||
Db::commit();
|
||||
return V(1,"添加成功", []);
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return V(0,"失败", []);
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post();
|
||||
$group = $params['group'];
|
||||
unset($params['group']);
|
||||
unset($params['__token__']);
|
||||
if ($params) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($params['password']) {
|
||||
if (!Validate::is($params['password'], '\S{6,30}')) {
|
||||
return V(0,"密码长度必须在6-30位之间,不能包含空格", []);
|
||||
}
|
||||
$params['salt'] = Random::alnum();
|
||||
$params['password'] = $this->auth->getEncryptPassword($params['password'], $params['salt']);
|
||||
} else {
|
||||
unset($params['password'], $params['salt']);
|
||||
}
|
||||
//这里需要针对username和email做唯一验证
|
||||
$adminValidate = \think\Loader::validate('admin/Admin');
|
||||
$adminValidate->rule([
|
||||
'username' => 'require|regex:\w{3,30}|unique:admin,username,' . $params['id'],
|
||||
'email' => 'require|email|unique:admin,email,' . $params['id'],
|
||||
'mobile' => 'regex:1[3-9]\d{9}|unique:admin,mobile,' . $params['id'],
|
||||
'password' => 'regex:\S{32}',
|
||||
]);
|
||||
$result = $this->model->save($params, $params['id']);
|
||||
if ($result === false) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
|
||||
// 先移除所有权限
|
||||
model('admin/AuthGroupAccess')->where('uid', $params['id'])->delete();
|
||||
|
||||
|
||||
// 过滤不允许的组别,避免越权
|
||||
$group = array_intersect($this->childrenGroupIds, $group);
|
||||
if (!$group) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
|
||||
$dataset = [];
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $params['id'], 'group_id' => $value];
|
||||
}
|
||||
model('admin/AuthGroupAccess')->saveAll($dataset);
|
||||
Db::commit();
|
||||
return V(1,"成功", []);
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
}
|
||||
return V(0,"参数错误!", []);
|
||||
}else{
|
||||
return V(0,"参数错误!", []);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 详情
|
||||
*
|
||||
*/
|
||||
public function detail($ids = ""){
|
||||
$id = $this->request->get('id');
|
||||
if (!$id) {
|
||||
return V(0,"未找到记录", []);
|
||||
}
|
||||
if (!in_array($id, $this->childrenAdminIds)) {
|
||||
return V(0,"你没有权限访问", []);
|
||||
}
|
||||
$data = $this->model->where('id',$id)->find();
|
||||
$grouplist = $this->auth->getGroups($id);
|
||||
$groupids = [];
|
||||
foreach ($grouplist as $k => $v) {
|
||||
$groupids[] = $v['id'];
|
||||
}
|
||||
$result = [];
|
||||
$result['row'] = $data;
|
||||
$result['groupids'] = $groupids;
|
||||
return V(1,"管理员详情", $result);
|
||||
}
|
||||
/*
|
||||
* 管理员状态修改
|
||||
*/
|
||||
public function changeStatus(){
|
||||
if (!$this->request->isPost()) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
$id = $this->request->post("id");
|
||||
if (empty($id)) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
if($id==1){
|
||||
return V(0,"超级管理员不能修改状态", []);
|
||||
}
|
||||
$status = $this->request->post("status");
|
||||
$data = [];
|
||||
$data['status'] = $status;
|
||||
$res = Db::name("admin")->where("id",$id)->update($data);
|
||||
if ($res) {
|
||||
return V(1,"成功", []);
|
||||
}else{
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
$ids = $ids ? $ids : $this->request->post("id");
|
||||
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) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$this->model->destroy($deleteIds);
|
||||
model('admin/AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete();
|
||||
Db::commit();
|
||||
return V(1,"成功", []);
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
}
|
||||
92
application/adminapi/controller/Adminlog.php
Normal file
92
application/adminapi/controller/Adminlog.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AuthGroup;
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 管理员日志
|
||||
*
|
||||
* @icon
|
||||
* @remark 管理员可以查看自己所拥有的权限的管理员日志
|
||||
*/
|
||||
class Adminlog extends adminApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\admin\model\AdminLog
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $childrenAdminIds = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('admin/AdminLog');
|
||||
$this->childrenAdminIds = $this->auth->getChildrenAdminIds(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_username = input('search_username', '');
|
||||
$search_title = input('search_title', '');
|
||||
$search_stime = input('search_time', '');
|
||||
$search_etime = input('search_etime', '');
|
||||
$where = [];
|
||||
if ($search_username) {
|
||||
$where['username'] = ['like', '%' . $search_username . '%'];
|
||||
}
|
||||
if ($search_title) {
|
||||
$where['title'] = ['like', '%' . $search_title . '%'];
|
||||
}
|
||||
if ($search_stime) {
|
||||
$where['createtime'] = ['>=', strtotime($search_stime)];
|
||||
}
|
||||
if ($search_etime) {
|
||||
$where['createtime'] = ['<=', strtotime($search_etime.' 23:59:59')];
|
||||
}
|
||||
if(!empty($search_stime) && !empty($search_etime)){
|
||||
$where['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime.' 23:59:59')]];
|
||||
}
|
||||
|
||||
$list_data = $this->model->where($where)->where('admin_id', 'in', $this->childrenAdminIds)->order('createtime', 'desc')->paginate($page_limit, false, ['page' => $page]);
|
||||
foreach ($list_data as &$v) {
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $list_data->total(),
|
||||
'lists' => $list_data->items(),
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail($id=0)
|
||||
{
|
||||
$id = input('id', 0);
|
||||
$row = $this->model->get(['id' => $id]);
|
||||
if (!$row) {
|
||||
return V(0,"日志不存在", null);
|
||||
}
|
||||
if (!$this->auth->isSuperAdmin()) {
|
||||
if (!$row['admin_id'] || !in_array($row['admin_id'], $this->childrenAdminIds)) {
|
||||
return V(0,"你没有权限访问", null);
|
||||
}
|
||||
}
|
||||
return V(1,"成功", $row->toArray());
|
||||
}
|
||||
|
||||
}
|
||||
219
application/adminapi/controller/Banner.php
Normal file
219
application/adminapi/controller/Banner.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
|
||||
/**
|
||||
* 广告位管理
|
||||
* @internal
|
||||
*/
|
||||
class Banner extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['banner_position_lists'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
/**
|
||||
* 广告管理列表
|
||||
*/
|
||||
public function banner_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_name = input('search_name', '');
|
||||
$show_type = input('show_type', '');
|
||||
$etime = input('etime', '');
|
||||
$where = [];
|
||||
if($search_name){
|
||||
$where['name'] = ['like', '%'.$search_name.'%'];
|
||||
}
|
||||
if($show_type){
|
||||
$where['show_type'] = $show_type;
|
||||
}
|
||||
if($etime){
|
||||
$where['etime'] = ['>', strtotime($etime)];
|
||||
}
|
||||
$where['delete_time'] = 0;
|
||||
$count = db('vs_banner')->where($where)->count();
|
||||
$lists = db('vs_banner')->where($where)->order('sort id desc')->page($page, $page_limit)->select();
|
||||
$return_list = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
$return_list[$key]['id'] = $value['bid'];
|
||||
$return_list[$key]['image'] = $value['image'];
|
||||
$return_list[$key]['name'] = $value['name'];
|
||||
$return_list[$key]['show_type'] = $value['show_type'];
|
||||
$return_list[$key]['show_type_str'] = model('api/Banner')->ShowType[$value['show_type']]?? '';
|
||||
$return_list[$key]['stime'] = date('Y-m-d H:i:s', $value['stime']);
|
||||
$return_list[$key]['etime'] = date('Y-m-d H:i:s', $value['etime']);
|
||||
$return_list[$key]['show_status'] = $value['show_status'];
|
||||
$return_list[$key]['clicks'] = $value['clicks'];
|
||||
$return_list[$key]['type'] = $value['type'];
|
||||
$return_list[$key]['type_str'] = model('api/Banner')->Type[$value['type']]?? '';
|
||||
$return_list[$key]['content'] = $value['content'] ?? "";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $return_list,
|
||||
'show_type_array' => model('api/Banner')->ShowType
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
}
|
||||
/*
|
||||
* 广告位置列表
|
||||
*/
|
||||
public function banner_position_lists(){
|
||||
$show_type = model('api/Banner')->ShowType;
|
||||
$i=0;
|
||||
$data =[];
|
||||
foreach ($show_type as $key => $value) {
|
||||
$data[$i]['id'] = $key;
|
||||
$data[$i]['name'] = $value;
|
||||
$i++;
|
||||
}
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加广告
|
||||
*/
|
||||
public function add_banner(){
|
||||
$name = input('name', '');
|
||||
$show_type = input('show_type', '');
|
||||
$type = input('type', '');
|
||||
$aid = input('aid', '');
|
||||
$url = input('url', '');
|
||||
$stime = input('stime', 0);
|
||||
$etime = input('etime', 0);
|
||||
$image = input('image', '');
|
||||
$show_status = input('show_status', 1);
|
||||
$remarks = input('remarks', '');
|
||||
$content = input('content', '');
|
||||
$stime = $stime ? strtotime($stime):0;
|
||||
$etime = $stime ? strtotime($etime):0;
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'show_type' => $show_type,
|
||||
'type' => $type,
|
||||
'aid' => $aid,
|
||||
'url' => $url,
|
||||
'stime' => $stime,
|
||||
'etime' => $etime,
|
||||
'image' => $image,
|
||||
'show_status' => $show_status,
|
||||
'remarks' => $remarks,
|
||||
'content' => $content,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$id = db::name('vs_banner')->insertGetId($data);
|
||||
if(!$id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功",['id'=>$id]);
|
||||
}
|
||||
/*
|
||||
* 广告详情
|
||||
*/
|
||||
public function banner_info(){
|
||||
$id = input('id', '');
|
||||
$info = db::name('vs_banner')->where('bid', $id)->find();
|
||||
if(!$info){
|
||||
return V(0,"数据不存在");
|
||||
}
|
||||
$info['stime'] = date('Y-m-d H:i:s', $info['stime']);
|
||||
$info['etime'] = date('Y-m-d H:i:s', $info['etime']);
|
||||
$info['show_type_array'] =model('api/Banner')->ShowType;
|
||||
return V(1,"成功", $info);
|
||||
}
|
||||
/*
|
||||
* 广告编辑
|
||||
*/
|
||||
public function banner_edit(){
|
||||
$id = input('id', '');
|
||||
$name = input('name', '');
|
||||
$show_type = input('show_type', '');
|
||||
$type = input('type', '');
|
||||
$aid = input('aid', '');
|
||||
$url = input('url', '');
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$image = input('image', '');
|
||||
$show_status = input('show_status', '');
|
||||
$remarks = input('remarks', '');
|
||||
$content = input('content', '');
|
||||
if (!$id){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
|
||||
if($name!=""){
|
||||
$data['name'] = $name;
|
||||
}
|
||||
if($show_type!=""){
|
||||
$data['show_type'] = $show_type;
|
||||
}
|
||||
if($stime!=""){
|
||||
$data['stime'] = strtotime($stime);
|
||||
}
|
||||
if($etime!=""){
|
||||
$data['etime'] = strtotime($etime);
|
||||
}
|
||||
if($remarks!=""){
|
||||
$data['remarks'] = $remarks;
|
||||
}
|
||||
if($image!=""){
|
||||
$data['image'] = $image;
|
||||
}
|
||||
if($url!=""){
|
||||
$data['url'] = $url;
|
||||
}
|
||||
if($type!=""){
|
||||
$data['type'] = $type;
|
||||
}
|
||||
if($aid!=""){
|
||||
//判断是数字
|
||||
if(!is_numeric($aid)){
|
||||
return V(0,"参数错误,对应跳转应为ID");
|
||||
}
|
||||
$data['aid'] = $aid;
|
||||
}
|
||||
if($show_status!=""){
|
||||
$data['show_status'] = $show_status;
|
||||
}
|
||||
if($content!=""){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
$res = Db::name('vs_banner')->where('bid',$id)->update($data);
|
||||
if(!$res){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
|
||||
}
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function banner_delete(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$res = db::name('vs_banner')->where(['bid'=>$id])->update(['delete_time'=>time()]);
|
||||
if(!$res){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
405
application/adminapi/controller/BlindBox.php
Normal file
405
application/adminapi/controller/BlindBox.php
Normal file
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 盲盒
|
||||
* @internal
|
||||
*/
|
||||
class BlindBox extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['blind_box_type','blind_box_gifts'];
|
||||
|
||||
protected $table = 'vs_gift_bag_detail';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 盲盒列表
|
||||
*/
|
||||
public function blind_box_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$gift_id = input('gift_id', '');
|
||||
$gift_name = input('gift_name', '');
|
||||
$gift_bag_id = input('gift_bag_id', 7);
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择盲盒类型");
|
||||
}
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>4,'status'=>1])->select();
|
||||
foreach ($bag_list as &$v) {
|
||||
$v['default'] = $gift_bag_id == $v['id'] ? 1 : 0;
|
||||
}
|
||||
$where=[];
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
if($gift_id!==''){
|
||||
$where['foreign_id'] =$gift_id;
|
||||
}
|
||||
if($gift_name!==''){
|
||||
$where['name'] = ['like', '%'.$gift_name.'%'];
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists_data = db::name($this->table)->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['gift_id'] = $value['foreign_id'];
|
||||
$lists[$key]['gift_name'] = $value['name'];
|
||||
$gift_data = db::name('vs_gift')->where(['gid'=>$value['foreign_id']])->find();
|
||||
$lists[$key]['base_image'] = $gift_data['base_image'];
|
||||
$lists[$key]['gift_price'] = $gift_data['gift_price'];
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$lists[$key]['remaining_number'] = $value['remaining_number'];
|
||||
$lists[$key]['is_public_screen'] = $gift_data['is_public_screen'];
|
||||
$lists[$key]['is_public_server'] = $gift_data['is_public_server'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
|
||||
}
|
||||
//统计
|
||||
$total_data = [];
|
||||
//每期总次数
|
||||
$total_count = db::name($this->table)->where(['gift_bag_id'=>$gift_bag_id])->sum('quantity');
|
||||
//每期总礼物价值
|
||||
$total_price_data = db::name($this->table)->alias('a')
|
||||
->field('a.quantity,b.gift_price,b.gift_price * a.quantity as total_price')
|
||||
->join('vs_gift b','a.foreign_id = b.gid')
|
||||
->where(['a.gift_bag_id'=>$gift_bag_id])
|
||||
->select();
|
||||
$total_price = array_sum(array_column($total_price_data,'total_price'));
|
||||
//每期总抽奖花费(支出)
|
||||
$bag_data = db::name("vs_gift_bag")->field('id,name,ext')->where(['id'=>$gift_bag_id])->find();
|
||||
$ext = json_decode($bag_data['ext'],true);
|
||||
$c_gift_id = $ext['gift_id'];
|
||||
$c_gift_data = db::name('vs_gift')->where(['gid'=>$c_gift_id])->find();
|
||||
$gift_price = $c_gift_data['gift_price']??0;
|
||||
$total_cost = $total_count * $gift_price;
|
||||
//每期统计(收入/支出)
|
||||
if($total_cost==0 || $total_price==0){
|
||||
$profit_loss_ratio = 0;
|
||||
}else{
|
||||
$profit_loss_ratio =round(($total_price / $total_cost ),2);
|
||||
}
|
||||
//今天抽奖人数
|
||||
$today_count_user = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->group('user_id')
|
||||
->count();
|
||||
//今日抽奖总次数
|
||||
$today_total_count = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->count();
|
||||
//今日抽奖收入
|
||||
$today_total_price = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->sum('bag_price');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'bag_list' => $bag_list,
|
||||
'total_data' => [
|
||||
'total_count' => $total_count,
|
||||
'total_price' => $total_price,
|
||||
'total_cost' => $total_cost,
|
||||
'profit_loss_ratio' => $profit_loss_ratio,
|
||||
'today_count_user' => $today_count_user,
|
||||
'today_total_count' => $today_total_count,
|
||||
'today_total_price' => $today_total_price,
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 添加
|
||||
*/
|
||||
public function blind_box_add(){
|
||||
$gift_id = input('gift_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$quantity = input('quantity', 0);
|
||||
if(empty($gift_id)){
|
||||
return V(0,"请选择礼物");
|
||||
}
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择盲盒类型");
|
||||
}
|
||||
$bag_gift = db::name($this->table)->where(['foreign_id'=>$gift_id,'gift_bag_id'=>$gift_bag_id])->find();
|
||||
if(!empty($bag_gift)){
|
||||
return V(0,"该礼物已添加");
|
||||
}
|
||||
$data = [];
|
||||
$gift = db::name('vs_gift')->where(['gid'=>$gift_id])->find();
|
||||
if(empty($gift)){
|
||||
return V(0,"礼物不存在");
|
||||
}
|
||||
$data['gift_bag_id'] = $gift_bag_id;
|
||||
$data['foreign_id'] = $gift_id;
|
||||
$data['name'] = $gift['gift_name'];
|
||||
$data['type'] = 2;
|
||||
$data['quantity'] = $quantity;
|
||||
$data['remaining_number'] = $quantity;
|
||||
$data['createtime'] = time();
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 礼物列表
|
||||
*/
|
||||
public function blind_box_gifts(){
|
||||
$type = input('type', 2);
|
||||
$list = db::name("vs_gift")->where(['type'=>$type,'delete_time'=>0])->order('sort','asc')->select();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['gid'] = $v['gid'];
|
||||
$list_data[$k]['gift_name'] = $v['gift_name'];
|
||||
}
|
||||
return V(1,"成功",$list_data);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 编辑
|
||||
*/
|
||||
public function blind_box_edit(){
|
||||
$id = input('id', '');
|
||||
$quantity = input('quantity', 0);
|
||||
if(empty($id)){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$gift_bag = db::name($this->table)->where('id',$id)->find();
|
||||
// if($gift_bag['remaining_number']>0){
|
||||
// return V(0,"该礼包已开售");
|
||||
// }
|
||||
$data = [];
|
||||
$data['quantity'] = $quantity;
|
||||
$data['remaining_number'] = $quantity;
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function blind_box_del(){
|
||||
$id = input('id', '');
|
||||
if(empty($id)){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$res = db::name($this->table)->where(['id'=>$id])->delete();
|
||||
if(!$res){
|
||||
return V(0,"失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 重置设置
|
||||
*/
|
||||
public function reset_set(){
|
||||
$gift_bag_id = input('gift_bag_id', 0);
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择盲盒类型");
|
||||
}
|
||||
$gift_bag_detail = db::name($this->table)->where(['gift_bag_id'=>$gift_bag_id])->select();
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
$bag_data = db::name($this->table)->where(['id'=>$v['id']])->update(['remaining_number'=>$v['quantity']]);
|
||||
}
|
||||
if($bag_data){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 设置规则
|
||||
*/
|
||||
public function set_rule(){
|
||||
$gift_bag_id = input('gift_bag_id', 7);
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择盲盒类型");
|
||||
}
|
||||
$gift_id = input('gift_id', '');
|
||||
$description = input('description', '');
|
||||
$introd =$_POST['introd']??"";
|
||||
if(empty($gift_id)){
|
||||
return V(0,"请配置礼物");
|
||||
}
|
||||
$gift = db('vs_gift')->where('gid',$gift_id)->find();
|
||||
if(empty($gift)){
|
||||
return V(0,"请配置礼物");
|
||||
}
|
||||
$ext =[
|
||||
'gift_id' => $gift_id,
|
||||
'description' => $description,
|
||||
'introd' => $introd,
|
||||
];
|
||||
$ext = json_encode($ext);
|
||||
$res = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->update(['ext'=>$ext]);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 规则详情
|
||||
*/
|
||||
public function rule_detail(){
|
||||
$gift_bag_id = input('gift_bag_id');
|
||||
$gift_bag = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->find();
|
||||
$ext_data = json_decode($gift_bag['ext'],true);
|
||||
$ext =[
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'gift_bag_name' => $gift_bag['name'],
|
||||
'gift_id' => $ext_data['gift_id'],
|
||||
'description' => $ext_data['description'],
|
||||
'introd' => stripcslashes($ext_data['introd']),
|
||||
];
|
||||
if($gift_bag){
|
||||
return V(1,"成功",$ext);
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 开奖记录
|
||||
*/
|
||||
public function open_record(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$gift_id = input('gift_id', '');
|
||||
$user_id = input('user_id', '');
|
||||
$room_id = input('room_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$periods = input('periods', '');
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$where = [];
|
||||
if($gift_id){
|
||||
$where['gift_id'] = $gift_id;
|
||||
}
|
||||
if($user_id){
|
||||
$user_id = db::name('user')->where('user_code', $user_id)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($room_id){
|
||||
$room_id = db::name('vs_room')->where('room_number', $room_id)->value('id');
|
||||
$where['room_id'] = $room_id;
|
||||
}
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
}
|
||||
if($periods){
|
||||
$where['periods'] = $periods;
|
||||
}
|
||||
if($stime!==""){
|
||||
$where['createtime'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if($etime!==""){
|
||||
$where['createtime'] = ['<=', strtotime($etime.'23:59:59')];
|
||||
}
|
||||
if($stime!=="" && $etime!==""){
|
||||
$where['createtime'] = ['between', [strtotime($stime), strtotime($etime.'23:59:59')]];
|
||||
}
|
||||
$count = db::name('vs_gift_bag_receive_log')->where($where)->count();
|
||||
$lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['user_id'] = $value['user_id'];
|
||||
$user = db::name('user')->where('id',$value['user_id'])->find();
|
||||
$lists[$key]['user_name'] = "";
|
||||
if($user){
|
||||
$lists[$key]['user_name'] = $user['user_code'].'-'.$user['nickname'];
|
||||
}
|
||||
|
||||
$lists[$key]['gift_user_id'] = $value['gift_user_id'];
|
||||
$gift_user = db::name('user')->where('id',$value['gift_user_id'])->find();
|
||||
$lists[$key]['gift_user_name'] = "";
|
||||
if($gift_user){
|
||||
$lists[$key]['gift_user_name'] = $gift_user['user_code'].'-'.$gift_user['nickname'];
|
||||
}
|
||||
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
||||
$lists[$key]['periods'] = $value['periods'];
|
||||
$room = db::name('vs_room')->where('id',$value['room_id'])->find();
|
||||
$lists[$key]['room_name'] = "";
|
||||
if($room){
|
||||
$lists[$key]['room_name'] = $room['room_number']."-".$room['room_name'];
|
||||
}
|
||||
$lists[$key]['bag_price'] = $value['bag_price'];
|
||||
$lists[$key]['gift_id'] = $value['gift_id'];
|
||||
$lists[$key]['gift_name'] = db::name('vs_gift')->where('gid',$value['gift_id'])->value('gift_name');
|
||||
$lists[$key]['gift_price'] = $value['gift_price'];
|
||||
$lists[$key]['gift_num'] = $value['num'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
//总抽奖次数
|
||||
$total = $count;
|
||||
//总抽奖金额(支出)
|
||||
$total_money = db::name('vs_gift_bag_receive_log')->where($where)->sum('bag_price');
|
||||
//总礼物价值(收入)
|
||||
$total_gift_money = db::name('vs_gift_bag_receive_log')->where($where)->sum('gift_price');
|
||||
//统计
|
||||
if($total_gift_money==0 || $total_money==0){
|
||||
$ratio = 0;
|
||||
}else{
|
||||
$ratio =round(($total_gift_money / $total_money),3);
|
||||
}
|
||||
//盈亏
|
||||
$profit_loss = $total_gift_money - $total_money;
|
||||
if($profit_loss==0 || $total_money==0){
|
||||
$profit_loss_ratio = 0;
|
||||
}else{
|
||||
// 盈亏比
|
||||
$profit_loss_ratio = round(($profit_loss / $total_money),3);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total_data' => [
|
||||
'total' => $total,
|
||||
'total_money' => $total_money,
|
||||
'total_gift_money' => $total_gift_money,
|
||||
'ratio' => $ratio,
|
||||
'profit_loss' => $profit_loss,
|
||||
'profit_loss_ratio' => $profit_loss_ratio,
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 礼包列表
|
||||
*/
|
||||
public function blind_box_type(){
|
||||
$activities_id = input('activities_id', 4);
|
||||
if($activities_id == ""){
|
||||
$activities_id = 4;
|
||||
}
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id,'status'=>1])->select();
|
||||
return V(1,"成功", $bag_list);
|
||||
}
|
||||
|
||||
}
|
||||
125
application/adminapi/controller/CanRecharge.php
Normal file
125
application/adminapi/controller/CanRecharge.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 可选充值金额表
|
||||
* @internal
|
||||
*/
|
||||
class CanRecharge extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'vs_can_recharge';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function recharge_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where = [];
|
||||
$where['delete_time'] = 0;
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists = db::name($this->table)->where($where)->order('money asc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['admin'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function recharge_add(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$money = input('money', '');
|
||||
$coins = input('coins', '');
|
||||
$status = input('status', 1);
|
||||
if(empty($money) || empty($coins)){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = [
|
||||
'money' => $money,
|
||||
'coins' => $coins,
|
||||
'status' => $status,
|
||||
'admin_id' => $admin_id,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if(!$res){
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
return V(1, "添加成功");
|
||||
}
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public function recharge_edit(){
|
||||
$money = input('money', '');
|
||||
$coins = input('coins', '');
|
||||
$status = input('status', 1);
|
||||
$id = input('id', '');
|
||||
if($money){
|
||||
$data['money'] = $money;
|
||||
}
|
||||
if($coins){
|
||||
$data['coins'] = $coins;
|
||||
}
|
||||
if($status){
|
||||
$data['status'] = $status;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name($this->table)->where(['crid'=>$id])->update($data);
|
||||
if(!$res){
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1, "修改成功");
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function recharge_del(){
|
||||
$id = input('id', '');
|
||||
$res = db::name($this->table)->where(['crid'=>$id])->update(['delete_time'=>time()]);
|
||||
if(!$res){
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
return V(1, "删除成功");
|
||||
}
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
public function recharge_status(){
|
||||
$id = input('id', '');
|
||||
$status = input('status', '');
|
||||
$res = db::name($this->table)->where(['crid'=>$id])->update(['status'=>$status]);
|
||||
if(!$res){
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1, "修改成功");
|
||||
}
|
||||
|
||||
}
|
||||
396
application/adminapi/controller/Decorate.php
Normal file
396
application/adminapi/controller/Decorate.php
Normal file
@@ -0,0 +1,396 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 装扮
|
||||
* @internal
|
||||
*/
|
||||
class Decorate extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'vs_decorate';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 装扮列表
|
||||
*/
|
||||
public function decorate_lists(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$name = input('name', '');
|
||||
$type = input('type', '');
|
||||
$where = ['delete_time'=>0];
|
||||
if($name){
|
||||
$where['name'] = ['like', '%'.$name.'%'];
|
||||
}
|
||||
if($type){
|
||||
$where['type'] = $type;
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists = db::name($this->table)->where($where)->order('did desc')->page($page, $page_limit)->select();
|
||||
$return_list = [];
|
||||
foreach ($lists as $k=>$v){
|
||||
$return_list[$k]['id'] = $v['did'];
|
||||
$return_list[$k]['name'] = $v['title'];
|
||||
$return_list[$k]['type'] = $v['type'];
|
||||
$return_list[$k]['type_str'] = model('api/Decorate')->TypeArray[$v['type']];
|
||||
$return_list[$k]['base_image'] = $v['base_image'];
|
||||
$return_list[$k]['file_type'] = $v['file_type'];
|
||||
$return_list[$k]['file_type_str'] = $v['file_type'] ? "SVGA" : "MP4";
|
||||
$return_list[$k]['play_image'] = $v['play_image'];
|
||||
$return_list[$k]['show_status'] = $v['show_status'];
|
||||
$return_list[$k]['is_buy'] = $v['is_buy'];
|
||||
$return_list[$k]['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$return_list[$k]['admin_name'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $return_list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加装扮
|
||||
*
|
||||
*/
|
||||
public function add_decorate(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$title = input('title', '');
|
||||
$type = input('type', '');
|
||||
$show_status = input('show_status', 1);
|
||||
$is_buy = input('is_buy', 1);
|
||||
$base_image = input('base_image', '');
|
||||
$file_type = input('file_type', 2);
|
||||
$play_image = input('play_image', '');
|
||||
//靓号
|
||||
$special_num = input('special_num', '');
|
||||
if($title==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
if($type==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'type' => $type,
|
||||
'show_status' => $show_status,
|
||||
'is_buy' => $is_buy,
|
||||
'base_image' => $base_image,
|
||||
'file_type' => $file_type,
|
||||
'play_image' => $play_image,
|
||||
'special_num' => $special_num,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
'admin_id' => $admin_id
|
||||
];
|
||||
$id = db::name($this->table)->insertGetId($data);
|
||||
if(!$id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功",['id'=>$id]);
|
||||
|
||||
}
|
||||
/*
|
||||
* 装扮详情
|
||||
*/
|
||||
public function decorate_info(){
|
||||
$did = input('id', '');
|
||||
if($did == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$decorate_data = db::name($this->table)->where(['did'=>$did])->find();
|
||||
if(!$decorate_data){
|
||||
return V(0,"装扮不存在");
|
||||
}
|
||||
return V(1,"成功", $decorate_data);
|
||||
}
|
||||
/*
|
||||
* 修改装扮
|
||||
*/
|
||||
public function edit_decorate(){
|
||||
$did = input('id', '');
|
||||
if($did == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$title = input('title', '');
|
||||
$type = input('type', '');
|
||||
$show_status = input('show_status', 1);
|
||||
$is_buy = input('is_buy', 1);
|
||||
$base_image = input('base_image', '');
|
||||
$file_type = input('file_type', 2);
|
||||
$play_image = input('play_image', '');
|
||||
$special_num = input('special_num', '');
|
||||
$data = [];
|
||||
if($title!=""){
|
||||
$data['title'] = $title;
|
||||
}
|
||||
if($type!=""){
|
||||
$data['type'] = $type;
|
||||
}
|
||||
if($show_status!=""){
|
||||
$data['show_status'] = $show_status;
|
||||
}
|
||||
if($is_buy!=""){
|
||||
$data['is_buy'] = $is_buy;
|
||||
}
|
||||
if($base_image!=""){
|
||||
$data['base_image'] = $base_image;
|
||||
}
|
||||
if($file_type!=""){
|
||||
$data['file_type'] = $file_type;
|
||||
}
|
||||
if($play_image!=""){
|
||||
$data['play_image'] = $play_image;
|
||||
}
|
||||
if($special_num!=""){
|
||||
$data['special_num'] = $special_num;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name($this->table)->where(['did'=>$did])->update($data);
|
||||
if(!$res){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 道具类型
|
||||
*/
|
||||
public function type_array(){
|
||||
$list = model('api/Decorate')->TypeArray;
|
||||
$type_array = [];
|
||||
$i=0;
|
||||
foreach ($list as $key => $value) {
|
||||
$type_array[$i]['id'] = $key;
|
||||
$type_array[$i]['name'] = $value;
|
||||
$i++;
|
||||
}
|
||||
return V(1,"成功", $type_array);
|
||||
}
|
||||
/*
|
||||
* 删除装扮
|
||||
*/
|
||||
public function delete_decorate(){
|
||||
$did = input('id', '');
|
||||
if($did == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$res = db::name($this->table)->where(['did'=>$did])->update(['delete_time'=>time()]);
|
||||
if(!$res){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 价格设置列表
|
||||
*/
|
||||
public function price_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$where['is_delete'] =1;
|
||||
$where['did'] = input('did', '');
|
||||
if($where['did']==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
$count = db::name("vs_decorate_price")->where($where)->count();
|
||||
$lists = db::name("vs_decorate_price")->where($where)->order('id desc')->page($page, $page_limit)->select();
|
||||
$return_list = [];
|
||||
foreach ($lists as $k=>$v){
|
||||
$return_list[$k]['id'] = $v['id'];
|
||||
$return_list[$k]['day'] = $v['day'];
|
||||
$return_list[$k]['original_price'] = $v['original_price'];
|
||||
$return_list[$k]['price'] = $v['price'];
|
||||
$return_list[$k]['discount'] = $v['discount'];
|
||||
$return_list[$k]['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$return_list[$k]['admin_name'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $return_list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/**
|
||||
* 添加价格设置
|
||||
*/
|
||||
public function add_price(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$did = input('did', '');
|
||||
$day = input('day', '');
|
||||
$original_price = input('original_price', '');
|
||||
$price = input('price', '');
|
||||
if($did==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
if($day==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
if($original_price==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
if($price==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
$decorate_data = db::name($this->table)->where(['did'=>$did,'day'=>$day])->find();
|
||||
if($decorate_data){
|
||||
return V(0,"该价格已存在");
|
||||
}
|
||||
//计算折扣取整
|
||||
$discount = round($price/$original_price, 2)*10;
|
||||
$data = [
|
||||
'did' => $did,
|
||||
'day' => $day,
|
||||
'original_price' => $original_price,
|
||||
'price' => $price,
|
||||
'discount' => $discount,
|
||||
'createtime' => time(),
|
||||
'admin_id' => $admin_id
|
||||
];
|
||||
$id = db::name('vs_decorate_price')->insertGetId($data);
|
||||
if(!$id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功",['id'=>$id]);
|
||||
}
|
||||
/*
|
||||
* 修改价格设置
|
||||
*/
|
||||
public function edit_price(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$day = input('day', '');
|
||||
$original_price = input('original_price', '');
|
||||
$price = input('price', '');
|
||||
$discount = round($price/$original_price, 2)*10;;
|
||||
$data = [
|
||||
'day' => $day,
|
||||
'original_price' => $original_price,
|
||||
'price' => $price,
|
||||
'discount' => $discount,
|
||||
'updatetime' => time()
|
||||
];
|
||||
$res = db::name('vs_decorate_price')->where(['id'=>$id])->update($data);
|
||||
if(!$res){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 删除价格设置
|
||||
*/
|
||||
public function delete_price(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$res = db::name('vs_decorate_price')->where(['id'=>$id])->delete();
|
||||
if(!$res){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 用户装扮列表
|
||||
*/
|
||||
public function user_decorate_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$user_id = input('user_id', '');
|
||||
$did = input('did', '');
|
||||
$type = input('type', '');
|
||||
$where = [];
|
||||
if($user_id!=""){
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($did!=""){
|
||||
$where['did'] = $did;
|
||||
}
|
||||
if($type!=""){
|
||||
$where['type'] = $type;
|
||||
}
|
||||
$count = db::name("vs_user_decorate")->where($where)->count();
|
||||
$lists = db::name("vs_user_decorate")->where($where)->order('udid desc')->page($page, $page_limit)->select();
|
||||
$return_list = [];
|
||||
foreach ($lists as $k=>$v){
|
||||
$return_list[$k]['id'] = $v['udid'];
|
||||
$return_list[$k]['user_name'] = $v['user_id']."-".db::name('user')->where(['id'=>$v['user_id']])->value('nickname');
|
||||
$return_list[$k]['type'] = model('api/Decorate')->TypeArray[$v['type']];
|
||||
if($v['type'] >= 6){
|
||||
$return_list[$k]['name'] = $v['special_num'];
|
||||
|
||||
}else{
|
||||
$return_list[$k]['name'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('title');
|
||||
}
|
||||
$return_list[$k]['base_image'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('base_image');
|
||||
$return_list[$k]['is_using'] = $v['is_using'];
|
||||
$return_list[$k]['is_using_str'] = $v['is_using']==1?"使用中":"未使用";
|
||||
if($v['is_perpetual']==1){
|
||||
$return_list[$k]['end_time'] = "永久";
|
||||
}else{
|
||||
$return_list[$k]['end_time'] = date('Y-m-d H:i:s', $v['end_time']);
|
||||
}
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $return_list,
|
||||
'type_array' => model('api/Decorate')->TypeArray
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 赠送装扮
|
||||
*/
|
||||
public function give_decorate(){
|
||||
$user_id = input('user_id', '');
|
||||
$decorate_id = input('decorate_id', '');
|
||||
$day = input('day', '');
|
||||
$user = db::name('user')->where(['id'=>$user_id])->find();
|
||||
if(!$user){
|
||||
return V(0,"用户不存在");
|
||||
}
|
||||
$decorate = db::name('vs_decorate')->where(['did'=>$decorate_id])->find();
|
||||
if(!$decorate){
|
||||
return V(0,"装扮不存在");
|
||||
}
|
||||
$decorate_price = db::name('vs_decorate_price')->where(['did'=>$decorate_id,'day'=>$day,'is_delete'=>1])->find();
|
||||
if(!$decorate_price){
|
||||
return V(0,"该装扮天数不存在");
|
||||
}
|
||||
$result = model('api/Decorate')->pay_decorate($user_id,$decorate_id,$day,2);
|
||||
if($result['code'] == 1){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,$result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
265
application/adminapi/controller/Gift.php
Normal file
265
application/adminapi/controller/Gift.php
Normal file
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 礼物
|
||||
* @internal
|
||||
*/
|
||||
class Gift extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['gift_type_lists'];
|
||||
|
||||
protected $table = 'vs_gift';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
/*
|
||||
* 一级分类列表
|
||||
*/
|
||||
|
||||
public function gift_type_lists(){
|
||||
$type = input('type', 1);
|
||||
$giftType = [];
|
||||
if($type == 1){
|
||||
$giftTypeArray = model('Gift')->giftType;
|
||||
$i=0;
|
||||
foreach ($giftTypeArray as $key => $value) {
|
||||
$giftType[$i]['id'] = $key;
|
||||
$giftType[$i]['name'] = $value;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if($type == 2){
|
||||
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->order("sort asc,id desc")->select();
|
||||
foreach ($giftTypeData as $key => $value) {
|
||||
$giftType[$key]['id'] = $value['id'];
|
||||
$giftType[$key]['name'] = $value['name'];
|
||||
}
|
||||
}
|
||||
return V(1,"成功", $giftType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼物列表
|
||||
*/
|
||||
public function gift_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_gift_id = input('search_gift_id', '');
|
||||
$search_gift_name = input('search_gift_name', '');
|
||||
$search_gift_type = input('search_gift_type', '');
|
||||
$search_gift_label = input('search_gift_label', '');
|
||||
$where=[];
|
||||
$where['delete_time'] = 0;
|
||||
if($search_gift_id!==''){
|
||||
$where['gid'] =$search_gift_id;
|
||||
}
|
||||
if($search_gift_type!==''){
|
||||
$where['type'] =$search_gift_type;
|
||||
}
|
||||
if($search_gift_label!==''){
|
||||
$where['label'] =$search_gift_label;
|
||||
}
|
||||
if($search_gift_name!==''){
|
||||
$where['gift_name'] = ['like', '%'.$search_gift_name.'%'];
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists_data = db::name($this->table)->where($where)->page($page, $page_limit)->order("sort,gid desc")->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['gid'] = $value['gid'];
|
||||
$lists[$key]['gift_name'] = $value['gift_name'];
|
||||
$lists[$key]['type'] = model('Gift')->giftType[$value['type']];
|
||||
$lists[$key]['label'] = db::name('vs_gift_label')->where('id', $value['label'])->value('name');
|
||||
$lists[$key]['base_image'] = $value['base_image'];
|
||||
$lists[$key]['gift_price'] = $value['gift_price'];
|
||||
$lists[$key]['sort'] = $value['sort'];
|
||||
$lists[$key]['is_public_screen'] = $value['is_public_screen'];
|
||||
$lists[$key]['is_public_server'] = $value['is_public_server'];
|
||||
$lists[$key]['is_show'] = $value['is_show'];
|
||||
$lists[$key]['is_can_buy'] = $value['is_can_buy'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加礼物
|
||||
*/
|
||||
public function add_gift(){
|
||||
$gift_name = input('gift_name', '');
|
||||
$type = input('type', '');
|
||||
$label = input('label', '');
|
||||
$gift_price = input('gift_price', '');
|
||||
$base_image = input('base_image', '');
|
||||
$file_type = input('file_type', 2);
|
||||
$play_image = input('play_image', '');
|
||||
$gift_type = input('gift_type', 1);
|
||||
$is_public_screen = input('is_public_screen', 1);
|
||||
$is_public_server = input('is_public_server', 1);
|
||||
$is_can_buy = input('is_can_buy', 1);
|
||||
$is_show = input('is_show', 1);
|
||||
$sort = input('sort', 0);
|
||||
if($gift_name==""){
|
||||
return V(0,"礼物名称不能为空");
|
||||
}
|
||||
if($type == ''){
|
||||
return V(0,"请选择礼物类型");
|
||||
}
|
||||
// if($label == ''){
|
||||
// return V(0,"请选择礼物标签");
|
||||
// }
|
||||
if($gift_price == ''){
|
||||
return V(0,"请输入礼物价格");
|
||||
}
|
||||
if($base_image == ''){
|
||||
return V(0,"请上传礼物图片");
|
||||
}
|
||||
$data = [
|
||||
'gift_name' => $gift_name,
|
||||
'type' => $type,
|
||||
'label' => $label,
|
||||
'gift_price' => $gift_price,
|
||||
'base_image' => $base_image,
|
||||
'file_type' => $file_type,
|
||||
'play_image' => $play_image,
|
||||
'gift_type' => $gift_type,
|
||||
'is_public_screen' => $is_public_screen,
|
||||
'is_public_server' => $is_public_server,
|
||||
'is_can_buy' => $is_can_buy,
|
||||
'is_show' => $is_show,
|
||||
'sort' => $sort,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
];
|
||||
$id = db::name($this->table)->insertGetId($data);
|
||||
if(!$id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功",['id'=>$id]);
|
||||
}
|
||||
/*
|
||||
* 礼物详情
|
||||
*/
|
||||
public function gift_info(){
|
||||
$gid = input('gid', '');
|
||||
if($gid == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$gift_data = db::name($this->table)->where(['gid'=>$gid])->find();
|
||||
if(!$gift_data){
|
||||
return V(0,"礼物不存在");
|
||||
}
|
||||
return V(1,"成功", $gift_data);
|
||||
}
|
||||
/*
|
||||
* 编辑礼物
|
||||
*/
|
||||
public function edit_gift(){
|
||||
$gid = input('gid', '');
|
||||
$gift_name = input('gift_name', '');
|
||||
$type = input('type', '');
|
||||
$label = input('label', '');
|
||||
$gift_price = input('gift_price', '');
|
||||
$base_image = input('base_image', '');
|
||||
$file_type = input('file_type', '');
|
||||
$play_image = input('play_image', '');
|
||||
$gift_type = input('gift_type', '');
|
||||
$is_public_screen = input('is_public_screen', '');
|
||||
$is_public_server = input('is_public_server', '');
|
||||
$is_can_buy = input('is_can_buy', '');
|
||||
$is_show = input('is_show', '');
|
||||
$sort = input('sort', '');
|
||||
if($gid == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$gift_data = db::name($this->table)->where(['gid'=>$gid])->find();
|
||||
if(!$gift_data){
|
||||
return V(0,"礼物不存在");
|
||||
}
|
||||
$gift_name = input('gift_name', '');
|
||||
$data=[];
|
||||
if($gift_name){
|
||||
$data['gift_name'] = $gift_name;
|
||||
$gift_data_to_name = db::name($this->table)->where(['gift_name'=>$gift_name,'delete_time'=>0,'gid'=>['<>',$gid]])->find();
|
||||
if($gift_data_to_name){
|
||||
return V(0,"礼物已存在");
|
||||
}
|
||||
}
|
||||
if($type){
|
||||
$data['type'] = $type;
|
||||
}
|
||||
if($label){
|
||||
$data['label'] = $label;
|
||||
}
|
||||
if($gift_price){
|
||||
$data['gift_price'] = $gift_price;
|
||||
}
|
||||
if($base_image){
|
||||
$data['base_image'] = $base_image;
|
||||
}
|
||||
if($file_type){
|
||||
$data['file_type'] = $file_type;
|
||||
}
|
||||
if($play_image){
|
||||
$data['play_image'] = $play_image;
|
||||
}
|
||||
if($gift_type){
|
||||
$data['gift_type'] = $gift_type;
|
||||
}
|
||||
if($is_public_screen){
|
||||
$data['is_public_screen'] = $is_public_screen;
|
||||
}
|
||||
if($is_public_server){
|
||||
$data['is_public_server'] = $is_public_server;
|
||||
}
|
||||
if($is_can_buy){
|
||||
$data['is_can_buy'] = $is_can_buy;
|
||||
}
|
||||
if($is_show){
|
||||
$data['is_show'] = $is_show;
|
||||
}
|
||||
$result = db::name($this->table)->where(['gid'=>$gid])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"修改失败,礼物内容无更改");
|
||||
}
|
||||
return V(1,"成功", ['id'=>$gid]);
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除礼物
|
||||
*/
|
||||
public function del_gift(){
|
||||
$gid = input('gid', '');
|
||||
if($gid == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$result = db::name($this->table)->where(['gid'=>$gid])->setField(['delete_time'=>time()]);
|
||||
if(!$result){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
}
|
||||
174
application/adminapi/controller/GiftLabel.php
Normal file
174
application/adminapi/controller/GiftLabel.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 礼物分类
|
||||
* @internal
|
||||
*/
|
||||
class GiftLabel extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['sort_label'];
|
||||
|
||||
protected $table = 'vs_gift_label';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function label_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_name = input('name', '');
|
||||
$where=[];
|
||||
$where['delete_time'] = 0;
|
||||
//标签名称
|
||||
if($search_name!==''){
|
||||
$where['name'] = ['like', '%'.$search_name.'%'];
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists = db::name($this->table)->where($where)
|
||||
->order('sort asc,id desc')
|
||||
->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['type'] = model('Gift')->giftType[$value['tid']];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
$lists[$key]['admin_name'] = db::name('admin')->where(['id'=>$value['admin_id']])->value('username');
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function sort_label(){
|
||||
$id = input('id', '');
|
||||
$sort = input('sort', 0);
|
||||
$data = [];
|
||||
$data = [
|
||||
'sort' => $sort,
|
||||
'updatetime' => time()
|
||||
];
|
||||
$result = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加标签
|
||||
*/
|
||||
public function add_label(){
|
||||
$name = input('name', '');
|
||||
$sort = input('sort', 0);
|
||||
$tid = input('tid', 0);
|
||||
if($name == ''){
|
||||
return V(0,"请输入礼物类型名称");
|
||||
}
|
||||
if($tid == 0){
|
||||
return V(0,"请选择一级分类");
|
||||
}
|
||||
$data = [
|
||||
'tid' => $tid,
|
||||
'name' => $name,
|
||||
'sort' => $sort,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
'admin_id' => Session::get('admin_id')
|
||||
];
|
||||
$id = db::name($this->table)->insertGetId($data);
|
||||
if($id){
|
||||
return V(1,"成功",['id'=>$id]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 标签详情
|
||||
*/
|
||||
public function label_info(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$tag_data = db::name($this->table)->where(['id'=>$id])->find();
|
||||
$tag_data['createtime'] = date('Y-m-d H:i:s', $tag_data['createtime']);
|
||||
if(!$tag_data){
|
||||
return V(0,"类型不存在");
|
||||
}
|
||||
return V(1,"成功", $tag_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 编辑标签
|
||||
*/
|
||||
public function edit_label(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$data = db::name($this->table)->where(['id'=>$id])->find();
|
||||
if(!$data){
|
||||
return V(0,"请输入礼物类型名称");
|
||||
}
|
||||
$name = input('name', '');
|
||||
if($name == ''){
|
||||
return V(0,"请输入礼物类型名称");
|
||||
}
|
||||
$data = db::name($this->table)->where(['name'=>$name,'id'=>['<>',$id]])->find();
|
||||
if($data){
|
||||
return V(0,"礼物类型已存在");
|
||||
}
|
||||
$tid = input('tid', 0);
|
||||
$sort = input('sort', 0);
|
||||
$data = [
|
||||
'tid' => $tid,
|
||||
'name' => $name,
|
||||
'sort' => $sort,
|
||||
'updatetime' => time()
|
||||
];
|
||||
$result = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"添加失败");
|
||||
|
||||
}
|
||||
return V(1,"成功", ['id'=>$id]);
|
||||
}
|
||||
/*
|
||||
* 删除标签
|
||||
*/
|
||||
public function del_label(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
// $result = db::name($this->table)->where(['id'=>$id])->delete();
|
||||
$result = db::name($this->table)->where(['id'=>$id])->setField('delete_time',time());
|
||||
if(!$result){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
}
|
||||
212
application/adminapi/controller/GiveGift.php
Normal file
212
application/adminapi/controller/GiveGift.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
|
||||
class GiveGift extends adminApi
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'vs_give_gift';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
//送礼物列表
|
||||
public function give_gift_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
|
||||
$send_user = input('send_user', '');//送礼物用户
|
||||
$gift_user = input('gift_user', '');//接受礼物用户
|
||||
$from_id = input('from_id', '');//礼物来源id
|
||||
$gift_id = input('gift_id', '');//礼物id
|
||||
$from = input('from', '');// 来源类型,1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$where=[];
|
||||
if($send_user != ''){
|
||||
$user_id = db::name('user')->where('user_code', $send_user)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($gift_user != ''){
|
||||
$gift_user_id = db::name('user')->where('user_code', $gift_user)->value('id');
|
||||
$where['gift_user'] = $gift_user_id;
|
||||
}
|
||||
if($from_id != ''){
|
||||
$room_id = db::name('vs_room')->where('room_number', $from_id)->value('id');
|
||||
if($room_id){
|
||||
$where['from_id'] = $room_id;
|
||||
}else{
|
||||
$where['from_id'] = $from_id;
|
||||
}
|
||||
}
|
||||
if($gift_id != ''){
|
||||
$where['gift_id'] = $gift_id;
|
||||
}
|
||||
if($from != ''){
|
||||
$where['from'] = $from;
|
||||
}
|
||||
// 时间筛选优化
|
||||
if(!empty($start_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between', [strtotime($start_time), strtotime($end_time.' 23:59:59')]];
|
||||
} elseif(!empty($start_time)){
|
||||
$where['createtime'] = ['>=', strtotime($start_time)];
|
||||
} elseif(!empty($end_time)){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
}
|
||||
//礼物总数
|
||||
$gift_num = db::name('vs_give_gift')->where($where)->sum('number');
|
||||
//总金额
|
||||
$total_price = db::name('vs_give_gift')->where($where)->sum('total_price');
|
||||
//平台收益
|
||||
$app_earning = 0;
|
||||
//接收人收益
|
||||
$receive_earning = 0;
|
||||
//房主收益
|
||||
$room_owner_earning = 0;
|
||||
|
||||
// 获取所有送礼记录
|
||||
$list = db::name('vs_give_gift')->where($where)->order('id', 'desc')->select();
|
||||
$gift_ids = array_column($list, 'id');
|
||||
if (!empty($gift_ids)) {
|
||||
// 批量获取所有收益记录
|
||||
$earning_list = db::name('vs_give_gift_ratio_log')
|
||||
->where('give_gift_id', 'in', $gift_ids)
|
||||
->order('id', 'desc')
|
||||
->select();
|
||||
|
||||
// 计算总收益
|
||||
foreach ($earning_list as $earning) {
|
||||
$app_earning += $earning['app_earning'];
|
||||
$receive_earning += $earning['gift_user_earning'];
|
||||
$room_owner_earning += $earning['room_owner_earning'];
|
||||
}
|
||||
}
|
||||
$count = count($list);
|
||||
$lists = $this->array_pagination($list, $page, $page_limit);
|
||||
|
||||
// 提取所有需要关联查询的ID
|
||||
$user_ids = array_merge(
|
||||
array_column($lists, 'user_id'),
|
||||
array_column($lists, 'gift_user')
|
||||
);
|
||||
$room_ids = array_filter(array_merge(
|
||||
array_column($lists, 'room_id'),
|
||||
array_column($lists, 'from_id')
|
||||
));
|
||||
$gift_ids_list = array_column($lists, 'gift_id');
|
||||
|
||||
// 批量获取用户信息
|
||||
$users = [];
|
||||
if (!empty($user_ids)) {
|
||||
$user_list = db::name('user')
|
||||
->where('id', 'in', array_unique($user_ids))
|
||||
->field('id,nickname,user_code')
|
||||
->select();
|
||||
foreach ($user_list as $user) {
|
||||
$users[$user['id']] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
// 批量获取房间信息
|
||||
$rooms = [];
|
||||
if (!empty($room_ids)) {
|
||||
$room_list = db::name('vs_room')
|
||||
->where('id', 'in', array_unique($room_ids))
|
||||
->field('id,room_name,room_number')
|
||||
->select();
|
||||
foreach ($room_list as $room) {
|
||||
$rooms[$room['id']] = $room;
|
||||
}
|
||||
}
|
||||
|
||||
// 批量获取礼物信息
|
||||
$gifts = [];
|
||||
if (!empty($gift_ids_list)) {
|
||||
$gift_list = db::name('vs_gift')
|
||||
->where('gid', 'in', array_unique($gift_ids_list))
|
||||
->field('gid,gift_name,gift_price')
|
||||
->select();
|
||||
foreach ($gift_list as $gift) {
|
||||
$gifts[$gift['gid']] = $gift;
|
||||
}
|
||||
}
|
||||
|
||||
// 批量获取收益详情
|
||||
$earnings = [];
|
||||
if (!empty(array_column($lists, 'id'))) {
|
||||
$earning_details = db::name('vs_give_gift_ratio_log')
|
||||
->where('give_gift_id', 'in', array_column($lists, 'id'))
|
||||
->order('id', 'desc')
|
||||
->select();
|
||||
foreach ($earning_details as $earning) {
|
||||
$earnings[$earning['give_gift_id']] = $earning;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理列表数据
|
||||
foreach ($lists as &$value) {
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
|
||||
// 用户信息
|
||||
$send_user_info = isset($users[$value['user_id']]) ? $users[$value['user_id']] : null;
|
||||
$value['send_user'] = $send_user_info ? $send_user_info['nickname'].'-'.$send_user_info['user_code'] : '';
|
||||
|
||||
$gift_user_info = isset($users[$value['gift_user']]) ? $users[$value['gift_user']] : null;
|
||||
$value['gift_user'] = $gift_user_info ? $gift_user_info['nickname'].'-'.$gift_user_info['user_code'] : '';
|
||||
|
||||
// 礼物信息
|
||||
$gift_info = isset($gifts[$value['gift_id']]) ? $gifts[$value['gift_id']] : null;
|
||||
$value['gift_name'] = $gift_info ? $gift_info['gift_name'].'-'.$value['gift_id'] : '';
|
||||
$value['gift_price'] = $gift_info ? $gift_info['gift_price'] : 0;
|
||||
|
||||
// 房间信息处理
|
||||
if($value['from'] == 1){
|
||||
$value['room'] = '聊天送礼';
|
||||
}elseif ($value['from'] == 2 || $value['from'] == 3){
|
||||
$room_info = isset($rooms[$value['from_id']]) ? $rooms[$value['from_id']] : null;
|
||||
$value['room'] = $room_info ? $room_info['room_number'].$room_info['room_name'].'-' : '';
|
||||
}elseif ($value['from'] == 4){
|
||||
$value['room'] = '动态打赏 -'.$value['from_id'];
|
||||
}elseif ($value['from'] == 5){
|
||||
$value['room'] = '系统任务';
|
||||
}elseif ($value['from'] == 6){
|
||||
$value['room'] = 'cp房间送礼-'.$value['from_id'];
|
||||
}else{
|
||||
$value['room'] = '未知来源';
|
||||
}
|
||||
|
||||
// 收益信息
|
||||
$earning_info = isset($earnings[$value['id']]) ? $earnings[$value['id']] : null;
|
||||
$value['app_earning'] = $earning_info ? $earning_info['app_earning'] : 0;
|
||||
$value['gift_user_earning'] = $earning_info ? $earning_info['gift_user_earning'] : 0;
|
||||
$value['room_owner_earning'] = $earning_info ? $earning_info['room_owner_earning'] : 0;
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'gift_num' => $gift_num,
|
||||
'total_price' => $total_price,
|
||||
'app_earning' => round($app_earning,2) ,
|
||||
'receive_earning' => round($receive_earning,2),
|
||||
'room_owner_earning' => round($room_owner_earning,2)
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
// 自定义分页函数
|
||||
function array_pagination($array, $page, $limit) {
|
||||
$start = ($page - 1) * $limit;
|
||||
return array_slice($array, $start, $limit);
|
||||
}
|
||||
}
|
||||
770
application/adminapi/controller/Guild.php
Normal file
770
application/adminapi/controller/Guild.php
Normal file
@@ -0,0 +1,770 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
|
||||
/*
|
||||
* 工会
|
||||
*/
|
||||
class Guild extends adminApi
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
protected $layout = '';
|
||||
protected $table_guild_subsidy_config = 'vs_guild_subsidy_config';
|
||||
protected $table_guild_subsidy = 'vs_guild_subsidy';
|
||||
protected $table_guild_user = 'vs_guild_user';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
//移除HTML标签
|
||||
$this->request->filter('trim,strip_tags,htmlspecialchars');
|
||||
}
|
||||
|
||||
/*
|
||||
* 工会列表
|
||||
* @param int $page
|
||||
* @param int $page_limit
|
||||
* @param string search_id
|
||||
* @param string search_name
|
||||
* @param string search_stime
|
||||
* @param string search_etime
|
||||
* @return array
|
||||
*/
|
||||
public function guild_lists()
|
||||
{
|
||||
$page = input('page',1);
|
||||
$page = $page > 0 ? $page : 1;
|
||||
$page_limit = input('page_limit',30);
|
||||
$search_id = input('search_id','');
|
||||
$search_name = input('search_name','');
|
||||
$search_stime = input('search_stime','');
|
||||
$search_etime = input('search_etime','');
|
||||
$where = [];
|
||||
if (!empty($search_id)) {
|
||||
$where['guild_special_id'] = $search_id;
|
||||
}
|
||||
if (!empty($search_name)) {
|
||||
$where['guild_name'] = ['like',"%{$search_name}%"];
|
||||
}
|
||||
// if (!empty($search_stime)) {
|
||||
// $where['createtime'] = ['>=',strtotime($search_stime)];
|
||||
// }
|
||||
// if (!empty($search_etime)) {
|
||||
// $where['createtime'] = ['<=',strtotime($search_etime.' 23:59:59')];
|
||||
// }
|
||||
// if(!empty($search_stime) && !empty($search_etime)){
|
||||
// $where['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime.' 23:59:59')]];
|
||||
// }
|
||||
$count = db::name('vs_guild')->where($where)->count();
|
||||
$data = db::name('vs_guild')->where($where)->page($page,$page_limit)->select();
|
||||
$list = [];
|
||||
foreach ($data as $k=>$v) {
|
||||
$list[$k]['id'] = $v['id'];
|
||||
$list[$k]['code_id'] = $v['guild_special_id'];
|
||||
$special_num = db::name('vs_user_decorate')->where(['type'=>8,'user_id'=>$v['user_id'],'is_using'=>1])->where('end_time',['>=',time()],'or')->value('special_num');
|
||||
if($special_num){
|
||||
$list[$k]['guild_special_id'] = $special_num;
|
||||
}else{
|
||||
$list[$k]['guild_special_id'] = "无";
|
||||
}
|
||||
$list[$k]['guild_name'] = $v['guild_name'];
|
||||
$user = model('User')->getOne(['id'=>$v['user_id']]);
|
||||
if(!$user){
|
||||
$list[$k]['user_name'] = "无";
|
||||
}else{
|
||||
$list[$k]['user_name'] = $user['user_code'].'-'.$user['nickname'];
|
||||
}
|
||||
$list[$k]['guild_logo'] = $v['cover'];
|
||||
//当日流水
|
||||
$list[$k]['today_money'] = model('Guild')->getTodayMoney($v['id'],$search_stime,$search_etime);
|
||||
$list[$k]['is_show'] = $v['is_show'];
|
||||
$list[$k]['status'] = $v['status'];
|
||||
$list[$k]['status_str'] = $v['status'] == 1 ? '正常' : '解散';
|
||||
$list[$k]['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
$list[$k]['updatetime'] = date('Y-m-d H:i:s',$v['updatetime']);
|
||||
$list[$k]['user_id'] = $user['user_code'];
|
||||
$list[$k]['intro'] = $v['intro'];
|
||||
}
|
||||
// 数组按today_money 排序
|
||||
usort($list, function($a, $b) {
|
||||
return $b['today_money'] - $a['today_money'];
|
||||
});
|
||||
$reslut = [];
|
||||
$reslut['page'] = $page;
|
||||
$reslut['page_limit'] = $page_limit;
|
||||
$reslut['count'] = $count;
|
||||
$reslut['list'] = $list;
|
||||
return V(1,"成功", $reslut);
|
||||
}
|
||||
|
||||
/**
|
||||
* 工会添加
|
||||
* @param guild_special_id 靓号 guild_special_id
|
||||
* @param user_id 会长ID user_id
|
||||
* @param guild_name 工会名称 guild_name
|
||||
* @param guild_desc 工会描述 intro
|
||||
* @param guild_logo 工会logo cover
|
||||
*
|
||||
*/
|
||||
public function guild_add(){
|
||||
if ($this->request->isPost()) {
|
||||
$request = $this->request->post();
|
||||
if (empty($request['guild_name'])) {
|
||||
return V(0, "请填写工会名称");
|
||||
}
|
||||
$guild = model('Guild')->getOne(['guild_name'=>$request['guild_name'],'delete_time'=>0]);
|
||||
if(!empty($guild)) {
|
||||
return V(0, "该工会名称已存在");
|
||||
}
|
||||
if(empty($request['user_id'])) {
|
||||
return V(0, "请填写会长用户ID");
|
||||
}
|
||||
$user = db('user')->where('user_code', $request['user_id'])->find();
|
||||
if(empty($user)) {
|
||||
return V(0, "会长ID不存在");
|
||||
}
|
||||
$user_id = $user['id'];
|
||||
if(empty($request['guild_logo'])) {
|
||||
return V(0, "请上传工会logo");
|
||||
}
|
||||
$guild_to_usser = model('Guild')->getOne(['user_id'=>$user_id,'delete_time'=>0]);
|
||||
if ($guild_to_usser) {
|
||||
return V(0, "该会长已创建工会");
|
||||
}
|
||||
$guild_user = db::name('vs_guild_user')->where('user_id',$user_id)->where('delete_time',0)->find();
|
||||
if ($guild_user) {
|
||||
return V(0, "该会长已加入其他工会");
|
||||
}
|
||||
//靓号处理
|
||||
if(empty($request['guild_special_id'])){
|
||||
$guild_special_id = model('Guild')->getGuildSpecialId();
|
||||
}else{
|
||||
$vip_code = db::name('vip_code')->where(['type' => 3, 'status' => 1,'is_use' => 1])->where('code', $request['guild_special_id'])->field('code')->select();
|
||||
if (empty($vip_code)) {
|
||||
return V(0, "请输入正确的靓号");
|
||||
}
|
||||
$guild_special_id = model('Guild')->getOne(['guild_special_id'=>$request['guild_special_id']]);
|
||||
if ($guild_special_id) {
|
||||
return V(0, "靓号已使用");
|
||||
}
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data = [
|
||||
'guild_special_id' => $guild_special_id,
|
||||
'user_id' => $user_id,
|
||||
'guild_name' => $request['guild_name'],
|
||||
'intro' => $request['guild_desc'],
|
||||
'cover' => $request['guild_logo']
|
||||
];
|
||||
$res = model('Guild')->add($data);
|
||||
if (!$res) {
|
||||
db::rollback();
|
||||
return V(0, "创建失败");
|
||||
}
|
||||
//会长是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['id'];
|
||||
}
|
||||
$insert_data = [];
|
||||
$insert_data['user_id'] = $user_id;
|
||||
$insert_data['guild_id'] = $res;
|
||||
$insert_data['room_id'] = $rid;
|
||||
$insert_data['status'] = 1;
|
||||
$insert_data['is_deacon'] = 1;
|
||||
$insert_data['createtime'] = time();
|
||||
$insert_data['is_show_room'] = 1;
|
||||
$re = db::name('vs_guild_user')->insert($insert_data);
|
||||
if (!$re) {
|
||||
db::rollback();
|
||||
return V(0, "加入失败");
|
||||
}
|
||||
$reslut = model('api/Tencent')->create_group($user_id,'g'.$res,"Public",$request['guild_logo'],$request['guild_name']);
|
||||
if ($reslut['code'] ==0 ) {
|
||||
db::rollback();
|
||||
return V(0, $reslut['msg']);
|
||||
}
|
||||
model('api/Tencent')->send_group_system_notification('g'.$res, $request['guild_name'].'工会群聊创建成功');
|
||||
db::commit();
|
||||
return V(1,"成功", []);
|
||||
} catch (\Exception $e) {
|
||||
db::rollback();
|
||||
return V(0, $e->getMessage());
|
||||
}
|
||||
}else{
|
||||
return V(0,"参数错误", []);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 修改
|
||||
*/
|
||||
public function guild_edit(){
|
||||
if ($this->request->isPost()) {
|
||||
$request = $this->request->post();
|
||||
if (empty($request['id'])) {
|
||||
return V(0, "请选择要修改的工会");
|
||||
}
|
||||
$guild = model('Guild')->getOne(['id'=>$request['id']]);
|
||||
if (empty($guild)) {
|
||||
return V(0, "该工会不存在");
|
||||
}
|
||||
if (!empty($request['guild_name'])) {
|
||||
$guild_name = model('Guild')->getOne(['guild_name'=>$request['guild_name']]);
|
||||
if (!empty($guild_name) && $guild_name['id'] != $request['id']) {
|
||||
return V(0, "该工会名称已存在");
|
||||
}
|
||||
}
|
||||
//靓号处理
|
||||
if(!empty($request['guild_special_id']) && is_numeric($request['guild_special_id'])){
|
||||
$decorate = model('api/Decorate')->where(['type'=>8,'special_num'=>$request['guild_special_id']])->find();
|
||||
if (!$decorate) {
|
||||
return V(0, "请输入正确的靓号");
|
||||
}
|
||||
if($decorate['is_user_buy'] ==1){
|
||||
return V(0, "该靓号已使用");
|
||||
}
|
||||
//装扮靓号
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where(['did' => $decorate['did'],'is_delete' => 1])->order('day','asc')->find();
|
||||
model('api/Decorate')->pay_decorate($guild['user_id'], $decorate['did'], $decorate_price_info['day'],2);
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data =[];
|
||||
if(isset($request['guild_name']) && $request['guild_name']){
|
||||
$data['guild_name'] = $request['guild_name'];
|
||||
}
|
||||
if(isset($request['user_id']) && $request['user_id']){
|
||||
$userID = db::name('user')->where('user_code',$request['user_id'])->value('id');
|
||||
$data['user_id'] = $userID;
|
||||
}
|
||||
if(isset($request['guild_logo']) && $request['guild_logo']){
|
||||
$data['cover'] = $request['guild_logo'];
|
||||
}
|
||||
if(isset($request['guild_desc']) && $request['guild_desc']){
|
||||
$data['intro'] = $request['guild_desc'];
|
||||
}
|
||||
$res = model('Guild')->edit(['id' => $request['id']], $data);
|
||||
if ($res) {
|
||||
db::commit();
|
||||
return V(1, "修改成功");
|
||||
} else {
|
||||
db::rollback();
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
db::rollback();
|
||||
return V(0, $e->getMessage());
|
||||
}
|
||||
}else{
|
||||
return V(0,"参数错误", []);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 解散工会
|
||||
*/
|
||||
public function guild_dissolve(){
|
||||
if(request()->isPost()){
|
||||
$id = input('id');
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$guild = model('Guild')->getOne(['id'=>$id]);
|
||||
if(empty($guild)){
|
||||
return V(0,"该工会不存在");
|
||||
}
|
||||
if($guild['status'] == 2){
|
||||
return V(0,"该工会已解散");
|
||||
}
|
||||
$res = model('Guild')->edit(['id'=>$id],['status'=>2,'delete_time'=>time()]);
|
||||
|
||||
if($res){
|
||||
db('vs_guild_user')->where(['guild_id'=>$id,'quit_type'=>0])->update(['quit_type'=>3,'quit_time'=>time()]);
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$id);
|
||||
return V(1,"解散成功");
|
||||
}else{
|
||||
return V(0,"解散失败");
|
||||
}
|
||||
}
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
/*
|
||||
* 查看工会成员
|
||||
*/
|
||||
public function guild_member_lists(){
|
||||
//管理员ID
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$guild_id = input('guild_id', 0);
|
||||
$search_stime = input('search_stime','');
|
||||
$search_etime = input('search_etime','');
|
||||
$user_id = input('user_id', 0);
|
||||
$where=['a.status'=>1];
|
||||
if(!$guild_id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($user_id){
|
||||
if(is_numeric($user_id)){
|
||||
$where['b.user_code'] = $user_id;
|
||||
}else{
|
||||
$where['b.nickname'] = ['like', '%'.$user_id.'%'];
|
||||
}
|
||||
|
||||
}
|
||||
$count = db::name($this->table_guild_user)->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id,'a.quit_type'=>['in',[0,3]]])->where($where)->count();
|
||||
$list = db::name($this->table_guild_user)->alias('a')
|
||||
->field('a.*,b.nickname,b.user_code')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id,'a.quit_type'=>['in',[0,3]]])->where($where)->page($page, $page_limit)->select();
|
||||
$rum_lists = [];
|
||||
$coin_consumption_type_array = model('common/UserWallet')->coin_consumption_type_array;
|
||||
$coin_consumption_type_array = array_diff($coin_consumption_type_array, [model('common/UserWallet')::OPERATION_CONSUME]);
|
||||
foreach ($list as $k=>$v){
|
||||
$user_info = model('api/User')->get_user_info($v['user_id'],['user','user_level']);
|
||||
$rum_lists[$k]['id']=$v['id'];
|
||||
$rum_lists[$k]['user_id']=$v['user_id'];
|
||||
$rum_lists[$k]['user_code']=model('api/Decorate')->user_decorate_detail($v['user_id'],6);
|
||||
$rum_lists[$k]['nickname']=$user_info['nickname'];
|
||||
$rum_lists[$k]['charm_level']=$user_info['charm_level'];
|
||||
$rum_lists[$k]['wealth_level']=$user_info['wealth_level'];
|
||||
//用户流水
|
||||
$consumption_sql = db::name('vs_user_money_log')
|
||||
->whereIn('change_type',$coin_consumption_type_array)
|
||||
->where(['money_type'=>1,'user_id' => $v['user_id']]);
|
||||
if($v['quit_type'] == 3){
|
||||
$consumption_sql->where(['createtime'=>['<=',$v['delete_time']]]);
|
||||
$consumption_sql->where(['createtime'=>['>=',$v['createtime']]]);
|
||||
}
|
||||
if($search_stime){
|
||||
$consumption_sql->where(['createtime'=>['>=',$search_stime]]);
|
||||
}
|
||||
if($search_etime){
|
||||
$consumption_sql->where(['createtime'=>['<=',$search_etime]]);
|
||||
|
||||
}
|
||||
$consumption = $consumption_sql->sum('change_value');
|
||||
$rum_lists[$k]['consumption'] = $consumption;
|
||||
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $rum_lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 查看房间
|
||||
*/
|
||||
public function guild_room_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$guild_id = input('guild_id', 0);
|
||||
$search_stime = input('search_stime','');
|
||||
$search_etime = input('search_etime','');
|
||||
$room_id = input('room_id', 0);
|
||||
$where=['a.status'=>1];
|
||||
$where=['a.room_id'=>['>',0]];
|
||||
if(!$guild_id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($room_id){
|
||||
if(is_numeric($room_id)){
|
||||
$where['b.room_number'] = $room_id;
|
||||
}else{
|
||||
$where['b.room_name'] = ['like', '%'.$room_id.'%'];
|
||||
}
|
||||
}
|
||||
$count = db::name($this->table_guild_user)->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id,'a.quit_type'=>['in',[0,3]]])->where($where)->count();
|
||||
$list = db::name($this->table_guild_user)->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id,'a.quit_type'=>['in',[0,3]]])->where($where)->page($page, $page_limit)->select();
|
||||
if(!$list){
|
||||
return V(0,"暂无数据");
|
||||
}
|
||||
$rum_lists = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$room_info = db::name('vs_room')->where(['id'=>$v['room_id']])->find();
|
||||
$rum_lists[$k]['id']=$v['id'];
|
||||
$rum_lists[$k]['room_id']=$v['room_id'];
|
||||
$rum_lists[$k]['room_code']= model('api/Decorate')->user_decorate_detail($v['room_id'], 7);
|
||||
$rum_lists[$k]['room_name']=$room_info['room_name']?? '';
|
||||
$rum_lists[$k]['room_cover']=$room_info['room_cover']?? '';
|
||||
//房间流水
|
||||
$rum_lists[$k]['consumption']= model('Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime);
|
||||
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $rum_lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
}
|
||||
|
||||
//踢出公会
|
||||
public function kick_guild_member(){
|
||||
$user_id = input('user_id', 0);
|
||||
$guild_id = input('guild_id', 0);
|
||||
if(!$guild_id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$guild_info = Db::name('vs_guild')->where('id', $guild_id)->find();
|
||||
if(!$guild_info){
|
||||
return V(0,"公会不存在");
|
||||
}
|
||||
$reslut = model('api/Guild')->kick_out_guild($guild_info['user_id'], $user_id, $guild_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 合并工会
|
||||
*/
|
||||
public function merge_guild(){
|
||||
$guild_id = input('guild_id', '');
|
||||
$merge_guild_id = input('merge_guild_id', '');
|
||||
//解散工会
|
||||
$guild = model('Guild')->getOne(['id'=>$guild_id]);
|
||||
if(empty($guild)){
|
||||
return V(0,"该工会不存在");
|
||||
}
|
||||
if($guild['status'] == 2){
|
||||
return V(0,"该工会已解散");
|
||||
}
|
||||
db::startTrans();
|
||||
try{
|
||||
$res = model('Guild')->edit(['id'=>$guild_id],['status'=>2,'delete_time'=>time()]);
|
||||
//并入工会
|
||||
if(!$merge_guild_id){
|
||||
db::rollback();
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$merge_guild = model('Guild')->getOne(['id'=>$merge_guild_id]);
|
||||
if(empty($merge_guild)){
|
||||
db::rollback();
|
||||
return V(0,"并入工会不存在");
|
||||
}
|
||||
$merge_guild_user = db('vs_guild_user')->where(['guild_id'=>$merge_guild_id,'quit_type'=>0])->select();
|
||||
foreach ($merge_guild_user as $key=>$value){
|
||||
$res = db('vs_guild_user')->insert([
|
||||
'user_id'=>$value['user_id'],
|
||||
'guild_id'=>$merge_guild_id,
|
||||
'room_id'=>$value['room_id'],
|
||||
'coin'=>$value['coin'],
|
||||
'status'=>$value['status'],
|
||||
'is_deacon'=>$value['is_deacon'],
|
||||
'is_show_room'=>$value['is_show_room'],
|
||||
'remarks'=>$value['remarks'],
|
||||
'apply_time'=>$value['apply_time'],
|
||||
'createtime'=>time(),
|
||||
]);
|
||||
if(!$res){
|
||||
db::rollback();
|
||||
return V(0,"失败");
|
||||
}
|
||||
//拉用户进入工会群聊
|
||||
$rid = 'g'.$merge_guild_id;
|
||||
$reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
|
||||
}
|
||||
$return = db('vs_guild_user')->where(['guild_id'=>$guild_id,'quit_type'=>0])->update(['quit_type'=>3,'quit_time'=>time(),'updatetime'=>time(),'delete_time'=>time()]);
|
||||
if (!$return) {
|
||||
db::rollback();
|
||||
return V(0,"失败");
|
||||
}
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$guild_id);
|
||||
db::commit();
|
||||
return V(1,"成功");
|
||||
} catch(\Exception $e) {
|
||||
db::rollback();
|
||||
return V(0,$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 工会补贴配置添加
|
||||
*/
|
||||
public function guild_subsidy_config_add(){
|
||||
$start_amount = input('start_amount', 0);
|
||||
$end_amount = input('end_amount', 0);
|
||||
$subsidy_ratio = input('subsidy_ratio', 0);
|
||||
if ($start_amount && $end_amount && $subsidy_ratio) {
|
||||
$res = db::name($this->table_guild_subsidy_config)->insertGetId([
|
||||
'start_amount' => $start_amount,
|
||||
'end_amount' => $end_amount,
|
||||
'subsidy_ratio' => $subsidy_ratio,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
if (!$res) {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
}else{
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
|
||||
return V(1, "添加成功");
|
||||
}
|
||||
/*
|
||||
* 工会补贴配置列表
|
||||
*/
|
||||
public function guild_subsidy_config_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where=[];
|
||||
$count = db::name($this->table_guild_subsidy_config)->where($where)->count();
|
||||
$lists = db::name($this->table_guild_subsidy_config)->where($where)->page($page, $page_limit)->order('end_amount asc')->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 工会补贴配置 删除
|
||||
*/
|
||||
public function del_guild_config_subsidy(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$result = db::name($this->table_guild_subsidy_config)->where(['id'=>$id])->delete();
|
||||
if(!$result){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 工会补贴配置 编辑
|
||||
*/
|
||||
public function edit_guild_config_subsidy(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$guild_subsidy_config = db::name($this->table_guild_subsidy_config)->where(['id'=>$id])->find();
|
||||
if(!$guild_subsidy_config){
|
||||
return V(0,"数据不存在");
|
||||
}
|
||||
$start_amount = input('start_amount', "");
|
||||
$end_amount = input('end_amount', "");
|
||||
$subsidy_ratio = input('subsidy_ratio', "");
|
||||
$data=[];
|
||||
if($start_amount != ""){
|
||||
$data['start_amount'] = $start_amount;
|
||||
}
|
||||
if($end_amount != ""){
|
||||
$data['end_amount'] = $end_amount;
|
||||
}
|
||||
if($subsidy_ratio != ""){
|
||||
$data['subsidy_ratio'] = $subsidy_ratio;
|
||||
}
|
||||
$result = db::name($this->table_guild_subsidy_config)->where(['id'=>$id])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 工会补贴配置 状态修改
|
||||
*/
|
||||
public function guild_config_subsidy_status(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$status = input('status', '');
|
||||
if($status == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$result = db::name($this->table_guild_subsidy_config)->where(['id'=>$id])->update(['status'=>$status]);
|
||||
if(!$result){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 工会周补贴列表
|
||||
*/
|
||||
public function guild_subsidy_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_user_id = input('search_user_id', '');
|
||||
$search_guild_id = input('search_guild_id', '');
|
||||
$search_status_time = input('search_status_time', '');
|
||||
$search_end_time = input('search_end_time', '');
|
||||
$search_status = input('search_status', '');
|
||||
$where = ['b.delete_time'=>0];
|
||||
if($search_user_id){
|
||||
$where['b.user_id'] = $search_user_id;
|
||||
}
|
||||
if($search_guild_id){
|
||||
$where['a.guild_id'] = $search_guild_id;
|
||||
}
|
||||
if($search_status_time){
|
||||
$where['a.start_time'] = ['>=', $search_status_time];
|
||||
}
|
||||
if($search_end_time){
|
||||
$where['a.end_time'] = ['<=', $search_end_time];
|
||||
}
|
||||
if($search_status){
|
||||
$where['a.status'] = $search_status;
|
||||
}
|
||||
$count = db::name($this->table_guild_subsidy)->alias('a')
|
||||
->join('vs_guild b','a.guild_id = b.id')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists_data = db::name($this->table_guild_subsidy)->alias('a')
|
||||
->join('vs_guild b','a.guild_id = b.id')
|
||||
->where($where)
|
||||
->order('a.id desc')
|
||||
->field('a.*,b.guild_name,b.user_id,b.guild_special_id')
|
||||
->page($page,$page_limit)
|
||||
->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['user_id'] = $value['user_id'];
|
||||
$lists[$key]['user_name'] = model('user')->where(['id'=>$value['user_id']])->value('nickname');
|
||||
$lists[$key]['guild_id'] = $value['guild_special_id'];
|
||||
$lists[$key]['guild_name'] = $value['guild_name'];
|
||||
$lists[$key]['total_transaction'] = $value['total_transaction'];
|
||||
$lists[$key]['subsidy_amount'] = $value['subsidy_amount'];
|
||||
$lists[$key]['time'] = date('Y-m-d',strtotime($value['start_time'])) .'~'.date('Y-m-d',strtotime($value['end_time']));
|
||||
$lists[$key]['status'] = $value['status'];
|
||||
$lists[$key]['status_str'] = $value['status'] ? '已发放' : '未发放';
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 补贴发放
|
||||
*/
|
||||
public function subsidy_give(){
|
||||
$id = input('id');
|
||||
$status = input('status', 0);
|
||||
$remark = input('remark', 0);
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$data = db::name($this->table_guild_subsidy)->alias('a')
|
||||
->join('vs_guild b','a.guild_id = b.id')
|
||||
->where(['a.id'=>$id])
|
||||
->field('a.subsidy_amount,b.user_id,a.status,a.id')
|
||||
->find();
|
||||
if(!$data){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($data['status']!=0){
|
||||
return V(0,"该申请已处理");
|
||||
}
|
||||
Db::startTrans();
|
||||
try{
|
||||
if($status==1){
|
||||
//发放处理用户资金
|
||||
$reslut = model('common/UserWallet')->change_user_money($data['user_id'], $data['subsidy_amount'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::GUILD_SUBSIDY,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::GUILD_SUBSIDY));
|
||||
if ($reslut['code'] != 1) {
|
||||
Db::rollback();
|
||||
return V($reslut['code'],$reslut['msg']);
|
||||
}
|
||||
|
||||
}
|
||||
$res = DB::name($this->table_guild_subsidy)->where('id', $id)->update([
|
||||
'status' => $status,
|
||||
'remark' => $remark
|
||||
]);
|
||||
if($res){
|
||||
Db::commit();
|
||||
return V(1,"操作成功");
|
||||
}else{
|
||||
Db::rollback();
|
||||
return V(0,"操作失败");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return V(0,$e->getMessage());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 批量补贴发放
|
||||
*/
|
||||
public function subsidy_give_batch()
|
||||
{
|
||||
$ids = input('ids');
|
||||
$status = input('status', 0);
|
||||
$remark = input('remark', 0);
|
||||
$ids = explode(',', $ids);
|
||||
if (!$ids) {
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = db::name($this->table_guild_subsidy)->alias('a')
|
||||
->join('vs_guild b','a.guild_id = b.id')
|
||||
->whereIn('guild_id',$ids)
|
||||
->field('a.subsidy_amount,b.user_id,a.status,a.id')
|
||||
->select();
|
||||
if (!$data) {
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value['status'] != 0) {
|
||||
continue;
|
||||
}
|
||||
if($status==1){
|
||||
//发放处理用户资金
|
||||
$reslut = model('common/UserWallet')->change_user_money($value['user_id'], $value['subsidy_amount'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::GUILD_SUBSIDY,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::GUILD_SUBSIDY));
|
||||
if ($reslut['code'] != 1) {
|
||||
Db::rollback();
|
||||
return V($reslut['code'],$reslut['msg']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$res = DB::name($this->table_guild_subsidy)->whereIn('id', $ids)->where('status', 0)->update([
|
||||
'status' => $status,
|
||||
'remark' => $remark
|
||||
]);
|
||||
if($res){
|
||||
Db::commit();
|
||||
return V(1,"操作成功");
|
||||
}else{
|
||||
Db::rollback();
|
||||
return V(0,"操作失败");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return V(0, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
201
application/adminapi/controller/Help.php
Normal file
201
application/adminapi/controller/Help.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 单页
|
||||
* @internal
|
||||
*/
|
||||
class Help extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'vs_help';
|
||||
protected $table_type = 'vs_help_type';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function help_type_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where = [];
|
||||
$where['delete_time'] = 0;
|
||||
$count = db::name($this->table_type)->where($where)->count();
|
||||
$lists = db::name($this->table_type)->where($where)->order('sort,id desc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['admin'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function help_type_add(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$type_name = input('type_name', '');
|
||||
$sort= input('sort', '');
|
||||
$status= input('status', '');
|
||||
if(empty($type_name)){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = [
|
||||
'type_name' => $type_name,
|
||||
'sort' => $sort,
|
||||
'status' => $status,
|
||||
'admin_id' => $admin_id,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = db::name($this->table_type)->insert($data);
|
||||
if(!$res){
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
return V(1, "添加成功");
|
||||
}
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public function help_type_edit(){
|
||||
$type_name = input('type_name', '');
|
||||
$sort= input('sort', '');
|
||||
$status= input('status', '');
|
||||
$id = input('id', '');
|
||||
if($type_name){
|
||||
$data['type_name'] = $type_name;
|
||||
}
|
||||
if($sort){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($status){
|
||||
$data['status'] = $status;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name($this->table_type)->where(['id'=>$id])->update($data);
|
||||
if(!$res){
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1, "修改成功");
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function help_type_del(){
|
||||
$id = input('id', '');
|
||||
$res = db::name($this->table_type)->where(['id'=>$id])->update(['delete_time'=>time()]);
|
||||
if(!$res){
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
return V(1, "删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 常见问题列表
|
||||
*/
|
||||
public function help_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$type = input('type', '');
|
||||
$where = [];
|
||||
$where['delete_time'] = 0;
|
||||
if($type){
|
||||
$where['type'] = $type;
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists = db::name($this->table)->where($where)->order('id desc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$v){
|
||||
$v['type_name'] = db::name($this->table_type)->where(['id'=>$v['type']])->value('type_name')??"--";
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['admin'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/**
|
||||
* 常见问题添加
|
||||
*/
|
||||
public function help_add(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$title = input('title', '');
|
||||
$content= input('content', '');
|
||||
$type= input('type', '');
|
||||
if(empty($title)){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'type' => $type,
|
||||
'admin_id' => $admin_id,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if(!$res){
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
return V(1, "添加成功");
|
||||
}
|
||||
/**
|
||||
* 常见问题修改
|
||||
*/
|
||||
public function help_edit(){
|
||||
$title = input('title', '');
|
||||
$content= input('content', '');
|
||||
$type= input('type', '');
|
||||
$id = input('id', '');
|
||||
if($title){
|
||||
$data['title'] = $title;
|
||||
}
|
||||
if($content){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
if($type){
|
||||
$data['type'] = $type;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if(!$res){
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1, "修改成功");
|
||||
}
|
||||
/**
|
||||
* 常见问题删除
|
||||
*/
|
||||
public function help_del(){
|
||||
$id = input('id', '');
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update(['delete_time'=>time()]);
|
||||
if(!$res){
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
return V(1, "删除成功");
|
||||
}
|
||||
|
||||
}
|
||||
224
application/adminapi/controller/Index.php
Normal file
224
application/adminapi/controller/Index.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 后台首页
|
||||
* @internal
|
||||
*/
|
||||
class Index extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['login'];
|
||||
protected $noNeedRight = ['index', 'logout'];
|
||||
protected $layout = '';
|
||||
public $province = ['北京市', '天津市', '河北省', '内蒙古自治区', '辽宁省', '吉林省', '黑龙江省', '上海市', '江苏省', '浙江省', '安徽省', '福建省', '江西省', '山东省', '河南省', '湖北省', '湖南省', '广东省', '广西壮族自治区', '海南省', '重庆市四川省', '贵州省', '云南省', '西藏自治区', '陕西省', '甘肃省', '青海省', '宁夏回族自治区', '新疆维吾尔自治区', '台湾省', '香港特别行政区', '澳门特别行政区'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
//移除HTML标签
|
||||
$this->request->filter('trim,strip_tags,htmlspecialchars');
|
||||
}
|
||||
/**
|
||||
* 后台首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//今日收入金额
|
||||
$return_data['today_money'] = db::name('vs_user_recharge')->where('pay_status',2)->whereTime('pay_time', 'today')->sum('money');
|
||||
//总收入金额
|
||||
$return_data['all_money'] = db::name('vs_user_recharge')->where('pay_status',2)->sum('money');
|
||||
//今日充值笔数
|
||||
$return_data['today_money_num'] = db::name('vs_user_recharge')->where('pay_status',2)->whereTime('pay_time', 'today')->count();
|
||||
//总充值笔数
|
||||
$return_data['all_money_num'] = db::name('vs_user_recharge')->where('pay_status',2)->count();
|
||||
//今日后台充值金币数
|
||||
$return_data['admin_today_coin'] =db::name('vs_admin_recharge_log')->where(['type'=>1])->whereTime('createtime', 'today')->sum('change_value');
|
||||
//总充值数
|
||||
$return_data['admin_coin'] = db::name('vs_admin_recharge_log')->where(['type'=>1])->sum('change_value');
|
||||
//今日待付款金额
|
||||
$return_data['today_wait_pay'] = db::name('vs_user_recharge')->where('pay_status',1)->whereTime('createtime', 'today')->sum('money');
|
||||
//总待付款金额
|
||||
$return_data['all_wait_pay'] = db::name('vs_user_recharge')->where('pay_status',1)->sum('money');
|
||||
//今日待付款笔数
|
||||
$return_data['today_wait_pay_num'] = db::name('vs_user_recharge')->where('pay_status',1)->whereTime('createtime', 'today')->count();
|
||||
//总待付款笔数
|
||||
$return_data['all_wait_pay_num'] = db::name('vs_user_recharge')->where('pay_status',1)->count();
|
||||
|
||||
//待办事项
|
||||
//房间审核数
|
||||
$return_data['room_audit_num'] = db::name('vs_room')->where('apply_status',1)->count();
|
||||
//举报待处理数
|
||||
$return_data['report_audit_num'] = db::name('vs_user_inform')->where('status',1)->count();
|
||||
//反馈待处理数
|
||||
$return_data['feedback_audit_num'] = db::name('vs_suggest')->where('is_deal',1)->count();
|
||||
//代办数据
|
||||
$room_audit = db::name('vs_room')->field('u.nickname as title')->alias('a')->join('user u','a.user_id=u.id')->where('a.apply_status',1)->select();
|
||||
foreach ($room_audit as $key => $value) {
|
||||
$room_audit[$key]['title'] = ''.$value['title'].'的房间申请待处理';
|
||||
}
|
||||
$report_audit = db::name('vs_user_inform')->field('u.nickname as title')->alias('a')->join('user u','a.user_id=u.id')->where('a.status',1)->select();
|
||||
foreach ($report_audit as $key => $value) {
|
||||
$report_audit[$key]['title'] = ''.$value['title'].'的举报待处理';
|
||||
}
|
||||
$feedback_audit = db::name('vs_suggest')->field('u.nickname as title')->alias('a')->join('user u','a.user_id=u.id')->where('a.is_deal',1)->select();
|
||||
foreach ($feedback_audit as $key => $value) {
|
||||
$feedback_audit[$key]['title'] = ''.$value['title'].'的反馈待处理';
|
||||
}
|
||||
$audit = array_merge($room_audit,$report_audit,$feedback_audit);
|
||||
$return_data['todo_list'] = $audit;
|
||||
//消息公告
|
||||
$system_message = db::name('system_message')->field('title,createtime')->where('delete_time',0)->select();
|
||||
foreach ($system_message as $key => $value){
|
||||
$system_message[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
$return_data['system_message'] = $system_message;
|
||||
//图标数据
|
||||
//一年内收支情况
|
||||
$year = date('Y');
|
||||
$return_data['income_expend'] = [];//一年内收支情况
|
||||
for($i = 1; $i <= 12; $i++){
|
||||
$key = $i-1;
|
||||
$return_data['income_expend'][$key]['year_month']= $year.'年'.$i.'月';
|
||||
$return_data['income_expend'][$key]['month']= $i.'月';
|
||||
$month_start = strtotime($year.'-'.$i.'-01');
|
||||
$month_end = strtotime($year.'-'.$i.'-31');
|
||||
//充值收入
|
||||
$return_data['income_expend'][$key]['recharge_income'] = db::name('vs_user_recharge')->where('pay_status',2)->where('pay_time', 'between', [$month_start, $month_end])->sum('money');
|
||||
//提现支出
|
||||
$return_data['income_expend'][$key]['withdraw_expend'] = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->where('createtime', 'between', [$month_start, $month_end])->sum('money');
|
||||
}
|
||||
//用户覆盖区域
|
||||
//中国所有省份
|
||||
foreach ($this->province as $key => $value) {
|
||||
$return_data['cover_area'][$key]['province'] = $value;
|
||||
$return_data['cover_area'][$key]['count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->whereLike('address_ip', $value."%")->count();
|
||||
}
|
||||
//会员分析
|
||||
//会员总数
|
||||
$return_data['member_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->count();
|
||||
//今日登录
|
||||
$return_data['online_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->whereTime('logintime', 'today')->count();
|
||||
//七天内未登录
|
||||
$return_data['no_login_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->whereTime('logintime', '<', '7 day ago')->count();
|
||||
//今日注册
|
||||
$return_data['register_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->whereTime('createtime', 'today')->count();
|
||||
//充值会员数
|
||||
$return_data['recharge_count'] = db::name('vs_user_recharge')->where('pay_status',2)->group('user_id')->count();
|
||||
//充值会员百分比
|
||||
$return_data['recharge_count_percent'] = round(($return_data['recharge_count'] / $return_data['member_count']) * 100);
|
||||
//未充值会员数
|
||||
$return_data['no_recharge_count'] = $return_data['member_count'] - $return_data['recharge_count'];
|
||||
$return_data['no_recharge_count_percent'] = round(($return_data['no_recharge_count'] / $return_data['member_count']) * 100);
|
||||
//IOS用户数
|
||||
$return_data['ios_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->where('system', 'iOS')->count();
|
||||
$return_data['ios_count_percent'] = round(($return_data['ios_count'] / $return_data['member_count']) * 100);
|
||||
//安卓用户数
|
||||
$return_data['android_count'] = $return_data['member_count']-$return_data['ios_count'];
|
||||
$return_data['android_count_percent'] = round(($return_data['android_count'] / $return_data['member_count']) * 100);
|
||||
|
||||
//礼物打赏实时统计
|
||||
//一个月内的礼物打赏
|
||||
// $start_time_day = 1;
|
||||
$end_time_day = date('d');
|
||||
for ($i = 0; $i <= $end_time_day; $i++) {
|
||||
if($i == 0){
|
||||
$gift_money[$i]['day'] = 0;
|
||||
$gift_money[$i]['time'] = 0;
|
||||
$gift_money[$i]['gift_total_day'] = 0;
|
||||
$gift_money[$i]['gift_buy_day'] = 0;
|
||||
$gift_money[$i]['gift_backpack_day'] = 0;
|
||||
}else{
|
||||
$gift_money[$i]['day'] = $i;
|
||||
$day_time = strtotime(date('Y-m-') . $i);
|
||||
$day_time_end = strtotime(date('Y-m-') . $i . ' 23:59:59');
|
||||
$gift_money[$i]['time'] = date('Y-m-') . $i;
|
||||
//总礼物打赏值
|
||||
$gift_money[$i]['gift_total_day'] = Db::name('vs_give_gift')->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
//购买礼物打赏价值
|
||||
$gift_money[$i]['gift_buy_day'] = Db::name('vs_give_gift')->where('type',1)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
//背包礼物打赏价值
|
||||
$gift_money[$i]['gift_backpack_day'] = Db::name('vs_give_gift')->where('type',2)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
}
|
||||
|
||||
}
|
||||
$return_data['gift_give_data'] = $gift_money;
|
||||
|
||||
return V(1,"后台首页", $return_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员登录
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
$url = $this->request->get('url', '', 'url_clean');
|
||||
$url = $url ?: 'index/index';
|
||||
if ($this->auth->isLogin()) {
|
||||
return V(0,"已登录", null);
|
||||
}
|
||||
//保持会话有效时长,单位:小时
|
||||
$keeyloginhours = 24;
|
||||
if ($this->request->isPost()) {
|
||||
$username = $this->request->post('username');
|
||||
$password = $this->request->post('password', '', null);
|
||||
$keeplogin = $this->request->post('keeplogin',0);
|
||||
$rule = [
|
||||
'username' => 'require|length:3,30',
|
||||
'password' => 'require|length:3,30',
|
||||
];
|
||||
$data = [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
];
|
||||
$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()]);
|
||||
}
|
||||
AdminLog::setTitle(__('Login'));
|
||||
$result = $this->auth->login($username, $password, $keeplogin ? $keeyloginhours * 3600 : 0);
|
||||
if ($result === true) {
|
||||
Hook::listen("admin_login_after", $this->request);
|
||||
$admin = $this->get_admin_info();
|
||||
return V(1,"登录成功", ['__token__' => $this->request->token(), 'admin' => $admin]);
|
||||
} else {
|
||||
return V(0,"用户名或密码错误", null);
|
||||
}
|
||||
}else{
|
||||
return V(0,"用户名或密码错误", null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->auth->logout();
|
||||
Hook::listen("admin_logout_after", $this->request);
|
||||
return V(1,'退出成功', null);
|
||||
}else{
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取当前登录管理员信息
|
||||
*/
|
||||
public function get_admin_info(){
|
||||
$admin_info = $this->auth->getUserInfo();
|
||||
$admin_info['ruleList'] = $this->auth->getRuleList();
|
||||
return $admin_info;
|
||||
}
|
||||
|
||||
}
|
||||
311
application/adminapi/controller/Inform.php
Normal file
311
application/adminapi/controller/Inform.php
Normal file
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
use function fast\e;
|
||||
|
||||
class Inform extends adminApi
|
||||
{
|
||||
/*
|
||||
* 用户反馈列表
|
||||
*/
|
||||
public function suggest_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
|
||||
$search_name = input('search_id', '');
|
||||
$status = input('status', '');
|
||||
$where = [];
|
||||
//标签名称
|
||||
if($search_name!==''){
|
||||
$where['id'] = $search_name;
|
||||
}
|
||||
if($status!==''){
|
||||
$where['is_deal'] = $status;
|
||||
}
|
||||
|
||||
$list = db::name('vs_suggest')->where($where)->order('id desc')->page($page, $page_limit)->select();
|
||||
$count = db::name('vs_suggest')->where($where)->count();
|
||||
foreach ($list as &$item) {
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
$item['updatetime'] = date('Y-m-d H:i:s', $item['updatetime']);
|
||||
$item['nickname'] = db::name('user')->where('id',$item['user_id'])->value('nickname');
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户反馈详情
|
||||
*/
|
||||
public function suggest_detail(){
|
||||
$id = input('id', '');
|
||||
if($id){
|
||||
$data = db::name('vs_suggest')->where('id',$id)->find();
|
||||
$data['createtime'] = date('Y-m-d H:i:s', $data['createtime']);
|
||||
$data['updatetime'] = date('Y-m-d H:i:s', $data['updatetime']);
|
||||
$data['nickname'] = db::name('user')->where('id',$data['user_id'])->value('nickname');
|
||||
if($data){
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户反馈处理
|
||||
*/
|
||||
public function suggest_deal(){
|
||||
$id = input('id', '');
|
||||
$deal_content = input('deal_content', '');
|
||||
if($deal_content == ''){
|
||||
return V(0,"处理内容不能为空");
|
||||
}
|
||||
$suggest = db::name('vs_suggest')->where('id',$id)->find();
|
||||
if(!$suggest){
|
||||
return V(0,"用户反馈信息不存在");
|
||||
}
|
||||
if($id){
|
||||
$data = db::name('vs_suggest')->where('id',$id)->update(['deal_content' => $deal_content,'is_deal' => 2,'updatetime' => time()]);
|
||||
if($data){
|
||||
db::name('system_message')->insert([
|
||||
'title' => '用户反馈处理结果',
|
||||
'content' => "您的建议反馈信息:".$suggest['content']." 处理结果为:".$deal_content,
|
||||
'type' => 1,
|
||||
'admin_id' => Session::get('admin_id'),
|
||||
'receiving_id' => $suggest['user_id'],
|
||||
'createtime' => time(),
|
||||
]);
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//用户详情
|
||||
public function user_detail(){
|
||||
$id = input('user_id', '');
|
||||
if($id){
|
||||
$data = db::name('user')
|
||||
->field('id,nickname,mobile,status,avatar,sex,birthday,createtime')
|
||||
->where('id',$id)->find();
|
||||
$data['createtime'] = date('Y-m-d H:i:s', $data['createtime']);
|
||||
$data['sex'] = $data['sex'] == 1 ? '男' : '女';
|
||||
$data['status'] = $data['status'] == 1 ? '正常' : '异常';
|
||||
$data['xiaofei'] = db::name('vs_give_gift')->where('user_id',$id)->sum('total_price');
|
||||
if($data){
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
//举报类型列表
|
||||
public function report_type_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_type = input('search_type', '');
|
||||
|
||||
//标签名称
|
||||
if($search_type !==''){
|
||||
$where['type'] = $search_type;
|
||||
}
|
||||
$where['delete_time'] = 0;
|
||||
$count = db::name('vs_user_inform_type')->where($where)->count();
|
||||
$list = db::name('vs_user_inform_type')->where($where)->page($page, $page_limit)->select();
|
||||
foreach ($list as &$item) {
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//举报类型添加
|
||||
public function report_type_add(){
|
||||
$type = input('type', '');
|
||||
if(empty($type)){
|
||||
return V(0,"举报类型不能为空");
|
||||
}
|
||||
$res = db::name('vs_user_inform_type')->insert(['type' => $type,'createtime' => time()]);
|
||||
if(!$res){
|
||||
return V(0,"失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
//举报类型编辑
|
||||
public function report_type_edit(){
|
||||
|
||||
$id = input('id', '');
|
||||
if($id){
|
||||
$data = [
|
||||
'updatetime' => time(),
|
||||
];
|
||||
$type = input('type', '');
|
||||
if($type){
|
||||
$data['type'] = $type;
|
||||
}
|
||||
|
||||
$res = db::name('vs_user_inform_type')->where('id',$id)->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
$data = [
|
||||
'type' => input('type', ''),
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = db::name('vs_user_inform_type')->insert($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//举报类型删除
|
||||
public function report_type_del(){
|
||||
$id = input('id', '');
|
||||
if($id){
|
||||
$res = db::name('vs_user_inform_type')->where('id',$id)->update(['delete_time'=>time()]);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
//用户举报列表
|
||||
public function report_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_id = input('user_id', '');
|
||||
$search_type = input('search_type_id', '');
|
||||
$report_type = input('report_type', '');//1-用户,2房间,3动态
|
||||
$search_status = input('search_status', '');//1-待处理,2-已处理,3-已忽略
|
||||
$where = [
|
||||
'delete_time' => 0,
|
||||
];
|
||||
if($search_id !==''){
|
||||
$where['user_id'] = $search_id;
|
||||
}
|
||||
if($search_type !==''){
|
||||
$where['type_id'] = $search_type;
|
||||
}
|
||||
if($search_status !==''){
|
||||
$where['status'] = $search_status;
|
||||
}
|
||||
if($report_type !==''){
|
||||
$where['report_type'] = $report_type;
|
||||
}
|
||||
|
||||
$count = db::name('vs_user_inform')->where($where)->count();
|
||||
$list = db::name('vs_user_inform')->where($where)->order('id desc')->page($page, $page_limit)->select();
|
||||
foreach ($list as &$item) {
|
||||
$user_info = db::name('user')->where('id',$item['user_id'])->field('nickname,user_code')->find();
|
||||
if($item['report_type'] ==1){
|
||||
$from_info = db::name('user')->where('id',$item['from_id'])->field('nickname as title,user_code as code')->find();
|
||||
}elseif($item['report_type'] ==2){
|
||||
$from_info = db::name('vs_room')->where('id',$item['from_id'])->field('room_number as code,room_name as title')->find();
|
||||
}elseif($item['report_type'] ==3){
|
||||
$from_info = db::name('user_zone')->where('id',$item['from_id'])->field('content as title ,id as code')->find();
|
||||
}
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
$item['updatetime'] = date('Y-m-d H:i:s', $item['updatetime']);
|
||||
$item['nickname'] = $user_info['user_code'] ."-".$user_info['nickname'];
|
||||
$item['type_name'] = db::name('vs_user_inform_type')->where('id',$item['type_id'])->value('type');
|
||||
$item['from_id_title'] = $from_info['code'] ."-".$from_info['title'];
|
||||
//举报的什么:1-用户,2房间,3动态
|
||||
$item['report_type_str'] = [
|
||||
1=>'用户',
|
||||
2=>'房间',
|
||||
3=>'动态'
|
||||
][$item['report_type']];
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//用户举报处理
|
||||
public function report_deal(){
|
||||
$id = input('id', '');
|
||||
$processing = input('processing', '');
|
||||
$status = input('status', '');
|
||||
if(empty($processing)){
|
||||
return V(0,"处理内容不能为空");
|
||||
}
|
||||
if($id){
|
||||
$suggest = db::name('vs_user_inform')->where('id',$id)->find();
|
||||
$data = [
|
||||
'updatetime' => time(),
|
||||
'status' => $status,
|
||||
'processing' => $processing
|
||||
];
|
||||
$res = db::name('vs_user_inform')->where('id',$id)->update($data);
|
||||
if($res){
|
||||
if($status == 2){
|
||||
$content = "您的举报:".$suggest['content']." 已被处理 处理结果为:".$processing;
|
||||
}else{
|
||||
$content = "您的举报:".$suggest['content']." 已被拒绝 拒绝原因为:".$processing;
|
||||
}
|
||||
db::name('system_message')->insert([
|
||||
'title' => '举报处理结果',
|
||||
'content' => "您的举报:".$suggest['content']." 处理结果为:".$processing,
|
||||
'type' => 1,
|
||||
'admin_id' => Session::get('admin_id'),
|
||||
'receiving_id' => $suggest['user_id'],
|
||||
'createtime' => time(),
|
||||
]);
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
62
application/adminapi/controller/Invited.php
Normal file
62
application/adminapi/controller/Invited.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
|
||||
class Invited extends adminApi
|
||||
{
|
||||
|
||||
//邀请列表
|
||||
public function invitedList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
|
||||
$count = db::name('vs_user_invited')->count();
|
||||
$lists = db::name('vs_user_invited')->alias('a')->field('a.*,b.nickname as parent_username,c.nickname as username')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->join('user c', 'a.sub_user_id = c.id', 'left')
|
||||
->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$value) {
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$value['parent_username'] = $value['parent_username'] . '-' .$value['user_id'];
|
||||
$value['username'] = $value['username'] . '-' .$value['sub_user_id'];
|
||||
}
|
||||
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
//邀请收益列表
|
||||
public function invitedIncomeList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$count = db::name('vs_user_invited_income_log')->count();
|
||||
$lists = db::name('vs_user_invited_income_log')->alias('a')
|
||||
->field('a.*,b.nickname as username,c.nickname as parent_username')
|
||||
->join('user b', 'a.sub_user_id = b.id', 'left')
|
||||
->join('user c', 'a.user_id = c.id', 'left')
|
||||
->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$value) {
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$value['username'] = $value['username'] . '-' .$value['sub_user_id'];
|
||||
$value['parent_username'] = $value['parent_username'] . '-' .$value['user_id'];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
}
|
||||
324
application/adminapi/controller/Level.php
Normal file
324
application/adminapi/controller/Level.php
Normal file
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 等级管理
|
||||
* @internal
|
||||
*/
|
||||
class Level extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table_wealth_level = 'vs_wealth_level';
|
||||
protected $table_charm_level = 'vs_charm_level';
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
//财富等级
|
||||
|
||||
/*
|
||||
* 财富等级列表
|
||||
*/
|
||||
public function wealth_level_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where=[];
|
||||
$count = db::name($this->table_wealth_level)->where($where)->count();
|
||||
$lists = db::name($this->table_wealth_level)->where($where)->order('level asc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$v) {
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
//等级特权
|
||||
$gift_id= db::name("vs_wealth_level_rights")->where(['level_id'=>$v['id']])->value('gift_id');
|
||||
//查询座驾信息
|
||||
$v['gift_id'] = $gift_id;
|
||||
$v['privilege']= DB::name("vs_decorate")->where(['did' => $gift_id, 'delete_time' => 0])->value('base_image');
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加财富等级
|
||||
*/
|
||||
public function wealth_level_add(){
|
||||
$level = input('level', '');
|
||||
$name = input('name', '');
|
||||
$image = input('image', '');
|
||||
$change_value = input('change_value', '');
|
||||
$coins = input('coins', '');
|
||||
$status = input('status', '');
|
||||
$gift_id = input('gift_id', '');
|
||||
$bg_image= input('bg_image', '');
|
||||
$color= input('color', '');
|
||||
if($level == ''){
|
||||
return V(0,"请输入等级");
|
||||
}
|
||||
if($name == ''){
|
||||
return V(0,"请输入等级名称");
|
||||
}
|
||||
$level_info = db::name($this->table_wealth_level)->where(['level'=>$level])->find();
|
||||
if($level_info){
|
||||
return V(0,"等级已存在");
|
||||
}
|
||||
$level_data = [
|
||||
'level' => $level,
|
||||
'name' => $name,
|
||||
'coins' => $coins,
|
||||
'status' => $status,
|
||||
'image' => $image,
|
||||
'change_value' => $change_value,
|
||||
'createtime' => time(),
|
||||
'bg_image' => $bg_image,
|
||||
'color' => $color,
|
||||
];
|
||||
$level_id = db::name($this->table_wealth_level)->insertGetId($level_data);
|
||||
if(!$level_id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
//等级特权
|
||||
$decorate = db::name("vs_decorate")->where(['did' => $gift_id, 'delete_time' => 0])->find();
|
||||
if(empty($decorate)){
|
||||
return V(0,"请选择等级特权");
|
||||
}
|
||||
if($gift_id){
|
||||
db::name('vs_wealth_level_rights')->insert([
|
||||
'level_id' => $level_id,
|
||||
'gift_id' => $gift_id,
|
||||
'createtime' => time()
|
||||
]);
|
||||
}
|
||||
return V(1,"成功", ['id'=>$level]);
|
||||
}
|
||||
/*
|
||||
* 财富等级编辑
|
||||
*/
|
||||
public function wealth_level_edit(){
|
||||
$level = input('level', '');
|
||||
$name = input('name', '');
|
||||
$image = input('image', '');
|
||||
$change_value = input('change_value', '');
|
||||
$coins = input('coins', '');
|
||||
$status = input('status', '');
|
||||
$gift_id = input('gift_id', '');
|
||||
$bg_image= input('bg_image', '');
|
||||
$color= input('color', '');
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($level){
|
||||
$level_data['level'] = $level;
|
||||
}
|
||||
if($name){
|
||||
$level_data['name'] = $name;
|
||||
}
|
||||
if($image){
|
||||
$level_data['image'] = $image;
|
||||
}
|
||||
if($status){
|
||||
$level_data['status'] = $status;
|
||||
}
|
||||
if($change_value){
|
||||
$level_data['change_value'] = $change_value;
|
||||
}
|
||||
if($coins){
|
||||
$level_data['coins'] = $coins;
|
||||
}
|
||||
if($bg_image){
|
||||
$level_data['bg_image'] = $bg_image;
|
||||
}
|
||||
if($color){
|
||||
$level_data['color'] = $color;
|
||||
}
|
||||
$level_data['updatetime'] = time();
|
||||
if($gift_id){
|
||||
$rights_gift_id = db::name('vs_wealth_level_rights')->where(['level_id'=>$id])->value('gift_id');
|
||||
if(empty($rights_gift_id)){
|
||||
db::name('vs_wealth_level_rights')->insert([
|
||||
'level_id' => $id,
|
||||
'gift_id' => $gift_id,
|
||||
'createtime' => time()
|
||||
]);
|
||||
}else{
|
||||
if($rights_gift_id != $gift_id){
|
||||
db::name('vs_wealth_level_rights')->where(['level_id'=>$id])->update(['gift_id'=>$gift_id,'updatetime'=>time()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$result = db::name($this->table_wealth_level)->where(['id'=>$id])->update($level_data);
|
||||
if(!$result){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 财富等级删除
|
||||
*/
|
||||
public function wealth_level_del(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$result = db::name($this->table_wealth_level)->where(['id'=>$id])->delete();
|
||||
if(!$result){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
//魅力等级
|
||||
|
||||
/*
|
||||
* 魅力等级列表
|
||||
*/
|
||||
public function charm_level_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where=[];
|
||||
$count = db::name($this->table_charm_level)->where($where)->count();
|
||||
$lists = db::name($this->table_charm_level)->where($where)->order('level asc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$v) {
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 魅力等级添加
|
||||
*/
|
||||
public function charm_level_add(){
|
||||
$level = input('level', '');
|
||||
$name = input('name', '');
|
||||
$image = input('image', '');
|
||||
$change_value = input('change_value', '');
|
||||
$status = input('status', '');
|
||||
$rights_icon = input('rights_icon', '');
|
||||
$bg_image = input('bg_image', '');
|
||||
$color = input('color', '');
|
||||
if($level == ''){
|
||||
return V(0,"等级不能为空");
|
||||
}
|
||||
if($name == ''){
|
||||
return V(0,"名称不能为空");
|
||||
}
|
||||
$level_info = db::name($this->table_charm_level)->where(['level'=>$level])->find();
|
||||
if($level_info){
|
||||
return V(0,"等级已存在");
|
||||
}
|
||||
$level_data = [
|
||||
'level' => $level,
|
||||
'name' => $name,
|
||||
'status' => $status,
|
||||
'image' => $image,
|
||||
'change_value' => $change_value,
|
||||
'rights_icon' => $rights_icon,
|
||||
'createtime' => time(),
|
||||
'bg_image' => $bg_image,
|
||||
'color' => $color,
|
||||
];
|
||||
$level_id = db::name($this->table_charm_level)->insertGetId($level_data);
|
||||
if(!$level_id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功", ['id'=>$level_id]);
|
||||
}
|
||||
|
||||
/*
|
||||
* 魅力等级编辑
|
||||
*/
|
||||
public function charm_level_edit(){
|
||||
$level = input('level', '');
|
||||
$name = input('name', '');
|
||||
$image = input('image', '');
|
||||
$change_value = input('change_value', '');
|
||||
$status = input('status', '');
|
||||
$rights_icon = input('rights_icon', '');
|
||||
$id = input('id', '');
|
||||
$bg_image = input('bg_image', '');
|
||||
$color = input('color', '');
|
||||
if($id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($level){
|
||||
$level_data['level'] = $level;
|
||||
}
|
||||
if($name){
|
||||
$level_data['name'] = $name;
|
||||
}
|
||||
if($image){
|
||||
$level_data['image'] = $image;
|
||||
}
|
||||
if($status){
|
||||
$level_data['status'] = $status;
|
||||
}
|
||||
if($change_value){
|
||||
$level_data['change_value'] = $change_value;
|
||||
}
|
||||
if($rights_icon){
|
||||
$level_data['rights_icon'] = $rights_icon;
|
||||
}
|
||||
if($bg_image){
|
||||
$level_data['bg_image'] = $bg_image;
|
||||
}
|
||||
if($color){
|
||||
$level_data['color'] = $color;
|
||||
}
|
||||
$result = db::name($this->table_charm_level)->where(['id'=>$id])->update($level_data);
|
||||
if(!$result){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 魅力等级删除
|
||||
*/
|
||||
public function charm_level_del(){
|
||||
$id = input('id', '');
|
||||
if($id == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
$result = db::name($this->table_charm_level)->where(['id'=>$id])->delete();
|
||||
if(!$result){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 财富等级特权列表
|
||||
*/
|
||||
public function wealth_level_rights_list(){
|
||||
$decorate = db::name("vs_decorate")->where(['type' => 2, 'delete_time' => 0])->select();
|
||||
$return_data = [];
|
||||
foreach ($decorate as $k=>$v) {
|
||||
$return_data[$k]['id'] = $v['did'];
|
||||
$return_data[$k]['title'] = $v['title'];
|
||||
}
|
||||
return V(1,"成功",['data'=>$return_data]);
|
||||
}
|
||||
}
|
||||
119
application/adminapi/controller/Page.php
Normal file
119
application/adminapi/controller/Page.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 单页
|
||||
* @internal
|
||||
*/
|
||||
class Page extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'vs_page';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function page_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$title = input('title', '');
|
||||
$where = [];
|
||||
$where['delete_time'] = 0;
|
||||
if($title){
|
||||
$where['title'] = ['like', "%$title%"];
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists = db::name($this->table)->where($where)->order('aid desc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['admin'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function page_add(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$title = input('title', '');
|
||||
$url= input('url', '');
|
||||
// $content = input('content', '');
|
||||
$content =$_POST['content']??"";
|
||||
if(empty($title) || empty($content)){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'url' => $url,
|
||||
'content' => $content,
|
||||
'admin_id' => $admin_id,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if(!$res){
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
return V(1, "添加成功");
|
||||
}
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public function page_edit(){
|
||||
$title = input('title', '');
|
||||
$url= input('url', '');
|
||||
// $content = input('content', '');
|
||||
$content =$_POST['content']??"";
|
||||
$id = input('id', '');
|
||||
if($title){
|
||||
$data['title'] = $title;
|
||||
}
|
||||
if($url){
|
||||
$data['url'] = $url;
|
||||
}
|
||||
if($content){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name($this->table)->where(['aid'=>$id])->update($data);
|
||||
if(!$res){
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1, "修改成功");
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function page_del(){
|
||||
$id = input('id', '');
|
||||
$res = db::name($this->table)->where(['aid'=>$id])->update(['delete_time'=>time()]);
|
||||
if(!$res){
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
return V(1, "删除成功");
|
||||
}
|
||||
|
||||
}
|
||||
313
application/adminapi/controller/Role.php
Normal file
313
application/adminapi/controller/Role.php
Normal file
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AuthGroup;
|
||||
use app\admin\model\AuthRule;
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\controller\Backend;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* 角色管理
|
||||
*
|
||||
* @icon
|
||||
* @remark 角色组可以有多个,角色有上下级层级关系,如果子角色有角色组和管理员的权限则可以派生属于自己组别下级的角色组或管理员
|
||||
*/
|
||||
class Role extends adminApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \app\admin\model\AuthGroup
|
||||
*/
|
||||
protected $model = null;
|
||||
//当前登录管理员所有子组别
|
||||
protected $childrenGroupIds = [];
|
||||
//当前组别列表数据
|
||||
protected $grouplist = [];
|
||||
protected $groupdata = [];
|
||||
//无需要权限判断的方法
|
||||
protected $noNeedRight = ['roletree'];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = model('admin/AuthGroup');
|
||||
|
||||
$this->childrenGroupIds = $this->auth->getChildrenGroupIds(true);
|
||||
|
||||
$groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray();
|
||||
|
||||
Tree::instance()->init($groupList);
|
||||
$groupList = [];
|
||||
if ($this->auth->isSuperAdmin()) {
|
||||
$groupList = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0));
|
||||
} else {
|
||||
$groups = $this->auth->getGroups();
|
||||
$groupIds = [];
|
||||
foreach ($groups as $m => $n) {
|
||||
if (in_array($n['id'], $groupIds) || in_array($n['pid'], $groupIds)) {
|
||||
continue;
|
||||
}
|
||||
$groupList = array_merge($groupList, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['pid'])));
|
||||
foreach ($groupList as $index => $item) {
|
||||
$groupIds[] = $item['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$groupName = [];
|
||||
foreach ($groupList as $k => $v) {
|
||||
$groupName[$v['id']] = $v['name'];
|
||||
}
|
||||
$this->grouplist = $groupList;
|
||||
$this->groupdata = $groupName;
|
||||
$this->assignconfig("admin", ['id' => $this->auth->id, 'group_ids' => $this->auth->getGroupIds()]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$list = $this->grouplist;
|
||||
$total = count($list);
|
||||
$result = array("total" => $total, "list" => $list);
|
||||
return V(1,"角色管理列表", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post();
|
||||
$params['rules'] = explode(',', $params['rules']);
|
||||
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
||||
return V(0,'请选择正确的父角色', null);
|
||||
}
|
||||
$parentmodel = model("admin/AuthGroup")->get($params['pid']);
|
||||
if (!$parentmodel) {
|
||||
return V(0,'请选择正确的父角色', null);
|
||||
}
|
||||
// 父级别的规则节点
|
||||
$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);
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$id = $params['id'];
|
||||
if (!in_array($id, $this->childrenGroupIds)) {
|
||||
return V(0,'你没有权限访问', null);
|
||||
}
|
||||
$row = $this->model->get(['id' => $id]);
|
||||
if (!$row) {
|
||||
return V(0,'角色不存在', null);
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
//父节点不能是非权限内节点
|
||||
if (!in_array($params['pid'], $this->childrenGroupIds)) {
|
||||
return V(0,'请选择正确的父角色', null);
|
||||
}
|
||||
// 父节点不能是它自身的子节点或自己本身
|
||||
if (in_array($params['pid'], Tree::instance()->getChildrenIds($row->id, true))) {
|
||||
return V(0,'父节点不能是它自身的子节点或自己本身', null);
|
||||
}
|
||||
$params['rules'] = explode(',', $params['rules']);
|
||||
|
||||
$parentmodel = model("admin/AuthGroup")->get($params['pid']);
|
||||
if (!$parentmodel) {
|
||||
return V(0,'请选择正确的父角色', null);
|
||||
}
|
||||
// 父级别的规则节点
|
||||
$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("admin/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("admin/AuthGroup")->saveAll($childparams);
|
||||
Db::commit();
|
||||
return V(1,"成功", null);
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
// $this->view->assign("row", $row);
|
||||
// return $this->view->fetch();
|
||||
}
|
||||
|
||||
/*
|
||||
* 详情
|
||||
*/
|
||||
public function detail(){
|
||||
$id =input('id', 0);
|
||||
if (!$id) {
|
||||
return V(0,'参数错误', null);
|
||||
}
|
||||
$row = $this->model->get($id);
|
||||
if (!$row) {
|
||||
return V(0,'数据不存在', null);
|
||||
}
|
||||
return V(1,'成功', $row);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = null)
|
||||
{
|
||||
$ids = $ids ? $ids : $this->request->post("ids");
|
||||
if (!$ids) {
|
||||
return V(0,'参数错误', null);
|
||||
}
|
||||
$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('admin/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;
|
||||
}
|
||||
}
|
||||
$count = $this->model->where('id', 'in', $ids)->delete();
|
||||
if ($count) {
|
||||
return V(1,'成功', $count);
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取角色权限树
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function roletree()
|
||||
{
|
||||
$model = model('admin/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('admin/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('admin/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);
|
||||
}
|
||||
return V(1,'成功', $nodeList);
|
||||
} else {
|
||||
return V(0,'父组别不能是它的子组别或它自己', null);
|
||||
}
|
||||
} else {
|
||||
return V(0,'角色未找到', null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1578
application/adminapi/controller/Room.php
Normal file
1578
application/adminapi/controller/Room.php
Normal file
File diff suppressed because it is too large
Load Diff
204
application/adminapi/controller/Rule.php
Normal file
204
application/adminapi/controller/Rule.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AuthRule;
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\controller\Backend;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
|
||||
/**
|
||||
* 规则管理
|
||||
*
|
||||
* @icon fa fa-list
|
||||
* @remark 规则通常对应一个控制器的方法,同时左侧的菜单栏数据也从规则中体现,通常建议通过控制台进行生成规则节点
|
||||
*/
|
||||
class Rule extends adminApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @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('app\admin\model\AuthRule');
|
||||
// 必须将结果集转换为数组
|
||||
$ruleList = \think\Db::name("auth_rule")->field('type,condition,remark,createtime,updatetime', true)->order('weigh DESC,id ASC')->select();
|
||||
foreach ($ruleList as $k => &$v) {
|
||||
$v['title'] = __($v['title']);
|
||||
}
|
||||
|
||||
unset($v);
|
||||
Tree::instance()->init($ruleList);
|
||||
$this->rulelist = Tree::instance()->getTreeArray(0);
|
||||
$ruledata = [0 => __('None')];
|
||||
foreach ($this->rulelist as $k => &$v) {
|
||||
if (!$v['ismenu']) {
|
||||
continue;
|
||||
}
|
||||
$ruledata[$v['id']] = $v['title'];
|
||||
unset($v['spacer']);
|
||||
}
|
||||
unset($v);
|
||||
}
|
||||
|
||||
/*
|
||||
* 菜单接口
|
||||
*/
|
||||
public function menus(){
|
||||
$ruleList = Tree::instance()->getTreeArray(0);
|
||||
$ruleList = $this->getTree($ruleList,['title','url','name','icon','extend']);
|
||||
return V(1,"系统菜单接口", $ruleList);
|
||||
}
|
||||
public function getTree($ruleList,$fieldData=[]){
|
||||
$ruledata = [];
|
||||
$i= 0;
|
||||
foreach ($ruleList as $k => &$v) {
|
||||
if (!$v['ismenu']) {
|
||||
continue;
|
||||
}
|
||||
if(!$this->auth->check($v['name'])){
|
||||
continue;
|
||||
}
|
||||
foreach ($fieldData as $key => $value) {
|
||||
$ruledata[$i][$value] = $v[$value];
|
||||
}
|
||||
if(!empty($v['childlist'])){
|
||||
$ruledata[$i]['childlist'] = $this->getTree($v['childlist'],$fieldData);
|
||||
if(empty($ruledata[$i]['childlist'])){
|
||||
unset($ruledata[$i]['childlist']);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $ruledata;
|
||||
}
|
||||
|
||||
/*
|
||||
* 菜单列表(添加时选择父级菜单用)
|
||||
*/
|
||||
public function list(){
|
||||
$ruledata = [0 => "无"];
|
||||
foreach ($this->rulelist as $k => &$v) {
|
||||
if (!$v['ismenu']) {
|
||||
continue;
|
||||
}
|
||||
$ruledata[$v['id']] = $v['title'];
|
||||
unset($v['spacer']);
|
||||
}
|
||||
unset($v);
|
||||
return V(1,"系统菜单接口", $ruledata);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$list = $this->rulelist;
|
||||
$total = count($this->rulelist);
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
return V(1,"菜单规则列表", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// $this->token();
|
||||
$params = $this->request->post();
|
||||
if ($params) {
|
||||
if (!$params['ismenu'] && !$params['pid']) {
|
||||
return V(0,'非菜单规则节点必须有父级', null);
|
||||
}
|
||||
$result = $this->model->validate('app\admin\validate\AuthRule')->save($params);
|
||||
if ($result === false) {
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
return V(1,'操作成功', null);
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($ids = NULL)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// $this->token();
|
||||
$params = $this->request->post();
|
||||
if ($params) {
|
||||
if (!$params['ismenu'] && !$params['pid']) {
|
||||
return V(0,'非菜单规则节点必须有父级', null);
|
||||
}
|
||||
if ($params['pid'] == $params['id']) {
|
||||
return V(0,'父级不能是它自己', null);
|
||||
}
|
||||
if ($params['pid'] != $params['pid']) {
|
||||
$childrenIds = Tree::instance()->init(collection(AuthRule::select())->toArray())->getChildrenIds($params['id']);
|
||||
if (in_array($params['pid'], $childrenIds)) {
|
||||
return V(0,'父组别不能是它的子组别', null);
|
||||
}
|
||||
}
|
||||
//这里需要针对name做唯一验证
|
||||
$ruleValidate = \think\Loader::validate('app\admin\validate\AuthRule');
|
||||
$ruleValidate->rule([
|
||||
'name' => 'require|unique:AuthRule,name,' . $params['id'],
|
||||
]);
|
||||
$result = $this->model->validate('app\admin\validate\AuthRule')->save($params, $params['id']);
|
||||
if ($result === false) {
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
return V(1,'操作成功', null);
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 详情
|
||||
*/
|
||||
public function detail(){
|
||||
$id = $this->request->param('id');
|
||||
$row = $this->model->get($id);
|
||||
if (!$row) {
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
return V(1,"详情", $row);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del($ids = "")
|
||||
{
|
||||
$ids = input('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__');
|
||||
return V(1,'操作成功', null);return V(1,'操作成功', null);
|
||||
}
|
||||
}
|
||||
return V(0,'操作失败', null);
|
||||
}
|
||||
}
|
||||
476
application/adminapi/controller/Statistical.php
Normal file
476
application/adminapi/controller/Statistical.php
Normal file
@@ -0,0 +1,476 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
use Yzh\YunPay;
|
||||
|
||||
class Statistical extends adminApi
|
||||
{
|
||||
//初始化
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
//充值排行统计
|
||||
public function get_recharge_ranking()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_uid = input('search_uid', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$where=[];
|
||||
//标签名称
|
||||
if($search_uid !== ''){
|
||||
$user_id = db::name('user')->where('user_code', $search_uid)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
$username = input('username', '');
|
||||
if($username !== ''){
|
||||
$user_id = db::name('user')->where('nickname', $username)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($begin_time !== ''){
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
}
|
||||
|
||||
$where['pay_status'] = 2;//1待支付,2已支付
|
||||
$where['order_type'] = 1;//订单类型:1 充值
|
||||
|
||||
$count = db::name('vs_user_recharge')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->count();
|
||||
$lists = db::name('vs_user_recharge')
|
||||
->field('rid,createtime,user_id,sum(money) as money,sum(coin) as coin')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->order('money desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['user_name'] = db::name('user')->where('id', $value['user_id'])->value('nickname').'-'.
|
||||
db::name('user')->where('id', $value['user_id'])->value('user_code');
|
||||
$lists[$key]['avatar'] = db::name('user')->where('id', $value['user_id'])->value('avatar');
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_user_recharge')->where($where)->sum('money'),
|
||||
'total_gold' => db::name('vs_user_recharge')->where($where)->sum('coin')
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//送礼、收礼排行
|
||||
public function get_gift_ranking()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$type = input('type', 1);//1送礼,2收礼
|
||||
$search_uid = input('search_uid', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$where=[];
|
||||
$group = 'user_id';
|
||||
if($type == 2){
|
||||
$group = 'gift_user';
|
||||
}
|
||||
//标签名称
|
||||
if($search_uid !== ''){
|
||||
$user_id = db::name('user')->where('user_code', $search_uid)->value('id');
|
||||
if($type == 1){
|
||||
$where['user_id'] = $user_id;
|
||||
}else{
|
||||
$where['gift_user'] = $user_id;
|
||||
}
|
||||
}
|
||||
$username = input('username', '');
|
||||
if($username !== ''){
|
||||
$user_id = db::name('user')->where('nickname', $username)->value('id');
|
||||
if($type == 1){
|
||||
$where['user_id'] = $user_id;
|
||||
}else{
|
||||
$where['gift_user'] = $user_id;
|
||||
}
|
||||
}
|
||||
if($begin_time !== ''){
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
}
|
||||
$count = db::name('vs_give_gift')
|
||||
->where($where)
|
||||
->group($group)
|
||||
->count();
|
||||
$lists = db::name('vs_give_gift')
|
||||
->field('id,createtime,user_id,gift_user,sum(total_price) as total_price,sum(number) as number')
|
||||
->where($where)
|
||||
->group($group)
|
||||
->order('total_price desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
if($type == 1){
|
||||
$lists[$key]['user_name'] = db::name('user')->where('id', $value['user_id'])->value('nickname').'-'.
|
||||
db::name('user')->where('id', $value['user_id'])->value('user_code');
|
||||
$lists[$key]['avatar'] = db::name('user')->where('id', $value['user_id'])->value('avatar');
|
||||
}else{
|
||||
$lists[$key]['user_name'] = db::name('user')->where('id', $value['gift_user'])->value('nickname').'-'.
|
||||
db::name('user')->where('id', $value['gift_user'])->value('user_code');
|
||||
$lists[$key]['avatar'] = db::name('user')->where('id', $value['gift_user'])->value('avatar');
|
||||
}
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->where($where)->sum('total_price'),
|
||||
'total_num' => db::name('vs_give_gift')->where($where)->sum('number')
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//消费排行
|
||||
public function get_consumption_ranking()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_uid = input('search_uid', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$where=[];
|
||||
//标签名称
|
||||
if($search_uid !== ''){
|
||||
$user_id = db::name('user')->where('user_code', $search_uid)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
$username = input('username', '');
|
||||
if($username !== ''){
|
||||
$user_id = db::name('user')->where('nickname', $username)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($begin_time !== ''){
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
}
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益
|
||||
$where['change_type'] = ['in', [4,7,10,17,20]];
|
||||
$count = db::name('vs_user_money_log')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->count();
|
||||
$lists = db::name('vs_user_money_log')
|
||||
->field('log_id,createtime,user_id,sum(change_value) as change_value')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->order('change_value desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['user_name'] = db::name('user')->where('id', $value['user_id'])->value('nickname').'-'.
|
||||
db::name('user')->where('id', $value['user_id'])->value('user_code');
|
||||
$lists[$key]['avatar'] = db::name('user')->where('id', $value['user_id'])->value('avatar');
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_user_money_log')->where($where)->sum('change_value')
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//房间流水统计
|
||||
public function get_room_flow_statistics()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_room_id = input('search_room_id', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$where=[];
|
||||
//标签名称
|
||||
$where['from_id'] = ['>' , 0];
|
||||
if($search_room_id !== ''){
|
||||
$room_id = db::name('vs_room')->where('room_number', $search_room_id)->value('id');
|
||||
$where['from_id'] = $room_id;
|
||||
}
|
||||
$room_name = input('room_name', '');
|
||||
if($room_name !== ''){
|
||||
$room_id = db::name('vs_room')->where('room_name', $room_name)->value('id');
|
||||
$where['from_id'] = $room_id;
|
||||
}
|
||||
if($begin_time !== ''){
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
}
|
||||
//不为空
|
||||
$where['from'] = 2;
|
||||
$count = db::name('vs_give_gift')
|
||||
->where($where)
|
||||
->group('from_id')
|
||||
->count();
|
||||
$lists = db::name('vs_give_gift')
|
||||
->field('id,createtime,user_id,gift_user,sum(total_price) as total_price,sum(number) as number,from_id')
|
||||
->where($where)
|
||||
->group('from_id')
|
||||
->order('total_price desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$room = db::name('vs_room')->where('id', $value['from_id'])->find();
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['room_name'] = $room['room_name'].'-'.$room['room_number'];
|
||||
$lists[$key]['room_number'] = $room['room_number'];
|
||||
$lists[$key]['room_cover'] = db::name('vs_room')->where('id', $value['from_id'])->value('room_cover');
|
||||
$label = db::name('vs_room')->where('id', $value['from_id'])->value('label_id');
|
||||
$lists[$key]['label'] = db::name('vs_room_label')->where('id', $label)->value('label_name');
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->where($where)->sum('total_price')
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//充值列表
|
||||
public function get_recharge_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_uid = input('search_uid', '');
|
||||
$pay_stime = input('pay_stime', '');
|
||||
$pay_etime = input('pay_etime', '');
|
||||
$pay_status = input('pay_status', '');//1.待支付 2.支付成功
|
||||
$order_sn = input('order_sn', '');
|
||||
$pay_type = input('pay_type', '');//1.微信 2.支付宝
|
||||
$money = input('money', '');
|
||||
$where=[];
|
||||
//标签名称
|
||||
if($search_uid !== ''){
|
||||
$user_id = db::name('user')->where('user_code', $search_uid)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
|
||||
}
|
||||
if($pay_stime !== ''){
|
||||
$where['createtime'] = ['>=', strtotime($pay_stime)];
|
||||
}
|
||||
if($pay_etime !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($pay_etime.' 23:59:59')];
|
||||
}
|
||||
if(!empty($pay_stime) && !empty($pay_etime)){
|
||||
$where['createtime'] = ['between',[strtotime($pay_stime),strtotime($pay_etime.' 23:59:59')]];
|
||||
}
|
||||
if($pay_status !== ''){
|
||||
$where['pay_status'] = $pay_status;
|
||||
}
|
||||
if($order_sn !== ''){
|
||||
$where['order_sn'] = $order_sn;
|
||||
}
|
||||
if($pay_type !== ''){
|
||||
if($pay_type == 1){
|
||||
$where['pay_type'] = ['in', [1,4]];
|
||||
}elseif ($pay_type == 2){
|
||||
$where['pay_type'] = ['in', [2,3]];
|
||||
}
|
||||
}
|
||||
if($money !== ''){
|
||||
$where['money'] = $money;
|
||||
}
|
||||
|
||||
$count = db::name('vs_user_recharge')->where($where)->count();
|
||||
$lists = db::name('vs_user_recharge')->where($where)->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['user_name'] = db::name('user')->where('id', $value['user_id'])->value('nickname').'-'.
|
||||
db::name('user')->where('id', $value['user_id'])->value('user_code');
|
||||
if($value['pay_type'] == 1 || $value['pay_type'] == 4){
|
||||
$lists[$key]['pay_type_name'] = '微信支付';
|
||||
}elseif ($value['pay_type'] == 2 || $value['pay_type'] == 3){
|
||||
$lists[$key]['pay_type_name'] = '支付宝支付';
|
||||
}
|
||||
$lists[$key]['pay_status_str'] = $value['pay_status'] == 1 ? '待支付' : '已支付';
|
||||
$lists[$key]['pay_time'] = $value['pay_time'] == 0 ? '' : date('Y-m-d H:i:s', $value['pay_time']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
//总收入
|
||||
$wherew=[];
|
||||
$return_data['total_money'] = db::name('vs_user_recharge')->sum('money');
|
||||
//未支付
|
||||
$return_data['unpaid_money'] = db::name('vs_user_recharge')->where('pay_status',1)->sum('money');
|
||||
//已支付
|
||||
$return_data['paid_money'] = db::name('vs_user_recharge')->where('pay_status',2)->sum('money');
|
||||
//微信支付
|
||||
$wherew['pay_type'] = ['in', [1,4]];
|
||||
$return_data['wx_money'] = db::name('vs_user_recharge')->where('pay_status',2)->where($wherew)->sum('money');
|
||||
//支付宝支付
|
||||
$wherez['pay_type'] = ['in', [2,3]];
|
||||
$return_data['ali_money'] = db::name('vs_user_recharge')->where('pay_status',2)->where($wherez)->sum('money');
|
||||
//金币数量
|
||||
$return_data['gold_num'] = db::name('vs_user_recharge')->where('pay_status',2)->sum('coin');
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//兑换列表
|
||||
public function get_exchange_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_uid = input('search_uid', '');
|
||||
$where=[];
|
||||
if($search_uid !== ''){
|
||||
if(is_numeric($search_uid)){
|
||||
$where['b.user_code'] = $search_uid;
|
||||
}else{
|
||||
$where['b.nickname'] = ['like', '%'.$search_uid.'%'];
|
||||
}
|
||||
}
|
||||
//时间筛选
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if($start_time !== ''){
|
||||
$where['a.createtime'] = ['>=', strtotime($start_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
}
|
||||
if($start_time !== '' && $end_time !== ''){
|
||||
$where['a.createtime'] = ['between', [strtotime($start_time), strtotime($end_time.' 23:59:59')]];
|
||||
}
|
||||
|
||||
$count = db::name('user_exchange')->where($where)->alias('a')->join('user b', 'a.user_id = b.id')->count();
|
||||
$lists = db::name('user_exchange')->where($where)->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->field('a.*,b.nickname,b.user_code')
|
||||
->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['user_name'] = $value['nickname'].'-'.$value['user_code'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_coin_num' => db::name('user_exchange')->where($where)->alias('a')->join('user b', 'a.user_id = b.id')->sum('earnings_num'),
|
||||
'total_earnings_num' => db::name('user_exchange')->where($where)->alias('a')->join('user b', 'a.user_id = b.id')->sum('coin_num'),
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//后台手动充值列表
|
||||
public function admin_recharge_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$where =[];
|
||||
$search_id = input('search_id', '');
|
||||
$search_name = input('search_name', '');
|
||||
if($search_id){
|
||||
$where['b.user_code'] = $search_id;
|
||||
}
|
||||
if($search_name){
|
||||
$where['b.username'] = ['like', '%'.$search_name.'%'];
|
||||
}
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if($start_time !== ''){
|
||||
$where['a.createtime'] = ['>=', strtotime($start_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
}
|
||||
if($start_time !== '' && $end_time !== ''){
|
||||
$where['a.createtime'] = ['between', [strtotime($start_time), strtotime($end_time.' 23:59:59')]];
|
||||
}
|
||||
$count = db::name('vs_admin_recharge_log')
|
||||
->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = db::name('vs_admin_recharge_log')
|
||||
->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->where($where)
|
||||
->field('a.*,b.nickname')
|
||||
->order('a.arid desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($lists as &$list){
|
||||
$user_code = model('api/Decorate')->user_decorate_detail($list['user_id'],6);
|
||||
$list['nickname'] = $user_code."-".$list['nickname'];
|
||||
$list['admin_name'] = db::name('admin')->where('id', $list['admin_id'])->value('username');
|
||||
$list['type_str'] = model('common/UserWallet')::getMoneyType($list['type']);
|
||||
$list['createtime'] = date('Y-m-d H:i:s', $list['createtime']);
|
||||
}
|
||||
//总充值(金币)
|
||||
$total_coin = db::name('vs_admin_recharge_log')->where(['type'=>1])->sum('change_value');
|
||||
//总充值(收益)
|
||||
$total_earnings = db::name('vs_admin_recharge_log')->where(['type'=>2])->sum('change_value');
|
||||
//今日充值(金币)
|
||||
$today_coin =db::name('vs_admin_recharge_log')->where(['type'=>1])->whereTime('createtime', 'today')->sum('change_value');
|
||||
//今日充值(收益)
|
||||
$today_earnings = db::name('vs_admin_recharge_log')->where(['type'=>2])->whereTime('createtime', 'today')->sum('change_value');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total_data' => [
|
||||
'total_coin' => $total_coin,
|
||||
'total_earnings' => $total_earnings,
|
||||
'today_coin' => $today_coin,
|
||||
'today_earnings' => $today_earnings
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
}
|
||||
93
application/adminapi/controller/SysSet.php
Normal file
93
application/adminapi/controller/SysSet.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 版本管理
|
||||
* @internal
|
||||
*/
|
||||
class SysSet extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['type_list', 'config_list','config_set'];
|
||||
|
||||
protected $table = 'vs_config';
|
||||
|
||||
public $configType = [
|
||||
'1' => '基础设置',
|
||||
'2' => '登录设置',
|
||||
'3' => '支付配置',
|
||||
'4' => '提现设置',
|
||||
'5' => '推送及IM配置',
|
||||
// '6' => '每日任务设置',
|
||||
'7' => '云存储配置',
|
||||
'8' => '房间配置',
|
||||
'9' => '弹窗内容设置',
|
||||
'10' => '邀请奖励',
|
||||
];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
/*
|
||||
* 类型列表
|
||||
*/
|
||||
public function type_list(){
|
||||
$configType = $this->configType;
|
||||
$list = [];
|
||||
$i=0;
|
||||
foreach ($configType as $k=>$v){
|
||||
$list[$i]['id'] = $k;
|
||||
$list[$i]['name'] = $v;
|
||||
$i++;
|
||||
}
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
|
||||
/*
|
||||
* 配置列表
|
||||
*/
|
||||
public function config_list(){
|
||||
$type = input('type', 1);
|
||||
|
||||
$list = db::name($this->table)->where(['type'=>$type,'delete_time'=>0])->order('sort desc')->select();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['id'] = $v['cid'];
|
||||
$list_data[$k]['key_title'] = $v['key_title'];
|
||||
$list_data[$k]['key_name'] = $v['key_name'];
|
||||
$list_data[$k]['key_value'] = $v['key_value'];
|
||||
$list_data[$k]['key_desc'] = $v['key_desc'];
|
||||
}
|
||||
return V(1,"成功", $list_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 配置设置
|
||||
*/
|
||||
public function config_set(){
|
||||
$params = $this->request->post();
|
||||
if(empty($params['type'])){
|
||||
return V(0,"请选择配置类型");
|
||||
}
|
||||
foreach ($params as $k=>$v){
|
||||
$data = [
|
||||
'key_value'=>$v,
|
||||
];
|
||||
db::name($this->table)->where(['key_title'=>$k])->update($data);
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
}
|
||||
184
application/adminapi/controller/SystemMessage.php
Normal file
184
application/adminapi/controller/SystemMessage.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\controller\Push;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
|
||||
class SystemMessage extends adminApi
|
||||
{
|
||||
|
||||
//系统消息列表
|
||||
public function message_lists()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_title = input('search_title', '');
|
||||
$search_type = input('search_type', '');//1系统消息 2官方公告,3公告下的房间推荐,4公告下的活动
|
||||
$where=[];
|
||||
//标签名称
|
||||
if($search_title!==''){
|
||||
$where['title'] = ['like', '%'.$search_title.'%'];
|
||||
}
|
||||
//标签类型
|
||||
if($search_type == 1){
|
||||
$where['type'] = $search_type;
|
||||
}else{
|
||||
$where['type'] = ['>', 0];
|
||||
}
|
||||
$where['delete_time'] = 0;
|
||||
$count = db::name('system_message')->where($where)->count();
|
||||
$lists = db::name('system_message')->where($where)->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
$lists[$key]['type_name'] = $value['type'] == 1 ? '系统消息' : '官方公告';
|
||||
$lists[$key]['admin_name'] = db::name('admin')->where('id', $value['admin_id'])->value('nickname');
|
||||
if($lists[$key]['room_id'] > 0){
|
||||
$lists[$key]['room_id'] = $lists[$key]['room_id'].'-'.db::name('vs_room')->where('id', $value['room_id'])->value('room_name');
|
||||
}else{
|
||||
$lists[$key]['room_id'] = '';
|
||||
}
|
||||
//提醒方式:1 站内 2短信
|
||||
$lists[$key]['remind_type_str'] = $value['remind_type'] == 1 ? '站内' : '短信';
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//编辑系统消息
|
||||
public function edit_message()
|
||||
{
|
||||
//管理员ID
|
||||
$admin_id = Session::get('admin_id');
|
||||
if(!$admin_id){
|
||||
return V(0,"管理员ID不能为空");
|
||||
}
|
||||
|
||||
$data['admin_id'] = $admin_id;
|
||||
$id = input('id', '');
|
||||
$type = input('type', '');
|
||||
if($type){
|
||||
$data['type'] = $type;
|
||||
}
|
||||
|
||||
$title = input('title', '');
|
||||
if($title){
|
||||
$data['title'] = $title;
|
||||
}
|
||||
|
||||
$content = input('content', '');
|
||||
if($content){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
|
||||
$image = input('image', '');
|
||||
if($image){
|
||||
$data['image'] = $image;
|
||||
}
|
||||
|
||||
$room_id = input('room_id', '');
|
||||
if($room_id){
|
||||
$data['room_id'] = $room_id;
|
||||
}
|
||||
|
||||
$url = input('url', '');
|
||||
if($url){
|
||||
$data['url'] = $url;
|
||||
}
|
||||
$remind_type = input('remind_type', '');
|
||||
if($remind_type){
|
||||
$data['remind_type'] = $remind_type;
|
||||
}
|
||||
$receiving_id = input('receiving_id', '');
|
||||
if($receiving_id){
|
||||
$data['receiving_id'] = $receiving_id;
|
||||
}else{
|
||||
$user_list = db::name('user')->field('id')->select();
|
||||
$data['receiving_id'] = implode(',', array_column($user_list, 'id'));
|
||||
}
|
||||
if($id){
|
||||
$data['updatetime'] = time();
|
||||
|
||||
$res = db::name('system_message')->where('id',$id)->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
$data['createtime'] = time();
|
||||
$res = db::name('system_message')->insert($data);
|
||||
if($res){
|
||||
// if($remind_type == 2){
|
||||
//发送短信
|
||||
// $remind_types = explode(',', $receiving_id);
|
||||
// foreach ($remind_types as $key => $value) {
|
||||
// $phone = db::name('user')->where('id', $value)->value('mobile');
|
||||
//
|
||||
// }
|
||||
// }else{
|
||||
//推送礼物横幅
|
||||
// $push = new Push(UID);
|
||||
// $text_list_new = [
|
||||
// 'text' => '系统消息'
|
||||
// ];
|
||||
// $push->systemMessage($text_list_new);
|
||||
// }
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//删除系统消息
|
||||
public function del_message()
|
||||
{
|
||||
$id = input('id', '');
|
||||
if($id){
|
||||
$data = [
|
||||
'delete_time' => time(),
|
||||
];
|
||||
|
||||
$res = db::name('system_message')->where('id',$id)->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
//系统消息详情
|
||||
public function get_message_detail()
|
||||
{
|
||||
$id = input('id', '');
|
||||
if($id){
|
||||
$data = db::name('system_message')->where('id',$id)->find();
|
||||
$data['createtime'] = date('Y-m-d H:i:s', $data['createtime']);
|
||||
if($data){
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
135
application/adminapi/controller/Tasks.php
Normal file
135
application/adminapi/controller/Tasks.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 版本管理
|
||||
* @internal
|
||||
*/
|
||||
class Tasks extends adminApi
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
protected $table = 'vs_daily_tasks';
|
||||
public $task_type = [
|
||||
'1' => '每日任务',
|
||||
'2' => '每日特殊任务',
|
||||
'3' => '平台常规任务'
|
||||
];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
/*
|
||||
* 任务列表
|
||||
*/
|
||||
public function task_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$seach_task_type = input('seach_task_type', '');
|
||||
$where=[];
|
||||
if($seach_task_type != ''){
|
||||
$where['task_type'] = $seach_task_type;
|
||||
}
|
||||
$list = db::name('vs_daily_tasks')->where(['delete_time'=>0])->where($where)->page($page, $page_limit)->order(['sort'=>'desc','task_id'=>'desc'])->select();
|
||||
$count = db::name('vs_daily_tasks')->where(['delete_time'=>0])->where($where)->count();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['task_id'] = $v['task_id'];
|
||||
$list_data[$k]['icon'] = $v['icon'];
|
||||
$list_data[$k]['task_name'] = $v['task_name'];
|
||||
$list_data[$k]['task_description'] = $v['task_description']??"";
|
||||
$list_data[$k]['gold_reward'] = $v['gold_reward'];
|
||||
$list_data[$k]['target_quantity'] = $v['target_quantity'];
|
||||
$list_data[$k]['task_type'] = $v['task_type'];
|
||||
$list_data[$k]['task_type_str'] = $this->task_type[$v['task_type']];
|
||||
$list_data[$k]['sort'] = $v['sort'];
|
||||
$list_data[$k]['bag_id'] = $v['bag_id'];
|
||||
$list_data[$k]['bag_name'] = $v['bag_id']?db::name('vs_gift_bag')->where(['id'=>$v['bag_id']])->value('name'):'';
|
||||
$list_data[$k]['is_active'] = $v['is_active'];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list_data,
|
||||
'task_type' => $this->task_type,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 编辑
|
||||
*/
|
||||
public function task_edit(){
|
||||
$task_id = input('task_id', '');
|
||||
$task_name = input('task_name', '');
|
||||
$task_type = input('task_type', '');
|
||||
$task_description = input('task_description', '');
|
||||
$icon = input('icon', '');
|
||||
$gold_reward = input('gold_reward', '');
|
||||
$target_quantity = input('target_quantity', '');
|
||||
$sort = input('sort', '');
|
||||
$bag_id = input('bag_id', '');
|
||||
$is_active = input('is_active', '');
|
||||
if($task_name != ''){
|
||||
$data['task_name'] = $task_name;
|
||||
}
|
||||
if($task_description != ''){
|
||||
$data['task_description'] = $task_description;
|
||||
}
|
||||
if($icon != ''){
|
||||
$data['icon'] = $icon;
|
||||
}
|
||||
if($sort != ''){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($bag_id != ''){
|
||||
$data['bag_id'] = $bag_id;
|
||||
}
|
||||
if($is_active != ''){
|
||||
$data['is_active'] = $is_active;
|
||||
}
|
||||
if($task_type != ''){
|
||||
$data['task_type'] = $task_type;
|
||||
}
|
||||
if($gold_reward != ''){
|
||||
$data['gold_reward'] = $gold_reward;
|
||||
}
|
||||
if($target_quantity){
|
||||
$data['target_quantity'] = $target_quantity;
|
||||
}
|
||||
$res = db::name($this->table)->where(['task_id'=>$task_id])->update($data);
|
||||
if($res){
|
||||
return V(1,"修改成功");
|
||||
}else{
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 开启任务
|
||||
*/
|
||||
public function task_open(){
|
||||
$task_id = input('task_id', '');
|
||||
$is_active = input('is_active', '');
|
||||
$res = db::name($this->table)->where(['task_id'=>$task_id])->update(['is_active'=>$is_active]);
|
||||
if($res){
|
||||
return V(1,"开启成功");
|
||||
}else{
|
||||
return V(0,"开启失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
132
application/adminapi/controller/Theme.php
Normal file
132
application/adminapi/controller/Theme.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 版本管理
|
||||
* @internal
|
||||
*/
|
||||
class Theme extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'vs_theme';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
/*
|
||||
* 列表
|
||||
*/
|
||||
public function theme_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$id = input('id', '');
|
||||
$theme_name = input('theme_name', '');
|
||||
$where=[];
|
||||
if($id != ''){
|
||||
$where['id'] = $id;
|
||||
}
|
||||
if($theme_name != ''){
|
||||
$where['theme_name'] = $theme_name;
|
||||
}
|
||||
$list = db::name($this->table)->where($where)->page($page, $page_limit)->select();
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 添加
|
||||
*/
|
||||
public function theme_add(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$theme_name = input('theme_name', '');
|
||||
$theme_color = input('theme_color', '');
|
||||
$auxiliary_color = input('auxiliary_color', '');
|
||||
$file_url = input('file_url', '');
|
||||
$is_active = input('is_active', '');
|
||||
$data = [
|
||||
'theme_name' => $theme_name,
|
||||
'theme_color' => $theme_color,
|
||||
'auxiliary_color' => $auxiliary_color,
|
||||
'file_url' => $file_url,
|
||||
'is_active' => $is_active,
|
||||
'admin_id' => $admin_id,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if($res){
|
||||
return V(1,"添加成功");
|
||||
}else{
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 修改
|
||||
*/
|
||||
public function theme_edit(){
|
||||
$theme_name = input('theme_name', '');
|
||||
$theme_color = input('theme_color', '');
|
||||
$auxiliary_color = input('auxiliary_color', '');
|
||||
$file_url = input('file_url', '');
|
||||
$is_active = input('is_active', '');
|
||||
$id = input('id', '');
|
||||
$data = [
|
||||
'theme_name' => $theme_name,
|
||||
'theme_color' => $theme_color,
|
||||
'auxiliary_color' => $auxiliary_color,
|
||||
'file_url' => $file_url,
|
||||
'is_active' => $is_active,
|
||||
'updatetime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if($res){
|
||||
return V(1,"修改成功");
|
||||
}else{
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function theme_del(){
|
||||
$id = input('id', '');
|
||||
$res = db::name($this->table)->where(['id'=>$id])->delete();
|
||||
if($res){
|
||||
return V(1,"删除成功");
|
||||
}else{
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 应用
|
||||
*/
|
||||
public function theme_apply(){
|
||||
$id = input('id', '');
|
||||
db::name($this->table)->where(['is_active'=>1])->update(['is_active'=>0]);
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update(['is_active'=>1]);
|
||||
if($res){
|
||||
return V(1,"应用成功");
|
||||
}else{
|
||||
return V(0,"应用失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
311
application/adminapi/controller/Underage.php
Normal file
311
application/adminapi/controller/Underage.php
Normal file
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 青少年模式
|
||||
* @internal
|
||||
*/
|
||||
class Underage extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
public function types_list()
|
||||
{
|
||||
$page = $this->request->get('page', 1);
|
||||
$page_limit = $this->request->get('page_limit', 30);
|
||||
$search_name = $this->request->get('search_name', '');
|
||||
$where = [];
|
||||
if ($search_name) {
|
||||
$where['type_name'] = ['like', '%' . $search_name . '%'];
|
||||
}
|
||||
$count = Db::name('vs_underage_mode_type')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('vs_underage_mode_type')
|
||||
->where($where)
|
||||
->where('is_delete', 1)
|
||||
->order(['sort'=>'asc', 'id' => 'desc'])
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_lists = [];
|
||||
foreach ($lists as $key =>$value) {
|
||||
$return_lists[$key]['id'] = $value['id'];
|
||||
$return_lists[$key]['name'] = $value['type_name'];
|
||||
$return_lists[$key]['num'] = Db::name('vs_underage_mode_content')
|
||||
->where('type_id', $value['id'])
|
||||
->where('is_delete', 1)
|
||||
->count();
|
||||
$return_lists[$key]['status'] = $value['status'];
|
||||
$return_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$return_lists[$key]['admin'] = Db::name('admin')
|
||||
->where('id', $value['admin_id'])
|
||||
->value('username');
|
||||
$return_lists[$key]['sort'] = $value['sort'];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $return_lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 添加
|
||||
*/
|
||||
public function types_add(){
|
||||
$admin_id = Session::get('id');
|
||||
$type_name = input('type_name', "");
|
||||
$sort = input('sort', 0);
|
||||
$status = input('status', 1);
|
||||
|
||||
if(!$type_name){
|
||||
return V(0, "请填写分类名称");
|
||||
}
|
||||
$data = [
|
||||
'type_name' => $type_name,
|
||||
'admin_id' => $admin_id,
|
||||
'sort' => $sort,
|
||||
'status' => $status,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = Db::name('vs_underage_mode_type')->insert($data);
|
||||
if(!$res){
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
return V(1, "添加成功");
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function types_edit(){
|
||||
$id = input('id','');
|
||||
$type_name = input('type_name');
|
||||
$sort = input('sort', 0);
|
||||
$status = input('status', '');
|
||||
if(!$id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$type = Db::name('vs_underage_mode_type')->where('id', $id)->find();
|
||||
if(!$type){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = [];
|
||||
if($type_name){
|
||||
$data['type_name'] = $type_name;
|
||||
}
|
||||
if($sort){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($status){
|
||||
$data['status'] = $status;
|
||||
}
|
||||
$reslut = DB::name('vs_underage_mode_type')->where('id', $id)->update($data);
|
||||
if(!$reslut){
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1, "修改成功");
|
||||
}
|
||||
/*
|
||||
* 状态修改
|
||||
*/
|
||||
public function types_change_status(){
|
||||
$id = input('id');
|
||||
$status = input('status');
|
||||
if(!$id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
if(!$status){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$reslut = DB::name('vs_underage_mode_type')->where('id', $id)->update(['status' => $status]);
|
||||
if(!$reslut){
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1, "修改成功");
|
||||
}
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function types_delete(){
|
||||
$id = input('id');
|
||||
if(!$id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$reslut = DB::name('vs_underage_mode_type')->where('id', $id)->update(['is_delete' => 0,'delete_time'=>time()]);
|
||||
if(!$reslut){
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
return V(1, "删除成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 未成年模式内容列表
|
||||
*/
|
||||
public function content_List(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('pageSize', 30);
|
||||
$search_name = input('search_name', '');
|
||||
$where = [];
|
||||
if($search_name){
|
||||
$where['title'] = ['like', '%'.$search_name.'%'];
|
||||
}
|
||||
$list = DB::name('vs_underage_mode_content')->where($where)->order('sort,id', 'asc')->page($page, $page_limit)->select();
|
||||
$count = DB::name('vs_underage_mode_content')->where($where)->count();
|
||||
foreach ($list as $key => $value) {
|
||||
$return_lists[$key]['id'] = $value['id'];
|
||||
$return_lists[$key]['type_id'] = $value['type_id'];
|
||||
$return_lists[$key]['type_name'] = db('vs_underage_mode_type')->where('id', $value['type_id'])->value('type_name');
|
||||
$return_lists[$key]['title'] = $value['title'];
|
||||
$return_lists[$key]['img'] = $value['img'];
|
||||
$return_lists[$key]['url'] = $value['url'];
|
||||
$return_lists[$key]['is_top'] = $value['is_top'];
|
||||
$return_lists[$key]['admin'] = db('admin')->where('id', $value['admin_id'])->value('username');
|
||||
$return_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$return_lists[$key]['introduced'] = $value['introduced'];
|
||||
$return_lists[$key]['from'] = $value['from'];
|
||||
$return_lists[$key]['content'] = $value['content'];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $return_lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 未成年模式内容详情
|
||||
*/
|
||||
public function content_detail(){
|
||||
$id=input('id', '');
|
||||
if(empty($id)){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$data = db('vs_underage_mode_content')->where(['id'=>$id])->find();
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
/*
|
||||
* 内容添加
|
||||
*/
|
||||
public function content_add(){
|
||||
$admin_id = session('admin_id');
|
||||
$type_id = input('type_id', '');
|
||||
$title = input('title', '');
|
||||
$introduced = input('introduced', '');
|
||||
$content = input('content', '');
|
||||
$url = input('url', '');
|
||||
$img = input('img', '');
|
||||
$from = input('from', 1);
|
||||
$sort = input('sort', '');
|
||||
$is_top = input('is_top', 0);
|
||||
if(!$title){
|
||||
return V(0,"标题必填");
|
||||
}
|
||||
if(!$introduced){
|
||||
return V(0,"简介必填");
|
||||
}
|
||||
//简介不能超过100字
|
||||
if(mb_strlen($introduced) > 100){
|
||||
return V(0,"简介不能超过100字");
|
||||
}
|
||||
$data = [
|
||||
'type_id' => $type_id,
|
||||
'title' => $title,
|
||||
'introduced' => $introduced,
|
||||
'content' => $content,
|
||||
'url' => $url,
|
||||
'img' => $img,
|
||||
'from' => $from,
|
||||
'sort' => $sort,
|
||||
'is_top' => $is_top,
|
||||
'createtime' => time(),
|
||||
'admin_id' => $admin_id,
|
||||
];
|
||||
$result = db::name('vs_underage_mode_content')->insertGetId($data);
|
||||
if(!$result){
|
||||
return V(0,"失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function content_del(){
|
||||
$id = input('id',0);
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$result = db::name('vs_underage_mode_content')->where('id',$id)->delete();
|
||||
if(!$result){
|
||||
return V(0,"失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
/*
|
||||
* 编辑
|
||||
*/
|
||||
public function content_edit(){
|
||||
$id = input('id',0);
|
||||
$type_id = input('type_id', '');
|
||||
$title = input('title', '');
|
||||
$introduced = input('introduced', '');
|
||||
$content = input('content', '');
|
||||
$url = input('url', '');
|
||||
$img = input('img', '');
|
||||
$from = input('from', 1);
|
||||
$sort = input('sort', '');
|
||||
$is_top = input('is_top', 0);
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($type_id){
|
||||
$data['type_id'] = $type_id;
|
||||
}
|
||||
if($title){
|
||||
$data['title'] = $title;
|
||||
}
|
||||
if($url){
|
||||
$data['url'] = $url;
|
||||
}
|
||||
if($img){
|
||||
$data['img'] = $img;
|
||||
}
|
||||
if($sort){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($is_top){
|
||||
$data['is_top'] = $is_top;
|
||||
}
|
||||
if($from){
|
||||
$data['from'] = $from;
|
||||
}
|
||||
if($introduced){
|
||||
$data['introduced'] = $introduced;
|
||||
}
|
||||
if($content){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
$result = db::name('vs_underage_mode_content')->where(['id'=>$id])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功", ['id'=>$id]);
|
||||
}
|
||||
}
|
||||
49
application/adminapi/controller/UploadFile.php
Normal file
49
application/adminapi/controller/UploadFile.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\Upload;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 后台首页
|
||||
* @internal
|
||||
*/
|
||||
class UploadFile extends Upload
|
||||
{
|
||||
protected $request;
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
parent::__construct();
|
||||
$this->config = get_system_config();
|
||||
}
|
||||
/*
|
||||
* 上传文件
|
||||
* @return array
|
||||
*/
|
||||
public function file_upload(){
|
||||
// 获取上传的文件对象
|
||||
$file = $this->request->file('files');
|
||||
if (!$file) {
|
||||
return V(0, '未上传文件', null);
|
||||
}
|
||||
try {
|
||||
// 获取临时路径和原始文件名
|
||||
$filePath = $file->getRealPath();
|
||||
$objectName = $file->getInfo('name');
|
||||
// 调用父类方法上传到 OSS
|
||||
$result = $this->uploadFile($objectName, $filePath);
|
||||
if (!$result) {
|
||||
return V(0, '上传失败,请检查OSS配置或网络', null);
|
||||
}
|
||||
// 返回访问地址
|
||||
$url = $this->config['oss_cdn_url'] . $objectName;
|
||||
return V(1, '上传成功', ['url' => $url]);
|
||||
} catch (\Exception $e) {
|
||||
return V(0, '上传异常: ' . $e->getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
741
application/adminapi/controller/User.php
Normal file
741
application/adminapi/controller/User.php
Normal file
@@ -0,0 +1,741 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 后台首页
|
||||
* @internal
|
||||
*/
|
||||
class User extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员列表
|
||||
*/
|
||||
public function user_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_str = input('search', '');
|
||||
$search_user_code = input('search_user_code', '');
|
||||
$where['a.is_robot'] =0;
|
||||
$where['a.delete_time'] = 0;
|
||||
//如果是手机号查手机号
|
||||
if($search_str !==''){
|
||||
if(is_numeric($search_str)) {
|
||||
$where['a.mobile'] = ['like', '%'.$search_str.'%'];
|
||||
}else{
|
||||
$where['a.nickname'] = ['like', '%'.$search_str.'%'];
|
||||
}
|
||||
}
|
||||
//是否官方账号
|
||||
$is_sys_tester = input('is_sys_tester', '');
|
||||
if($is_sys_tester !==''){
|
||||
if($is_sys_tester == 1) {
|
||||
$where['a.is_sys_tester'] = 1;
|
||||
}else {
|
||||
$where['a.is_sys_tester'] = 0;
|
||||
}
|
||||
}
|
||||
//实名状态
|
||||
$is_real = input('is_real', '');
|
||||
if($is_real !==''){
|
||||
if($is_real == 1) {
|
||||
$where['b.is_real'] = 1;
|
||||
}else {
|
||||
$where['b.is_real'] = ['<>',1];
|
||||
}
|
||||
}
|
||||
//高级搜索
|
||||
//靓号,//登录设备,//昵称, //状态,//金币,//主持时间
|
||||
$search_type =['user_code','login_device','nickname','status','coin1','coin2','createtime'];
|
||||
foreach ($search_type as $v) {
|
||||
$input_data = input($v, '');
|
||||
if($input_data!==""){
|
||||
if($v=='coin1'){
|
||||
$where['c.coin'] = ['>=',$input_data];
|
||||
}elseif($v=='coin2'){
|
||||
$where['c.coin'] = ['<=',$input_data];
|
||||
}elseif($v=='createtime'){
|
||||
$where['a.createtime'] = ['>=',strtotime($input_data.' 00:00:00')];
|
||||
$where['a.createtime'] = ['<=',strtotime($input_data.' 23:59:59')];
|
||||
}else{
|
||||
$where['a.'.$v] = $input_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
$field = '
|
||||
a.id,
|
||||
a.avatar,
|
||||
a.mobile,
|
||||
a.nickname,
|
||||
a.sex,
|
||||
a.user_code,
|
||||
a.login_device,
|
||||
a.loginip,
|
||||
c.coin,
|
||||
c.earnings,
|
||||
b.is_real,
|
||||
a.init_code,
|
||||
a.status
|
||||
';
|
||||
$user_data = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order('a.id desc');
|
||||
$lists = $user_data->page($page, $page_limit)->select();
|
||||
$count = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order('a.id desc')->count();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['status_str'] = $value['status'] == 1 ? '正常' : '禁用';
|
||||
$lists[$key]['is_real_str'] = $value['is_real'] == 1 ? '已实名' : '未实名';
|
||||
//禁用状态
|
||||
//1:禁用账号 2:禁用设备号 3:禁用IP
|
||||
$lists[$key]['is_block_user'] = $lists[$key]['is_block_mobile'] =$lists[$key]['is_block_ip'] = 0;
|
||||
$is_block_user = Db::name('block')->where(['type_text' => $value['id'],'type'=>1,'block_time'=>['>=',time ()]])->find();
|
||||
// $is_block_mobile = Db::name('block')->where(['type_text' => $value['login_device'],'type'=>2,'block_time'=>['>=',time ()]])->find();
|
||||
// $is_block_ip = Db::name('block')->where(['type_text' => $value['loginip'],'type'=>3,'block_time'=>['>=',time ()]])->find();
|
||||
$lists[$key]['user_block_time'] = '';
|
||||
$lists[$key]['mobile_block_time'] = '';
|
||||
$lists[$key]['ip_block_time'] = '';
|
||||
if($is_block_user){
|
||||
$lists[$key]['is_block_user'] = 1;
|
||||
if($is_block_user['block_time']==0){
|
||||
$lists[$key]['user_block_time'] = '永久封禁';
|
||||
}else{
|
||||
$lists[$key]['user_block_time'] = date('Y-m-d H:i:s',$is_block_user['block_time']);
|
||||
}
|
||||
}
|
||||
// if($is_block_mobile){
|
||||
// $lists[$key]['is_block_mobile'] = 1;
|
||||
// $lists[$key]['mobile_block_time'] = date('Y-m-d H:i:s',$is_block_mobile['block_time']);
|
||||
// }
|
||||
// if($is_block_ip){
|
||||
// $lists[$key]['is_block_ip'] = 1;
|
||||
// $lists[$key]['ip_block_time'] = date('Y-m-d H:i:s',$is_block_ip['block_time']);
|
||||
// }
|
||||
//靓号处理
|
||||
//查询用是否有靓号
|
||||
$special_num = db::name('vs_user_decorate')->where(['user_id'=>$value['id'],'type'=>6,'is_using'=>1])->where('end_time',['>=',time()],'or')->value('special_num');
|
||||
if($special_num){
|
||||
$lists[$key]['special_num'] = $special_num;
|
||||
}else{
|
||||
$lists[$key]['special_num'] = "无";
|
||||
}
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除用户
|
||||
*/
|
||||
public function delUser(){
|
||||
$user_id = input('user_id', 0);
|
||||
if(!$user_id){
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
$res = model('User')->where('id', $user_id)->update(['status' => 0,'delete_time'=>time()]);
|
||||
if (!$res) {
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 封禁用户
|
||||
* @ type 1:禁用账号 2:禁用设备号 3:禁用IP
|
||||
*/
|
||||
public function banUser(){
|
||||
//获取管理员ID
|
||||
$admin_id = Session::get('id');
|
||||
$user_id = input('user_id', 0);
|
||||
$type = input('type', 0);
|
||||
$time = input('time', 0);
|
||||
$status = input('status', 1);
|
||||
$user_info = model('User')->where('id', $user_id)->find();
|
||||
if(!$user_info){
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
if($status ==1){
|
||||
$type_text = "";
|
||||
if($type ==1){
|
||||
$res = model('User')->where('id', $user_id)->update(['status' => 2]);
|
||||
if (!$res) {
|
||||
return V(0, "禁用失败");
|
||||
}
|
||||
$type_text = $user_id;
|
||||
}
|
||||
if($type ==2){
|
||||
$type_text = $user_info['login_device'];
|
||||
}
|
||||
if($type ==3){
|
||||
$type_text = $user_info['loginip'];
|
||||
}
|
||||
if($time){
|
||||
$block_time = strtotime($time);
|
||||
}else{
|
||||
$block_time = ''; //永久
|
||||
}
|
||||
//插入fa_block 表
|
||||
$res = Db::name('block')->insert([
|
||||
'admin_id' => $admin_id,
|
||||
'type' => $type,
|
||||
'type_text' => $type_text,
|
||||
'block_time' => $block_time,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
if (!$res) {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
}else{
|
||||
if($type ==1) {
|
||||
$res = model('User')->where('id', $user_id)->update(['status' => 1]);
|
||||
$type_text = $user_id;
|
||||
}
|
||||
if($type ==2){
|
||||
$type_text = $user_info['login_device'];
|
||||
}
|
||||
if($type ==3){
|
||||
$type_text = $user_info['loginip'];
|
||||
}
|
||||
$map = [
|
||||
'type' => $type,
|
||||
'type_text' => $type_text,
|
||||
];
|
||||
$res = Db::name('block')->where($map)->delete();
|
||||
}
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 设为官方账号
|
||||
*/
|
||||
public function setSysTester(){
|
||||
$user_id = input('user_id', 0);
|
||||
if(!$user_id){
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
$res = model('User')->where('id', $user_id)->update(['is_sys_tester' => 1]);
|
||||
if (!$res) {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
/*
|
||||
* 修改密码
|
||||
*
|
||||
*/
|
||||
public function changePwd(){
|
||||
$user_id = input('user_id', 0);
|
||||
if(!$user_id){
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
$new_pwd = input('new_pwd', '');
|
||||
if(!$new_pwd){
|
||||
return V(0, "请输入新密码");
|
||||
}
|
||||
$res = model('User')->where('id', $user_id)->update(['password' => md5($new_pwd)]);
|
||||
if (!$res) {
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 设置资金
|
||||
*/
|
||||
public function setMoney(){
|
||||
$user_id = input('user_id', 0);
|
||||
$money_type = input('money_type', '');
|
||||
$change_value = input('change_value', 0);
|
||||
$secondary_password = input('secondary_password','');
|
||||
$remark = input('remarks', '');
|
||||
if(!$user_id){
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
if(!$money_type){
|
||||
return V(0, "请选择类型");
|
||||
}
|
||||
$check_pass = model('adminapi/admin')->check_secondary_password($secondary_password);
|
||||
if($check_pass['code']==0){
|
||||
return v($check_pass['code'], $check_pass['msg'], $check_pass['data']);
|
||||
}
|
||||
if(!$change_value){
|
||||
return V(0, "请输入金额");
|
||||
}
|
||||
if($remark){
|
||||
$remarks = model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::OPERATION_SYSTEM)." 备注:".$remark;
|
||||
}else{
|
||||
$remarks = model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::OPERATION_SYSTEM);
|
||||
}
|
||||
if($change_value<0){
|
||||
$remarks = "后台扣除-".$remarks;
|
||||
}
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $change_value, $money_type, model('common/UserWallet')::OPERATION_SYSTEM,$remarks);
|
||||
if($res['code']==0){
|
||||
return V($res['code'],$res['msg']);
|
||||
}
|
||||
$return = db::name('vs_admin_recharge_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'type' => $money_type,
|
||||
'change_value' => $change_value,
|
||||
'remarks' => $remark,
|
||||
'createtime' => time(),
|
||||
'admin_id' => Session::get('admin_id')
|
||||
]);
|
||||
if(!$return){
|
||||
return v(0,'添加失败');
|
||||
}
|
||||
return v(1,'添加成功');
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户信息
|
||||
*/
|
||||
public function userInfo(){
|
||||
$user_id = input('user_id', 0);
|
||||
$user = model('api/User')->get_user_info($user_id);
|
||||
if(!$user){
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
//数据处理
|
||||
$user_data['user_info']['avatar'] = $user['avatar'];
|
||||
$user_data['user_info']['nickname'] = $user['nickname'];
|
||||
$user_data['user_info']['charm_level_icon'] = $user['charm_level_icon'];
|
||||
$user_data['user_info']['wealth_level_icon'] = $user['wealth_level_icon'];
|
||||
$user_data['user_info']['user_code'] = $user['user_code'];
|
||||
$user_data['user_info']['mobile'] = $user['mobile'];
|
||||
$user_data['user_info']['sex'] = $user['sex']==1 ? '男' : '女';
|
||||
$user_data['user_info']['birthday'] = $user['birthday'];
|
||||
$user_data['user_info']['system'] = $user['system'];
|
||||
$user_data['user_info']['age'] = $user['age'];
|
||||
$user_data['user_info']['profile'] = $user['profile'];
|
||||
$user_data['user_info']['status'] = $user['status'];
|
||||
//状态 1正常,2禁止登录,0注销
|
||||
$user_data['user_info']['status_str'] = $user['status']==1 ? '正常' : ($user['status']==2 ? '禁止登录' : '注销');
|
||||
$user_data['user_info']['red_status'] = $user['red_status'];
|
||||
$user_data['user_info']['red_status_str'] = $user['red_status']==1 ? '开启' : '禁止';
|
||||
//标签
|
||||
$user_data['user_info']['tag'] = $user['tag_list'];
|
||||
$user_data['user_info']['createtime'] = date('Y-m-d H:i:s', $user['createtime']);//主持时间
|
||||
//统计相关:
|
||||
$user_data['follow_num']['user_recharge_all_money'] = $user['user_recharge_all_money'];
|
||||
$user_data['follow_num']['coin'] = $user['coin'];
|
||||
$user_data['follow_num']['earnings'] = $user['earnings'];
|
||||
$user_data['follow_num']['follow_num'] = $user['follow_num'];
|
||||
$user_data['follow_num']['fans_num'] = $user['fans_num'];
|
||||
$user_data['follow_num']['invited_num'] = $user['invited_num'];
|
||||
$user_data['follow_num']['invited_earnings'] = $user['invited_earnings'];
|
||||
//收藏话题【咱无】
|
||||
//收藏评论【咱无】
|
||||
$user_data['follow_num']['is_real'] = $user['is_real'] == 1 ? '已实名' : '未实名';;
|
||||
$user_data['follow_num']['real_name'] = $user['real_name'];
|
||||
$user_data['follow_num']['card_id'] = $user['card_id'];
|
||||
return V(1,"成功", $user_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 编辑用户信息
|
||||
*/
|
||||
public function editUser(){
|
||||
$user_id = input('user_id', 0);
|
||||
$user = model('User')->get($user_id);
|
||||
if (!$user) {
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
$up_user = [];
|
||||
$nickname = input('nickname', '');
|
||||
if ($nickname) {
|
||||
$up_user['nickname'] = $nickname;
|
||||
}
|
||||
$sex = input('sex', '');
|
||||
if ($sex) {
|
||||
$up_user['sex'] = $sex;
|
||||
}
|
||||
$birthday = input('birthday', '');
|
||||
if ($birthday) {
|
||||
$up_user['birthday'] = $birthday;
|
||||
}
|
||||
$profile = input('profile', '');
|
||||
if ($profile) {
|
||||
$up_user['profile'] = $profile;
|
||||
}
|
||||
$status = input('status', '');
|
||||
if ($status) {
|
||||
$up_user['status'] = $status;
|
||||
}
|
||||
$red_status = input('red_status', '');
|
||||
if($red_status!=""){
|
||||
$up_user['red_status'] = $red_status;
|
||||
}
|
||||
$up_user_data =[];
|
||||
$real_name = input('real_name', '');
|
||||
if ($real_name) {
|
||||
$up_user_data['real_name'] = $real_name;
|
||||
}
|
||||
$card_id = input('card_id', '');
|
||||
if ($card_id) {
|
||||
$up_user_data['card_id'] = $card_id;
|
||||
}
|
||||
$is_real = input('is_real', '');
|
||||
if ($is_real) {
|
||||
$up_user_data['is_real'] = $is_real;
|
||||
}
|
||||
$init_code = input('init_code', '');
|
||||
if($init_code){
|
||||
//绑定
|
||||
$reslut = model('api/Invited')->invited_bind($init_code, $user_id);
|
||||
if ($reslut['code'] == 0) {
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
if($up_user){
|
||||
$reslut = DB::name('user')->where('id', $user_id)->update($up_user);
|
||||
}
|
||||
if($up_user_data){
|
||||
$res = DB::name('user_auth')->where('mobile', $user['mobile'])->update($up_user_data);
|
||||
}
|
||||
return V(1,'操作成功');
|
||||
}
|
||||
|
||||
/*
|
||||
* 会员收支日志
|
||||
*/
|
||||
public function money_log_list(){
|
||||
$user_id = input('user_id');
|
||||
$page = input('page',1);
|
||||
$page_limit = input('page_limit',10);
|
||||
$type = input('type','');
|
||||
$return = model('UserWallet')->money_change_log($user_id,$type,$page,$page_limit);
|
||||
$list = [];
|
||||
foreach($return['list'] as $k=>$v){
|
||||
$list[$k] = [
|
||||
'title' => $v['change_type'],
|
||||
'change_time' => $v['createtime'],
|
||||
'type' => $v['change_in_out'],
|
||||
'content' => $v['remarks'],
|
||||
'change_money' => $v['change_value'],
|
||||
];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $return['count'],
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"操作成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 相册列表
|
||||
*/
|
||||
public function get_album_list(){
|
||||
$user_id = input('user_id',0);
|
||||
$reslut = model('api/user')->get_album_list($user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 相册详情
|
||||
*/
|
||||
public function get_album_detail()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$user_id = input('user_id',0);
|
||||
$pwd = input('pwd','');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('api/user')->get_album_detail($user_id,$album_id,$pwd, $page, $page_limit,1);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//删除相册
|
||||
public function delete_album()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$user_id = input('user_id',0);
|
||||
$reslut = model('api/user')->delete_album($user_id,$album_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 机器人列表
|
||||
*/
|
||||
public function get_robot_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_mobile = input('search_mobile', '');
|
||||
$search_nickname = input('search_nickname', '');
|
||||
$search_id = input('search_id', '');
|
||||
$where['is_robot'] =1;
|
||||
$where['a.delete_time'] = 0;
|
||||
$where['a.status'] = 1;
|
||||
if($search_id!==""){
|
||||
$where['user_code'] = $search_id;
|
||||
}
|
||||
if($search_mobile !==''){
|
||||
$where['a.mobile'] = ['like', '%'.$search_mobile.'%'];
|
||||
}
|
||||
if($search_nickname !==''){
|
||||
$where['a.nickname'] = ['like', '%'.$search_nickname.'%'];
|
||||
}
|
||||
$field = '
|
||||
a.id,
|
||||
a.avatar,
|
||||
a.mobile,
|
||||
a.nickname,
|
||||
a.sex,
|
||||
a.user_code,
|
||||
a.login_device,
|
||||
c.coin,
|
||||
c.earnings,
|
||||
b.is_real,
|
||||
a.init_code,
|
||||
a.status,
|
||||
a.createtime
|
||||
';
|
||||
$count = db::name('user')->alias('a')
|
||||
->join('fa_user_auth b', 'a.mobile = b.mobile','LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_data = db::name('user')->alias('a')
|
||||
->join('fa_user_auth b', 'a.mobile = b.mobile','LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order('a.id desc');
|
||||
$lists = $user_data->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/**
|
||||
* 批量生成机器人
|
||||
*/
|
||||
public function get_robot_detail(){
|
||||
$num = 20;
|
||||
for($i=1;$i<=$num;$i++){
|
||||
$user_name = $this->hao_duan_create();
|
||||
$reslut = model('User')->user_reg($user_name);
|
||||
}
|
||||
return V(1,"操作成功", null);
|
||||
}
|
||||
|
||||
//单个生成账号
|
||||
public function create_robot(){
|
||||
//根据号段生成账号
|
||||
$user_name = $this->hao_duan_create();
|
||||
$reslut = model('User')->user_reg($user_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//虚拟号段
|
||||
public function hao_duan_create(){
|
||||
$user_name = generateRandomPhoneNumber();
|
||||
$user_name_exist = db::name('user')->where('username','=',$user_name)->field('id')->find();
|
||||
if(!empty($user_name_exist)){
|
||||
return $this->hao_duan_create();
|
||||
// return false;
|
||||
}
|
||||
return $user_name;
|
||||
}
|
||||
/*
|
||||
* 删除机器人
|
||||
*/
|
||||
public function delete_robot(){
|
||||
$user_id = input('user_id', 0);
|
||||
if(!$user_id){
|
||||
return V(0, "用户不存在");
|
||||
}
|
||||
$res = model('User')->where('id', $user_id)->update(['status' => 0,'delete_time'=>time()]);
|
||||
if (!$res) {
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 背包列表
|
||||
*/
|
||||
public function get_backpack_list(){
|
||||
$user_id = input('user_id',0);
|
||||
$gid = input('gid',0);
|
||||
$page = input('page',1);
|
||||
$page_limit = input('page_limit',10);
|
||||
$where['a.is_tester'] = 1;
|
||||
if($user_id){
|
||||
$where['a.user_id'] = $user_id;
|
||||
}
|
||||
if($gid){
|
||||
$where['a.gid'] = $gid;
|
||||
}
|
||||
$count = db::name('vs_user_gift_pack')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->count();
|
||||
$list = db::name('vs_user_gift_pack')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_gift c', 'a.gid = c.gid')
|
||||
->field('a.*,b.user_code,b.nickname,c.gift_name,c.base_image,c.gift_price')->where($where)->order('a.pid', "desc")->page($page, $page_limit)->select();
|
||||
foreach ($list as $key => &$value) {
|
||||
$value['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
$value['user_id_nickname'] = $value['user_code'].'——'.$value['nickname'];
|
||||
$value['gift_id_name'] = $value['gid'].'——'.$value['gift_name'];
|
||||
}
|
||||
//礼物个数
|
||||
$gift_count = db::name('vs_user_gift_pack')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->group('a.gid')->count();
|
||||
//礼物总金额
|
||||
$gift_total = db::name('vs_user_gift_pack')->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_gift c', 'a.gid = c.gid')
|
||||
->where($where)->sum('c.gift_price');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'gift_count' => $gift_count,
|
||||
'gift_total' => $gift_total,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"操作成功", $return_data);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 禁用列表
|
||||
*/
|
||||
public function get_forbidden_list(){
|
||||
$user_id = input('user_id',);
|
||||
$seach_value = input('seach_value', '');
|
||||
$search_user_id = input('search_user_id', '');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where = ['is_delete'=>0,'type'=>['<>',1]];
|
||||
//判断seach_value是否是IP地址
|
||||
if($seach_value!=''){
|
||||
if(filter_var($seach_value, FILTER_VALIDATE_IP)){
|
||||
$type = 3;
|
||||
}else{
|
||||
$type = 2;
|
||||
}
|
||||
$where['type'] = $type;
|
||||
$where['type_text'] = $seach_value;
|
||||
}
|
||||
// if($search_user_id!=''){
|
||||
// $type = 1;
|
||||
// $where['type'] = $type;
|
||||
// $where['type_text'] = $search_user_id;
|
||||
// }
|
||||
$list = Db::name('block')->where($where)->order('id desc')->page($page,$page_limit)->select();
|
||||
$count = Db::name('block')->where($where)->count();
|
||||
$type_arr = [
|
||||
1=>'账号',
|
||||
2=>'设备',
|
||||
3=>'ip',
|
||||
4=>'禁言',
|
||||
];
|
||||
foreach ($list as $key => &$value) {
|
||||
//封禁类型 1账号, 2设备, 3ip 4禁言
|
||||
$value['type_str'] = $type_arr[$value['type']];
|
||||
if($value['block_time'] == 0){
|
||||
$value['block_time'] = '永久封禁';
|
||||
$value['status_str'] = '封禁中';
|
||||
$value['status'] = 1;
|
||||
}else{
|
||||
$value['block_time'] = date('Y-m-d H:i:s',$value['block_time']);
|
||||
if($value['block_time']>time()){
|
||||
$value['status_str'] = '封禁中';
|
||||
$value['status'] = 1;
|
||||
}else{
|
||||
$value['status_str'] = '已解封';
|
||||
$value['status'] =2;
|
||||
}
|
||||
}
|
||||
$value['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 封禁添加
|
||||
*/
|
||||
public function add_forbidden(){
|
||||
$type = input('type', 1);
|
||||
$type_text = input('type_text', '');
|
||||
$block_time = input('block_time', 0);
|
||||
$admin_id = Session::get('admin_id');
|
||||
//插入fa_block 表
|
||||
$res = Db::name('block')->insert([
|
||||
'admin_id' => $admin_id,
|
||||
'type' => $type,
|
||||
'type_text' => $type_text,
|
||||
'block_time' => strtotime($block_time),
|
||||
'createtime' => time(),
|
||||
]);
|
||||
if (!$res) {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
return V(1,"添加成功", null);
|
||||
}
|
||||
/*
|
||||
* 解封
|
||||
*/
|
||||
public function del_forbidden(){
|
||||
$id = input('id', 0);
|
||||
if (!$id) {
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$res = Db::name('block')->where(['id'=>$id])->delete();
|
||||
if (!$res) {
|
||||
return V(0, "解封失败");
|
||||
}
|
||||
return V(1,"解封成功", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户列表
|
||||
*/
|
||||
public function get_user_list(){
|
||||
$user = db::name('user')->field('id,nickname,avatar')->where(['status'=>1,'is_robot'=>0,'delete_time'=>0])->select();
|
||||
return V(1,"操作成功", $user);
|
||||
}
|
||||
}
|
||||
143
application/adminapi/controller/UserTag.php
Normal file
143
application/adminapi/controller/UserTag.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 用户标签
|
||||
* @internal
|
||||
*/
|
||||
class UserTag extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'user_tag';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签列表
|
||||
*/
|
||||
public function tag_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_tag_name = input('search_tag_name', '');
|
||||
$where=[];
|
||||
//标签名称
|
||||
if($search_tag_name!==''){
|
||||
$where['tag_name'] = ['like', '%'.$search_tag_name.'%'];
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists = db::name($this->table)->where($where)->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加标签
|
||||
*/
|
||||
public function add_tag(){
|
||||
$tag_name = input('tag_name', '');
|
||||
if($tag_name == ''){
|
||||
return V(0,"请输入标签名称");
|
||||
}
|
||||
$tag_data = [
|
||||
'tag_name' => $tag_name,
|
||||
'createtime' => time()
|
||||
];
|
||||
$tag_id = db::name($this->table)->insertGetId($tag_data);
|
||||
if($tag_id){
|
||||
return V(1,"成功",['id'=>$tag_id]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
*/
|
||||
public function del_tag(){
|
||||
$tag_id = input('tag_id', '');
|
||||
if($tag_id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$tag_data = db::name($this->table)->where(['id'=>$tag_id])->find();
|
||||
if(!$tag_data){
|
||||
return V(0,"标签不存在");
|
||||
}
|
||||
$result = db::name($this->table)->where(['id'=>$tag_id])->delete();
|
||||
if(!$result){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 标签详情
|
||||
*/
|
||||
public function tag_info(){
|
||||
$tag_id = input('tag_id', '');
|
||||
if($tag_id == ''){
|
||||
return V(0,"标签ID不能为空");
|
||||
}
|
||||
$tag_data = db::name($this->table)->where(['id'=>$tag_id])->find();
|
||||
$tag_data['createtime'] = date('Y-m-d H:i:s', $tag_data['createtime']);
|
||||
if(!$tag_data){
|
||||
return V(0,"标签不存在");
|
||||
}
|
||||
return V(1,"成功", $tag_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 编辑标签
|
||||
*/
|
||||
public function edit_tag(){
|
||||
$tag_id = input('tag_id', '');
|
||||
if($tag_id == ''){
|
||||
return V(0,"标签ID不能为空");
|
||||
}
|
||||
$tag_data = db::name($this->table)->where(['id'=>$tag_id])->find();
|
||||
if(!$tag_data){
|
||||
return V(0,"标签不存在");
|
||||
}
|
||||
$tag_name = input('tag_name', '');
|
||||
if($tag_name == ''){
|
||||
return V(0,"标签名称不能为空");
|
||||
}
|
||||
$tag_data = db::name($this->table)->where(['tag_name'=>$tag_name])->find();
|
||||
if($tag_data){
|
||||
return V(0,"标签已存在");
|
||||
}
|
||||
$tag_data = [
|
||||
'tag_name' => $tag_name,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$result = db::name($this->table)->where(['id'=>$tag_id])->update($tag_data);
|
||||
if(!$result){
|
||||
return V(0,"添加失败");
|
||||
|
||||
}
|
||||
return V(1,"成功", ['id'=>$tag_id]);
|
||||
}
|
||||
|
||||
}
|
||||
188
application/adminapi/controller/UserZone.php
Normal file
188
application/adminapi/controller/UserZone.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
|
||||
class UserZone extends adminApi
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['zone_lists','topic_lists','zone_detail','add_topic','del_zone','del_comment','zone_top_or_show','del_topic'];
|
||||
|
||||
protected $table = 'user_zone';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 话题列表
|
||||
*/
|
||||
public function topic_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_name = input('search_name', '');
|
||||
$where=[];
|
||||
//标签名称
|
||||
if($search_name != ''){
|
||||
$where['title'] = ['like', '%'.$search_name.'%'];
|
||||
}
|
||||
$count = db::name('topic')->where($where)->count();
|
||||
$lists = db::name('topic')->where($where)->order('createtime desc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$value) {
|
||||
if($value['createtime'] > 0){
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
if($value['updatetime'] > 0){
|
||||
$value['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
}
|
||||
$value['num'] = db::name('user_zone_topic')->where(['topic_id'=>$value['id']])->count();
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//添加话题
|
||||
public function add_topic(){
|
||||
$id = input('id', 0);
|
||||
$title = input('title', '');
|
||||
$content = input('content', '');
|
||||
$pic = input('pic', '');
|
||||
|
||||
if($title){
|
||||
$data['title'] = '#'.$title;
|
||||
}
|
||||
if($content){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
if($pic){
|
||||
$data['pic'] = $pic;
|
||||
}
|
||||
|
||||
$data['createtime'] = time();
|
||||
if($id > 0){
|
||||
$res = db::name('topic')->where(['id'=>$id])->update($data);
|
||||
}else{
|
||||
$res = db::name('topic')->insert($data);
|
||||
}
|
||||
|
||||
return V($res ? 1 : 0, $res ? '添加成功' : '添加失败');
|
||||
}
|
||||
|
||||
//删除话题
|
||||
public function del_topic(){
|
||||
$id = input('id', 0);
|
||||
$res = db::name('topic')->where(['id'=>$id])->update(['is_delete'=> time(),'updatetime'=> time()]);
|
||||
return V($res ? 1 : 0, $res ? '删除成功' : '删除失败');
|
||||
}
|
||||
|
||||
//动态列表
|
||||
public function zone_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_name = input('search_name', '');
|
||||
$where['is_delete'] = 1;
|
||||
//标签名称
|
||||
if($search_name != ''){
|
||||
$where['content'] = ['like', '%'.$search_name.'%'];
|
||||
}
|
||||
$count = db::name('user_zone')->where($where)->count();
|
||||
$lists = db::name('user_zone')->where($where)->order('createtime desc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as &$value) {
|
||||
if($value['createtime'] > 0){
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
if($value['updatetime'] > 0){
|
||||
$value['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
}
|
||||
if($value['delete_time'] > 0){
|
||||
$value['delete_time'] = date('Y-m-d H:i:s', $value['delete_time']);
|
||||
}
|
||||
if($value['images']){
|
||||
$value['images'] = explode(',', $value['images'])[0];
|
||||
}
|
||||
$value['rewards_num'] = db::name('user_zone_rewards')->where(['zone_id'=>$value['id']])->sum('gift_price_total');
|
||||
$value['topic_title'] = db::name('topic')->where(['id'=>$value['topic_id']])->value('title');
|
||||
$value['user_nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname').'-'.
|
||||
db::name('user')->where(['id'=>$value['user_id']])->value('user_code');
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//动态详情
|
||||
public function zone_detail(){
|
||||
$id = input('id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$detail = db::name('user_zone')->where(['id'=>$id])->find();
|
||||
if($detail){
|
||||
if($detail['createtime'] > 0){
|
||||
$detail['createtime'] = date('Y-m-d H:i:s', $detail['createtime']);
|
||||
}
|
||||
if($detail['updatetime'] > 0){
|
||||
$detail['updatetime'] = date('Y-m-d H:i:s', $detail['updatetime']);
|
||||
}
|
||||
//打赏金额
|
||||
$detail['rewards_num'] = db::name('user_zone_rewards')->where(['zone_id'=>$detail['id']])->sum('gift_price_total');
|
||||
//打赏人数
|
||||
$detail['rewards_user_num'] = db::name('user_zone_rewards')->where(['zone_id'=>$detail['id']])->count();
|
||||
//标签
|
||||
$detail['title'] = [];
|
||||
if(isset($detail['topic_id'])){
|
||||
$top = explode(',', $detail['topic_id']);
|
||||
foreach ($top as $kk){
|
||||
$title = db::name('topic')->where(['id' => $kk])->find();
|
||||
if(isset($title)){
|
||||
$title['topic_id'] = $title['id'];
|
||||
}
|
||||
$detail['title'][] =$title?? [];
|
||||
}
|
||||
}
|
||||
//评论列表
|
||||
$coment = model('api/UserZone')->getCommentsWithReplies($detail['id'], $page, $page_limit);
|
||||
$detail['comment_lists'] = $coment['data'];
|
||||
}
|
||||
return V(1,"成功", $detail);
|
||||
}
|
||||
|
||||
//删除动态
|
||||
public function del_zone(){
|
||||
$id = input('id', 0);
|
||||
$res = db::name('user_zone')->where(['id'=>$id])->update(['is_delete'=> 2,'delete_time'=> time()]);
|
||||
return V($res ? 1 : 0, $res ? '删除成功' : '删除失败');
|
||||
}
|
||||
|
||||
//删除评论
|
||||
public function del_comment(){
|
||||
$id = input('id', 0);
|
||||
$res = db::name('user_zone_comment')->where(['id'=>$id])->update(['is_delete'=> 2,'updatetime'=> time()]);
|
||||
return V($res ? 1 : 0, $res ? '删除成功' : '删除失败');
|
||||
}
|
||||
//动态置顶或显示操作操作
|
||||
public function zone_top_or_show(){
|
||||
$id = input('id', 0);
|
||||
$type = input('type', 0);
|
||||
$status = input('status', 0);
|
||||
if($type ==1){
|
||||
$data['is_recommend'] = $status;
|
||||
}else{
|
||||
$data['show_status'] = $status;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name('user_zone')->where(['id'=>$id])->update($data);
|
||||
return V($res ? 1 : 0, $res ? '操作成功' : '操作失败');
|
||||
}
|
||||
}
|
||||
156
application/adminapi/controller/Version.php
Normal file
156
application/adminapi/controller/Version.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 版本管理
|
||||
* @internal
|
||||
*/
|
||||
class Version extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
protected $table = 'version';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
/*
|
||||
* 列表
|
||||
*/
|
||||
public function version_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$version = input('version', '');
|
||||
$where=[];
|
||||
if($version != ''){
|
||||
$where['newversion'] = $version;
|
||||
}
|
||||
$list = db::name($this->table)->where($where)->page($page, $page_limit)->select();
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$list_data = [];
|
||||
foreach ($list as $key => $value) {
|
||||
$list_data[$key]['id'] = $value['id'];
|
||||
$list_data[$key]['newversion'] = $value['newversion'];
|
||||
$list_data[$key]['type'] = $value['type'];
|
||||
$list_data[$key]['downloadurl'] = $value['downloadurl'];
|
||||
$list_data[$key]['content'] = $value['content'];
|
||||
$list_data[$key]['enforce'] = $value['enforce'];
|
||||
$list_data[$key]['enforce_str'] = $value['enforce']==1 ? '是' : '否';
|
||||
$list_data[$key]['status'] = $value['status'];
|
||||
$list_data[$key]['status_str'] = $value['status']==1 ? '启用' : '禁用';
|
||||
$list_data[$key]['version_code'] = $value['code'];
|
||||
$list_data[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list_data
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 添加
|
||||
*/
|
||||
public function version_add(){
|
||||
$version = input('version', '');
|
||||
$type = input('type', '');
|
||||
$downloadurl = input('downloadurl', '');
|
||||
$content = input('content', '');
|
||||
$enforce = input('enforce', '');
|
||||
$version_code = input('version_code', '');
|
||||
$status = input('status', 1);
|
||||
$version = db::name($this->table)->where(['newversion'=>$version])->find();
|
||||
if($version){
|
||||
return V(0,"版本号已存在");
|
||||
}
|
||||
$data = [
|
||||
'newversion' => $version,
|
||||
'type' => $type,
|
||||
'downloadurl' => $downloadurl,
|
||||
'content' => $content,
|
||||
'enforce' => $enforce,
|
||||
'code' => $version_code,
|
||||
'status' => $status,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if($res){
|
||||
return V(1,"添加成功");
|
||||
}else{
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 修改
|
||||
*/
|
||||
public function version_edit(){
|
||||
$version = input('version', '');
|
||||
$type = input('type', '');
|
||||
$downloadurl = input('downloadurl', '');
|
||||
$content = input('content', '');
|
||||
$enforce = input('enforce', '');
|
||||
$version_code = input('version_code', '');
|
||||
$status = input('status', 1);
|
||||
$id = input('id', '');
|
||||
$versions = db::name($this->table)->where(['newversion'=>$version,'id'=>['neq',$id]])->find();
|
||||
if($versions){
|
||||
return V(0,"版本号已存在");
|
||||
}
|
||||
$data = [
|
||||
'newversion' => $version,
|
||||
'type' => $type,
|
||||
'downloadurl' => $downloadurl,
|
||||
'content' => $content,
|
||||
'enforce' => $enforce,
|
||||
'code' => $version_code,
|
||||
'status' => $status,
|
||||
'createtime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if($res){
|
||||
return V(1,"修改成功");
|
||||
}else{
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function version_del(){
|
||||
$id = input('id', '');
|
||||
$res = db::name($this->table)->where(['id'=>$id])->delete();
|
||||
if($res){
|
||||
return V(1,"删除成功");
|
||||
}else{
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 状态修改
|
||||
*/
|
||||
public function version_status(){
|
||||
$id = input('id', '');
|
||||
$status = input('status', 0);
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update(['status'=>$status]);
|
||||
if($res){
|
||||
return V(1,"修改成功");
|
||||
}else{
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
299
application/adminapi/controller/Withdrawal.php
Normal file
299
application/adminapi/controller/Withdrawal.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
use Yzh\YunPay;
|
||||
|
||||
class Withdrawal extends adminApi
|
||||
{
|
||||
public $withdraw_type = [
|
||||
1=>'微信',
|
||||
2=>'支付宝',
|
||||
3=>'银行卡',
|
||||
];
|
||||
public $withd_type = [
|
||||
1=>'微信',
|
||||
2=>'支付宝',
|
||||
3=>'银行卡',
|
||||
4=>'云账户',
|
||||
5=>'其他'
|
||||
];
|
||||
//初始化
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
//提现列表
|
||||
public function get_withdraw_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_order_sn = input('search_order_sn', '');
|
||||
$search_order_status = input('search_order_status', '');
|
||||
$search_uid = input('search_uid', '');
|
||||
$search_nickname = input('search_nickname', '');
|
||||
$search_type = input('search_type', '');
|
||||
$search_withd_type = input('search_withd_type', '');
|
||||
$search_stime = input('search_stime', '');
|
||||
$search_etime = input('search_etime', '');
|
||||
$where=[];
|
||||
if($search_order_sn !== ''){
|
||||
$where['a.order_sn'] = $search_order_sn;
|
||||
}
|
||||
if($search_order_status !== ''){
|
||||
$where['a.status'] = $search_order_status;
|
||||
}
|
||||
if($search_uid !== ''){
|
||||
$where['b.user_code'] = $search_uid;
|
||||
}
|
||||
if($search_nickname !== ''){
|
||||
$where['b.nickname'] = ['like', '%'.$search_nickname.'%'];
|
||||
}
|
||||
if($search_type !== ''){
|
||||
$where['a.type'] = $search_type;
|
||||
}
|
||||
if($search_withd_type !== ''){
|
||||
$where['a.withd_type'] = $search_withd_type;
|
||||
}
|
||||
if($search_stime !== ''){
|
||||
$where['a.createtime'] = ['>=', strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime !== ''){
|
||||
$where['a.createtime'] = ['<=', strtotime($search_etime.' 23:59:59')];
|
||||
}
|
||||
if(!empty($search_stime) && !empty($search_etime)){
|
||||
$where['a.createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime.' 23:59:59')]];
|
||||
}
|
||||
$count = db::name('vs_user_withdrawal')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->field('a.*,b.nickname')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = db::name('vs_user_withdrawal')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->field('a.*,b.nickname,b.user_code')
|
||||
->order('a.createtime desc')
|
||||
->where($where)
|
||||
->select();
|
||||
$data_lists = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
$data_lists[$key]['id'] = $value['wid'];
|
||||
$data_lists[$key]['order_sn'] = $value['order_sn'];
|
||||
$data_lists[$key]['nickname'] = $value['user_code'].'-'.$value['nickname'];
|
||||
$data_lists[$key]['money'] = $value['money'];
|
||||
$data_lists[$key]['general_money'] = $value['general_money'];
|
||||
$data_lists[$key]['server_money'] = $value['server_money'];
|
||||
//支付宝账号
|
||||
$data_lists[$key]['real_name'] = $value['real_name'];
|
||||
$data_lists[$key]['alipay_account'] = $value['alipay_account'];
|
||||
$data_lists[$key]['bank_card'] = $value['bank_card'];
|
||||
$data_lists[$key]['open_bank'] = $value['open_bank'];
|
||||
$data_lists[$key]['bank_card'] = $value['bank_card'];
|
||||
$data_lists[$key]['bank_card_number'] = $value['bank_card_number'];
|
||||
$data_lists[$key]['remarke'] = $value['remarke'];
|
||||
$data_lists[$key]['status'] = $value['status'];
|
||||
$pay_message = '';
|
||||
if(in_array($value['status'],[5,4])){
|
||||
$pay_message = $value['pay_message'] ? "【".$value['pay_message']."】":'';
|
||||
}
|
||||
$data_lists[$key]['status_str'] = Model('api/UserWithdrawal')->withdraw_status[$value['status']].$pay_message;
|
||||
$data_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
//统计
|
||||
|
||||
//待审核数量
|
||||
$wait_num = db::name('vs_user_withdrawal')->where('status',1)->count();
|
||||
//今日提现
|
||||
$today_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->whereTime('createtime', 'today')->sum('money');
|
||||
//昨日提现
|
||||
$yesterday_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->whereTime('createtime', 'yesterday')->sum('money');
|
||||
//已完成提现总额
|
||||
$complete_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->sum('money');
|
||||
//手续费收入
|
||||
$server_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->sum('server_money');
|
||||
//提现总额
|
||||
$total_money = $complete_money+$server_money;
|
||||
|
||||
//订单状态列表
|
||||
$i = 0;
|
||||
$withdraw_status_array = [];
|
||||
foreach (Model('api/UserWithdrawal')->withdraw_status as $key => $value){
|
||||
$withdraw_status_array[$i]['id'] = $key;
|
||||
$withdraw_status_array[$i]['name'] = $value;
|
||||
$i++;
|
||||
}
|
||||
//提现方式
|
||||
$withdraw_type_array = [];
|
||||
$i = 0;
|
||||
foreach ($this->withdraw_type as $key => $value){
|
||||
$withdraw_type_array[$i]['id'] = $key;
|
||||
$withdraw_type_array[$i]['name'] = $value;
|
||||
$i++;
|
||||
}
|
||||
//平台处理方式
|
||||
$withd_type_array = [];
|
||||
$i = 0;
|
||||
foreach ($this->withd_type as $key => $value){
|
||||
$withd_type_array[$i]['id'] = $key;
|
||||
$withd_type_array[$i]['name'] = $value;
|
||||
$i++;
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $data_lists,
|
||||
'total_data' => [
|
||||
'total_money' => $total_money,
|
||||
'wait_num' => $wait_num,
|
||||
'today_money' => $today_money,
|
||||
'yesterday_money' => $yesterday_money,
|
||||
'complete_money' => $complete_money,
|
||||
'server_money' => $server_money
|
||||
],
|
||||
'withdraw_status' => $withdraw_status_array,
|
||||
'withdraw_type' => $withdraw_type_array,
|
||||
'withd_type' => $withd_type_array,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 提现发放
|
||||
*/
|
||||
public function withdraw_send(){
|
||||
$wid = input('id', '');
|
||||
$status = input('status', '');
|
||||
$withd_type = input('withd_type', '');
|
||||
$remarke = input('remarke', '');
|
||||
$secondary_password = input('secondary_password', '');
|
||||
$check_pass = model('adminapi/admin')->check_secondary_password($secondary_password);
|
||||
if($check_pass['code']==0){
|
||||
return v($check_pass['code'], $check_pass['msg'], $check_pass['data']);
|
||||
}
|
||||
if($wid == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$withdraw_info = db::name('vs_user_withdrawal')->where('wid', $wid)->find();
|
||||
if($withdraw_info['status'] != 1){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($withdraw_info['status'] != 1){
|
||||
return V(0,"该提现已处理");
|
||||
}
|
||||
|
||||
DB::startTrans();
|
||||
try{
|
||||
if($status == 2){
|
||||
$data['status']= 2;
|
||||
$deal_type =1;
|
||||
if($withd_type==1){//微信
|
||||
$transfer_type = 2;
|
||||
return V(0,"功能暂未开放,请选用云账户");
|
||||
} elseif($withd_type==2){//支付宝
|
||||
$transfer_type = 2;
|
||||
return V(0,"功能暂未开放,请选用云账户");
|
||||
} elseif($withd_type==3){//银行卡
|
||||
$transfer_type = 2;
|
||||
return V(0,"功能暂未开放,请选用云账户");
|
||||
} elseif($withd_type==4){//云账户
|
||||
$transfer_type = 2;
|
||||
$deal_type =2;
|
||||
$result_yun = $this->submit_yun($withdraw_info);
|
||||
if($result_yun['code'] == 1){
|
||||
$data['status'] = 4;
|
||||
$data['submit_yun_time'] = time();
|
||||
}else{
|
||||
Db::rollback();
|
||||
return V(0,$result_yun['msg']);
|
||||
}
|
||||
} elseif($withd_type==5){//其他
|
||||
$transfer_type = 1;
|
||||
} else{
|
||||
Db::rollback();
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$data['withd_type']= $withd_type;
|
||||
$data['remarke']= $remarke;
|
||||
$data['transfer_type']= $transfer_type;
|
||||
$data['deal_type']= $deal_type;
|
||||
$data['deal_time']= time();
|
||||
$data['updatetime']= time();
|
||||
$result = db::name('vs_user_withdrawal')->where('wid', $wid)->update($data);
|
||||
if(!$result){
|
||||
Db::rollback();
|
||||
return V(0,"操作失败");
|
||||
}
|
||||
}else{
|
||||
$result = db::name('vs_user_withdrawal')->where('wid', $wid)->update([
|
||||
'status' => 3,
|
||||
'remarke' => $remarke,
|
||||
'deal_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
if(!$result){
|
||||
Db::rollback();
|
||||
return V(0,"操作失败");
|
||||
}
|
||||
$res = model('api/UserWithdrawal')->withdrawal_fail($withdraw_info['order_sn']);
|
||||
if($res['code'] == 0){
|
||||
Db::rollback();
|
||||
return V(0,$res['msg']);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return V(0,$e->getMessage());
|
||||
}
|
||||
return V(1,"操作成功");
|
||||
}
|
||||
/*
|
||||
* 云账户提现
|
||||
*/
|
||||
public function submit_yun($withdraw_info){
|
||||
//查询该用户云账户提现金额
|
||||
$had_money = db::name('vs_user_withdrawal')->where(['user_id'=>$withdraw_info['user_id'],'deal_type'=>2,'status'=>6])->where('pay_time','month')->sum('general_money');
|
||||
$max_month_money = 98000;
|
||||
if(($had_money+$withdraw_info['general_money']) >= 98000){
|
||||
return ['code' => 0, 'msg' => '单人单月云账户提现金额最大为98000元!', 'data' => null];
|
||||
}
|
||||
//查询该用户信息
|
||||
$user_info = model('api/user')->get_user_info($withdraw_info['user_id']);
|
||||
if(empty($user_info)){
|
||||
return ['code' => 0, 'msg' => '用户信息错误!', 'data' => null];
|
||||
}
|
||||
$real_name = $user_info['real_name'];
|
||||
$id_card = $user_info['card_id'];
|
||||
$order_id = $withdraw_info['order_sn'];
|
||||
$order_amount = $withdraw_info['general_money'];
|
||||
$phone = $user_info['mobile'];
|
||||
if (empty($real_name) || empty($id_card)) {
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
}
|
||||
if($withdraw_info['type'] == 1){
|
||||
return ['code' => 0, 'msg' => '暂未对接微信', 'data' => null];
|
||||
// $yun_pay = new YunPay($order_id, $real_name, $id_card, $card_no, $order_amount,$phone);
|
||||
// $result = $yun_pay->Wxpay($user_info['wx_openid']);
|
||||
} elseif ($withdraw_info['type'] == 2) {
|
||||
if(empty($user_info['alipay_account'])){
|
||||
return ['code' => 0, 'msg' => '请先绑定支付宝账号', 'data' => null];
|
||||
}
|
||||
$card_no = $user_info['alipay_account'];
|
||||
$yun_pay = new YunPay($order_id, $real_name, $id_card, $card_no, $order_amount,$phone);
|
||||
$result = $yun_pay->alipay();
|
||||
} elseif ($withdraw_info['type'] == 3) {
|
||||
if(empty($user_info['bank_card_number'])){
|
||||
return ['code' => 0, 'msg' => '请先绑定银行卡号', 'data' => null];
|
||||
}
|
||||
$card_no = $user_info['bank_card_number'];
|
||||
$yun_pay = new YunPay($order_id, $real_name, $id_card, $card_no, $order_amount,$phone);
|
||||
$result = $yun_pay->bank();
|
||||
}
|
||||
if ($result['code'] == 1) {
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}else{
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
102
application/adminapi/lang/zh-cn.php
Normal file
102
application/adminapi/lang/zh-cn.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Keep login' => '保持会话',
|
||||
'Username' => '用户名',
|
||||
'User id' => '会员ID',
|
||||
'Nickname' => '昵称',
|
||||
'Password' => '密码',
|
||||
'Sign up' => '注 册',
|
||||
'Sign in' => '登 录',
|
||||
'Sign out' => '退 出',
|
||||
'Guest' => '游客',
|
||||
'Welcome' => '%s,你好!',
|
||||
'Add' => '添加',
|
||||
'Edit' => '编辑',
|
||||
'Delete' => '删除',
|
||||
'Move' => '移动',
|
||||
'Name' => '名称',
|
||||
'Status' => '状态',
|
||||
'Weigh' => '权重',
|
||||
'Operate' => '操作',
|
||||
'Warning' => '温馨提示',
|
||||
'Default' => '默认',
|
||||
'Article' => '文章',
|
||||
'Page' => '单页',
|
||||
'OK' => '确定',
|
||||
'Cancel' => '取消',
|
||||
'Loading' => '加载中',
|
||||
'More' => '更多',
|
||||
'Normal' => '正常',
|
||||
'Hidden' => '隐藏',
|
||||
'Submit' => '提交',
|
||||
'Reset' => '重置',
|
||||
'Execute' => '执行',
|
||||
'Close' => '关闭',
|
||||
'Search' => '搜索',
|
||||
'Refresh' => '刷新',
|
||||
'First' => '首页',
|
||||
'Previous' => '上一页',
|
||||
'Next' => '下一页',
|
||||
'Last' => '末页',
|
||||
'None' => '无',
|
||||
'Home' => '主页',
|
||||
'Online' => '在线',
|
||||
'Logout' => '退出',
|
||||
'Profile' => '个人资料',
|
||||
'Index' => '首页',
|
||||
'Hot' => '热门',
|
||||
'Recommend' => '推荐',
|
||||
'Dashboard' => '控制台',
|
||||
'Code' => '编号',
|
||||
'Message' => '内容',
|
||||
'Line' => '行号',
|
||||
'File' => '文件',
|
||||
'Menu' => '菜单',
|
||||
'Type' => '类型',
|
||||
'Title' => '标题',
|
||||
'Content' => '内容',
|
||||
'Append' => '追加',
|
||||
'Memo' => '备注',
|
||||
'Parent' => '父级',
|
||||
'Params' => '参数',
|
||||
'Permission' => '权限',
|
||||
'Advance search' => '高级搜索',
|
||||
'Check all' => '选中全部',
|
||||
'Expand all' => '展开全部',
|
||||
'Begin time' => '开始时间',
|
||||
'End time' => '结束时间',
|
||||
'Create time' => '创建时间',
|
||||
'Flag' => '标志',
|
||||
'Please login first' => '请登录后操作',
|
||||
'Uploaded successful' => '上传成功',
|
||||
'You can upload up to %d file%s' => '你最多还可以上传%d个文件',
|
||||
'You can choose up to %d file%s' => '你最多还可以选择%d个文件',
|
||||
'Chunk file write error' => '分片写入失败',
|
||||
'Chunk file info error' => '分片文件错误',
|
||||
'Chunk file merge error' => '分片合并错误',
|
||||
'Chunk file disabled' => '未开启分片上传功能',
|
||||
'Cancel upload' => '取消上传',
|
||||
'Upload canceled' => '上传已取消',
|
||||
'No file upload or server upload limit exceeded' => '未上传文件或超出服务器上传限制',
|
||||
'Uploaded file format is limited' => '上传文件格式受限制',
|
||||
'Uploaded file is not a valid image' => '上传文件不是有效的图片文件',
|
||||
'Are you sure you want to cancel this upload?' => '确定取消上传?',
|
||||
'Remove file' => '移除文件',
|
||||
'You can only upload a maximum of %s files' => '你最多允许上传 %s 个文件',
|
||||
'You can\'t upload files of this type' => '不允许上传的文件类型',
|
||||
'Server responded with %s code' => '服务端响应(Code:%s)',
|
||||
'File is too big (%sMiB), Max filesize: %sMiB.' => '当前上传(%sM),最大允许上传文件大小:%sM',
|
||||
'Redirect now' => '立即跳转',
|
||||
'Operation completed' => '操作成功!',
|
||||
'Operation failed' => '操作失败!',
|
||||
'Unknown data format' => '未知的数据格式!',
|
||||
'Network error' => '网络错误!',
|
||||
'Advanced search' => '高级搜索',
|
||||
'Invalid parameters' => '未知参数',
|
||||
'No results were found' => '记录未找到',
|
||||
'Parameter %s can not be empty' => '参数%s不能为空',
|
||||
'You have no permission' => '你没有权限访问',
|
||||
'An unexpected error occurred' => '发生了一个意外错误,程序猿正在紧急处理中',
|
||||
'This page will be re-directed in %s seconds' => '页面将在 %s 秒后自动跳转',
|
||||
];
|
||||
3
application/adminapi/lang/zh-cn/common.php
Normal file
3
application/adminapi/lang/zh-cn/common.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
return [];
|
||||
39
application/adminapi/lang/zh-cn/user.php
Normal file
39
application/adminapi/lang/zh-cn/user.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'User center' => '会员中心',
|
||||
'Register' => '注册',
|
||||
'Login' => '登录',
|
||||
'Sign up successful' => '注册成功',
|
||||
'Username can not be empty' => '用户名不能为空',
|
||||
'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
|
||||
'Username must be 6 to 30 characters' => '用户名必须6-30个字符',
|
||||
'Password can not be empty' => '密码不能为空',
|
||||
'Password must be 6 to 30 characters' => '密码必须6-30个字符',
|
||||
'Mobile is incorrect' => '手机格式不正确',
|
||||
'Username already exist' => '用户名已经存在',
|
||||
'Nickname already exist' => '昵称已经存在',
|
||||
'Email already exist' => '邮箱已经存在',
|
||||
'Mobile already exist' => '手机号已经存在',
|
||||
'Username is incorrect' => '用户名不正确',
|
||||
'Email is incorrect' => '邮箱不正确',
|
||||
'Account is locked' => '账户已经被锁定',
|
||||
'Password is incorrect' => '密码不正确',
|
||||
'Account is incorrect' => '账户不正确',
|
||||
'Account not exist' => '账户不存在',
|
||||
'Account can not be empty' => '账户不能为空',
|
||||
'Username or password is incorrect' => '用户名或密码不正确',
|
||||
'You are not logged in' => '你当前还未登录',
|
||||
'You\'ve logged in, do not login again' => '你已经存在,请不要重复登录',
|
||||
'Profile' => '个人资料',
|
||||
'Verify email' => '邮箱验证',
|
||||
'Change password' => '修改密码',
|
||||
'Captcha is incorrect' => '验证码不正确',
|
||||
'Logged in successful' => '登录成功',
|
||||
'Logout successful' => '退出成功',
|
||||
'Operation failed' => '操作失败',
|
||||
'Invalid parameters' => '参数不正确',
|
||||
'Change password failure' => '修改密码失败',
|
||||
'Change password successful' => '修改密码成功',
|
||||
'Reset password successful' => '重置密码成功',
|
||||
];
|
||||
37
application/adminapi/library/ExceptionHandle.php
Normal file
37
application/adminapi/library/ExceptionHandle.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\library;
|
||||
|
||||
use Exception;
|
||||
use think\exception\Handle;
|
||||
|
||||
/**
|
||||
* 自定义API模块的错误显示
|
||||
*/
|
||||
class ExceptionHandle extends Handle
|
||||
{
|
||||
|
||||
public function render(Exception $e)
|
||||
{
|
||||
// 在生产环境下返回code信息
|
||||
if (!\think\Config::get('app_debug')) {
|
||||
$statuscode = $code = 500;
|
||||
$msg = 'An error occurred';
|
||||
// 验证异常
|
||||
if ($e instanceof \think\exception\ValidateException) {
|
||||
$code = 0;
|
||||
$statuscode = 200;
|
||||
$msg = $e->getError();
|
||||
}
|
||||
// Http异常
|
||||
if ($e instanceof \think\exception\HttpException) {
|
||||
$statuscode = $code = $e->getStatusCode();
|
||||
}
|
||||
return json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null], $statuscode);
|
||||
}
|
||||
|
||||
//其它此交由系统处理
|
||||
return parent::render($e);
|
||||
}
|
||||
|
||||
}
|
||||
36
application/adminapi/model/Admin.php
Normal file
36
application/adminapi/model/Admin.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
class Admin extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $name = 'admin';
|
||||
|
||||
|
||||
/*
|
||||
* 二级密码校验
|
||||
*/
|
||||
//二级密码校验
|
||||
public function check_secondary_password($pass){
|
||||
if(empty($pass)){
|
||||
return ['code' => 0, 'msg' => '二级密码不能为空', 'data' => null];
|
||||
}
|
||||
$pass_word = secondary_password();
|
||||
if(md5($pass) != $pass_word){
|
||||
return ['code' => 0, 'msg' => '二级密码错误', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
76
application/adminapi/model/Gift.php
Normal file
76
application/adminapi/model/Gift.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
class Gift extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
protected $name = 'vs_gift';
|
||||
|
||||
//礼物类型 1普通 2盲盒 3礼包礼物
|
||||
public $giftType = [
|
||||
1 => '普通礼物',
|
||||
2 => '盲盒礼物',
|
||||
3 => '礼包礼物'
|
||||
];
|
||||
//送礼流水来源:1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
|
||||
public $GiveGiftFromStr = [
|
||||
1 => '聊天送礼',
|
||||
2 => '房间语聊送礼',
|
||||
3 => '直播送礼',
|
||||
4 => '动态打赏'
|
||||
];
|
||||
|
||||
public function getList($where = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$where['delete_time'] = 0;
|
||||
$list = $this->where($where)->page($page, $limit)->select();
|
||||
$list = collection($list)->toArray();
|
||||
return $list;
|
||||
}
|
||||
public function getCount($where = [])
|
||||
{
|
||||
$where['delete_time'] = 0;
|
||||
return $this->where($where)->count();
|
||||
}
|
||||
public function getOne($where = [])
|
||||
{
|
||||
$one = $this->where($where)->find();
|
||||
return $one;
|
||||
}
|
||||
public function add($data)
|
||||
{
|
||||
$res = $this->save($data);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
$guild_id = $this->id;
|
||||
return $guild_id;
|
||||
}
|
||||
public function edit($where = [], $data = [])
|
||||
{
|
||||
$res = $this->where($where)->update($data);
|
||||
return $res;
|
||||
}
|
||||
public function del($where = [])
|
||||
{
|
||||
$res = $this->where($where)->delete();
|
||||
return $res;
|
||||
}
|
||||
//软删除
|
||||
public function setDel($where = []){
|
||||
$res = $this->where($where)->setField('delete_time',time());
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
146
application/adminapi/model/Guild.php
Normal file
146
application/adminapi/model/Guild.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
class Guild extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
protected $name = 'vs_guild';
|
||||
|
||||
public function getList($where = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$list = $this->where($where)->page($page, $limit)->select();
|
||||
$list = collection($list)->toArray();
|
||||
return $list;
|
||||
}
|
||||
public function getCount($where = [])
|
||||
{
|
||||
return $this->where($where)->count();
|
||||
}
|
||||
public function getOne($where = [])
|
||||
{
|
||||
$one = $this->where($where)->find();
|
||||
return $one;
|
||||
}
|
||||
public function add($data)
|
||||
{
|
||||
$res = $this->save($data);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
$guild_id = $this->id;
|
||||
return $guild_id;
|
||||
}
|
||||
public function edit($where = [], $data = [])
|
||||
{
|
||||
$res = $this->where($where)->update($data);
|
||||
return $res;
|
||||
}
|
||||
public function del($where = [])
|
||||
{
|
||||
$res = $this->where($where)->delete();
|
||||
return $res;
|
||||
}
|
||||
//软删除
|
||||
public function setDel($where = []){
|
||||
$res = $this->where($where)->setField('delete_time',time());
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
//靓号处理
|
||||
public function getGuildSpecialId(){
|
||||
$code = $this->order('guild_special_id desc')->value('guild_special_id');
|
||||
if(empty($code)){
|
||||
$code = 10000;
|
||||
}
|
||||
$code = $code + 1;
|
||||
$vip_code = db::name('vip_code')->where(['type' => 3, 'status' => 1,'is_use' => 1])->field('code')->select();
|
||||
if (empty($vip_code)) {
|
||||
return $code;
|
||||
}
|
||||
if (in_array($code, (array)$vip_code)) {
|
||||
return $code + 2;
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
/*
|
||||
* 通过用户ID 获取公会信息
|
||||
*
|
||||
*/
|
||||
public function getGuildByUserId($user_id){
|
||||
$guild = db::name('vs_guild_user')
|
||||
->alias('g')
|
||||
->join('vs_guild gg','g.guild_id = gg.id')
|
||||
->field('gg.*')
|
||||
->where(['g.user_id' => $user_id])
|
||||
->find();
|
||||
return $guild;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*工会当日流水
|
||||
*/
|
||||
public function getTodayMoney($guild_id,$stoday="",$etoday=""){
|
||||
$where = [];
|
||||
if(empty($stoday) && empty($etoday)){
|
||||
$stoday = strtotime(date('Y-m-d 00:00:00'));
|
||||
$etoday = strtotime(date('Y-m-d 23:59:59'));
|
||||
$where['createtime'] = ['between', [$stoday, $etoday]];
|
||||
}else{
|
||||
if(!empty($stoday)){
|
||||
$where['createtime'] = ['>=', strtotime($stoday."00:00:00")];
|
||||
}
|
||||
if(!empty($etoday)){
|
||||
$where['createtime'] = ['<=', strtotime($etoday." 23:59:59")];
|
||||
}
|
||||
if(!empty($stoday) && !empty($etoday)){
|
||||
$where['createtime'] = ['between', [strtotime($stoday." 00:00:00"), strtotime($etoday." 23:59:59")]];
|
||||
}
|
||||
}
|
||||
|
||||
//获取所有工会房间ID
|
||||
$room_ids = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id')->select();
|
||||
$room_ids = array_column($room_ids, 'room_id');
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$room_ids)
|
||||
->where(['from'=>['in',[2,3,6]]])
|
||||
->where($where)
|
||||
->sum('total_price');
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
/*
|
||||
* 工会个人流水
|
||||
*/
|
||||
public function getUserMoney($guild_id,$user_id,$stoday="",$etoday=""){
|
||||
if(empty($stoday)){
|
||||
$stoday = strtotime(date('Y-m-d 00:00:00'));
|
||||
}
|
||||
if(empty($etoday)){
|
||||
$etoday = strtotime(date('Y-m-d 23:59:59'));
|
||||
}
|
||||
//获取所有工会房间ID
|
||||
$room_ids = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id')->select();
|
||||
$room_ids = array_column($room_ids, 'room_id');
|
||||
$transaction =0;
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$room_ids)
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$stoday, $etoday]]])
|
||||
->sum('total_price');
|
||||
return $transaction;
|
||||
}
|
||||
}
|
||||
93
application/adminapi/model/Room.php
Normal file
93
application/adminapi/model/Room.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
class Room extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
protected $name = 'vs_room';
|
||||
|
||||
public $relation_type = [1=>'真爱拍',2=>'友情拍'];
|
||||
public $room_status = [1=>'正常',2=>'封禁',3=>'关闭'];
|
||||
|
||||
|
||||
//房间操作 日志 类型
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
public $room_log_type = [1=>'禁麦位',2=>'清空消息',3=>'清空魅力值',4=>'加入黑名单',5=>'踢出房间',6=>'关闭麦克风',7=>'申请上麦',8=>'同意上麦',9=>'拒绝上麦',10=>'点歌',11=>'开启PK'];
|
||||
|
||||
|
||||
public function getList($where = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$list = $this->where($where)->page($page, $limit)->select();
|
||||
$list = collection($list)->toArray();
|
||||
return $list;
|
||||
}
|
||||
public function getCount($where = [])
|
||||
{
|
||||
return $this->where($where)->count();
|
||||
}
|
||||
public function getOne($where = [])
|
||||
{
|
||||
$one = $this->where($where)->find();
|
||||
return $one;
|
||||
}
|
||||
public function add($data)
|
||||
{
|
||||
$res = $this->save($data);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
$guild_id = $this->id;
|
||||
return $guild_id;
|
||||
}
|
||||
public function edit($where = [], $data = [])
|
||||
{
|
||||
$res = $this->where($where)->update($data);
|
||||
return $res;
|
||||
}
|
||||
public function del($where = [])
|
||||
{
|
||||
$res = $this->where($where)->delete();
|
||||
return $res;
|
||||
}
|
||||
//软删除
|
||||
public function setDel($where = []){
|
||||
$res = $this->where($where)->setField('delete_time',time());
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查询房间流水
|
||||
*/
|
||||
public function getRoomFlow($room_id,$stime='',$etime=''){
|
||||
$give_where = [];
|
||||
$give_where['from_id'] = $room_id;
|
||||
$give_where['from'] = ["in",[2,3,6]];
|
||||
if(!empty($stime)){
|
||||
$give_where['createtime'] = ['>=',strtotime($stime.' 00:00:00')];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$give_where['createtime'] = ['<=',strtotime($etime.' 23:59:59')];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$give_where['createtime'] = ['between',[strtotime($stime.' 00:00:00'),strtotime($etime.' 23:59:59')]];
|
||||
}
|
||||
$total_price = db::name('vs_give_gift')->where($give_where)
|
||||
->sum('total_price');
|
||||
return $total_price;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
138
application/adminapi/model/User.php
Normal file
138
application/adminapi/model/User.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
class User extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
protected $name = 'user';
|
||||
|
||||
|
||||
public function getList($where = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$list = $this->where($where)->page($page, $limit)->select();
|
||||
$list = collection($list)->toArray();
|
||||
return $list;
|
||||
}
|
||||
public function getCount($where = [])
|
||||
{
|
||||
return $this->where($where)->count();
|
||||
}
|
||||
public function getOne($where = [])
|
||||
{
|
||||
$one = $this->where($where)->find();
|
||||
return $one;
|
||||
}
|
||||
public function add($data)
|
||||
{
|
||||
$res = $this->save($data);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
$guild_id = $this->id;
|
||||
return $guild_id;
|
||||
}
|
||||
public function edit($where = [], $data = [])
|
||||
{
|
||||
$res = $this->where($where)->update($data);
|
||||
return $res;
|
||||
}
|
||||
public function del($where = [])
|
||||
{
|
||||
$res = $this->where($where)->delete();
|
||||
return $res;
|
||||
}
|
||||
//软删除
|
||||
public function setDel($where = []){
|
||||
$res = $this->where($where)->setField('delete_time',time());
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 用户注册 (机器人)
|
||||
*/
|
||||
public function user_reg($user_name='')
|
||||
{
|
||||
$data = [];
|
||||
$user_code = model('api/Login')->get_user_code(); //获取用户code_id 过滤靓号
|
||||
$data['user_code'] = $user_code;
|
||||
$data['username'] = $user_name;
|
||||
$data['mobile'] = $user_name;
|
||||
$data['nickname'] = '游客'.$user_code;
|
||||
$data['joinip'] = request()->ip();
|
||||
$data['birthday'] = date('Y-m-d');
|
||||
$data['avatar'] = get_system_config_value('web_site').'/data/avatar/head_pic.png';
|
||||
$data['profile'] = '这个人很懒,什么都没写';
|
||||
$data['system'] = '';
|
||||
$data['login_device'] = '';
|
||||
$data['createtime'] = time();
|
||||
$data['logintime'] = time();
|
||||
$data['status'] = 1;
|
||||
$data['is_robot'] = 1;
|
||||
$data['is_sys_tester'] = 1;
|
||||
$data['init_code'] = model('api/User')->invite_code();
|
||||
|
||||
$reslut = model('api/User')->insert($data);
|
||||
//获取上一步的id
|
||||
$user_id = model('api/User')->where('user_code',$user_code)->value('id');
|
||||
|
||||
if (!$reslut) {
|
||||
return ['code' => 0, 'msg' => '登录失败le', 'data' => null];
|
||||
};
|
||||
|
||||
//创建钱包
|
||||
$user_wallet = model('api/UserWallet')->create_data($user_id);
|
||||
if (!$user_wallet) {
|
||||
return ['code' => 0, 'msg' => '登录失败1', 'data' => null];
|
||||
}
|
||||
|
||||
//登录token
|
||||
$login_token = model('api/UserToken')->update_token($user_id);
|
||||
if(isset($login_token['code']) && $login_token['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '登录失败3', 'data' => null];
|
||||
}
|
||||
|
||||
$user_data = [];
|
||||
$user_data['tencent_im'] = "";
|
||||
$user_data['createtime'] = time();
|
||||
$user_data['user_id'] = $user_id;
|
||||
$user_data['wx_openid'] = "";
|
||||
$user_data['ali_userid'] = "";
|
||||
|
||||
$reslut_user_data = model('api/UserData')->save($user_data);
|
||||
if (!$reslut_user_data) {
|
||||
return ['code' => 0, 'msg' => '登录失败4', 'data' => null];
|
||||
}
|
||||
|
||||
$return_res[0]['user_id'] = $user_id;
|
||||
$return_res[0]['user_code'] = $user_code;
|
||||
$return_res[0]['avatar'] = 'data/avatar/head_pic.png';
|
||||
$return_res[0]['nickname'] = '游客'.$user_code;
|
||||
$return_res[0]['token'] = $login_token;
|
||||
$return_res[0]['tencent_im'] = "";
|
||||
$return_res[0]['sex'] = 0;
|
||||
$return_res[0]['mobile'] = $user_name;
|
||||
$return_res[0]['auth'] = 0;
|
||||
$return_res[0]['icon'][0] = model('api/UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$return_res[0]['icon'][1] = model('api/UserData')->user_charm_icon($user_id);//魅力图标
|
||||
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return_res];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user