diff --git a/app/Admin/Actions/Tools/SalesmanOption.php b/app/Admin/Actions/Tools/SalesmanOption.php index 3b18325..90f5c5d 100644 --- a/app/Admin/Actions/Tools/SalesmanOption.php +++ b/app/Admin/Actions/Tools/SalesmanOption.php @@ -24,19 +24,25 @@ JS; public function render() { $options = [ + 'all'=>'全部', 'today' => '今日', 'yesterday' => '昨日', 'week' => '本周', + 'last_week' => '上周', 'month' => '本月', 'last_month' => '上月', + ]; $data = [ + 'all'=>'0', 'today' => '1', 'yesterday' => '-1', 'week' => 'w', + 'last_week' => 'lw', 'month' => '30', 'last_month' => '-30', + ]; foreach ($data as $key=>$value){ diff --git a/app/Admin/Common/Order.php b/app/Admin/Common/Order.php index 918f76c..1b58914 100644 --- a/app/Admin/Common/Order.php +++ b/app/Admin/Common/Order.php @@ -111,8 +111,14 @@ class Order $endTime = strtotime(date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), 0, date("Y")))); break; default: - $beginTime = mktime(0, 0, 0, date('m'), date('d'), date('Y')); - $endTime = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1; + $searchTime = request()->input('created_at'); + if ($searchTime){ + $beginTime = strtotime($searchTime['start']); + $endTime = strtotime($searchTime['end']); + }else{ + $beginTime = 0; + $endTime = 999999999999; + } break; } return [$beginTime,$endTime]; diff --git a/app/Admin/Controllers/v3/Salesman.php b/app/Admin/Controllers/v3/Salesman.php index 37b5baa..91569ee 100644 --- a/app/Admin/Controllers/v3/Salesman.php +++ b/app/Admin/Controllers/v3/Salesman.php @@ -41,11 +41,16 @@ class Salesman extends AdminController } else { return Grid::make(new \App\Admin\Repositories\v3\Salesman(), function (Grid $grid) { $grid->tools(new SalesmanOption()); - $name = request()->get('name') ?? '今日'; - $option = request()->get('option') ?? 1; + $name = request()->get('name') ?(request()->get('name')=='全部'?'总':request()->get('name')): ''; + $option = request()->get('option') ?? 0; + $searchTime = request()->input('created_at');//搜索时间 + if ($searchTime){ + $content = " 导出 "; + }else{ + $content = " 导出 "; + } $grid->paginate(10); - $grid->tools(" 导出 "); - $grid->export(); + $grid->tools($content); $grid->column('person_id', '懒ID'); $grid->column('nick_name', '拓展员'); $grid->column('total', '社区总数'); @@ -58,28 +63,35 @@ class Salesman extends AdminController //$grid->column('order_user_num', $name.'下单人数'); $grid->column('order_num', $name . '订单数'); $grid->column('order_amount', $name . '成交额'); - $grid->actions(function (Grid\Displayers\Actions $actions) use ($name, $option) { + $grid->actions(function (Grid\Displayers\Actions $actions) use ($name, $option,$searchTime) { $row = $actions->row->toArray(); - $actions->append(new \App\Admin\Extensions\Salesman($row['admin_user_id'], $name, $option, '详情')); + $actions->append(new \App\Admin\Extensions\Salesman($row['admin_user_id'], $name, $option,$searchTime, '详情')); }); $grid->disableCreateButton(); $grid->disableEditButton(); $grid->disableDeleteButton(); $grid->disableViewButton(); - $grid->filter(function (Grid\Filter $filter) { + $grid->filter(function (Grid\Filter $filter)use ($option) { $filter->equal('person_id', '拓展员懒ID'); + if ($option==0){ + $filter->between('created_at','日期')->datetime(); + } }); }); } - } + /** + * 数据导出 + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + */ public function export() { $name = request()->get('name'); $option = request()->get('option'); - return Excel::download(new \App\Admin\Actions\Exporter\SalesMan($option,$name), $name.'拓展员报表.xlsx'); + $time = date('Y-m-d H:i:s',time()); + return Excel::download(new \App\Admin\Actions\Exporter\SalesMan($option,$name), $time.'.xlsx'); } diff --git a/app/Admin/Extensions/Salesman.php b/app/Admin/Extensions/Salesman.php index 800d0f6..9348d0b 100644 --- a/app/Admin/Extensions/Salesman.php +++ b/app/Admin/Extensions/Salesman.php @@ -15,12 +15,14 @@ class Salesman extends RowAction protected $adminUid; protected $name; protected $option; - public function __construct($adminUid,$name,$option,$title=null) + protected $searchTime; + public function __construct($adminUid,$name,$option,$searchTime,$title=null) { $this->title = $title; $this->name = $name; $this->option = $option; $this->adminUid = $adminUid; + $this->searchTime = $searchTime; parent::__construct($title); @@ -29,7 +31,7 @@ class Salesman extends RowAction public function render() { // 实例化表单类并传递自定义参数 - $table = CsInfo::make(['admin_user_id'=>$this->adminUid,'name'=>$this->name,'option'=>$this->option]); + $table = CsInfo::make(['admin_user_id'=>$this->adminUid,'name'=>$this->name,'option'=>$this->option,'created_at'=>$this->searchTime]); return Modal::make() ->lg() ->title('数据明细') diff --git a/resources/views/admin/tools/salesman.blade.php b/resources/views/admin/tools/salesman.blade.php index b2a76f6..3fac8eb 100644 --- a/resources/views/admin/tools/salesman.blade.php +++ b/resources/views/admin/tools/salesman.blade.php @@ -1,6 +1,6 @@