From 3b68a005962e192e3ce61c04a8f97dbf6ee2b8a1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 16 Sep 2022 22:13:10 +0800 Subject: [PATCH] =?UTF-8?q?add=20reverse:for=20v3.3.4=20=E7=9B=B4=E6=8E=A8?= =?UTF-8?q?=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/relate_commission.go | 81 +++++++++++++++++++++++++++++++++++++++ svc/reward_commission.go | 11 +++++- 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/rule/relate_commission.go b/rule/relate_commission.go index f2fecc4..4804518 100644 --- a/rule/relate_commission.go +++ b/rule/relate_commission.go @@ -24,6 +24,57 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi return goodsId2lvUser, errors.New("参数错误") } + group, _ := errgroup.WithContext(context.Background()) + var mu sync.Mutex + virCfg, _ := db.SysCfgGetOne(eg, "virtual_coin_rebate_type") + var virType = "price" + if virCfg != nil && virCfg.Val != "" { + virType = virCfg.Val + } + for _, param := range commissionParamList { + param := param // 为下面的闭包创建局部变量 + group.Go(func() error { + if param.IsShare != 0 { + isShare = true + } + if param.IsAllLevelReturn != 0 { + isAllLevelReturn = true + } + if param.GoodsId == "" { + return errors.New("商品ID缺失") + } + param.CommissionParam.Oid = param.GoodsId + param.CommissionParam.IsGoods = "1" + + _, _, _, _, lvUser, err := svc.GetRewardCommission(eg, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType) + if err != nil { + return err + } + mu.Lock() + goodsId2lvUser[param.GoodsId] = lvUser + mu.Unlock() + + return nil + }) + } + if err := group.Wait(); err != nil { + return goodsId2lvUser, errors.New("处理错误") + } + + return goodsId2lvUser, nil +} + +// BatchGetCommission 批量分佣 商品显示 +func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionParamList []*md.CommissionFirstParam) (map[string]*comm_plan.LvUser, error) { + var ( + isShare = false + isAllLevelReturn = false + ) + goodsId2lvUser := make(map[string]*comm_plan.LvUser, len(commissionParamList)) + if len(commissionParamList) == 0 { + return goodsId2lvUser, errors.New("参数错误") + } + group, _ := errgroup.WithContext(context.Background()) var mu sync.Mutex virCfg, _ := db.SysCfgGetOne(eg, "virtual_coin_rebate_type") @@ -133,6 +184,36 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m isShare = true } + if CommissionParam.IsAllLevelReturn != 0 { + isAllLevelReturn = true + } + var mapData = map[string]string{ + "old_lv": CommissionParam.OldLv, + "new_lv": CommissionParam.NewLv, + "ownbuy_return_type": zhios_order_relate_utils.IntToStr(CommissionParam.OwnbuyReturnType), + } + virCfg, _ := db.SysCfgGetOne(eg, "virtual_coin_rebate_type") + var virType = "price" + if virCfg != nil && virCfg.Val != "" { + virType = virCfg.Val + } + CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId + CommissionParam.CommissionParam.IsGoods = "1" + + 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 +} + +//商品详情等使用 +func SettleCommWithGoodsDetailExtend(eg *xorm.Engine, dbName string, CommissionParam md.CommissionFirstParam) (float64, float64, float64, float64, *comm_plan.LvUser, error) { + var ( + isShare = false + isAllLevelReturn = false + ) + if CommissionParam.IsShare != 0 { + isShare = true + } + if CommissionParam.IsAllLevelReturn != 0 { isAllLevelReturn = true } diff --git a/svc/reward_commission.go b/svc/reward_commission.go index 8950b24..8c32bd1 100644 --- a/svc/reward_commission.go +++ b/svc/reward_commission.go @@ -186,7 +186,16 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b if returnAllLevel { userRelationship, err = UserRelativeNetwork(engine, uid, 0) } else if rmd.IsShowExtend == "1" { - userRelationship, err = UserRelativeNetwork(engine, uid, 1) + //userRelationship, err = UserRelativeNetwork(engine, uid, 1) + userRelationship = &[]md.UserRelation{ + { + CurUid: user.Uid, + Diff: 1, + Level: user.Level, + }, + } + uid = 0 + level = 0 } else { userRelationship = nil }