|
|
|
@ -4,17 +4,15 @@ |
|
|
|
namespace App\Admin\Controllers\v3; |
|
|
|
|
|
|
|
|
|
|
|
use App\Admin\Actions\Lazy\CsInfo; |
|
|
|
use App\Admin\Actions\Tools\SalesmanOption; |
|
|
|
use App\Admin\Actions\Tools\SalesmanOptionCopy; |
|
|
|
use App\Http\Controllers\TestController; |
|
|
|
use App\Models\LanzuMarket; |
|
|
|
use App\Admin\Common\Order; |
|
|
|
use App\Models\LanzuUserRelationBind; |
|
|
|
use App\Models\v3\LanzuEmployees; |
|
|
|
use App\Models\v3\SalesmanData; |
|
|
|
use Dcat\Admin\Admin; |
|
|
|
use Dcat\Admin\Controllers\AdminController; |
|
|
|
use Dcat\Admin\Grid; |
|
|
|
use Dcat\Admin\Widgets\Modal; |
|
|
|
use Maatwebsite\Excel\Facades\Excel; |
|
|
|
|
|
|
|
class Salesman extends AdminController |
|
|
|
@ -42,54 +40,56 @@ class Salesman extends AdminController |
|
|
|
}); |
|
|
|
} else { |
|
|
|
$adu = Admin::user(); |
|
|
|
return Grid::make(new \App\Admin\Repositories\v3\Salesman(), function (Grid $grid)use ($adu) { |
|
|
|
return Grid::make(new \App\Admin\Repositories\v3\Salesman(), function (Grid $grid) use ($adu) { |
|
|
|
$grid->tools(new SalesmanOption()); |
|
|
|
$name = request()->get('name') ?(request()->get('name')=='全部'?'总':request()->get('name')): ''; |
|
|
|
$name = request()->get('name') ? (request()->get('name') == '全部' ? '总' : request()->get('name')) : ''; |
|
|
|
$option = request()->get('option') ?? 0; |
|
|
|
list($beginTime,$endTime) = Order::beginAndEnd($option); |
|
|
|
$searchTime = request()->input('created_at');//搜索时间
|
|
|
|
if ($searchTime){ |
|
|
|
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{ |
|
|
|
} else { |
|
|
|
$content = "<a href='salesman_export?option={$option}&name={$name}' class='btn btn-primary feather icon-download'> 导出 </a>"; |
|
|
|
} |
|
|
|
$grid->tools($content); |
|
|
|
$grid->paginate(10); |
|
|
|
$grid->column('person_id', '懒ID'); |
|
|
|
$grid->column('nick_name', '拓展员')->display(function (){ |
|
|
|
$row = LanzuEmployees::where('user_id',$this->person_id)->where('status',1)->first(); |
|
|
|
if ($row){ |
|
|
|
$grid->column('nick_name', '拓展员')->display(function () { |
|
|
|
$row = LanzuEmployees::where('user_id', $this->person_id)->where('status', 1)->first(); |
|
|
|
if ($row) { |
|
|
|
return $row->name; |
|
|
|
} |
|
|
|
return $this->nick_name; |
|
|
|
}); |
|
|
|
$grid->column('total', '社区总数'); |
|
|
|
$grid->column('user_id', '绑定用户数')->display(function ($uid) { |
|
|
|
$grid->column('user_id', $name.'绑定用户数')->display(function ($uid) use ($beginTime,$endTime) { |
|
|
|
if ($uid) { |
|
|
|
return count(explode(',', $uid)); |
|
|
|
$count = LanzuUserRelationBind::whereIn('user_id',explode(',', $uid))->whereBetween('created_at',[$beginTime,$endTime])->count(); |
|
|
|
return $count; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
}); |
|
|
|
//$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,$searchTime) { |
|
|
|
$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,$searchTime, '详情')); |
|
|
|
$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)use ($option,$adu) { |
|
|
|
if (!$adu->isRole('lanzu_cs')){ |
|
|
|
$filter->equal('person_id','懒ID'); |
|
|
|
$filter->equal('user_id','拓展员')->select( |
|
|
|
LanzuEmployees::where('status',1)->pluck('name','user_id') |
|
|
|
$grid->filter(function (Grid\Filter $filter) use ($option, $adu) { |
|
|
|
if (!$adu->isRole('lanzu_cs')) { |
|
|
|
$filter->equal('person_id', '懒ID'); |
|
|
|
$filter->equal('user_id', '拓展员')->select( |
|
|
|
LanzuEmployees::where('status', 1)->pluck('name', 'user_id') |
|
|
|
); |
|
|
|
} |
|
|
|
if ($option==0){ |
|
|
|
$filter->between('created_at','日期')->datetime(); |
|
|
|
if ($option == 0) { |
|
|
|
$filter->between('created_at', '日期')->datetime(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -104,8 +104,8 @@ class Salesman extends AdminController |
|
|
|
{ |
|
|
|
$name = request()->get('name'); |
|
|
|
$option = request()->get('option'); |
|
|
|
$time = date('Y-m-d H:i:s',time()); |
|
|
|
return Excel::download(new \App\Admin\Actions\Excel\SalesMan($option,$name), $time.'.xlsx'); |
|
|
|
$time = date('Y-m-d H:i:s', time()); |
|
|
|
return Excel::download(new \App\Admin\Actions\Excel\SalesMan($option, $name), $time . '.xlsx'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|