From 3d118caadf9be0a2255d5c29170cd49a71d3eeb5 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 28 Dec 2023 20:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/model/subsidy_base.go | 1 + rule/consume_integral_settlement.go | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/db/model/subsidy_base.go b/db/model/subsidy_base.go index 057c3af..1c297d6 100644 --- a/db/model/subsidy_base.go +++ b/db/model/subsidy_base.go @@ -5,6 +5,7 @@ type SubsidyBase struct { IsOpen int `json:"is_open" xorm:"default 0 comment('功能开关:') INT(1)"` LvId string `json:"lv_id" xorm:"comment('json [] 兑换等级:') VARCHAR(255)"` FloatSubsidyOpen int `json:"float_subsidy_open" xorm:"default 0 comment('浮动补贴比例:') INT(1)"` + FloatSubsidyBili int `json:"float_subsidy_bili" xorm:"default 0 comment('浮动补贴比例:') INT(11)"` BaseSubsidyMoney string `json:"base_subsidy_money" xorm:"default 0.00 comment('补贴基础金额设置:') DECIMAL(20,2)"` ConsumptionIntegral string `json:"consumption_integral" xorm:"not null default 0.00 comment('消费积分数量') DECIMAL(20,2)"` ConsumptionMoney string `json:"consumption_money" xorm:"default 0.00 comment('消费补贴') DECIMAL(20,2)"` diff --git a/rule/consume_integral_settlement.go b/rule/consume_integral_settlement.go index 2db0fad..c85694a 100644 --- a/rule/consume_integral_settlement.go +++ b/rule/consume_integral_settlement.go @@ -163,9 +163,12 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask func calcNowEverydayConsumeIntegral(subsidyBase *model.SubsidyBase, hasConsumeTotal int64) (value float64, err error) { consumptionMoney, _ := decimal.NewFromString(subsidyBase.ConsumptionTotalMoney) baseSubsidyMoney, _ := decimal.NewFromString(subsidyBase.BaseSubsidyMoney) - floatSubsidyOpen := decimal.NewFromInt(int64(subsidyBase.FloatSubsidyOpen) / 10000) + if subsidyBase.FloatSubsidyOpen == 0 { //没有浮动补贴情况 + subsidyBase.FloatSubsidyBili = 0 + } + floatSubsidyBili := decimal.NewFromInt(int64(subsidyBase.FloatSubsidyBili) / 10000) consumeTotal := decimal.NewFromInt(hasConsumeTotal) - value, _ = consumptionMoney.Mul(floatSubsidyOpen).Div(consumeTotal).Add(baseSubsidyMoney).Float64() + value, _ = consumptionMoney.Mul(floatSubsidyBili).Div(consumeTotal).Add(baseSubsidyMoney).Float64() return } @@ -174,9 +177,12 @@ func calcNowEverydayExperienceIntegral(subsidyBase *model.SubsidyBase, hasExperi //2、通过公式计算 "((资金池的金额 * 浮动比例) / 体验补贴总数) + 基础补贴" experienceMoney, _ := decimal.NewFromString(subsidyBase.ExperienceTotalMoney) baseSubsidyMoney, _ := decimal.NewFromString(subsidyBase.BaseSubsidyMoney) - floatSubsidyOpen := decimal.NewFromInt(int64(subsidyBase.FloatSubsidyOpen) / 10000) + if subsidyBase.FloatSubsidyOpen == 0 { //没有浮动补贴情况 + subsidyBase.FloatSubsidyBili = 0 + } + floatSubsidyBili := decimal.NewFromInt(int64(subsidyBase.FloatSubsidyBili) / 10000) consumeTotal := decimal.NewFromInt(hasExperienceTotal) - value, _ = experienceMoney.Mul(floatSubsidyOpen).Div(consumeTotal).Add(baseSubsidyMoney).Float64() + value, _ = experienceMoney.Mul(floatSubsidyBili).Div(consumeTotal).Add(baseSubsidyMoney).Float64() return }