From dae030c2fcdca7c75affd1b4e4201b6eb811c645 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 30 Nov 2021 11:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E9=A1=BB=E7=9F=A5=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ProductBuynoteController.php | 85 +++++++++++++++++++ .../Controllers/ProductSpuController.php | 2 + app/Admin/Repositories/ProductBuynote.php | 16 ++++ app/Admin/routes.php | 4 + app/Models/ProductBuynote.php | 13 +++ ...11_22_110044_create_product_spus_table.php | 1 + ...11_24_120232_create_product_skus_table.php | 2 + ...0_104546_create_product_buynotes_table.php | 33 +++++++ dcat_admin_ide_helper.php | 4 + resources/lang/zh_CN/product-buynote.php | 14 +++ resources/lang/zh_CN/product-spu.php | 1 + 11 files changed, 175 insertions(+) create mode 100644 app/Admin/Controllers/ProductBuynoteController.php create mode 100644 app/Admin/Repositories/ProductBuynote.php create mode 100644 app/Models/ProductBuynote.php create mode 100644 database/migrations/2021_11_30_104546_create_product_buynotes_table.php create mode 100644 resources/lang/zh_CN/product-buynote.php diff --git a/app/Admin/Controllers/ProductBuynoteController.php b/app/Admin/Controllers/ProductBuynoteController.php new file mode 100644 index 00000000..fe18e4c9 --- /dev/null +++ b/app/Admin/Controllers/ProductBuynoteController.php @@ -0,0 +1,85 @@ +column('id')->sortable(); + $grid->column('name'); + // $grid->column('content'); + $grid->column('created_at')->sortable(); + + //排序 + $grid->model()->orderBy('created_at', 'desc'); + + /** 操作 **/ + //新增 + if (Admin::user()->can('dcat.admin.product_buynotes.create')) { + $grid->disableCreateButton(false); + // $grid->enableDialogCreate(); + } + + //删除以及自定义操作 + $grid->actions(function (Grid\Displayers\Actions $actions) { + $actions->disableEdit(Admin::user()->cannot('dcat.admin.product_buynotes.edit')); + $actions->disableDelete(Admin::user()->cannot('dcat.admin.product_buynotes.destroy')); + }); + + /** 查询 **/ + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + $filter->like('name')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new ProductBuynote(), function (Show $show) { + $show->field('id'); + $show->field('name'); + $show->field('content'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new ProductBuynote(), function (Form $form) { + $form->display('id'); + $form->text('name')->required(); + $form->editor('content'); + + $form->display('created_at'); + $form->display('updated_at'); + }); + } +} diff --git a/app/Admin/Controllers/ProductSpuController.php b/app/Admin/Controllers/ProductSpuController.php index eaf53f03..ebe8787b 100644 --- a/app/Admin/Controllers/ProductSpuController.php +++ b/app/Admin/Controllers/ProductSpuController.php @@ -3,6 +3,7 @@ namespace App\Admin\Controllers; use App\Admin\Repositories\ProductSpu; +use App\Models\ProductBuynote; use App\Models\ProductFeature; use App\Models\ProductGroup; use Carbon\Carbon; @@ -121,6 +122,7 @@ class ProductSpuController extends AdminController return array_column($v, 'id'); }); $form->editor('description'); + $form->select('buynot_id')->options(ProductBuynote::all()->pluck('name', 'id')); $form->number('weight'); $form->currency('sell_price')->symbol('¥')->default(0); diff --git a/app/Admin/Repositories/ProductBuynote.php b/app/Admin/Repositories/ProductBuynote.php new file mode 100644 index 00000000..f068b0d7 --- /dev/null +++ b/app/Admin/Repositories/ProductBuynote.php @@ -0,0 +1,16 @@ +names('product_features'); + $router->resource('product-buynotes', 'ProductBuynoteController')->only([ + 'index', 'create', 'store', 'edit', 'update', 'destroy', + ])->names('product_buynotes'); + $router->resource('product-spus', 'ProductSpuController')->names('product_spus'); diff --git a/app/Models/ProductBuynote.php b/app/Models/ProductBuynote.php new file mode 100644 index 00000000..47362472 --- /dev/null +++ b/app/Models/ProductBuynote.php @@ -0,0 +1,13 @@ +integer('stock')->unsigned()->default(0)->comment('库存'); $table->integer('sales')->unsigned()->default(0)->comment('销量'); $table->timestamp('release_at')->nullable()->comment('上架时间'); + $table->unsignedBigInteger('buynote_id')->nullable()->comment('购买须知模板ID'); $table->timestamps(); $table->index('category_id'); diff --git a/database/migrations/2021_11_24_120232_create_product_skus_table.php b/database/migrations/2021_11_24_120232_create_product_skus_table.php index 3cc65019..56541b04 100644 --- a/database/migrations/2021_11_24_120232_create_product_skus_table.php +++ b/database/migrations/2021_11_24_120232_create_product_skus_table.php @@ -33,6 +33,8 @@ class CreateProductSkusTable extends Migration $table->integer('stock')->unsigned()->default(0)->comment('库存'); $table->integer('sales')->unsigned()->default(0)->comment('销量'); $table->timestamp('release_at')->nullable()->comment('上架时间'); + $table->tinyInteger('verify_state')->unsigned()->default(0)->comment('审核状态:0正常,1处理中,2处理失败'); + $table->unsignedBigInteger('buynote_id')->nullable()->comment('购买须知模板ID'); $table->timestamps(); $table->index('spu_id'); diff --git a/database/migrations/2021_11_30_104546_create_product_buynotes_table.php b/database/migrations/2021_11_30_104546_create_product_buynotes_table.php new file mode 100644 index 00000000..83cfd6f3 --- /dev/null +++ b/database/migrations/2021_11_30_104546_create_product_buynotes_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('name')->comment('模板名称'); + $table->text('content')->nullable()->comment('模板内容'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('product_buynotes'); + } +} diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index bb42dbbf..80306399 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -79,6 +79,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection stock * @property Grid\Column|Collection sales * @property Grid\Column|Collection release_at + * @property Grid\Column|Collection feature_id * @property Grid\Column|Collection product_spu_id * @property Grid\Column|Collection items * @property Grid\Column|Collection is_sell @@ -167,6 +168,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection stock(string $label = null) * @method Grid\Column|Collection sales(string $label = null) * @method Grid\Column|Collection release_at(string $label = null) + * @method Grid\Column|Collection feature_id(string $label = null) * @method Grid\Column|Collection product_spu_id(string $label = null) * @method Grid\Column|Collection items(string $label = null) * @method Grid\Column|Collection is_sell(string $label = null) @@ -260,6 +262,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection stock * @property Show\Field|Collection sales * @property Show\Field|Collection release_at + * @property Show\Field|Collection feature_id * @property Show\Field|Collection product_spu_id * @property Show\Field|Collection items * @property Show\Field|Collection is_sell @@ -348,6 +351,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection stock(string $label = null) * @method Show\Field|Collection sales(string $label = null) * @method Show\Field|Collection release_at(string $label = null) + * @method Show\Field|Collection feature_id(string $label = null) * @method Show\Field|Collection product_spu_id(string $label = null) * @method Show\Field|Collection items(string $label = null) * @method Show\Field|Collection is_sell(string $label = null) diff --git a/resources/lang/zh_CN/product-buynote.php b/resources/lang/zh_CN/product-buynote.php new file mode 100644 index 00000000..e4b07f63 --- /dev/null +++ b/resources/lang/zh_CN/product-buynote.php @@ -0,0 +1,14 @@ + [ + 'ProductBuynote' => '商品购买须知', + 'product-buynotes' => '商品购买须知', + ], + 'fields' => [ + 'name' => '模板名称', + 'content' => '模板内容', + ], + 'options' => [ + ], +]; diff --git a/resources/lang/zh_CN/product-spu.php b/resources/lang/zh_CN/product-spu.php index 7b0c87b0..154a4997 100644 --- a/resources/lang/zh_CN/product-spu.php +++ b/resources/lang/zh_CN/product-spu.php @@ -15,6 +15,7 @@ return [ 'images' => '商品图片', 'features' => '商品特点', 'description' => '商品详情', + 'buynot_id'=>'购买须知模板', 'sell_price' => '销售价格', 'market_price' => '市场价格', 'cost_price' => '成本价格',