瀏覽代碼

add reverse:for v3.6.3 制度调整

tags/v3.6.3
huangjiajun 2 年之前
父節點
當前提交
00d7ee02e6
共有 4 個文件被更改,包括 104 次插入43 次删除
  1. +15
    -0
      db/db_block_green.go
  2. +32
    -0
      db/model/block_green_chain.go
  3. +38
    -41
      rule/relate_commission.go
  4. +19
    -2
      svc/reward_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
}

+ 32
- 0
db/model/block_green_chain.go 查看文件

@@ -0,0 +1,32 @@
package model

import (
"time"
)

type BlockGreenChain struct {
Id int `json:"id" xorm:"not null pk autoincr comment('主键id') INT(11)"`
IsUse int `json:"is_use" xorm:"not null default 0 comment('是否开启(否:0;是:1)') TINYINT(1)"`
Coin1 int `json:"coin_1" xorm:"coin_1 not null default 0 comment('coinId_1(类似于区块币)') INT(11)"`
Coin2 int `json:"coin_2" xorm:"coin_2 not null default 0 comment('coinId_2(类似于静态贡献值)') INT(11)"`
InitialEverydayPublishCoin string `json:"initial_everyday_publish_coin" xorm:"not null default 0.0000000000 comment('初始每日区块币发行数量') DECIMAL(28,10)"`
NowEverydayPublishCoin string `json:"now_everyday_publish_coin" xorm:"not null default 0.0000000000 comment('当前每日区块币发行数量') DECIMAL(28,10)"`
TodayPublishCoin string `json:"today_publish_coin" xorm:"not null default 0.0000000000 comment('今日区块币发行数量(若为0,则按当前每日区块币发行数量)') DECIMAL(28,10)"`
EveryThirtyDaysReduceRate string `json:"every_thirty_days_reduce_rate" xorm:"not null default 5.00 comment('每三十日递减发行百分比') DECIMAL(5,2)"`
TotalNowCoin string `json:"total_now_coin" xorm:"not null default 0.0000000000 comment('当前区块币总量') DECIMAL(28,10)"`
TotalPublishCoin string `json:"total_publish_coin" xorm:"not null default 0.0000000000 comment('累计区块币发行总量') DECIMAL(28,10)"`
TotalDestroyCoin string `json:"total_destroy_coin" xorm:"not null default 0.0000000000 comment('累计区块币销毁总量') DECIMAL(28,10)"`
TotalRemainderCoin string `json:"total_remainder_coin" xorm:"not null default 0.0000000000 comment('累计区块币剩余总量') DECIMAL(28,10)"`
InitialCoinTotal string `json:"initial_coin_total" xorm:"not null default 0.0000000000 comment('初始区块币总量') DECIMAL(28,10)"`
PlatformGuidePriceForCoin string `json:"platform_guide_price_for_coin" xorm:"not null default 0.0000000000 comment('平台区块币指导价') DECIMAL(22,10)"`
PlatformBusinessDiscountRate string `json:"platform_business_discount_rate" xorm:"not null default 10.00 comment('平台商家让利百分比') DECIMAL(5,2)"`
ChemicalsForDailyRate string `json:"chemicals_for_daily_rate" xorm:"not null default 100.00 comment('日化率') DECIMAL(5,2)"`
PublishCoinConsumeRate string `json:"publish_coin_consume_rate" xorm:"not null default 45.00 comment('区块币发行消费占比') DECIMAL(5,2)"`
PublishCoinAirdropRate string `json:"publish_coin_airdrop_rate" xorm:"not null default 45.00 comment('区块币发行空投占比') DECIMAL(5,2)"`
RewardSettings string `json:"reward_settings" xorm:"comment('奖励设置') TEXT"`
StartAt string `json:"start_at" xorm:"not null default '0000-00' comment('起始时间(0000-00)') CHAR(50)"`
SettlementDate string `json:"settlement_date" xorm:"not null default '0000-00' comment('结算日期(0000-00)') CHAR(50)"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
IntegralRewardMultiple int `json:"integral_reward_multiple" xorm:"default 0 comment('自购积分奖励倍数') INT(11)"`
}

+ 38
- 41
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,7 +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
}
@@ -78,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 {
@@ -101,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
}
@@ -137,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
}

@@ -169,17 +176,14 @@ 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
}

@@ -204,17 +208,17 @@ 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
@@ -233,11 +237,7 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar

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
}
commArr := GetComm(engine)
plan, commission, virtualCoinMoneyRate := svc.GetAllPlan(engine, dbName)

for _, param := range CommissionParamList {
@@ -258,7 +258,7 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar
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)
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
}
@@ -297,14 +297,11 @@ func SettleCommWithOrder(eg *xorm.Engine, dbName string, CommissionParam md.Comm
"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
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
}

+ 19
- 2
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 {
@@ -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" { //直推奖励
@@ -212,6 +220,15 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
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 {


Loading…
取消
儲存