Kaynağa Gözat

add reverse:for v3.1.9 制度加入总金额分佣不扣除同级奖励

tags/v3.1.9
huangjiajun 2 yıl önce
ebeveyn
işleme
8c013e7f61
6 değiştirilmiş dosya ile 56 ekleme ve 6 silme
  1. +12
    -0
      db/db_user_level.go
  2. +28
    -1
      lib/comm_plan/all.go
  3. +1
    -1
      lib/comm_plan/init.go
  4. +8
    -2
      lib/comm_plan/other.go
  5. +1
    -1
      lib/comm_plan/self.go
  6. +6
    -1
      svc/reward_commission.go

+ 12
- 0
db/db_user_level.go Dosyayı Görüntüle

@@ -37,6 +37,18 @@ func UserLevelDescByWeightLow(session *xorm.Session) (userIds []int, err error)
}
return userIds, nil

}
func UserLevelInIDescByWeightLowWithOne(Db *xorm.Engine) (*model.UserLevel, error) {
var ms model.UserLevel
has, err := Db.Asc("level_weight").Get(&ms)
if err != nil {
return nil, err
}
if has == false {
return nil, zhios_order_relate_logx.Warn(errors.New("等级不存在"))
}
return &ms, nil

}

// UserLevlEgAll is 获取所有开启等级并且升序返回


+ 28
- 1
lib/comm_plan/all.go Dosyayı Görüntüle

@@ -60,6 +60,33 @@ func CalReturnAmountAndRatio(level, ownbuyReturnType, peerNum int, userType stri
return commission, commissionRatio, amountList, ratioList
}

//佣金 积分 区块币计算
func CalReturnAmountAndRatioByLevel(level, ownbuyReturnType, peerNum int, userType string, fee, integralFee float64, opt *PlanOpt) (commissionRatio float64, ratioList []*VirtualCoinCommission) {
// 佣金的比例兼容旧系统 比例独立出来的 所以这样算
commissionRatio = getCommissionRatio(userType, level, peerNum, opt.UserRate)
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 {
ratio := getVirtualCoinRatio(userType, level, peerNum, opt.UserRate, coinId)
ratioList = append(ratioList, &VirtualCoinCommission{
Cid: coinId,
Val: zhios_order_relate_utils.AnyToFloat64(ratio),
})
}
}
return commissionRatio, ratioList
}

//佣金 积分 区块币计算
func CalReturnAmountAndRatioToWinery(level int, fee, integralFee float64, opt *PlanOpt) (commission, commissionRatio float64, amountList, ratioList []*VirtualCoinCommission) {
if opt.UserRate[level].ReturnType != nil { //返佣类型
@@ -89,7 +116,7 @@ func CalReturnAmountAndRatioToWinery(level int, fee, integralFee float64, opt *P
}

// 按总佣金的比例进行划分计算
func CalcAll(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64) error {
func CalcAll(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, levelWeight int) error {
grade := opt.UserRate
if len(grade) == 0 {
return zhios_order_relate_logx.Warn("level grade is not set")


+ 1
- 1
lib/comm_plan/init.go Dosyayı Görüntüle

@@ -1,6 +1,6 @@
package comm_plan

var Fn = map[string]func(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64) error{
var Fn = map[string]func(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64,levelWeight int) error{
"lv_all": CalcAll,
"lv_self": CalcSelf,
"lv_subsidy": CalcAll,


+ 8
- 2
lib/comm_plan/other.go Dosyayı Görüntüle

@@ -7,7 +7,7 @@ import (
)

// 按总佣金的比例进行划分计算
func CalcOther(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64) error {
func CalcOther(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, levelWeight int) error {
grade := opt.UserRate
if len(grade) == 0 {
return zhios_order_relate_logx.Warn("level grade is not set")
@@ -41,7 +41,7 @@ func CalcOther(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUse
var (
node = userList
maxLv = node.Lv // 当前等级
maxLevelWeight = node.LevelWeight // 当前权重
maxLevelWeight = levelWeight // 当前权重
peerNum = 0 // 存在同级数
peerRate float64 = 0 // 同级累计比例
peerRateList = make([]*VirtualCoinCommission, 0) // 各虚拟币同级累计
@@ -49,6 +49,7 @@ func CalcOther(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUse
accumulateRatioList = make([]*VirtualCoinCommission, 0) // 各虚拟币累计比例
restAmt = totalAmt - userList.Profit // 剩余比例
totalCommissionRatio = commissionRatio // 累计佣金比例

)
// 计算剩余额度
restAmtList, _ = CalVirtualCommissionMinus(totalAmtList, amountList)
@@ -93,6 +94,11 @@ Loop:
if _, ok := grade[node.ParentUser.Lv]; !ok {
return zhios_order_relate_logx.Warn("level grade node.ParentUser.Lv is not set")
}
if maxLv == 0 {
commissionRatio1, ratioList1 := CalReturnAmountAndRatioByLevel(node.ParentUser.Lv, userList.OwnbuyReturnType, 0, "own", totalAmt, integralTotalAmt, opt)
totalCommissionRatio = commissionRatio1
accumulateRatioList = ratioList1
}
peerNum1 := 0 //不用扣同级
commission, _, amountList, teamRatioList := CalReturnAmountAndRatio(node.ParentUser.Lv, userList.OwnbuyReturnType, peerNum1, "team", totalAmt, integralTotalAmt, opt)
//佣金


+ 1
- 1
lib/comm_plan/self.go Dosyayı Görüntüle

@@ -7,7 +7,7 @@ import (
)

// 按自购佣金进行计算
func CalcSelf(opt *PlanOpt, totalAmt float64, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64) error {
func CalcSelf(opt *PlanOpt, totalAmt float64, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64,levelWeight int) error {
grade := opt.UserRate
if len(grade) == 0 {
return zhios_order_relate_logx.Warn("level grade is not set")


+ 6
- 1
svc/reward_commission.go Dosyayı Görüntüle

@@ -483,7 +483,12 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee
node.ParentUser = &comm_plan.LvUser{Uid: v.Uid, Lv: v.Level, Diff: v.Diff, OldDiff: v.OldDiff, LevelWeight: levelWeight}
node = node.ParentUser
}
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee); err != nil {
levelWeight1 := 0
lvWeight, _ := db.UserLevelInIDescByWeightLowWithOne(eg)
if lvWeight != nil {
levelWeight1 = lvWeight.LevelWeight
}
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee, levelWeight1); err != nil {
fmt.Println("方案有问题1")
return 0, 0, 0, nil, err
}


Yükleniyor…
İptal
Kaydet