4
0
Fork 0

init goods

master
panliang 2022-07-28 10:00:03 +08:00
parent ebd56dc4e8
commit 81270ebb83
8 changed files with 173 additions and 0 deletions

7
packages/goods/.gitignore vendored 100644
View File

@ -0,0 +1,7 @@
.DS_Store
phpunit.phar
/vendor
composer.phar
composer.lock
*.project
.idea/

View File

@ -0,0 +1,3 @@
# Dcat Admin Extension

View File

@ -0,0 +1,31 @@
{
"name": "peidikeji/goods",
"alias": "goods",
"description": "基础商品管理",
"type": "library",
"keywords": ["dcat-admin", "extension"],
"homepage": "https://github.com/peidikeji/goods",
"license": "MIT",
"authors": [
{
"name": "panliang",
"email": "1163816051@qq.com"
}
],
"require": {
"php": ">=7.1.0"
},
"autoload": {
"psr-4": {
"Peidikeji\\Goods\\": "src/"
}
},
"extra": {
"dcat-admin": "Peidikeji\\Goods\\GoodsServiceProvider",
"laravel": {
"providers": [
"Peidikeji\\Goods\\GoodsServiceProvider"
]
}
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Peidikeji\Goods;
use Dcat\Admin\Extend\ServiceProvider;
use Dcat\Admin\Admin;
class GoodsServiceProvider extends ServiceProvider
{
public function register()
{
//
}
public function init()
{
parent::init();
//
}
// public function settingForm()
// {
// return new Setting($this);
// }
}

View File

@ -0,0 +1,3 @@
<?php
use Illuminate\Support\Facades\Route;

View File

@ -0,0 +1,14 @@
<?php
namespace Peidikeji\Goods;
use Dcat\Admin\Extend\Setting as Form;
class Setting extends Form
{
public function form()
{
$this->text('key1')->required();
$this->text('key2')->required();
}
}

View File

@ -0,0 +1,81 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGoodsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('goods_category', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('分类名称');
$table->string('image')->nullable()->comment('封面图');
$table->string('description')->nullable()->comment('描述');
$table->unsignedBigInteger('parent_id')->default(0)->comment('父级ID');
$table->unsignedInteger('level')->default(1)->comment('层级');
$table->unsignedInteger('sort')->default(1)->comment('排序 asc');
$table->string('path')->default('-')->comment('所有的父级ID');
$table->comment('商品分类');
});
Schema::create('goods', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('category_id')->comment('所属分类, 关联 goods_category.id');
$table->string('name')->comment('商品名称');
$table->string('goods_sn')->unique()->comment('编号');
$table->string('cover_image')->nullable()->comment('封面图');
$table->json('images')->nullable()->comment('图片集');
$table->string('description')->nullable()->comment('描述');
$table->text('content')->nullable()->comment('详细');
$table->unsignedInteger('on_sale')->default(0)->comment('是否上架');
$table->unsignedInteger('stock')->default(0)->comment('库存');
$table->json('weight')->nullable()->comment('重量 {weight: 0, unit: "g"}');
$table->unsignedInteger('sold_count')->default(0)->comment('实际销量');
$table->decimal('price', 12, 2)->comment('售价');
$table->json('attr')->nullable()->comment('属性');
$table->json('spec')->nullable()->comment('规格');
$table->json('part')->nullable()->comment('配件');
$table->string('category_path');
$table->timestamps();
$table->softDeletes();
$table->foreign('category_id')->references('id')->on('goods_category');
$table->comment('商品');
});
Schema::create('goods_sku', function (Blueprint $table) {
$table->id();
$table->string('sn')->unique()->comment('货号');
$table->unsignedBigInteger('goods_id')->comment('所属商品, 关联 goods.id');
$table->string('name')->comment('名称');
$table->decimal('price', 12, 2)->comment('价格');
$table->unsignedInteger('stock')->comment('库存');
$table->json('spec')->nullable()->comment('规格');
$table->foreign('goods_id')->references('id')->on('goods');
$table->comment('商品-SKU');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('goods_sku');
Schema::dropIfExists('goods');
Schema::dropIfExists('goods_category');
}
};

View File

@ -0,0 +1,7 @@
<?php
return [
'1.0.0' => [
'Initialize extension.',
],
];