|
@@ -47,7 +47,6 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi |
|
|
param.CommissionParam.Oid = param.GoodsId |
|
|
param.CommissionParam.Oid = param.GoodsId |
|
|
param.CommissionParam.IsGoods = "1" |
|
|
param.CommissionParam.IsGoods = "1" |
|
|
param.CommissionParam.ShowLevel = param.ShowLevel |
|
|
param.CommissionParam.ShowLevel = param.ShowLevel |
|
|
|
|
|
|
|
|
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate) |
|
|
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
@@ -120,66 +119,6 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP |
|
|
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 |
|
|
|
|
|
} |
|
|
|
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(engine, dbName) |
|
|
|
|
|
|
|
|
|
|
|
for _, param := range CommissionParamList { |
|
|
|
|
|
param := param // 为下面的闭包创建局部变量 |
|
|
|
|
|
group.Go(func() error { |
|
|
|
|
|
defer mu.Unlock() |
|
|
|
|
|
mu.Lock() |
|
|
|
|
|
if param.IsShare != 0 { |
|
|
|
|
|
isShare = true |
|
|
|
|
|
} |
|
|
|
|
|
if param.IsAllLevelReturn != 0 { |
|
|
|
|
|
isAllLevelReturn = true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if param.Oid == "" { |
|
|
|
|
|
return errors.New("订单缺失") |
|
|
|
|
|
} |
|
|
|
|
|
param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice |
|
|
|
|
|
param.CommissionParam.Oid = param.Oid |
|
|
|
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
goodsId2lvUser[param.Oid] = &comm_plan.SettleCommissionToGuide{ |
|
|
|
|
|
Profit: profit, |
|
|
|
|
|
PvdFee: pvdFee, |
|
|
|
|
|
SysFee: sysFee, |
|
|
|
|
|
SubsidyFee: subsidyFee, |
|
|
|
|
|
LvUser: lvUser, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if err := group.Wait(); err != nil { |
|
|
|
|
|
return goodsId2lvUser, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return goodsId2lvUser, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//商品详情等使用 |
|
|
//商品详情等使用 |
|
|
func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam md.CommissionFirstParam) (float64, float64, float64, float64, *comm_plan.LvUser, error) { |
|
|
func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam md.CommissionFirstParam) (float64, float64, float64, float64, *comm_plan.LvUser, error) { |
|
|
var ( |
|
|
var ( |
|
@@ -243,36 +182,8 @@ func SettleCommWithGoodsDetailExtend(eg *xorm.Engine, dbName string, CommissionP |
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType, plan, commission, virtualCoinMoneyRate) |
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType, plan, commission, virtualCoinMoneyRate) |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
} |
|
|
} |
|
|
func SettleCommWithOrder(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 |
|
|
|
|
|
} |
|
|
|
|
|
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 |
|
|
|
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
|
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType, plan, commission, virtualCoinMoneyRate) |
|
|
|
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取自购分享佣金的 |
|
|
|
|
|
|
|
|
//获取自购分享佣金的 商品显示 |
|
|
func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam md.CommissionFirstParam) (float64, float64, *comm_plan.LvUser, error) { |
|
|
func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam md.CommissionFirstParam) (float64, float64, *comm_plan.LvUser, error) { |
|
|
var ( |
|
|
var ( |
|
|
isAll = false |
|
|
isAll = false |
|
@@ -308,3 +219,92 @@ func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam m |
|
|
} |
|
|
} |
|
|
return commission, shareCommission, lvUser, nil |
|
|
return commission, shareCommission, lvUser, 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 |
|
|
|
|
|
} |
|
|
|
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(engine, dbName) |
|
|
|
|
|
|
|
|
|
|
|
for _, param := range CommissionParamList { |
|
|
|
|
|
param := param // 为下面的闭包创建局部变量 |
|
|
|
|
|
group.Go(func() error { |
|
|
|
|
|
defer mu.Unlock() |
|
|
|
|
|
mu.Lock() |
|
|
|
|
|
if param.IsShare != 0 { |
|
|
|
|
|
isShare = true |
|
|
|
|
|
} |
|
|
|
|
|
if param.IsAllLevelReturn != 0 { |
|
|
|
|
|
isAllLevelReturn = true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if param.Oid == "" { |
|
|
|
|
|
return errors.New("订单缺失") |
|
|
|
|
|
} |
|
|
|
|
|
param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice |
|
|
|
|
|
param.CommissionParam.Oid = param.Oid |
|
|
|
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
goodsId2lvUser[param.Oid] = &comm_plan.SettleCommissionToGuide{ |
|
|
|
|
|
Profit: profit, |
|
|
|
|
|
PvdFee: pvdFee, |
|
|
|
|
|
SysFee: sysFee, |
|
|
|
|
|
SubsidyFee: subsidyFee, |
|
|
|
|
|
LvUser: lvUser, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if err := group.Wait(); err != nil { |
|
|
|
|
|
return goodsId2lvUser, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return goodsId2lvUser, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func SettleCommWithOrder(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 |
|
|
|
|
|
} |
|
|
|
|
|
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 |
|
|
|
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
|
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType, plan, commission, virtualCoinMoneyRate) |
|
|
|
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
|
|
|
} |