ソースを参照

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	db/model/block_green_chain.go
tags/v3.6.4
DengBiao 2年前
コミット
a2dc86d5d5
8個のファイルの変更180行の追加136行の削除
  1. +15
    -0
      db/db_block_green.go
  2. +1
    -0
      db/model/plan_reward.go
  3. +1
    -0
      lib/comm_plan/init.go
  4. +116
    -119
      rule/relate_commission.go
  5. +1
    -0
      svc/get_plan_cfg.go
  6. +6
    -2
      svc/public_platoon_relate_commission.go
  7. +34
    -12
      svc/reward_commission.go
  8. +6
    -3
      svc/small_public_platoon_relate_commission.go

+ 15
- 0
db/db_block_green.go ファイルの表示

@@ -0,0 +1,15 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"xorm.io/xorm"
)

func GetGreenChain(eg *xorm.Engine) *model.BlockGreenChain {
var data model.BlockGreenChain
get, err := eg.Where("is_use=1").Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

+ 1
- 0
db/model/plan_reward.go ファイルの表示

@@ -17,5 +17,6 @@ type PlanReward struct {
MerchantRate float32 `json:"merchant_rate" xorm:"not null default 0.0000 comment('o2o商家抽成比例') FLOAT(6,4)"`
NewAgentRate float32 `json:"new_agent_rate" xorm:"not null default 0.0000 comment('') FLOAT(6,4)"`
PushHandRate float32 `json:"push_hand_rate" xorm:"not null default 0.0000 comment('o2o推手抽成比例') FLOAT(6,4)"`
OrderBeforeRate float32 `json:"order_before_rate" xorm:"not null default 0.0000 comment('下单前的联盟抽成') FLOAT(6,4)"`
IntegralOpen int `json:"integral_open" xorm:"not null default 0 comment('积分抽成') TINYINT(1)"`
}

+ 1
- 0
lib/comm_plan/init.go ファイルの表示

@@ -24,6 +24,7 @@ type PlanOpt struct {
GlobalRate float64 // 全球分红占佣比例
MerchantRate float64 //商家占佣比例
NewAgentRate float64 //代理分红占佣比例
OrderBeforeRate float64
PushHandRate float64 //推手占佣比例
//IntegralBili float64 // 积分兑换比例
//BlockIconsBili float64 // 区块币兑换比例


+ 116
- 119
rule/relate_commission.go ファイルの表示

@@ -13,6 +13,23 @@ import (
"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 批量分佣 商品显示
func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamList []*md.CommissionFirstParam) (map[string]*comm_plan.LvUser, error) {
var (
@@ -26,11 +43,7 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi

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
}
commArr := GetComm(eg)
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)
for _, param := range commissionParamList {
param := param // 为下面的闭包创建局部变量
@@ -47,8 +60,7 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi
param.CommissionParam.Oid = param.GoodsId
param.CommissionParam.IsGoods = "1"
param.CommissionParam.ShowLevel = param.ShowLevel

_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate)
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, commArr, plan, commission, virtualCoinMoneyRate)
if err != nil {
return err
}
@@ -79,11 +91,8 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP

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
}
commArr := GetComm(eg)

plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)

for _, param := range commissionParamList {
@@ -102,7 +111,7 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP
param.CommissionParam.IsGoods = "1"
param.CommissionParam.IsShowExtend = param.IsShowExtend

_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType, plan, commission, virtualCoinMoneyRate)
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, commArr, plan, commission, virtualCoinMoneyRate)
if err != nil {
return err
}
@@ -120,66 +129,6 @@ func BatchGetCommissionByGoodsExtend(eg *xorm.Engine, dbName string, commissionP
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, &param.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) {
var (
@@ -198,17 +147,14 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m
"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
}
commArr := GetComm(eg)

CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel
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
}

@@ -230,49 +176,18 @@ func SettleCommWithGoodsDetailExtend(eg *xorm.Engine, dbName string, CommissionP
"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
}
commArr := GetComm(eg)

CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"
CommissionParam.CommissionParam.IsShowExtend = CommissionParam.IsShowExtend
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
}
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) {
var (
isAll = false
@@ -293,18 +208,100 @@ func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam m
CommissionParam.CommissionParam.IsGoods = "1"
CommissionParam.CommissionParam.ShowLevel = CommissionParam.ShowLevel
plan, commissions, virtualCoinMoneyRate := svc.GetAllPlan(eg, dbName)
commArr := GetComm(eg)
var lvUser = &comm_plan.LvUser{}
var mapsDta = map[string]string{"show_level": CommissionParam.ShowLevel}
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 {
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 {
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
}

// 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
commArr := GetComm(engine)
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, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, commArr, 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),
}
commArr := GetComm(eg)

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, commArr, plan, commission, virtualCoinMoneyRate)
return profit, pvdFee, sysFee, subsidyFee, lvUser, err
}

