添加充值扣减权限
parent
9d1e38014d
commit
a8ddfa9ec9
|
|
@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
|
|||
use App\Admin\Extensions\Grid\Tools\Balance\Deduction;
|
||||
use App\Admin\Extensions\Grid\Tools\Balance\Recharge;
|
||||
use App\Admin\Repositories\BalanceLog;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
|
|
@ -22,8 +23,12 @@ class BalanceLogController extends AdminController
|
|||
$builder = BalanceLog::with('user');
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new Recharge());
|
||||
$tools->append(new Deduction());
|
||||
if (Admin::user()->can('dcat.admin.balance_logs.recharge')) {
|
||||
$tools->append(new Recharge());
|
||||
}
|
||||
if (Admin::user()->can('dcat.admin.balance_logs.deduction')) {
|
||||
$tools->append(new Deduction());
|
||||
}
|
||||
});
|
||||
// $grid->column('id')->sortable();
|
||||
$grid->column('user.phone')->copyable();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Repositories\PointsLog;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use Dcat\Admin\Show;
|
||||
|
||||
class PointsLogController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$builder = PointsLog::with('user');
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
// $grid->column('id')->sortable();
|
||||
$grid->column('user.phone');
|
||||
$grid->column('desc');
|
||||
// $grid->column('type');
|
||||
$grid->column('points');
|
||||
$grid->column('old_points');
|
||||
|
||||
$grid->column('created_at')->sortable();
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
// $grid->column('updated_at')->sortable();
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->panel(false);
|
||||
$filter->equal('user.phone')->width(3);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new PointsLog(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('user_id');
|
||||
$show->field('type');
|
||||
$show->field('points');
|
||||
$show->field('old_points');
|
||||
$show->field('desc');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new PointsLog(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('user_id');
|
||||
$form->text('type');
|
||||
$form->text('points');
|
||||
$form->text('old_points');
|
||||
$form->text('desc');
|
||||
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
|
|||
use App\Admin\Extensions\Grid\Tools\Wallet\Deduction;
|
||||
use App\Admin\Extensions\Grid\Tools\Wallet\Recharge;
|
||||
use App\Admin\Repositories\WalletLog;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
|
|
@ -22,8 +23,12 @@ class WalletLogController extends AdminController
|
|||
$builder = WalletLog::with('user');
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new Recharge());
|
||||
$tools->append(new Deduction());
|
||||
if (Admin::user()->can('dcat.admin.wallet_logs.recharge')) {
|
||||
$tools->append(new Recharge());
|
||||
}
|
||||
if (Admin::user()->can('dcat.admin.wallet_logs.deduction')) {
|
||||
$tools->append(new Deduction());
|
||||
}
|
||||
});
|
||||
// $grid->column('id')->sortable();
|
||||
$grid->column('user.phone')->copyable();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\PointsLog as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class PointsLog extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
|
|
@ -135,6 +135,10 @@ Route::group([
|
|||
'index',
|
||||
])->names('balance_logs');
|
||||
|
||||
$router->resource('points-logs', 'PointsLogController')->only([
|
||||
'index',
|
||||
])->names('points_logs');
|
||||
|
||||
/** api接口 **/
|
||||
$router->get('api/product-categories', 'ProductCategoryController@categories')->name('api.product_categories');
|
||||
$router->get('api/product-group-details', 'ProductGroupController@details')->name('api.product_group_details');
|
||||
|
|
|
|||
|
|
@ -2,17 +2,24 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PointsLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasDateTimeFormatter;
|
||||
|
||||
public const TYPE_CLICK = 1;//签到
|
||||
public const TYPE_READ = 2;//阅读文章
|
||||
|
||||
protected $fillable = [
|
||||
'type', 'user_id', 'old_points', 'desc',
|
||||
'type', 'user_id', 'points', 'old_points', 'desc',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,6 +236,30 @@ class AdminPermissionSeeder extends Seeder
|
|||
'verify'=>['name' =>'审核'],
|
||||
],
|
||||
],
|
||||
'distribution_pre_incomes'=>[
|
||||
'name' =>'预收益',
|
||||
'curd' => ['index'],
|
||||
],
|
||||
'wallet_logs'=>[
|
||||
'name' =>'可提账户',
|
||||
'curd' =>['index'],
|
||||
'children' => [
|
||||
'recharge'=>['name' =>'充值'],
|
||||
'deduction'=>['name' =>'扣减'],
|
||||
],
|
||||
],
|
||||
'balance_logs'=>[
|
||||
'name' =>'余额账户',
|
||||
'curd' =>['index'],
|
||||
'children' => [
|
||||
'recharge'=>['name' =>'充值'],
|
||||
'deduction'=>['name' =>'扣减'],
|
||||
],
|
||||
],
|
||||
'points_logs'=>[
|
||||
'name' =>'预收益',
|
||||
'curd' => ['index'],
|
||||
],
|
||||
];
|
||||
try {
|
||||
DB::begintransaction();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'labels' => [
|
||||
'PointsLog' => '积分账户',
|
||||
'points-logs' => '积分账户',
|
||||
],
|
||||
'fields' => [
|
||||
'user_id' => '用户ID',
|
||||
'user'=>[
|
||||
'phone' => '手机号',
|
||||
],
|
||||
'type' => '类别',
|
||||
'points' => '变动积分',
|
||||
'old_points' => '变动前',
|
||||
'desc' => '备注',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
];
|
||||
Loading…
Reference in New Issue