1、SKU:庫存量單位
SKU(Stock Keeping Unit)是指商品庫存量的最小單位。如果一個商品有多個型號、顏色、版本等多種維度時,可以通過設置SKU屬性來細分,倉管可以根據SKU來盤點庫存數量。
比如:一款球鞋,有顏色和碼數兩個維度;顏色有白色、紅色和黑色,碼數有38碼、...、43碼等,根據維度生成相應的笛卡爾積(SKU組合),總共有3*6=18個SKU組合。在編輯商品SKU數據時,就需要對這18個組合的圖片、庫存編碼、價格、數量進行完善。
2、SKU數據庫設計
屬性組表:ben_attribute_class
- id:自增主鍵
- prouct_class_id:商品分類ID
- product_id:商品ID(null:公用的屬性組;>0:某個商品的自定義屬性組)
- class_name:SKU屬性組名稱
- attribute_count:SKU屬性項數量
- order_id:排序ID
屬性項表:ben_attribute_item
- id:自增主鍵
- attribute_class_id:SKU屬性組ID
- item_name:SKU屬性項名稱
- img_url:圖片url
- order_id:排序ID
屬性項更新表:ben_attribute_update
某個商品,對共用屬性項的更新調整
- id:自增主鍵
- product_id:商品ID
- attribute_class_id:SKU屬性組ID
- attribute_item_id:SKU屬性項ID
- attribute_name:屬性項名稱(編輯更新的值)
- img_url:圖片url
商品SKU庫存表:ben_product_stock
- id:自增主鍵
- product_id:商品ID
- attribute_class_id1:一級SKU屬性組ID
- attribute_id1:一級SKU屬性項ID
- attribute_class_id2:二級SKU屬性組ID
- attribute_id2:二級SKU屬性項ID
- attribute_class_id3:三級SKU屬性組ID
- attribute_id3:三級SKU屬性項ID
- stock_code:庫存編碼
- price:銷售價格
- stock_count:庫存數量
- img_url:圖片
商品SKU庫存變化日誌表:ben_product_stock_log
- id:自增主鍵
- product_id:商品ID
- stock_id:商品SKU ID
- start_count:開始數量
- end_count:結束數量
- change_count:調整的數量
- order_id:關聯的訂單ID
- order_detail_id:關聯的訂單詳情ID
商品表:ben_product
- id:自增主鍵
- class_id:商品分類
- product_name:商品名稱
- product_code:商品編碼
- sku_attribute:商品SKU屬性,商品有SKU時,存放組成成的SKU屬性值,方便前端展示
- stock_count:庫存數量
- price:銷售價格
<code>sku_attribute的值:
[{
\t"id": 34,
\t"className": "顏色",
\t"attributes": [{
\t\t"productId": 2558,
\t\t"attributeClassId": 34,
\t\t"attributeItemId": 99,
\t\t"attributeName": "紅色",
\t\t"imgUrl": null
\t}, {
\t\t"productId": 2558,
\t\t"attributeClassId": 34,
\t\t"attributeItemId": 98,
\t\t"attributeName": "白色",
\t\t"imgUrl": null
\t}]
}]/<code>
閱讀更多 天下一笨蛋 的文章