6
0
Fork 0

添加日志显示

release
vine_liutk 2022-03-07 10:13:51 +08:00
parent a557725c91
commit ee06382d9f
9 changed files with 192 additions and 37 deletions

View File

@ -0,0 +1,87 @@
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\QuotaV1Log;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
class QuotaV1LogController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$builder = QuotaV1Log::with(['user', 'user.userInfo']);
return Grid::make($builder, function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('user.phone', '手机号')->copyable();
$grid->column('user.userInfo.nickname', '昵称');
// $grid->column('loggable_type');
// $grid->column('loggable_id');
// $grid->column('action');
$grid->column('before_balance');
$grid->column('change_balance');
$grid->column('remarks');
$grid->model()->orderBy('created_at', 'desc');
$grid->column('created_at')->sortable();
// $grid->column('updated_at')->sortable();
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
$filter->panel();
$filter->like('user.phone', '手机号')->width(3);
// $filter->equal('id');
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new QuotaV1Log(), function (Show $show) {
$show->field('id');
$show->field('user_id');
$show->field('loggable_type');
$show->field('loggable_id');
$show->field('action');
$show->field('before_balance');
$show->field('change_balance');
$show->field('remarks');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new QuotaV1Log(), function (Form $form) {
$form->display('id');
$form->text('user_id');
$form->text('loggable_type');
$form->text('loggable_id');
$form->text('action');
$form->text('before_balance');
$form->text('change_balance');
$form->text('remarks');
$form->display('created_at');
$form->display('updated_at');
});
}
}

View File

