瀏覽代碼

test

tags/v4.3.1
huangjiajun 1 年之前
父節點
當前提交
bb4ccc8031
共有 1 個檔案被更改,包括 16 行新增21 行删除
  1. +16
    -21
      rule/relate_commission.go

+ 16
- 21
rule/relate_commission.go 查看文件

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

group, _ := errgroup.WithContext(context.Background())
var mu sync.Mutex
wg := sync.WaitGroup{}
mu := sync.Mutex{}
commArr := GetComm(eg)
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)
for _, param := range commissionParamList {
param := param // 为下面的闭包创建局部变量
group.Go(func() error {
wg.Add(1)
go func(param *md.CommissionFirstParam) {
defer wg.Done()
mu.Lock()
if param.IsShare != 0 {
isShare = true
}
if param.IsAllLevelReturn != 0 {
isAllLevelReturn = true
}
if param.GoodsId == "" {
return errors.New("商品ID缺失")
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
}
}
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()

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

wg.Wait()
return goodsId2lvUser, nil
}



Loading…
取消
儲存