diff --git a/lib/comm_plan/all.go b/lib/comm_plan/all.go index e2244de..4ec84e8 100644 --- a/lib/comm_plan/all.go +++ b/lib/comm_plan/all.go @@ -233,6 +233,40 @@ Loop: //公共处理同级计算 (只计算佣金 旧版本用) func sameMoney(lv, isOnlySubsidy int, restAmt, profit, peerRate, totalRatio, restRatio, subsidyFee, subsidyBili float64, opt *PlanOpt) (float64, float64, float64, float64, float64, bool) { + //如果不够扣了,并且是比例返利就跳过 + if restAmt < profit { + return 0, restAmt, totalRatio, peerRate, subsidyFee, true + } + if opt == nil { + return 0, restAmt, totalRatio, peerRate, subsidyFee, true + } + if opt.UserRate == nil { + return 0, restAmt, totalRatio, peerRate, subsidyFee, true + } + if opt.UserRate[lv] == nil { + return 0, restAmt, totalRatio, peerRate, subsidyFee, true + } + //极差返利 + if opt.UserRate[lv].PayMode == 0 && isOnlySubsidy == 0 { + restAmt -= profit // 剩余可分 + restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 2) + peerRate += restRatio + totalRatio += restRatio + } else if isOnlySubsidy == 1 { //如果只返补贴 当成是极差的一部分 所以要扣 不是额外的 + profit = 0 + if opt.UserRate[lv].PayMode == 0 { + if restAmt < subsidyFee { + subsidyFee = 0 + return profit, restAmt, totalRatio, subsidyFee, peerRate, true + } + restAmt -= subsidyFee // 剩余可分 + restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 2) + totalRatio += zhios_order_relate_utils.FloatFormat(subsidyBili, 6) + } + } + return profit, restAmt, totalRatio, peerRate, subsidyFee, false +} +func sameMoneyWinery(lv, isOnlySubsidy int, restAmt, profit, peerRate, totalRatio, restRatio, subsidyFee, subsidyBili float64, opt *PlanOpt) (float64, float64, float64, float64, float64, bool) { //如果不够扣了,并且是比例返利就跳过 if restAmt < profit { return 0, restAmt, totalRatio, peerRate, subsidyFee, true diff --git a/lib/comm_plan/winery.go b/lib/comm_plan/winery.go index 4c81570..493fd7f 100644 --- a/lib/comm_plan/winery.go +++ b/lib/comm_plan/winery.go @@ -158,7 +158,7 @@ Loop: //同级奖励比例 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.Profit, restAmt, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, isBreak = sameMoneyWinery(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) // 全部都没得分了