Browse Source

更新

tags/v4.3.0
huangjiajun 1 year ago
parent
commit
d9cba3259b
1 changed files with 84 additions and 2 deletions
  1. +84
    -2
      lib/comm_plan/ds_check.go

+ 84
- 2
lib/comm_plan/ds_check.go View File

@@ -8,6 +8,88 @@ import (
"xorm.io/xorm"
)

func CalReturnAmountAndRatioDsOwn(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 := getVirtualCoinRatioDsOwn(userType, level, peerNum, opt.UserRate, coinId, 0)
amount := getCoinAmount(ratio, zhios_order_relate_utils.StrToInt(coinId), newFee, opt.VirtualCoinMoneyRatioList)
if coinId == "0" {
commission = amount
}
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 getVirtualCoinRatioDsOwn(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 "extend_lv":
if isPostion == 1 {
ratio, ok = grade[level].SecondExtendList[coinId]
} else {
ratio, ok = grade[level].NewExtendList[coinId]
}
case "team":
ratio, ok = grade[level].TeamRateList[coinId]
case "new_team":
ratio, ok = grade[level].NewTeamList[coinId]
case "same_lv":
ratio, ok = grade[level].PeerRateList[peerNum][coinId]
case "same_extend":
ratio, ok = grade[level].SameExtend[peerNum][coinId]
default:
ratio, ok = grade[level].SelfRateList[coinId]
}
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 4)

if !ok {
ratio = "0"
}
return
}

func CalReturnAmountAndRatioDs(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)
@@ -116,7 +198,7 @@ func CalcDsCheck(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvU
}

//查出用户自购佣金
commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatio(userList.Lv, userList.OwnbuyReturnType, 0, "own", totalAmt, integralTotalAmt, opt)
commission, commissionRatio, amountList, ratioList := CalReturnAmountAndRatioDsOwn(userList.Lv, userList.OwnbuyReturnType, 0, "own", totalAmt, integralTotalAmt, opt)
userList.Profit = commission // 另外出来的佣金 兼容旧的
userList.ProfitList = amountList // 各币种分佣
userList.SubsidyFee = 0
@@ -222,7 +304,7 @@ Loop:
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)
commission, _, amountList, teamRatioList := CalReturnAmountAndRatioDsOwn(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum, "team", 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, 0)


Loading…
Cancel
Save