diff --git a/lib/comm_plan/niubei_all.go b/lib/comm_plan/niubei_all.go index 2b8145b..defb771 100644 --- a/lib/comm_plan/niubei_all.go +++ b/lib/comm_plan/niubei_all.go @@ -71,19 +71,58 @@ func NiuBeiCalcAll(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *L userList.SubsidyFee = 0 // 各种币换算出总的额度 totalAmtList := make([]*VirtualCoinCommission, 0) + amountList := make([]*VirtualCoinCommission, 0) + for coinId, rate := range opt.VirtualCoinMoneyRatioList { + var amount float64 + if coinId == 0 { + amount = totalAmt + } else { + amount = integralTotalAmt * zhios_order_relate_utils.AnyToFloat64(rate) + } + totalAmtList = append(totalAmtList, &VirtualCoinCommission{ + Cid: zhios_order_relate_utils.AnyToString(coinId), + Val: amount, + }) + } var ( node = userList maxLv = node.Lv // 当前等级 - maxLevelWeight = node.LevelWeight // 当前权重 + maxLevelWeight = -2 // 当前权重 peerNum = 0 // 存在同级数 peerRate float64 = 0 // 同级累计比例 peerRateList = make([]*VirtualCoinCommission, 0) // 各虚拟币同级累计 restAmtList = make([]*VirtualCoinCommission, 0) // 各虚拟币剩余额度 accumulateRatioList = make([]*VirtualCoinCommission, 0) // 各虚拟币累计比例 + ratioList = make([]*VirtualCoinCommission, 0) // 各虚拟币累计比例 restAmt = totalAmt - userList.Profit // 剩余比例 totalCommissionRatio float64 = 0 // 累计佣金比例 ) + var returnType = make([]string, 0) + var maxReturnTypeCount = 0 + for _, v := range opt.UserRate { + if v.ReturnType != nil { + if len(v.ReturnType) > maxReturnTypeCount { + maxReturnTypeCount = len(v.ReturnType) + returnType = v.ReturnType + } + } + } + // 新版支持多种虚拟币 支持的种类id保存在ReturnType id=0代表现金佣金 其他为虚拟币 + if returnType != nil { //返佣类型 + + for _, coinId := range returnType { + amountList = append(amountList, &VirtualCoinCommission{ + Cid: coinId, + Val: 0, + }) + ratioList = append(ratioList, &VirtualCoinCommission{ + Cid: coinId, + Val: 0, + }) + } + } + restAmtList, _ = CalVirtualCommissionMinus(totalAmtList, amountList) Loop: for node.ParentUser != nil { //查找上级用户