+ 1
- 0
svc/get_plan_cfg.go ファイルの表示

@@ -72,6 +72,7 @@ func GetPlanCfg(eg *xorm.Engine, pvd, masterId string, rewardOpts map[string]*mo
opt.PushHandRate = float64(int64(rewardOpt.PushHandRate*1e4)) / 1e4
opt.MerchantRate = float64(int64(rewardOpt.MerchantRate*1e4)) / 1e4
opt.NewAgentRate = float64(int64(rewardOpt.NewAgentRate*1e4)) / 1e4
opt.OrderBeforeRate = float64(int64(rewardOpt.OrderBeforeRate*1e4)) / 1e4
opt.PlanCommissionId = rewardOpt.PlanCommissionId
// 兑换现金比例
if virtualCoinMoneyRate == nil {


+ 6
- 2
svc/public_platoon_relate_commission.go ファイルの表示

@@ -8,7 +8,6 @@ import (
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"xorm.io/xorm"
)
@@ -120,11 +119,16 @@ func BatchGetPublicPlatoonRelateCommissionByOrder(engine *xorm.Engine, masterId
return nil, errors.New("更新公排关系记录失败")
}
}
recommendUid := ""
userProfile, _ := db.UserProfileFindByID(engine, param.Uid)
if userProfile != nil && userProfile.ParentUid > 0 {
recommendUid = zhios_order_relate_utils.IntToStr(userProfile.ParentUid)
}
///
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{
Uid: param.Uid,
CommonWealthBenefitUid: nowBenefitUid,
DirectPushBenefitUid: strconv.Itoa(userPublicPlatoonRelation.RecommendUid),
DirectPushBenefitUid: recommendUid,
PendingAmount: param.PendingAmount,
PendingIntegral: param.PendingIntegral,
Oid: param.Oid,


+ 34
- 12
svc/reward_commission.go ファイルの表示

@@ -15,8 +15,8 @@ import (

// getRewardCommission is 获取制度后的佣金
// 返回:单个佣金、层级佣金、错误
func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare bool, userId, provider, masterId string, returnAllLevel bool, extraData map[string]string, virType string, rewardOpts map[string]*model.PlanReward, commissionOpts map[int]*model.PlanCommission, virtualCoinMoneyRate map[int]string) (float64, float64, float64, float64, *comm_plan.LvUser, error) {
func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare bool, userId, provider, masterId string, returnAllLevel bool, extraData map[string]string, commArr map[string]string, rewardOpts map[string]*model.PlanReward, commissionOpts map[int]*model.PlanCommission, virtualCoinMoneyRate map[int]string) (float64, float64, float64, float64, *comm_plan.LvUser, error) {
virType := commArr["virType"]
if virType == "commission" {
rmd.PaidPrice = rmd.Commission
if zhios_order_relate_utils.InArr(provider, []string{md.PVD_TB, md.PVD_TM, md.PVD_PDD, md.PVD_SN, md.PVD_KL, md.PVD_JD, md.PVD_VIP}) == false {
@@ -78,9 +78,9 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
}
if cfg.Mode == "public_platoon" { //公排
//佣金扣除抽成后
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission")
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd.IsGoods)
////积分扣除抽成后
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral")
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd.IsGoods)
//调用公排制度

userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{
@@ -150,6 +150,14 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
}
//自购
ulink = getRewardLink(reward.Uid, 0, reward.SelfRateList, ulink, "own", cfg)
if zhios_order_relate_utils.StrToFloat64(commArr["integralRewardMultiple"]) > 0 {
for k, v := range ulink.OwnSubsidyFeeList {
ulink.OwnSubsidyFeeList[k] = v * zhios_order_relate_utils.StrToFloat64(commArr["integralRewardMultiple"])
}
for k, v := range ulink.ProfitList {
ulink.ProfitList[k].Val = v.Val * zhios_order_relate_utils.StrToFloat64(commArr["integralRewardMultiple"])
}
}
return profit, pvdFee, sysFee, 0, ulink, nil
}
if cfg.Mode == "extend_price" { //直推奖励
@@ -161,9 +169,9 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
userLevel = zhios_order_relate_utils.StrToInt(extraData["agent_lv"])
}
//佣金扣除抽成后
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission")
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission", rmd.IsGoods)
////积分扣除抽成后
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral")
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral", rmd.IsGoods)
var param = map[string]string{
"commission": zhios_order_relate_utils.Float64ToStr(fee),
"integral": zhios_order_relate_utils.Float64ToStr(integralFee),
@@ -205,13 +213,22 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
userRelationship = nil
}
// userRelationship == nil 是只返回第一层 即用户自己的
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine)
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine, rmd.IsGoods)
if err != nil {
return 0, 0, 0, 0, nil, nil
}
if ulink == nil {
return 0, 0, 0, 0, nil, nil
}
if zhios_order_relate_utils.StrToFloat64(commArr["integralRewardMultiple"]) > 0 {
for k, v := range ulink.OwnSubsidyFeeList {
ulink.OwnSubsidyFeeList[k] = v * zhios_order_relate_utils.StrToFloat64(commArr["integralRewardMultiple"])
}
for k, v := range ulink.ProfitList {
ulink.ProfitList[k].Val = v.Val * zhios_order_relate_utils.StrToFloat64(commArr["integralRewardMultiple"])
}
}

