Contents.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\controller;
  4. use app\common\controller\Backend;
  5. use app\common\model\Notice;
  6. use app\common\model\Problem;
  7. use app\common\model\Quotation;
  8. use think\facade\Db;
  9. use think\facade\Request;
  10. use think\facade\View;
  11. use app\common\model\User;
  12. class Contents extends Backend
  13. {
  14. // todo 内容管理
  15. //轮播图
  16. public function index()
  17. {
  18. if (Request::isPost()){
  19. $page=input("page")?:1;
  20. $limit=input("limit")?:10;
  21. $url="http://".$_SERVER['HTTP_HOST'];
  22. $list=Db::name("banner")->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) use (&$url){
  23. $item["url"]=$url;
  24. return $item;
  25. })->toArray();
  26. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
  27. }
  28. return View::fetch();
  29. }
  30. // 添加轮播图
  31. public function addbanner()
  32. {
  33. $name=input("text");
  34. $img=input("img")?:"";
  35. $text=input("text")?:"";
  36. $id=input("id");
  37. $add["text"]=$name;
  38. $add["image"]=$img;
  39. $add["text"]=$text;
  40. // $add["centos"]=$centos;
  41. if ($id){
  42. $where["id"]=$id;
  43. $res=Db::name("banner")->where($where)->update($add);
  44. }else{
  45. $res=Db::name("banner")->insert($add);
  46. }
  47. if ($res){
  48. json_result(1,"添加成功");
  49. }
  50. json_result(2,"添加失败");
  51. }
  52. public function add()
  53. {
  54. $id=input("id");
  55. $info=[];
  56. if ($id){
  57. $where["id"]=$id;
  58. $info=Db::name("banner")->where($where)->find();
  59. }else{
  60. $info["text"]='';
  61. $info["img"]='';
  62. }
  63. $view = [
  64. 'info' => $info,
  65. 'title' => lang('add'),
  66. ];
  67. View::assign($view);
  68. return View::fetch();
  69. }
  70. // 删除轮播图
  71. public function del_banner()
  72. {
  73. $id=input("id");
  74. $where["id"]=$id;
  75. Db::name("banner")->where($where)->delete();
  76. json_result(1,"删除成功");
  77. }
  78. //
  79. //关于我们
  80. public function about()
  81. {
  82. if (Request::isPost()){
  83. $centos=input("text");
  84. $add["text"]=$centos;
  85. $ehere["id"]=1;
  86. Db::name("about")->where($ehere)->update($add);
  87. json_result(1,"修改成功");
  88. }
  89. $data=Db::name("about")->where(["id"=>1])->value("text");
  90. $view = [
  91. 'info' => $data,
  92. 'title' => lang('add'),
  93. ];
  94. View::assign($view);
  95. return View::fetch();
  96. }
  97. //
  98. //意见反馈
  99. public function feedback()
  100. {
  101. if (Request::isPost()){
  102. $name=input("name");
  103. $page=input("page")?:1;
  104. $limit=input("limit")?:10;
  105. $where=[];
  106. // if ($name){
  107. // $where["name"]=["like","% $name %"];
  108. // }
  109. $list=Db::name("feedback")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
  110. $user=\app\common\model\User::where(["id"=>$item["user_id"]])->field("name")->find();
  111. $item["name"]=$user->name;
  112. if ($item["image"]){
  113. $item["image"]=explode(",",$item["image"]);
  114. }else{
  115. $item["image"]="";
  116. }
  117. return $item;
  118. })->toArray();
  119. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
  120. }
  121. return View::fetch();
  122. }
  123. //
  124. public function hlep()
  125. {
  126. if (Request::isPost()){
  127. $name=input("name");
  128. $page=input("page")?:1;
  129. $limit=input("limit")?:10;
  130. $where=[];
  131. $list=Db::name("problem")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
  132. return $item;
  133. })->toArray();
  134. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
  135. }
  136. return View::fetch();
  137. }
  138. // 删除常见问题
  139. public function del_hlep()
  140. {
  141. $id=input("id");
  142. Problem::where(["id"=>$id])->delete();
  143. json_result(200,"删除成功");
  144. }
  145. // 添加修改
  146. public function addhlep()
  147. {
  148. if (Request::isPost()){
  149. $id=input("id");
  150. $add["name"]=input("name");
  151. $add["text"]=input("text");
  152. if ($id){
  153. Problem::update($add,["id"=>$id]);
  154. }else{
  155. Problem::create($add);
  156. }
  157. json_result(200,"操作成功");
  158. }else{
  159. $id=input("id");
  160. if ($id){
  161. $da=Problem::where(["id"=>$id])->find();
  162. $info["name"]=$da->name;
  163. $info["text"]=$da->text;
  164. $info["id"]=$id;
  165. }else{
  166. $info["name"]="";
  167. $info["text"]="";
  168. $info["id"]=0;
  169. }
  170. $view = [
  171. 'info' => $info,
  172. 'title' => lang('add'),
  173. ];
  174. View::assign($view);
  175. return View::fetch();
  176. }
  177. }
  178. // 收款信息
  179. public function push()
  180. {
  181. if (Request::isPost()){
  182. $data = Request::post();
  183. foreach ($data as $k=>$v){
  184. $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
  185. }
  186. json_result(200,"修改成功",$data);
  187. }
  188. $list = Db::name('system')
  189. ->where(["type"=>"shouk"])
  190. ->field('name,value')
  191. ->column('value','name');
  192. View::assign('config',json_encode($list));
  193. $view = [
  194. 'info' => $list,
  195. 'title' => lang('add'),
  196. ];
  197. View::assign($view);
  198. return View::fetch();
  199. }
  200. //系统消息管理
  201. public function sysmsg()
  202. {
  203. if (Request::isPost()){
  204. $name=input("name");
  205. $page=input("page")?:1;
  206. $limit=input("limit")?:10;
  207. $where=[];
  208. $list=Db::name("notice")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
  209. return $item;
  210. })->toArray();
  211. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
  212. }
  213. return View::fetch();
  214. }
  215. // 更新是否显示消息
  216. public function update_nocice_status()
  217. {
  218. $id=input("id");
  219. $status=input("status")?:0;
  220. Notice::update(["status"=>$status],["id"=>$id]);
  221. json_result(200,"操作成功");
  222. }
  223. public function del_msg()
  224. {
  225. $id=input("id");
  226. Notice::where(["id"=>$id])->delete();
  227. json_result(200,"删除成功");
  228. }
  229. // 添加消息
  230. public function addmsg()
  231. {
  232. if (Request::isPost()){
  233. $id=input("id");
  234. $add["name"]=input("name");
  235. $add["text"]=input("text");
  236. if ($id){
  237. Notice::update($add,["id"=>$id]);
  238. }else{
  239. Notice::create($add);
  240. }
  241. json_result(200,"操作成功");
  242. }else{
  243. $id=input("id");
  244. if ($id){
  245. $da=Problem::where(["id"=>$id])->find();
  246. $info["name"]=$da->name;
  247. $info["text"]=$da->text;
  248. $info["id"]=$id;
  249. }else{
  250. $info["name"]="";
  251. $info["text"]="";
  252. $info["id"]=0;
  253. }
  254. $view = [
  255. 'info' => $info,
  256. 'title' => lang('add'),
  257. ];
  258. View::assign($view);
  259. return View::fetch();
  260. }
  261. }
  262. // 开盘设置
  263. public function opens()
  264. {
  265. if (Request::isPost()){
  266. $data = Request::post();
  267. if (isset($data["open"])){
  268. $data["open"]=1;
  269. }else{
  270. $data["open"]="";
  271. }
  272. foreach ($data as $k=>$v){
  273. $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
  274. }
  275. json_result(200,"修改成功",$data);
  276. }
  277. $list = Db::name('system')
  278. ->where(["type"=>"open"])
  279. ->field('name,value')
  280. ->column('value','name');
  281. // var_dump($list["open"]);die();
  282. View::assign('config',json_encode($list));
  283. $view = [
  284. 'info' => $list,
  285. 'title' => lang('add'),
  286. ];
  287. View::assign($view);
  288. return View::fetch();
  289. }
  290. // 后台收款账号
  291. public function adminuser()
  292. {
  293. if (Request::isPost()){
  294. $page=input("page")?:1;
  295. $limit=input("limit")?:10;
  296. $name=input("name");
  297. $where=[];
  298. if ($name){
  299. $where[]=["name","like","%".$name."%"];
  300. }
  301. $where[]=["admin","=",1];
  302. $list=User::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
  303. return $item;
  304. })->toArray();
  305. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
  306. }
  307. return View::fetch();
  308. }
  309. // 修改信息
  310. public function update_user_admin()
  311. {
  312. $id=input("id");
  313. $field=input("field");
  314. $value=input("value");
  315. $where["id"]=$id;
  316. $update[$field]=$value;
  317. User::update($update,$where);
  318. json_result(200,"操作成功");
  319. }
  320. // 收款信息
  321. public function showuser()
  322. {
  323. if (Request::isPost()) {
  324. $data = Request::post();
  325. $adminid=input("user_id");
  326. $where["user_id"]=$adminid;
  327. \app\common\model\UserMessage::update($data,$where);
  328. json_result(200, "修改成功", $data);
  329. }
  330. $adminid=input("user_id");
  331. $where["user_id"]=$adminid;
  332. $code=\app\common\model\UserMessage::where($where)->find();
  333. if (!$code){
  334. \app\common\model\UserMessage::create($where);
  335. $code=\app\common\model\UserMessage::where($where)->find();
  336. }
  337. View::assign("user",$code);
  338. return View::fetch();
  339. }
  340. // 封号
  341. public function fenhao()
  342. {
  343. $id=input("id");
  344. $user=\app\common\model\User::where(["id"=>$id])->field("status")->find();
  345. if ($user->status==1){
  346. $update["status"]=0;
  347. }else{
  348. $update["status"]=1;
  349. }
  350. \app\common\model\User::update($update,["id"=>$id]);
  351. json_result(200,"操作成功");
  352. }
  353. // 密码重置
  354. public function update_pwd()
  355. {
  356. $id=input("id");
  357. $pwd=input("pwd");
  358. $data["pwd"] = password_hash($pwd, PASSWORD_DEFAULT);;
  359. User::update($data,["id"=>$id]);
  360. json_result(200,"重置成功");
  361. }
  362. // 删除账号
  363. public function delete_user()
  364. {
  365. $id=input("id");
  366. User::where(["id"=>$id])->delete();
  367. json_result(200,"删除成功");
  368. }
  369. // 添加后台账号
  370. public function add_admin_user()
  371. {
  372. $name=input("name");
  373. $add["name"]=$name;
  374. $add["admin"]=1;
  375. $add["add_time"]=time();
  376. $add["update_time"]=time();
  377. User::create($add);
  378. json_result(200,"添加成功");
  379. }
  380. // 自动发币管理
  381. public function fb()
  382. {
  383. if (Request::isPost()){
  384. $data = Request::post();
  385. if (isset($data["fbkg"])){
  386. $data["fbkg"]=1;
  387. }else{
  388. $data["fbkg"]="";
  389. }
  390. foreach ($data as $k=>$v){
  391. $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
  392. }
  393. json_result(200,"修改成功",$data);
  394. }
  395. $list = Db::name('system')
  396. ->where(["type"=>"fb"])
  397. ->field('name,value')
  398. ->column('value','name');
  399. // var_dump($list["open"]);die();
  400. View::assign('config',json_encode($list));
  401. $view = [
  402. 'info' => $list,
  403. 'title' => lang('add'),
  404. ];
  405. View::assign($view);
  406. return View::fetch();
  407. }
  408. public function configs()
  409. {
  410. if (Request::isPost()){
  411. $data = Request::post();
  412. foreach ($data as $k=>$v){
  413. $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
  414. }
  415. json_result(200,"修改成功",$data);
  416. }
  417. $list = Db::name('system')
  418. ->where(["type"=>"sys"])
  419. ->field('name,value')
  420. ->column('value','name');
  421. // var_dump($list["open"]);die();
  422. View::assign('config',json_encode($list));
  423. $view = [
  424. 'info' => $list,
  425. 'title' => lang('add'),
  426. ];
  427. View::assign($view);
  428. return View::fetch();
  429. }
  430. // 开盘控制 第二套
  431. public function quotation()
  432. {
  433. if (Request::isPost()){
  434. $page=input("page")?:1;
  435. $limit=input("limit")?:10;
  436. $name=input("name");
  437. $where=[];
  438. $list=Quotation::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
  439. return $item;
  440. })->toArray();
  441. return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
  442. }
  443. return View::fetch();
  444. }
  445. // 更新状态
  446. public function quotation_update()
  447. {
  448. $id=input("id");
  449. $where["id"]=$id;
  450. $quotation=Quotation::where($where)->find();
  451. if ($quotation["status"]==1){
  452. $update["status"]=0;
  453. }else{
  454. $update["status"]=1;
  455. }
  456. Quotation::update($update,$where);
  457. json_result(200,"操作成功");
  458. }
  459. // 更新数据
  460. public function quotation_update_data()
  461. {
  462. $id=input("id");
  463. $field=input("field");
  464. $value=input("value");
  465. $where["id"]=$id;
  466. $update[$field]=$value;
  467. Quotation::update($update,$where);
  468. json_result(200,"修改成功");
  469. }
  470. }