|
@@ -32,6 +32,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
level = 0 |
|
|
level = 0 |
|
|
userLevel = 0 |
|
|
userLevel = 0 |
|
|
newLevel = 0 |
|
|
newLevel = 0 |
|
|
|
|
|
minLevel = 0 |
|
|
) |
|
|
) |
|
|
user, _ := db.UserFindByID(engine, userId) |
|
|
user, _ := db.UserFindByID(engine, userId) |
|
|
if user != nil { |
|
|
if user != nil { |
|
@@ -41,6 +42,10 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
userLevel = user.Level |
|
|
userLevel = user.Level |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
minLevelList, _ := db.UserLevelInIDescByWeightLowWithOne(engine) |
|
|
|
|
|
if minLevelList != nil { |
|
|
|
|
|
minLevel = minLevelList.Id |
|
|
|
|
|
} |
|
|
// 获取抽成方案 |
|
|
// 获取抽成方案 |
|
|
newProvider := provider |
|
|
newProvider := provider |
|
|
if newProvider == md.PVD_TM { //抽成方案只有淘宝的要替换回来 |
|
|
if newProvider == md.PVD_TM { //抽成方案只有淘宝的要替换回来 |
|
@@ -243,6 +248,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b |
|
|
return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil |
|
|
return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil |
|
|
} |
|
|
} |
|
|
// userRelationship == nil 是只返回第一层 即用户自己的 |
|
|
// userRelationship == nil 是只返回第一层 即用户自己的 |
|
|
|
|
|
rmd.MinLevel = minLevel |
|
|
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine, rmd.IsGoods, rmd) |
|
|
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine, rmd.IsGoods, rmd) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return 0, 0, 0, 0, nil, nil |
|
|
return 0, 0, 0, 0, nil, nil |
|
@@ -543,8 +549,24 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee |
|
|
for k, v := range amountList { |
|
|
for k, v := range amountList { |
|
|
amountList[k].Val = ratioListMap[v.Cid] * v.Val |
|
|
amountList[k].Val = ratioListMap[v.Cid] * v.Val |
|
|
} |
|
|
} |
|
|
|
|
|
minProfit := 0.00 |
|
|
|
|
|
minProfitList := make([]*comm_plan.VirtualCoinCommission, 0) |
|
|
|
|
|
if opt.Mode == "lv_ds_check" { |
|
|
|
|
|
if level == rmd.MinLevel { |
|
|
|
|
|
minProfit = commission |
|
|
|
|
|
minProfitList = amountList |
|
|
|
|
|
} else { |
|
|
|
|
|
commission, _, amountList, ratioList = comm_plan.CalReturnAmountAndRatioDsOwn(rmd.MinLevel, ownbuyReturnType, 0, "own", fee, integralFee, opt) |
|
|
|
|
|
ratioListMap := convertList2Map(ratioList) |
|
|
|
|
|
for k, v := range amountList { |
|
|
|
|
|
amountList[k].Val = ratioListMap[v.Cid] * v.Val |
|
|
|
|
|
} |
|
|
|
|
|
minProfit = commission |
|
|
|
|
|
minProfitList = amountList |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
//重新计算佣金 |
|
|
//重新计算佣金 |
|
|
return pvdFee, sysFee, subsidyFee, &comm_plan.LvUser{TikTokOwnSubsidyFeeList: tikTokSubsidyFeeList, OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, OldDiff: oldDiff, Profit: commission, ProfitList: amountList, Diff: 0}, nil |
|
|
|
|
|
|
|
|
return pvdFee, sysFee, subsidyFee, &comm_plan.LvUser{MinProfit: minProfit, MinProfitList: minProfitList, TikTokOwnSubsidyFeeList: tikTokSubsidyFeeList, OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, OldDiff: oldDiff, Profit: commission, ProfitList: amountList, Diff: 0}, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//查出所有等级替换权重 |
|
|
//查出所有等级替换权重 |
|
@@ -555,7 +577,7 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee |
|
|
levelWeight = v1.LevelWeight |
|
|
levelWeight = v1.LevelWeight |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
lvUser = &comm_plan.LvUser{TikTokOwnSubsidyFeeList: tikTokSubsidyFeeList, OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, Diff: 0, OldDiff: oldDiff, NewLv: newLevel, LevelWeight: levelWeight, OwnbuyReturnType: ownbuyReturnType} |
|
|
|
|
|
|
|
|
lvUser = &comm_plan.LvUser{MinLevel: rmd.MinLevel, TikTokOwnSubsidyFeeList: tikTokSubsidyFeeList, OwnSubsidyFeeList: subsidyFeeList, Uid: uid, Lv: level, Diff: 0, OldDiff: oldDiff, NewLv: newLevel, LevelWeight: levelWeight, OwnbuyReturnType: ownbuyReturnType} |
|
|
var node = lvUser |
|
|
var node = lvUser |
|
|
//关系链处理 |
|
|
//关系链处理 |
|
|
for _, v := range *userRelationShip { |
|
|
for _, v := range *userRelationShip { |
|
|