Pārlūkot izejas kodu

链动制度

tags/v4.3.0
huangjiajun pirms 1 gada
vecāks
revīzija
fe57dbe556
3 mainītis faili ar 321 papildinājumiem un 50 dzēšanām
  1. +8
    -2
      lib/comm_plan/all.go
  2. +2
    -0
      lib/comm_plan/init.go
  3. +311
    -48
      lib/comm_plan/winery.go

+ 8
- 2
lib/comm_plan/all.go Parādīt failu

@@ -249,7 +249,7 @@ func sameMoney(lv, isOnlySubsidy int, restAmt, profit, peerRate, totalRatio, res
restAmt -= profit // 剩余可分
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 2)
peerRate += restRatio
totalRatio += restRatio
//totalRatio += restRatio
} else if isOnlySubsidy == 1 { //如果只返补贴 当成是极差的一部分 所以要扣 不是额外的
profit = 0
if opt.UserRate[lv].PayMode == 0 {
@@ -259,7 +259,7 @@ func sameMoney(lv, isOnlySubsidy int, restAmt, profit, peerRate, totalRatio, res
}
restAmt -= subsidyFee // 剩余可分
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 2)
totalRatio += zhios_order_relate_utils.FloatFormat(subsidyBili, 6)
//totalRatio += zhios_order_relate_utils.FloatFormat(subsidyBili, 6)
}
}
return profit, restAmt, totalRatio, peerRate, subsidyFee, false
@@ -709,8 +709,14 @@ func getVirtualCoinRatio(typ string, level, peerNum int, grade map[int]*LvGrade,
}
ok := false
switch typ {
case "extend_lv":
ratio, ok = grade[level].NewExtendList[coinId]
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4)
case "team":
ratio, ok = grade[level].TeamRateList[coinId]
case "new_team":
ratio, ok = grade[level].NewTeamList[coinId]
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4)
case "same_lv":
ratio, ok = grade[level].PeerRateList[peerNum][coinId]
default:


+ 2
- 0
lib/comm_plan/init.go Parādīt failu

