@@ -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 查询获取 权重最低 对应等级 | //UserLevelDescByWeightLow 查询获取 权重最低 对应等级 | ||||
func UserLevelDescByWeightLow(session *xorm.Session) (userIds []int, err error) { | func UserLevelDescByWeightLow(session *xorm.Session) (userIds []int, err error) { | ||||
var m model.UserLevel | var m model.UserLevel | ||||
@@ -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_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" | zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" | ||||
"fmt" | "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 | grade := opt.UserRate | ||||
if len(grade) == 0 { | if len(grade) == 0 { | ||||
return zhios_order_relate_logx.Warn("level grade is not set") | return zhios_order_relate_logx.Warn("level grade is not set") | ||||
@@ -1,6 +1,8 @@ | |||||
package comm_plan | 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, | "lv_all": CalcAll, | ||||
"niubei_commission": NiuBeiCalcAll, | "niubei_commission": NiuBeiCalcAll, | ||||
"niubei_amount": NiuBeiCalcAll, | "niubei_amount": NiuBeiCalcAll, | ||||
@@ -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 | grade := opt.UserRate | ||||
if len(grade) == 0 { | if len(grade) == 0 { | ||||
return zhios_order_relate_logx.Warn("level grade is not set") | return zhios_order_relate_logx.Warn("level grade is not set") | ||||
@@ -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_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" | zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" | ||||
"fmt" | "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 | grade := opt.UserRate | ||||
if len(grade) == 0 { | if len(grade) == 0 { | ||||
return zhios_order_relate_logx.Warn("level grade is not set") | return zhios_order_relate_logx.Warn("level grade is not set") | ||||
@@ -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_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" | zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" | ||||
"fmt" | "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 | grade := opt.UserRate | ||||
if len(grade) == 0 { | if len(grade) == 0 { | ||||
return zhios_order_relate_logx.Warn("level grade is not set") | return zhios_order_relate_logx.Warn("level grade is not set") | ||||
@@ -1,13 +1,15 @@ | |||||
package comm_plan | package comm_plan | ||||
import ( | 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_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" | zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" | ||||
"fmt" | "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 | grade := opt.UserRate | ||||
if len(grade) == 0 { | if len(grade) == 0 { | ||||
return zhios_order_relate_logx.Warn("level grade is not set") | 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.ProfitList = amountList // 各币种分佣 | ||||
userList.SubsidyFee = 0 | userList.SubsidyFee = 0 | ||||
ratioListMap := convertList2Map(ratioList) | ratioListMap := convertList2Map(ratioList) | ||||
for k, v := range userList.ProfitList { | for k, v := range userList.ProfitList { | ||||
userList.ProfitList[k].Val = ratioListMap[v.Cid] * v.Val | userList.ProfitList[k].Val = ratioListMap[v.Cid] * v.Val | ||||
} | } | ||||
maxLvData, _ := db.UserLevelByID(eg, "2") | |||||
// 各种币换算出总的额度 | // 各种币换算出总的额度 | ||||
totalAmtList := make([]*VirtualCoinCommission, 0) | totalAmtList := make([]*VirtualCoinCommission, 0) | ||||
for coinId, rate := range opt.VirtualCoinMoneyRatioList { | 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 | maxLevelWeight, maxLv, peerRate, peerRateList, peerNum, sameProfit, sameProfitList = node.ParentUser.LevelWeight, node.ParentUser.Lv, 0, nil, 0, node.ParentUser.Profit, node.ParentUser.ProfitList | ||||
} else { | } else { | ||||
if node.ParentUser.Lv > 2 && maxLvData != nil { | |||||
node.ParentUser.LevelWeight = maxLvData.LevelWeight | |||||
} | |||||
// 同级奖 | // 同级奖 | ||||
if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum { | if node.ParentUser.LevelWeight == maxLevelWeight && count > peerNum { | ||||
@@ -574,7 +574,7 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee | |||||
levelWeight1 = lvWeight.LevelWeight | levelWeight1 = lvWeight.LevelWeight | ||||
level1 = lvWeight.Id | 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") | fmt.Println("方案有问题1") | ||||
return 0, 0, 0, nil, err | return 0, 0, 0, nil, err | ||||
} | } | ||||
@@ -662,7 +662,7 @@ func NiuBeiCalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integr | |||||
levelWeight1 = lvWeight.LevelWeight | levelWeight1 = lvWeight.LevelWeight | ||||
level1 = lvWeight.Id | 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") | fmt.Println("方案有问题1") | ||||
return 0, 0, 0, nil, err | return 0, 0, 0, nil, err | ||||
} | } | ||||