diff --git a/lib/comm_plan/winery.go b/lib/comm_plan/winery.go index 1655828..e463dfd 100644 --- a/lib/comm_plan/winery.go +++ b/lib/comm_plan/winery.go @@ -57,6 +57,7 @@ func CalcWinery(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUs sameProfitList = make([]*VirtualCoinCommission, 0) isCus = 0 extendUid = 0 + firstLvWeight = 0 ) // 计算剩余额度 restAmtList, _ = CalVirtualCommissionMinus(totalAmtList, amountList) @@ -121,13 +122,11 @@ Loop: if isPostion == 1 { //只要是前2个会员 都走店员----店员逻辑 isCus = 1 extendUid = node.ParentUser.Uid + firstLvWeight = node.ParentUser.LevelWeight } else { maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList, isCus, extendUid = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList, isCus, extendUid } } else { - if node.ParentUser.Lv > 2 && maxLvData != nil { - node.ParentUser.LevelWeight = maxLvData.LevelWeight - } isNext := 0 //如果前一等级是团长 就不用判断这个了 if isCus == 1 && extendUid > 0 { //店员才有值 @@ -148,51 +147,58 @@ Loop: } } } - if isNext == 0 { - // 同级奖 - if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum { - - peerRate = 0 - //同级奖励比例 - commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatioWinery(maxLv, userList.OwnbuyReturnType, peerNum, "same_lv", sameProfit, sameProfitList, 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 = sameMoneyV2Winery(node.Lv, isOnlySubsidyFee, totalAmtList, restAmtList, amountList, peerRateList, accumulateRatioList, ratioList, node.ParentUser.SubsidyFeeList, subsidyRatioList, opt) - - // 全部都没得分了 - if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { - break Loop - } - isCus = 0 - extendUid = 0 - peerNum++ - } else if node.ParentUser.LevelWeight > maxLevelWeight { - if _, ok := grade[node.Lv]; !ok { - return zhios_order_relate_logx.Warn("level grade node.Lv is not set") - } - if _, ok := grade[node.ParentUser.Lv]; !ok { - return zhios_order_relate_logx.Warn("level grade node.ParentUser.Lv is not set") - } + //如果前一个等级比这个等级高,就跳过 并设extendUid + if node.ParentUser.LevelWeight >= firstLvWeight { + if node.ParentUser.Lv > 2 && maxLvData != nil { + node.ParentUser.LevelWeight = maxLvData.LevelWeight + } + if isNext == 0 { + // 同级奖 + if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum { + + peerRate = 0 + //同级奖励比例 + commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatioWinery(maxLv, userList.OwnbuyReturnType, peerNum, "same_lv", sameProfit, sameProfitList, 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 = sameMoneyV2Winery(node.Lv, isOnlySubsidyFee, totalAmtList, restAmtList, amountList, peerRateList, accumulateRatioList, ratioList, node.ParentUser.SubsidyFeeList, subsidyRatioList, opt) + + // 全部都没得分了 + if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { + break Loop + } + isCus = 0 + extendUid = 0 + peerNum++ + } else if node.ParentUser.LevelWeight > maxLevelWeight { + if _, ok := grade[node.Lv]; !ok { + return zhios_order_relate_logx.Warn("level grade node.Lv is not set") + } + if _, ok := grade[node.ParentUser.Lv]; !ok { + return zhios_order_relate_logx.Warn("level grade node.ParentUser.Lv is not set") + } - //原来的团队奖 - commission1, _, amountList1, teamRatioList1 := CalReturnAmountAndRatioWineryTeam(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "team", totalAmt, integralTotalAmt, opt) - //佣金 - node.ParentUser.Profit = commission1 - node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoneyWinery(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio) - //积分 - node.ParentUser.ProfitList = amountList1 - node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2Winery(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList1, accumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList) - - // 没得分了 就结束 - if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { - break Loop - } - if node.ParentUser.Lv > 2 && maxLvData != nil { - node.ParentUser.LevelWeight = maxLvData.LevelWeight + //原来的团队奖 + commission1, _, amountList1, teamRatioList1 := CalReturnAmountAndRatioWineryTeam(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "team", totalAmt, integralTotalAmt, opt) + //佣金 + node.ParentUser.Profit = commission1 + node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoneyWinery(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio) + //积分 + node.ParentUser.ProfitList = amountList1 + node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2Winery(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList1, accumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList) + + // 没得分了 就结束 + if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { + break Loop + } + if node.ParentUser.Lv > 2 && maxLvData != nil { + node.ParentUser.LevelWeight = maxLvData.LevelWeight + } + // 等级往上升则置0 + maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList, isCus, extendUid = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList, 0, 0 } - // 等级往上升则置0 - maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList, isCus, extendUid = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList, 0, 0 } + } } //新的团队奖