diff --git a/app/Admin/Actions/Grid/v3/GoodsActivitySetting.php b/app/Admin/Actions/Grid/v3/GoodsActivitySetting.php index 068b7af..dcc437f 100644 --- a/app/Admin/Actions/Grid/v3/GoodsActivitySetting.php +++ b/app/Admin/Actions/Grid/v3/GoodsActivitySetting.php @@ -36,7 +36,7 @@ class GoodsActivitySetting extends AbstractTool */ // public function href() // { - // return admin_url('category/tie'); + // return admin_url('/'); // } /** diff --git a/app/Admin/Actions/Grid/v3/OrderReportLastMonth.php b/app/Admin/Actions/Grid/v3/OrderReportLastMonth.php new file mode 100644 index 0000000..1ff2557 --- /dev/null +++ b/app/Admin/Actions/Grid/v3/OrderReportLastMonth.php @@ -0,0 +1,78 @@ +response() + ->success('查询中~') + ->redirect('/order_report?start_time='.$lastMonthStart.'&end_time='.$lastMonthEnd); + } + + /** + * @return string|void + */ + // public function href() + // { + // return admin_url('/'); + // } + + /** + * @return string|array|void + */ + public function confirm() + { + // return ['Confirm?', 'contents']; + } + +// protected function actionScript() +// { + +// return <<response() + ->success('查询中~') + ->redirect('/order_report?start_time='.$lastMonday.'&end_time='.$lastSunday); + } + + /** + * @return string|void + */ + // public function href() + // { + // return admin_url('/'); + // } + + /** + * @return string|array|void + */ + public function confirm() + { + // return ['Confirm?', 'contents']; + } + +// protected function actionScript() +// { + +// return <<response() + ->success('查询中~') + ->redirect('/order_report?start_time='.$startTime.'&end_time='.$endTime); + } + + /** + * @return string|void + */ + // public function href() + // { + // return admin_url('/'); + // } + + /** + * @return string|array|void + */ + public function confirm() + { + // return ['Confirm?', 'contents']; + } + +// protected function actionScript() +// { + +// return <<response() + ->success('查询中~') + ->redirect('/order_report?start_time='.$startTime.'&end_time='.$endTime); + } + + /** + * @return string|void + */ + // public function href() + // { + // return admin_url('/'); + // } + + /** + * @return string|array|void + */ + public function confirm() + { + // return ['Confirm?', 'contents']; + } + +// protected function actionScript() +// { + +// return <<equal('market_id','市场')->select($marketList); $filter->equal('start_time','开始时间')->date(); $filter->equal('end_time','结束时间')->date(); - - }); - $grid->selector(function (Grid\Tools\Selector $selector) { - $today = date('Y-m-d'); - $selector->selectOne('time', '选择日期', ['today'=>'今天', 'yesterday'=>'昨天', 'last_week'=>'上周','last_month'=>'上月'], function($query, $value) use($today){ - $where = []; - - switch($value){ - case 'today': - $where['start_time'] = $today; - $where['end_time'] = $today; - break; - case 'yesterday': - $yesterday = date("Y-m-d",strtotime("-1 days",strtotime($today))); - $where['start_time'] = $yesterday; - $where['end_time'] = $yesterday; - break; - case 'last_week': - //上周日 - $lastSunday = date('Y-m-d', strtotime('-1 sunday', time())); - // 上周一 - $lastMonday = date('Y-m-d', strtotime('-1 monday', strtotime($lastSunday))); - $where['start_time'] = $lastMonday; - $where['end_time'] = $lastSunday; - break; - case 'last_month': - //上月初 - $lastMonthStart = date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m', time()) . '-01'))); - // 上月底 - $lastMonthEnd = date('Y-m-d', strtotime(date('Y-m', time()) . '-01') - 86400); - $where['start_time'] = $lastMonthStart; - $where['end_time'] = $lastMonthEnd; - break; - } - self::$searchTime = $where; - }); }); + + $grid->tools([new OrderReportToday(), new OrderReportYesterday(), new OrderReportLastWeek(), new OrderReportLastMonth()]); + // 每页1条 $grid->paginate(10); $grid->disableCreateButton(); @@ -105,5 +75,41 @@ class OrderReportController extends AdminController } return array_reverse($arr); + + // $grid->selector(function (Grid\Tools\Selector $selector) { + // $today = date('Y-m-d'); + // $selector->selectOne('time', '选择日期', ['today'=>'今日', 'yesterday'=>'昨日', 'last_week'=>'上周','last_month'=>'上月'], function($query, $value) use($today){ + // $where = []; + + // switch($value){ + // case 'today': + // $where['start_time'] = $today; + // $where['end_time'] = $today; + // break; + // case 'yesterday': + // $yesterday = date("Y-m-d",strtotime("-1 days",strtotime($today))); + // $where['start_time'] = $yesterday; + // $where['end_time'] = $yesterday; + // break; + // case 'last_week': + // //上周日 + // $lastSunday = date('Y-m-d', strtotime('-1 sunday', time())); + // // 上周一 + // $lastMonday = date('Y-m-d', strtotime('-1 monday', strtotime($lastSunday))); + // $where['start_time'] = $lastMonday; + // $where['end_time'] = $lastSunday; + // break; + // case 'last_month': + // //上月初 + // $lastMonthStart = date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m', time()) . '-01'))); + // // 上月底 + // $lastMonthEnd = date('Y-m-d', strtotime(date('Y-m', time()) . '-01') - 86400); + // $where['start_time'] = $lastMonthStart; + // $where['end_time'] = $lastMonthEnd; + // break; + // } + // self::$searchTime = $where; + // }); + // }); } } diff --git a/app/Admin/Repositories/v3/OrderReport.php b/app/Admin/Repositories/v3/OrderReport.php index c18e3b9..91eb627 100644 --- a/app/Admin/Repositories/v3/OrderReport.php +++ b/app/Admin/Repositories/v3/OrderReport.php @@ -33,15 +33,14 @@ class OrderReport extends EloquentRepository { $marketId = request()->input('market_id'); $time = date('Y-m-d',time()); - - $searchTime = OrderReportController::$searchTime; - if(!empty($searchTime)){ - $startTime = $searchTime['start_time']; - $endTime = $searchTime['end_time']; - }else{ - $startTime = request()->input('start_time'); - $endTime = request()->input('end_time'); - } + $startTime = request()->input('start_time'); + $endTime = request()->input('end_time'); + + // $searchTime = OrderReportController::$searchTime; + // if(!empty($searchTime) && !($startTime || $endTime)){ + // $startTime = $searchTime['start_time']; + // $endTime = $searchTime['end_time']; + // } $orderMainOnline = OrderMainModel::select(DB::raw('COUNT(id) AS total_num, SUM(money) AS total_money'))->whereIn('state',[4,5])->where('type',OrderMainModel::ORDER_TYPE_ONLINE); $orderMainOffline = OrderMainModel::select(DB::raw('COUNT(id) AS total_num, SUM(money) AS total_money'))->whereIn('state',[4,5])->where('type',OrderMainModel::ORDER_TYPE_OFFLINE);