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