Browse Source

拓展员数据导出

master
lanzu_qinsheng 5 years ago
parent
commit
14669d739a
  1. 6
      app/Admin/Actions/Tools/SalesmanOption.php
  2. 10
      app/Admin/Common/Order.php
  3. 30
      app/Admin/Controllers/v3/Salesman.php
  4. 6
      app/Admin/Extensions/Salesman.php
  5. 2
      resources/views/admin/tools/salesman.blade.php
  6. BIN
      storage/framework/laravel-excel/laravel-excel-BbbC7pM3HCd1weeA0V4UN0GAxiCvQVqf.xlsx
  7. BIN
      storage/framework/laravel-excel/laravel-excel-GSR0lr0ehU4HeX4rS6APlCzXL4AhYdkO.xlsx
  8. BIN
      storage/framework/laravel-excel/laravel-excel-WpYNLsEP4D5qzoG7PWZVQJXa2S4noJOW.xlsx

6
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){

10
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];

30
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 = "<a href='salesman_export?option={$option}&name={$name}&created_at[start]={$searchTime['start']}&created_at[end]={$searchTime['end']}' class='btn btn-primary feather icon-download'> 导出 </a>";
}else{
$content = "<a href='salesman_export?option={$option}&name={$name}' class='btn btn-primary feather icon-download'> 导出 </a>";
}
$grid->paginate(10);
$grid->tools("<a href='salesman_export?option={$option}&name={$name}' class='btn btn-primary feather icon-download'> 导出 </a>");
$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');
}

6
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('数据明细')

2
resources/views/admin/tools/salesman.blade.php

@ -1,6 +1,6 @@
<div class="btn-group btn-group-toggle" data-toggle="buttons">
@foreach($options as $option => $label)
<label class="btn btn-primary {{request()->get('type','today')==$option? 'active':''}}">
<label class="btn btn-primary {{request()->get('type','all')==$option? 'active':''}}">
<input type="radio" name="options" id="{{$option}}"> {{$label}}
</label>
@endforeach

BIN
storage/framework/laravel-excel/laravel-excel-BbbC7pM3HCd1weeA0V4UN0GAxiCvQVqf.xlsx

BIN
storage/framework/laravel-excel/laravel-excel-GSR0lr0ehU4HeX4rS6APlCzXL4AhYdkO.xlsx

BIN
storage/framework/laravel-excel/laravel-excel-WpYNLsEP4D5qzoG7PWZVQJXa2S4noJOW.xlsx

Loading…
Cancel
Save