init goods
parent
ebd56dc4e8
commit
81270ebb83
|
|
@ -0,0 +1,7 @@
|
||||||
|
.DS_Store
|
||||||
|
phpunit.phar
|
||||||
|
/vendor
|
||||||
|
composer.phar
|
||||||
|
composer.lock
|
||||||
|
*.project
|
||||||
|
.idea/
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Dcat Admin Extension
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'1.0.0' => [
|
||||||
|
'Initialize extension.',
|
||||||
|
],
|
||||||
|
];
|
||||||
Loading…
Reference in New Issue