Sfoglia il codice sorgente

add reverse:for v3.5.1 分佣调整

tags/v3.5.1
huangjiajun 2 anni fa
parent
commit
677bef094f
3 ha cambiato i file con 48 aggiunte e 27 eliminazioni
  1. +23
    -13
      rule/relate_commission.go
  2. +22
    -12
      svc/get_plan_cfg.go
  3. +3
    -2
      svc/reward_commission.go

+ 23
- 13
rule/relate_commission.go Vedi File

@@ -31,6 +31,7 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi
if virCfg != nil && virCfg.Val != "" {
virType = virCfg.Val
}
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)
for _, param := range commissionParamList {
param := param // 为下面的闭包创建局部变量
group.Go(func() error {
@@ -45,9 +46,9 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi
}
param.CommissionParam.Oid = param.GoodsId
param.CommissionParam.IsGoods = "1"
param.CommissionParam.ShowLevel=param.ShowLevel
param.CommissionParam.ShowLevel = param.ShowLevel

_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType)
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate)
if err != nil {
return err
}
@@ -83,6 +84,8 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP
if virCfg != nil && virCfg.Val != "" {
virType = virCfg.Val
}
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)

for _, param := range commissionParamList {
param := param // 为下面的闭包创建局部变量
group.Go(func() error {
@@ -99,7 +102,7 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP
param.CommissionParam.IsGoods = "1"
param.CommissionParam.IsShowExtend = param.IsShowExtend

_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType)
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate)
if err != nil {
return err
}
@@ -135,6 +138,8 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar
if virCfg != nil && virCfg.Val != "" {
virType = virCfg.Val
}
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(engine, dbName)

for _, param := range CommissionParamList {
param := param // 为下面的闭包创建局部变量
group.Go(func() error {
@@ -153,7 +158,7 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar
param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice
param.CommissionParam.Oid = param.Oid

profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType)
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate)
if err != nil {
return err
}
@@ -200,9 +205,10 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m
}
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"
CommissionParam.CommissionParam.ShowLevel=CommissionParam.ShowLevel
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)

profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType)
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType, plan, commission, virtualCoinMoneyRate)
return profit, pvdFee, sysFee, subsidyFee, lvUser, err
}

@@ -232,8 +238,9 @@ func SettleCommWithGoodsDetailExtend(eg *xorm.Engine, dbName string, CommissionP
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"
CommissionParam.CommissionParam.IsShowExtend = CommissionParam.IsShowExtend
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)

profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType)
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType, plan, commission, virtualCoinMoneyRate)
return profit, pvdFee, sysFee, subsidyFee, lvUser, err
}
func SettleCommWithOrder(eg *xorm.Engine, dbName string, CommissionParam md.CommissionFirstParam) (float64, float64, float64, float64, *comm_plan.LvUser, error) {
@@ -259,7 +266,9 @@ func SettleCommWithOrder(eg *xorm.Engine, dbName string, CommissionParam md.Comm
virType = virCfg.Val
}
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType)
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)

profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType, plan, commission, virtualCoinMoneyRate)
return profit, pvdFee, sysFee, subsidyFee, lvUser, err
}

@@ -282,18 +291,19 @@ func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam m
}
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"
CommissionParam.CommissionParam.ShowLevel=CommissionParam.ShowLevel
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel
plan, commissions, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)

var lvUser = &comm_plan.LvUser{}
var mapsDta = map[string]string{"show_level": CommissionParam.ShowLevel}
if isAll {
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, true, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode)
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, false, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode)
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, true, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate)
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, false, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate)
} else {
if isShare {
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode)
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate)
} else {
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode)
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate)
}
}
return commission, shareCommission, lvUser, nil


+ 22
- 12
svc/get_plan_cfg.go Vedi File

