|
@@ -13,6 +13,23 @@ import ( |
|
|
"xorm.io/xorm" |
|
|
"xorm.io/xorm" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func GetComm(eg *xorm.Engine) map[string]string { |
|
|
|
|
|
virCfg, _ := db.SysCfgGetOne(eg, "virtual_coin_rebate_type") |
|
|
|
|
|
var virType = "price" |
|
|
|
|
|
if virCfg != nil && virCfg.Val != "" { |
|
|
|
|
|
virType = virCfg.Val |
|
|
|
|
|
} |
|
|
|
|
|
var arg = map[string]string{ |
|
|
|
|
|
"virType": virType, |
|
|
|
|
|
"integralRewardMultiple": "0", |
|
|
|
|
|
} |
|
|
|
|
|
chain := db.GetGreenChain(eg) |
|
|
|
|
|
if chain != nil { |
|
|
|
|
|
arg["integralRewardMultiple"] = zhios_order_relate_utils.IntToStr(chain.IntegralRewardMultiple) |
|
|
|
|
|
} |
|
|
|
|
|
return arg |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// BatchGetCommission 批量分佣 商品显示 |
|
|
// BatchGetCommission 批量分佣 商品显示 |
|
|
func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamList []*md.CommissionFirstParam) (map[string]*comm_plan.LvUser, error) { |
|
|
func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamList []*md.CommissionFirstParam) (map[string]*comm_plan.LvUser, error) { |
|
|
var ( |
|
|
var ( |
|
@@ -26,11 +43,7 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi |
|
|
|
|
|
|
|
|
group, _ := errgroup.WithContext(context.Background()) |
|
|
group, _ := errgroup.WithContext(context.Background()) |
|
|
var mu sync.Mutex |
|
|
var mu sync.Mutex |
|
|
virCfg, _ := db.SysCfgGetOne(eg, "virtual_coin_rebate_type") |
|
|
|
|
|
var virType = "price" |
|
|
|
|
|
if virCfg != nil && virCfg.Val != "" { |
|
|
|
|
|
virType = virCfg.Val |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
commArr := GetComm(eg) |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
for _, param := range commissionParamList { |
|
|
for _, param := range commissionParamList { |
|
|
param := param // 为下面的闭包创建局部变量 |
|
|
param := param // 为下面的闭包创建局部变量 |
|
@@ -47,7 +60,7 @@ 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{}, commArr, plan, commission, virtualCoinMoneyRate) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
@@ -78,11 +91,8 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP |
|
|
|
|
|
|
|
|
group, _ := errgroup.WithContext(context.Background()) |
|
|
group, _ := errgroup.WithContext(context.Background()) |
|
|
var mu sync.Mutex |
|
|
var mu sync.Mutex |
|
|
virCfg, _ := db.SysCfgGetOne(eg, "virtual_coin_rebate_type") |
|
|
|
|
|
var virType = "price" |
|
|
|
|
|
if virCfg != nil && virCfg.Val != "" { |
|
|
|
|
|
virType = virCfg.Val |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
commArr := GetComm(eg) |
|
|
|
|
|
|
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
|
|
|
|
|
|
for _, param := range commissionParamList { |
|
|
for _, param := range commissionParamList { |
|
@@ -101,7 +111,7 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP |
|
|
param.CommissionParam.IsGoods = "1" |
|
|
param.CommissionParam.IsGoods = "1" |
|
|
param.CommissionParam.IsShowExtend = param.IsShowExtend |
|
|
param.CommissionParam.IsShowExtend = param.IsShowExtend |
|
|
|
|
|
|
|
|
_, _, _, _, 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{}, commArr, plan, commission, virtualCoinMoneyRate) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
@@ -137,17 +147,14 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m |
|
|
"new_lv": CommissionParam.NewLv, |
|
|
"new_lv": CommissionParam.NewLv, |
|
|
"ownbuy_return_type": zhios_order_relate_utils.IntToStr(CommissionParam.OwnbuyReturnType), |
|
|
"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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
commArr := GetComm(eg) |
|
|
|
|
|
|
|
|
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId |
|
|
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId |
|
|
CommissionParam.CommissionParam.IsGoods = "1" |
|
|
CommissionParam.CommissionParam.IsGoods = "1" |
|
|
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel |
|
|
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
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) |
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, commArr, plan, commission, virtualCoinMoneyRate) |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -169,17 +176,14 @@ func SettleCommWithGoodsDetailExtend(eg *xorm.Engine, dbName string, CommissionP |
|
|
"new_lv": CommissionParam.NewLv, |
|
|
"new_lv": CommissionParam.NewLv, |
|
|
"ownbuy_return_type": zhios_order_relate_utils.IntToStr(CommissionParam.OwnbuyReturnType), |
|
|
"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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
commArr := GetComm(eg) |
|
|
|
|
|
|
|
|
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId |
|
|
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId |
|
|
CommissionParam.CommissionParam.IsGoods = "1" |
|
|
CommissionParam.CommissionParam.IsGoods = "1" |
|
|
CommissionParam.CommissionParam.IsShowExtend = CommissionParam.IsShowExtend |
|
|
CommissionParam.CommissionParam.IsShowExtend = CommissionParam.IsShowExtend |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
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) |
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, commArr, plan, commission, virtualCoinMoneyRate) |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -204,17 +208,17 @@ func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam m |
|
|
CommissionParam.CommissionParam.IsGoods = "1" |
|
|
CommissionParam.CommissionParam.IsGoods = "1" |
|
|
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel |
|
|
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel |
|
|
plan, commissions, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
plan, commissions, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
|
|
|
|
|
|
|
|
|
commArr := GetComm(eg) |
|
|
var lvUser = &comm_plan.LvUser{} |
|
|
var lvUser = &comm_plan.LvUser{} |
|
|
var mapsDta = map[string]string{"show_level": CommissionParam.ShowLevel} |
|
|
var mapsDta = map[string]string{"show_level": CommissionParam.ShowLevel} |
|
|
if isAll { |
|
|
if isAll { |
|
|
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, true, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate) |
|
|
|
|
|
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, false, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate) |
|
|
|
|
|
|
|
|
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, true, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, commArr, plan, commissions, virtualCoinMoneyRate) |
|
|
|
|
|
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, false, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, commArr, plan, commissions, virtualCoinMoneyRate) |
|
|
} else { |
|
|
} else { |
|
|
if isShare { |
|
|
if isShare { |
|
|
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate) |
|
|
|
|
|
|
|
|
shareCommission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, commArr, plan, commissions, virtualCoinMoneyRate) |
|
|
} else { |
|
|
} else { |
|
|
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, mode, plan, commissions, virtualCoinMoneyRate) |
|
|
|
|
|
|
|
|
commission, _, _, _, lvUser, _ = svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapsDta, commArr, plan, commissions, virtualCoinMoneyRate) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return commission, shareCommission, lvUser, nil |
|
|
return commission, shareCommission, lvUser, nil |
|
@@ -233,11 +237,7 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar |
|
|
|
|
|
|
|
|
group, _ := errgroup.WithContext(context.Background()) |
|
|
group, _ := errgroup.WithContext(context.Background()) |
|
|
var mu sync.Mutex |
|
|
var mu sync.Mutex |
|
|
virCfg, _ := db.SysCfgGetOne(engine, "virtual_coin_rebate_type") |
|
|
|
|
|
var virType = "price" |
|
|
|
|
|
if virCfg != nil && virCfg.Val != "" { |
|
|
|
|
|
virType = virCfg.Val |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
commArr := GetComm(engine) |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(engine, dbName) |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(engine, dbName) |
|
|
|
|
|
|
|
|
for _, param := range CommissionParamList { |
|
|
for _, param := range CommissionParamList { |
|
@@ -258,7 +258,7 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar |
|
|
param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice |
|
|
param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice |
|
|
param.CommissionParam.Oid = param.Oid |
|
|
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) |
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, commArr, plan, commission, virtualCoinMoneyRate) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
@@ -297,14 +297,11 @@ func SettleCommWithOrder(eg *xorm.Engine, dbName string, CommissionParam md.Comm |
|
|
"new_lv": CommissionParam.NewLv, |
|
|
"new_lv": CommissionParam.NewLv, |
|
|
"ownbuy_return_type": zhios_order_relate_utils.IntToStr(CommissionParam.OwnbuyReturnType), |
|
|
"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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
commArr := GetComm(eg) |
|
|
|
|
|
|
|
|
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId |
|
|
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId |
|
|
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName) |
|
|
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) |
|
|
|
|
|
|
|
|
profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, commArr, plan, commission, virtualCoinMoneyRate) |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
return profit, pvdFee, sysFee, subsidyFee, lvUser, err |
|
|
} |
|
|
} |