Browse Source

add reverse:for v3.8.6 积分释放规则

tags/v3.8.6
huangjiajun 2 years ago
parent
commit
502d283b06
3 changed files with 30 additions and 8 deletions
  1. +14
    -2
      svc/get_plan_cfg.go
  2. +1
    -0
      svc/reward_commission.go
  3. +15
    -6
      svc/svc_integral_release.go

+ 14
- 2
svc/get_plan_cfg.go View File

@@ -59,7 +59,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
if commissionOpt == nil || commissionOpt.Id == 0 { if commissionOpt == nil || commissionOpt.Id == 0 {
return nil, errors.New("佣金方案有误") return nil, errors.New("佣金方案有误")
} }
if _, ok := comm_plan.Fn[commissionOpt.Mode]; !ok && zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon", "extend_price"}) == false {
if _, ok := comm_plan.Fn[commissionOpt.Mode]; !ok && zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon", "extend_price", "lv_integral_release"}) == false {
return nil, zhios_order_relate_logx.Warn("分佣模式不存在") return nil, zhios_order_relate_logx.Warn("分佣模式不存在")
} }
opt.Pvd = pvd opt.Pvd = pvd
@@ -80,7 +80,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
} else { } else {
opt.VirtualCoinMoneyRatioList = virtualCoinMoneyRate opt.VirtualCoinMoneyRatioList = virtualCoinMoneyRate
} }
if zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon", "extend_price"}) { //公排
if zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"public_platoon", "extend_price", "lv_integral_release"}) { //公排
return opt, nil return opt, nil
} }


@@ -91,6 +91,11 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
var subsidyTmp map[int]*comm_plan.LvGrade var subsidyTmp map[int]*comm_plan.LvGrade
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"bili\":0", "\"bili\":\"0\"") commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"bili\":0", "\"bili\":\"0\"")
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"buy_deliver_list\":[]", "\"buy_deliver_list\":{}") commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"buy_deliver_list\":[]", "\"buy_deliver_list\":{}")
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"team_rate_list\":[]", "\"team_rate_list\":{}")
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"second_extend\":[]", "\"second_extend\":{}")
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"first_extend\":[]", "\"first_extend\":{}")
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"peer_rate_list\":[]", "\"peer_rate_list\":{}")
commissionOpt.Data = strings.ReplaceAll(commissionOpt.Data, "\"peer_rate_list\":[[],[],[]]", "\"peer_rate_list\":[]")
if strings.Contains(commissionOpt.Data, "\"subsidy_mode_list\":[") { //兼容旧的方案 if strings.Contains(commissionOpt.Data, "\"subsidy_mode_list\":[") { //兼容旧的方案
tmp := strings.Split(commissionOpt.Data, "\"subsidy_mode_list\":[") tmp := strings.Split(commissionOpt.Data, "\"subsidy_mode_list\":[")
if len(tmp) > 0 { if len(tmp) > 0 {
@@ -120,6 +125,13 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
if err := json.Unmarshal([]byte(commissionOpt.Data), &subsidyTmp); err != nil { if err := json.Unmarshal([]byte(commissionOpt.Data), &subsidyTmp); err != nil {
return nil, zhios_order_relate_logx.Warn(fmt.Sprintf("%s:分佣方案数据设置错误", masterId)) return nil, zhios_order_relate_logx.Warn(fmt.Sprintf("%s:分佣方案数据设置错误", masterId))
} }
if zhios_order_relate_utils.InArr(commissionOpt.Mode, []string{"lv_integral_release"}) {
var subsidyTmp1 = make(map[int]*comm_plan.LvGrade)
for _, v := range subsidyTmp {
subsidyTmp1[v.Lv] = v
}
subsidyTmp = subsidyTmp1
}
opt.UserRate = subsidyTmp opt.UserRate = subsidyTmp


return opt, nil return opt, nil


+ 1
- 0
svc/reward_commission.go View File

@@ -162,6 +162,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
return profit, pvdFee, sysFee, 0, ulink, nil return profit, pvdFee, sysFee, 0, ulink, nil
} }
if cfg.Mode == "lv_integral_release" { //公排 if cfg.Mode == "lv_integral_release" { //公排
price = rmd.OldPrice
pvdFee, sysFee, _, ulink, err := IntegralRelease(engine, uid, newLevel, returnAllLevel, rmd.IsShowExtend, newProvider, user, comf, price, cfg, rmd.IsGoods, commArr) pvdFee, sysFee, _, ulink, err := IntegralRelease(engine, uid, newLevel, returnAllLevel, rmd.IsShowExtend, newProvider, user, comf, price, cfg, rmd.IsGoods, commArr)
if err != nil { if err != nil {
return 0, 0, 0, 0, nil, nil return 0, 0, 0, 0, nil, nil


+ 15
- 6
svc/svc_integral_release.go View File

@@ -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
} }


Loading…
Cancel
Save