@@ -11,6 +11,8 @@ const ( | |||||
GreenEnergyExchangeBalance | GreenEnergyExchangeBalance | ||||
TeamActivePointRedemption | TeamActivePointRedemption | ||||
SettlementStarLevelDividends | SettlementStarLevelDividends | ||||
MarketplaceMerchantNumsAutoExchangeMarketplaceMerchantFunds | |||||
MarketplaceMerchantFundsAutoExchangeMarketplaceMerchantNums | |||||
) | ) | ||||
func (kind OneCirclesAvailableGreenEnergyPointsFlowKind) String() string { | func (kind OneCirclesAvailableGreenEnergyPointsFlowKind) String() string { | ||||
@@ -29,6 +31,10 @@ func (kind OneCirclesAvailableGreenEnergyPointsFlowKind) String() string { | |||||
return "团队活跃积分兑换" | return "团队活跃积分兑换" | ||||
case SettlementStarLevelDividends: | case SettlementStarLevelDividends: | ||||
return "结算星级分红" | return "结算星级分红" | ||||
case MarketplaceMerchantNumsAutoExchangeMarketplaceMerchantFunds: | |||||
return "市商数量自动兑换市商资金" | |||||
case MarketplaceMerchantFundsAutoExchangeMarketplaceMerchantNums: | |||||
return "市商资金自动兑换市商数量" | |||||
default: | default: | ||||
return "未知状态" | return "未知状态" | ||||
} | } | ||||
@@ -19,6 +19,13 @@ type SignInRewardStruct struct { | |||||
RewardValue string `json:"reward_value"` //奖励值 | RewardValue string `json:"reward_value"` //奖励值 | ||||
} | } | ||||
type PriceSettingStruct struct { | |||||
PriceHigherThanValue string `json:"price_higher_than_value"` //高于x元 | |||||
MarketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue string `json:"marketplace_merchants_nums_exchange_marketplace_merchants_fund_value"` //市商数量单笔x数量自动兑换 | |||||
PriceBelowValue string `json:"price_below_value"` //低于x元 | |||||
MarketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue string `json:"marketplace_merchants_fund_exchange_marketplace_merchants_nums_value"` //市商资金单笔x元自动兑换 | |||||
} | |||||
type DestructionSettingStruct struct { | type DestructionSettingStruct struct { | ||||
DestructionQuantity string `json:"destruction_quantity"` //销毁百分比 | DestructionQuantity string `json:"destruction_quantity"` //销毁百分比 | ||||
PublicWelfareAndCharity string `json:"public_welfare_and_charity"` //公益慈善百分比 | PublicWelfareAndCharity string `json:"public_welfare_and_charity"` //公益慈善百分比 | ||||
@@ -7,6 +7,7 @@ import ( | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum" | "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" | 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_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" | "encoding/json" | ||||
"errors" | "errors" | ||||
"fmt" | "fmt" | ||||
@@ -73,6 +74,13 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( | |||||
} | } | ||||
session := engine.NewSession() | session := engine.NewSession() | ||||
defer func() { | |||||
session.Close() | |||||
if err := recover(); err != nil { | |||||
_ = zhios_order_relate_logx.Error(err) | |||||
} | |||||
}() | |||||
session.Begin() | |||||
//4、处理"个人活跃积分"兑换 | //4、处理"个人活跃积分"兑换 | ||||
for _, v := range list1 { | for _, v := range list1 { | ||||
@@ -81,9 +89,9 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( | |||||
//4.1计算涨价公式 | //4.1计算涨价公式 | ||||
err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByPersonAmount, oneCirclesGreenEnergyBasicSetting) | err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByPersonAmount, oneCirclesGreenEnergyBasicSetting) | ||||
if err1 != nil { | if err1 != nil { | ||||
_ = session.Rollback() | |||||
return err1 | return err1 | ||||
} | } | ||||
oneCirclesGreenEnergyBasicSetting.NowPrice = afterPriceValue //TODO::改变当前价格 | |||||
//4.2给相应的用户加上个人的绿色积分(可用数量) | //4.2给相应的用户加上个人的绿色积分(可用数量) | ||||
err = DealUserCoin(session, md.DealUserCoinReq{ | err = DealUserCoin(session, md.DealUserCoinReq{ | ||||
@@ -96,6 +104,11 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( | |||||
Uid: v.Uid, | Uid: v.Uid, | ||||
Amount: zhios_order_relate_utils.StrToFloat64(values), | Amount: zhios_order_relate_utils.StrToFloat64(values), | ||||
}) | }) | ||||
if err != nil { | |||||
_ = session.Rollback() | |||||
fmt.Println("err:::::33333", err) | |||||
return err | |||||
} | |||||
//4.3给相应的用户减去个人活跃积分 | //4.3给相应的用户减去个人活跃积分 | ||||
err = DealUserCoin(session, md.DealUserCoinReq{ | err = DealUserCoin(session, md.DealUserCoinReq{ | ||||
@@ -115,7 +128,7 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( | |||||
} | } | ||||
//4.4 减少“原始数量”中的绿色能量 | //4.4 减少“原始数量”中的绿色能量 | ||||
err = DealAvailableGreenEnergyCoin(session, int(enum.PersonalActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), zhios_order_relate_utils.StrToFloat64(autoExchangeNumsByPersonAmount), enum.PersonalActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) | |||||
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 { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
fmt.Println("err:::::44444", err) | fmt.Println("err:::::44444", err) | ||||
@@ -130,9 +143,9 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( | |||||
//5.1计算涨价公式 | //5.1计算涨价公式 | ||||
err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByTeamAmount, oneCirclesGreenEnergyBasicSetting) | err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByTeamAmount, oneCirclesGreenEnergyBasicSetting) | ||||
if err1 != nil { | if err1 != nil { | ||||
_ = session.Rollback() | |||||
return err1 | return err1 | ||||
} | } | ||||
oneCirclesGreenEnergyBasicSetting.NowPrice = afterPriceValue //TODO::改变当前价格 | |||||
//5.2给相应的用户加上个人的绿色积分(结算数量) | //5.2给相应的用户加上个人的绿色积分(结算数量) | ||||
err = DealUserCoin(session, md.DealUserCoinReq{ | err = DealUserCoin(session, md.DealUserCoinReq{ | ||||
@@ -145,6 +158,11 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( | |||||
Uid: v.Uid, | Uid: v.Uid, | ||||
Amount: zhios_order_relate_utils.StrToFloat64(values), | Amount: zhios_order_relate_utils.StrToFloat64(values), | ||||
}) | }) | ||||
if err != nil { | |||||
_ = session.Rollback() | |||||
fmt.Println("err:::::33333", err) | |||||
return err | |||||
} | |||||
//5.3给相应的用户减去个人团队积分 | //5.3给相应的用户减去个人团队积分 | ||||
err = DealUserCoin(session, md.DealUserCoinReq{ | err = DealUserCoin(session, md.DealUserCoinReq{ | ||||
@@ -164,7 +182,7 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( | |||||
} | } | ||||
//5.4 减少“原始数量”中的绿色能量 | //5.4 减少“原始数量”中的绿色能量 | ||||
err = DealAvailableGreenEnergyCoin(session, int(enum.TeamActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), zhios_order_relate_utils.StrToFloat64(autoExchangeNumsByTeamAmount), enum.TeamActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) | |||||
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 { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
fmt.Println("err:::::44444", err) | fmt.Println("err:::::44444", err) | ||||
@@ -0,0 +1,94 @@ | |||||
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" | |||||
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" | |||||
"errors" | |||||
"fmt" | |||||
"github.com/shopspring/decimal" | |||||
"time" | |||||
"xorm.io/xorm" | |||||
) | |||||
// AutoAdjustPrice 自动调整价格 | |||||
func AutoAdjustPrice(engine *xorm.Engine, masterId string) (err error) { | |||||
now := time.Now() | |||||
fmt.Println(now.Hour()) | |||||
//1、查找 `one_circles_green_energy_basic_setting` 基础设置 | |||||
oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ | |||||
"key": "is_open", | |||||
"value": 1, | |||||
}) | |||||
if err != nil { | |||||
return | |||||
} | |||||
var priceSettingStruct *md2.PriceSettingStruct | |||||
err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.PriceSetting), &priceSettingStruct) | |||||
if err != nil { | |||||
return | |||||
} | |||||
if priceSettingStruct.PriceHigherThanValue == "" || priceSettingStruct.MarketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue == "" || priceSettingStruct.PriceBelowValue == "" || priceSettingStruct.MarketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue == "" { | |||||
err = errors.New("价格设置未完全!") | |||||
return | |||||
} | |||||
session := engine.NewSession() | |||||
defer func() { | |||||
session.Close() | |||||
if err := recover(); err != nil { | |||||
_ = zhios_order_relate_logx.Error(err) | |||||
} | |||||
}() | |||||
session.Begin() | |||||
priceHigherThanValue, _ := decimal.NewFromString(priceSettingStruct.PriceHigherThanValue) | |||||
marketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue, _ := decimal.NewFromString(priceSettingStruct.MarketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue) | |||||
priceBelowValue, _ := decimal.NewFromString(priceSettingStruct.PriceBelowValue) | |||||
marketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue, _ := decimal.NewFromString(priceSettingStruct.MarketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue) | |||||
nowPriceValue, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) | |||||
if nowPriceValue.GreaterThan(priceHigherThanValue) { | |||||
//当价格涨到设置某个价格时,自动执行 市商数量 兑换 市商资金 (降价公式) | |||||
err1, amount, _, afterPriceValue := NewCalcPriceReductionFormula(marketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue.String(), oneCirclesGreenEnergyBasicSetting) | |||||
if err1 != nil { | |||||
fmt.Println("err1111:::", err1) | |||||
_ = session.Rollback() | |||||
return err1 | |||||
} | |||||
// 市商数量 减少、原始数量 增加、原始资金 减少、市商资金 增加 | |||||
err = DealAvailableGreenEnergyCoin(session, int(enum.MarketplaceMerchantNumsAutoExchangeMarketplaceMerchantFunds), zhios_order_relate_utils.StrToFloat64(marketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue.String()), zhios_order_relate_utils.StrToFloat64(amount), enum.MarketplaceMerchantNumsAutoExchangeMarketplaceMerchantFunds.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue) | |||||
if err != nil { | |||||
fmt.Println("err:::::22222", err) | |||||
_ = session.Rollback() | |||||
return err | |||||
} | |||||
} | |||||
if nowPriceValue.LessThan(priceBelowValue) { | |||||
//当价格降到设置某个价格时,自动执行 市商资金 兑换 市商数量 (涨价公式) | |||||
err1, greenEnergy, _, afterPriceValue := NewCalcPriceIncreaseFormula(marketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue.String(), oneCirclesGreenEnergyBasicSetting) | |||||
if err1 != nil { | |||||
fmt.Println("err33333:::", err1) | |||||
_ = session.Rollback() | |||||
return err1 | |||||
} | |||||
// 市商数量 增加、原始数量 减少、原始资金 增加、市商资金 减少 | |||||
err = DealAvailableGreenEnergyCoin(session, int(enum.MarketplaceMerchantFundsAutoExchangeMarketplaceMerchantNums), zhios_order_relate_utils.StrToFloat64(greenEnergy), zhios_order_relate_utils.StrToFloat64(marketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue.String()), enum.MarketplaceMerchantFundsAutoExchangeMarketplaceMerchantNums.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue) | |||||
if err != nil { | |||||
fmt.Println("err:::::44444", err) | |||||
_ = session.Rollback() | |||||
return err | |||||
} | |||||
} | |||||
err = session.Commit() | |||||
if err != nil { | |||||
_ = session.Rollback() | |||||
return errors.New("事务提交失败") | |||||
} | |||||
return | |||||
} |
@@ -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/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/md" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache" | "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache" | ||||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" | |||||
"errors" | "errors" | ||||
"fmt" | "fmt" | ||||
"github.com/shopspring/decimal" | "github.com/shopspring/decimal" | ||||
@@ -54,6 +55,14 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e | |||||
} | } | ||||
session := engine.NewSession() | session := engine.NewSession() | ||||
defer func() { | |||||
session.Close() | |||||
if err := recover(); err != nil { | |||||
_ = zhios_order_relate_logx.Error(err) | |||||
} | |||||
}() | |||||
session.Begin() | |||||
//4、处理释放 | //4、处理释放 | ||||
settlementQuantityRadio := decimal.NewFromFloat(100) | settlementQuantityRadio := decimal.NewFromFloat(100) | ||||
settlementQuantityValue := decimal.NewFromInt(int64(settlementQuantity)).Div(settlementQuantityRadio) | settlementQuantityValue := decimal.NewFromInt(int64(settlementQuantity)).Div(settlementQuantityRadio) | ||||
@@ -46,7 +46,7 @@ func NewCalcPriceIncreaseFormula(userAmountValue string, oneCirclesGreenEnergyBa | |||||
return | return | ||||
} | } | ||||
// CalcPriceReductionFormula 计算降价公式(【用户需兑换绿能色量数量*{原始资金÷(用户需兑换绿色数量+原始数量}*(1 - 扣比例50% ~ 23%) = 用户获得绿色能量个数) | |||||
// CalcPriceReductionFormula 计算降价公式(【用户需兑换绿能色量数量*{原始资金÷(用户需兑换绿色数量+原始数量}*(1 - 扣比例50% ~ 23%) = 用户获得钱) | |||||
func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string, levelId string) (err error, values, greenEnergy, greenEnergyFee, nowPriceValue, afterPriceValue string) { | func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string, levelId string) (err error, values, greenEnergy, greenEnergyFee, nowPriceValue, afterPriceValue string) { | ||||
//1、查找 `one_circles_green_energy_basic_setting` 基础设置 | //1、查找 `one_circles_green_energy_basic_setting` 基础设置 | ||||
oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ | oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ | ||||
@@ -89,3 +89,19 @@ func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string | |||||
afterPriceValue = afterPrice.String() | afterPriceValue = afterPrice.String() | ||||
return | return | ||||
} | } | ||||
// NewCalcPriceReductionFormula 计算降价公式(【用户需兑换绿能色量数量*{原始资金÷(用户需兑换绿色数量+原始数量}*(1 - 扣比例50% ~ 23%) = 用户获得钱) | |||||
func NewCalcPriceReductionFormula(userExchangeNumsValue string, oneCirclesGreenEnergyBasicSetting *model.OneCirclesGreenEnergyBasicSetting) (err error, greenEnergy, nowPriceValue, afterPriceValue 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)) //降价后的价格 | |||||
greenEnergyValues := userExchangeNums.Mul(afterPrice) //用户获得的钱 | |||||
greenEnergy = greenEnergyValues.Truncate(8).String() | |||||
nowPriceValue = nowPrice.String() | |||||
afterPriceValue = afterPrice.String() | |||||
return | |||||
} |
@@ -303,6 +303,76 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金 | oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金 | ||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds | oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds | ||||
break | break | ||||
case int(enum.MarketplaceMerchantNumsAutoExchangeMarketplaceMerchantFunds): //市商数量自动兑换市商资金 | |||||
beforeOriginalQuantityNums, _ := decimal.NewFromString(chain.OriginalQuantityNums) | |||||
beforeMarketplaceMerchantNums, _ := decimal.NewFromString(chain.MarketplaceMerchantNums) | |||||
beforeOriginalFunds, _ := decimal.NewFromString(chain.OriginalFunds) | |||||
beforeMarketplaceMerchantFunds, _ := decimal.NewFromString(chain.MarketplaceMerchantFunds) | |||||
oneCirclesAvailableGreenEnergyPointsFlow.Direction = 1 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeEcologicalApplicationValues = chain.EcologicalApplication //生态应用 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterEcologicalApplicationValues = chain.EcologicalApplication | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeTechnicalTeamValues = chain.TotalTechnologyTeam //技术团队 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterTechnicalTeamValues = chain.TotalTechnologyTeam | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOperateTeamValues = chain.TotalOperateTeam //运营团队 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterOperateTeamValues = chain.TotalOperateTeam | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeActiveGiveawaysValues = chain.TotalActiveGiveaways //活跃赠送 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterActiveGiveawaysValues = chain.TotalActiveGiveaways | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityValues = chain.OriginalQuantityNums //原始数量 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityValues = beforeOriginalQuantityNums.Add(amountValue).String() | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantValues = chain.MarketplaceMerchantNums //市商数量 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantValues = beforeMarketplaceMerchantNums.Sub(amountValue).String() | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDevelopmentCommitteeValues = chain.DevelopmentCommittee //发展委员会 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues = chain.DevelopmentCommittee | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforePublicWelfareAndCharityValues = chain.PublicWelfareAndCharity //公益慈善 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends //星级分红 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums | |||||
amountFeeValue := decimal.NewFromFloat(amountFee) //金额 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = beforeOriginalFunds.Sub(amountFeeValue).String() | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = beforeMarketplaceMerchantFunds.Add(amountFeeValue).String() | |||||
break | |||||
case int(enum.MarketplaceMerchantFundsAutoExchangeMarketplaceMerchantNums): //市商资金自动兑换市商数量 | |||||
beforeOriginalQuantityNums, _ := decimal.NewFromString(chain.OriginalQuantityNums) | |||||
beforeMarketplaceMerchantNums, _ := decimal.NewFromString(chain.MarketplaceMerchantNums) | |||||
beforeOriginalFunds, _ := decimal.NewFromString(chain.OriginalFunds) | |||||
beforeMarketplaceMerchantFunds, _ := decimal.NewFromString(chain.MarketplaceMerchantFunds) | |||||
oneCirclesAvailableGreenEnergyPointsFlow.Direction = 1 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeEcologicalApplicationValues = chain.EcologicalApplication //生态应用 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterEcologicalApplicationValues = chain.EcologicalApplication | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeTechnicalTeamValues = chain.TotalTechnologyTeam //技术团队 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterTechnicalTeamValues = chain.TotalTechnologyTeam | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOperateTeamValues = chain.TotalOperateTeam //运营团队 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterOperateTeamValues = chain.TotalOperateTeam | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeActiveGiveawaysValues = chain.TotalActiveGiveaways //活跃赠送 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterActiveGiveawaysValues = chain.TotalActiveGiveaways | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityValues = chain.OriginalQuantityNums //原始数量 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityValues = beforeOriginalQuantityNums.Sub(amountValue).String() | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantValues = chain.MarketplaceMerchantNums //市商数量 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantValues = beforeMarketplaceMerchantNums.Add(amountValue).String() | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDevelopmentCommitteeValues = chain.DevelopmentCommittee //发展委员会 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues = chain.DevelopmentCommittee | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforePublicWelfareAndCharityValues = chain.PublicWelfareAndCharity //公益慈善 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues = chain.PublicWelfareAndCharity | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeStarLevelDividendsValues = chain.StarLevelDividends //星级分红 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends //星级分红 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums | |||||
amountFeeValue := decimal.NewFromFloat(amountFee) //金额 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = beforeOriginalFunds.Add(amountFeeValue).String() | |||||
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金 | |||||
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = beforeMarketplaceMerchantFunds.Sub(amountFeeValue).String() | |||||
break | |||||
} | } | ||||
chain.EcologicalApplication = oneCirclesAvailableGreenEnergyPointsFlow.AfterEcologicalApplicationValues //生态应用 | chain.EcologicalApplication = oneCirclesAvailableGreenEnergyPointsFlow.AfterEcologicalApplicationValues //生态应用 | ||||
@@ -6,6 +6,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/md" | ||||
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md" | 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_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" | "encoding/json" | ||||
"errors" | "errors" | ||||
"fmt" | "fmt" | ||||
@@ -124,6 +125,14 @@ func SettlementPublicGiveActivityCoin(engine *xorm.Engine, masterId string, uid | |||||
} | } | ||||
session := engine.NewSession() | session := engine.NewSession() | ||||
defer func() { | |||||
session.Close() | |||||
if err := recover(); err != nil { | |||||
_ = zhios_order_relate_logx.Error(err) | |||||
} | |||||
}() | |||||
session.Begin() | |||||
//给相应的用户加上"个人"活跃积分 | //给相应的用户加上"个人"活跃积分 | ||||
err = DealUserCoin(session, md.DealUserCoinReq{ | err = DealUserCoin(session, md.DealUserCoinReq{ | ||||
Kind: "add", | Kind: "add", | ||||
@@ -7,6 +7,7 @@ import ( | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum" | "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" | 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_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" | "encoding/json" | ||||
"errors" | "errors" | ||||
"fmt" | "fmt" | ||||
@@ -58,6 +59,14 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string) (err erro | |||||
} | } | ||||
session := engine.NewSession() | session := engine.NewSession() | ||||
defer func() { | |||||
session.Close() | |||||
if err := recover(); err != nil { | |||||
_ = zhios_order_relate_logx.Error(err) | |||||
} | |||||
}() | |||||
session.Begin() | |||||
var reduceTotalGreenEnergy float64 | var reduceTotalGreenEnergy float64 | ||||
for _, v := range list { | for _, v := range list { | ||||
//4.2给相应的用户加上个人的绿色积分(可用数量) | //4.2给相应的用户加上个人的绿色积分(可用数量) | ||||
@@ -99,7 +108,7 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string) (err erro | |||||
TransferType: md.OneCirclesGreenEnergySignInSettlementTeamRewardForUserVirtualCoinFlow, | TransferType: md.OneCirclesGreenEnergySignInSettlementTeamRewardForUserVirtualCoinFlow, | ||||
OrdId: "", | OrdId: "", | ||||
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId, | CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId, | ||||
Uid: relate.Uid, | |||||
Uid: relate.ParentUid, | |||||
Amount: parentRewardValue, | Amount: parentRewardValue, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
@@ -8,6 +8,7 @@ import ( | |||||
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md" | 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_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache" | "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache" | ||||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" | |||||
"encoding/json" | "encoding/json" | ||||
"errors" | "errors" | ||||
"fmt" | "fmt" | ||||
@@ -82,6 +83,14 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string) (err err | |||||
} | } | ||||
session := engine.NewSession() | session := engine.NewSession() | ||||
defer func() { | |||||
session.Close() | |||||
if err := recover(); err != nil { | |||||
_ = zhios_order_relate_logx.Error(err) | |||||
} | |||||
}() | |||||
session.Begin() | |||||
//2、查找 `one_circles_star_level_dividends_records` 基础设置 | //2、查找 `one_circles_star_level_dividends_records` 基础设置 | ||||
oneCirclesStarLevelDividendsRecords, err := db.OneCirclesStarLevelDividendsRecordsGetOneByParamsBySession(session, map[string]interface{}{ | oneCirclesStarLevelDividendsRecords, err := db.OneCirclesStarLevelDividendsRecordsGetOneByParamsBySession(session, map[string]interface{}{ | ||||
"key": "date", | "key": "date", | ||||
@@ -147,9 +156,9 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string) (err err | |||||
if int(v["weight"]) > allUserLevelMap[item.Level].LevelWeight { | if int(v["weight"]) > allUserLevelMap[item.Level].LevelWeight { | ||||
continue | continue | ||||
} | } | ||||
if vipEquitySettingMap[zhios_order_relate_utils.IntToStr(item.Level)] != "" && vipLevelUserTotalMap[zhios_order_relate_utils.IntToStr(item.Level)]["count"] > 0 { | |||||
if vipEquitySettingMap[k] != "" && vipLevelUserTotalMap[k]["count"] > 0 { | |||||
dividendValue, _ := decimal.NewFromString(vipEquitySettingMap[k]) | dividendValue, _ := decimal.NewFromString(vipEquitySettingMap[k]) | ||||
userTotal := decimal.NewFromInt(vipLevelUserTotalMap[zhios_order_relate_utils.IntToStr(item.Level)]["count"]) | |||||
userTotal := decimal.NewFromInt(vipLevelUserTotalMap[k]["count"]) | |||||
siginDividendValue = siginDividendValue.Add(dividendValue.Div(userTotal)) | siginDividendValue = siginDividendValue.Add(dividendValue.Div(userTotal)) | ||||
} | } | ||||
} | } | ||||