Certificate.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. *
  4. * User: anyluck
  5. * Date: 2020/6/2
  6. * Time: 17:39
  7. */
  8. namespace app\admin\controller;
  9. use app\common\controller\Backend;
  10. use app\common\model\Mining;
  11. use app\common\model\State;
  12. use think\facade\Request;
  13. use think\facade\View;
  14. class Certificate extends Backend
  15. {
  16. //通证管理
  17. /**
  18. * 通证管理
  19. */
  20. public function index()
  21. {
  22. }
  23. /**
  24. * BTS管理
  25. */
  26. public function bts()
  27. {
  28. if (Request::isPost()) {
  29. $name = input("name");
  30. $page = input("page") ?: 1;
  31. $limit = input("limit") ?: 10;
  32. $where = [];
  33. // if ($name){
  34. // $where["name"]=["like","% $name %"];
  35. // }
  36. $list = Mining::where($where)->order("id desc")->paginate(["list_row" => $limit, "page" => $page])->each(function ($item) {
  37. return $item;
  38. })->toArray();
  39. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'] ?: [], 'count' => $list['total'] ?: 0];
  40. }
  41. return View::fetch();
  42. }
  43. // 修改状态
  44. public function update_bts_status()
  45. {
  46. $id=input("id");
  47. $mining=Mining::where(["id"=>$id])->find();
  48. if ($mining->status==0){
  49. $update["status"]=1;
  50. }else{
  51. $update["status"]=0;
  52. }
  53. Mining::update($update,["id"=>$id]);
  54. json_result(200,"设置成功");
  55. }
  56. // 删除bts
  57. public function del_mining()
  58. {
  59. $id=input("id");
  60. Mining::where(["id"=>$id])->delete();
  61. json_result(200,"删除成功");
  62. }
  63. // 修改添加
  64. public function addbts()
  65. {
  66. if (Request::isPost()) {
  67. $data = Request::post();
  68. $id=input("id");
  69. if ($id){
  70. Mining::update($data);
  71. }else{
  72. Mining::create($data);
  73. }
  74. json_result(200,"操作成功",$data);
  75. }
  76. $id=input("id");
  77. $info="";
  78. if ($id){
  79. $info= Mining::where(["id"=>$id])->find();
  80. }
  81. $view = [
  82. 'info' =>$info,
  83. ];
  84. View::assign($view);
  85. return View::fetch();
  86. }
  87. }