LiverecordController.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-02-17
  10. // +—————————————————————————————————————————————————————————————————————
  11. /**
  12. * 直播记录
  13. */
  14. namespace app\admin\controller;
  15. use cmf\controller\AdminBaseController;
  16. use think\Db;
  17. class LiverecordController extends AdminbaseController {
  18. public function index(){
  19. $config=getConfigPub();
  20. $data = $this->request->param();
  21. $map=[];
  22. $start_time=isset($data['start_time']) ? $data['start_time']: '';
  23. $end_time=isset($data['end_time']) ? $data['end_time']: '';
  24. if($start_time!=""){
  25. $map[]=['starttime','>=',strtotime($start_time)];
  26. }
  27. if($end_time!=""){
  28. $map[]=['starttime','<=',strtotime($end_time) + 60*60*24];
  29. }
  30. $uid=isset($data['uid']) ? $data['uid']: '';
  31. if($uid!=''){
  32. $lianguid=getLianguser($uid);
  33. if($lianguid){
  34. $map[]=['uid',['=',$uid],['in',$lianguid],'or'];
  35. }else{
  36. $map[]=['uid','=',$uid];
  37. }
  38. }
  39. $lists = Db::name("live_record")
  40. ->where($map)
  41. ->order("id DESC")
  42. ->paginate(20);
  43. $lists->each(function($v,$k){
  44. $v['userinfo']=getUserInfo($v['uid']);
  45. return $v;
  46. });
  47. $lists->appends($data);
  48. $page = $lists->render();
  49. $this->assign('lists', $lists);
  50. $this->assign("page", $page);
  51. $this->assign("config", $config);
  52. return $this->fetch();
  53. }
  54. public function del()
  55. {
  56. $id = $this->request->param('id', 0, 'intval');
  57. $rs = DB::name('live_record')->where("id={$id}")->delete();
  58. if(!$rs){
  59. $this->error("删除失败!");
  60. }
  61. $this->success("删除成功!",url("liverecord/index"));
  62. }
  63. }