@@ -60,6 +60,8 @@ type LvGrade struct {
ReturnType []string `json:"return_type"` //返利类型
SelfRateList map[string]string `json:"self_rate_list"` // 自购比例
TeamRateList map[string]string `json:"team_rate_list"` // 团队最高比例
NewTeamList map[string]string `json:"new_team_list"` // 新团队比例
NewExtendList map[string]string `json:"new_extend_list"` // 直推比例
SubsidyModeList map[string]interface{} `json:"subsidy_mode_list"` // 各币种返佣模式:bili:比例 money:固定金额
//SubsidyBlockIconsMode string `json:"subsidy_block_icons_mode"` //分销 区块币返利类型 bili 比例 money 固定金额
//SubsidyCommissionMode string `json:"subsidy_commission_mode"` //分销 佣金返利类型 bili 比例 money 固定金额


+ 311
- 48
lib/comm_plan/winery.go Parādīt failu

@@ -39,19 +39,20 @@ func CalcWinery(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUs
}

var (
node = userList
maxLv = node.Lv // 当前等级
maxLevelWeight = node.LevelWeight // 当前权重
peerNum = 0 // 存在同级数
peerRate float64 = 0 // 同级累计比例
peerRateList = make([]*VirtualCoinCommission, 0) // 各虚拟币同级累计
restAmtList = make([]*VirtualCoinCommission, 0) // 各虚拟币剩余额度
accumulateRatioList = make([]*VirtualCoinCommission, 0) // 各虚拟币累计比例
restAmt = totalAmt - userList.Profit // 剩余比例
totalCommissionRatio = commissionRatio // 累计佣金比例
first = 1
sameProfit float64 = 0
sameProfitList = make([]*VirtualCoinCommission, 0)
node = userList
maxLv = node.Lv // 当前等级
maxLevelWeight = node.LevelWeight // 当前权重
peerNum = 0 // 存在同级数
peerRate float64 = 0 // 同级累计比例
peerRateList = make([]*VirtualCoinCommission, 0) // 各虚拟币同级累计
restAmtList = make([]*VirtualCoinCommission, 0) // 各虚拟币剩余额度
accumulateRatioList = make([]*VirtualCoinCommission, 0) // 各虚拟币累计比例
newAccumulateRatioList = make([]*VirtualCoinCommission, 0) // 各虚拟币累计比例
restAmt = totalAmt - userList.Profit // 剩余比例
totalCommissionRatio = commissionRatio // 累计佣金比例
newTotalCommissionRatio float64 = 0 // 累计佣金比例
sameProfit float64 = 0
sameProfitList = make([]*VirtualCoinCommission, 0)
)
// 计算剩余额度
restAmtList, _ = CalVirtualCommissionMinus(totalAmtList, amountList)
@@ -76,51 +77,79 @@ Loop:
}
var isBreak bool
zeroList := make(map[string]struct{})
// 同级奖
if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum {
var commission float64
var commissionRatio float64
var amountList = make([]*VirtualCoinCommission, 0)
var ratioList = make([]*VirtualCoinCommission, 0)
peerRate = 0
//同级奖励比例
if first == 0 {
commission, commissionRatio, amountList, ratioList = CalReturnAmountAndRatioWinery(maxLv, userList.OwnbuyReturnType, peerNum, "same_lv", sameProfit, sameProfitList, opt)
} else {
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)
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
}
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")
}
if _, ok := grade[node.ParentUser.Lv]; !ok {
return zhios_order_relate_logx.Warn("level grade node.ParentUser.Lv is not set")
}
commission, _, amountList, teamRatioList := CalReturnAmountAndRatio(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "team", totalAmt, integralTotalAmt, opt)
if node.ParentUser.Diff == 1 {
commission, _, amountList, teamRatioList := CalReturnAmountAndRatioExtendWinery(maxLv, userList.OwnbuyReturnType, peerNum, "extend_lv", totalAmt, integralTotalAmt, opt)
//佣金
node.ParentUser.Profit = commission
node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoney(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)
//积分
node.ParentUser.ProfitList = amountList
// profitList []*VirtualCoinCommission, payMode, isOnlySubsidy int, totalAmtList, restAmtList, teamRatioList, totalRatioList, peerRateList, subsidyFeeList, subsidyRatioList []*VirtualCoinCommission
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, accumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList)
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
}
// 等级往上升则置0
maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, first, sameProfit, sameProfitList = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, 0, node.ParentUser.Profit, node.ParentUser.ProfitList
maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList
} else {
// 同级奖
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
}
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")
}
if _, ok := grade[node.ParentUser.Lv]; !ok {
return zhios_order_relate_logx.Warn("level grade node.ParentUser.Lv is not set")
}
//新的团队奖
commission, _, amountList, teamRatioList := CalReturnAmountAndRatioWineryTeam(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "new_team", totalAmt, integralTotalAmt, opt)
commission, restAmt, newTotalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoneyWinery(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, newTotalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio)
node.ParentUser.ProfitList = amountList
amountList, restAmtList, newAccumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2Winery(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList, newAccumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList)
amountMap := make(map[string]float64)
for _, v := range amountList {
amountMap[v.Cid] = v.Val
}
//原来的团队奖
commission1, _, amountList1, teamRatioList1 := CalReturnAmountAndRatioWineryTeam(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "team", totalAmt, integralTotalAmt, opt)
//佣金
node.ParentUser.Profit = commission1
node.ParentUser.Profit, restAmt, totalCommissionRatio, node.ParentUser.SubsidyFee, isBreak = teamDiffMoneyWinery(node.ParentUser.Profit, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmt, restAmt, grade[node.ParentUser.Lv].TeamRate, totalCommissionRatio, peerRate, node.ParentUser.SubsidyFee, subsidyRatio)
node.ParentUser.Profit += commission
//积分
node.ParentUser.ProfitList = amountList1
node.ParentUser.ProfitList, restAmtList, accumulateRatioList, node.ParentUser.SubsidyFeeList, zeroList = teamDiffMoneyV2Winery(node.ParentUser.ProfitList, grade[node.Lv].PayMode, isOnlySubsidyFee, totalAmtList, restAmtList, teamRatioList1, accumulateRatioList, peerRateList, subsidyFeeList, subsidyRatioList)
for _, v := range node.ParentUser.ProfitList {
amountMap[v.Cid] += amountMap[v.Cid]
}
var tmp = make([]*VirtualCoinCommission, 0)
for k, v := range amountMap {
var tmp1 = &VirtualCoinCommission{Cid: k, Val: v}
tmp = append(tmp, tmp1)
}
node.ParentUser.ProfitList = tmp
// 没得分了 就结束
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) {
break Loop
}
// 等级往上升则置0
maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList
}
}

//如果是酒庄制度,要看这里处理 额外的补贴
subsidyFee, subsidyRatio, isOnlySubsidyFee, subsidyFeeList, subsidyRatioList = subsidyFeeDo(opt, totalAmt, integralTotalAmt, node.ParentUser, userList.NewLv, pvd, sysFee, integralSysFee)
node.ParentUser.SubsidyFee = subsidyFee
@@ -131,6 +160,142 @@ Loop:

return nil
}
func teamDiffMoneyWinery(profit float64, payMode, isOnlySubsidy int, totalAmt, restAmt, teamRatio, totalRatio, peerRate, subsidyFee, subsidyRatio float64) (float64, float64, float64, float64, bool) {
// 如果是团队内部支出团队比例大于同级累计比例 或站长支出
if payMode == 1 || teamRatio > peerRate {
teamRatio = zhios_order_relate_utils.FloatFormat(teamRatio-totalRatio, 6)
}
//极差返利
if isOnlySubsidy == 0 {
totalRatio += teamRatio
//出现负数跳过
if teamRatio <= 0 {
profit = 0
return profit, restAmt, totalRatio, subsidyFee, true
}
profit = zhios_order_relate_utils.FloatFormat(teamRatio*totalAmt, 2)
if restAmt < profit {
profit = 0
return profit, restAmt, totalRatio, subsidyFee, true
}
restAmt -= profit // 剩余可分

} else if isOnlySubsidy == 1 { //如果只返补贴 当成是极差的一部分 所以要扣 不是额外的
totalRatio += zhios_order_relate_utils.FloatFormat(subsidyRatio, 6)
profit = 0
if restAmt < subsidyFee {
profit = 0
subsidyFee = 0
return profit, restAmt, totalRatio, subsidyFee, true
}
restAmt -= subsidyFee // 剩余可分
}
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 2)
return profit, restAmt, totalRatio, subsidyFee, false
}

// 处理多虚拟币团队的
func teamDiffMoneyV2Winery(profitList []*VirtualCoinCommission, payMode, isOnlySubsidy int, totalAmtList, restAmtList, teamRatioList, totalRatioList, peerRateList, subsidyFeeList, subsidyRatioList []*VirtualCoinCommission) (newProfitList, newRestAmtList, newTotalRatioList, newSubsidyFeeList []*VirtualCoinCommission, zeroList map[string]struct{}) {
restAmtMap := convertList2Map(restAmtList)
totalAmtMap := convertList2Map(totalAmtList)
profitMap := convertList2Map(profitList)
totalRatioMap := convertList2Map(totalRatioList)
peerRateMap := convertList2Map(peerRateList)
subsidyFeeMap := convertList2Map(subsidyFeeList)
subsidyRatioMap := convertList2Map(subsidyRatioList)
teamRatioMap := convertList2Map(teamRatioList)

zeroList = make(map[string]struct{})
newProfitList = make([]*VirtualCoinCommission, 0)

for _, coin := range profitList {
// 如果是团队内部支出团队比例大于同级累计比例 或站长支出
if payMode == 1 || teamRatioMap[coin.Cid] > peerRateMap[coin.Cid] {
teamRatioMap[coin.Cid] = zhios_order_relate_utils.FloatFormat(teamRatioMap[coin.Cid]-totalRatioMap[coin.Cid], 6)
}

if isOnlySubsidy == 0 {
totalRatioMap[coin.Cid] += teamRatioMap[coin.Cid]

profitOne := &VirtualCoinCommission{}
profitOne.Cid = coin.Cid
profitOne.Val = zhios_order_relate_utils.FloatFormat(totalAmtMap[coin.Cid]*teamRatioMap[coin.Cid], 6)
// 剩余不足或比例小于0
if teamRatioMap[coin.Cid] < 0 || restAmtMap[coin.Cid] < profitOne.Val {
zeroList[coin.Cid] = struct{}{}
profitOne.Val = 0
}
newProfitList = append(newProfitList, profitOne)

restAmtMap[coin.Cid] -= profitOne.Val
} else if isOnlySubsidy == 1 { //如果只返补贴 当成是极差的一部分 所以要扣 不是额外的
totalRatioMap[coin.Cid] += zhios_order_relate_utils.FloatFormat(subsidyRatioMap[coin.Cid], 6)
profitMap[coin.Cid] = 0
if restAmtMap[coin.Cid] < subsidyFeeMap[coin.Cid] {
subsidyFeeMap[coin.Cid] = 0
}
restAmtMap[coin.Cid] -= subsidyFeeMap[coin.Cid]
}
}
newTotalRatioList = convertMap2List(totalRatioMap)
newRestAmtList = convertMap2List(restAmtMap)
newSubsidyFeeList = convertMap2List(subsidyFeeMap)

return newProfitList, newRestAmtList, newTotalRatioList, newSubsidyFeeList, zeroList
}

func CalReturnAmountAndRatioWineryTeam(level, ownbuyReturnType, peerNum int, userType string, fee, integralFee float64, opt *PlanOpt) (commission, commissionRatio float64, amountList, ratioList []*VirtualCoinCommission) {
// 佣金的比例兼容旧系统 比例独立出来的 所以这样算
commissionRatio = getCommissionRatio(userType, level, peerNum, opt.UserRate)
commission = fee * commissionRatio
var maxReturnTypeCount = 0
var returnType = make([]string, 0)
for _, v := range opt.UserRate {
if v.ReturnType != nil {
if len(v.ReturnType) > maxReturnTypeCount {
maxReturnTypeCount = len(v.ReturnType)
returnType = v.ReturnType
}
}
}
// 新版支持多种虚拟币 支持的种类id保存在ReturnType id=0代表现金佣金 其他为虚拟币
if returnType != nil { //返佣类型
for _, coinId := range returnType {
newFee := integralFee
if coinId == "0" {
newFee = fee
}
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId)
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList)
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算
amount = 0
}
amountList = append(amountList, &VirtualCoinCommission{
Cid: coinId,
Val: amount,
})
ratioList = append(ratioList, &VirtualCoinCommission{
Cid: coinId,
Val: zhios_order_relate_utils.AnyToFloat64(ratio),
})
}
}

if ownbuyReturnType == 1 { //自购不返利
commission = 0
for i := range amountList {
amountList[i].Val = 0
}
}
commission = zhios_order_relate_utils.FloatFormat(commission, 2)

for i, coin := range amountList {
amountList[i].Val = zhios_order_relate_utils.FloatFormat(coin.Val, 6)
}

return commission, commissionRatio, amountList, ratioList
}

