fix streamer id

This commit is contained in:
lwl0608 2024-03-13 21:06:00 +08:00
parent 371cf04c5f
commit 7b4954bbf8
1 changed files with 10 additions and 10 deletions

View File

@ -2580,29 +2580,29 @@ func (v *Vas) refundMembership(ctx *gin.Context, order *dbstruct.Order, req *vas
// 有分成的情况
if len(incomeChList) > 0 {
ch := incomeChList[0]
uid := ch.GetUid()
if uid <= 0 {
err = errors.New("收入uid错误")
logger.Error("invalid uid: %v", uid)
streamerMid := ch.GetMid()
if streamerMid <= 0 {
err = errors.New("收入streamerMid错误")
logger.Error("invalid streamerMid: %v", streamerMid)
return err
}
// 主播钱包
wallet, err := v.store.GetWalletForUpdate(ctx, tx, uid)
wallet, err := v.store.GetWalletForUpdate(ctx, tx, streamerMid)
if err != nil {
return err
}
// 扣主播金币
change := ch.GetChange()
err = v.store.DecDiamonds(ctx, tx, uid, change)
err = v.store.DecDiamonds(ctx, tx, streamerMid, change)
if err != nil {
return err
}
// 扣金币的收入记录
chNew := &dbstruct.ConsumeHistory{
Mid: goproto.Int64(uid),
Mid: goproto.Int64(streamerMid),
Uid: goproto.Int64(ch.GetMid()),
Did: goproto.String(ch.GetDid()),
Type: goproto.Int32(dbstruct.CHTypeIncome),
@ -2623,15 +2623,15 @@ func (v *Vas) refundMembership(ctx *gin.Context, order *dbstruct.Order, req *vas
// 如果已结算,扣提现钻石
if isFinish {
// 扣提现钻石
err = v.store.DecWithdrawDiamonds(ctx, tx, uid, change)
err = v.store.DecWithdrawDiamonds(ctx, tx, streamerMid, change)
if err != nil {
logger.Error("DecWithdrawDiamonds fail, uid: %v, change: %v, err: %v", uid, change, err)
logger.Error("DecWithdrawDiamonds fail, streamerMid: %v, change: %v, err: %v", streamerMid, change, err)
return err
}
// 提现钻石记录
wh := &dbstruct.WithdrawDiamondsHis{
Mid: goproto.Int64(uid),
Mid: goproto.Int64(streamerMid),
IncomeChId: goproto.Int64(ch.GetId()),
OrderId: goproto.String(ch.GetOrderId()),
Ct: goproto.Int64(time.Now().Unix()),