You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.7 KiB
156 lines
5.7 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers\v3;
|
|
|
|
use App\Admin\Actions\Grid\v3\DataReportOption;
|
|
use App\Admin\Actions\Tools\ReportCommunityExport;
|
|
use App\Admin\Common\Auth;
|
|
use App\Admin\Repositories\v3\ReportCommunity;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Controllers\AdminController;
|
|
use Dcat\Admin\Grid\Filter;
|
|
use Illuminate\Http\Request;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use App\Models\v3\Market as MarketModel;
|
|
use App\Models\ImsCjdcUser as UserModel;
|
|
use App\Models\v3\LanzuEmployees as EmployeesModel;
|
|
use Dcat\Admin\Layout\Content;
|
|
use Dcat\Admin\Layout\Row;
|
|
use Dcat\Admin\Widgets\Alert;
|
|
|
|
class ReportCommunityController extends AdminController
|
|
{
|
|
/**
|
|
* 社区代理点统计
|
|
*/
|
|
protected $GoodsActivityReport = null;
|
|
public $marketId = 0;
|
|
public $newParams = ['status' => 1];
|
|
public $marketList = [];
|
|
public $storeList = [];
|
|
protected $reportDate = '';
|
|
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$this->marketId = Auth::getMarket();
|
|
|
|
if($this->marketId){
|
|
$this->newParams['market_id'] = $this->marketId;
|
|
$builder = new ReportCommunity($this->newParams);
|
|
$this->marketList = MarketModel::getMarketArray([['id','=',$this->marketId]]);
|
|
}else{
|
|
$builder = new ReportCommunity($this->newParams);
|
|
$this->marketList = MarketModel::getMarketArray();
|
|
}
|
|
|
|
return Grid::make($builder, function (Grid $grid) {
|
|
$marketList = $this->marketList;
|
|
|
|
$grid->column('market_id','市场')->display(function($marketId) use($marketList){
|
|
return $marketList[$marketId] ?? '';
|
|
});
|
|
$grid->column('user_id','懒ID');
|
|
|
|
$grid->column('avatar','微信头像')->display(function(){
|
|
$userId = $this->user_id ?? 0;
|
|
$item = UserModel::select('avatar')->find($userId);
|
|
return $item['avatar'] ?? '';
|
|
})->image('',50);
|
|
$grid->column('name','姓名');
|
|
|
|
$grid->column('new_cs_count','新拓展代理点数');
|
|
|
|
$grid->column('new_bind_user_count','新增绑定用户数');
|
|
|
|
$grid->column('plat_new_user_count','平台新增用户数');
|
|
$grid->column('bound_order_online_count','绑定用户线上订单总数');
|
|
$grid->column('plat_new_user_order_online_count','平台新增用户线上订单数');
|
|
|
|
$grid->filter(function (Filter $filter) use($marketList) {
|
|
// 更改为 panel 布局
|
|
$filter->panel();
|
|
$filter->where('start_time',function(){
|
|
$this->newParams['start_time'] = $this->input['start_time'];
|
|
},'开始时间',)->date()->width(2);
|
|
$filter->equal('end_time','结束时间')->date()->width(2);
|
|
|
|
$filter->equal('user_id','懒ID')->width(2);
|
|
$filter->equal('name','姓名')->width(2);
|
|
if(!$this->marketId){
|
|
$filter->equal('market_id','市场')->select($marketList)->width(2);
|
|
}
|
|
$filter->equal('status','状态')->select(EmployeesModel::$_STATUS)->width(2);
|
|
});
|
|
|
|
$grid->tools([
|
|
new DataReportOption('today','report_community','今日', $this->newParams),
|
|
new DataReportOption('yesterday','report_community','昨日', $this->newParams),
|
|
new DataReportOption('this_week','report_community','本周', $this->newParams),
|
|
new DataReportOption('last_week','report_community','上周', $this->newParams),
|
|
new DataReportOption('this_month','report_community','本月', $this->newParams),
|
|
new DataReportOption('last_month','report_community','上月', $this->newParams),
|
|
new ReportCommunityExport()
|
|
]);
|
|
|
|
// 每页1条
|
|
$grid->paginate(10);
|
|
$grid->disableCreateButton();
|
|
$grid->disableBatchActions();
|
|
$grid->disableBatchDelete();
|
|
|
|
$grid->toolsWithOutline();
|
|
|
|
$grid->disableDeleteButton();
|
|
$grid->disableEditButton();
|
|
$grid->disableQuickEditButton();
|
|
$grid->disableViewButton();
|
|
$grid->disableActions();
|
|
|
|
$grid->disableRowSelector();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 页面
|
|
*/
|
|
public function index(Content $content)
|
|
{
|
|
$startTime = request()->get('start_time');
|
|
$endTime = request()->get('end_time');
|
|
if(empty($startTime) && empty($endTime)){
|
|
$content->row(Alert::make('请先选择时间查询!','')->removable());
|
|
}
|
|
|
|
return $content->title('社区代理点统计报表')
|
|
->body(function(Row $row){
|
|
$row->column(12,$this->grid());
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 数据导出
|
|
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
|
*/
|
|
public function export(Request $request)
|
|
{
|
|
$this->marketId = Auth::getMarket();
|
|
$params = [
|
|
'status' => $request->input('status',null),
|
|
'name' => $request->input('name',false),
|
|
'market_id' => $this->marketId ? $this->marketId : $request->input('market_id',null),
|
|
'user_id' => $request->input('user_id',null),
|
|
'start_time' => $request->input('start_time',null),
|
|
'end_time' => $request->input('end_time',null),
|
|
];
|
|
|
|
$name = date('Y-m-d-His',time());
|
|
$data = new \App\Admin\Actions\Exporter\ReportCommunity($params);
|
|
|
|
return Excel::download($data, $name.'.xlsx');
|
|
}
|
|
}
|