From a5fef4c92a7f3d7570a7d647fbf96a77e501474c Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 28 Dec 2023 16:53:16 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=B6=88=E8=B4=B9=E8=A1=A5=E8=B4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/model/subsidy_base.go | 30 +++++++++++++++-------------- rule/consume_integral_settlement.go | 8 ++++---- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/db/model/subsidy_base.go b/db/model/subsidy_base.go index 3dba776..057c3af 100644 --- a/db/model/subsidy_base.go +++ b/db/model/subsidy_base.go @@ -1,18 +1,20 @@ package model type SubsidyBase struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - 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)"` - 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)"` - ExperienceIntegral string `json:"experience_integral" xorm:"default 0.00 comment('体验积分数量') DECIMAL(20,2)"` - ExperienceMoney string `json:"experience_money" xorm:"default 0.00 comment('体验补贴') DECIMAL(20,2)"` - ConsumptionDay int `json:"consumption_day" xorm:"default 0 comment('消费补贴兑换后第X天') INT(11)"` - ExperienceDay int `json:"experience_day" xorm:"comment('体贴补贴兑换后第X天') VARCHAR(255)"` - SettleTime string `json:"settle_time" xorm:"comment('每天 XX:xx') VARCHAR(255)"` - HolidaySettleOpen int `json:"holiday_settle_open" xorm:"default 0 comment('节假日是否结算') INT(1)"` - SettlementDate string `json:"settlement_date" xorm:"not null default '0000-00' comment('结算日期(0000-00)') CHAR(50)"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + 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)"` + 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)"` + ConsumptionTotalMoney string `json:"consumption_total_money" xorm:"default 0.00 comment('资金池 消费补贴(元)') DECIMAL(20,2)"` + ExperienceIntegral string `json:"experience_integral" xorm:"default 0.00 comment('体验积分数量') DECIMAL(20,2)"` + ExperienceMoney string `json:"experience_money" xorm:"default 0.00 comment('体验补贴') DECIMAL(20,2)"` + ExperienceTotalMoney string `json:"experience_total_money" xorm:"default 0.00 comment('资金池 体验补贴(元)') DECIMAL(20,2)"` + ConsumptionDay int `json:"consumption_day" xorm:"default 0 comment('消费补贴兑换后第X天') INT(11)"` + ExperienceDay int `json:"experience_day" xorm:"comment('体贴补贴兑换后第X天') VARCHAR(255)"` + SettleTime string `json:"settle_time" xorm:"comment('每天 XX:xx') VARCHAR(255)"` + HolidaySettleOpen int `json:"holiday_settle_open" xorm:"default 0 comment('节假日是否结算') INT(1)"` + SettlementDate string `json:"settlement_date" xorm:"not null default '0000-00' comment('结算日期(0000-00)') CHAR(50)"` } diff --git a/rule/consume_integral_settlement.go b/rule/consume_integral_settlement.go index 1d5e8f4..b027d17 100644 --- a/rule/consume_integral_settlement.go +++ b/rule/consume_integral_settlement.go @@ -128,8 +128,8 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask //3、修改 subsidy_base 中 consumption_money、experience_money consumeTotal, _ := consumeValueTotal.Float64() experienceTotal, _ := experienceValueTotal.Float64() - subsidyBase.ConsumptionMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ConsumptionMoney) - consumeTotal) - subsidyBase.ExperienceMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ExperienceMoney) - experienceTotal) + subsidyBase.ConsumptionTotalMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ConsumptionTotalMoney) - consumeTotal) + subsidyBase.ExperienceTotalMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ExperienceTotalMoney) - experienceTotal) updateAffected, err := db.SubsidyBaseUpdate(session, subsidyBase.Id, subsidyBase, "consumption_money", "experience_money") if err != nil { _ = session.Rollback() @@ -154,7 +154,7 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask //计算当前消费积分价值(公式 "((资金池的金额 * 浮动比例) / 消费补贴总数) + 基础补贴") func calcNowEverydayConsumeIntegral(subsidyBase *model.SubsidyBase, hasConsumeTotal int64) (value float64, err error) { - consumptionMoney, _ := decimal.NewFromString(subsidyBase.ConsumptionMoney) + consumptionMoney, _ := decimal.NewFromString(subsidyBase.ConsumptionTotalMoney) baseSubsidyMoney, _ := decimal.NewFromString(subsidyBase.BaseSubsidyMoney) floatSubsidyOpen := decimal.NewFromInt(int64(subsidyBase.FloatSubsidyOpen) / 10000) consumeTotal := decimal.NewFromInt(hasConsumeTotal) @@ -165,7 +165,7 @@ func calcNowEverydayConsumeIntegral(subsidyBase *model.SubsidyBase, hasConsumeTo //计算当前体验积分价值 func calcNowEverydayExperienceIntegral(subsidyBase *model.SubsidyBase, hasExperienceTotal int64) (value float64, err error) { //2、通过公式计算 "((资金池的金额 * 浮动比例) / 体验补贴总数) + 基础补贴" - experienceMoney, _ := decimal.NewFromString(subsidyBase.ExperienceMoney) + experienceMoney, _ := decimal.NewFromString(subsidyBase.ExperienceTotalMoney) baseSubsidyMoney, _ := decimal.NewFromString(subsidyBase.BaseSubsidyMoney) floatSubsidyOpen := decimal.NewFromInt(int64(subsidyBase.FloatSubsidyOpen) / 10000) consumeTotal := decimal.NewFromInt(hasExperienceTotal)