func CalReturnAmountAndRatioWinery(level, ownbuyReturnType, peerNum int, userType string, profit float64, profitList []*VirtualCoinCommission, opt *PlanOpt) (commission, commissionRatio float64, amountList, ratioList []*VirtualCoinCommission) {
// 佣金的比例兼容旧系统 比例独立出来的 所以这样算
commissionRatio = getCommissionRatio(userType, level, peerNum, opt.UserRate)
@@ -187,3 +352,101 @@ func CalReturnAmountAndRatioWinery(level, ownbuyReturnType, peerNum int, userTyp

return commission, commissionRatio, amountList, ratioList
}
func CalReturnAmountAndRatioExtendWinery(level, ownbuyReturnType, peerNum int, userType string, fee, integralFee float64, opt *PlanOpt) (commission, commissionRatio float64, amountList, ratioList []*VirtualCoinCommission) {
var maxReturnTypeCount = 0
var returnType = make([]string, 0)
for _, v := range opt.UserRate {
if v.ReturnType != nil {
if len(v.ReturnType) > maxReturnTypeCount {
maxReturnTypeCount = len(v.ReturnType)
returnType = v.ReturnType
}
}
}
// 新版支持多种虚拟币 支持的种类id保存在ReturnType id=0代表现金佣金 其他为虚拟币
if returnType != nil { //返佣类型
for _, coinId := range returnType {
newFee := integralFee
if coinId == "0" {
newFee = fee
}
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId)
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList)
if coinId != "0" && opt.Mode == "lv_winery" && userType == "own" { //酒庄模式不在这里计算
amount = 0
}
amountList = append(amountList, &VirtualCoinCommission{
Cid: coinId,
Val: amount,
})
ratioList = append(ratioList, &VirtualCoinCommission{
Cid: coinId,
Val: zhios_order_relate_utils.AnyToFloat64(ratio),
})
}
}

if ownbuyReturnType == 1 { //自购不返利
commission = 0
for i := range amountList {
amountList[i].Val = 0
}
}
commission = zhios_order_relate_utils.FloatFormat(commission, 2)

for i, coin := range amountList {
amountList[i].Val = zhios_order_relate_utils.FloatFormat(coin.Val, 6)
}

return commission, commissionRatio, amountList, ratioList
}

//公共处理下团队-上一层 (用于旧版的制度 只有佣金时)
func extendDiffMoney(profit float64, payMode, isOnlySubsidy int, totalAmt, restAmt, teamRatio, totalRatio, peerRate, subsidyFee, subsidyRatio float64) (float64, float64, float64, float64, bool) {
//totalRatio += teamRatio
//出现负数跳过
if teamRatio <= 0 {
profit = 0
return profit, restAmt, totalRatio, subsidyFee, true
}
profit = zhios_order_relate_utils.FloatFormat(teamRatio*totalAmt, 2)
if restAmt < profit {
profit = 0
return profit, restAmt, totalRatio, subsidyFee, true
}
restAmt -= profit // 剩余可分
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 2)
return profit, restAmt, totalRatio, subsidyFee, false
}

// 处理多虚拟币团队的
func extendDiffMoneyV2(profitList []*VirtualCoinCommission, payMode, isOnlySubsidy int, totalAmtList, restAmtList, teamRatioList, totalRatioList, peerRateList, subsidyFeeList, subsidyRatioList []*VirtualCoinCommission) (newProfitList, newRestAmtList, newTotalRatioList, newSubsidyFeeList []*VirtualCoinCommission, zeroList map[string]struct{}) {
restAmtMap := convertList2Map(restAmtList)
totalAmtMap := convertList2Map(totalAmtList)
totalRatioMap := convertList2Map(totalRatioList)
subsidyFeeMap := convertList2Map(subsidyFeeList)
teamRatioMap := convertList2Map(teamRatioList)

zeroList = make(map[string]struct{})
newProfitList = make([]*VirtualCoinCommission, 0)

for _, coin := range profitList {
//totalRatioMap[coin.Cid] += teamRatioMap[coin.Cid]
profitOne := &VirtualCoinCommission{}
profitOne.Cid = coin.Cid
profitOne.Val = zhios_order_relate_utils.FloatFormat(totalAmtMap[coin.Cid]*teamRatioMap[coin.Cid], 6)
// 剩余不足或比例小于0
if teamRatioMap[coin.Cid] < 0 || restAmtMap[coin.Cid] < profitOne.Val {
zeroList[coin.Cid] = struct{}{}
profitOne.Val = 0
}
newProfitList = append(newProfitList, profitOne)
restAmtMap[coin.Cid] -= profitOne.Val

}
newTotalRatioList = convertMap2List(totalRatioMap)
newRestAmtList = convertMap2List(restAmtMap)
newSubsidyFeeList = convertMap2List(subsidyFeeMap)

return newProfitList, newRestAmtList, newTotalRatioList, newSubsidyFeeList, zeroList
}

Notiek ielāde…
Atcelt
Saglabāt