From 80d1b204e6a43f29d554e30801c7be3b49ce3aa6 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Fri, 26 Apr 2024 19:07:40 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=B8=80=E4=B8=AA=E5=9C=88=E5=9C=88?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E8=AE=BE=E7=BD=AE=E4=BB=B7=E6=A0=BC=E5=8A=A0?= =?UTF-8?q?=E9=94=81=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ctivity_coin_auto_exchange_green_energy.go | 355 ------------------ .../one_circles_auto_adjust_prices.go | 11 +- .../one_circles_community_dividends.go | 19 +- ...cles_deal_available_green_energy_points.go | 12 + ...circles_sign_in_green_energy_settlement.go | 10 +- .../one_circles_star_level_dividends.go | 2 +- 6 files changed, 34 insertions(+), 375 deletions(-) diff --git a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go index 942b3e0..84df0e4 100644 --- a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go +++ b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go @@ -5,7 +5,6 @@ import ( "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" - "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum" md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md" zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" @@ -16,360 +15,6 @@ import ( "xorm.io/xorm" ) -// ActivityCoinAutoExchangeGreenEnergyNew 活跃积分自动兑换成绿色能量 -func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string, ch *rabbit.Channel) (err error) { - //1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 - //oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ - // "key": "is_open", - // "value": 1, - //}) - //if err != nil { - // return - //} - - oneCirclesPublicPlatoonBasicSetting, err := db.OneCirclesPublicPlatoonBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - return - } - if oneCirclesPublicPlatoonBasicSetting.ExchangeRules == "" { - err = errors.New("自动兑换未设置!") - return - } - var exchangeRulesStruct *md2.ExchangeRulesStruct - err = json.Unmarshal([]byte(oneCirclesPublicPlatoonBasicSetting.ExchangeRules), &exchangeRulesStruct) - if err != nil { - return - } - var autoExchangeNumsByPerson = zhios_order_relate_utils.StrToFloat64(exchangeRulesStruct.AutoExchangeNumsByPerson) //个人活跃积分X个自动兑换 - var autoExchangeNumsByTeam = zhios_order_relate_utils.StrToFloat64(exchangeRulesStruct.AutoExchangeNumsByTeam) //团队活跃积分X个自动兑换 - fmt.Println("autoExchangeNumsByPerson>>>>>>>>>>>>", autoExchangeNumsByPerson) - fmt.Println("autoExchangeNumsByTeam>>>>>>>>>>>>", autoExchangeNumsByTeam) - - //2、获取"个人活跃积分" && 获取"团队活跃积分" - var coin1, coin2 model.VirtualCoin - _, err = engine.Where("id = ?", oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId).Get(&coin1) - if err != nil { - return err - } - _, err = engine.Where("id = ?", oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId).Get(&coin2) - if err != nil { - return err - } - personActivePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin1.ExchangeRatio) - teamActivePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin2.ExchangeRatio) - - //3、当前 "个人活跃积分"可以自动兑换的用户数据 && "团队活跃积分"可以自动兑换的用户数据 - var list1, list2 []model.UserVirtualAmount - err = engine.Where("coin_id = ?", oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId).And("amount >=?", autoExchangeNumsByPerson).Find(&list1) - if err != nil { - fmt.Println("err:::::1111", err) - return - } - err = engine.Where("coin_id = ?", oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId).And("amount >=?", autoExchangeNumsByTeam).Find(&list2) - if err != nil { - fmt.Println("err:::::2222", err) - return - } - - session := engine.NewSession() - defer func() { - session.Close() - if err := recover(); err != nil { - _ = zhios_order_relate_logx.Error(err) - } - }() - session.Begin() - - for _, v := range list1 { - autoExchangeNumsByPersonValue, _ := decimal.NewFromString(v.Amount) - autoExchangeNumsByPersonAmount := autoExchangeNumsByPersonValue.Div(personActivePointsCoinExchangeRatioValue).String() - //TODO::推入rabbitmq 异步处理 - ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ - MasterId: masterId, - Uid: v.Uid, - Amount: v.Amount, - CoinId: coin1.Id, - AutoExchangeNumsAmount: autoExchangeNumsByPersonAmount, - }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToPerson) - } - - for _, v := range list2 { - autoExchangeNumsByTeamValue, _ := decimal.NewFromString(v.Amount) - autoExchangeNumsByTeamAmount := autoExchangeNumsByTeamValue.Div(teamActivePointsCoinExchangeRatioValue).String() - //TODO::推入rabbitmq 异步处理 - ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ - MasterId: masterId, - Uid: v.Uid, - Amount: v.Amount, - CoinId: coin2.Id, - AutoExchangeNumsAmount: autoExchangeNumsByTeamAmount, - }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToTeam) - } - - return -} - -// OldActivityCoinAutoExchangeGreenEnergy 活跃积分自动兑换成绿色能量 -func OldActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err error) { - //1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 - oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - return - } - - oneCirclesPublicPlatoonBasicSetting, err := db.OneCirclesPublicPlatoonBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - return - } - if oneCirclesPublicPlatoonBasicSetting.ExchangeRules == "" { - err = errors.New("自动兑换未设置!") - return - } - var exchangeRulesStruct *md2.ExchangeRulesStruct - err = json.Unmarshal([]byte(oneCirclesPublicPlatoonBasicSetting.ExchangeRules), &exchangeRulesStruct) - if err != nil { - return - } - var autoExchangeNumsByPerson = zhios_order_relate_utils.StrToFloat64(exchangeRulesStruct.AutoExchangeNumsByPerson) //个人活跃积分X个自动兑换 - fmt.Println("autoExchangeNumsByPerson>>>>>>>>>>>>", autoExchangeNumsByPerson) - - //2、获取"个人活跃积分" && 获取"团队活跃积分" - var coin1 model.VirtualCoin - _, err = engine.Where("id = ?", oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId).Get(&coin1) - if err != nil { - return err - } - personActivePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin1.ExchangeRatio) - - //3、当前 "个人活跃积分"可以自动兑换的用户数据 && "团队活跃积分"可以自动兑换的用户数据 - var list1 []model.UserVirtualAmount - err = engine.Where("coin_id = ?", oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId).And("amount >=?", autoExchangeNumsByPerson).Limit(1000, 0).Find(&list1) - if err != nil { - fmt.Println("err:::::1111", err.Error()) - return - } - - //4、处理"个人活跃积分"兑换 - for _, v := range list1 { - session := engine.NewSession() - session.Begin() - - autoExchangeNumsByPersonValue, _ := decimal.NewFromString(v.Amount) - autoExchangeNumsByPersonAmount := autoExchangeNumsByPersonValue.Div(personActivePointsCoinExchangeRatioValue).String() - //4.1计算涨价公式 - err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByPersonAmount, oneCirclesGreenEnergyBasicSetting) - if err1 != nil { - _ = session.Rollback() - return err1 - } - - //4.2给相应的用户加上个人的绿色积分(可用数量) - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "add", - Mid: masterId, - Title: md.OneCirclesPersonalActiveCoinExchangeGreenEnergy, - TransferType: md.OneCirclesPersonalActiveCoinExchangeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesGreenEnergyBasicSetting.PersonGreenEnergyCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(values), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::33333", err.Error()) - return err - } - - //4.3给相应的用户减去个人活跃积分 - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "sub", - Mid: masterId, - Title: md.OneCirclesPersonalActiveCoinExchangeToBeGreenEnergy, - TransferType: md.OneCirclesPersonalActiveCoinExchangeToBeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(v.Amount), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::33333", err.Error()) - return err - } - - //4.4 减少“原始数量”中的绿色能量 - err = DealAvailableGreenEnergyCoin(session, int(enum.PersonalActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), zhios_order_relate_utils.StrToFloat64(autoExchangeNumsByPersonAmount), enum.PersonalActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::44444", err.Error()) - return err - } - session.Commit() - session.Close() - } - - session := engine.NewSession() - defer func() { - session.Close() - if err := recover(); err != nil { - _ = zhios_order_relate_logx.Error(err) - } - }() - session.Begin() - - //6、修改 one_circles_green_energy_basic_setting 的 now_price - _, err = db.OneCirclesGreenEnergyBasicSettingUpdate(session, oneCirclesGreenEnergyBasicSetting.Id, oneCirclesGreenEnergyBasicSetting) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::77777", err.Error()) - return err - } - - if err != nil { - _ = session.Rollback() - return errors.New("事务提交失败") - } - return -} - -// OldActivityCoinAutoExchangeGreenEnergyForTeam 活跃积分自动兑换成绿色能量 -func OldActivityCoinAutoExchangeGreenEnergyForTeam(engine *xorm.Engine, masterId string) (err error) { - //1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 - oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - return - } - - oneCirclesPublicPlatoonBasicSetting, err := db.OneCirclesPublicPlatoonBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - return - } - if oneCirclesPublicPlatoonBasicSetting.ExchangeRules == "" { - err = errors.New("自动兑换未设置!") - return - } - var exchangeRulesStruct *md2.ExchangeRulesStruct - err = json.Unmarshal([]byte(oneCirclesPublicPlatoonBasicSetting.ExchangeRules), &exchangeRulesStruct) - if err != nil { - return - } - var autoExchangeNumsByTeam = zhios_order_relate_utils.StrToFloat64(exchangeRulesStruct.AutoExchangeNumsByTeam) //团队活跃积分X个自动兑换 - fmt.Println("autoExchangeNumsByTeam>>>>>>>>>>>>", autoExchangeNumsByTeam) - - //2、获取"个人活跃积分" && 获取"团队活跃积分" - var coin2 model.VirtualCoin - _, err = engine.Where("id = ?", oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId).Get(&coin2) - if err != nil { - return err - } - teamActivePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin2.ExchangeRatio) - - //3、当前 "个人活跃积分"可以自动兑换的用户数据 && "团队活跃积分"可以自动兑换的用户数据 - var list2 []model.UserVirtualAmount - err = engine.Where("coin_id = ?", oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId).And("amount >=?", autoExchangeNumsByTeam).Limit(1000, 0).Find(&list2) - if err != nil { - fmt.Println("err:::::2222", err.Error()) - return - } - - //5、处理"团队活跃积分"兑换 - for _, v := range list2 { - session := engine.NewSession() - session.Begin() - - autoExchangeNumsByTeamValue, _ := decimal.NewFromString(v.Amount) - autoExchangeNumsByTeamAmount := autoExchangeNumsByTeamValue.Div(teamActivePointsCoinExchangeRatioValue).String() - //5.1计算涨价公式 - err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByTeamAmount, oneCirclesGreenEnergyBasicSetting) - if err1 != nil { - _ = session.Rollback() - return err1 - } - - //5.2给相应的用户加上个人的绿色积分(结算数量) - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "add", - Mid: masterId, - Title: md.OneCirclesTeamActiveCoinExchangeGreenEnergy, - TransferType: md.OneCirclesTeamActiveCoinExchangeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(values), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::33333", err.Error()) - return err - } - - //5.3给相应的用户减去个人团队积分 - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "sub", - Mid: masterId, - Title: md.OneCirclesTeamActiveCoinExchangeToBeGreenEnergy, - TransferType: md.OneCirclesTeamActiveCoinExchangeToBeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(v.Amount), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::66666", err.Error()) - return err - } - - //5.4 减少“原始数量”中的绿色能量 - err = DealAvailableGreenEnergyCoin(session, int(enum.TeamActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), zhios_order_relate_utils.StrToFloat64(autoExchangeNumsByTeamAmount), enum.TeamActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::44444", err.Error()) - return err - } - err = session.Commit() - session.Close() - } - - session := engine.NewSession() - defer func() { - session.Close() - if err := recover(); err != nil { - _ = zhios_order_relate_logx.Error(err) - } - }() - session.Begin() - - //6、修改 one_circles_green_energy_basic_setting 的 now_price - _, err = db.OneCirclesGreenEnergyBasicSettingUpdate(session, oneCirclesGreenEnergyBasicSetting.Id, oneCirclesGreenEnergyBasicSetting) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::77777", err.Error()) - return err - } - - if err != nil { - _ = session.Rollback() - return errors.New("事务提交失败") - } - return -} - // ActivityCoinAutoExchangeGreenEnergy 活跃积分自动兑换成绿色能量(个人) func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string, ch *rabbit.Channel) (err error) { //1、查找`one_circles_public_platoon_basic_setting` 基础设置 diff --git a/rule/one_circles/one_circles_auto_adjust_prices.go b/rule/one_circles/one_circles_auto_adjust_prices.go index 91953fb..3f100d1 100644 --- a/rule/one_circles/one_circles_auto_adjust_prices.go +++ b/rule/one_circles/one_circles_auto_adjust_prices.go @@ -1,9 +1,9 @@ package one_circles import ( - "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum" md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/svc" zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" "encoding/json" @@ -20,13 +20,13 @@ func AutoAdjustPrice(engine *xorm.Engine, masterId string) (err error) { fmt.Println(now.Hour()) //1、查找 `one_circles_green_energy_basic_setting` 基础设置 - oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) + oneCirclesGreenEnergyBasicSetting, cb, err := svc.GetPrice(engine, masterId) if err != nil { return } + if cb != nil { + defer cb() // 释放锁 + } var priceSettingStruct *md2.PriceSettingStruct err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.PriceSetting), &priceSettingStruct) @@ -37,6 +37,7 @@ func AutoAdjustPrice(engine *xorm.Engine, masterId string) (err error) { err = errors.New("价格设置未完全!") return } + session := engine.NewSession() defer func() { session.Close() diff --git a/rule/one_circles/one_circles_community_dividends.go b/rule/one_circles/one_circles_community_dividends.go index 8382772..2fbb1cc 100644 --- a/rule/one_circles/one_circles_community_dividends.go +++ b/rule/one_circles/one_circles_community_dividends.go @@ -1,7 +1,6 @@ package one_circles import ( - "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum" @@ -16,14 +15,14 @@ import ( // CommunityDividends 社区分红 func CommunityDividends(engine *xorm.Engine, masterId string) (err error) { - //1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 - oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - return - } + ////1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 + //oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ + // "key": "is_open", + // "value": 1, + //}) + //if err != nil { + // return + //} //2、查找当前是否有待分红的记录 "个人活跃积分"可以自动兑换的用户数据 && "团队活跃积分"可以自动兑换的用户数据 var m model.OneCirclesCommunityDividends @@ -84,7 +83,7 @@ func CommunityDividends(engine *xorm.Engine, masterId string) (err error) { } //6、 减少“社区分红”钱包中的值 totalDividend, _ := totalValue.Float64() - err = DealAvailableGreenEnergyCoin(session, int(enum.CommunityDividends), totalDividend, 0, enum.CommunityDividends.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) + err = DealAvailableGreenEnergyCoin(session, int(enum.CommunityDividends), totalDividend, 0, enum.CommunityDividends.String(), nil, masterId) if err != nil { _ = session.Rollback() fmt.Println("err:::::444444", err) diff --git a/rule/one_circles/one_circles_deal_available_green_energy_points.go b/rule/one_circles/one_circles_deal_available_green_energy_points.go index 3f2b5c2..9d91fbc 100644 --- a/rule/one_circles/one_circles_deal_available_green_energy_points.go +++ b/rule/one_circles/one_circles_deal_available_green_energy_points.go @@ -5,6 +5,7 @@ import ( "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum" md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/svc" "encoding/json" "github.com/shopspring/decimal" "time" @@ -12,6 +13,17 @@ import ( ) func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amountFee float64, title string, chain *model.OneCirclesGreenEnergyBasicSetting, nowPriceValue string) error { + if chain == nil { + // 查找 `one_circles_green_energy_basic_setting` 基础设置 + oneCirclesGreenEnergyBasicSetting, cb, err := svc.GetPrice(session.Engine(), nowPriceValue) + if err != nil { + return err + } + if cb != nil { + defer cb() // 释放锁 + } + chain = oneCirclesGreenEnergyBasicSetting + } amountValue := decimal.NewFromFloat(amount) now := time.Now() var oneCirclesAvailableGreenEnergyPointsFlow model.OneCirclesAvailableGreenEnergyPointsFlow 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 8f1237b..32d81f5 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 @@ -7,6 +7,7 @@ import ( "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum" md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/svc" zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" "encoding/json" @@ -71,13 +72,14 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, ch *rabbi func HandleSettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, id int64, uid int) (err error) { //1、查找 `one_circles_green_energy_basic_setting` 基础设置 - oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) + oneCirclesGreenEnergyBasicSetting, cb, err := svc.GetPrice(engine, masterId) if err != nil { return } + if cb != nil { + defer cb() // 释放锁 + } + var teamRewardSetting *md2.TeamRewardSettingStruct err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.TeamReward), &teamRewardSetting) if err != nil { diff --git a/rule/one_circles/one_circles_star_level_dividends.go b/rule/one_circles/one_circles_star_level_dividends.go index 072420d..30c5318 100644 --- a/rule/one_circles/one_circles_star_level_dividends.go +++ b/rule/one_circles/one_circles_star_level_dividends.go @@ -288,7 +288,7 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string, ch *rabb //6、 减少“星级分红”中的绿色能量 totalDividend, _ := totalDividendValue.Float64() - err = DealAvailableGreenEnergyCoin(session, int(enum.SettlementStarLevelDividends), totalDividend, 0, enum.SettlementStarLevelDividends.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) + err = DealAvailableGreenEnergyCoin(session, int(enum.SettlementStarLevelDividends), totalDividend, 0, enum.SettlementStarLevelDividends.String(), nil, masterId) if err != nil { _ = session.Rollback() fmt.Println("err:::::9999999", err)