WxCash.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. use think\Exception;
  5. class WxCash extends Auth
  6. {
  7. public function index(){
  8. if(request()->isAjax()){
  9. //分页参数
  10. $length = input('rows',10,'intval'); //每页条数
  11. $page = input('page',1,'intval'); //第几页
  12. $start = ($page - 1) * $length; //分页开始位置
  13. //排序
  14. $sortRow = input('sidx','sort','trim'); //排序列
  15. $sort = input('sord','asc','trim'); //排序方式
  16. $order = $sortRow.' '.$sort.' ,id desc';
  17. $order_sn = input('order_sn','','trim');
  18. if($order_sn){
  19. $map[] = ['sn','=',$order_sn];
  20. }
  21. $name = input('name','','trim');
  22. if($name){
  23. $map1[] = ['nickname','like','%'.$name.'%'];
  24. $u = Db::name('wxuser')
  25. ->where($map1)
  26. ->where('type',1)
  27. ->column('id');
  28. if(empty($u)){
  29. $map[] = ['id','=',-1];
  30. }else{
  31. $map[] = ['user_id','in',$u];
  32. }
  33. }
  34. $b = input('begin','','trim');
  35. $e = input('end','','trim');
  36. if($b){
  37. $b = date('Y-m-d 00:00:00',strtotime($b));
  38. $map[] = ['create_time','>=',$b];
  39. }
  40. if($e){
  41. $e = date('Y-m-d 23:59:59',strtotime($e));
  42. $map[] = ['create_time','<=',$e];
  43. }
  44. $map[] = ['org_id','=',cur_org_id()];
  45. $map[] = ['del','=',0];
  46. $map = empty($map) ? true: $map;
  47. //数据查询
  48. $lists = Db::name('wx_cash')->where($map)
  49. ->limit($start,$length)
  50. ->order($order)->select();
  51. foreach ($lists as $k=>$v){
  52. $lists[$k]['barrel_name'] = Db::name('wx_barrel')
  53. ->where('id',$v['barrel_id'])
  54. ->value('title');
  55. $lists[$k]['user_name'] = Db::name('wxuser')
  56. ->where('id',$v['user_id'])
  57. ->value('phone');
  58. }
  59. //数据返回
  60. $totalCount = Db::name('wx_cash')->where($map)->count();
  61. $totalPage = ceil($totalCount/$length);
  62. $result['page'] = $page;
  63. $result['total'] = $totalPage;
  64. $result['records'] = $totalCount;
  65. $result['rows'] = $lists;
  66. return json($result);
  67. }else{
  68. $status = model('WxCash')->status;
  69. $this->assign('status',$status);
  70. $this->assign('meta_title','押金列表');
  71. return $this->fetch();
  72. }
  73. }
  74. public function details($id){
  75. if(!$id){
  76. $this->error('参数错误');
  77. }
  78. $ret = Db::name('wx_cash')->where('id',$id)
  79. ->find();
  80. $ret['barrel_name'] = Db::name('wx_barrel')
  81. ->where('id',$ret['barrel_id'])
  82. ->value('title');
  83. $ret['user_name'] = Db::name('wxuser')
  84. ->where('id',$ret['user_id'])
  85. ->value('phone');
  86. $ret['del_user_name'] = Db::name('user')
  87. ->where('id',$ret['user_id'])
  88. ->value('real_name');
  89. $this->assign('info',$ret);
  90. $this->assign('meta_title','押金详情');
  91. return $this->fetch();
  92. }
  93. }