|
|
@@ -57,6 +57,7 @@ func CalcWinery(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUs |
|
|
|
sameProfitList = make([]*VirtualCoinCommission, 0) |
|
|
|
isCus = 0 |
|
|
|
extendUid = 0 |
|
|
|
isEnd = 0 |
|
|
|
) |
|
|
|
// 计算剩余额度 |
|
|
|
restAmtList, _ = CalVirtualCommissionMinus(totalAmtList, amountList) |
|
|
@@ -81,47 +82,49 @@ Loop: |
|
|
|
} |
|
|
|
var isBreak bool |
|
|
|
zeroList := make(map[string]struct{}) |
|
|
|
if node.ParentUser.Diff == 1 { |
|
|
|
//定位 |
|
|
|
isPostion := 0 |
|
|
|
if node.ParentUser.ParentUser != nil && node.ParentUser.Lv > 0 { |
|
|
|
//找出前两个人 如果不是就分团队奖 如果是就再找 |
|
|
|
sql := `SELECT u.uid,u.first_arrive_at FROM user_profile up |
|
|
|
if isEnd != 1 { |
|
|
|
if node.ParentUser.Lv > 0 { //不是粉丝 |
|
|
|
//定位 |
|
|
|
isPostion := 0 |
|
|
|
if node.ParentUser.ParentUser != nil && node.ParentUser.Lv > 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=? and u.level>0 ORDER BY u.first_arrive_at asc,u.uid asc LIMIT 2` |
|
|
|
nativeString, err := db.QueryNativeString(eg, sql, node.ParentUser.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"]) == node.ParentUser.Uid { |
|
|
|
isPostion = 1 |
|
|
|
nativeString, err := db.QueryNativeString(eg, sql, node.ParentUser.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"]) == node.ParentUser.Uid { |
|
|
|
isPostion = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
commission, _, amountList, teamRatioList := CalReturnAmountAndRatioExtendWinery(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "extend_lv", totalAmt, integralTotalAmt, opt, isPostion) |
|
|
|
//佣金 |
|
|
|
node.ParentUser.Profit = commission |
|
|
|
node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = extendDiffMoney(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio) |
|
|
|
//积分 |
|
|
|
node.ParentUser.ProfitList = amountList |
|
|
|
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = extendDiffMoneyV2(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, accumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList) |
|
|
|
|
|
|
|
// 没得分了 就结束 |
|
|
|
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { |
|
|
|
break Loop |
|
|
|
} |
|
|
|
if node.ParentUser.Lv > 2 && maxLvData != nil { |
|
|
|
node.ParentUser.LevelWeight = maxLvData.LevelWeight |
|
|
|
} |
|
|
|
if isPostion == 1 { //只要是前2个会员 都走店员----店员逻辑 |
|
|
|
isCus = 1 |
|
|
|
extendUid = node.ParentUser.Uid |
|
|
|
} else { |
|
|
|
maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList, isCus, extendUid = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList, isCus, extendUid |
|
|
|
commission, _, amountList, teamRatioList := CalReturnAmountAndRatioExtendWinery(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "extend_lv", totalAmt, integralTotalAmt, opt, isPostion) |
|
|
|
//佣金 |
|
|
|
node.ParentUser.Profit = commission |
|
|
|
node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = extendDiffMoney(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio) |
|
|
|
//积分 |
|
|
|
node.ParentUser.ProfitList = amountList |
|
|
|
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = extendDiffMoneyV2(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, accumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList) |
|
|
|
isEnd = 1 |
|
|
|
// 没得分了 就结束 |
|
|
|
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { |
|
|
|
break Loop |
|
|
|
} |
|
|
|
if node.ParentUser.Lv > 2 && maxLvData != nil { |
|
|
|
node.ParentUser.LevelWeight = maxLvData.LevelWeight |
|
|
|
} |
|
|
|
if isPostion == 1 { //只要是前2个会员 都走店员----店员逻辑 |
|
|
|
isCus = 1 |
|
|
|
extendUid = node.ParentUser.Uid |
|
|
|
} else { |
|
|
|
maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList, isCus, extendUid = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList, isCus, extendUid |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
isNext := 0 |
|
|
|