初始化
|
After Width: | Height: | Size: 15 KiB |
BIN
doc/商城表设计/img/01.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
doc/商城表设计/img/02.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
doc/商城表设计/img/05.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
doc/商城表设计/img/1008612.png
Normal file
|
After Width: | Height: | Size: 214 KiB |
BIN
doc/商城表设计/img/1566788134396.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
doc/商城表设计/img/24.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
doc/商城表设计/img/sku.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
doc/商城表设计/img/tk01.png
Normal file
|
After Width: | Height: | Size: 147 KiB |
BIN
doc/商城表设计/img/tk03.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
doc/商城表设计/img/优惠券数据关系设计2.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
doc/商城表设计/img/减免类型.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
doc/商城表设计/img/分组管理数据库设计2.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
doc/商城表设计/img/发布商品.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
doc/商城表设计/img/后台-商品分组.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
doc/商城表设计/img/后台-添加优惠券活动.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
doc/商城表设计/img/后台分组位置.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
doc/商城表设计/img/后台商城地址管理.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
doc/商城表设计/img/后台指定包邮条件.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
doc/商城表设计/img/后台指定区域包邮项.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
doc/商城表设计/img/后台新增商品运费模板展示.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
doc/商城表设计/img/后台新增地址.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
doc/商城表设计/img/后台新增标签.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
doc/商城表设计/img/后台满减瞒折.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
doc/商城表设计/img/后台运费模板新增.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
doc/商城表设计/img/后天满减瞒着活动规则.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
doc/商城表设计/img/固定时间生效.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
doc/商城表设计/img/地区信息数据库设计1.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
doc/商城表设计/img/小程序-优惠券使用.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
doc/商城表设计/img/小程序-分组商品.png
Normal file
|
After Width: | Height: | Size: 168 KiB |
BIN
doc/商城表设计/img/小程序-收货地址.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
doc/商城表设计/img/小程序-用户中心-优惠券.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
doc/商城表设计/img/小程序-用户优惠券列表.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
doc/商城表设计/img/小程序-用户优惠券列表2.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
doc/商城表设计/img/小程序-首页-领券中心.png
Normal file
|
After Width: | Height: | Size: 213 KiB |
BIN
doc/商城表设计/img/小程序加入购物车.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
doc/商城表设计/img/我的购物车列表.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
doc/商城表设计/img/满减优惠项.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
doc/商城表设计/img/满减优惠项1.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
doc/商城表设计/img/满减满折商品.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
doc/商城表设计/img/满减满折数据库关系.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
doc/商城表设计/img/留言.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
BIN
doc/商城表设计/img/规格关联关系.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
doc/商城表设计/img/规格可以输入.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
doc/商城表设计/img/规格属性.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
doc/商城表设计/img/规格选择.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
doc/商城表设计/img/订单管理界面.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
doc/商城表设计/img/订单表设计.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
doc/商城表设计/img/订单详情页面.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
doc/商城表设计/img/购买页.png
Normal file
|
After Width: | Height: | Size: 729 KiB |
BIN
doc/商城表设计/img/购物车关系设计.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
doc/商城表设计/img/购物车关系设计1.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
doc/商城表设计/img/运费模板城市.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
doc/商城表设计/img/运费模板指定包邮城市.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
doc/商城表设计/img/运费模板数据库关系.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
doc/商城表设计/img/运费模板运费项.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
doc/商城表设计/img/配送与运费模板.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
doc/商城表设计/img/领取后生效.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
149
doc/商城表设计/商品分组.md
Normal file
@@ -0,0 +1,149 @@
|
||||
## 商品分组
|
||||
|
||||
#### 商城应用
|
||||
|
||||
在mall4j精选商城首页中,可以看到有`每日上新`、`商城热卖`、`更多商品`等标签栏,在每一栏位中用来展示特定的商品列表,如下图:。
|
||||
|
||||

|
||||
|
||||
在后台中,我们可以对分组标签进行管理
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
后台指定绑定商品所指定的标签
|
||||
|
||||
|
||||
|
||||
店铺商品分组有**两种**分组类型:
|
||||
|
||||
- 系统内置
|
||||
|
||||
更多宝贝:在新增商品的时候,如果用户没有新增任何的分组标签,系统默认提供了一个默认标签。系统内置的标签不能够被删除。
|
||||
|
||||
- 商家自定义分组标签
|
||||
|
||||
用户可以通过自定义分组标签,在首页根据自定义的分组情况对商品的经行展示。
|
||||
|
||||
#### 数据库设计
|
||||
|
||||
整体实体类关系如下图:
|
||||
|
||||

