6
0
Fork 0

添加后台补贴状态查询

release
vine_liutk 2022-01-27 14:08:31 +08:00
parent d631f96fb7
commit 2ff139ca1e
2 changed files with 86 additions and 2 deletions

View File

@ -3,6 +3,7 @@
namespace App\Admin\Controllers;
use App\Admin\Actions\Show\DealerEarningPay;
use App\Admin\Renderable\Grid\Filter\DealerEarningStatusIn;
use App\Admin\Repositories\DealerEarning;
use App\Enums\DealerEarningStatus;
use App\Models\DealerChannelSubsidyLog;
@ -68,8 +69,13 @@ class DealerEarningController extends AdminController
-1=> '待结算',
0 => '待打款',
1 => '待收款',
2 => '已完成',
])->dot();
5 => '已完成',
])->dot()->filter(DealerEarningStatusIn::make([
-1=> '待结算',
0 => '待打款',
1 => '待收款',
5 => '已完成',
]));
$grid->column('settle_at');
$grid->column('payer_id')->display(function () {
return $this->payer_id ? $this->payer?->phone : '公司';

View File

@ -0,0 +1,78 @@
<?php
namespace App\Admin\Renderable\Grid\Filter;
use Dcat\Admin\Grid\Column\Filter;
use Dcat\Admin\Grid\Column\Filter\Checkbox;
use Dcat\Admin\Grid\Model;
class DealerEarningStatusIn extends Filter
{
use Checkbox;
/**
* @var array
*/
protected $options = [];
/**
* CheckFilter constructor.
*
* @param array $options
*/
public function __construct(array $options)
{
$this->options = $options;
$this->class = [
'all' => uniqid('column-filter-all-'),
'item' => uniqid('column-filter-item-'),
];
}
/**
* Add a binding to the query.
*
* @param array $value
* @param Model $model
*/
public function addBinding($value, Model $model)
{
if (empty($value)) {
return;
}
$all = [-1, 0, 1, 5];
if (array_diff($all, $value)) {//无差别则直接跳过
//判断查询的状态有哪些;
$model->where(function ($query) use ($value) {
foreach ($value as $status) {
switch ($status) {
case -1:
$query->orWhereNull('settle_at');
break;
case 0:
$query->orWhere('status', 0);
break;
case 1:
$query->orWhere('status', 1);
break;
case 5:
$query->orWhere('status', 5);
break;
}
}
});
}
}
/**
* Render this filter.
*
* @return string
*/
public function render()
{
return $this->renderCheckbox();
}
}