Browse Source

test

tags/v4.3.1
huangjiajun 1 year ago
parent
commit
ef863f8569
2 changed files with 25 additions and 16 deletions
  1. +21
    -16
      rule/relate_commission.go
  2. +4
    -0
      svc/get_plan_cfg.go

+ 21
- 16
rule/relate_commission.go View File

@@ -59,35 +59,40 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi
return goodsId2lvUser, errors.New("参数错误")
}

wg := sync.WaitGroup{}
mu := sync.Mutex{}
group, _ := errgroup.WithContext(context.Background())
var mu sync.Mutex
commArr := GetComm(eg)
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)
for _, param := range commissionParamList {
param := param // 为下面的闭包创建局部变量
wg.Add(1)
go func(param *md.CommissionFirstParam) {
defer wg.Done()
mu.Lock()
group.Go(func() error {
if param.IsShare != 0 {
isShare = true
}
if param.IsAllLevelReturn != 0 {
isAllLevelReturn = true
}
if param.GoodsId != "" {
param.CommissionParam.Oid = param.GoodsId
param.CommissionParam.IsGoods = "1"
param.CommissionParam.ShowLevel = param.ShowLevel
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, commArr, plan, commission, virtualCoinMoneyRate)
if err == nil {
goodsId2lvUser[param.GoodsId] = lvUser
}
if param.GoodsId == "" {
return errors.New("商品ID缺失")
}
param.CommissionParam.Oid = param.GoodsId
param.CommissionParam.IsGoods = "1"
param.CommissionParam.ShowLevel = param.ShowLevel
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, commArr, plan, commission, virtualCoinMoneyRate)
if err != nil {
return err
}
mu.Lock()
goodsId2lvUser[param.GoodsId] = lvUser
mu.Unlock()
}(param)

return nil
})
}
wg.Wait()
if err := group.Wait(); err != nil {
return goodsId2lvUser, errors.New("处理错误")
}

return goodsId2lvUser, nil
}



+ 4
- 0
svc/get_plan_cfg.go View File

@@ -126,6 +126,10 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
}
}
if err := json.Unmarshal([]byte(commissionOpt.Data), &subsidyTmp); err != nil {
if masterId == "68823769" {
fmt.Println("===========================分佣方案数据设置错误", commissionOpt)
fmt.Println("===========================分佣方案数据设置错误", err)
}
return nil, zhios_order_relate_logx.Warn(fmt.Sprintf("%s:分佣方案数据设置错误", masterId))
}
opt.UserRate = subsidyTmp


Loading…
Cancel
Save