return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil
}
func getRewardLink(uid string, diff int, reward map[string]string, ulinkParent *comm_plan.LvUser, types string, cfg *comm_plan.PlanOpt) *comm_plan.LvUser {
@@ -407,7 +424,7 @@ func currentPrice(m *md.CommissionParam, pvd string) string {
return ""
}
}
func CommFee(fee float64, opt *comm_plan.PlanOpt, types string) (float64, float64, float64) {
func CommFee(fee float64, opt *comm_plan.PlanOpt, types, isGoods string) (float64, float64, float64) {
if types == "integral" && opt.IntegralOpen == 0 || opt.Mode == "lv_winery" { //积分抽成后台没开启不用扣
return fee, 0, 0
}
@@ -419,19 +436,24 @@ func CommFee(fee float64, opt *comm_plan.PlanOpt, types string) (float64, float6
merchantFee := fee * opt.MerchantRate
newAgentFee := fee * opt.NewAgentRate
// 剩余可分配的佣金
fee = float64(int64(fee*1e4)-int64(pvdFee*1e4)-int64(sysFee*1e4)-int64(regionFee*1e4)-int64(globalFee*1e4)-int64(pushHandFee*1e4)-int64(merchantFee*1e4)-int64(newAgentFee*1e4)) / 1e4
total := int64(fee*1e4) - int64(pvdFee*1e4) - int64(sysFee*1e4) - int64(regionFee*1e4) - int64(globalFee*1e4) - int64(pushHandFee*1e4) - int64(merchantFee*1e4) - int64(newAgentFee*1e4)
if isGoods == "1" {
orderBeforeRate := fee * opt.OrderBeforeRate
total = total - int64(orderBeforeRate*1e4)
}
fee = float64(total) / 1e4
return fee, pvdFee, sysFee
}

// 根据用户计算对应的手续费
//ownbuyReturnType 0返利 1不返利 (免单商品是淘礼金商品的时候用的)
//pvd 只是为了判断是会员升级的订单 可不传
func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee float64, isShare bool, opt *comm_plan.PlanOpt, userRelationShip *[]md.UserRelation, pvd string, newLevel int, eg *xorm.Engine) (pvdFee, sysFee, subsidyFee float64, lvUser *comm_plan.LvUser, err error) {
func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee float64, isShare bool, opt *comm_plan.PlanOpt, userRelationShip *[]md.UserRelation, pvd string, newLevel int, eg *xorm.Engine, isGoods string) (pvdFee, sysFee, subsidyFee float64, lvUser *comm_plan.LvUser, err error) {
//佣金扣除抽成后
fee, pvdFee, sysFee = CommFee(fee, opt, "commission")
fee, pvdFee, sysFee = CommFee(fee, opt, "commission", isGoods)
//积分扣除抽成后
var integralSysFee float64 = 0
integralFee, _, integralSysFee = CommFee(integralFee, opt, "integral")
integralFee, _, integralSysFee = CommFee(integralFee, opt, "integral", isGoods)
// 计算自购补贴比例
subsidyFee = 0
//如果没登录,要找出权重最低的那个


+ 6
- 3
svc/small_public_platoon_relate_commission.go ファイルの表示

@@ -8,7 +8,6 @@ import (
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"xorm.io/xorm"
)
@@ -122,11 +121,15 @@ func BatchSmallGetPublicPlatoonRelateCommission(engine *xorm.Engine, masterId st
return nil, errors.New("更新公排关系记录失败")
}
}

recommendUid := ""
userProfile, _ := db.UserProfileFindByID(engine, param.Uid)
if userProfile != nil && userProfile.ParentUid > 0 {
recommendUid = zhios_order_relate_utils.IntToStr(userProfile.ParentUid)
}
resp[param.Oid] = &md.SmallPublicPlatoonRelateCommissionResp{
Uid: param.Uid,
CommonWealthBenefitUid: nowBenefitUid,
DirectPushBenefitUid: strconv.Itoa(userPublicPlatoonRelation.RecommendUid),
DirectPushBenefitUid: recommendUid,
PendingAmount: param.PendingAmount,
Oid: param.Oid,
SelfRateList: selfRateList,


読み込み中…
キャンセル
保存