3 changed files with 130 additions and 15 deletions
-
113app/Admin/Actions/Grid/v3/DataReportOption.php
-
26app/Admin/Controllers/v3/GoodsActivityReportController.php
-
6app/Admin/Controllers/v3/OrderReportController.php
@ -0,0 +1,113 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions\Grid\v3; |
||||
|
|
||||
|
use Dcat\Admin\Actions\Response; |
||||
|
use Dcat\Admin\Admin; |
||||
|
use Dcat\Admin\Tree\AbstractTool; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class DataReportOption extends AbstractTool |
||||
|
{ |
||||
|
protected $url; |
||||
|
protected $option; |
||||
|
protected $title = ''; |
||||
|
|
||||
|
public function __construct($option = '', $url = '', $title = '') |
||||
|
{ |
||||
|
$this->option = $option; |
||||
|
$this->url = $url; |
||||
|
$this->title = $title; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Handle the action request. |
||||
|
* |
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(Request $request) |
||||
|
{ |
||||
|
// $date = $this->getDataByOption($this->option);
|
||||
|
// $startTime = $date['start'] ?? '';
|
||||
|
// $endTime = $date['end'] ?? '';
|
||||
|
return $this->response() |
||||
|
->success('查询中~'); |
||||
|
// ->redirect('/'.$this->url.'?start_time='.$startTime.'&end_time='.$endTime);
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected function html() |
||||
|
{ |
||||
|
$date = $this->getDataByOption($this->option); |
||||
|
$startTime = $date['start'] ?? ''; |
||||
|
$endTime = $date['end'] ?? ''; |
||||
|
$url = 'admin/'.$this->url.'?start_time='.$startTime.'&end_time='.$endTime; |
||||
|
$this->defaultHtmlAttribute('href', url($url)); |
||||
|
|
||||
|
return <<<HTML |
||||
|
<a {$this->formatHtmlAttributes()}>{$this->title()}</a> |
||||
|
HTML; |
||||
|
} |
||||
|
|
||||
|
public function getDataByOption($option) |
||||
|
{ |
||||
|
$date = ['start','end']; |
||||
|
$today = date('Y-m-d'); |
||||
|
switch($option){ |
||||
|
case 'today': |
||||
|
$date['start'] = $today; |
||||
|
$date['end'] = $today; |
||||
|
break; |
||||
|
case 'yesterday': |
||||
|
$yesterday = date("Y-m-d",strtotime("-1 days",time())); |
||||
|
$date['start'] = $yesterday; |
||||
|
$date['end'] = $yesterday; |
||||
|
break; |
||||
|
case 'this_week': |
||||
|
$first=1; |
||||
|
//获取当前周的第几天 周日是 0 周一到周六是 1 - 6
|
||||
|
$w=date('w',strtotime($today)); |
||||
|
//获取本周开始日期,如果$w是0,则表示周日,减去 6 天
|
||||
|
$week_start=date('Y-m-d',strtotime("$today -".($w ? $w - $first : 6).' days')); |
||||
|
//本周结束日期
|
||||
|
$week_end=date('Y-m-d',strtotime("$week_start +6 days")); |
||||
|
$date['start'] = $week_start; |
||||
|
$date['end'] = $week_end; |
||||
|
break; |
||||
|
case 'last_week': |
||||
|
// 上周日
|
||||
|
$lastSunday = date('Y-m-d', strtotime('-1 sunday', time())); |
||||
|
// 上周一
|
||||
|
$lastMonday = date('Y-m-d', strtotime('-1 monday', strtotime($lastSunday))); |
||||
|
|
||||
|
$date['start'] = $lastMonday; |
||||
|
$date['end'] = $lastSunday; |
||||
|
break; |
||||
|
case 'this_month': |
||||
|
$thisMonthStart = date('Y-m-01', strtotime($today)); |
||||
|
$thisMonthEnd = date('Y-m-d', strtotime($today)); |
||||
|
|
||||
|
$date['start'] = $thisMonthStart; |
||||
|
$date['end'] = $thisMonthEnd; |
||||
|
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); |
||||
|
|
||||
|
$date['start'] = $lastMonthStart; |
||||
|
$date['end'] = $lastMonthEnd; |
||||
|
break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
return $date; |
||||
|
} |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue