|
@@ -43,6 +43,7 @@ func CalcWinery(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUs |
|
|
var ( |
|
|
var ( |
|
|
node = userList |
|
|
node = userList |
|
|
maxLv = node.Lv // 当前等级 |
|
|
maxLv = node.Lv // 当前等级 |
|
|
|
|
|
firstLevelWeight = node.LevelWeight // 当前权重 |
|
|
maxLevelWeight = node.LevelWeight // 当前权重 |
|
|
maxLevelWeight = node.LevelWeight // 当前权重 |
|
|
peerNum = 0 // 存在同级数 |
|
|
peerNum = 0 // 存在同级数 |
|
|
peerRate float64 = 0 // 同级累计比例 |
|
|
peerRate float64 = 0 // 同级累计比例 |
|
@@ -82,7 +83,24 @@ Loop: |
|
|
var isBreak bool |
|
|
var isBreak bool |
|
|
zeroList := make(map[string]struct{}) |
|
|
zeroList := make(map[string]struct{}) |
|
|
if node.ParentUser.Diff == 1 { |
|
|
if node.ParentUser.Diff == 1 { |
|
|
commission, _, amountList, teamRatioList := CalReturnAmountAndRatioExtendWinery(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "extend_lv", totalAmt, integralTotalAmt, opt) |
|
|
|
|
|
|
|
|
//找出前两个人 如果不是就分团队奖 如果是就再找 |
|
|
|
|
|
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.ParentUser.Uid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return zhios_order_relate_logx.Warn("sql error") |
|
|
|
|
|
} |
|
|
|
|
|
//定位 |
|
|
|
|
|
isPostion := 0 |
|
|
|
|
|
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 = 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.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) |
|
@@ -101,8 +119,8 @@ Loop: |
|
|
isCus = 1 |
|
|
isCus = 1 |
|
|
extendUid = node.ParentUser.Uid |
|
|
extendUid = node.ParentUser.Uid |
|
|
} |
|
|
} |
|
|
|
|
|
isPostion = 0 |
|
|
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 |
|
|
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 { |
|
|
} else { |
|
|
if node.ParentUser.Lv > 2 && maxLvData != nil { |
|
|
if node.ParentUser.Lv > 2 && maxLvData != nil { |
|
|
node.ParentUser.LevelWeight = maxLvData.LevelWeight |
|
|
node.ParentUser.LevelWeight = maxLvData.LevelWeight |
|
@@ -125,6 +143,7 @@ Loop: |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
maxLevelWeight = firstLevelWeight |
|
|
} |
|
|
} |
|
|
if isNext == 0 { |
|
|
if isNext == 0 { |
|
|
// 同级奖 |
|
|
// 同级奖 |
|
@@ -385,7 +404,7 @@ func CalReturnAmountAndRatioWineryTeam(level, ownbuyReturnType, peerNum int, use |
|
|
if coinId == "0" { |
|
|
if coinId == "0" { |
|
|
newFee = fee |
|
|
newFee = fee |
|
|
} |
|
|
} |
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId) |
|
|
|
|
|
|
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId, 0) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
amount = 0 |
|
|
amount = 0 |
|
@@ -434,7 +453,7 @@ func CalReturnAmountAndRatioWineryTeamNew(level, ownbuyReturnType, peerNum int, |
|
|
if coinId == "0" { |
|
|
if coinId == "0" { |
|
|
newFee = fee |
|
|
newFee = fee |
|
|
} |
|
|
} |
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId) |
|
|
|
|
|
|
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId, 0) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
amount = 0 |
|
|
amount = 0 |
|
@@ -494,7 +513,7 @@ func CalReturnAmountAndRatioWinery(level, ownbuyReturnType, peerNum int, userTyp |
|
|
if coinId == "0" { |
|
|
if coinId == "0" { |
|
|
newFee = profit |
|
|
newFee = profit |
|
|
} |
|
|
} |
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId) |
|
|
|
|
|
|
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId, 0) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
amount = 0 |
|
|
amount = 0 |
|
@@ -524,7 +543,7 @@ func CalReturnAmountAndRatioWinery(level, ownbuyReturnType, peerNum int, userTyp |
|
|
|
|
|
|
|
|
return commission, commissionRatio, amountList, ratioList |
|
|
return commission, commissionRatio, amountList, ratioList |
|
|
} |
|
|
} |
|
|
func CalReturnAmountAndRatioExtendWinery(level, ownbuyReturnType, peerNum int, userType string, fee, integralFee float64, opt *PlanOpt) (commission, commissionRatio float64, amountList, ratioList []*VirtualCoinCommission) { |
|
|
|
|
|
|
|
|
func CalReturnAmountAndRatioExtendWinery(level, ownbuyReturnType, peerNum int, userType string, fee, integralFee float64, opt *PlanOpt, isPostion int) (commission, commissionRatio float64, amountList, ratioList []*VirtualCoinCommission) { |
|
|
var maxReturnTypeCount = 0 |
|
|
var maxReturnTypeCount = 0 |
|
|
var returnType = make([]string, 0) |
|
|
var returnType = make([]string, 0) |
|
|
for _, v := range opt.UserRate { |
|
|
for _, v := range opt.UserRate { |
|
@@ -542,7 +561,7 @@ func CalReturnAmountAndRatioExtendWinery(level, ownbuyReturnType, peerNum int, u |
|
|
if coinId == "0" { |
|
|
if coinId == "0" { |
|
|
newFee = fee |
|
|
newFee = fee |
|
|
} |
|
|
} |
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId) |
|
|
|
|
|
|
|
|
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId, isPostion) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算 |
|
|
amount = 0 |
|
|
amount = 0 |
|
|