1.修改创建租赁订单时异常退出导致数据库死锁问题;
This commit is contained in:
parent
b96590ab28
commit
f8f774ca1c
|
@ -289,11 +289,17 @@ func RentCardOrderCreate(c *gin.Context) {
|
|||
isRentCount, err := rentCard.IsHaveUnreturnedOrders(cardCount)
|
||||
//unreturnedOrders, err := model.IsHaveUnreturnedOrders(uc.Uid) //
|
||||
if err != nil {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
if isRentCount {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("unreturnedOrders")
|
||||
RespJson(c, status.HaveUnreturnedOrders, nil)
|
||||
return
|
||||
|
@ -301,11 +307,17 @@ func RentCardOrderCreate(c *gin.Context) {
|
|||
|
||||
online, err := model.IsGameCardListOnline(req.GameCardList)
|
||||
if err != nil {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
if !online {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("unreturnedOrders")
|
||||
RespJson(c, status.GoodsSoldOut, nil)
|
||||
return
|
||||
|
@ -314,6 +326,9 @@ func RentCardOrderCreate(c *gin.Context) {
|
|||
store.ID = req.StoreId
|
||||
err = store.Info()
|
||||
if err != nil {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("store err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
|
@ -345,6 +360,9 @@ func RentCardOrderCreate(c *gin.Context) {
|
|||
// OrderAscByID().Limit(1).One(&userCoupon)
|
||||
err = model.NewUserCouponQuerySet(model.DB).IDEq(req.UserCouponId).One(&userCoupon)
|
||||
if err != nil && err != model.RecordNotFound {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("user coupon err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
|
@ -370,11 +388,17 @@ func RentCardOrderCreate(c *gin.Context) {
|
|||
//}
|
||||
stockEnough, err := model.IsCardGoodsStockEnough(req.GameCardList, req.StoreId)
|
||||
if err != nil {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("err:", err)
|
||||
RespJson(c, status.OrderStockOut, nil)
|
||||
return
|
||||
}
|
||||
if stockEnough {
|
||||
if req.Price == 0 {
|
||||
tx.Rollback()
|
||||
}
|
||||
logger.Error("order stock out ")
|
||||
RespJson(c, status.OrderStockOut, nil)
|
||||
return
|
||||
|
@ -420,7 +444,7 @@ func RentCardOrderCreate(c *gin.Context) {
|
|||
// RespJson(c, status.InternalServerError, nil)
|
||||
// return
|
||||
//}
|
||||
err := model.GameCardGoodsInventoryReduction(req.GameCardList, req.StoreId, tx)
|
||||
err = model.GameCardGoodsInventoryReduction(req.GameCardList, req.StoreId, tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
logger.Error("inventory reduction err:", err.Error())
|
||||
|
|
Loading…
Reference in New Issue
Block a user