From 090c2ffc76a3878332baede388cae16312889062 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 4 Aug 2022 10:25:25 +0800 Subject: [PATCH] add reverse:for v1.5.9 test --- md/extend_price_reward.go | 20 ++++++++++++++++---- svc/extend_price_reward.go | 29 ++++++++++++++++++++++------- svc/get_plan_cfg.go | 2 +- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/md/extend_price_reward.go b/md/extend_price_reward.go index 4841031..f6519d2 100644 --- a/md/extend_price_reward.go +++ b/md/extend_price_reward.go @@ -2,8 +2,20 @@ package md // 直推奖励结构 type ExtendRewardLvGrade struct { - Lv int `json:"lv"` // 会员级别 - LvName string `json:"lv_name"` // 会员名称 - ReturnType []string `json:"return_type"` //返利类型 - ExtendPriceRewardList []map[string]string `json:"extend_price_reward_list"` // 直推奖励比例 + 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"` +} +type ExtendPriceRewardListDetail struct { + BaseVal string `json:"base_val"` + Bili string `json:"bili"` + PositionBili string `json:"position_bili"` } diff --git a/svc/extend_price_reward.go b/svc/extend_price_reward.go index 1492828..1e6ead6 100644 --- a/svc/extend_price_reward.go +++ b/svc/extend_price_reward.go @@ -39,9 +39,9 @@ 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]map[string]string) + var rewardList = make(map[string]md.ExtendPriceRewardList) for _, v := range lvGrade.ExtendPriceRewardList { - rewardList[v["coin_id"]] = v + rewardList[v.CoinID] = v } //查出当前的数量 count, _ := eg.Where("source=? and lv=?", param["source"], param["level"]).Count(&model.UserLvBuyList{}) @@ -53,17 +53,32 @@ func ExtendPriceReward(eg *xorm.Engine, param map[string]string, cfg *comm_plan. } var extendReward = make(map[string]string) for _, coinId := range lvGrade.ReturnType { - reward := rewardList[coinId] + 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 + } + } var pendingAmount = param["commission"] if zhios_order_relate_utils.StrToInt(coinId) > 0 { //积分更换基数 pendingAmount = param["integral"] } - rewardAmount := reward["extend_bili"] + rewardAmount := reward.Bili //如果等级一致 判断位置 - if isTrue { - position := count % zhios_order_relate_utils.StrToInt64(param["base_val"]) + if isTrue && zhios_order_relate_utils.StrToInt(reward.BaseVal) > 0 { + position := count % zhios_order_relate_utils.StrToInt64(reward.BaseVal) if position == 0 { - rewardAmount = reward["extend_position_bili"] + rewardAmount = reward.PositionBili } } diff --git a/svc/get_plan_cfg.go b/svc/get_plan_cfg.go index 29a5495..05f2234 100644 --- a/svc/get_plan_cfg.go +++ b/svc/get_plan_cfg.go @@ -48,7 +48,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string) (*comm_plan.PlanOpt, erro if err != nil || commissionOpt == nil || commissionOpt.Id == 0 { return nil, err } - if _, ok := comm_plan.Fn[commissionOpt.Mode]; !ok && commissionOpt.Mode != "public_platoon" { + 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("分佣模式不存在") } opt.Pvd = pvd