|
@@ -78,8 +78,8 @@ Loop: |
|
|
//同级奖励比例 |
|
|
//同级奖励比例 |
|
|
commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatio(maxLv, userList.OwnbuyReturnType, peerNum, "same_lv", totalAmt, integralTotalAmt, opt) |
|
|
commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatio(maxLv, userList.OwnbuyReturnType, peerNum, "same_lv", totalAmt, integralTotalAmt, opt) |
|
|
//佣金 (lv, isOnlySubsidy int, restAmt, profit, peerRate, totalRatio, restRatio, subsidyFee, subsidyBili float64, opt *PlanOpt) |
|
|
//佣金 (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 = sameMoneyV2(node.Lv, isOnlySubsidyFee, totalAmtList, restAmtList, amountList, peerRateList, accumulateRatioList, ratioList, node.ParentUser.SubsidyFeeList, subsidyRatioList, opt) |
|
|
|
|
|
|
|
|
node.ParentUser.Profit, restAmt, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, isBreak = otherSameMoney(node.Lv, isOnlySubsidyFee, restAmt, commission, peerRate, totalCommissionRatio, commissionRatio, node.ParentUser.SubsidyFee, subsidyRatio, opt) |
|
|
|
|
|
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, peerRateList, node.ParentUser.SubsidyFeeList, zeroList = otherSameMoneyV2(node.Lv, isOnlySubsidyFee, totalAmtList, restAmtList, amountList, peerRateList, accumulateRatioList, ratioList, node.ParentUser.SubsidyFeeList, subsidyRatioList, opt) |
|
|
|
|
|
|
|
|
// 全部都没得分了 |
|
|
// 全部都没得分了 |
|
|
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { |
|
|
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { |
|
@@ -120,3 +120,132 @@ Loop: |
|
|
|
|
|
|
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//公共处理同级计算 (只计算佣金 旧版本用) |
|
|
|
|
|
func otherSameMoney(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, 6) |
|
|
|
|
|
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, 6) |
|
|
|
|
|
totalRatio += zhios_order_relate_utils.FloatFormat(subsidyBili, 6) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return profit, restAmt, totalRatio, peerRate, subsidyFee, false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func otherSameMoneyV2(lv, isOnlySubsidy int, totalAmtList, restAmtList, profitList, peerRateList, totalRatioList, restRatioList, subsidyFeeList, subsidyRatioList []*VirtualCoinCommission, opt *PlanOpt) ([]*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, map[string]struct{}) { |
|
|
|
|
|
|
|
|
|
|
|
restAmtMap := convertList2Map(restAmtList) |
|
|
|
|
|
totalAmtMap := convertList2Map(totalAmtList) |
|
|
|
|
|
//profitMap := convertList2Map(profitList) |
|
|
|
|
|
restRatioMap := convertList2Map(restRatioList) |
|
|
|
|
|
totalRatioMap := convertList2Map(totalRatioList) |
|
|
|
|
|
peerRateMap := convertList2Map(peerRateList) |
|
|
|
|
|
subsidyMap := convertList2Map(subsidyFeeList) |
|
|
|
|
|
|
|
|
|
|
|
zeroList := make(map[string]struct{}) |
|
|
|
|
|
|
|
|
|
|
|
newProfitList := make([]*VirtualCoinCommission, 0) |
|
|
|
|
|
newRestAmtList := make([]*VirtualCoinCommission, 0) |
|
|
|
|
|
newTotalRatioList := make([]*VirtualCoinCommission, 0) |
|
|
|
|
|
newPeerRateList := make([]*VirtualCoinCommission, 0) |
|
|
|
|
|
newSubsidyFeeList := subsidyFeeList |
|
|
|
|
|
if opt == nil { |
|
|
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList |
|
|
|
|
|
} |
|
|
|
|
|
if opt.UserRate == nil { |
|
|
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList |
|
|
|
|
|
} |
|
|
|
|
|
if opt.UserRate[lv] == nil { |
|
|
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList |
|
|
|
|
|
} |
|
|
|
|
|
//极差返利 |
|
|
|
|
|
if opt.UserRate[lv].PayMode == 0 && isOnlySubsidy == 0 { |
|
|
|
|
|
for _, coin := range profitList { |
|
|
|
|
|
profitOne := &VirtualCoinCommission{} |
|
|
|
|
|
profitOne.Cid = coin.Cid |
|
|
|
|
|
profitOne.Val = totalAmtMap[coin.Cid] * restRatioMap[coin.Cid] |
|
|
|
|
|
// 不够扣了 设为0 |
|
|
|
|
|
if restAmtMap[coin.Cid] < profitOne.Val { |
|
|
|
|
|
profitOne.Val = 0 |
|
|
|
|
|
zeroList[coin.Cid] = struct{}{} |
|
|
|
|
|
} |
|
|
|
|
|
// 分佣 |
|
|
|
|
|
newProfitList = append(newProfitList, profitOne) |
|
|
|
|
|
|
|
|
|
|
|
//// 剩余 |
|
|
|
|
|
//restAmtMap[coin.Cid] -= profitOne.Val |
|
|
|
|
|
|
|
|
|
|
|
//// 累计比例 |
|
|
|
|
|
//totalRatioMap[coin.Cid] += restRatioMap[coin.Cid] |
|
|
|
|
|
|
|
|
|
|
|
// 同级累计比例 |
|
|
|
|
|
if _, ok := peerRateMap[coin.Cid]; !ok { |
|
|
|
|
|
peerRateMap[coin.Cid] = 0 |
|
|
|
|
|
} |
|
|
|
|
|
peerRateMap[coin.Cid] += restRatioMap[coin.Cid] |
|
|
|
|
|
} |
|
|
|
|
|
} else if isOnlySubsidy == 1 { |
|
|
|
|
|
newSubsidyFeeList = make([]*VirtualCoinCommission, 0) |
|
|
|
|
|
for _, coin := range profitList { |
|
|
|
|
|
profitOne := &VirtualCoinCommission{} |
|
|
|
|
|
subsidyFeeOne := &VirtualCoinCommission{} |
|
|
|
|
|
|
|
|
|
|
|
profitOne.Cid = coin.Cid |
|
|
|
|
|
profitOne.Val = 0 |
|
|
|
|
|
newProfitList = append(newProfitList, profitOne) |
|
|
|
|
|
|
|
|
|
|
|
if opt.UserRate[lv].PayMode == 0 { |
|
|
|
|
|
subsidyFeeOne.Cid = coin.Cid |
|
|
|
|
|
subsidyFeeOne.Val = subsidyMap[coin.Cid] |
|
|
|
|
|
if restAmtMap[coin.Cid] < subsidyMap[coin.Cid] { |
|
|
|
|
|
subsidyFeeOne.Val = 0 |
|
|
|
|
|
zeroList[coin.Cid] = struct{}{} |
|
|
|
|
|
} |
|
|
|
|
|
newSubsidyFeeList = append(newSubsidyFeeList, subsidyFeeOne) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// 剩余额度 |
|
|
|
|
|
//restAmtMap[coin.Cid] -= subsidyFeeOne.Val |
|
|
|
|
|
|
|
|
|
|
|
//// 累计比例 |
|
|
|
|
|
//totalRatioMap[coin.Cid] += subsidyRatioMap[coin.Cid] |
|
|
|
|
|
|
|
|
|
|
|
// 同级累计比例 |
|
|
|
|
|
if _, ok := peerRateMap[coin.Cid]; !ok { |
|
|
|
|
|
peerRateMap[coin.Cid] = 0 |
|
|
|
|
|
} |
|
|
|
|
|
peerRateMap[coin.Cid] += restRatioMap[coin.Cid] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
newTotalRatioList = convertMap2List(totalRatioMap) |
|
|
|
|
|
newPeerRateList = convertMap2List(peerRateMap) |
|
|
|
|
|
newRestAmtList = convertMap2List(restAmtMap) |
|
|
|
|
|
|
|
|
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, newSubsidyFeeList, zeroList |
|
|
|
|
|
} |