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