@ -34,6 +34,9 @@ class QuotaV1SendJobController extends AdminController
if (Admin::user()->can('dcat.admin.quota_v1_send_jobs.deduction')) {
$tools->append(new Deduction());
}
if (Admin::user()->can('dcat.admin.quota_v1_send_jobs.logs_index')) {
$tools->append('<a href="'.admin_route('quota_v1_send_jobs.logs_index').'" target="_blank"> <i class="feather grid-action-icon icon-list"></i>变动记录</a>');
}
});
$grid->column('amount')->display(function ($value) {
return bcdiv($value, 100, 2);

View File

@ -0,0 +1,16 @@
<?php
namespace App\Admin\Repositories;
use App\Models\QuotaV1Log as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class QuotaV1Log extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}

View File

@ -154,6 +154,7 @@ Route::group([
'index', 'create', 'store', 'edit', 'update', 'destroy',
])->names('quota_v1_send_jobs');
$router->get('quota-v1-send-jobs/{job}/log-list', 'QuotaV1SendJobController@logList')->name('quota_v1_send_jobs.log_list');
$router->get('quota-v1-send-jobs/logs-index', 'QuotaV1LogController@index')->name('quota_v1_send_jobs.logs_index');
$router->resource('order-refunds', 'OrderRefundLogController')->only([
'index',

View File

@ -2,12 +2,14 @@
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class QuotaV1Log extends Model
{
use HasFactory;
use HasDateTimeFormatter;
public const ACTION_ADMIN_RECHARGE = 7;
public const ACTION_ADMIN_DEDUCTION = 8;
@ -24,4 +26,9 @@ class QuotaV1Log extends Model
'change_balance',
'remarks',
];
public function user()
{
return $this->belongsTo(User::class);
}
}

View File

@ -14,7 +14,7 @@ class ChangeBeforeBalanceToQuotaV1LogsTable extends Migration
public function up()
{
Schema::table('quota_v1_logs', function (Blueprint $table) {
$table->string('before_balance', 12, 3)->change();
$table->decimal('before_balance', 12, 3)->change();
$table->decimal('change_balance', 12, 3)->change();
});
}

View File

@ -307,6 +307,7 @@ class AdminPermissionSeeder extends Seeder
'log_list'=>['name' =>'分红记录'],
'recharge'=>['name' =>'增加配额'],
'deduction'=>['name' =>'扣减配额'],
'logs_index'=>['name' =>'变动日志'],
],
],
'dealers' =>[

View File

@ -12,13 +12,25 @@ namespace Dcat\Admin {
/**
* @property Grid\Column|Collection width
* @property Grid\Column|Collection content
* @property Grid\Column|Collection coupons_rule
* @property Grid\Column|Collection cover
* @property Grid\Column|Collection created_at
* @property Grid\Column|Collection dimensions
* @property Grid\Column|Collection ended_at
* @property Grid\Column|Collection gifts_rule
* @property Grid\Column|Collection id
* @property Grid\Column|Collection is_use
* @property Grid\Column|Collection started_at
* @property Grid\Column|Collection updated_at
* @property Grid\Column|Collection activity_id
* @property Grid\Column|Collection coupon_id
* @property Grid\Column|Collection qty
* @property Grid\Column|Collection sku_id
* @property Grid\Column|Collection part_id
* @property Grid\Column|Collection dimensions
* @property Grid\Column|Collection is_show
* @property Grid\Column|Collection key
* @property Grid\Column|Collection name
* @property Grid\Column|Collection updated_at
* @property Grid\Column|Collection detail
* @property Grid\Column|Collection type
* @property Grid\Column|Collection version
@ -72,8 +84,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection article_id
* @property Grid\Column|Collection author_name
* @property Grid\Column|Collection category_id
* @property Grid\Column|Collection content
* @property Grid\Column|Collection cover
* @property Grid\Column|Collection likes
* @property Grid\Column|Collection media_content
* @property Grid\Column|Collection media_type
@ -91,7 +101,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection transferable
* @property Grid\Column|Collection continue_click_times
* @property Grid\Column|Collection last_click_at
* @property Grid\Column|Collection coupon_id
* @property Grid\Column|Collection is_enable
* @property Grid\Column|Collection ranges
* @property Grid\Column|Collection administrator_id
@ -128,7 +137,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection last_consignor_id
* @property Grid\Column|Collection new_consignor_id
* @property Grid\Column|Collection price
* @property Grid\Column|Collection qty
* @property Grid\Column|Collection sale_price
* @property Grid\Column|Collection reason
* @property Grid\Column|Collection allocated_at
@ -212,7 +220,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection gift_for_sku_id
* @property Grid\Column|Collection reduced_amount
* @property Grid\Column|Collection remain_quantity
* @property Grid\Column|Collection sku_id
* @property Grid\Column|Collection specs
* @property Grid\Column|Collection spu_id
* @property Grid\Column|Collection vip_discount_amount
@ -238,7 +245,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection gift_sku_id
* @property Grid\Column|Collection remaining
* @property Grid\Column|Collection attrs
* @property Grid\Column|Collection part_id
* @property Grid\Column|Collection applicant_id
* @property Grid\Column|Collection reviewer_id
* @property Grid\Column|Collection buynote_id
@ -256,7 +262,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection message_type
* @property Grid\Column|Collection change_quota
* @property Grid\Column|Collection order_user_id
* @property Grid\Column|Collection is_use
* @property Grid\Column|Collection size
* @property Grid\Column|Collection x
* @property Grid\Column|Collection y
@ -311,13 +316,25 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection status_remark
*
* @method Grid\Column|Collection width(string $label = null)
* @method Grid\Column|Collection content(string $label = null)
* @method Grid\Column|Collection coupons_rule(string $label = null)
* @method Grid\Column|Collection cover(string $label = null)
* @method Grid\Column|Collection created_at(string $label = null)
* @method Grid\Column|Collection dimensions(string $label = null)
* @method Grid\Column|Collection ended_at(string $label = null)
* @method Grid\Column|Collection gifts_rule(string $label = null)
* @method Grid\Column|Collection id(string $label = null)
* @method Grid\Column|Collection is_use(string $label = null)
* @method Grid\Column|Collection started_at(string $label = null)
* @method Grid\Column|Collection updated_at(string $label = null)
* @method Grid\Column|Collection activity_id(string $label = null)
* @method Grid\Column|Collection coupon_id(string $label = null)
* @method Grid\Column|Collection qty(string $label = null)
* @method Grid\Column|Collection sku_id(string $label = null)
* @method Grid\Column|Collection part_id(string $label = null)
* @method Grid\Column|Collection dimensions(string $label = null)
* @method Grid\Column|Collection is_show(string $label = null)
* @method Grid\Column|Collection key(string $label = null)
* @method Grid\Column|Collection name(string $label = null)
* @method Grid\Column|Collection updated_at(string $label = null)
* @method Grid\Column|Collection detail(string $label = null)
* @method Grid\Column|Collection type(string $label = null)
* @method Grid\Column|Collection version(string $label = null)
@ -371,8 +388,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection article_id(string $label = null)
* @method Grid\Column|Collection author_name(string $label = null)
* @method Grid\Column|Collection category_id(string $label = null)
* @method Grid\Column|Collection content(string $label = null)
* @method Grid\Column|Collection cover(string $label = null)
* @method Grid\Column|Collection likes(string $label = null)
* @method Grid\Column|Collection media_content(string $label = null)
* @method Grid\Column|Collection media_type(string $label = null)
@ -390,7 +405,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection transferable(string $label = null)
* @method Grid\Column|Collection continue_click_times(string $label = null)
* @method Grid\Column|Collection last_click_at(string $label = null)
* @method Grid\Column|Collection coupon_id(string $label = null)
* @method Grid\Column|Collection is_enable(string $label = null)
* @method Grid\Column|Collection ranges(string $label = null)
* @method Grid\Column|Collection administrator_id(string $label = null)
@ -427,7 +441,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection last_consignor_id(string $label = null)
* @method Grid\Column|Collection new_consignor_id(string $label = null)
* @method Grid\Column|Collection price(string $label = null)
* @method Grid\Column|Collection qty(string $label = null)
* @method Grid\Column|Collection sale_price(string $label = null)
* @method Grid\Column|Collection reason(string $label = null)
* @method Grid\Column|Collection allocated_at(string $label = null)
@ -511,7 +524,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection gift_for_sku_id(string $label = null)
* @method Grid\Column|Collection reduced_amount(string $label = null)
* @method Grid\Column|Collection remain_quantity(string $label = null)
* @method Grid\Column|Collection sku_id(string $label = null)
* @method Grid\Column|Collection specs(string $label = null)
* @method Grid\Column|Collection spu_id(string $label = null)
* @method Grid\Column|Collection vip_discount_amount(string $label = null)
@ -537,7 +549,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection gift_sku_id(string $label = null)
* @method Grid\Column|Collection remaining(string $label = null)
* @method Grid\Column|Collection attrs(string $label = null)
* @method Grid\Column|Collection part_id(string $label = null)
* @method Grid\Column|Collection applicant_id(string $label = null)
* @method Grid\Column|Collection reviewer_id(string $label = null)
* @method Grid\Column|Collection buynote_id(string $label = null)
@ -555,7 +566,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection message_type(string $label = null)
* @method Grid\Column|Collection change_quota(string $label = null)
* @method Grid\Column|Collection order_user_id(string $label = null)
* @method Grid\Column|Collection is_use(string $label = null)
* @method Grid\Column|Collection size(string $label = null)
* @method Grid\Column|Collection x(string $label = null)
* @method Grid\Column|Collection y(string $label = null)
@ -615,13 +625,25 @@ namespace Dcat\Admin {
/**
* @property Show\Field|Collection width
* @property Show\Field|Collection content
* @property Show\Field|Collection coupons_rule
* @property Show\Field|Collection cover
* @property Show\Field|Collection created_at
* @property Show\Field|Collection dimensions
* @property Show\Field|Collection ended_at
* @property Show\Field|Collection gifts_rule
* @property Show\Field|Collection id
* @property Show\Field|Collection is_use
* @property Show\Field|Collection started_at
* @property Show\Field|Collection updated_at
* @property Show\Field|Collection activity_id
* @property Show\Field|Collection coupon_id
* @property Show\Field|Collection qty
* @property Show\Field|Collection sku_id
* @property Show\Field|Collection part_id
* @property Show\Field|Collection dimensions
* @property Show\Field|Collection is_show
* @property Show\Field|Collection key
* @property Show\Field|Collection name
* @property Show\Field|Collection updated_at
* @property Show\Field|Collection detail
* @property Show\Field|Collection type
* @property Show\Field|Collection version
@ -675,8 +697,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection article_id
* @property Show\Field|Collection author_name
* @property Show\Field|Collection category_id
* @property Show\Field|Collection content
* @property Show\Field|Collection cover
* @property Show\Field|Collection likes
* @property Show\Field|Collection media_content
* @property Show\Field|Collection media_type
@ -694,7 +714,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection transferable
* @property Show\Field|Collection continue_click_times
* @property Show\Field|Collection last_click_at
* @property Show\Field|Collection coupon_id
* @property Show\Field|Collection is_enable
* @property Show\Field|Collection ranges
* @property Show\Field|Collection administrator_id
@ -731,7 +750,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection last_consignor_id
* @property Show\Field|Collection new_consignor_id
* @property Show\Field|Collection price
* @property Show\Field|Collection qty
* @property Show\Field|Collection sale_price
* @property Show\Field|Collection reason
* @property Show\Field|Collection allocated_at
@ -815,7 +833,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection gift_for_sku_id
* @property Show\Field|Collection reduced_amount
* @property Show\Field|Collection remain_quantity
* @property Show\Field|Collection sku_id
* @property Show\Field|Collection specs
* @property Show\Field|Collection spu_id
* @property Show\Field|Collection vip_discount_amount
@ -841,7 +858,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection gift_sku_id
* @property Show\Field|Collection remaining
* @property Show\Field|Collection attrs
* @property Show\Field|Collection part_id
* @property Show\Field|Collection applicant_id
* @property Show\Field|Collection reviewer_id
* @property Show\Field|Collection buynote_id
@ -859,7 +875,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection message_type
* @property Show\Field|Collection change_quota
* @property Show\Field|Collection order_user_id
* @property Show\Field|Collection is_use
* @property Show\Field|Collection size
* @property Show\Field|Collection x
* @property Show\Field|Collection y
@ -914,13 +929,25 @@ namespace Dcat\Admin {
* @property Show\Field|Collection status_remark
*
* @method Show\Field|Collection width(string $label = null)
* @method Show\Field|Collection content(string $label = null)
* @method Show\Field|Collection coupons_rule(string $label = null)
* @method Show\Field|Collection cover(string $label = null)
* @method Show\Field|Collection created_at(string $label = null)
* @method Show\Field|Collection dimensions(string $label = null)
* @method Show\Field|Collection ended_at(string $label = null)
* @method Show\Field|Collection gifts_rule(string $label = null)
* @method Show\Field|Collection id(string $label = null)
* @method Show\Field|Collection is_use(string $label = null)
* @method Show\Field|Collection started_at(string $label = null)
* @method Show\Field|Collection updated_at(string $label = null)
* @method Show\Field|Collection activity_id(string $label = null)
* @method Show\Field|Collection coupon_id(string $label = null)
* @method Show\Field|Collection qty(string $label = null)
* @method Show\Field|Collection sku_id(string $label = null)
* @method Show\Field|Collection part_id(string $label = null)
* @method Show\Field|Collection dimensions(string $label = null)
* @method Show\Field|Collection is_show(string $label = null)
* @method Show\Field|Collection key(string $label = null)
* @method Show\Field|Collection name(string $label = null)
* @method Show\Field|Collection updated_at(string $label = null)
* @method Show\Field|Collection detail(string $label = null)
* @method Show\Field|Collection type(string $label = null)
* @method Show\Field|Collection version(string $label = null)
@ -974,8 +1001,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection article_id(string $label = null)
* @method Show\Field|Collection author_name(string $label = null)
* @method Show\Field|Collection category_id(string $label = null)
* @method Show\Field|Collection content(string $label = null)
* @method Show\Field|Collection cover(string $label = null)
* @method Show\Field|Collection likes(string $label = null)
* @method Show\Field|Collection media_content(string $label = null)
* @method Show\Field|Collection media_type(string $label = null)
@ -993,7 +1018,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection transferable(string $label = null)
* @method Show\Field|Collection continue_click_times(string $label = null)
* @method Show\Field|Collection last_click_at(string $label = null)
* @method Show\Field|Collection coupon_id(string $label = null)
* @method Show\Field|Collection is_enable(string $label = null)
* @method Show\Field|Collection ranges(string $label = null)
* @method Show\Field|Collection administrator_id(string $label = null)
@ -1030,7 +1054,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection last_consignor_id(string $label = null)
* @method Show\Field|Collection new_consignor_id(string $label = null)
* @method Show\Field|Collection price(string $label = null)
* @method Show\Field|Collection qty(string $label = null)
* @method Show\Field|Collection sale_price(string $label = null)
* @method Show\Field|Collection reason(string $label = null)
* @method Show\Field|Collection allocated_at(string $label = null)
@ -1114,7 +1137,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection gift_for_sku_id(string $label = null)
* @method Show\Field|Collection reduced_amount(string $label = null)
* @method Show\Field|Collection remain_quantity(string $label = null)
* @method Show\Field|Collection sku_id(string $label = null)
* @method Show\Field|Collection specs(string $label = null)
* @method Show\Field|Collection spu_id(string $label = null)
* @method Show\Field|Collection vip_discount_amount(string $label = null)
@ -1140,7 +1162,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection gift_sku_id(string $label = null)
* @method Show\Field|Collection remaining(string $label = null)
* @method Show\Field|Collection attrs(string $label = null)
* @method Show\Field|Collection part_id(string $label = null)
* @method Show\Field|Collection applicant_id(string $label = null)
* @method Show\Field|Collection reviewer_id(string $label = null)
* @method Show\Field|Collection buynote_id(string $label = null)
@ -1158,7 +1179,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection message_type(string $label = null)
* @method Show\Field|Collection change_quota(string $label = null)
* @method Show\Field|Collection order_user_id(string $label = null)
* @method Show\Field|Collection is_use(string $label = null)
* @method Show\Field|Collection size(string $label = null)
* @method Show\Field|Collection x(string $label = null)
* @method Show\Field|Collection y(string $label = null)

View File

@ -0,0 +1,20 @@
<?php
return [
'labels' => [
'QuotaV1Log' => '老配额变动日志',
'quota-v1-send-jobs' => '老配额分红',
'logs-index'=>'变动日志',
],
'fields' => [
'user_id' => '用户',
'loggable_type' => '类型',
'loggable_id' => '关联ID',
'action' => '操作类型',
'before_balance' => '变更前的余额',
'change_balance' => '变动余额',
'remarks' => '备注',
],
'options' => [
],
];