Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化 #12

Open
seven-yu opened this issue Nov 12, 2020 · 2 comments
Open

优化 #12

seven-yu opened this issue Nov 12, 2020 · 2 comments

Comments

@seven-yu
Copy link

seven-yu commented Nov 12, 2020

if localSpike.LocalDeductionStock() && remoteSpike.RemoteDeductionStock(redisConn) {
		util.RespJson(w, 1,  "抢票成功", nil)
		LogMsg = LogMsg + "result:1,localSales:" + strconv.FormatInt(localSpike.LocalSalesVolume, 10)
	} else {
		util.RespJson(w, -1, "已售罄", nil)
		LogMsg = LogMsg + "result:0,localSales:" + strconv.FormatInt(localSpike.LocalSalesVolume, 10)
	}

失败应该回滚本地的一个记录

if localSpike.LocalDeductionStock() && remoteSpike.RemoteDeductionStock(redisConn) {
		util.RespJson(w, 1,  "抢票成功", nil)
		LogMsg = LogMsg + "result:1,localSales:" + strconv.FormatInt(localSpike.LocalSalesVolume, 10)
	} else {
		util.RespJson(w, -1, "已售罄", nil)
		spike.LocalSalesVolume = spike.LocalSalesVolume - 1   
		LogMsg = LogMsg + "result:0,localSales:" + strconv.FormatInt(localSpike.LocalSalesVolume, 10)
	}
@GuoZhaoran
Copy link
Owner

其实回滚不回滚都无所谓了

@ResolLIU
Copy link

ResolLIU commented Oct 1, 2022

是的,回滚更加科学!但是如果后续有追加订单的需求才需要回滚。当然也看设计思路,如果追加是新开一个库存池,那么回滚也是不必须的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants