优化访问
This commit is contained in:
@@ -6,7 +6,6 @@ use App\Models\ActivityCoupon;
|
|||||||
use App\Models\ActivityRule;
|
use App\Models\ActivityRule;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Encore\Admin\Controllers\AdminController;
|
use Encore\Admin\Controllers\AdminController;
|
||||||
use Encore\Admin\Form;
|
|
||||||
use Encore\Admin\Grid;
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
class CouponController extends AdminController
|
class CouponController extends AdminController
|
||||||
@@ -30,11 +29,17 @@ class CouponController extends AdminController
|
|||||||
$query->where('identity_id', 1);
|
$query->where('identity_id', 1);
|
||||||
})->get()->pluck('nickname', 'id');
|
})->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->column(1 / 2, function ($filter) {
|
||||||
$filter->like('code', '平安券编号');
|
$filter->like('code', '卡券编号');
|
||||||
$filter->where(function ($query) {
|
$filter->where(function ($query) {
|
||||||
$query->whereHas('activity', function ($query) {
|
$query->whereHas('activity', function ($query) {
|
||||||
$query->whereHas('rule', 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'));
|
}, '优惠政策', '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 () {
|
$grid->column('优惠政策')->display(function () {
|
||||||
return $this->activity->rule->title;
|
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('code', '卡券编号');
|
||||||
$grid->column('status', '状态')
|
$grid->column('status', '状态')
|
||||||
->using(ActivityCoupon::STATUS)
|
->using(ActivityCoupon::STATUS)
|
||||||
@@ -75,7 +97,7 @@ class CouponController extends AdminController
|
|||||||
$export->column('mobile', function ($value, $original) {
|
$export->column('mobile', function ($value, $original) {
|
||||||
return $value . "\t";
|
return $value . "\t";
|
||||||
});
|
});
|
||||||
|
|
||||||
$export->filename($this->title . date("YmdHis"));
|
$export->filename($this->title . date("YmdHis"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Admin\Controllers\Finance;
|
|||||||
use App\Admin\Actions\Coupon\Batch;
|
use App\Admin\Actions\Coupon\Batch;
|
||||||
use App\Admin\Actions\Coupon\BatchProfit;
|
use App\Admin\Actions\Coupon\BatchProfit;
|
||||||
use App\Admin\Actions\Coupon\BatchProfits;
|
use App\Admin\Actions\Coupon\BatchProfits;
|
||||||
use App\Admin\Exporters\CouponPassExport;
|
|
||||||
use App\Models\Coupon;
|
use App\Models\Coupon;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Encore\Admin\Controllers\AdminController;
|
use Encore\Admin\Controllers\AdminController;
|
||||||
@@ -25,7 +24,7 @@ class IndexController extends AdminController
|
|||||||
protected function grid()
|
protected function grid()
|
||||||
{
|
{
|
||||||
$grid = new Grid(new Coupon);
|
$grid = new Grid(new Coupon);
|
||||||
$grid->model()->where('profit', '>', 0);
|
$grid->model()->with(['outlet', 'user', 'user.info'])->where('profit', '>', 0);
|
||||||
$grid->disableCreateButton();
|
$grid->disableCreateButton();
|
||||||
$grid->disableBatchActions(false);
|
$grid->disableBatchActions(false);
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ class IndexController extends AdminController
|
|||||||
->where('type', 'pingan')
|
->where('type', 'pingan')
|
||||||
->get()
|
->get()
|
||||||
->pluck('nickname', 'id');
|
->pluck('nickname', 'id');
|
||||||
|
|
||||||
$filter->equal('user_id', '渠道')->select($users);
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
});
|
});
|
||||||
$filter->column(1 / 2, function ($filter) {
|
$filter->column(1 / 2, function ($filter) {
|
||||||
@@ -124,16 +123,17 @@ class IndexController extends AdminController
|
|||||||
$grid->column('created_at', '核销时间');
|
$grid->column('created_at', '核销时间');
|
||||||
|
|
||||||
$grid->footer(function ($query) {
|
$grid->footer(function ($query) {
|
||||||
$all = $query->get();
|
$total = $query->count();
|
||||||
$pass = $query->where('status', 2)->get();
|
$success = $query->where('status', 2)->count();
|
||||||
$reject = $query->where('status', 3)->get();
|
$faield = $total - $success;
|
||||||
|
|
||||||
return '<label class="label label-success">全部:' . $all->count() . '张</label> '
|
return '<label class="label label-success">全部:' . $total . '张</label> '
|
||||||
. '<label class="label label-success">核销金额:' . $pass->sum('price') . '元</label> '
|
. '<label class="label label-success">核销金额:' . $query->sum('price') . '元</label> '
|
||||||
. '<label class="label label-success">资金通道结算:' . $pass->sum('profit') . '元</label> '
|
. '<label class="label label-success">资金通道结算:' . $query->sum('profit') . '元</label> '
|
||||||
. '<label class="label label-success">打款金额:' . $pass->where('is_profit', 1)
|
. '<label class="label label-success">打款金额:' . $query->where('is_profit', 1)
|
||||||
->sum('profit') . '元</label> ';
|
->sum('profit') . '元</label> ';
|
||||||
});
|
});
|
||||||
|
|
||||||
$grid->disableExport(false);
|
$grid->disableExport(false);
|
||||||
|
|
||||||
$grid->export(function ($export) {
|
$grid->export(function ($export) {
|
||||||
|
|||||||
Reference in New Issue
Block a user