model()->where('shop_agent_id','>',0) ->selectRaw('shop_agent_id,count(*) as shop_num,sum(amount) as amount_num,sum(agent_amount) as agent_amount_num,sum(use_amount) as use_amount_num') ->groupBy('shop_agent_id') ->orderBy('agent_amount_num', 'desc'); $grid->column('shop_agent_name','代理人')->display(function(){ return ShopAgent::where('agent_id',$this->shop_agent_id)->value('agent_name'); }); $grid->column('shop_num','店铺数'); $grid->column('amount_num','流水'); $grid->column('use_amount_num','平台服务费')->help('当前平台服务费的抽成点是4‰'); $grid->column('agent_amount_num','提成金额')->help("当前一级代理的提成点是".ShopAgentBill::SHOP_AGENT_RATE_ONE.",二级代理的提成点是".ShopAgentBill::SHOP_AGENT_RATE_TWO.",一级代理对手下二级代理业绩的提成点是".ShopAgentBill::SHOP_AGENT_RATE_SUPPER); $grid->fixColumns(-2); $grid->filter(function($filter){ $filter->panel(); $filter->between('cdate', '日期')->date(); $filter->equal('shop_agent_id','代理人')->select(ShopAgent::pluck('agent_name','agent_id')); }); //导出 // $grid->export()->rows(function ($rows) { // foreach ($rows as $k => &$row) { // $row['shop_agent_name'] = ShopAgent::where('agent_id',$rows->shop_agent_id)->value('agent_name'); // } // return $rows; // }); $grid->disableViewButton(); $grid->disableEditButton(); $grid->disableCreateButton(); $grid->disableDeleteButton(); $grid->scrollbarX();//数据展开 $grid->disableActions(); $grid->disableRowSelector(); }); } }