|
@@ -16,6 +16,7 @@ func IntegralRelease(engine *xorm.Engine, uid, level int, returnAllLevel bool, I |
|
|
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission", isGoods) |
|
|
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission", isGoods) |
|
|
////积分扣除抽成后 |
|
|
////积分扣除抽成后 |
|
|
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", isGoods) |
|
|
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", isGoods) |
|
|
|
|
|
integralFeeCom, _, _ := CommFee(comf, cfg, "integral", isGoods) |
|
|
//常规级差 |
|
|
//常规级差 |
|
|
var userRelationship *[]md.UserRelation |
|
|
var userRelationship *[]md.UserRelation |
|
|
if returnAllLevel { |
|
|
if returnAllLevel { |
|
@@ -73,7 +74,7 @@ func IntegralRelease(engine *xorm.Engine, uid, level int, returnAllLevel bool, I |
|
|
node = node.ParentUser |
|
|
node = node.ParentUser |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
err = CalIntegralRelease(cfg, fee, integralFee, lvUser, commArr) |
|
|
|
|
|
|
|
|
err = CalIntegralRelease(cfg, fee, integralFee, integralFeeCom, lvUser, commArr) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return 0, 0, 0, nil, err |
|
|
return 0, 0, 0, nil, err |
|
|
} |
|
|
} |
|
@@ -81,13 +82,13 @@ func IntegralRelease(engine *xorm.Engine, uid, level int, returnAllLevel bool, I |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 按总佣金的比例进行划分计算 |
|
|
// 按总佣金的比例进行划分计算 |
|
|
func CalIntegralRelease(opt *comm_plan.PlanOpt, totalAmt, integralTotalAmt float64, userList *comm_plan.LvUser, commArr map[string]string) error { |
|
|
|
|
|
|
|
|
func CalIntegralRelease(opt *comm_plan.PlanOpt, totalAmt, integralTotalAmt, integralTotalAmtCom float64, userList *comm_plan.LvUser, commArr map[string]string) 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") |
|
|
} |
|
|
} |
|
|
//查出用户自购佣金 |
|
|
//查出用户自购佣金 |
|
|
commission, _, amountList, ratioList := CalReturnAmountAndRatio(userList.Lv, userList.OwnbuyReturnType, "own", totalAmt, integralTotalAmt, opt, commArr) |
|
|
|
|
|
|
|
|
commission, _, amountList, ratioList := CalReturnAmountAndRatio(userList.Lv, userList.OwnbuyReturnType, "own", totalAmt, integralTotalAmt, integralTotalAmtCom, opt, commArr) |
|
|
userList.Profit = commission // 另外出来的佣金 兼容旧的 |
|
|
userList.Profit = commission // 另外出来的佣金 兼容旧的 |
|
|
userList.ProfitList = amountList // 各币种分佣 |
|
|
userList.ProfitList = amountList // 各币种分佣 |
|
|
ratioListMap := convertList2Map(ratioList) |
|
|
ratioListMap := convertList2Map(ratioList) |
|
@@ -130,11 +131,15 @@ func CalIntegralRelease(opt *comm_plan.PlanOpt, totalAmt, integralTotalAmt float |
|
|
if node.ParentUser.Diff == 2 { |
|
|
if node.ParentUser.Diff == 2 { |
|
|
userType = "second_extend" |
|
|
userType = "second_extend" |
|
|
} |
|
|
} |
|
|
commission, _, amountList, _ := CalReturnAmountAndRatio(node.ParentUser.Lv, userList.OwnbuyReturnType, userType, totalAmt, integralTotalAmt, opt, commArr) |
|
|
|
|
|
|
|
|
commission, _, amountList, ratioList := CalReturnAmountAndRatio(node.ParentUser.Lv, userList.OwnbuyReturnType, userType, totalAmt, integralTotalAmt, integralTotalAmtCom, opt, commArr) |
|
|
//佣金 |
|
|
//佣金 |
|
|
node.ParentUser.Profit = commission |
|
|
node.ParentUser.Profit = commission |
|
|
//积分 |
|
|
//积分 |
|
|
node.ParentUser.ProfitList = amountList |
|
|
node.ParentUser.ProfitList = amountList |
|
|
|
|
|
ratioListMap := convertList2Map(ratioList) |
|
|
|
|
|
for k, v := range node.ParentUser.ProfitList { |
|
|
|
|
|
node.ParentUser.ProfitList[k].Val = ratioListMap[v.Cid] * v.Val |
|
|
|
|
|
} |
|
|
// 等级往上升则置0 |
|
|
// 等级往上升则置0 |
|
|
maxLevelWeight = node.ParentUser.LevelWeight |
|
|
maxLevelWeight = node.ParentUser.LevelWeight |
|
|
} |
|
|
} |
|
@@ -146,8 +151,10 @@ func CalIntegralRelease(opt *comm_plan.PlanOpt, totalAmt, integralTotalAmt float |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//佣金 积分 区块币计算 |
|
|
//佣金 积分 区块币计算 |
|
|
func CalReturnAmountAndRatio(level, ownbuyReturnType int, userType string, fee, integralFee float64, opt *comm_plan.PlanOpt, commArr map[string]string) (commission, commissionRatio float64, amountList, ratioList []*comm_plan.VirtualCoinCommission) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func CalReturnAmountAndRatio(level, ownbuyReturnType int, userType string, fee, integralFee, integralFeeCom float64, opt *comm_plan.PlanOpt, commArr map[string]string) (commission, commissionRatio float64, amountList, ratioList []*comm_plan.VirtualCoinCommission) { |
|
|
|
|
|
if userType != "own" { |
|
|
|
|
|
integralFee = integralFeeCom |
|
|
|
|
|
} |
|
|
lvGrade := opt.UserRate[level] |
|
|
lvGrade := opt.UserRate[level] |
|
|
if lvGrade.SelfRateList != nil { |
|
|
if lvGrade.SelfRateList != nil { |
|
|
commissionRatioStr := getVirtualCoinRatio(userType, level, opt.UserRate, "0") |
|
|
commissionRatioStr := getVirtualCoinRatio(userType, level, opt.UserRate, "0") |
|
@@ -246,6 +253,8 @@ func getVirtualCoinRatio(typ string, level int, grade map[int]*comm_plan.LvGrade |
|
|
} |
|
|
} |
|
|
if !ok { |
|
|
if !ok { |
|
|
ratio = "0" |
|
|
ratio = "0" |
|
|
|
|
|
} else { |
|
|
|
|
|
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 6) |
|
|
} |
|
|
} |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|