first commit
This commit is contained in:
47
app/Admin/Controllers/Account/IndexController.php
Normal file
47
app/Admin/Controllers/Account/IndexController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Account;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '账户管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Account);
|
||||
|
||||
$grid->model()->whereHasMorph(
|
||||
'accountable',
|
||||
User::class,
|
||||
function ($query) {
|
||||
$query->where('type', 'pingan')->whereHas('identity', function ($q) {
|
||||
$q->where('identity_id', 1);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->disableCreateButton();
|
||||
// $grid->column('所属项目')->display(function () {
|
||||
// return $this->accountable->type_text;
|
||||
// });
|
||||
$grid->column('渠道名称')->display(function () {
|
||||
return $this->accountable->name ?? $this->accountable->nickname;
|
||||
});
|
||||
$grid->column('balance', '总分润');
|
||||
$grid->column('score', '已打款');
|
||||
// $grid->column('updated_at', '更新时间');
|
||||
$grid->column('日志')->display(function () {
|
||||
return '<a href="' . admin_url('accounts/logs?id=' . $this->id) . '">账户日志</a>';
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
66
app/Admin/Controllers/Account/LogController.php
Normal file
66
app/Admin/Controllers/Account/LogController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Account;
|
||||
|
||||
use App\Models\AccountLog;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class LogController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '账户日志';
|
||||
|
||||
function grid()
|
||||
{
|
||||
$grid = new Grid(new AccountLog);
|
||||
$userId = request()->user_id;
|
||||
$grid->model()->when($userId, function ($query, $userId) {
|
||||
$query->where('user_id', $userId);
|
||||
});
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('rule.title', '触发规则');
|
||||
$filter->equal('type', '账户类型')->select(config('account.account_type'));
|
||||
});
|
||||
// $filter->column(1 / 3, function ($filter) {
|
||||
// $filter->where(function ($query) {
|
||||
// $query->whereHas('user', function ($query) {
|
||||
// $query->whereHas('info', function ($query) {
|
||||
// $query->where('nickname', 'like', "%{$this->input}%");
|
||||
// });
|
||||
// });
|
||||
// }, '会员姓名');
|
||||
// $filter->between('variable', '变量');
|
||||
// });
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('frozen', '冻结')->select([
|
||||
0 => '否',
|
||||
1 => '是',
|
||||
]);
|
||||
$filter->between('created_at', '创建时间')->datetime();
|
||||
});
|
||||
});
|
||||
|
||||
// $grid->column('user.username', '会员账号');
|
||||
// $grid->column('user.nickname', '会员姓名');
|
||||
$grid->column('rule.title', '触发规则');
|
||||
$grid->column('type', '类型')->using(config('account.account_type'));
|
||||
$grid->column('variable', '变量');
|
||||
$grid->column('balance', '余额');
|
||||
$grid->column('frozen', '冻结')
|
||||
->using([0 => '否', 1 => '是'])
|
||||
->label([
|
||||
0 => 'success',
|
||||
1 => 'warning',
|
||||
]);
|
||||
$grid->column('created_at', '获取时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
107
app/Admin/Controllers/Account/RuleController.php
Normal file
107
app/Admin/Controllers/Account/RuleController.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Account;
|
||||
|
||||
use App\Models\AccountRule;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RuleController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Title for current resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title = '账户规则';
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new AccountRule);
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
});
|
||||
});
|
||||
$grid->quickSearch('title')->placeholder('规则名称');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('title', '规则名称');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('name', '调用标记');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('type', '账户类型')->select([
|
||||
'cash' => '现金账户',
|
||||
'score' => '积分账户',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '编号');
|
||||
$grid->column('title', '规则名称');
|
||||
$grid->column('name', '调用标记');
|
||||
$grid->column('type', '账户类型')->using(config('account.account_type'));
|
||||
$grid->column('variable', '增减变量');
|
||||
$grid->column('trigger', '频率')->display(function () {
|
||||
return $this->trigger_text;
|
||||
});
|
||||
$grid->column('deductions', '立即处理')->bool();
|
||||
$grid->column('remark', '备注');
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('updated_at', '更新时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
|
||||
$form = new Form(new AccountRule);
|
||||
$form->text('title', '规则名称')
|
||||
->rules('required|between:2,50');
|
||||
|
||||
$form->text('name', '调用标记')
|
||||
->creationRules('required|alpha_dash|between:2,50|unique:account_rules')
|
||||
->updateRules('required|alpha_dash|between:2,50|unique:account_rules,name,{{id}}');
|
||||
|
||||
$form->select('type', '账户类型')
|
||||
->options(config('account.account_type'))
|
||||
->rules(['required', Rule::in(array_keys(config('account.account_type')))]);
|
||||
|
||||
$form->number('variable', '增减变量')
|
||||
->value(0)
|
||||
->rules('required|numeric');
|
||||
|
||||
$form->number('trigger', '次数限制')->value(0)
|
||||
->help('执行次数限制,小于0则终身一次,等于0不限制,大于0每日N次')
|
||||
->rules('required|integer');
|
||||
|
||||
$states = [
|
||||
'on' => ['value' => 1, 'text' => '打开'],
|
||||
'off' => ['value' => 0, 'text' => '关闭'],
|
||||
];
|
||||
|
||||
$form->switch('deductions', '立即处理')->value(1)->states($states);
|
||||
|
||||
$form->textarea('remark', '备注信息')->rules('nullable|max:255');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user