123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\admin\controller;
- use think\Db;
- use think\Exception;
- class WxCash extends Auth
- {
- public function index(){
- if(request()->isAjax()){
- //分页参数
- $length = input('rows',10,'intval'); //每页条数
- $page = input('page',1,'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- //排序
- $sortRow = input('sidx','sort','trim'); //排序列
- $sort = input('sord','asc','trim'); //排序方式
- $order = $sortRow.' '.$sort.' ,id desc';
- $order_sn = input('order_sn','','trim');
- if($order_sn){
- $map[] = ['sn','=',$order_sn];
- }
- $name = input('name','','trim');
- if($name){
- $map1[] = ['nickname','like','%'.$name.'%'];
- $u = Db::name('wxuser')
- ->where($map1)
- ->where('type',1)
- ->column('id');
- if(empty($u)){
- $map[] = ['id','=',-1];
- }else{
- $map[] = ['user_id','in',$u];
- }
- }
- $b = input('begin','','trim');
- $e = input('end','','trim');
- if($b){
- $b = date('Y-m-d 00:00:00',strtotime($b));
- $map[] = ['create_time','>=',$b];
- }
- if($e){
- $e = date('Y-m-d 23:59:59',strtotime($e));
- $map[] = ['create_time','<=',$e];
- }
- $map[] = ['org_id','=',cur_org_id()];
- $map[] = ['del','=',0];
- $map = empty($map) ? true: $map;
- //数据查询
- $lists = Db::name('wx_cash')->where($map)
- ->limit($start,$length)
- ->order($order)->select();
- foreach ($lists as $k=>$v){
- $lists[$k]['barrel_name'] = Db::name('wx_barrel')
- ->where('id',$v['barrel_id'])
- ->value('title');
- $lists[$k]['user_name'] = Db::name('wxuser')
- ->where('id',$v['user_id'])
- ->value('phone');
- }
- //数据返回
- $totalCount = Db::name('wx_cash')->where($map)->count();
- $totalPage = ceil($totalCount/$length);
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $lists;
- return json($result);
- }else{
- $status = model('WxCash')->status;
- $this->assign('status',$status);
- $this->assign('meta_title','押金列表');
- return $this->fetch();
- }
- }
- public function details($id){
- if(!$id){
- $this->error('参数错误');
- }
- $ret = Db::name('wx_cash')->where('id',$id)
- ->find();
- $ret['barrel_name'] = Db::name('wx_barrel')
- ->where('id',$ret['barrel_id'])
- ->value('title');
- $ret['user_name'] = Db::name('wxuser')
- ->where('id',$ret['user_id'])
- ->value('phone');
- $ret['del_user_name'] = Db::name('user')
- ->where('id',$ret['user_id'])
- ->value('real_name');
- $this->assign('info',$ret);
- $this->assign('meta_title','押金详情');
- return $this->fetch();
- }
- }
|