# Dcat Admin Extension Goods Dcat-admin 商品管理 ## 安装 - 进入项目目录 - `mkdir packages && cd packages` - `git clone https://gitea.peidikeji.cn/pdkj/dcat-admin-goods.git` - `composer config repositories.peidikeji/dcat-admin-goods path ./packages/dcat-admin-goods` - `composer require peidikeji/dcat-admin-goods` - `php artisan migrate` - `php artisan vendor:publish --provider=Peidikeji\Goods\GoodsServiceProvider` ## 测试数据 - 复制文件 `database/seeders/GoodsCategorySeeder`, ``database/seeders/GoodsSeeder`` ## 后台权限 ```php $permissions = [ 'goods' => ['name' => '商品管理', 'curd' => true], 'goods_sku' => ['name' => '货品管理', 'curd' => true], 'goods_category' => ['name' => '商品分类', 'curd' => true], 'goods_brand' => ['name' => '商品品牌', 'curd' => true], 'goods_type' => ['name' => '商品类别', 'curd' => true], ]; ``` ## 后台菜单 ```php $menus = [ ['title' => '商品模块', 'icon' => 'feather icon-layers', 'uri' => '', 'permission' => ['goods', 'goods_category', 'goods_brand', 'goods_type'], 'children' => [ ['title' => '商品分类', 'icon' => '', 'uri' => '/goods-category', 'permission' => 'goods_category'], ['title' => '商品品牌', 'icon' => '', 'uri' => '/goods-brand', 'permission' => 'goods_brand'], ['title' => '商品类别', 'icon' => '', 'uri' => '/goods-type', 'permission' => 'goods_type'], ['title' => '商品管理', 'icon' => '', 'uri' => '/goods', 'permission' => 'goods', 'children' => ['import' => '导入']], ]], ]; ``` ## API接口 - [在线预览](https://www.apifox.cn/apidoc/shared-86eb60cb-ba8f-46c6-b718-f33f99de5e7d) ## 数据表 ### 商品分类: goods_category | column | type | nullable | default | comment | | - | - | - | - | - | | id | bigint | not null | - | 主键 | | name | varchar(191) | not null | - | 分类名称 | | image | varchar(191) | null | - | 分类图片 | | description | varchar(191) | null | - | 描述 | | parent_id | bigint | not null | 0 | 上级 id | | level | integer | not null | 1 | 层级 | | sort | integer | not null | 1 | 排序(asc) | | is_enable | integer | not null | 1 | 是否可用(0, 1) | | path | varchar(191) | not null | '-' | 所有上级 id(1-2-3-, -) | | created_at | timestamp | null | - | 创建时间 | | updated_at | timestamp | null | - | 更新时间 | ### 商品类别: goods_type | column | type | nullable | default | comment | | - | - | - | - | - | | id | bigint | not null | - | 主键 | | name | varchar(191) | not null | - | 名称 | | attr | json | null | - | 属性展示 | | spec | json | null | - | 规格筛选 | | part | json | null | - | 配件多选 | > goods_type.attr 存储格式 ```json [ {"name": "主体", "values": ["入网型号", "上市年份"]}, {"name": "基本信息", "values": ["尺寸", "颜色", "CPU型号", "重量"]} ] ``` > goods_type.spec 存储格式 ```json [ {"name": "颜色", "values": ["红色", "白色", "灰色"]}, {"name": "版本", "values": ["128G", "256G", "512G", "1TB"]} ] ``` > goods_type.part 存储格式 ```json [ {"name": "配件", "values": ["耳机", "快充", "手机壳"]}, ] ``` ### 商品品牌: goods_brand | column | type | nullable | default | comment | | - | - | - | - | - | | id | bigint | not null | - | 主键 | | name | varchar(191) | not null | - | 名称 | | image | varchar(191) | not null | - | 图标 | ### 商品: goods | column | type | nullable | default | comment | | - | - | - | - | - | | id | bigint | not null | - | 主键 | | category_id | bigint | not null | - | 分类 id | | merchant_id | bigint | not null | - | 商户 id | | type_id | bigint | not null | - | 类别 id | | brand_id | bigint | not null | - | 品牌 id | | name | varchar(191) | not null | - | 商品名称 | | description | varchar(191) | not null | - | 商品名称 | | goods_sn | varchar(191) | null | - | 编号 | | cover_image | varchar(191) | not null | - | 封面图 | | images | json | null | - | 图片集 | | content | json | null | - | 内容 | | on_sale | integer | not null | 0 | 是否上架 | | is_recommend | integer | not null | 0 | 是否推荐 | | stock | integer | not null | 0 | 库存 | | sold_count | integer | not null | 0 | 销量 | | price | decimal(12, 2) | not null | 0 | 售价 | | attr | json | null | - | 属性介绍 | | spec | json | null | - | 规格加价(单选) | | part | json | null | - | 配件加购(多选) | | created_at | timestamp | null | - | 创建时间 | | updated_at | timestamp | null | - | 更新时间 | > goods.attr 存储格式 ```json [ { "name": "主体", "values": [ {"name": "入网型号", "value": "5G"}, {"name": "上市年份", "value": "2020"} ] } ] ``` > goods.spec 存储格式 ```json [ { "name": "颜色", "values": [ {"name": "红色", "value": 0}, {"name": "白色", "value": 0}, {"name": "灰色", "value": 0} ] }, { "name": "内存", "values": [ {"name": "128G", "value": 0}, {"name": "256G", "value": 1000}, {"name": "1TB", "value": 3000} ] } ] ``` > goods.part 存储格式 ```json [ { "name": "套餐", "values": [ {"name": "套餐1", "value": 100}, {"name": "套餐2", "value": 200}, {"name": "套餐3", "value": 300} ] } ] ``` ### 商品SKU: goods_sku | column | type | nullable | default | comment | | - | - | - | - | - | | id | bigint | not null | - | 主键 | | sn | varchar(191) | null | - | 货号 | | goods_id | bigint | not null | - | 关联商品 | | name | varchar(191) | not null | - | 名称 | | on_sale | integer | not null | 0 | 是否上架 | | stock | integer | not null | 0 | 库存 | | sold_count | integer | not null | 0 | 销量 | | spec | json | null | - | 规格 | > goods.spec ```json [ {"name": "颜色", "value": "白色"} {"name": "内存", "value": "128G"} ] ```