|
||||
|
||||
model 实体类
|
||||
|
||||
商品标签类:
|
||||
|
||||
```java
|
||||
@Data
|
||||
@TableName("tz_prod_tag")
|
||||
public class ProdTag implements Serializable {
|
||||
private static final long serialVersionUID = 1991508792679311621L;
|
||||
/**
|
||||
* 分组标签id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 分组标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 状态(1为正常,0为删除)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 默认类型(0:商家自定义,1:系统默认类型)
|
||||
*/
|
||||
private Integer isDefault;
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private Long prodCount;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer seq;
|
||||
/**
|
||||
* 列表样式(0:一列一个,1:一列两个,2:一列三个)
|
||||
*/
|
||||
private Integer style;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
private Date deleteTime;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
- `id` ,商品分组编号,自增
|
||||
- `shopId` ,店铺ID
|
||||
|
||||
用于取分每个店铺,可扩展为B2B2C模式
|
||||
|
||||
- `status` ,删除时,1为正常,0为删除
|
||||
- `title`, 分组标题
|
||||
- `isDefault` 是否为默认类型
|
||||
- 商家自定义:每日上新,商城热卖等
|
||||
- 系统内置:更多宝贝,默认内置的标签不能被删除,在用户
|
||||
- `prodCount`,商品数量统计
|
||||
- `seq` 排序顺序
|
||||
- `style`列表样式(0:一列一个,1:一列两个,2:一列三个) ,用于扩展开发,用户可以根据自己喜欢的排版布局,对商品布局进行排版
|
||||
|
||||
商品分组引用:商品分组**引用**。一个商品可以有多个商品分组。
|
||||
|
||||
```java
|
||||
@Data
|
||||
@TableName("tz_prod_tag_reference")
|
||||
public class ProdTagReference implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 分组引用id
|
||||
*/
|
||||
@TableId
|
||||
private Long referenceId;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private Long tagId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long prodId;
|
||||
/**
|
||||
* 状态(1:正常,0:删除)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
}
|
||||
```
|
||||
|
||||
- `referenceId` ,分组引用ID
|
||||
- `shopId` , 标识所属的店铺,用于取分每个店铺
|
||||
- `tagId`, 所指向的标签ID
|
||||
- `prodId`,所指向的商品ID
|
||||
- `createTime` 创建时间
|
||||
|
||||
411
doc/商城表设计/商品表设计.md
Normal file
@@ -0,0 +1,411 @@
|
||||
# 1. 背景了解
|
||||
|
||||
在看具体的数据库实体设计之前,我们先一起了解下**电商的名词定义**
|
||||
|
||||
## 1.1 名词定义
|
||||
|
||||
参考 [《产品 SKU 是什么意思?与之相关的还有哪些?》](https://www.zhihu.com/question/19841574) 整理。
|
||||
|
||||
**SKU:Stock Keeping Unit**
|
||||
|
||||
中文翻译为库存单位。SKU 从**库存**视角,以库存进出为单位,可以是件、瓶、箱等等。
|
||||
|
||||
例如,iPhone 手机,按照规格( 颜色 + 内存 )可以组合出如下多个 SKU :
|
||||
|
||||
| SKU | 颜色 | 内存 |
|
||||
| ---- | ---- | ---- |
|
||||
| A | 白色 | 16G |
|
||||
| B | 白色 | 64G |
|
||||
| C | 黑色 | 16G |
|
||||
| D | 黑色 | 64G |
|
||||
|
||||
可以看出,颜色(白色、黑色)与内存(16G、64G)组合排列出四种 iPhone SKU。
|
||||
|
||||
**SPU:Standard Product Unit**
|
||||
|
||||
中文翻译为标准产品单位。SPU 从**产品**视角,是产品信息聚合的**最小单位**,是一组可复用、易检索的标准化信息的集合,该集合描述了一个产品的特性。通俗点讲,属性值、特性相同的商品就可以被称为一个 SPU 。例如 iPhone 8 就是一个 SPU ,iPhone 8 Plus 也是一个 SPU ,这个与**商家**无关,与颜色、款式、套餐等**规格**无关。
|
||||
|
||||
**商品**:
|
||||
|
||||
商家出售某个 SPU ,那么这就是一个商品。商品在 SPU 之上,增加了销售价格、促销活动、运费等等信息。另外,**一个商品可以包含多个 SKU**。
|
||||
|
||||
**总结**
|
||||
|
||||

|
||||
|
||||
------
|
||||
|
||||
现实的场景往往比定义复杂的多,在本文中,**SKU 代表销售的单元**。主要考虑如下两方面:
|
||||
|
||||
- 实际我们看到的商品详情页,购买的是一个**销售组合单元**。例如,很多商家会打包 【iPhone X :银色-64G-套餐三】,其中套餐三为赠送贴膜 + 保护壳等等,当然价格上会更贵。这明显就违背了我们上述提到 SKU 库存的概念,已经变成了多个 SKU 的销售组合单元。
|
||||
- 一个商家会在不同平台销售商品,例如三只松鼠,其在天猫、京东等等平台都有官方旗舰店,同时也供货给其他渠道商,那么实际关系会变成如下图所示: 通过这样的方式,三只松鼠在不同的平台,定义不同的价格,设置不同的促销信息等等个性化的运营。
|
||||
|
||||
------
|
||||
|
||||
**那么注意了**!!!
|
||||
**下文开始,SKU 代表销售的单元**
|
||||
**下文开始,SKU 代表销售的单元**
|
||||
**下文开始,SKU 代表销售的单元**
|
||||
|
||||
## 1.2 界面
|
||||
|
||||
1. 商城端-购买页
|
||||
|
||||

|
||||
|
||||
2. 运营后台-商品发布页 
|
||||
|
||||
# 2. 数据库实体
|
||||
|
||||
整体实体类关系如下图:
|
||||
|
||||

|
||||
|
||||
全部实体可在数据库中查阅。
|
||||
|
||||
## 2.1 Product
|
||||
|
||||
Product 字段较多,我们进行简单的切块。
|
||||
|
||||
### 2.1.1 基础字段
|
||||
|
||||
```java
|
||||
@Data
|
||||
@TableName("tz_prod")
|
||||
public class Product implements Serializable {
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@TableId
|
||||
private Long prodId;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String prodName;
|
||||
|
||||
/**
|
||||
* 简要描述,卖点等
|
||||
*/
|
||||
private String brief;
|
||||
|
||||
/**
|
||||
* 商品主图
|
||||
*/
|
||||
private String pic;
|
||||
|
||||
/**
|
||||
* 商品图片
|
||||
*/
|
||||
private String imgs;
|
||||
|
||||
/**
|
||||
* 默认是1,表示正常状态, -1表示删除, 0下架
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 已经销售数量
|
||||
*/
|
||||
private Integer soldNum;
|
||||
|
||||
/**
|
||||
* 录入时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 详细描述
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 上架时间
|
||||
*/
|
||||
private Date putawayTime;
|
||||
|
||||
|
||||
@Data
|
||||
public static class DeliveryModeVO {
|
||||
|
||||
/**
|
||||
* 用户自提
|
||||
*/
|
||||
private Boolean hasUserPickUp;
|
||||
|
||||
/**
|
||||
* 店铺配送
|
||||
*/
|
||||
private Boolean hasShopDelivery;
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `prodId` ,商品id,数据库自增。
|
||||
- `shopId` ,店铺编号,支持多商户( 店铺 )。
|
||||
- `categoryId` ,商品所在分类id,每个商品都有自己所属的分类
|
||||
|
||||
|
||||
|
||||
### 2.1.2 价格库存
|
||||
|
||||
```java
|
||||
|
||||
/**
|
||||
* 库存量
|
||||
* 基于 sku 的库存数量累加
|
||||
*/
|
||||
private Integer totalStocks;
|
||||
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
private Double oriPrice;
|
||||
|
||||
/**
|
||||
* 现价
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
|
||||
```
|
||||
|
||||
- 在我们的数据库中规定,所有的商品都是具有sku的,就算是只有一种规格的商品,所以`product`里面的库存数量为所有sku库存数量的总和
|
||||
- `price` ,商品价格为元,这里使用`Double`而没有使用`BigDecimal `,而数据库中使用`decimal` 进行存储,所以在数据库中是可以进行直接进行运算的,而在java当中需要使用`com.yami.shop.common.util.Arith`进行运算 。
|
||||
|
||||
|
||||
### 2.1.3 运费信息
|
||||
|
||||
```java
|
||||
/**
|
||||
* 配送方式json
|
||||
*/
|
||||
private String deliveryMode;
|
||||
|
||||
/**
|
||||
* 运费模板id
|
||||
*/
|
||||
private Long deliveryTemplateId;
|
||||
|
||||
@Data
|
||||
public static class DeliveryModeVO {
|
||||
|
||||
/**
|
||||
* 用户自提
|
||||
*/
|
||||
private Boolean hasUserPickUp;
|
||||
|
||||
/**
|
||||
* 店铺配送
|
||||
*/
|
||||
private Boolean hasShopDelivery;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
- 根据` deliveryMode `标记所含有的配送方式进行配送。
|
||||
|
||||
- `deliveryTemplateId` 运费模板id,根据不同的运费模板设计不同的配送费
|
||||
|
||||

|
||||
|
||||
运费模板的操作见 :运费模板的设计相关文章。
|
||||
|
||||
|
||||
## 2.2 Sku
|
||||
|
||||
商品 SKU 。
|
||||
|
||||

|
||||
|
||||
```java
|
||||
@Data
|
||||
@TableName("tz_sku")
|
||||
public class Sku implements Serializable {
|
||||
/**
|
||||
* 单品ID
|
||||
*/
|
||||
@TableId
|
||||
private Long skuId;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
private Long prodId;
|
||||
|
||||
/**
|
||||
* 销售属性组合字符串,格式是p1:v1;p2:v2
|
||||
*/
|
||||
private String properties;
|
||||
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
private Double oriPrice;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private Integer stocks;
|
||||
|
||||
/**
|
||||
* 实际库存
|
||||
*/
|
||||
private Integer actualStocks;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 记录时间
|
||||
*/
|
||||
private Date recTime;
|
||||
|
||||
/**
|
||||
* 商家编码
|
||||
*/
|
||||
private String partyCode;
|
||||
|
||||
/**
|
||||
* 商品条形码
|
||||
*/
|
||||
private String modelId;
|
||||
|
||||
/**
|
||||
* sku图片
|
||||
*/
|
||||
private String pic;
|
||||
|
||||
/**
|
||||
* sku名称
|
||||
*/
|
||||
private String skuName;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String prodName;
|
||||
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private Double weight;
|
||||
|
||||
/**
|
||||
* 体积
|
||||
*/
|
||||
private Double volume;
|
||||
|
||||
/**
|
||||
* 状态:0禁用 1 启用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 0 正常 1 已被删除
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
- `skuId` ,SKU 编号,自增,唯一,参见分销场景。
|
||||
|
||||
- `prodId` ,商品编号,N:1 指向对应的 Product 。
|
||||
|
||||
- `status`,SKU 状态。编辑商品时,当禁用该sku时,前端将会将该sku置灰
|
||||
|
||||
- `stocks` ,库存数量。
|
||||
|
||||
- `properties`,商品规格,字符串拼接格式。
|
||||
|
||||
绝大多数情况下,数据库里的该字段,不存在检索的需求,更多的时候,是查询整体记录,在内存中解析使用。
|
||||
|
||||
少部分情况,灵活的检索,使用 Elasticsearch 进行解决。
|
||||
|
||||
因为我们的规格是直接保存字符串的,所以可以选择,或直接输入
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## 2.3 ProdProp
|
||||
|
||||
商品 SKU 规格属性,在数据库中保存的常用数据。不常用的数据可以直接手动输入即可。
|
||||
|
||||

|
||||
|
||||
```java
|
||||
public class ProdProp implements Serializable {
|
||||
/**
|
||||
* 属性id
|
||||
*/
|
||||
@TableId
|
||||
private Long propId;
|
||||
|
||||
/**
|
||||
* 属性名称
|
||||
*/
|
||||
private String propName;
|
||||
|
||||
private Long shopId;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
- `propId` ,属性编号。
|
||||
- `propName` ,属性名称。
|
||||
|
||||
|
||||
|
||||
## 2.4 ProdPropValue
|
||||
|
||||
商品 SKU 规格属性,在数据库中保存的常用数据。
|
||||
|
||||
```java
|
||||
public class ProdProp implements Serializable {
|
||||
/**
|
||||
* 属性值ID
|
||||
*/
|
||||
@TableId
|
||||
private Long valueId;
|
||||
|
||||
/**
|
||||
* 属性值名称
|
||||
*/
|
||||
private String propValue;
|
||||
|
||||
/**
|
||||
* 属性ID
|
||||
*/
|
||||
private Long propId;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
- `valueId` ,属性值ID。
|
||||
- `propValue` ,属性值名称。
|
||||