123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use app\common\model\Notice;
- use app\common\model\Problem;
- use app\common\model\Quotation;
- use think\facade\Db;
- use think\facade\Request;
- use think\facade\View;
- use app\common\model\User;
- class Contents extends Backend
- {
- // todo 内容管理
- //轮播图
- public function index()
- {
- if (Request::isPost()){
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $url="http://".$_SERVER['HTTP_HOST'];
- $list=Db::name("banner")->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) use (&$url){
- $item["url"]=$url;
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 添加轮播图
- public function addbanner()
- {
- $name=input("text");
- $img=input("img")?:"";
- $text=input("text")?:"";
- $id=input("id");
- $add["text"]=$name;
- $add["image"]=$img;
- $add["text"]=$text;
- // $add["centos"]=$centos;
- if ($id){
- $where["id"]=$id;
- $res=Db::name("banner")->where($where)->update($add);
- }else{
- $res=Db::name("banner")->insert($add);
- }
- if ($res){
- json_result(1,"添加成功");
- }
- json_result(2,"添加失败");
- }
- public function add()
- {
- $id=input("id");
- $info=[];
- if ($id){
- $where["id"]=$id;
- $info=Db::name("banner")->where($where)->find();
- }else{
- $info["text"]='';
- $info["img"]='';
- }
- $view = [
- 'info' => $info,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- // 删除轮播图
- public function del_banner()
- {
- $id=input("id");
- $where["id"]=$id;
- Db::name("banner")->where($where)->delete();
- json_result(1,"删除成功");
- }
- //
- //关于我们
- public function about()
- {
- if (Request::isPost()){
- $centos=input("text");
- $add["text"]=$centos;
- $ehere["id"]=1;
- Db::name("about")->where($ehere)->update($add);
- json_result(1,"修改成功");
- }
- $data=Db::name("about")->where(["id"=>1])->value("text");
- $view = [
- 'info' => $data,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- //
- //意见反馈
- public function feedback()
- {
- if (Request::isPost()){
- $name=input("name");
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $where=[];
- // if ($name){
- // $where["name"]=["like","% $name %"];
- // }
- $list=Db::name("feedback")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
- $user=\app\common\model\User::where(["id"=>$item["user_id"]])->field("name")->find();
- $item["name"]=$user->name;
- if ($item["image"]){
- $item["image"]=explode(",",$item["image"]);
- }else{
- $item["image"]="";
- }
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- //
- public function hlep()
- {
- if (Request::isPost()){
- $name=input("name");
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $where=[];
- $list=Db::name("problem")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 删除常见问题
- public function del_hlep()
- {
- $id=input("id");
- Problem::where(["id"=>$id])->delete();
- json_result(200,"删除成功");
- }
- // 添加修改
- public function addhlep()
- {
- if (Request::isPost()){
- $id=input("id");
- $add["name"]=input("name");
- $add["text"]=input("text");
- if ($id){
- Problem::update($add,["id"=>$id]);
- }else{
- Problem::create($add);
- }
- json_result(200,"操作成功");
- }else{
- $id=input("id");
- if ($id){
- $da=Problem::where(["id"=>$id])->find();
- $info["name"]=$da->name;
- $info["text"]=$da->text;
- $info["id"]=$id;
- }else{
- $info["name"]="";
- $info["text"]="";
- $info["id"]=0;
- }
- $view = [
- 'info' => $info,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- }
- // 收款信息
- public function push()
- {
- if (Request::isPost()){
- $data = Request::post();
- foreach ($data as $k=>$v){
- $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
- }
- json_result(200,"修改成功",$data);
- }
- $list = Db::name('system')
- ->where(["type"=>"shouk"])
- ->field('name,value')
- ->column('value','name');
- View::assign('config',json_encode($list));
- $view = [
- 'info' => $list,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- //系统消息管理
- public function sysmsg()
- {
- if (Request::isPost()){
- $name=input("name");
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $where=[];
- $list=Db::name("notice")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 更新是否显示消息
- public function update_nocice_status()
- {
- $id=input("id");
- $status=input("status")?:0;
- Notice::update(["status"=>$status],["id"=>$id]);
- json_result(200,"操作成功");
- }
- public function del_msg()
- {
- $id=input("id");
- Notice::where(["id"=>$id])->delete();
- json_result(200,"删除成功");
- }
- // 添加消息
- public function addmsg()
- {
- if (Request::isPost()){
- $id=input("id");
- $add["name"]=input("name");
- $add["text"]=input("text");
- if ($id){
- Notice::update($add,["id"=>$id]);
- }else{
- Notice::create($add);
- }
- json_result(200,"操作成功");
- }else{
- $id=input("id");
- if ($id){
- $da=Problem::where(["id"=>$id])->find();
- $info["name"]=$da->name;
- $info["text"]=$da->text;
- $info["id"]=$id;
- }else{
- $info["name"]="";
- $info["text"]="";
- $info["id"]=0;
- }
- $view = [
- 'info' => $info,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- }
- // 开盘设置
- public function opens()
- {
- if (Request::isPost()){
- $data = Request::post();
- if (isset($data["open"])){
- $data["open"]=1;
- }else{
- $data["open"]="";
- }
- foreach ($data as $k=>$v){
- $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
- }
- json_result(200,"修改成功",$data);
- }
- $list = Db::name('system')
- ->where(["type"=>"open"])
- ->field('name,value')
- ->column('value','name');
- // var_dump($list["open"]);die();
- View::assign('config',json_encode($list));
- $view = [
- 'info' => $list,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- // 后台收款账号
- public function adminuser()
- {
- if (Request::isPost()){
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $name=input("name");
- $where=[];
- if ($name){
- $where[]=["name","like","%".$name."%"];
- }
- $where[]=["admin","=",1];
- $list=User::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 修改信息
- public function update_user_admin()
- {
- $id=input("id");
- $field=input("field");
- $value=input("value");
- $where["id"]=$id;
- $update[$field]=$value;
- User::update($update,$where);
- json_result(200,"操作成功");
- }
- // 收款信息
- public function showuser()
- {
- if (Request::isPost()) {
- $data = Request::post();
- $adminid=input("user_id");
- $where["user_id"]=$adminid;
- \app\common\model\UserMessage::update($data,$where);
- json_result(200, "修改成功", $data);
- }
- $adminid=input("user_id");
- $where["user_id"]=$adminid;
- $code=\app\common\model\UserMessage::where($where)->find();
- if (!$code){
- \app\common\model\UserMessage::create($where);
- $code=\app\common\model\UserMessage::where($where)->find();
- }
- View::assign("user",$code);
- return View::fetch();
- }
- // 封号
- public function fenhao()
- {
- $id=input("id");
- $user=\app\common\model\User::where(["id"=>$id])->field("status")->find();
- if ($user->status==1){
- $update["status"]=0;
- }else{
- $update["status"]=1;
- }
- \app\common\model\User::update($update,["id"=>$id]);
- json_result(200,"操作成功");
- }
- // 密码重置
- public function update_pwd()
- {
- $id=input("id");
- $pwd=input("pwd");
- $data["pwd"] = password_hash($pwd, PASSWORD_DEFAULT);;
- User::update($data,["id"=>$id]);
- json_result(200,"重置成功");
- }
- // 删除账号
- public function delete_user()
- {
- $id=input("id");
- User::where(["id"=>$id])->delete();
- json_result(200,"删除成功");
- }
- // 添加后台账号
- public function add_admin_user()
- {
- $name=input("name");
- $add["name"]=$name;
- $add["admin"]=1;
- $add["add_time"]=time();
- $add["update_time"]=time();
- User::create($add);
- json_result(200,"添加成功");
- }
- // 自动发币管理
- public function fb()
- {
- if (Request::isPost()){
- $data = Request::post();
- if (isset($data["fbkg"])){
- $data["fbkg"]=1;
- }else{
- $data["fbkg"]="";
- }
- foreach ($data as $k=>$v){
- $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
- }
- json_result(200,"修改成功",$data);
- }
- $list = Db::name('system')
- ->where(["type"=>"fb"])
- ->field('name,value')
- ->column('value','name');
- // var_dump($list["open"]);die();
- View::assign('config',json_encode($list));
- $view = [
- 'info' => $list,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- public function configs()
- {
- if (Request::isPost()){
- $data = Request::post();
- foreach ($data as $k=>$v){
- $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
- }
- json_result(200,"修改成功",$data);
- }
- $list = Db::name('system')
- ->where(["type"=>"sys"])
- ->field('name,value')
- ->column('value','name');
- // var_dump($list["open"]);die();
- View::assign('config',json_encode($list));
- $view = [
- 'info' => $list,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- // 开盘控制 第二套
- public function quotation()
- {
- if (Request::isPost()){
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $name=input("name");
- $where=[];
- $list=Quotation::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 更新状态
- public function quotation_update()
- {
- $id=input("id");
- $where["id"]=$id;
- $quotation=Quotation::where($where)->find();
- if ($quotation["status"]==1){
- $update["status"]=0;
- }else{
- $update["status"]=1;
- }
- Quotation::update($update,$where);
- json_result(200,"操作成功");
- }
- // 更新数据
- public function quotation_update_data()
- {
- $id=input("id");
- $field=input("field");
- $value=input("value");
- $where["id"]=$id;
- $update[$field]=$value;
- Quotation::update($update,$where);
- json_result(200,"修改成功");
- }
-
-
- }
|