diff --git a/controller/order.go b/controller/order.go index 0cd36c9..3a09b60 100644 --- a/controller/order.go +++ b/controller/order.go @@ -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())