Browse Source

update 消费补贴

master
DengBiao 1 year ago
parent
commit
a5fef4c92a
2 changed files with 20 additions and 18 deletions
  1. +16
    -14
      db/model/subsidy_base.go
  2. +4
    -4
      rule/consume_integral_settlement.go

+ 16
- 14
db/model/subsidy_base.go View File

@@ -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)"`
}

+ 4
- 4
rule/consume_integral_settlement.go View File

@@ -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)


Loading…
Cancel
Save