Parcourir la source

add reverse:for v3.1.8 制度加入总金额分佣不扣除同级奖励

tags/v3.1.8
huangjiajun il y a 2 ans
Parent
révision
311f9e78fc
2 fichiers modifiés avec 149 ajouts et 3 suppressions
  1. +18
    -1
      lib/comm_plan/all.go
  2. +131
    -2
      lib/comm_plan/other.go

+ 18
- 1
lib/comm_plan/all.go Voir le fichier

@@ -624,8 +624,25 @@ func GetLvUpSubsidyVirtualCoinRatio(level, newLevel, diff int, grade map[int]*Lv
jsons, ok := oneLevelMap["rate_list"].([]interface{})
if ok {
levelRateListArr = jsons
} else {
jsons1, ok := oneLevelMap["rate_list"].(map[string]interface{})
if ok {
max := 0
for k, _ := range jsons1 {
if zhios_order_relate_utils.StrToInt(k) > max {
max = zhios_order_relate_utils.StrToInt(k)
}
}
for i := 0; i <= max; i++ {
bili, ok := jsons1[zhios_order_relate_utils.IntToStr(i)]
if ok {
levelRateListArr = append(levelRateListArr, bili)
} else {
levelRateListArr = append(levelRateListArr, "0")
}
}
}
}

}
}
if len(levelRateListArr) == 0 {


+ 131
- 2
lib/comm_plan/other.go Voir le fichier

@@ -78,8 +78,8 @@ Loop:
//同级奖励比例
commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatio(maxLv, userList.OwnbuyReturnType, peerNum, "same_lv", totalAmt, integralTotalAmt, opt)
//佣金 (lv, isOnlySubsidy int, restAmt, profit, peerRate, totalRatio, restRatio, subsidyFee, subsidyBili float64, opt *PlanOpt)
node.ParentUser.Profit, restAmt, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, isBreak = sameMoney(node.Lv, isOnlySubsidyFee, restAmt, commission, peerRate, totalCommissionRatio, commissionRatio, node.ParentUser.SubsidyFee, subsidyRatio, opt)
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, peerRateList, node.ParentUser.SubsidyFeeList, zeroList = sameMoneyV2(node.Lv, isOnlySubsidyFee, totalAmtList, restAmtList, amountList, peerRateList, accumulateRatioList, ratioList, node.ParentUser.SubsidyFeeList, subsidyRatioList, opt)
node.ParentUser.Profit, restAmt, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, isBreak = otherSameMoney(node.Lv, isOnlySubsidyFee, restAmt, commission, peerRate, totalCommissionRatio, commissionRatio, node.ParentUser.SubsidyFee, subsidyRatio, opt)
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, peerRateList, node.ParentUser.SubsidyFeeList, zeroList = otherSameMoneyV2(node.Lv, isOnlySubsidyFee, totalAmtList, restAmtList, amountList, peerRateList, accumulateRatioList, ratioList, node.ParentUser.SubsidyFeeList, subsidyRatioList, opt)

// 全部都没得分了
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) {
@@ -120,3 +120,132 @@ Loop:

return nil
}

//公共处理同级计算 (只计算佣金 旧版本用)
func otherSameMoney(lv, isOnlySubsidy int, restAmt, profit, peerRate, totalRatio, restRatio, subsidyFee, subsidyBili float64, opt *PlanOpt) (float64, float64, float64, float64, float64, bool) {
//如果不够扣了,并且是比例返利就跳过
if restAmt < profit {
return 0, restAmt, totalRatio, peerRate, subsidyFee, true
}
if opt == nil {
return 0, restAmt, totalRatio, peerRate, subsidyFee, true
}
if opt.UserRate == nil {
return 0, restAmt, totalRatio, peerRate, subsidyFee, true
}
if opt.UserRate[lv] == nil {
return 0, restAmt, totalRatio, peerRate, subsidyFee, true
}
//极差返利
if opt.UserRate[lv].PayMode == 0 && isOnlySubsidy == 0 {
restAmt -= profit // 剩余可分
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 6)
peerRate += restRatio
totalRatio += restRatio
} else if isOnlySubsidy == 1 { //如果只返补贴 当成是极差的一部分 所以要扣 不是额外的
profit = 0
if opt.UserRate[lv].PayMode == 0 {
if restAmt < subsidyFee {
subsidyFee = 0
return profit, restAmt, totalRatio, subsidyFee, peerRate, true
}
restAmt -= subsidyFee // 剩余可分
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 6)
totalRatio += zhios_order_relate_utils.FloatFormat(subsidyBili, 6)
}
}
return profit, restAmt, totalRatio, peerRate, subsidyFee, false
}

