140 lines
4.8 KiB
PHP
140 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\DealerEarning;
|
|
use App\Models\DealerChannelSubsidyLog;
|
|
use App\Models\DealerManagerSubsidy;
|
|
use App\Models\DealerManageSubsidy;
|
|
use App\Models\DealerPurchaseSubsidy;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Show;
|
|
|
|
class DealerEarningController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$earning = DealerEarning::with('user');
|
|
return Grid::make($earning, function (Grid $grid) {
|
|
$grid->setResource('dealer-earnings');
|
|
$grid->column('id')->sortable();
|
|
$grid->column('user.phone');
|
|
$grid->column('type_name')->display(function () {
|
|
return $this->type_name;
|
|
})->label()->filter(Grid\Column\Filter\In::make([
|
|
(new DealerManagerSubsidy())->getMorphClass() =>'管理者补贴',
|
|
(new DealerManageSubsidy())->getMorphClass() =>'管理补贴',
|
|
(new DealerChannelSubsidyLog())->getMorphClass() =>'渠道补贴',
|
|
(new DealerPurchaseSubsidy())->getMorphClass() =>'进货补贴',
|
|
])->setColumnName('earningable_type'));
|
|
// $grid->column('earningable_type');
|
|
// $grid->column('earningable_id');
|
|
$grid->column('lvl')->display(function () {
|
|
return $this->lvl_text;
|
|
});
|
|
$grid->column('is_manager')->bool();
|
|
$grid->column('total_amount')->prepend('¥');
|
|
$grid->column('fee_rate')->append('%');
|
|
$grid->column('fee')->prepend('¥');
|
|
$grid->column('total_earnings')->prepend('¥');
|
|
$grid->column('payer_id');
|
|
// $grid->column('pay_info');
|
|
$grid->column('pay_at');
|
|
$grid->column('settle_at');
|
|
$grid->column('status_format')->display(function ($value) {
|
|
return $this->status_format;
|
|
})->using([
|
|
-1=> '待结算',
|
|
0 => '待打款',
|
|
1 => '待收款',
|
|
2 => '已完成',
|
|
])->dot();
|
|
|
|
$grid->column('remark');
|
|
// $grid->column('pay_image');
|
|
$grid->column('created_at')->sortable();
|
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
//如果不是渠道补贴添加详情显示
|
|
if ($actions->row->earningable_type != (new DealerChannelSubsidyLog())->getMorphClass()) {
|
|
$actions->append('<a style="cursor: pointer;" target="_blank" href="'.admin_route('dealer_earnings.show', ['dealer_earning'=>$actions->row]).'"><i class="feather icon-eye"></i> 显示 </a>');
|
|
}
|
|
});
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
$filter->equal('user.phone')->width(3);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new DealerEarning(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('user_id');
|
|
$show->field('earningable_type');
|
|
$show->field('earningable_id');
|
|
$show->field('lvl');
|
|
$show->field('is_manager');
|
|
$show->field('total_amount');
|
|
$show->field('total_earnings');
|
|
$show->field('fee');
|
|
$show->field('fee_rate');
|
|
$show->field('payer_id');
|
|
$show->field('pay_info');
|
|
$show->field('pay_at');
|
|
$show->field('settle_at');
|
|
$show->field('status');
|
|
$show->field('remark');
|
|
$show->field('pay_image');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new DealerEarning(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('user_id');
|
|
$form->text('earningable_type');
|
|
$form->text('earningable_id');
|
|
$form->text('lvl');
|
|
$form->text('is_manager');
|
|
$form->text('total_amount');
|
|
$form->text('total_earnings');
|
|
$form->text('fee');
|
|
$form->text('fee_rate');
|
|
$form->text('payer_id');
|
|
$form->text('pay_info');
|
|
$form->text('pay_at');
|
|
$form->text('settle_at');
|
|
$form->text('status');
|
|
$form->text('remark');
|
|
$form->text('pay_image');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|