Selaa lähdekoodia

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

tags/v3.8.6
huangjiajun 1 vuosi sitten
vanhempi
commit
502d283b06
3 muutettua tiedostoa jossa 30 lisäystä ja 8 poistoa
  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 Näytä tiedosto

@@ -59,7 +59,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
if commissionOpt == nil || commissionOpt.Id == 0 {
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("分佣模式不存在")
}
opt.Pvd = pvd
@@ -80,7 +80,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
} else {
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
}

@@ -91,6 +91,11 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
var subsidyTmp map[int]*comm_plan.LvGrade
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, "\"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\":[") { //兼容旧的方案
tmp := strings.Split(commissionOpt.Data, "\"subsidy_mode_list\":[")
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 {
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

return opt, nil


+ 1
- 0
svc/reward_commission.go Näytä tiedosto

@@ -162,6 +162,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
return profit, pvdFee, sysFee, 0, ulink, nil
}
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)
if err != nil {
return 0, 0, 0, 0, nil, nil


+ 15
- 6
svc/svc_integral_release.go Näytä tiedosto

@@ -16,6 +16,7 @@ func IntegralRelease(engine *xorm.Engine, uid, level int, returnAllLevel bool, I
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission", isGoods)
////积分扣除抽成后
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", isGoods)
integralFeeCom, _, _ := CommFee(comf, cfg, "integral", isGoods)
//常规级差
var userRelationship *[]md.UserRelation
if returnAllLevel {
@@ -73,7 +74,7 @@ func IntegralRelease(engine *xorm.Engine, uid, level int, returnAllLevel bool, I
node = node.ParentUser
}
}
err = CalIntegralRelease(cfg, fee, integralFee, lvUser, commArr)
err = CalIntegralRelease(cfg, fee, integralFee, integralFeeCom, lvUser, commArr)
if err != nil {
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
if len(grade) == 0 {
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.ProfitList = amountList // 各币种分佣
ratioListMap := convertList2Map(ratioList)
@@ -130,11 +131,15 @@ func CalIntegralRelease(opt *comm_plan.PlanOpt, totalAmt, integralTotalAmt float
if node.ParentUser.Diff == 2 {
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.ProfitList = amountList
ratioListMap := convertList2Map(ratioList)
for k, v := range node.ParentUser.ProfitList {
node.ParentUser.ProfitList[k].Val = ratioListMap[v.Cid] * v.Val
}
// 等级往上升则置0
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]
if lvGrade.SelfRateList != nil {
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 {
ratio = "0"
} else {
ratio = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(ratio)/100, 6)
}
return
}


Ladataan…
Peruuta
Tallenna