From 2ab34a3471bf8ac0ea7f277bfb925d31949dea2f Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 28 May 2024 16:55:34 +0800 Subject: [PATCH] update --- ...ne_circles_available_green_energy_settlement.go | 14 ++++++++++++-- .../one_circles_sign_in_green_energy_settlement.go | 6 ------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/rule/one_circles/one_circles_available_green_energy_settlement.go b/rule/one_circles/one_circles_available_green_energy_settlement.go index 05fe5f0..debed39 100644 --- a/rule/one_circles/one_circles_available_green_energy_settlement.go +++ b/rule/one_circles/one_circles_available_green_energy_settlement.go @@ -115,8 +115,18 @@ func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string userExchangeNums, _ := decimal.NewFromString(userExchangeNumsValue) //用户兑换绿色能量 originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量 nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格 - originalQuantityFunds, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalFunds) //原始资金 - afterPrice := originalQuantityFunds.Div(userExchangeNums.Add(originalQuantityNums)) //降价后的价格 + var priceSettingStruct *md2.PriceSettingStruct + err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.PriceSetting), &priceSettingStruct) + if err != nil { + return + } + priceHigherThanValue, _ := decimal.NewFromString(priceSettingStruct.PriceHigherThanValue) + if nowPrice.Cmp(priceHigherThanValue) == 1 { + err = errors.New("当前价格异常,请稍后重新兑换") + return + } + originalQuantityFunds, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalFunds) //原始资金 + afterPrice := originalQuantityFunds.Div(userExchangeNums.Add(originalQuantityNums)) //降价后的价格 greenEnergyValues := userExchangeNums.Mul(afterPrice) //绿色能量个数 greenEnergyFeeValues := greenEnergyValues.Mul(exchangeAccountBalanceFee.Div(decimalRate)) //绿色能量个数扣除手续费价值 diff --git a/rule/one_circles/one_circles_sign_in_green_energy_settlement.go b/rule/one_circles/one_circles_sign_in_green_energy_settlement.go index 7b3f40a..511f18b 100644 --- a/rule/one_circles/one_circles_sign_in_green_energy_settlement.go +++ b/rule/one_circles/one_circles_sign_in_green_energy_settlement.go @@ -213,12 +213,6 @@ func HandleSettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, id } } - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::1111", err) - return - } - err = session.Commit() if err != nil { _ = session.Rollback()