@@ -11,6 +11,8 @@ const ( | |||||
EggPointCoinToExchangeToTeamEggEnergy | EggPointCoinToExchangeToTeamEggEnergy | ||||
PersonEggGetByEnergyEggPointCoin | PersonEggGetByEnergyEggPointCoin | ||||
TeamEggGetByEnergyEggPointCoin | TeamEggGetByEnergyEggPointCoin | ||||
TeamEggEnergyReleaseToPersonEggEnergy | |||||
PersonEggGetByTeamEggEnergyRelease | |||||
) | ) | ||||
func (kind UserVirtualAmountFlowTransferType) String() string { | func (kind UserVirtualAmountFlowTransferType) String() string { | ||||
@@ -26,9 +28,13 @@ func (kind UserVirtualAmountFlowTransferType) String() string { | |||||
case EggPointCoinToExchangeToTeamEggEnergy: | case EggPointCoinToExchangeToTeamEggEnergy: | ||||
return "团队蛋蛋积分兑换" | return "团队蛋蛋积分兑换" | ||||
case PersonEggGetByEnergyEggPointCoin: | case PersonEggGetByEnergyEggPointCoin: | ||||
return "个人蛋蛋积分兑换蛋蛋能量" | |||||
return "兑换到个人蛋蛋能量" | |||||
case TeamEggGetByEnergyEggPointCoin: | case TeamEggGetByEnergyEggPointCoin: | ||||
return "团队蛋蛋积分兑换蛋蛋能量" | |||||
return "兑换到团队蛋蛋能量" | |||||
case TeamEggEnergyReleaseToPersonEggEnergy: | |||||
return "团队蛋蛋能量释放" | |||||
case PersonEggGetByTeamEggEnergyRelease: | |||||
return "释放到个人蛋蛋能量" | |||||
default: | default: | ||||
return "未知状态" | return "未知状态" | ||||
} | } | ||||
@@ -3,7 +3,7 @@ module code.fnuoos.com/EggPlanet/egg_system_rules.git | |||||
go 1.19 | go 1.19 | ||||
// go.mod文件中 | // go.mod文件中 | ||||
replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models | |||||
//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models | |||||
require ( | require ( | ||||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | ||||
@@ -11,4 +11,4 @@ require ( | |||||
xorm.io/xorm v1.3.1 | xorm.io/xorm v1.3.1 | ||||
) | ) | ||||
require code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112032738-ca9b07ba7b24 // indirect | |||||
require code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112135742-0200baa0a923 // indirect |
@@ -2,6 +2,9 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT | |||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= | ||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112032738-ca9b07ba7b24 h1:zH+UExmxPnD0vUTy2aGXG/sGH+g/oLtMXbO/c8iRDz4= | code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112032738-ca9b07ba7b24 h1:zH+UExmxPnD0vUTy2aGXG/sGH+g/oLtMXbO/c8iRDz4= | ||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112032738-ca9b07ba7b24/go.mod h1:Ktgi+Hk87UlF7/7wg1BvQnAbXWxGa3y+OqDXSD0AA4Q= | code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112032738-ca9b07ba7b24/go.mod h1:Ktgi+Hk87UlF7/7wg1BvQnAbXWxGa3y+OqDXSD0AA4Q= | ||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112090248-0a49428505eb/go.mod h1:Ktgi+Hk87UlF7/7wg1BvQnAbXWxGa3y+OqDXSD0AA4Q= | |||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112135742-0200baa0a923 h1:07C/4B2J6M5gjclRoSqqkO7UPEXn1V41sADCH1OThfc= | |||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112135742-0200baa0a923/go.mod h1:Ktgi+Hk87UlF7/7wg1BvQnAbXWxGa3y+OqDXSD0AA4Q= | |||||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5/go.mod h1:TTcCnFn/LhBGapnutpezlW+GXkLRNPMWkziOoCsXQqY= | code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5/go.mod h1:TTcCnFn/LhBGapnutpezlW+GXkLRNPMWkziOoCsXQqY= | ||||
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241017011352-f7f92494c0f4/go.mod h1:nT2x13YFgrS3tS1fDyUR6q/GNIK+hPw7bdzZXz99SM0= | code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241017011352-f7f92494c0f4/go.mod h1:nT2x13YFgrS3tS1fDyUR6q/GNIK+hPw7bdzZXz99SM0= | ||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= | filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= | ||||
@@ -1,9 +1,11 @@ | |||||
package egg_energy | package egg_energy | ||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/db" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/db/model" | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/md" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | ||||
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx" | zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx" | ||||
"errors" | "errors" | ||||
@@ -13,10 +15,10 @@ import ( | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
const LockKey = "auto_release_exchange_green_energy_lock_key" | |||||
const LockKey = "auto_release_exchange_team_egg_energy_lock_key" | |||||
// AutoReleaseExchangeGreenEnergy 结算绿色能量自动释放成可用绿色能量 | |||||
func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err error) { | |||||
// AutoReleaseExchangeTeamEggEnergy 团队蛋蛋能量自动释放成可用绿色能量 | |||||
func AutoReleaseExchangeTeamEggEnergy(engine *xorm.Engine, masterId string) (err error) { | |||||
now := time.Now() | now := time.Now() | ||||
fmt.Println(now.Hour()) | fmt.Println(now.Hour()) | ||||
if !(now.Hour() > 1 && now.Hour() < 8) { | if !(now.Hour() > 1 && now.Hour() < 8) { | ||||
@@ -34,21 +36,26 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e | |||||
} | } | ||||
cache.SetEx(LockKey, "running", 3600*8) //8小时 | cache.SetEx(LockKey, "running", 3600*8) //8小时 | ||||
//1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 | |||||
oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ | |||||
//1、查找`egg_energy_basic_setting` 基础设置 | |||||
eggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(engine) | |||||
eggEnergyBasicSetting, err := eggEnergyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{ | |||||
"key": "is_open", | "key": "is_open", | ||||
"value": 1, | "value": 1, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
return | return | ||||
} | } | ||||
if eggEnergyBasicSetting.SettlementQuantity == 0 { | |||||
err = errors.New("结算百分比未设置!") | |||||
return | |||||
} | |||||
settlementQuantity := oneCirclesGreenEnergyBasicSetting.SettlementQuantity | |||||
settlementQuantity := eggEnergyBasicSetting.SettlementQuantity | |||||
fmt.Println("settlementQuantity>>>>>>>>>>>>", settlementQuantity) | fmt.Println("settlementQuantity>>>>>>>>>>>>", settlementQuantity) | ||||
//2、当前 "可用"绿色能量可以兑换的用户数据 | //2、当前 "可用"绿色能量可以兑换的用户数据 | ||||
var list1 []model.UserVirtualAmount | var list1 []model.UserVirtualAmount | ||||
err = engine.Where("coin_id = ?", oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId).And("amount > ?", 0).Find(&list1) | |||||
err = engine.Where("coin_id = ?", eggEnergyBasicSetting.TeamEggEnergyCoinId).And("amount > ?", 0).Find(&list1) | |||||
if err != nil { | if err != nil { | ||||
fmt.Println("err:::::1111", err) | fmt.Println("err:::::1111", err) | ||||
return | return | ||||
@@ -70,40 +77,35 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e | |||||
}() | }() | ||||
session.Begin() | session.Begin() | ||||
//4.2给相应的用户加上个人的绿色积分(可用数量) | |||||
err = DealUserCoin(session, md.DealUserCoinReq{ | |||||
Kind: "add", | |||||
Mid: masterId, | |||||
Title: md.OneCirclesSettlementGreenEnergyExchangeGreenEnergy, | |||||
TransferType: md.OneCirclesSettlementGreenEnergyExchangeGreenEnergyForUserVirtualCoinFlow, | |||||
OrdId: "", | |||||
CoinId: oneCirclesGreenEnergyBasicSetting.PersonGreenEnergyCoinId, | |||||
//4.2给相应的用户减少团队蛋蛋能量 | |||||
err = rule.DealUserVirtualCoin(session, md.DealUserVirtualCoinReq{ | |||||
Kind: "sub", | |||||
Title: enum.TeamEggEnergyReleaseToPersonEggEnergy.String(), | |||||
TransferType: int(enum.TeamEggEnergyReleaseToPersonEggEnergy), | |||||
CoinId: eggEnergyBasicSetting.TeamEggEnergyCoinId, | |||||
Uid: v.Uid, | Uid: v.Uid, | ||||
Amount: settlementQuantityAmount, | Amount: settlementQuantityAmount, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
fmt.Println("err:::::22222", err) | |||||
fmt.Println("err:::::33333", err) | |||||
continue | continue | ||||
} | } | ||||
//4.2给相应的用户减少个人的绿色积分(结算数量) | |||||
err = DealUserCoin(session, md.DealUserCoinReq{ | |||||
Kind: "sub", | |||||
Mid: masterId, | |||||
Title: md.OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergy, | |||||
TransferType: md.OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergyForUserVirtualCoinFlow, | |||||
OrdId: "", | |||||
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId, | |||||
//4.3给相应的用户增加个人的蛋蛋能量 | |||||
err = rule.DealUserVirtualCoin(session, md.DealUserVirtualCoinReq{ | |||||
Kind: "add", | |||||
Title: enum.PersonEggGetByTeamEggEnergyRelease.String(), | |||||
TransferType: int(enum.PersonEggGetByTeamEggEnergyRelease), | |||||
CoinId: eggEnergyBasicSetting.PersonEggEnergyCoinId, | |||||
Uid: v.Uid, | Uid: v.Uid, | ||||
Amount: settlementQuantityAmount, | Amount: settlementQuantityAmount, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
fmt.Println("err:::::33333", err) | |||||
fmt.Println("err:::::22222", err) | |||||
continue | continue | ||||
} | } | ||||
err = session.Commit() | err = session.Commit() | ||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
@@ -0,0 +1,23 @@ | |||||
package enum | |||||
// EggEnergyFundDataKind 蛋蛋能量-资金数据-种类 | |||||
type EggEnergyFundDataKind int | |||||
const ( | |||||
CompanySubsidies EggEnergyFundDataKind = iota + 1 | |||||
InvestmentByInvestors | |||||
MarketExpectations | |||||
) | |||||
func (kind EggEnergyFundDataKind) String() string { | |||||
switch kind { | |||||
case CompanySubsidies: | |||||
return "公司补贴" | |||||
case InvestmentByInvestors: | |||||
return "资方投资" | |||||
case MarketExpectations: | |||||
return "市场期望" | |||||
default: | |||||
return "未知状态" | |||||
} | |||||
} |
@@ -1,11 +1,8 @@ | |||||
package egg_energy | package egg_energy | ||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/db" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/db/model" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/md" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/one_circles/enum" | |||||
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/one_circles/md" | |||||
db "code.fnuoos.com/EggPlanet/egg_models.git/src" | |||||
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" | |||||
egg_system_rules "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" | egg_system_rules "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | ||||
@@ -5,6 +5,7 @@ import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/enum" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/enum" | ||||
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" | md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/svc" | |||||
egg_system_rules "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" | egg_system_rules "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | ||||
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx" | zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx" | ||||
@@ -288,8 +289,24 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string, ch *rabb | |||||
} | } | ||||
//6、 减少“星级分红”中的绿色能量 | //6、 减少“星级分红”中的绿色能量 | ||||
totalDividend, _ := totalDividendValue.Float64() | |||||
err = DealAvailableGreenEnergyCoin(session, int(enum.SettlementStarLevelDividends), totalDividend, 0, enum.SettlementStarLevelDividends.String(), nil, "", masterId) | |||||
totalDividend := totalDividendValue.String() | |||||
eggEnergyCoreData, cb, err := svc.GetEggEnergyCoreData(engine) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
if cb != nil { | |||||
defer cb() // 释放锁 | |||||
} | |||||
err = DealAvailableEggEnergyCoin(session, int(enum.SettlementStarLevelDividends), eggEnergyCoreData, md2.DealAvailableEggEnergyCoinReq{ | |||||
Amount: totalDividend, | |||||
AmountFee: "", | |||||
BeforePrice: eggEnergyCoreData.NowPrice, | |||||
AfterPrice: eggEnergyCoreData.NowPrice, | |||||
BeforePlanetTotalValue: eggEnergyCoreData.PlanetTotalValue, | |||||
AfterPlanetTotalValue: eggEnergyCoreData.PlanetTotalValue, | |||||
BeforeEnergyTotalNums: eggEnergyCoreData.NowEnergyTotalNums, | |||||
AfterEnergyTotalNums: eggEnergyCoreData.NowEnergyTotalNums, | |||||
}) | |||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
fmt.Println("err:::::9999999", err) | fmt.Println("err:::::9999999", err) | ||||
@@ -4,6 +4,7 @@ import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/md" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" | ||||
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" | |||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/cache" | ||||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx" | "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx" | ||||
@@ -17,7 +18,7 @@ import ( | |||||
) | ) | ||||
// AddPublicPlatoonUserRelationCommission 新增公排用户关系记录 | // AddPublicPlatoonUserRelationCommission 新增公排用户关系记录 | ||||
func AddPublicPlatoonUserRelationCommission(engine *xorm.Engine, AddPublicPlatoonUserRelationCommissionReqList []*md.AddPublicPlatoonUserRelationCommissionReq) (map[string]*model.PublicPlatoonUserRelation, error) { | |||||
func AddPublicPlatoonUserRelationCommission(engine *xorm.Engine, AddPublicPlatoonUserRelationCommissionReqList []*md2.AddPublicPlatoonUserRelationCommissionReq) (map[string]*model.PublicPlatoonUserRelation, error) { | |||||
var resp = map[string]*model.PublicPlatoonUserRelation{} | var resp = map[string]*model.PublicPlatoonUserRelation{} | ||||
//查找 `public_platoon_basic_setting` 基础设置 | //查找 `public_platoon_basic_setting` 基础设置 | ||||
publicPlatoonBasicSettingDb := implement.NewPublicPlatoonBasicSettingDb(engine) | publicPlatoonBasicSettingDb := implement.NewPublicPlatoonBasicSettingDb(engine) | ||||
@@ -280,13 +281,13 @@ func PublicPlatoon(engine *xorm.Engine, uid, recommendUid int64, PublicPlatoonBa | |||||
var fatherUidStr string | var fatherUidStr string | ||||
if m1.FatherUid == "" { | if m1.FatherUid == "" { | ||||
//TODO::顶级 | //TODO::顶级 | ||||
fatherUidStr = egg_system_rules.IntToStr(m1.Id) | |||||
fatherUidStr = egg_system_rules.Int64ToStr(m1.Id) | |||||
} else { | } else { | ||||
fatherUids := strings.Split(m1.FatherUid, "-") | fatherUids := strings.Split(m1.FatherUid, "-") | ||||
if len(fatherUids) >= PublicPlatoonBasicSetting.SeveralRows { | if len(fatherUids) >= PublicPlatoonBasicSetting.SeveralRows { | ||||
fatherUidStr = egg_system_rules.IntToStr(m1.Id) + "-" + strings.Join(fatherUids[0:PublicPlatoonBasicSetting.SeveralRows:len(fatherUids)], "-") | |||||
fatherUidStr = egg_system_rules.Int64ToStr(m1.Id) + "-" + strings.Join(fatherUids[0:PublicPlatoonBasicSetting.SeveralRows:len(fatherUids)], "-") | |||||
} else { | } else { | ||||
fatherUidStr = egg_system_rules.IntToStr(m1.Id) + "-" + m1.FatherUid | |||||
fatherUidStr = egg_system_rules.Int64ToStr(m1.Id) + "-" + m1.FatherUid | |||||
} | } | ||||
} | } | ||||