model = new \app\api\model\app\agent\Order(); } /** * 获取统计数据 * @return void */ public function getTotal(){ $type = $this->request->post('type',''); $data = $this->model->getTotal($this->auth->id,$type); $this->success("获取成功",$data); } /** * 获取订单列表 * @return void */ public function getOrderList(){ $limit = input('limit',10); $page = input('page',1); $type = input('type',''); $status = input('status',0); $uid = input('uid',''); $where = [ 'beneficiary_user_id'=>$this->auth->id ]; if($uid){ $time = input('time',time()); $startOfMonth = strtotime(date('Y-m-01',$time)); // 获取当前月份的第一天的时间戳 $endOfMonth = strtotime(date('Y-m-t 23:59:59',$time)); // 获取当前月份的最后一天的时间戳 $where['order.createtime'] = ['BETWEEN',[$startOfMonth, $endOfMonth]]; $where['order_user_id'] = $uid; } if($type){ $where['order.type'] = $type; } $status--; if($status >= 0){ $where['order.status'] = $status; } $list = $this->model ->with(['item','user']) ->where($where) ->limit($limit) ->page($page) ->order('createtime','desc') ->select(); if(!empty($list)){ foreach ($list as &$item){ $item->user->visible(['nickname','avatar','id']); $item->item->visible(['item_name','item_id','total_price','count','real_price']); $item->item->total_price = $item->item->real_price; $item->is_channels = false; if(\app\admin\library\project\App::isInstall('channels')){ $item->is_channels = (new \app\admin\model\app\channels\Order)->checkIsChannelsOrder($item->order_no); } } } $this->success('获取成功', $list); } }