From 1837e6b7d3a9004654f754c718e2ba5dc4d9f102 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 16 Aug 2022 10:55:22 +0800 Subject: [PATCH] add reverse:for v1.8.4 test --- db/model/plan_reward.go | 1 + lib/comm_plan/init.go | 1 + md/extend_price_reward.go | 22 ++++++++++------------ svc/extend_agent_commission.go | 25 ++++++++++--------------- svc/extend_price_reward.go | 34 +++++++++++++++------------------- svc/get_plan_cfg.go | 1 + svc/reward_commission.go | 3 ++- 7 files changed, 40 insertions(+), 47 deletions(-) diff --git a/db/model/plan_reward.go b/db/model/plan_reward.go index 17243c7..493fe2b 100644 --- a/db/model/plan_reward.go +++ b/db/model/plan_reward.go @@ -15,6 +15,7 @@ type PlanReward struct { Source int `json:"source" xorm:"not null default 1 comment('佣金来源:1联盟佣金 2补贴金额') TINYINT(1)"` AppType int `json:"app_type" xorm:"not null default 1 comment('所属应用:1导购 2自营 4O2O') TINYINT(3)"` MerchantRate float32 `json:"merchant_rate" xorm:"not null default 0.0000 comment('o2o商家抽成比例') FLOAT(6,4)"` + NewAgentRate float32 `json:"new_agent_rate" xorm:"not null default 0.0000 comment('') FLOAT(6,4)"` PushHandRate float32 `json:"push_hand_rate" xorm:"not null default 0.0000 comment('o2o推手抽成比例') FLOAT(6,4)"` IntegralOpen int `json:"integral_open" xorm:"not null default 0 comment('积分抽成') TINYINT(1)"` } diff --git a/lib/comm_plan/init.go b/lib/comm_plan/init.go index 4dbd299..b0addb0 100644 --- a/lib/comm_plan/init.go +++ b/lib/comm_plan/init.go @@ -22,6 +22,7 @@ type PlanOpt struct { RegionRate float64 // 区域代理占佣比例 GlobalRate float64 // 全球分红占佣比例 MerchantRate float64 //商家占佣比例 + NewAgentRate float64 //代理分红占佣比例 PushHandRate float64 //推手占佣比例 //IntegralBili float64 // 积分兑换比例 //BlockIconsBili float64 // 区块币兑换比例 diff --git a/md/extend_price_reward.go b/md/extend_price_reward.go index deef7a6..942a46f 100644 --- a/md/extend_price_reward.go +++ b/md/extend_price_reward.go @@ -2,21 +2,19 @@ package md // 直推奖励结构 type ExtendRewardLvGrade struct { - Lv int `json:"lv"` // 会员级别 - LvName string `json:"lv_name"` // 会员名称 - ReturnType []string `json:"return_type"` //返利类型 - ExtendPriceRewardList []ExtendPriceRewardList `json:"extend_price_reward_list"` // 直推奖励比例 -} -type ExtendPriceRewardList struct { - CoinID string `json:"coin_id"` - AreaAgent ExtendPriceRewardListDetail `json:"area_agent"` - CityAgent ExtendPriceRewardListDetail `json:"city_agent"` - ProvinceAgent ExtendPriceRewardListDetail `json:"province_agent"` - UpLv ExtendPriceRewardListDetail `json:"up_lv"` + Lv int `json:"lv"` // 会员级别 + LvName string `json:"lv_name"` // 会员名称 + ReturnType []string `json:"return_type"` //返利类型 + ExtendPriceRewardUpLv map[string]ExtendPriceRewardListDetail `json:"extend_price_reward_up_lv"` + ExtendPriceRewardProvince map[string]ExtendPriceRewardListDetail `json:"extend_price_reward_province"` + ExtendPriceRewardCity map[string]ExtendPriceRewardListDetail `json:"extend_price_reward_city"` + ExtendPriceRewardArea map[string]ExtendPriceRewardListDetail `json:"extend_price_reward_area"` + ExtendPriceRewardBuyGoodsProvince map[string]ExtendPriceRewardListDetail `json:"extend_price_reward_buy_goods_province"` + ExtendPriceRewardBuyGoodsCity map[string]ExtendPriceRewardListDetail `json:"extend_price_reward_buy_goods_city"` + ExtendPriceRewardBuyGoodsArea map[string]ExtendPriceRewardListDetail `json:"extend_price_reward_buy_goods_area"` } type ExtendPriceRewardListDetail struct { BaseVal string `json:"base_val"` Bili string `json:"bili"` PositionBili string `json:"position_bili"` - ExtendAgentBili string `json:"extend_agent_bili"` } diff --git a/svc/extend_agent_commission.go b/svc/extend_agent_commission.go index f3c4c41..a34d9d6 100644 --- a/svc/extend_agent_commission.go +++ b/svc/extend_agent_commission.go @@ -69,9 +69,15 @@ func AddExtendAgentCommission(eg *xorm.Engine, args map[string]string) { return } lvGrade := subsidyTmp[parentUser.Level] - var rewardList = make(map[string]md.ExtendPriceRewardList) - for _, v := range lvGrade.ExtendPriceRewardList { - rewardList[v.CoinID] = v + var rewardList = make(map[string]md.ExtendPriceRewardListDetail) + if agentUser.Level == 1 { + rewardList = lvGrade.ExtendPriceRewardBuyGoodsProvince + } + if agentUser.Level == 2 { + rewardList = lvGrade.ExtendPriceRewardBuyGoodsCity + } + if agentUser.Level == 3 { + rewardList = lvGrade.ExtendPriceRewardBuyGoodsArea } //判断有没有存过 relate, _ := db.GetExtendAgentCommissionRelate(eg, args["oid"], args["pvd"]) @@ -81,18 +87,7 @@ func AddExtendAgentCommission(eg *xorm.Engine, args map[string]string) { for k, v := range rewardList { var amount float64 = 0 - rewardData := v - reward := md.ExtendPriceRewardListDetail{} - if agentUser.Level == 1 { - reward = rewardData.ProvinceAgent - } - if agentUser.Level == 2 { - reward = rewardData.CityAgent - } - if agentUser.Level == 3 { - reward = rewardData.AreaAgent - } - amount = zhios_order_relate_utils.StrToFloat64(args["commission"]) * zhios_order_relate_utils.StrToFloat64(reward.ExtendAgentBili) / 100 + amount = zhios_order_relate_utils.StrToFloat64(args["commission"]) * zhios_order_relate_utils.StrToFloat64(v.Bili) / 100 if amount == 0 { continue } diff --git a/svc/extend_price_reward.go b/svc/extend_price_reward.go index 1e6ead6..8dfb0ff 100644 --- a/svc/extend_price_reward.go +++ b/svc/extend_price_reward.go @@ -39,9 +39,20 @@ func ExtendPriceReward(eg *xorm.Engine, param map[string]string, cfg *comm_plan. return map[string]string{"0": "0"}, 0 } lvGrade := subsidyTmp[parentUser.Level] - var rewardList = make(map[string]md.ExtendPriceRewardList) - for _, v := range lvGrade.ExtendPriceRewardList { - rewardList[v.CoinID] = v + var rewardList = make(map[string]md.ExtendPriceRewardListDetail) + if param["source"] == "mall_goods_extend_price" { + rewardList = lvGrade.ExtendPriceRewardUpLv + } + if param["source"] == "regional_agent_pay" { + if param["level"] == "1" { + rewardList = lvGrade.ExtendPriceRewardProvince + } + if param["level"] == "2" { + rewardList = lvGrade.ExtendPriceRewardCity + } + if param["level"] == "3" { + rewardList = lvGrade.ExtendPriceRewardArea + } } //查出当前的数量 count, _ := eg.Where("source=? and lv=?", param["source"], param["level"]).Count(&model.UserLvBuyList{}) @@ -53,22 +64,7 @@ func ExtendPriceReward(eg *xorm.Engine, param map[string]string, cfg *comm_plan. } var extendReward = make(map[string]string) for _, coinId := range lvGrade.ReturnType { - rewardData := rewardList[coinId] - reward := md.ExtendPriceRewardListDetail{} - if param["source"] == "mall_goods_extend_price" { - reward = rewardData.UpLv - } - if param["source"] == "regional_agent_pay" { - if param["level"] == "1" { - reward = rewardData.ProvinceAgent - } - if param["level"] == "2" { - reward = rewardData.CityAgent - } - if param["level"] == "3" { - reward = rewardData.AreaAgent - } - } + reward := rewardList[coinId] var pendingAmount = param["commission"] if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 pendingAmount = param["integral"] diff --git a/svc/get_plan_cfg.go b/svc/get_plan_cfg.go index 05f2234..5f45617 100644 --- a/svc/get_plan_cfg.go +++ b/svc/get_plan_cfg.go @@ -60,6 +60,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string) (*comm_plan.PlanOpt, erro opt.GlobalRate = float64(int64(rewardOpt.GlobalRate*1e4)) / 1e4 opt.PushHandRate = float64(int64(rewardOpt.PushHandRate*1e4)) / 1e4 opt.MerchantRate = float64(int64(rewardOpt.MerchantRate*1e4)) / 1e4 + opt.NewAgentRate = float64(int64(rewardOpt.NewAgentRate*1e4)) / 1e4 opt.PlanCommissionId = rewardOpt.PlanCommissionId // 兑换现金比例 virtualCoinMoneyRate, err := GetVirtualCoinMoneyRateList(eg, masterId) diff --git a/svc/reward_commission.go b/svc/reward_commission.go index 43f88c7..3004bad 100644 --- a/svc/reward_commission.go +++ b/svc/reward_commission.go @@ -397,8 +397,9 @@ func CommFee(fee float64, opt *comm_plan.PlanOpt, types string) (float64, float6 globalFee := fee * opt.GlobalRate // 全球分红比例 pushHandFee := fee * opt.PushHandRate merchantFee := fee * opt.MerchantRate + newAgentFee := fee * opt.NewAgentRate // 剩余可分配的佣金 - fee = float64(int64(fee*1e4)-int64(pvdFee*1e4)-int64(sysFee*1e4)-int64(regionFee*1e4)-int64(globalFee*1e4)-int64(pushHandFee*1e4)-int64(merchantFee*1e4)) / 1e4 + fee = float64(int64(fee*1e4)-int64(pvdFee*1e4)-int64(sysFee*1e4)-int64(regionFee*1e4)-int64(globalFee*1e4)-int64(pushHandFee*1e4)-int64(merchantFee*1e4)-int64(newAgentFee*1e4)) / 1e4 return fee, pvdFee, sysFee }