12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- /**
- * 对账角色用于对账的订单统计
- */
- namespace app\admin\controller;
- use app\admin\service\LogService;
- use app\common\controller\Backend;
- use app\common\model\OrdersCollect;
- use app\main\constants\AdminConstants;
- use app\main\constants\ApiConstants;
- use app\main\constants\PayConstants;
- use app\main\helper\ArrayHelper;
- use app\main\service\ApiService;
- use think\Db;
- /**
- * 数据统计-订单汇总
- *
- * @icon fa fa-circle-o
- */
- class Collectstatement extends Backend
- {
- /**
- * @var OrdersCollect
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->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();
- }
- }
|