fix tx
This commit is contained in:
parent
9cd894a47b
commit
561afa8755
|
@ -762,40 +762,44 @@ func (v *Vas) OneStepUnlockContact(ctx *gin.Context, req *vasproto.OneStepUnlock
|
|||
return
|
||||
}
|
||||
|
||||
// 扣金币
|
||||
err = v.store.DecCoins(ctx, tx, req.Mid, coinPrice)
|
||||
if err != nil {
|
||||
logger.Error("DecCoins fail, mid: %v, coinPrice: %v, err: %v", req.Mid, coinPrice, err)
|
||||
return
|
||||
}
|
||||
if coinPrice > 0 {
|
||||
// 扣金币
|
||||
err = v.store.DecCoins(ctx, tx, req.Mid, coinPrice)
|
||||
if err != nil {
|
||||
logger.Error("DecCoins fail, mid: %v, coinPrice: %v, err: %v", req.Mid, coinPrice, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 计算收入
|
||||
var totalDias = coinPrice
|
||||
// h5解锁情况
|
||||
if originalContactProductId == dbstruct.ProductIdH5ContactWechat {
|
||||
totalDias = uVasInfo.GetWechatCoinPrice()
|
||||
}
|
||||
incomeList, err := v.calcAndUpdateIncome(ctx, tx, uid, mid, req.Did, orderId, contactProductId, totalDias, dbstruct.CHSTypeIncomeContact)
|
||||
if err != nil {
|
||||
logger.Error("calcAndUpdateIncome fail, coinOrder: %v, err: %v", util.ToJson(coinOrder), err)
|
||||
return
|
||||
}
|
||||
// 计算收入
|
||||
var totalDias = coinPrice
|
||||
// h5解锁情况
|
||||
if originalContactProductId == dbstruct.ProductIdH5ContactWechat {
|
||||
totalDias = uVasInfo.GetWechatCoinPrice()
|
||||
}
|
||||
incomeList, err := v.calcAndUpdateIncome(ctx, tx, uid, mid, req.Did, orderId, contactProductId, totalDias, dbstruct.CHSTypeIncomeContact)
|
||||
if err != nil {
|
||||
logger.Error("calcAndUpdateIncome fail, coinOrder: %v, err: %v", util.ToJson(coinOrder), err)
|
||||
return
|
||||
}
|
||||
|
||||
// 把分成信息写到金币订单ext里面
|
||||
orderExt := map[string]any{
|
||||
"total_dias": totalDias,
|
||||
"income_list": incomeList,
|
||||
}
|
||||
err = v.store.UpdateCoinOrderExt(ctx, tx, orderId, util.ToJson(orderExt))
|
||||
if err != nil {
|
||||
logger.Error("UpdateCoinOrderExt fail, order_id: %v, ext: %v, err: %v", orderId, util.ToJson(orderExt), err)
|
||||
return
|
||||
}
|
||||
// 把分成信息写到金币订单ext里面
|
||||
orderExt := map[string]any{
|
||||
"total_dias": totalDias,
|
||||
"income_list": incomeList,
|
||||
}
|
||||
err = v.store.UpdateCoinOrderExt(ctx, tx, orderId, util.ToJson(orderExt))
|
||||
if err != nil {
|
||||
logger.Error("UpdateCoinOrderExt fail, order_id: %v, ext: %v, err: %v", orderId, util.ToJson(orderExt), err)
|
||||
return
|
||||
}
|
||||
|
||||
// 增加空间消费
|
||||
_err := v.IncZoneConsume(ctx, tx, 0, mid, uid, coinPrice, orderId, contactProductId)
|
||||
if _err != nil {
|
||||
logger.Error("IncZoneConsume fail, mid: %v, streamerMid: %v, orderId: %v, err: %v", mid, uid, orderId, err)
|
||||
// 增加空间消费
|
||||
if coinPrice > 0 {
|
||||
_err := v.IncZoneConsume(ctx, tx, 0, mid, uid, coinPrice, orderId, contactProductId)
|
||||
if _err != nil {
|
||||
logger.Error("IncZoneConsume fail, mid: %v, streamerMid: %v, orderId: %v, err: %v", mid, uid, orderId, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue