From 94b19f23f16652accd8c2c1b7c1113f55b94e7cf Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Wed, 17 Aug 2022 21:44:11 +0800 Subject: [PATCH 01/47] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8F=9C=E5=8D=95ICON?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/mycms/config-admin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/mycms/config-admin.js b/public/mycms/config-admin.js index 0ac4d836..9714b685 100644 --- a/public/mycms/config-admin.js +++ b/public/mycms/config-admin.js @@ -27,7 +27,7 @@ require.config({ // 路径配置信息 var PATH_CONFIG = { - iconLess: BASE_URL + "plugs/font-awesome-4.7.0/less/variables.less", + iconLess: BASE_URL + "/mycms/plugs/font-awesome-4.7.0/less/variables.less", }; window.PATH_CONFIG = PATH_CONFIG; -- Gitee From e13cd28513740f7113820d9647715386ff96fe16 Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Thu, 18 Aug 2022 16:16:37 +0800 Subject: [PATCH 02/47] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=80=BB=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/MyAdminController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/MyAdminController.php b/app/Http/Controllers/MyAdminController.php index 12ea87d7..03e06913 100644 --- a/app/Http/Controllers/MyAdminController.php +++ b/app/Http/Controllers/MyAdminController.php @@ -19,7 +19,6 @@ class MyAdminController extends MyController public $with = []; - public function __call($method, $parameters) { if (method_exists($this, "{$method}Action")) { @@ -53,6 +52,7 @@ class MyAdminController extends MyController if (request()->ajax() && request()->wantsJson()) { $data = $this->getModel()::with($this->with) + ->where($this->getIndexWhere()) ->orderBy('id', 'desc') ->paginate($this->request('limit', 'intval')) ->toArray(); @@ -63,6 +63,16 @@ class MyAdminController extends MyController return $this->view($this->view . 'index'); } + + /** + * @return array + */ + public function getIndexWhere(): array + { + return []; + } + + /** * 创建页 */ -- Gitee From 0932699e7f48c038343c3b5288e42eb455b1f919 Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Fri, 19 Aug 2022 15:51:38 +0800 Subject: [PATCH 03/47] =?UTF-8?q?=E6=B3=A8=E9=87=8A=20=E7=A9=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E8=BD=ACnull=20=E4=B8=AD=E9=97=B4=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 2055831a..7acd0107 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -21,7 +21,7 @@ class Kernel extends HttpKernel \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, - \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + //\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Expand\Addon\Middlewares\RouteBehavior::class ]; -- Gitee From dcc92a2258017529c76b22904c3379614697ec07 Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Mon, 22 Aug 2022 23:05:42 +0800 Subject: [PATCH 04/47] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=95=B0=E6=8D=AE=E5=A1=AB=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/seeders/DatabaseSeeder.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index e52970b9..372435e6 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -8,6 +8,7 @@ use Modules\System\Database\Seeders\SystemAdminSeeder; use Modules\System\Database\Seeders\SystemConfigSeeder; use Modules\System\Database\Seeders\SystemMenuSeeder; use Modules\System\Database\Seeders\SystemRoleSeeder; +use Nwidart\Modules\Facades\Module; class DatabaseSeeder extends Seeder { @@ -23,5 +24,25 @@ class DatabaseSeeder extends Seeder $this->call(SystemMenuSeeder::class); $this->call(SystemRoleSeeder::class); $this->call(RegionSeeder::class); + + $this->runModuleSeeder(); + } + + /** + * 运行模块自定义数据填充 + */ + protected function runModuleSeeder() + { + $modules = Module::allEnabled(); + + foreach ($modules as $module) { + + $name = $module->getName(); + + if (file_exists(module_path($name,"Database/Seeders/{$name}DatabaseSeeder.php"))) { + + $this->call("Modules\\{$name}\Database\Seeders\\{$name}DatabaseSeeder"); + } + } } } -- Gitee From 64dd56f42291dfa2824f99c05cb818c5b6e1fd2e Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Wed, 24 Aug 2022 11:51:45 +0800 Subject: [PATCH 05/47] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=95=B0=E6=8D=AE=E5=A1=AB=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/seeders/DatabaseSeeder.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 372435e6..44568b43 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -33,15 +33,16 @@ class DatabaseSeeder extends Seeder */ protected function runModuleSeeder() { - $modules = Module::allEnabled(); + $modules = json_decode(file_get_contents(base_path('modules_statuses.json')), true); - foreach ($modules as $module) { + foreach ($modules as $name => $value) { - $name = $module->getName(); + if ($value) { - if (file_exists(module_path($name,"Database/Seeders/{$name}DatabaseSeeder.php"))) { + if (file_exists(module_path($name, "Database/Seeders/{$name}DatabaseSeeder.php"))) { - $this->call("Modules\\{$name}\Database\Seeders\\{$name}DatabaseSeeder"); + $this->call("Modules\\{$name}\Database\Seeders\\{$name}DatabaseSeeder"); + } } } } -- Gitee From f9fee3ff7f11a32e701066b3c9e37611b99081f9 Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Wed, 24 Aug 2022 16:34:10 +0800 Subject: [PATCH 06/47] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=A2=9E=E5=8A=A0with?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/MyAdminController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/MyAdminController.php b/app/Http/Controllers/MyAdminController.php index 03e06913..dc330520 100644 --- a/app/Http/Controllers/MyAdminController.php +++ b/app/Http/Controllers/MyAdminController.php @@ -103,7 +103,8 @@ class MyAdminController extends MyController */ public function editAction() { - $data = $this->getModel()::find($this->request('id', 'intval')); + $data = $this->getModel()::with($this->with) + ->find($this->request('id', 'intval')); return $this->view($this->view . 'edit', compact('data')); } -- Gitee From 7f40d69ca0b48ea3d4866851b188ef178e797bab Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Wed, 24 Aug 2022 16:35:35 +0800 Subject: [PATCH 07/47] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=A2=9E=E5=8A=A0with?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/MyAdminController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/MyAdminController.php b/app/Http/Controllers/MyAdminController.php index dc330520..b5664cf7 100644 --- a/app/Http/Controllers/MyAdminController.php +++ b/app/Http/Controllers/MyAdminController.php @@ -19,6 +19,8 @@ class MyAdminController extends MyController public $with = []; + public $editWith = []; + public function __call($method, $parameters) { if (method_exists($this, "{$method}Action")) { @@ -103,7 +105,7 @@ class MyAdminController extends MyController */ public function editAction() { - $data = $this->getModel()::with($this->with) + $data = $this->getModel()::with($this->editWith) ->find($this->request('id', 'intval')); return $this->view($this->view . 'edit', compact('data')); -- Gitee From 4aab3fa4ce0e98d1b3dc259b2d0454be7991f85b Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Thu, 25 Aug 2022 09:50:12 +0800 Subject: [PATCH 08/47] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E8=AF=AD=E8=A8=80=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/lang/en/installer_messages.php | 2 +- resources/lang/fr/installer_messages.php | 2 +- resources/lang/zh-CN/installer_messages.php | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/lang/en/installer_messages.php b/resources/lang/en/installer_messages.php index 04718332..bd485930 100644 --- a/resources/lang/en/installer_messages.php +++ b/resources/lang/en/installer_messages.php @@ -188,7 +188,7 @@ return [ 'title' => 'Installation Finished', 'templateTitle' => 'Installation Finished', 'finished' => 'Application has been successfully installed.', - 'migration' => 'Migration & Seed Console Output:', + 'migration' => 'Migration & Seed Console Output:', 'console' => 'Application Console Output:', 'log' => 'Installation Log Entry:', 'env' => 'Final .env File:', diff --git a/resources/lang/fr/installer_messages.php b/resources/lang/fr/installer_messages.php index 01cba9b4..48eba47d 100644 --- a/resources/lang/fr/installer_messages.php +++ b/resources/lang/fr/installer_messages.php @@ -177,7 +177,7 @@ return [ 'title' => 'Terminé', 'templateTitle' => 'Installation Terminé', 'finished' => 'L’application a été installée avec succès.', - 'migration' => 'Migration & Seed Console Output:', + 'migration' => 'Migration & Seed Console Output:', 'console' => 'Application Console Output:', 'log' => 'Installation Log Entry:', 'env' => 'Final .env File:', diff --git a/resources/lang/zh-CN/installer_messages.php b/resources/lang/zh-CN/installer_messages.php index 7f3a023d..93d1f660 100644 --- a/resources/lang/zh-CN/installer_messages.php +++ b/resources/lang/zh-CN/installer_messages.php @@ -172,8 +172,10 @@ return [ * */ 'final' => [ - 'title' => '完成', + 'title' => '安装完成', + 'templateTitle' => '安装完成', 'finished' => '应用已成功安装.', 'exit' => '回到首页', + ], ]; -- Gitee From af934eb33cb9cb03e2cef343f6e69d561574d1ed Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Fri, 26 Aug 2022 16:50:36 +0800 Subject: [PATCH 09/47] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=86=E7=B1=BB=20&?= =?UTF-8?q?=20=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BC=A9=E7=95=A5=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...8_26_164324_AlterArticleCategoryAddImg.php | 32 +++++++++++++++++++ .../Http/Requests/ArticleCategoryRequest.php | 1 + .../views/admin/category/create.blade.php | 11 +++++++ .../views/admin/category/edit.blade.php | 11 +++++++ ..._08_26_164247_AlterGoodsCategoryAddImg.php | 32 +++++++++++++++++++ .../Shop/Http/Requests/CategoryRequest.php | 1 + .../views/admin/category/create.blade.php | 11 +++++++ .../views/admin/category/edit.blade.php | 11 +++++++ 8 files changed, 110 insertions(+) create mode 100644 Modules/Cms/Database/Migrations/2022_08_26_164324_AlterArticleCategoryAddImg.php create mode 100644 Modules/Shop/Database/Migrations/2022_08_26_164247_AlterGoodsCategoryAddImg.php diff --git a/Modules/Cms/Database/Migrations/2022_08_26_164324_AlterArticleCategoryAddImg.php b/Modules/Cms/Database/Migrations/2022_08_26_164324_AlterArticleCategoryAddImg.php new file mode 100644 index 00000000..d57b6259 --- /dev/null +++ b/Modules/Cms/Database/Migrations/2022_08_26_164324_AlterArticleCategoryAddImg.php @@ -0,0 +1,32 @@ +string('img')->after('description')->default(''); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('my_article_category', function (Blueprint $table) { + $table->dropColumn('img'); + }); + } +} diff --git a/Modules/Cms/Http/Requests/ArticleCategoryRequest.php b/Modules/Cms/Http/Requests/ArticleCategoryRequest.php index 8adb54da..fe730b17 100644 --- a/Modules/Cms/Http/Requests/ArticleCategoryRequest.php +++ b/Modules/Cms/Http/Requests/ArticleCategoryRequest.php @@ -19,6 +19,7 @@ class ArticleCategoryRequest extends MyRequest 'pid' => ['required'], 'name' => ['required','max:255'], 'description' => ['max:255'], + 'img' => [], ]; } diff --git a/Modules/Cms/Resources/views/admin/category/create.blade.php b/Modules/Cms/Resources/views/admin/category/create.blade.php index ddcbd1e8..4aac12e9 100644 --- a/Modules/Cms/Resources/views/admin/category/create.blade.php +++ b/Modules/Cms/Resources/views/admin/category/create.blade.php @@ -55,6 +55,17 @@ @endif +
+ +
+ +
+ 上传 +
+
+
+
diff --git a/Modules/Cms/Resources/views/admin/category/edit.blade.php b/Modules/Cms/Resources/views/admin/category/edit.blade.php index f69224f7..3c179b14 100644 --- a/Modules/Cms/Resources/views/admin/category/edit.blade.php +++ b/Modules/Cms/Resources/views/admin/category/edit.blade.php @@ -54,6 +54,17 @@
@endif +
+ +
+ +
+ 上传 +
+
+
+
diff --git a/Modules/Shop/Database/Migrations/2022_08_26_164247_AlterGoodsCategoryAddImg.php b/Modules/Shop/Database/Migrations/2022_08_26_164247_AlterGoodsCategoryAddImg.php new file mode 100644 index 00000000..5906ccfc --- /dev/null +++ b/Modules/Shop/Database/Migrations/2022_08_26_164247_AlterGoodsCategoryAddImg.php @@ -0,0 +1,32 @@ +string('img')->after('description')->default(''); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('my_shop_goods_category', function (Blueprint $table) { + $table->dropColumn('img'); + }); + } +} diff --git a/Modules/Shop/Http/Requests/CategoryRequest.php b/Modules/Shop/Http/Requests/CategoryRequest.php index c5af0d8b..9a02a151 100644 --- a/Modules/Shop/Http/Requests/CategoryRequest.php +++ b/Modules/Shop/Http/Requests/CategoryRequest.php @@ -19,6 +19,7 @@ class CategoryRequest extends MyRequest 'pid' => ['required'], 'name' => ['required','max:255'], 'description' => ['max:255'], + 'img' => [], ]; } diff --git a/Modules/Shop/Resources/views/admin/category/create.blade.php b/Modules/Shop/Resources/views/admin/category/create.blade.php index e7a2fdcf..e16aca25 100644 --- a/Modules/Shop/Resources/views/admin/category/create.blade.php +++ b/Modules/Shop/Resources/views/admin/category/create.blade.php @@ -42,6 +42,17 @@
+
+ +
+ +
+ 上传 +
+
+
+
diff --git a/Modules/Shop/Resources/views/admin/category/edit.blade.php b/Modules/Shop/Resources/views/admin/category/edit.blade.php index f0364bc9..7eebc986 100644 --- a/Modules/Shop/Resources/views/admin/category/edit.blade.php +++ b/Modules/Shop/Resources/views/admin/category/edit.blade.php @@ -43,6 +43,17 @@
+
+ +
+ +
+ 上传 +
+
+
+
-- Gitee From 508dce17153a4618027bf922b99b0f4c584ba24f Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Sat, 27 Aug 2022 18:05:45 +0800 Subject: [PATCH 10/47] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/ArticleController.php | 4 +-- .../Controllers/Admin/GoodsController.php | 4 +-- ...22_08_27_172122_AlterSystemAttrAddType.php | 32 +++++++++++++++++++ Modules/System/Http/Requests/AttrRequest.php | 3 ++ .../views/admin/attr/create.blade.php | 10 ++++++ .../Resources/views/admin/attr/edit.blade.php | 10 ++++++ Modules/System/Service/SystemService.php | 5 +-- public/mycms/admin/js/system.attr.js | 1 + 8 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 Modules/System/Database/Migrations/2022_08_27_172122_AlterSystemAttrAddType.php diff --git a/Modules/Cms/Http/Controllers/Admin/ArticleController.php b/Modules/Cms/Http/Controllers/Admin/ArticleController.php index 5fdaaa15..7be15ba0 100644 --- a/Modules/Cms/Http/Controllers/Admin/ArticleController.php +++ b/Modules/Cms/Http/Controllers/Admin/ArticleController.php @@ -42,7 +42,7 @@ class ArticleController extends MyController public function create() { $categories = app('cms')->categoryTreeForSelect(); - $attributes = app('system')->attributes(); + $attributes = app('system')->attributes('cms'); return $this->view('admin.article.create', compact('categories', 'attributes')); } @@ -85,7 +85,7 @@ class ArticleController extends MyController $article = Article::find($id); $tags = article_tags_text($id); - $attributes = app('system')->attributes(); + $attributes = app('system')->attributes('cms'); $meta = app('cms')->articleMeta($id, array_merge( ['short_title'], diff --git a/Modules/Shop/Http/Controllers/Admin/GoodsController.php b/Modules/Shop/Http/Controllers/Admin/GoodsController.php index eb8aba73..1e2aca7b 100644 --- a/Modules/Shop/Http/Controllers/Admin/GoodsController.php +++ b/Modules/Shop/Http/Controllers/Admin/GoodsController.php @@ -43,7 +43,7 @@ class GoodsController extends MyController public function create() { $categories = app('store')->categoryTreeForSelect(); - $attributes = app('system')->attributes(); + $attributes = app('system')->attributes('shop'); return $this->view('admin.goods.create', compact('categories', 'attributes')); } @@ -76,7 +76,7 @@ class GoodsController extends MyController $goods = Goods::find($id); $goods && $goods->goods_albums = app('store')->goodsAlbums($id, true); - $attributes = app('system')->attributes(); + $attributes = app('system')->attributes('shop'); $meta = app('store')->goodsMeta($id, array_merge( diff --git a/Modules/System/Database/Migrations/2022_08_27_172122_AlterSystemAttrAddType.php b/Modules/System/Database/Migrations/2022_08_27_172122_AlterSystemAttrAddType.php new file mode 100644 index 00000000..eaea9997 --- /dev/null +++ b/Modules/System/Database/Migrations/2022_08_27_172122_AlterSystemAttrAddType.php @@ -0,0 +1,32 @@ +string('type', 15)->after('name')->default("cms"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('my_system_attr', function (Blueprint $table) { + $table->dropColumn('type'); + }); + } +} diff --git a/Modules/System/Http/Requests/AttrRequest.php b/Modules/System/Http/Requests/AttrRequest.php index 4762111b..ea9ee682 100644 --- a/Modules/System/Http/Requests/AttrRequest.php +++ b/Modules/System/Http/Requests/AttrRequest.php @@ -16,6 +16,7 @@ class AttrRequest extends MyRequest public function rules(): array { return [ + 'type' => ['required'], 'name' => ['required', 'max:255'], 'ident' => ['required', 'max:255'], ]; @@ -24,6 +25,8 @@ class AttrRequest extends MyRequest public function messages(): array { return [ + 'type.required' => '分类为必选项', + 'name.required' => '名称不能为空', 'name.max' => '名称长度错误', diff --git a/Modules/System/Resources/views/admin/attr/create.blade.php b/Modules/System/Resources/views/admin/attr/create.blade.php index 59b0c3a8..6825af1c 100644 --- a/Modules/System/Resources/views/admin/attr/create.blade.php +++ b/Modules/System/Resources/views/admin/attr/create.blade.php @@ -3,6 +3,16 @@
+
+ +
+ +
+
+
diff --git a/Modules/System/Resources/views/admin/attr/edit.blade.php b/Modules/System/Resources/views/admin/attr/edit.blade.php index 5801fea2..a2c21d61 100644 --- a/Modules/System/Resources/views/admin/attr/edit.blade.php +++ b/Modules/System/Resources/views/admin/attr/edit.blade.php @@ -3,6 +3,16 @@
+
+ +
+ +
+
+
diff --git a/Modules/System/Service/SystemService.php b/Modules/System/Service/SystemService.php index 4540e5bf..dd14fdf0 100644 --- a/Modules/System/Service/SystemService.php +++ b/Modules/System/Service/SystemService.php @@ -75,11 +75,12 @@ class SystemService extends MyService /** * 获取系统辅助属性 + * @param $type * @return array */ - public function attributes(): array + public function attributes($type): array { - return Attr::get()->toArray(); + return Attr::where('type', $type)->get()->toArray(); } /** diff --git a/public/mycms/admin/js/system.attr.js b/public/mycms/admin/js/system.attr.js index 3e1b5fd4..190c7daf 100644 --- a/public/mycms/admin/js/system.attr.js +++ b/public/mycms/admin/js/system.attr.js @@ -20,6 +20,7 @@ define(["jquery", "easy-admin"], function ($, ea) { {field: 'id', width: 80, title: 'ID'}, {field: 'ident', minWidth: 80, title: '标识'}, {field: 'name', minWidth: 80, title: '名称'}, + {field: 'type', minWidth: 80, title: '类型'}, {field: 'created_at', minWidth: 120, title: '创建时间'}, {field: 'updated_at', minWidth: 120, title: '更新时间'}, { -- Gitee From 4ab425d4cbd1d2b70924e451c04de54ad1be876a Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Mon, 29 Aug 2022 22:52:28 +0800 Subject: [PATCH 11/47] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=20&?= =?UTF-8?q?=20=E5=95=86=E5=93=81=E8=AF=84=E8=AE=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022_08_29_222930_CreateMyGoodsSpec.php | 38 ++++++++++++++++++ ...22_08_29_222937_CreateMyGoodsSpecValue.php | 37 ++++++++++++++++++ ...022_08_29_223530_CreateMyGoodsSpecItem.php | 34 ++++++++++++++++ ...2022_08_29_224533_CreateMyGoodsComment.php | 39 +++++++++++++++++++ ...9_225010_CreateMyGoodsCommentResources.php | 35 +++++++++++++++++ 5 files changed, 183 insertions(+) create mode 100644 Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php create mode 100644 Modules/Shop/Database/Migrations/2022_08_29_222937_CreateMyGoodsSpecValue.php create mode 100644 Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php create mode 100644 Modules/Shop/Database/Migrations/2022_08_29_224533_CreateMyGoodsComment.php create mode 100644 Modules/Shop/Database/Migrations/2022_08_29_225010_CreateMyGoodsCommentResources.php diff --git a/Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php b/Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php new file mode 100644 index 00000000..0b8dfc74 --- /dev/null +++ b/Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php @@ -0,0 +1,38 @@ +id(); + $table->integer('goods_id')->index(); + $table->string('spec_name')->default(''); + $table->string('spec_key')->default(''); + $table->integer('stock')->default('0'); + $table->decimal('market_price', 10)->default('0'); + $table->decimal('shop_price', 10)->default('0'); + $table->timestamps(); + $table->engine = 'InnoDB'; + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('my_shop_goods_spec'); + } +} diff --git a/Modules/Shop/Database/Migrations/2022_08_29_222937_CreateMyGoodsSpecValue.php b/Modules/Shop/Database/Migrations/2022_08_29_222937_CreateMyGoodsSpecValue.php new file mode 100644 index 00000000..66f08a54 --- /dev/null +++ b/Modules/Shop/Database/Migrations/2022_08_29_222937_CreateMyGoodsSpecValue.php @@ -0,0 +1,37 @@ +id(); + $table->integer('goods_id'); + $table->integer('spec_id'); + $table->string('value')->default(''); + $table->timestamps(); + $table->engine = 'InnoDB'; + + $table->index(['goods_id', 'spec_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('my_shop_goods_spec_value'); + } +} diff --git a/Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php b/Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php new file mode 100644 index 00000000..1a6a803f --- /dev/null +++ b/Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php @@ -0,0 +1,34 @@ +id(); + $table->integer('goods_id')->index(); + $table->string('name')->default(''); + $table->timestamps(); + $table->engine = 'InnoDB'; + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('my_shop_goods_spec_item'); + } +} diff --git a/Modules/Shop/Database/Migrations/2022_08_29_224533_CreateMyGoodsComment.php b/Modules/Shop/Database/Migrations/2022_08_29_224533_CreateMyGoodsComment.php new file mode 100644 index 00000000..25664c58 --- /dev/null +++ b/Modules/Shop/Database/Migrations/2022_08_29_224533_CreateMyGoodsComment.php @@ -0,0 +1,39 @@ +id(); + $table->integer('goods_id')->index(); + $table->integer('order_id'); + $table->integer('user_id'); + $table->integer('star'); + $table->string('spec_name')->default(''); + $table->text('content'); + $table->text('reply'); + $table->timestamps(); + $table->engine = 'InnoDB'; + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('my_shop_goods_comment'); + } +} diff --git a/Modules/Shop/Database/Migrations/2022_08_29_225010_CreateMyGoodsCommentResources.php b/Modules/Shop/Database/Migrations/2022_08_29_225010_CreateMyGoodsCommentResources.php new file mode 100644 index 00000000..b1221c0f --- /dev/null +++ b/Modules/Shop/Database/Migrations/2022_08_29_225010_CreateMyGoodsCommentResources.php @@ -0,0 +1,35 @@ +id(); + $table->integer('comment_id')->index(); + $table->string('type')->default(''); + $table->string('path')->default(''); + $table->timestamps(); + $table->engine = 'InnoDB'; + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('my_shop_goods_comment_resources'); + } +} -- Gitee From d6a23da9d431b78921107c689643181c9176be3d Mon Sep 17 00:00:00 2001 From: zhangbang <386654667@qq.com> Date: Tue, 30 Aug 2022 17:20:35 +0800 Subject: [PATCH 12/47] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=20&=20=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/admin/article/create.blade.php | 2 +- .../views/admin/article/edit.blade.php | 2 +- .../views/admin/category/create.blade.php | 2 +- .../views/admin/category/edit.blade.php | 2 +- .../2022_08_29_222930_CreateMyGoodsSpec.php | 1 + ...022_08_29_223530_CreateMyGoodsSpecItem.php | 1 + .../Controllers/Admin/GoodsController.php | 182 +++++++++++++++++- Modules/Shop/Models/GoodsSpecItemModel.php | 10 + Modules/Shop/Models/GoodsSpecModel.php | 10 + Modules/Shop/Models/GoodsSpecValueModel.php | 10 + .../views/admin/category/create.blade.php | 2 +- .../views/admin/category/edit.blade.php | 2 +- .../views/admin/goods/create.blade.php | 86 ++++++++- .../views/admin/goods/edit.blade.php | 84 +++++++- public/mycms/admin/js/shop.goods.js | 137 +++++++++++++ 15 files changed, 524 insertions(+), 9 deletions(-) create mode 100644 Modules/Shop/Models/GoodsSpecItemModel.php create mode 100644 Modules/Shop/Models/GoodsSpecModel.php create mode 100644 Modules/Shop/Models/GoodsSpecValueModel.php diff --git a/Modules/Cms/Resources/views/admin/article/create.blade.php b/Modules/Cms/Resources/views/admin/article/create.blade.php index 09fc73d8..d372af0b 100644 --- a/Modules/Cms/Resources/views/admin/article/create.blade.php +++ b/Modules/Cms/Resources/views/admin/article/create.blade.php @@ -5,7 +5,7 @@
  • 基本信息
  • -
  • 拓展配置
  • +
  • 自定义配置
diff --git a/Modules/Cms/Resources/views/admin/article/edit.blade.php b/Modules/Cms/Resources/views/admin/article/edit.blade.php index 08be54aa..33902433 100644 --- a/Modules/Cms/Resources/views/admin/article/edit.blade.php +++ b/Modules/Cms/Resources/views/admin/article/edit.blade.php @@ -5,7 +5,7 @@
  • 基本信息
  • -
  • 拓展配置
  • +
  • 自定义配置
diff --git a/Modules/Cms/Resources/views/admin/category/create.blade.php b/Modules/Cms/Resources/views/admin/category/create.blade.php index 4aac12e9..8f298458 100644 --- a/Modules/Cms/Resources/views/admin/category/create.blade.php +++ b/Modules/Cms/Resources/views/admin/category/create.blade.php @@ -6,7 +6,7 @@
  • 基本信息
  • -
  • 拓展配置
  • +
  • 自定义配置
diff --git a/Modules/Cms/Resources/views/admin/category/edit.blade.php b/Modules/Cms/Resources/views/admin/category/edit.blade.php index 3c179b14..dda39413 100644 --- a/Modules/Cms/Resources/views/admin/category/edit.blade.php +++ b/Modules/Cms/Resources/views/admin/category/edit.blade.php @@ -6,7 +6,7 @@
  • 基本信息
  • -
  • 拓展配置
  • +
  • 自定义配置
diff --git a/Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php b/Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php index 0b8dfc74..99c0d808 100644 --- a/Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php +++ b/Modules/Shop/Database/Migrations/2022_08_29_222930_CreateMyGoodsSpec.php @@ -19,6 +19,7 @@ class CreateMyGoodsSpec extends Migration $table->string('spec_name')->default(''); $table->string('spec_key')->default(''); $table->integer('stock')->default('0'); + $table->string('img')->default(''); $table->decimal('market_price', 10)->default('0'); $table->decimal('shop_price', 10)->default('0'); $table->timestamps(); diff --git a/Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php b/Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php index 1a6a803f..55510995 100644 --- a/Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php +++ b/Modules/Shop/Database/Migrations/2022_08_29_223530_CreateMyGoodsSpecItem.php @@ -17,6 +17,7 @@ class CreateMyGoodsSpecItem extends Migration $table->id(); $table->integer('goods_id')->index(); $table->string('name')->default(''); + $table->text('values'); $table->timestamps(); $table->engine = 'InnoDB'; }); diff --git a/Modules/Shop/Http/Controllers/Admin/GoodsController.php b/Modules/Shop/Http/Controllers/Admin/GoodsController.php index 1e2aca7b..ef686d37 100644 --- a/Modules/Shop/Http/Controllers/Admin/GoodsController.php +++ b/Modules/Shop/Http/Controllers/Admin/GoodsController.php @@ -11,10 +11,17 @@ use Modules\Shop\Models\Goods; use Modules\Shop\Models\GoodsAlbums; use Modules\Shop\Models\GoodsCategory; use Modules\Shop\Models\GoodsMeta; +use Modules\Shop\Models\GoodsSpecItemModel; +use Modules\Shop\Models\GoodsSpecModel; +use Modules\Shop\Models\GoodsSpecValueModel; class GoodsController extends MyController { + protected $spec = []; + + protected $specText = []; + public function index(Request $request) { if ($request->ajax() && $request->wantsJson()) { @@ -60,6 +67,7 @@ class GoodsController extends MyController $this->updateMeta($goods->id); $this->updateAlbums($goods->id); + $this->updateSpec($goods->id); } return $this->result($result); @@ -85,7 +93,30 @@ class GoodsController extends MyController ) ); - return $this->view('admin.goods.edit', compact('categories', 'goods', 'attributes', 'meta')); + $specItems = GoodsSpecItemModel::where('goods_id', $id)->get(); + + $specArray = []; + $specs = GoodsSpecModel::where('goods_id', $id)->get(); + + foreach ($specs as $spec) { + + $specArray[] = [ + 'stock' => $spec->stock, + 'img' => $spec->img, + 'market_price' => $spec->market_price, + 'shop_price' => $spec->shop_price, + ]; + } + + return $this->view('admin.goods.edit', + compact( + 'categories', + 'goods', + 'attributes', + 'meta', + 'specItems', + 'specArray') + ); } /** @@ -104,6 +135,7 @@ class GoodsController extends MyController $this->updateMeta($id); $this->updateAlbums($id); + $this->updateSpec($id); } return $this->result($result); @@ -175,4 +207,152 @@ class GoodsController extends MyController } + + /** + * 更新规格 + * @param $id + * @return void + */ + protected function updateSpec($id) + { + $items = []; + $specItemArray = []; + $specValueArray = []; + $specTextArray = []; + $date = date('Y-m-d H:i:s'); + + $specItem = $this->request('spec'); + $specValue = $this->request('specVal'); + $img = $this->request('spec_img'); + $stock = $this->request('spec_stock'); + $shop_price = $this->request('spec_shop_price'); + $market_price = $this->request('spec_market_price'); + + GoodsSpecItemModel::where('goods_id', $id)->delete(); + GoodsSpecValueModel::where('goods_id', $id)->delete(); + GoodsSpecModel::where('goods_id', $id)->delete(); + + foreach ($specItem as $key => $item) { + + $value = $specValue[$key]; + + $specItemArray[] = $itemId = GoodsSpecItemModel::insert([ + 'goods_id' => $id, + 'name' => $item, + 'values' => $value, + ]); + + $specValueArray[$itemId] = []; + $values = explode("\n", $value); + + foreach ($values as $val) { + + $data = [ + 'goods_id' => $id, + 'spec_id' => $itemId, + 'value' => $val, + 'created_at' => $date, + 'updated_at' => $date, + ]; + + $specTextArray[$itemId][] = $val; + $specValueArray[$itemId][] = GoodsSpecValueModel::insert($data); + } + } + + $this->specArray($specItemArray, $specValueArray); + $this->specTextArray($specItemArray, $specTextArray); + + foreach ($this->spec as $key => $spec) { + + $items[] = [ + 'goods_id' => $id, + 'spec_name' => $this->specText[$key], + 'spec_key' => $spec, + 'stock' => $stock[$key], + 'img' => $img[$key], + 'market_price' => $market_price[$key], + 'shop_price' => $shop_price[$key], + 'created_at' => $date, + 'updated_at' => $date, + ]; + } + + GoodsSpecModel::insertAll($items); + } + + + /** + * 处理商品规格数据 + * @param $specItemArray + * @param $specValueArray + * @param int $index + * @param string $subContext + * @return void + */ + protected function specArray($specItemArray, $specValueArray, int $index = 0, string $subContext = '') + { + if (isset($specItemArray[$index])) { + + $itemId = $specItemArray[$index]; + $array = $specValueArray[$itemId]; + + foreach ($array as $item) { + + $item = $itemId . ":" . $item; + + if ($index !== 0) { + $item = $subContext . ';' . $item; + } + + if (count($specValueArray) === 1) { + $this->spec[] = $item; + } else { + if ($index === count($specValueArray) - 1 && $index !== 0) { + $this->spec[] = $item; + } else { + $this->specArray($specItemArray, $specValueArray, $index + 1, $item); + } + } + + } + } + + } + + + /** + * 处理商品规格数据 + * @param $specItemArray + * @param $specTextArray + * @param int $index + * @param string $subContext + * @return void + */ + protected function specTextArray($specItemArray, $specTextArray, int $index = 0, string $subContext = '') + { + if (isset($specItemArray[$index])) { + $itemId = $specItemArray[$index]; + $array = $specTextArray[$itemId]; + + foreach ($array as $item) { + + if ($index !== 0) { + $item = $subContext . ';' . $item; + } + + if (count($specTextArray) === 1) { + $this->specText[] = $item; + } else { + if ($index === count($specTextArray) - 1 && $index !== 0) { + $this->specText[] = $item; + } else { + $this->specTextArray($specItemArray, $specTextArray, $index + 1, $item); + } + } + + } + } + } + } diff --git a/Modules/Shop/Models/GoodsSpecItemModel.php b/Modules/Shop/Models/GoodsSpecItemModel.php new file mode 100644 index 00000000..c1602128 --- /dev/null +++ b/Modules/Shop/Models/GoodsSpecItemModel.php @@ -0,0 +1,10 @@ +
  • 基本信息
  • -
  • 拓展配置
  • +
  • 自定义配置
diff --git a/Modules/Shop/Resources/views/admin/category/edit.blade.php b/Modules/Shop/Resources/views/admin/category/edit.blade.php index 7eebc986..b294fa5e 100644 --- a/Modules/Shop/Resources/views/admin/category/edit.blade.php +++ b/Modules/Shop/Resources/views/admin/category/edit.blade.php @@ -6,7 +6,7 @@
  • 基本信息
  • -
  • 拓展配置
  • +
  • 自定义配置
diff --git a/Modules/Shop/Resources/views/admin/goods/create.blade.php b/Modules/Shop/Resources/views/admin/goods/create.blade.php index 593c0f43..592765cf 100644 --- a/Modules/Shop/Resources/views/admin/goods/create.blade.php +++ b/Modules/Shop/Resources/views/admin/goods/create.blade.php @@ -1,12 +1,18 @@ @include("system::admin.layouts._header") +
  • 基本信息
  • -
  • 拓展配置
  • +
  • 规格配置
  • +
  • 自定义配置
@@ -119,6 +125,56 @@
+
+ +
+
商品规格项[ - ]
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+ + 填写规格值,多个可换行填写 +
+
+ +
+
+
+ +
+ +
+ + + +
+
+ +
+ + + +
+ +
@@ -156,6 +212,34 @@
+ +