|
|
@@ -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, ¶m.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, ¶m.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 |
|
|
|
} |
|
|
|
|
|
|
|