Przeglądaj źródła

add reverse:for v3.3.4 直推奖励

tags/v3.3.4
huangjiajun 2 lat temu
rodzic
commit
3b68a00596
2 zmienionych plików z 91 dodań i 1 usunięć
  1. +81
    -0
      rule/relate_commission.go
  2. +10
    -1
      svc/reward_commission.go

+ 81
- 0
rule/relate_commission.go Wyświetl plik

@@ -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, &param.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
}


+ 10
- 1
svc/reward_commission.go Wyświetl plik

@@ -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
}


Ładowanie…
Anuluj
Zapisz