From a91c469f5574fcb74332307ba5a938f9ffa01824 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 14 Feb 2023 17:53:50 +0800 Subject: [PATCH] test --- lib/comm_plan/winery.go | 67 +++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/lib/comm_plan/winery.go b/lib/comm_plan/winery.go index 274f820..b93283d 100644 --- a/lib/comm_plan/winery.go +++ b/lib/comm_plan/winery.go @@ -124,44 +124,45 @@ Loop: if node.ParentUser.Lv > 2 && maxLvData != nil { node.ParentUser.LevelWeight = maxLvData.LevelWeight } - - // 同级奖 - 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 { - isNext := 0 - if isCus == 1 && extendUid > 0 { - //找出前两个人 如果不是就分团队奖 如果是就再找 - sql := `SELECT u.uid,u.first_arrive_at FROM user_profile up + isNext := 0 + //如果前一等级是团长 就不用判断这个了 + if isCus == 1 && extendUid > 0 { //店员才有值 + //找出前两个人 如果不是就分团队奖 如果是就再找 + sql := `SELECT u.uid,u.first_arrive_at FROM user_profile up LEFT JOIN user u on u.uid=up.uid WHERE up.parent_uid=? ORDER BY u.first_arrive_at asc,u.uid asc LIMIT 2` - nativeString, err := db.QueryNativeString(eg, sql, node.ParentUser.Uid) - if err != nil { - return zhios_order_relate_logx.Warn("sql error") - } - if len(nativeString) > 0 { - for _, v := range nativeString { - if zhios_order_relate_utils.StrToInt(v["uid"]) == extendUid { - isNext = 1 - extendUid = node.ParentUser.Uid - } + nativeString, err := db.QueryNativeString(eg, sql, node.ParentUser.Uid) + if err != nil { + return zhios_order_relate_logx.Warn("sql error") + } + if len(nativeString) > 0 { + for _, v := range nativeString { + if zhios_order_relate_utils.StrToInt(v["uid"]) == extendUid { + isNext = 1 + extendUid = node.ParentUser.Uid } } } - if isNext == 0 { + } + 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") }