|
|
@@ -43,7 +43,6 @@ func CalcWinery(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUs |
|
|
|
var ( |
|
|
|
node = userList |
|
|
|
maxLv = node.Lv // 当前等级 |
|
|
|
firstLevelWeight = node.LevelWeight // 当前权重 |
|
|
|
maxLevelWeight = node.LevelWeight // 当前权重 |
|
|
|
peerNum = 0 // 存在同级数 |
|
|
|
peerRate float64 = 0 // 同级累计比例 |
|
|
@@ -125,45 +124,44 @@ Loop: |
|
|
|
if node.ParentUser.Lv > 2 && maxLvData != nil { |
|
|
|
node.ParentUser.LevelWeight = maxLvData.LevelWeight |
|
|
|
} |
|
|
|
isNext := 0 |
|
|
|
if isCus == 1 && extendUid > 0 { |
|
|
|
//找出前两个人 如果不是就分团队奖 如果是就再找 |
|
|
|
sql := `SELECT u.uid,u.first_arrive_at FROM user_profile up |
|
|
|
|
|
|
|
// 同级奖 |
|
|
|
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 |
|
|
|
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 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
maxLevelWeight = firstLevelWeight |
|
|
|
} |
|
|
|
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 isNext == 0 { |
|
|
|
if _, ok := grade[node.Lv]; !ok { |
|
|
|
return zhios_order_relate_logx.Warn("level grade node.Lv is not set") |
|
|
|
} |
|
|
|