From 88b4c917c60ce7b3cb90ee951903e0428a947d72 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Thu, 25 Apr 2024 16:44:46 +0800 Subject: [PATCH] fix calc --- app/mix/service/logic/calc_income_test.go | 6 ++--- app/mix/service/logic/vas_zone.go | 31 +++++++++++++++-------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/mix/service/logic/calc_income_test.go b/app/mix/service/logic/calc_income_test.go index 7e3c45d9..ffce5dfd 100644 --- a/app/mix/service/logic/calc_income_test.go +++ b/app/mix/service/logic/calc_income_test.go @@ -11,12 +11,12 @@ func TestCalcIncome(t *testing.T) { ztp := &dbstruct.ZoneThirdPartner{ ThirdPartnerMid: goproto.Int64(100001), - SharingRatio: goproto.Float64(0.4), + SharingRatio: goproto.Float64(0.1), } zclList := []*dbstruct.ZoneCollaborator{ &dbstruct.ZoneCollaborator{ CollaboratorMid: goproto.Int64(200001), - SharingRatio: goproto.Float64(0.15), + SharingRatio: goproto.Float64(0.09), }, &dbstruct.ZoneCollaborator{ CollaboratorMid: goproto.Int64(200002), @@ -31,7 +31,7 @@ func TestCalcIncome(t *testing.T) { SharingRatio: goproto.Float64(0.05), }, } - list := v._calcWithZoneWithTp(100, 10000, 1, ztp, zclList) + list := v._calcWithZoneWithTp(100, 10, 1, ztp, zclList) for _, v := range list { t.Logf("%v, %v, %v\n", v.Mid, v.Rate, v.Dias) } diff --git a/app/mix/service/logic/vas_zone.go b/app/mix/service/logic/vas_zone.go index 43d99d97..982361e2 100644 --- a/app/mix/service/logic/vas_zone.go +++ b/app/mix/service/logic/vas_zone.go @@ -629,7 +629,7 @@ func (v *Vas) _calcWithZoneWithoutTp(streamerMid, totalDias int64, defaultIncome // 有空间,有代运营 func (v *Vas) _calcWithZoneWithTp(streamerMid, totalDias int64, defaultIncomeSType int32, ztp *dbstruct.ZoneThirdPartner, zclList []*dbstruct.ZoneCollaborator) []IncomeInfo { list := make([]IncomeInfo, 0) - ztpDias := totalDias + leftDias := totalDias // 官方 officialDias := int64(float64(totalDias) * 0.2) @@ -639,15 +639,13 @@ func (v *Vas) _calcWithZoneWithTp(streamerMid, totalDias int64, defaultIncomeSTy Rate: 0.2, Dias: officialDias, }) - ztpDias -= officialDias + leftDias -= officialDias // 代运营+协作者真正分成rate - ztpRate := 0.8 * ztp.GetSharingRatio() - // 代运营自己 - ztpSelfRate := ztpRate + partsRate := 0.8 * ztp.GetSharingRatio() // 主播 - streamerRate := 0.8 - ztpRate + streamerRate := 0.8 - partsRate streamerDias := int64(float64(totalDias) * streamerRate) list = append(list, IncomeInfo{ Mid: streamerMid, @@ -655,7 +653,7 @@ func (v *Vas) _calcWithZoneWithTp(streamerMid, totalDias int64, defaultIncomeSTy Rate: streamerRate, Dias: streamerDias, }) - ztpDias -= streamerDias + leftDias -= streamerDias // 协作者 for _, zcl := range zclList { @@ -667,17 +665,28 @@ func (v *Vas) _calcWithZoneWithTp(streamerMid, totalDias int64, defaultIncomeSTy Rate: zclRate, Dias: zclDias, }) - ztpSelfRate -= zclRate - ztpDias -= zclDias + leftDias -= zclDias } - // 代运营自己 + // 代运营 + ztpRate := 0.8 * ztp.GetSharingRatio() + ztpDias := int64(float64(totalDias) * ztpRate) list = append(list, IncomeInfo{ Mid: ztp.GetThirdPartnerMid(), IncomeSType: dbstruct.CHSTypeIncomeThirdPartner, - Rate: ztpSelfRate, + Rate: ztpRate, Dias: ztpDias, }) + leftDias -= ztpDias + + // 如果剩余钻石,加到官方上 + list = append(list, IncomeInfo{ + Mid: common.OfficialMid, + IncomeSType: defaultIncomeSType, + Rate: 0, + Dias: leftDias, + }) + return list }