model = model('OrdersCollect'); } public function index() { //今天 $today = date('Ymd', time()); //昨天 $yesterday = date('Ymd', strtotime('-1 days')); //本月 $month = date('Ym', time()).'01'; $business_line = $this->request->param('business_line'); if (!$business_line) { $business_line = PayConstants::BUSINESS_WECHAT; } if (!$this->request->isAjax()) { $todayData = $this->model->where(['type'=>'1','flag'=>'2','admin_id'=>0,'createdate'=>$today,'business_line'=> $business_line])->find(); //今天的数据 $yesterdayData = $this->model->where(['type'=>'1','flag'=>'2','admin_id'=>0,'createdate'=>$yesterday,'business_line'=> $business_line])->find(); //昨天的数据 // $monthData = $this->model->where(['type'=>'2','flag'=>'2','admin_id'=>0,'createdate'=>$month])->find(); //当月的数据 $monthData = $this->model->sumCollect(0, 1, 2, $month, $yesterday, $business_line); //当月的数据 // $allData = $this->model->where(['type'=>'3','flag'=>'2','admin_id'=>0,])->find(); //汇总的数据 $allData = $this->model->sumCollect(0, 1, 2, null, null, $business_line); //汇总的数据 if (is_null($todayData)) { $todayData = []; } if (is_null($yesterdayData)) { $yesterdayData = []; } $this->assign('today',$todayData); $this->assign('yesterday',$yesterdayData); $this->assign('month',$monthData); $this->assign('all',$allData); } else { $beginDate = date('Ymd', strtotime('-31 days')); $endDate = date('Ymd', strtotime('-1 days')); list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $condition = []; $condition['type'] = 1; $condition['business_line'] = $business_line; $condition['admin_id'] = 0; $condition['flag'] = 2; $total = $this->model ->where($where) ->where('createdate', '>=', $beginDate) ->where('createdate', '<=', $endDate) ->where($condition) ->order($sort, $order) ->count(); $list = $this->model ->where($where) ->where('createdate', '>=', $beginDate) ->where('createdate', '<=', $endDate) ->where($condition) ->order($sort, $order) ->limit($offset, $limit) ->select(); $result = array("total" => $total, "rows" => $list); return json($result); } return $this->view->fetch(); } }