@@ -8,6 +8,7 @@ import (
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"
"encoding/json"
"errors"
"fmt"
"strings"
"xorm.io/xorm"
@@ -26,13 +27,25 @@ var pvdCfgList = map[string]struct {
md.PVD_VIP: {md.KEY_CFG_ZM_AK, md.KEY_CFG_ZM_SK, md.KEY_CFG_ZM_WEB_ID},
}

func GetPlanCfg(eg *xorm.Engine, pvd, masterId string) (*comm_plan.PlanOpt, error) {
func GetAllPlan(eg *xorm.Engine, dbName string) (map[string]*model.PlanReward, map[int]*model.PlanCommission, map[int]string) {
plan := make(map[string]*model.PlanReward, 0)
pvds, _ := db.DbsPlanRewardByPvds(eg)
for _, v := range pvds {
plan[v.Pvd] = v
}
commission := make(map[int]*model.PlanCommission, 0)
commissions := db.DbsPlanCommissionByIds(eg)
for _, v := range commissions {
commission[v.Id] = v
}
virtualCoinMoneyRate, _ := GetVirtualCoinMoneyRateList(eg, dbName)
return plan, commission, virtualCoinMoneyRate
}

func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*model.PlanReward, commissionOpts map[int]*model.PlanCommission, virtualCoinMoneyRate map[int]string) (*comm_plan.PlanOpt, error) {
opt := &comm_plan.PlanOpt{}
// 根据供应商
rewardOpt, err := db.DbsPlanRewardByPvd(eg, pvd)
if err != nil {
return nil, err
}
rewardOpt := rewardOpts[pvd]
if rewardOpt == nil {
return nil, zhios_order_relate_logx.Warn("找不到方案记录")
}
@@ -42,11 +55,9 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string) (*comm_plan.PlanOpt, erro
if rewardOpt.PlanCommissionId == 0 {
return nil, zhios_order_relate_logx.Warn("抽成方案未设置佣金方案id")
}
fmt.Println("抽成设置:", zhios_order_relate_utils.SerializeStr(rewardOpt))
fmt.Println("commission id:", rewardOpt.PlanCommissionId)
commissionOpt, err := db.DbsPlanCommissionById(eg, rewardOpt.PlanCommissionId)
if err != nil || commissionOpt == nil || commissionOpt.Id == 0 {
return nil, err
commissionOpt := commissionOpts[rewardOpt.PlanCommissionId]
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 {
return nil, zhios_order_relate_logx.Warn("分佣模式不存在")
@@ -63,8 +74,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string) (*comm_plan.PlanOpt, erro
opt.NewAgentRate = float64(int64(rewardOpt.NewAgentRate*1e4)) / 1e4
opt.PlanCommissionId = rewardOpt.PlanCommissionId
// 兑换现金比例
virtualCoinMoneyRate, err := GetVirtualCoinMoneyRateList(eg, masterId)
if err != nil || virtualCoinMoneyRate == nil {
if virtualCoinMoneyRate == nil {
opt.VirtualCoinMoneyRatioList = nil
} else {
opt.VirtualCoinMoneyRatioList = virtualCoinMoneyRate


+ 3
- 2
svc/reward_commission.go Vedi File

@@ -2,6 +2,7 @@ package svc

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
@@ -14,7 +15,7 @@ import (

// getRewardCommission is 获取制度后的佣金
// 返回:单个佣金、层级佣金、错误
func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare bool, userId, provider, masterId string, returnAllLevel bool, extraData map[string]string, virType string) (float64, float64, float64, float64, *comm_plan.LvUser, error) {
func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare bool, userId, provider, masterId string, returnAllLevel bool, extraData map[string]string, virType string, rewardOpts map[string]*model.PlanReward, commissionOpts map[int]*model.PlanCommission, virtualCoinMoneyRate map[int]string) (float64, float64, float64, float64, *comm_plan.LvUser, error) {

if virType == "commission" {
rmd.PaidPrice = rmd.Commission
@@ -59,7 +60,7 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
level = zhios_order_relate_utils.StrToInt(extraData["show_level"])
}
ownbuyReturnType := zhios_order_relate_utils.StrToInt(extraData["ownbuy_return_type"])
cfg, err := GetPlanCfg(engine, newProvider, masterId)
cfg, err := GetPlanCfg(engine, newProvider, masterId, rewardOpts, commissionOpts, virtualCoinMoneyRate)
if err != nil {
return 0, 0, 0, 0, nil, err
}


Caricamento…
Annulla
Salva