From 3bfd8dfe1122ccc9389e828d9cacd66ca8a68b3f Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 13 Sep 2022 20:59:19 +0800 Subject: [PATCH] =?UTF-8?q?add=20reverse:for=20v3.2.1=20=E6=9E=81=E5=B7=AE?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9B=B4=E6=8E=A8=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/dbs_user.go | 8 ++++++-- md/commission_parameter.go | 2 ++ rule/relate_commission.go | 3 +++ svc/reward_commission.go | 7 ++++--- svc/user_relative_network.go | 4 ++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/db/dbs_user.go b/db/dbs_user.go index 7b2237b..0094799 100644 --- a/db/dbs_user.go +++ b/db/dbs_user.go @@ -17,9 +17,13 @@ func DbsUserFindByIds(eg *xorm.Engine, uid []int) (*[]model.User, error) { return &users, nil } -func DbsUserRelate(eg *xorm.Engine, uid int) (*[]model.UserRelate, error) { +func DbsUserRelate(eg *xorm.Engine, uid, level int) (*[]model.UserRelate, error) { var userRelate []model.UserRelate - if err := eg.Where("uid = ?", uid).Asc("level").Find(&userRelate); err != nil { + sess := eg.Where("uid = ?", uid) + if level > 0 { + sess.And("level<=?", level) + } + if err := sess.Asc("level").Find(&userRelate); err != nil { return nil, zhios_order_relate_logx.Error(err) } if len(userRelate) == 0 { diff --git a/md/commission_parameter.go b/md/commission_parameter.go index 9949cab..3f899de 100644 --- a/md/commission_parameter.go +++ b/md/commission_parameter.go @@ -14,6 +14,7 @@ type CommissionParam struct { PaidPrice string `json:"paid_price"` Oid string `json:"oid"` //标记 IsGoods string `json:"is_goods"` + IsShowExtend string `json:"is_show_extend"` } type CommissionFirstParam struct { CommissionParam CommissionParam `json:"commission_param"` @@ -27,4 +28,5 @@ type CommissionFirstParam struct { OwnbuyReturnType int `json:"ownbuy_return_type"` //自购是否返利 0返利 1不返利 Oid string `json:"oid"` ShowLevel string `json:"show_level"` + IsShowExtend string `json:"is_show_extend"` } diff --git a/rule/relate_commission.go b/rule/relate_commission.go index dec227c..f2fecc4 100644 --- a/rule/relate_commission.go +++ b/rule/relate_commission.go @@ -45,6 +45,8 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi } param.CommissionParam.Oid = param.GoodsId param.CommissionParam.IsGoods = "1" + param.CommissionParam.IsShowExtend = param.IsShowExtend + _, _, _, _, lvUser, err := svc.GetRewardCommission(eg, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType) if err != nil { return err @@ -146,6 +148,7 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m } CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId CommissionParam.CommissionParam.IsGoods = "1" + CommissionParam.CommissionParam.IsShowExtend = CommissionParam.IsShowExtend profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType) return profit, pvdFee, sysFee, subsidyFee, lvUser, err diff --git a/svc/reward_commission.go b/svc/reward_commission.go index aa2d71e..8950b24 100644 --- a/svc/reward_commission.go +++ b/svc/reward_commission.go @@ -182,10 +182,11 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b return 0, pvdFee, sysFee, 0, ulink, nil } //常规级差 - var userRelationship *[]md.UserRelation if returnAllLevel { - userRelationship, err = UserRelativeNetwork(engine, uid) + userRelationship, err = UserRelativeNetwork(engine, uid, 0) + } else if rmd.IsShowExtend == "1" { + userRelationship, err = UserRelativeNetwork(engine, uid, 1) } else { userRelationship = nil } @@ -490,7 +491,7 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee levelWeight1 = lvWeight.LevelWeight level1 = lvWeight.Id } - if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee,level1, levelWeight1); err != nil { + if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee, level1, levelWeight1); err != nil { fmt.Println("方案有问题1") return 0, 0, 0, nil, err } diff --git a/svc/user_relative_network.go b/svc/user_relative_network.go index 4e0ee31..cf4b980 100644 --- a/svc/user_relative_network.go +++ b/svc/user_relative_network.go @@ -7,8 +7,8 @@ import ( ) // 获取用户关系等级, 如果返回nil则没有上级用户 -func UserRelativeNetwork(eg *xorm.Engine, uid int) (*[]md.UserRelation, error) { - parent, err := db.DbsUserRelate(eg, uid) +func UserRelativeNetwork(eg *xorm.Engine, uid, level int) (*[]md.UserRelation, error) { + parent, err := db.DbsUserRelate(eg, uid, level) if err != nil || parent == nil { return nil, err }