From ee06382d9f390b0767a9df6e438ec0e87bc89214 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Mon, 7 Mar 2022 10:13:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/QuotaV1LogController.php | 87 ++++++++++++++++++ .../Controllers/QuotaV1SendJobController.php | 3 + app/Admin/Repositories/QuotaV1Log.php | 16 ++++ app/Admin/routes.php | 1 + app/Models/QuotaV1Log.php | 7 ++ ..._before_balance_to_quota_v1_logs_table.php | 2 +- database/seeders/AdminPermissionSeeder.php | 1 + dcat_admin_ide_helper.php | 92 +++++++++++-------- resources/lang/zh_CN/quota-v1-log.php | 20 ++++ 9 files changed, 192 insertions(+), 37 deletions(-) create mode 100644 app/Admin/Controllers/QuotaV1LogController.php create mode 100644 app/Admin/Repositories/QuotaV1Log.php create mode 100644 resources/lang/zh_CN/quota-v1-log.php diff --git a/app/Admin/Controllers/QuotaV1LogController.php b/app/Admin/Controllers/QuotaV1LogController.php new file mode 100644 index 00000000..12847eb3 --- /dev/null +++ b/app/Admin/Controllers/QuotaV1LogController.php @@ -0,0 +1,87 @@ +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'); + }); + } +} diff --git a/app/Admin/Controllers/QuotaV1SendJobController.php b/app/Admin/Controllers/QuotaV1SendJobController.php index 1f10a622..3a036a6d 100644 --- a/app/Admin/Controllers/QuotaV1SendJobController.php +++ b/app/Admin/Controllers/QuotaV1SendJobController.php @@ -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(' 变动记录'); + } }); $grid->column('amount')->display(function ($value) { return bcdiv($value, 100, 2); diff --git a/app/Admin/Repositories/QuotaV1Log.php b/app/Admin/Repositories/QuotaV1Log.php new file mode 100644 index 00000000..d9ffa971 --- /dev/null +++ b/app/Admin/Repositories/QuotaV1Log.php @@ -0,0 +1,16 @@ +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', diff --git a/app/Models/QuotaV1Log.php b/app/Models/QuotaV1Log.php index e8440b3c..603887be 100644 --- a/app/Models/QuotaV1Log.php +++ b/app/Models/QuotaV1Log.php @@ -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); + } } diff --git a/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php b/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php index 4391ca78..09b42f6b 100644 --- a/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php +++ b/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php @@ -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(); }); } diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php index 8e6103e6..389bd35b 100644 --- a/database/seeders/AdminPermissionSeeder.php +++ b/database/seeders/AdminPermissionSeeder.php @@ -307,6 +307,7 @@ class AdminPermissionSeeder extends Seeder 'log_list'=>['name' =>'分红记录'], 'recharge'=>['name' =>'增加配额'], 'deduction'=>['name' =>'扣减配额'], + 'logs_index'=>['name' =>'变动日志'], ], ], 'dealers' =>[ diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index a2d41b6c..d1d1dab1 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -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) diff --git a/resources/lang/zh_CN/quota-v1-log.php b/resources/lang/zh_CN/quota-v1-log.php new file mode 100644 index 00000000..db69b27f --- /dev/null +++ b/resources/lang/zh_CN/quota-v1-log.php @@ -0,0 +1,20 @@ + [ + 'QuotaV1Log' => '老配额变动日志', + 'quota-v1-send-jobs' => '老配额分红', + 'logs-index'=>'变动日志', + ], + 'fields' => [ + 'user_id' => '用户', + 'loggable_type' => '类型', + 'loggable_id' => '关联ID', + 'action' => '操作类型', + 'before_balance' => '变更前的余额', + 'change_balance' => '变动余额', + 'remarks' => '备注', + ], + 'options' => [ + ], +];