first commit
This commit is contained in:
164
app/Admin/Controllers/Finance/IndexController.php
Normal file
164
app/Admin/Controllers/Finance/IndexController.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
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\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '平安渠道打款处理';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date: 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Coupon);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions(false);
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new Batch);
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
$batch->add(new BatchProfits);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableView();
|
||||
$actions->disableEdit();
|
||||
$actions->disableDelete();
|
||||
if ($actions->row->canProfit()) {
|
||||
$actions->add(new BatchProfit);
|
||||
}
|
||||
});
|
||||
|
||||
$grid->model()->where('status', 2)->orderBy('id', 'desc');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('is_profit', '打款')->select([
|
||||
'0' => '未打款',
|
||||
'1' => '已打款',
|
||||
]);
|
||||
$filter->between('created_at', '核销时间')->datetime();
|
||||
$filter->between('paid_at', '打款时间')->datetime();
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->where('type', 'pingan')
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
$filter->equal('user_id', '渠道')->select($users);
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('partnerOrderId', '订单号');
|
||||
$filter->like('redemptionCode', '平安券编号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '渠道名称');
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->user->nickname;
|
||||
});
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
});
|
||||
|
||||
// $grid->column('partnerOrderId', '订单号');
|
||||
$grid->column('redemptionCode', '平安券编号');
|
||||
$grid->column('couponName', '优惠政策');
|
||||
$grid->column('price', '核销金额');
|
||||
$grid->column('profit', '资金通道结算');
|
||||
|
||||
$grid->column('状态')->display(function () {
|
||||
switch ($this->status) {
|
||||
case 2:
|
||||
return '<span style="color:green">' . $this->status_text . '</span>';
|
||||
break;
|
||||
case 3:
|
||||
return '<span style="color:red">' . $this->status_text . '</span>';
|
||||
break;
|
||||
default:
|
||||
return $this->status_text;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('打款')->display(function () {
|
||||
switch ($this->is_profit) {
|
||||
case 0:
|
||||
return '<span style="color:green">未打款</span>';
|
||||
break;
|
||||
case 1:
|
||||
return '<span style="color:red">已打款</span>';
|
||||
break;
|
||||
default:
|
||||
return '未知';
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('paid_at', '打款时间');
|
||||
$grid->column('created_at', '核销时间');
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
$all = $query->get();
|
||||
$pass = $all->where('status', 2)->all();
|
||||
$reject = $all->where('status', 3)->all();
|
||||
$pass = collect($pass);
|
||||
$reject = collect($reject);
|
||||
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> ';
|
||||
});
|
||||
$grid->disableExport(false);
|
||||
$grid->export(function ($export) {
|
||||
$export->column('打款', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('状态', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
|
||||
$export->column('网点名称/编号', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('price', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('profit', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('redemptionCode', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
|
||||
$export->filename($this->title . date("YmdHis"));
|
||||
});
|
||||
// $grid->exporter(new CouponPassExport());
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user