diff --git a/lib/comm_plan/winery_adv.go b/lib/comm_plan/winery_adv.go index a519e11..32540d0 100644 --- a/lib/comm_plan/winery_adv.go +++ b/lib/comm_plan/winery_adv.go @@ -158,19 +158,25 @@ func CalcAdv(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, maxLv = node.Lv // 当前等级 maxLevelWeight = node.LevelWeight // 当前权重 peerNum = 0 // 存在同级数 - + isFirst = 0 ) Loop: for node.ParentUser != nil { //查找上级用户 node.ParentUser.Profit = 0 count := len(grade[maxLv].PeerRate) - if grade[maxLv].PeerRateList != nil { + if grade[maxLv].NewPeerList != nil { count = len(grade[maxLv].PeerRateList) } var isBreak bool zeroList := make(map[string]struct{}) - if node.ParentUser.Diff == 1 { + if node.ParentUser.Lv == 0 { + node.ParentUser.LastProfitList = node.LastProfitList + node.ParentUser.LastProfit = node.LastProfit + node = node.ParentUser + continue + } + if isFirst == 0 { userType := "to_extend" commission, _, amountList, _ := CalReturnAmountAndRatioWineryAdv(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, userType, totalAmt, integralTotalAmt, opt) node.ParentUser.Profit = commission @@ -183,6 +189,7 @@ Loop: node.ParentUser.LastProfit = node.ParentUser.Profit // 等级往上升则置0 maxLevelWeight, maxLv, peerNum = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0 + isFirst = 1 } else { // 同级奖 if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum {