只给用户一定时间完成一笔交易,比如5分钟没有其他交易过程 [英] give user only a certain time to complete a transaction, like 5 minutes no other transaction process

查看:85
本文介绍了只给用户一定时间完成一笔交易,比如5分钟没有其他交易过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要想出一种方法来临时保留库存,并且只给用户一定的时间来完成交易,比如5分钟;

问题是2人同时预订相同的库存时间。我们怎样才能确保不会发生这种情况?

a)。我们可以临时保留第一个用户的库存,如果他们没有在5分钟内预订,请释放保留或类似的东西吗?



请帮助我

Need to come up with a way to "temp hold" inventory and give user only a certain time to complete a transaction, like 5 minutes;
Problem is 2 people booking same inventory at the same time. How can we make sure this does not happen?
a). Can we "temp hold" the inventory for the first user and if they do not book within 5 minutes, release the hold or something simiilar?

please help me

推荐答案

我很久以前就已经按照以下方式实现了它。看看它是否适合你。

流程

1.客户访问产品目录页面。

2.客户选择一个或多个项目并添加他们到购物车。

3.每次将项目添加到购物车时,

调用存储过程以在库存表中将该项目的数量减少1。

此用户的购物车保存在ShoppingCart表中的等待付款状态。

4.客户付款。购物车进入付款已完成状态。



客户不付款并离开。购物车保持等待付款状态2小时(可配置)。

5.每5分钟

a'CheceCleanup'存储过程运行(通过SQL作业)

转到ShoppingCart表

将等待付款状态下的所有购物车转换为已取消超过2小时

在购物车中的每件商品的库存表中将数量增加1

6.与此同时,在这5分钟内,更多的客户可能已经看过这个项目,并且会在网站上看到Out Of Stock消息。捕获这些客户ID,并通过另一个预定作业发送电子邮件,告诉他们该产品现已重新库存。



[请鼓励通过投票解决方案或适合您的答案参与]
I have implemented it the following way long time ago. See if it works for you.
Flow
1. Customer visits product catalog page.
2. Customer selects one or more items and adds them to the shopping cart.
3. Each time an item is added to the cart,
A stored proc is invoked to reduce the quantity of that item by 1 in the Inventory table.
The shopping cart for this user is kept in 'Awaiting Payment' Status in ShoppingCart Table.
4. Customer makes payment. Cart goes to 'Payment Completed' Status.
OR
Customer doesn't make payment and leaves. Cart stays in 'Awaiting Payment' Status for 2 hrs(configurable).
5. Every 5 minutes
a 'BookingCleanup' stored procedure runs (via a SQL job)
that goes to ShoppingCart table
converts all Carts in 'Awaiting Payment' status for more than 2hrs to 'Cancelled'
increases quantity by 1 in the Inventory table for each item in the cart
6. Meanwhile in these 5 minutes some more customers may have viewed this item and would have seen an 'Out Of Stock' message on the site. Those customer IDs are captured and emails are sent out by another scheduled job to tell them that the product is now back in stock.

[Please encourage participation by up-voting solutions or answers that work for you]


这篇关于只给用户一定时间完成一笔交易,比如5分钟没有其他交易过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