diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 23865c4d..a62e7a0b 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -1313,7 +1313,7 @@ func (v *Vas) PayCallback(ctx *gin.Context, p *vasproto.PayCallbackParamIn) { } case product.Id == dbstruct.ProductIdMembership: // 解锁会员资格 - _, err = v.UnlockMembership(ctx, util.DerefInt64(order.Mid), product, order, wallet) + _, err = v.UnlockMembership(ctx, tx, util.DerefInt64(order.Mid), product, order, wallet) if err != nil { logger.Error("UnlockMembership fail, order: %v, err: %v", util.ToJson(order), err) return @@ -1851,7 +1851,7 @@ func (v *Vas) dealOneMembershipOrder(ctx *gin.Context, tx *sqlx.Tx, order *dbstr } // 解锁会员资格 -func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Product, order *dbstruct.Order, wallet *dbstruct.Wallet) (orderId string, err error) { +func (v *Vas) UnlockMembership(ctx *gin.Context, tx *sqlx.Tx, mid int64, product *dbstruct.Product, order *dbstruct.Order, wallet *dbstruct.Wallet) (orderId string, err error) { var ( did = util.DerefString(order.Did) productId = product.Id @@ -1867,20 +1867,6 @@ func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Pr return } - // 开启事务 - tx, err := v.store.VasBegin(ctx) - if err != nil { - logger.Error("vas begin fail, err: %v", err) - return - } - defer func() { - errTx := v.store.DealTxCR(tx, err) - if errTx != nil { - logger.Error("DealTxCR fail, err: %v", errTx) - return - } - }() - // 增加金币消费历史(伪记录,仅为对账平插入一条消费流水) ch := &dbstruct.ConsumeHistory{ Mid: goproto.Int64(mid), @@ -1934,8 +1920,15 @@ func (v *Vas) UnlockMembership(ctx *gin.Context, mid int64, product *dbstruct.Pr return } + // 获取空间id + zid := int64(0) + zone, _ := v.zone.GetByMid(ctx, order.GetUid()) + if zone != nil { + zid = zone.GetId() + } + // 增加空间消费 - _err := v.IncZoneConsume(ctx, tx, 0, mid, order.GetUid(), order.GetPayAmount(), orderId, order.GetProductId()) + _err := v.IncZoneConsume(ctx, tx, zid, mid, order.GetUid(), order.GetPayAmount(), orderId, order.GetProductId()) if _err != nil { logger.Error("IncZoneConsume fail, mid: %v, orderId: %v, err: %v", mid, orderId, err) }