优化访问
This commit is contained in:
@@ -6,7 +6,6 @@ use App\Models\ActivityCoupon;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class CouponController extends AdminController
|
||||
@@ -30,11 +29,17 @@ class CouponController extends AdminController
|
||||
$query->where('identity_id', 1);
|
||||
})->get()->pluck('nickname', 'id');
|
||||
|
||||
$filter->equal('activity.user_id', '渠道')->select(array_merge(['0' => '系统'], $users->toArray()));
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '网点名称', 'outlet_name');
|
||||
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('code', '平安券编号');
|
||||
$filter->like('code', '卡券编号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('activity', function ($query) {
|
||||
$query->whereHas('rule', function ($query) {
|
||||
@@ -42,6 +47,21 @@ class CouponController extends AdminController
|
||||
});
|
||||
});
|
||||
}, '优惠政策', 'rule_code')->select(ActivityRule::where('status', 1)->pluck('title', 'code'));
|
||||
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('parent', function ($query) {
|
||||
$query->where('id', $this->input);
|
||||
});
|
||||
});
|
||||
}, '渠道', 'parent_id')->select($users);;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,9 +71,11 @@ class CouponController extends AdminController
|
||||
$grid->column('优惠政策')->display(function () {
|
||||
return $this->activity->rule->title;
|
||||
});
|
||||
$grid->column('agent', '所属渠道')->display(function () {
|
||||
return $this->activity->user_nickname;
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
});
|
||||
|
||||
$grid->column('code', '卡券编号');
|
||||
$grid->column('status', '状态')
|
||||
->using(ActivityCoupon::STATUS)
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Admin\Controllers\Finance;
|
||||
use App\Admin\Actions\Coupon\Batch;
|
||||
use App\Admin\Actions\Coupon\BatchProfit;
|
||||
use App\Admin\Actions\Coupon\BatchProfits;
|
||||
use App\Admin\Exporters\CouponPassExport;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
@@ -25,7 +24,7 @@ class IndexController extends AdminController
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Coupon);
|
||||
$grid->model()->where('profit', '>', 0);
|
||||
$grid->model()->with(['outlet', 'user', 'user.info'])->where('profit', '>', 0);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions(false);
|
||||
|
||||
@@ -124,16 +123,17 @@ class IndexController extends AdminController
|
||||
$grid->column('created_at', '核销时间');
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
$all = $query->get();
|
||||
$pass = $query->where('status', 2)->get();
|
||||
$reject = $query->where('status', 3)->get();
|
||||
$total = $query->count();
|
||||
$success = $query->where('status', 2)->count();
|
||||
$faield = $total - $success;
|
||||
|
||||
return '<label class="label label-success">全部:' . $all->count() . '张</label> '
|
||||
. '<label class="label label-success">核销金额:' . $pass->sum('price') . '元</label> '
|
||||
. '<label class="label label-success">资金通道结算:' . $pass->sum('profit') . '元</label> '
|
||||
. '<label class="label label-success">打款金额:' . $pass->where('is_profit', 1)
|
||||
->sum('profit') . '元</label> ';
|
||||
return '<label class="label label-success">全部:' . $total . '张</label> '
|
||||
. '<label class="label label-success">核销金额:' . $query->sum('price') . '元</label> '
|
||||
. '<label class="label label-success">资金通道结算:' . $query->sum('profit') . '元</label> '
|
||||
. '<label class="label label-success">打款金额:' . $query->where('is_profit', 1)
|
||||
->sum('profit') . '元</label> ';
|
||||
});
|
||||
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
|
||||
Reference in New Issue
Block a user