func otherSameMoneyV2(lv, isOnlySubsidy int, totalAmtList, restAmtList, profitList, peerRateList, totalRatioList, restRatioList, subsidyFeeList, subsidyRatioList []*VirtualCoinCommission, opt *PlanOpt) ([]*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, map[string]struct{}) {

restAmtMap := convertList2Map(restAmtList)
totalAmtMap := convertList2Map(totalAmtList)
//profitMap := convertList2Map(profitList)
restRatioMap := convertList2Map(restRatioList)
totalRatioMap := convertList2Map(totalRatioList)
peerRateMap := convertList2Map(peerRateList)
subsidyMap := convertList2Map(subsidyFeeList)

zeroList := make(map[string]struct{})

newProfitList := make([]*VirtualCoinCommission, 0)
newRestAmtList := make([]*VirtualCoinCommission, 0)
newTotalRatioList := make([]*VirtualCoinCommission, 0)
newPeerRateList := make([]*VirtualCoinCommission, 0)
newSubsidyFeeList := subsidyFeeList
if opt == nil {
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList
}
if opt.UserRate == nil {
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList
}
if opt.UserRate[lv] == nil {
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList
}
//极差返利
if opt.UserRate[lv].PayMode == 0 && isOnlySubsidy == 0 {
for _, coin := range profitList {
profitOne := &VirtualCoinCommission{}
profitOne.Cid = coin.Cid
profitOne.Val = totalAmtMap[coin.Cid] * restRatioMap[coin.Cid]
// 不够扣了 设为0
if restAmtMap[coin.Cid] < profitOne.Val {
profitOne.Val = 0
zeroList[coin.Cid] = struct{}{}
}
// 分佣
newProfitList = append(newProfitList, profitOne)

//// 剩余
//restAmtMap[coin.Cid] -= profitOne.Val

//// 累计比例
//totalRatioMap[coin.Cid] += restRatioMap[coin.Cid]

// 同级累计比例
if _, ok := peerRateMap[coin.Cid]; !ok {
peerRateMap[coin.Cid] = 0
}
peerRateMap[coin.Cid] += restRatioMap[coin.Cid]
}
} else if isOnlySubsidy == 1 {
newSubsidyFeeList = make([]*VirtualCoinCommission, 0)
for _, coin := range profitList {
profitOne := &VirtualCoinCommission{}
subsidyFeeOne := &VirtualCoinCommission{}

profitOne.Cid = coin.Cid
profitOne.Val = 0
newProfitList = append(newProfitList, profitOne)

if opt.UserRate[lv].PayMode == 0 {
subsidyFeeOne.Cid = coin.Cid
subsidyFeeOne.Val = subsidyMap[coin.Cid]
if restAmtMap[coin.Cid] < subsidyMap[coin.Cid] {
subsidyFeeOne.Val = 0
zeroList[coin.Cid] = struct{}{}
}
newSubsidyFeeList = append(newSubsidyFeeList, subsidyFeeOne)
}

//// 剩余额度
//restAmtMap[coin.Cid] -= subsidyFeeOne.Val

//// 累计比例
//totalRatioMap[coin.Cid] += subsidyRatioMap[coin.Cid]

// 同级累计比例
if _, ok := peerRateMap[coin.Cid]; !ok {
peerRateMap[coin.Cid] = 0
}
peerRateMap[coin.Cid] += restRatioMap[coin.Cid]
}
}

newTotalRatioList = convertMap2List(totalRatioMap)
newPeerRateList = convertMap2List(peerRateMap)
newRestAmtList = convertMap2List(restAmtMap)

return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList
}

Chargement…
Annuler
Enregistrer