Home | Mirror | Search

3. 促銷優惠組件設計

設計思想是,在購物車結算前匹配促銷規則計算出最終優惠金額

		
                                     +-----------------------+
User -> Goods -> Cart -> Delivery -> | Promotions components | -> Checkout
                                     +-----------------------+
                                     | Promotion rule 1      |
                                     | Promotion rule 2      |
                                     | Promotion rule 3      |
                                     | Promotion rule 4      |
                                     | Promotion rule 5      |
                                     +-----------------------+
		
		

資料庫設計

		
 +--------------+
 | goods        |
 +--------------+
 | id           |o---+
 | ...          |    |
 | ...          |    |
 +--------------+    |    +----------------------+
                     |    | goods_promotion_rule |
 +--------------+    |    +----------------------+
 | promotion    |    |    | id                   |
 +--------------+    +--->| goods_id             |
 | id           |o------->| promotion_id         |
 | name         |         | ...                  |
 | plugin       |         | ...                  |
 +--------------+         +----------------------+
		
		

goods_promotion_rule 負責將商品與促銷規則關係建立起來

promotion 是促銷腳本,我方案是使用 lua 編寫促銷腳本,plugin用於存儲lua檔案地址

這樣做的好處是不用因為促銷規則改變而重新修改程序,單獨製作 lua腳本即可,

以上僅僅提供一個思路,你還可以建立一個goods_promotion_group將促銷商品分組,然後再與goods_promotion_rule建立關係。

另外在購物車中會同時出現多種促銷規則,也是要考慮的。

comments powered by Disqus