浏览代码

链动制度

tags/v4.3.0
huangjiajun 1年前
父节点
当前提交
f82c768372
共有 1 个文件被更改,包括 80 次插入2 次删除
  1. +80
    -2
      lib/comm_plan/winery.go

+ 80
- 2
lib/comm_plan/winery.go 查看文件

@@ -138,8 +138,8 @@ Loop:
}
//新的团队奖
commission, _, amountList, teamRatioList := CalReturnAmountAndRatioWineryTeam(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "new_team", totalAmt, integralTotalAmt, opt)
commission, restAmt, newTotalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoneyWinery(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, newTotalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio)
amountList, restAmtList, newAccumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2Winery(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, newAccumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList)
commission, restAmt, newTotalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoneyWineryNew(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, newTotalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio)
amountList, restAmtList, newAccumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2WineryNew(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, newAccumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList)
amountMap := make(map[string]float64)
for _, v := range amountList {
amountMap[v.Cid] = v.Val
@@ -248,6 +248,84 @@ func teamDiffMoneyV2Winery(profitList []*VirtualCoinCommission, payMode, isOnlyS

return newProfitList, newRestAmtList, newTotalRatioList, newSubsidyFeeList, zeroList
}
func teamDiffMoneyWineryNew(profit float64, payMode, isOnlySubsidy int, totalAmt, restAmt, teamRatio, totalRatio, peerRate, subsidyFee, subsidyRatio float64) (float64, float64, float64, float64, bool) {
// 如果是团队内部支出团队比例大于同级累计比例 或站长支出
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, 2)
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, 2)
return profit, restAmt, totalRatio, subsidyFee, false
}

// 处理多虚拟币团队的
func teamDiffMoneyV2WineryNew(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)
subsidyFeeMap := convertList2Map(subsidyFeeList)
subsidyRatioMap := convertList2Map(subsidyRatioList)
teamRatioMap := convertList2Map(teamRatioList)

zeroList = make(map[string]struct{})
newProfitList = make([]*VirtualCoinCommission, 0)

for _, coin := range profitList {
// 如果是团队内部支出团队比例大于同级累计比例 或站长支出
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
}

func CalReturnAmountAndRatioWineryTeam(level, ownbuyReturnType, peerNum int, userType string, fee, integralFee float64, opt *PlanOpt) (commission, commissionRatio float64, amountList, ratioList []*VirtualCoinCommission) {
// 佣金的比例兼容旧系统 比例独立出来的 所以这样算


正在加载...
取消
保存