|
|
@@ -0,0 +1,420 @@ |
|
|
|
package comm_plan |
|
|
|
|
|
|
|
import ( |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" |
|
|
|
"fmt" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func CalReturnAmountAndRatioWineryAdv(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 := getVirtualCoinRatioWineryAdv(userType, level, peerNum, opt.UserRate, coinId, 0) |
|
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
|
if userType == "own" { //酒庄模式不在这里计算 |
|
|
|
amount = 0 |
|
|
|
commission = 0 |
|
|
|
} |
|
|
|
if coinId == "0" { |
|
|
|
commission = amount |
|
|
|
commissionRatio = zhios_order_relate_utils.StrToFloat64(ratio) |
|
|
|
} |
|
|
|
amountList = append(amountList, &VirtualCoinCommission{ |
|
|
|
Cid: coinId, |
|
|
|
Val: amount, |
|
|
|
ProfitBili: zhios_order_relate_utils.AnyToFloat64(ratio), |
|
|
|
}) |
|
|
|
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 CalReturnAmountAndRatioWineryAdvTeam(node *LvUser, level, peerNum int, userType string, 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 { |
|
|
|
var newFee float64 = 0 |
|
|
|
if len(node.LastProfitList) > 0 { |
|
|
|
for _, v := range node.LastProfitList { |
|
|
|
if v.Cid == coinId { |
|
|
|
newFee = v.Val |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if coinId == "0" { |
|
|
|
newFee = node.LastProfit |
|
|
|
} |
|
|
|
ratio := getVirtualCoinRatioWineryAdv(userType, level, peerNum, opt.UserRate, coinId, 0) |
|
|
|
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList) |
|
|
|
if userType == "own" { //酒庄模式不在这里计算 |
|
|
|
amount = 0 |
|
|
|
commission = 0 |
|
|
|
} |
|
|
|
if coinId == "0" { |
|
|
|
commission = amount |
|
|
|
commissionRatio = zhios_order_relate_utils.StrToFloat64(ratio) |
|
|
|
} |
|
|
|
amountList = append(amountList, &VirtualCoinCommission{ |
|
|
|
Cid: coinId, |
|
|
|
Val: amount, |
|
|
|
ProfitBili: zhios_order_relate_utils.AnyToFloat64(ratio), |
|
|
|
}) |
|
|
|
ratioList = append(ratioList, &VirtualCoinCommission{ |
|
|
|
Cid: coinId, |
|
|
|
Val: zhios_order_relate_utils.AnyToFloat64(ratio), |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
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 CalcAdv(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, level, levelWeight int, eg *xorm.Engine) error { |
|
|
|
grade := opt.UserRate |
|
|
|
if len(grade) == 0 { |
|
|
|
return zhios_order_relate_logx.Warn("level grade is not set") |
|
|
|
} |
|
|
|
userList.Profit = 0 |
|
|
|
userList.ProfitList = make([]*VirtualCoinCommission, 0) // 各币种分佣 |
|
|
|
userList.SubsidyFee = 0 |
|
|
|
|
|
|
|
userList.LastProfit = totalAmt |
|
|
|
userList.LastProfitList = make([]*VirtualCoinCommission, 0) |
|
|
|
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 := integralTotalAmt |
|
|
|
if coinId == "0" { |
|
|
|
newFee = totalAmt |
|
|
|
} |
|
|
|
if coinId == "0" { |
|
|
|
continue |
|
|
|
} |
|
|
|
userList.LastProfitList = append(userList.LastProfitList, &VirtualCoinCommission{ |
|
|
|
Cid: coinId, |
|
|
|
Val: newFee, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
var ( |
|
|
|
node = userList |
|
|
|
maxLv = node.Lv // 当前等级 |
|
|
|
maxLevelWeight = node.LevelWeight // 当前权重 |
|
|
|
peerNum = 0 // 存在同级数 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
Loop: |
|
|
|
for node.ParentUser != nil { //查找上级用户 |
|
|
|
node.ParentUser.Profit = 0 |
|
|
|
count := len(grade[maxLv].PeerRate) |
|
|
|
if grade[maxLv].PeerRateList != nil { |
|
|
|
count = len(grade[maxLv].PeerRateList) |
|
|
|
} |
|
|
|
var isBreak bool |
|
|
|
zeroList := make(map[string]struct{}) |
|
|
|
if node.ParentUser.Diff == 1 { |
|
|
|
userType := "to_extend" |
|
|
|
commission, _, amountList, _ := CalReturnAmountAndRatioWineryAdv(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, userType, totalAmt, integralTotalAmt, opt) |
|
|
|
node.ParentUser.Profit = commission |
|
|
|
node.ParentUser.ProfitList = amountList |
|
|
|
// 没得分了 就结束 |
|
|
|
if isBreak && len(zeroList) == len(opt.UserRate[maxLv].ReturnType) { |
|
|
|
break Loop |
|
|
|
} |
|
|
|
node.ParentUser.LastProfitList = node.ParentUser.ProfitList |
|
|
|
node.ParentUser.LastProfit = node.ParentUser.Profit |
|
|
|
// 等级往上升则置0 |
|
|
|
maxLevelWeight, maxLv, peerNum = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0 |
|
|
|
} else { |
|
|
|
// 同级奖 |
|
|
|
if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum { |
|
|
|
//同级奖励比例 |
|
|
|
commission, _, amountList, _ := CalReturnAmountAndRatioWineryAdvTeam(node, maxLv, peerNum, "same_lv", opt) |
|
|
|
node.ParentUser.Profit = commission |
|
|
|
node.ParentUser.ProfitList = amountList |
|
|
|
if peerNum+1 == count { |
|
|
|
node.ParentUser.LastProfitList = node.LastProfitList |
|
|
|
node.ParentUser.LastProfit = node.LastProfit |
|
|
|
} else { |
|
|
|
node.ParentUser.LastProfitList = node.ParentUser.ProfitList |
|
|
|
node.ParentUser.LastProfit = node.ParentUser.Profit |
|
|
|
} |
|
|
|
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, _ := CalReturnAmountAndRatioWineryAdvTeam(node, node.ParentUser.Lv, peerNum, "to_team", opt) |
|
|
|
node.ParentUser.Profit = commission |
|
|
|
node.ParentUser.ProfitList = amountList |
|
|
|
node.ParentUser.LastProfitList = node.ParentUser.ProfitList |
|
|
|
node.ParentUser.LastProfit = node.ParentUser.Profit |
|
|
|
// 等级往上升则置0 |
|
|
|
maxLevelWeight, maxLv, peerNum = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0 |
|
|
|
} |
|
|
|
} |
|
|
|
node.Profit = zhios_order_relate_utils.StrToFloat64(fmt.Sprintf("%.4f", node.Profit)) |
|
|
|
node = node.ParentUser |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
//公共处理同级计算 (只计算佣金 旧版本用) |
|
|
|
func sameMoneyWineryAdv(node *LvUser, restAmt, profit, peerRate, totalRatio, restRatio float64, opt *PlanOpt) (float64, float64, float64, float64, bool) { |
|
|
|
lv := node.Lv |
|
|
|
//如果不够扣了,并且是比例返利就跳过 |
|
|
|
if restAmt < profit { |
|
|
|
return 0, restAmt, totalRatio, peerRate, true |
|
|
|
} |
|
|
|
if opt == nil { |
|
|
|
return 0, restAmt, totalRatio, peerRate, true |
|
|
|
} |
|
|
|
if opt.UserRate == nil { |
|
|
|
return 0, restAmt, totalRatio, peerRate, true |
|
|
|
} |
|
|
|
if opt.UserRate[lv] == nil { |
|
|
|
return 0, restAmt, totalRatio, peerRate, true |
|
|
|
} |
|
|
|
//极差返利 |
|
|
|
if opt.UserRate[lv].PayMode == 0 { |
|
|
|
restAmt -= profit // 剩余可分 |
|
|
|
restAmt = zhios_order_relate_utils.FloatFormat(restAmt, 2) |
|
|
|
peerRate += restRatio |
|
|
|
totalRatio += restRatio |
|
|
|
} |
|
|
|
return profit, restAmt, totalRatio, peerRate, false |
|
|
|
} |
|
|
|
|
|
|
|
func sameMoneyV2WineryAdv(node *LvUser, totalAmtList, restAmtList, profitList, peerRateList, totalRatioList, restRatioList []*VirtualCoinCommission, opt *PlanOpt) ([]*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, []*VirtualCoinCommission, map[string]struct{}) { |
|
|
|
lv := node.Lv |
|
|
|
restAmtMap := convertList2Map(restAmtList) |
|
|
|
totalAmtMap := convertList2Map(totalAmtList) |
|
|
|
//profitMap := convertList2Map(profitList) |
|
|
|
restRatioMap := convertList2Map(restRatioList) |
|
|
|
totalRatioMap := convertList2Map(totalRatioList) |
|
|
|
peerRateMap := convertList2Map(peerRateList) |
|
|
|
|
|
|
|
zeroList := make(map[string]struct{}) |
|
|
|
|
|
|
|
newProfitList := make([]*VirtualCoinCommission, 0) |
|
|
|
newRestAmtList := make([]*VirtualCoinCommission, 0) |
|
|
|
newTotalRatioList := make([]*VirtualCoinCommission, 0) |
|
|
|
newPeerRateList := make([]*VirtualCoinCommission, 0) |
|
|
|
if opt == nil { |
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, zeroList |
|
|
|
} |
|
|
|
if opt.UserRate == nil { |
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, zeroList |
|
|
|
} |
|
|
|
if opt.UserRate[lv] == nil { |
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, zeroList |
|
|
|
} |
|
|
|
//极差返利 |
|
|
|
if opt.UserRate[lv].PayMode == 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] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newTotalRatioList = convertMap2List(totalRatioMap) |
|
|
|
newPeerRateList = convertMap2List(peerRateMap) |
|
|
|
newRestAmtList = convertMap2List(restAmtMap) |
|
|
|
|
|
|
|
return newProfitList, newRestAmtList, newTotalRatioList, newPeerRateList, zeroList |
|
|
|
} |
|
|
|
|
|
|
|
//公共处理下团队-上一层 (用于旧版的制度 只有佣金时) |
|
|
|
func teamDiffMoneyWineryAdv(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 teamDiffMoneyV2WineryAdv(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 |
|
|
|
} |
|
|
|
|
|
|
|
// 获取佣金、虚拟币比例 0=佣金 |
|
|
|
func getVirtualCoinRatioWineryAdv(typ string, level, peerNum int, grade map[int]*LvGrade, coinId string, isPostion int) (ratio string) { |
|
|
|
if grade[level].ReturnType == nil { |
|
|
|
return "0" |
|
|
|
} |
|
|
|
if zhios_order_relate_utils.InArr(coinId, grade[level].ReturnType) == false { |
|
|
|
return "0" |
|
|
|
} |
|
|
|
ok := false |
|
|
|
switch typ { |
|
|
|
case "same_lv": |
|
|
|
ratio, ok = grade[level].PeerRateList[peerNum][coinId] |
|
|
|
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4) |
|
|
|
case "to_extend": |
|
|
|
ratio, ok = grade[level].ToExtendList[coinId] |
|
|
|
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4) |
|
|
|
case "to_team": |
|
|
|
ratio, ok = grade[level].ToTeamList[coinId] |
|
|
|
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4) |
|
|
|
default: |
|
|
|
ratio = "0" |
|
|
|
} |
|
|
|
if !ok { |
|
|
|
ratio = "0" |
|
|
|
} |
|
|
|
return |
|
|
|
} |