|
|
@@ -329,11 +329,11 @@ Loop: |
|
|
|
if len(grade[node.ParentUser.Lv].TeamRateList) > 0 { |
|
|
|
teamRate = zhios_order_relate_utils.StrToFloat64(grade[node.ParentUser.Lv].TeamRateList["0"]) / 100 |
|
|
|
} |
|
|
|
node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoney(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, teamRate, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, 0) |
|
|
|
node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoneyDs(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, teamRate, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, 0) |
|
|
|
//积分 |
|
|
|
node.ParentUser.ProfitList = amountList |
|
|
|
// profitList []*VirtualCoinCommission, payMode, isOnlySubsidy int, totalAmtList, restAmtList, teamRatioList, totalRatioList, peerRateList, subsidyFeeList, subsidyRatioList []*VirtualCoinCommission |
|
|
|
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, accumulateRatioList, peerRateList, []*VirtualCoinCommission{}, []*VirtualCoinCommission{}) |
|
|
|
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2Ds(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, accumulateRatioList, peerRateList, []*VirtualCoinCommission{}, []*VirtualCoinCommission{}) |
|
|
|
|
|
|
|
// 没得分了 就结束 |
|
|
|
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { |
|
|
@@ -348,3 +348,86 @@ Loop: |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
func teamDiffMoneyDs(profit float64, payMode, isOnlySubsidy int, totalAmt, restAmt, teamRatio, totalRatio, peerRate, subsidyFee, subsidyRatio float64) (float64, float64, float64, float64, bool) { |
|
|
|
// 如果是团队内部支出团队比例大于同级累计比例 或站长支出 |
|
|
|
if payMode == 1 || teamRatio > peerRate { |
|
|
|
teamRatio = zhios_order_relate_utils.FloatFormat(teamRatio-totalRatio, 6) |
|
|
|
} |
|
|
|
//极差返利 |
|
|
|
if isOnlySubsidy == 0 { |
|
|
|
totalRatio += teamRatio |
|
|
|
//出现负数跳过 |
|
|
|
if teamRatio <= 0 { |
|
|
|
profit = 0 |
|
|
|
return profit, restAmt, totalRatio, subsidyFee, true |
|
|
|
} |
|
|
|
profit = zhios_order_relate_utils.FloatFormat(teamRatio*totalAmt, 6) |
|
|
|
if restAmt < profit { |
|
|
|
profit = 0 |
|
|
|
return profit, restAmt, totalRatio, subsidyFee, true |
|
|
|
} |
|
|
|
restAmt -= profit // 剩余可分 |
|
|
|
|
|
|
|
} else if isOnlySubsidy == 1 { //如果只返补贴 当成是极差的一部分 所以要扣 不是额外的 |
|
|
|
totalRatio += zhios_order_relate_utils.FloatFormat(subsidyRatio, 6) |
|
|
|
profit = 0 |
|
|
|
if restAmt < subsidyFee { |
|
|
|
profit = 0 |
|
|
|
subsidyFee = 0 |
|
|
|
return profit, restAmt, totalRatio, subsidyFee, true |
|
|
|
} |
|
|
|
restAmt -= subsidyFee // 剩余可分 |
|
|
|
} |
|
|
|
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 6) |
|
|
|
return profit, restAmt, totalRatio, subsidyFee, false |
|
|
|
} |
|
|
|
|
|
|
|
// 处理多虚拟币团队的 |
|
|
|
func teamDiffMoneyV2Ds(profitList []*VirtualCoinCommission, payMode, isOnlySubsidy int, totalAmtList, restAmtList, teamRatioList, totalRatioList, peerRateList, subsidyFeeList, subsidyRatioList []*VirtualCoinCommission) (newProfitList, newRestAmtList, newTotalRatioList, newSubsidyFeeList []*VirtualCoinCommission, zeroList map[string]struct{}) { |
|
|
|
restAmtMap := convertList2Map(restAmtList) |
|
|
|
totalAmtMap := convertList2Map(totalAmtList) |
|
|
|
profitMap := convertList2Map(profitList) |
|
|
|
totalRatioMap := convertList2Map(totalRatioList) |
|
|
|
peerRateMap := convertList2Map(peerRateList) |
|
|
|
subsidyFeeMap := convertList2Map(subsidyFeeList) |
|
|
|
subsidyRatioMap := convertList2Map(subsidyRatioList) |
|
|
|
teamRatioMap := convertList2Map(teamRatioList) |
|
|
|
|
|
|
|
zeroList = make(map[string]struct{}) |
|
|
|
newProfitList = make([]*VirtualCoinCommission, 0) |
|
|
|
|
|
|
|
for _, coin := range profitList { |
|
|
|
// 如果是团队内部支出团队比例大于同级累计比例 或站长支出 |
|
|
|
if payMode == 1 || teamRatioMap[coin.Cid] > peerRateMap[coin.Cid] { |
|
|
|
teamRatioMap[coin.Cid] = zhios_order_relate_utils.FloatFormat(teamRatioMap[coin.Cid]-totalRatioMap[coin.Cid], 6) |
|
|
|
} |
|
|
|
|
|
|
|
if isOnlySubsidy == 0 { |
|
|
|
totalRatioMap[coin.Cid] += teamRatioMap[coin.Cid] |
|
|
|
|
|
|
|
profitOne := &VirtualCoinCommission{} |
|
|
|
profitOne.Cid = coin.Cid |
|
|
|
profitOne.Val = zhios_order_relate_utils.FloatFormat(totalAmtMap[coin.Cid]*teamRatioMap[coin.Cid], 6) |
|
|
|
// 剩余不足或比例小于0 |
|
|
|
if teamRatioMap[coin.Cid] < 0 || restAmtMap[coin.Cid] < profitOne.Val { |
|
|
|
zeroList[coin.Cid] = struct{}{} |
|
|
|
profitOne.Val = 0 |
|
|
|
} |
|
|
|
newProfitList = append(newProfitList, profitOne) |
|
|
|
|
|
|
|
restAmtMap[coin.Cid] -= profitOne.Val |
|
|
|
} else if isOnlySubsidy == 1 { //如果只返补贴 当成是极差的一部分 所以要扣 不是额外的 |
|
|
|
totalRatioMap[coin.Cid] += zhios_order_relate_utils.FloatFormat(subsidyRatioMap[coin.Cid], 6) |
|
|
|
profitMap[coin.Cid] = 0 |
|
|
|
if restAmtMap[coin.Cid] < subsidyFeeMap[coin.Cid] { |
|
|
|
subsidyFeeMap[coin.Cid] = 0 |
|
|
|
} |
|
|
|
restAmtMap[coin.Cid] -= subsidyFeeMap[coin.Cid] |
|
|
|
} |
|
|
|
} |
|
|
|
newTotalRatioList = convertMap2List(totalRatioMap) |
|
|
|
newRestAmtList = convertMap2List(restAmtMap) |
|
|
|
newSubsidyFeeList = convertMap2List(subsidyFeeMap) |
|
|
|
|
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newSubsidyFeeList, zeroList |
|
|
|
} |