|
@@ -12,8 +12,8 @@ import ( |
|
|
"xorm.io/xorm" |
|
|
"xorm.io/xorm" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// BatchGetCommission 批量分佣 |
|
|
|
|
|
func BatchGetCommission(eg *xorm.Engine, dbName string, commissionParamList []*md.CommissionFirstParam) (map[string]*comm_plan.LvUser, error) { |
|
|
|
|
|
|
|
|
// BatchGetCommission 批量分佣 商品显示 |
|
|
|
|
|
func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamList []*md.CommissionFirstParam) (map[string]*comm_plan.LvUser, error) { |
|
|
var ( |
|
|
var ( |
|
|
isShare = false |
|
|
isShare = false |
|
|
isAllLevelReturn = false |
|
|
isAllLevelReturn = false |
|
@@ -62,3 +62,60 @@ func BatchGetCommission(eg *xorm.Engine, dbName string, commissionParamList []*m |
|
|
|
|
|
|
|
|
return goodsId2lvUser, nil |
|
|
return goodsId2lvUser, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// BatchGetCommission 批量分佣 订单显示 |
|
|
|
|
|
func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionParamList []*md.CommissionFirstParam) (map[string]*comm_plan.SettleCommissionToGuide, error) { |
|
|
|
|
|
var ( |
|
|
|
|
|
isShare = false |
|
|
|
|
|
isAllLevelReturn = false |
|
|
|
|
|
) |
|
|
|
|
|
goodsId2lvUser := make(map[string]*comm_plan.SettleCommissionToGuide, len(CommissionParamList)) |
|
|
|
|
|
if len(CommissionParamList) == 0 { |
|
|
|
|
|
return goodsId2lvUser, errors.New("参数缺失") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
group, _ := errgroup.WithContext(context.Background()) |
|
|
|
|
|
var mu sync.Mutex |
|
|
|
|
|
virCfg, _ := db.SysCfgGetOne(engine, "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.Oid == "" { |
|
|
|
|
|
return errors.New("订单缺失") |
|
|
|
|
|
} |
|
|
|
|
|
param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice |
|
|
|
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
mu.Lock() |
|
|
|
|
|
goodsId2lvUser[param.Oid] = &comm_plan.SettleCommissionToGuide{ |
|
|
|
|
|
Profit: profit, |
|
|
|
|
|
PvdFee: pvdFee, |
|
|
|
|
|
SysFee: sysFee, |
|
|
|
|
|
SubsidyFee: subsidyFee, |
|
|
|
|
|
LvUser: lvUser, |
|
|
|
|
|
} |
|
|
|
|
|
mu.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if err := group.Wait(); err != nil { |
|
|
|
|
|
return goodsId2lvUser, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return goodsId2lvUser, nil |
|
|
|
|
|
} |