2

我正在使用 Ruby On rails 从头开始​​开发一个在线商店。

我有一个关于库存和订单的设计问题。

当用户选择产品时,您何时更新库存

  • 如果您在将产品放入购物车时降低库存,那么在用户关闭浏览器时您必须能够补货。问题,rails 不处理此用例的会话过期

  • 如果我在将客户发送到我的支付解决方案(如贝宝、谷歌结账或亚马逊)之前降低库存,如果用户关闭他的浏览器,我仍然不会收到通知。

-如果我在付款有效后减少库存,我可能有两个不同的客户在只剩下一个时购买相同的产品,而当他只剩下一个时,商店现在必须交付两个产品。

你知道网上商店是如何处理这个问题的吗?

我在哪里可以找到开源在线商店的设计文档?

4

2 回答 2

2

我想过这个,但从来没有编程过。

不管它值多少钱,如果它即将通过付款过程,我会做的是暂时“保留”一个对象。这样一来,其他人就无法购买这个对象了。虽然它被搁置,但我会给出用户可以持有它多长时间(也许一个小时)的到期时间。然后只有当付款有效时,产品才会从库存中移除。

于 2011-07-23T14:46:23.280 回答
1

Well normally you keep inventory separated such that you have one value for what is in the warehouse and one value for submitted but not shipped orders.

When an item is placed in a shopping cart all you can do is inform the user when the effective inventory changes, i.e. when another user has submitted an order. There are no guarantees until the cart has been checked out.

于 2011-07-23T14:57:47.127 回答