Explorar el Código

链动制度

tags/v4.3.0
huangjiajun hace 1 año
padre
commit
db29d0d38a
Se han modificado 8 ficheros con 33 adiciones y 9 borrados
  1. +14
    -0
      db/db_user_level.go
  2. +2
    -1
      lib/comm_plan/all.go
  3. +3
    -1
      lib/comm_plan/init.go
  4. +1
    -1
      lib/comm_plan/niubei_all.go
  5. +2
    -1
      lib/comm_plan/other.go
  6. +2
    -1
      lib/comm_plan/self.go
  7. +7
    -2
      lib/comm_plan/winery.go
  8. +2
    -2
      svc/reward_commission.go

+ 14
- 0
db/db_user_level.go Ver fichero

@@ -17,6 +17,20 @@ func UserLevelInIDescByWeightLow(Db *xorm.Engine) ([]*model.UserLevel, error) {

}

//UserLevelByID is 根据用户id 获取对应的等级信息
func UserLevelByID(Db *xorm.Engine, id interface{}) (*model.UserLevel, error) {
m := new(model.UserLevel)
has, err := Db.Where("id = ?", id).Get(m)
if err != nil {
return nil, err
}
if !has {
return nil, errors.New("no found")
}

return m, nil
}

//UserLevelDescByWeightLow 查询获取 权重最低 对应等级
func UserLevelDescByWeightLow(session *xorm.Session) (userIds []int, err error) {
var m model.UserLevel


+ 2
- 1
lib/comm_plan/all.go Ver fichero

@@ -4,6 +4,7 @@ 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"
)

//佣金 积分 区块币计算
@@ -116,7 +117,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, level, levelWeight int) error {
func CalcAll(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")


+ 3
- 1
lib/comm_plan/init.go Ver fichero

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

var Fn = map[string]func(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, level, levelWeight int) error{
import "xorm.io/xorm"

var Fn = map[string]func(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, level, levelWeight int, eg *xorm.Engine) error{
"lv_all": CalcAll,
"niubei_commission": NiuBeiCalcAll,
"niubei_amount": NiuBeiCalcAll,


+ 1
- 1
lib/comm_plan/niubei_all.go Ver fichero

@@ -60,7 +60,7 @@ func NiuBeiCalReturnAmountAndRatio(eg *xorm.Engine, pvd, bili string, integralFe
}

// 按总佣金的比例进行划分计算
func NiuBeiCalcAll(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, level, levelWeight int) error {
func NiuBeiCalcAll(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")


+ 2
- 1
lib/comm_plan/other.go Ver fichero

@@ -4,10 +4,11 @@ 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 CalcOther(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, level, levelWeight int) error {
func CalcOther(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")


+ 2
- 1
lib/comm_plan/self.go Ver fichero

@@ -4,10 +4,11 @@ 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 CalcSelf(opt *PlanOpt, totalAmt float64, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, level, levelWeight int) error {
func CalcSelf(opt *PlanOpt, totalAmt float64, 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")


+ 7
- 2
lib/comm_plan/winery.go Ver fichero

@@ -1,13 +1,15 @@
package comm_plan

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
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 CalcWinery(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUser, pvd string, sysFee float64, integralSysFee float64, level, levelWeight int) error {
func CalcWinery(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")
@@ -19,10 +21,10 @@ func CalcWinery(opt *PlanOpt, totalAmt, integralTotalAmt float64, userList *LvUs
userList.ProfitList = amountList // 各币种分佣
userList.SubsidyFee = 0
ratioListMap := convertList2Map(ratioList)

for k, v := range userList.ProfitList {
userList.ProfitList[k].Val = ratioListMap[v.Cid] * v.Val
}
maxLvData, _ := db.UserLevelByID(eg, "2")
// 各种币换算出总的额度
totalAmtList := make([]*VirtualCoinCommission, 0)
for coinId, rate := range opt.VirtualCoinMoneyRatioList {
@@ -92,6 +94,9 @@ Loop:
}
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.Lv > 2 && maxLvData != nil {
node.ParentUser.LevelWeight = maxLvData.LevelWeight
}
// 同级奖
if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum {



+ 2
- 2
svc/reward_commission.go Ver fichero

@@ -574,7 +574,7 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee
levelWeight1 = lvWeight.LevelWeight
level1 = lvWeight.Id
}
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee, level1, levelWeight1); err != nil {
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee, level1, levelWeight1, eg); err != nil {
fmt.Println("方案有问题1")
return 0, 0, 0, nil, err
}
@@ -662,7 +662,7 @@ func NiuBeiCalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integr
levelWeight1 = lvWeight.LevelWeight
level1 = lvWeight.Id
}
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee, level1, levelWeight1); err != nil {
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee, level1, levelWeight1, eg); err != nil {
fmt.Println("方案有问题1")
return 0, 0, 0, nil, err
}


Cargando…
Cancelar
Guardar