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[] = ['order_sn','=',$order_sn]; } $name = input('name','','trim'); if($name){ $map[] = ['name','like','%'.$name.'%']; } $status = input('status','','trim'); if($status != ''){ $map[] = ['status','=',$status]; } // if($this->user_id > 1){ // $map[] = ['user_id','=',$this->user_id]; // } $map[] = ['org_id','=',cur_org_id()]; $map= empty($map) ? true: $map; //数据查询 $lists = Db::name('g_orders')->where($map)->limit($start,$length)->order($order)->select(); //数据返回 $totalCount = Db::name('g_orders')->where($map)->count(); $totalPage = ceil($totalCount/$length); $result['page'] = $page; $result['total'] = $totalPage; $result['records'] = $totalCount; $result['rows'] = $lists; return json($result); }else{ $this->assign('meta_title','订单列表'); return $this->fetch(); } } public function details($id){ if(!$id){ $this->error('参数错误'); } $ret = Db::name('g_orders')->where('id',$id)->find(); $ret['goods'] = $orderGoods = Db::name('g_order_goods') ->alias('og') ->field('og.nums,og.price,og.goods_id,g.title,g.img') ->join('g_goods g', 'g.id=og.goods_id') ->where('og.order_id', $ret['id']) ->select(); if($ret['status']==1 && time() < (strtotime($ret['create_time'])+(7*24*3600))){ $ret['tk'] = 1; }else{ $ret['tk'] = 0; } $this->assign('info',$ret); $this->assign('meta_title','订单详情'); return $this->fetch(); } /** * 退款 */ public function refund($id = 0){ if(request()->isPost()){ $res = model('GOrders')->refundOrder($this->userId); if($res){ $this->success('操作成功',url('index')); }else{ $this->error(model('GOrders')->getError()); } }else{ $pay = Db::name('g_orders')->where('id',$id)->find(); $money = $pay['amount']; $this->assign('money',$money); $this->assign('pay',$pay); $this->assign('id',$id); return $this->fetch(); } } }