fix income stype
This commit is contained in:
parent
b038ef5896
commit
6a6781e9d8
|
@ -11,7 +11,7 @@ func TestCalcIncome(t *testing.T) {
|
|||
|
||||
ztp := &dbstruct.ZoneThirdPartner{
|
||||
ThirdPartnerMid: goproto.Int64(100001),
|
||||
SharingRatio: goproto.Float64(0.1),
|
||||
SharingRatio: goproto.Float64(0.20),
|
||||
}
|
||||
zclList := []*dbstruct.ZoneCollaborator{
|
||||
&dbstruct.ZoneCollaborator{
|
||||
|
@ -20,18 +20,18 @@ func TestCalcIncome(t *testing.T) {
|
|||
},
|
||||
&dbstruct.ZoneCollaborator{
|
||||
CollaboratorMid: goproto.Int64(200002),
|
||||
SharingRatio: goproto.Float64(0.05),
|
||||
SharingRatio: goproto.Float64(0.02),
|
||||
},
|
||||
&dbstruct.ZoneCollaborator{
|
||||
CollaboratorMid: goproto.Int64(200003),
|
||||
SharingRatio: goproto.Float64(0.05),
|
||||
SharingRatio: goproto.Float64(0.02),
|
||||
},
|
||||
&dbstruct.ZoneCollaborator{
|
||||
CollaboratorMid: goproto.Int64(200004),
|
||||
SharingRatio: goproto.Float64(0.05),
|
||||
SharingRatio: goproto.Float64(0.02),
|
||||
},
|
||||
}
|
||||
list := v._calcWithZoneWithTp(100, 10, 1, ztp, zclList)
|
||||
list := v._calcWithZoneWithTp(100, 100, 1, ztp, zclList)
|
||||
for _, v := range list {
|
||||
t.Logf("%v, %v, %v\n", v.Mid, v.Rate, v.Dias)
|
||||
}
|
||||
|
|
|
@ -454,6 +454,7 @@ type IncomeInfo struct {
|
|||
IncomeSType int32 `json:"income_stype"` // 收入类类型
|
||||
Rate float64 `json:"rate"` // 收入比例
|
||||
Dias int64 `json:"dias"` // 收入钻石
|
||||
SettingRate float64 `json:"setting_rate"` // 设置的收入比例
|
||||
}
|
||||
|
||||
func (v *Vas) calcAndUpdateIncome(ctx *gin.Context, tx *sqlx.Tx, streamerMid, uid int64, did, orderId, typeId string, totalDias int64, defaultIncomeSType int32) ([]IncomeInfo, error) {
|
||||
|
@ -638,11 +639,13 @@ func (v *Vas) _calcWithZoneWithTp(streamerMid, totalDias int64, defaultIncomeSTy
|
|||
IncomeSType: defaultIncomeSType,
|
||||
Rate: 0.2,
|
||||
Dias: officialDias,
|
||||
SettingRate: 0.2,
|
||||
})
|
||||
leftDias -= officialDias
|
||||
|
||||
// 代运营+协作者真正分成rate
|
||||
partsRate := 0.8 * ztp.GetSharingRatio()
|
||||
ztpRate := partsRate
|
||||
|
||||
// 主播
|
||||
streamerRate := 0.8 - partsRate
|
||||
|
@ -652,6 +655,7 @@ func (v *Vas) _calcWithZoneWithTp(streamerMid, totalDias int64, defaultIncomeSTy
|
|||
IncomeSType: defaultIncomeSType,
|
||||
Rate: streamerRate,
|
||||
Dias: streamerDias,
|
||||
SettingRate: 1.0 - ztp.GetSharingRatio(),
|
||||
})
|
||||
leftDias -= streamerDias
|
||||
|
||||
|
@ -664,18 +668,20 @@ func (v *Vas) _calcWithZoneWithTp(streamerMid, totalDias int64, defaultIncomeSTy
|
|||
IncomeSType: dbstruct.CHSTypeIncomeCollaborator,
|
||||
Rate: zclRate,
|
||||
Dias: zclDias,
|
||||
SettingRate: zcl.GetSharingRatio(),
|
||||
})
|
||||
leftDias -= zclDias
|
||||
ztpRate -= zclRate
|
||||
}
|
||||
|
||||
// 代运营
|
||||
ztpRate := 0.8 * ztp.GetSharingRatio()
|
||||
ztpDias := int64(float64(totalDias) * ztpRate)
|
||||
list = append(list, IncomeInfo{
|
||||
Mid: ztp.GetThirdPartnerMid(),
|
||||
IncomeSType: dbstruct.CHSTypeIncomeThirdPartner,
|
||||
Rate: ztpRate,
|
||||
Dias: ztpDias,
|
||||
SettingRate: ztp.GetSharingRatio(),
|
||||
})
|
||||
leftDias -= ztpDias
|
||||
|
||||
|
|
Loading…
Reference in New Issue