Update
parent
c6f6133ea6
commit
11b16d80d4
|
|
@ -9,9 +9,7 @@ use App\Enums\OfflineOrderStatus;
|
|||
use App\Enums\PayWay;
|
||||
use App\Models\OfflineOrder;
|
||||
use App\Models\OfflineOrderItem;
|
||||
use App\Models\Order;
|
||||
use App\Models\Store\Store;
|
||||
use App\Models\UserInfo;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Grid\Column;
|
||||
|
|
@ -33,7 +31,7 @@ class OfflineOrderController extends AdminController
|
|||
CSS
|
||||
);
|
||||
|
||||
$grid = new Grid(OfflineOrderRepository::with(['user', 'userInfo', 'store']));
|
||||
$grid = new Grid(OfflineOrderRepository::with(['user', 'userInfo', 'store', 'staff', 'staffInfo']));
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
|
|
@ -56,6 +54,20 @@ class OfflineOrderController extends AdminController
|
|||
HTML;
|
||||
});
|
||||
$grid->column('store_id')->display(fn() => $this->store?->title);
|
||||
$grid->column('staff_id')->display(function () {
|
||||
if (is_null($this->staff_id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$nickname = $this->staffInfo?->nickname ?? '---';
|
||||
$avatar = $this->staffInfo?->avatar ?? 'https://via.placeholder.com/45x45.png';
|
||||
$phone = $this->staff?->phone;
|
||||
return <<<HTML
|
||||
<img src="{$avatar}" width="45" />
|
||||
<span class="label bg-danger">{$nickname}</span>
|
||||
<span class="label bg-success">{$phone}</span>
|
||||
HTML;
|
||||
});
|
||||
$grid->column('products_total_amount')->display(fn($v) => bcdiv($v, 100, 2))->prepend('¥');
|
||||
$grid->column('discount_reduction_amount')->display(fn($v) => bcdiv($v, 100, 2))->prepend('¥');
|
||||
$grid->column('points_deduction_amount')->display(fn($v) => bcdiv($v, 100, 2))->prepend('¥');
|
||||
|
|
@ -71,12 +83,18 @@ class OfflineOrderController extends AdminController
|
|||
$filter->where('user_id', function ($q) {
|
||||
$q->where(function ($q) {
|
||||
$q->whereHas('user', fn($q) => $q->where('phone', 'like', '%'.$this->input.'%'))
|
||||
->orWhereHas('userinfo', fn($q) => $q->where('nickname', 'like', '%'.$this->input.'%'));
|
||||
->orWhereHas('userInfo', fn($q) => $q->where('nickname', 'like', '%'.$this->input.'%'));
|
||||
});
|
||||
})->width(3)->placeholder('昵称/手机号');
|
||||
$filter->like('payment_sn')->width(3);
|
||||
$filter->like('out_trade_no')->width(3);
|
||||
$filter->equal('store_id')->select(Store::pluck('title', 'id'))->width(3);
|
||||
$filter->where('staff_id', function ($q) {
|
||||
$q->where(function ($q) {
|
||||
$q->whereHas('staff', fn($q) => $q->where('phone', 'like', '%'.$this->input.'%'))
|
||||
->orWhereHas('staffInfo', fn($q) => $q->where('nickname', 'like', '%'.$this->input.'%'));
|
||||
});
|
||||
})->width(3)->placeholder('昵称/手机号');
|
||||
$filter->where('type', function ($builder) {
|
||||
if ($this->input == 1) {
|
||||
$builder->where('points_deduction_amount', '>', 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue