From 3886b897dec3f2ce4406fbe9d1644a5913557f45 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Wed, 25 Dec 2024 17:50:39 +0800 Subject: [PATCH] fix: add TotalEggEnergyValue --- app/hdl/hdl_home_page.go | 32 +++++++++++++++++++++++--------- app/md/md_home_page.go | 19 ++++++++++--------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/app/hdl/hdl_home_page.go b/app/hdl/hdl_home_page.go index 0e92909..f95a6ab 100644 --- a/app/hdl/hdl_home_page.go +++ b/app/hdl/hdl_home_page.go @@ -144,6 +144,19 @@ func HomePage(c *gin.Context) { // 6、预估能量 + 原有能量 totalEggEnergyDecimal := decimal.NewFromFloat(totalEggEnergy).Add(estimatePersonEggEnergyValue).Add(estimateTeamEggEnergyValue) + // 7、总能量预估价值 + coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db) + coreData, err := coreDataDb.EggEnergyCoreDataGet() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + nowPriceDecimal, err := decimal.NewFromString(coreData.NowPrice) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + totalEggEnergyValueDecimal := totalEggEnergyDecimal.Mul(nowPriceDecimal) utils.FilePutContents("HomePage", utils.SerializeStr(map[string]interface{}{ "user_phone": user.Phone, @@ -167,15 +180,16 @@ func HomePage(c *gin.Context) { })) resp := md.HomePageResp{ - LeaveTimer: utils.Int64ToStr(residueTimes), - IsSign: isSign, - SignEndTime: signCountdown, - TotalEggEnergy: totalEggEnergyDecimal.String(), - TotalActivePoints: utils.Float64ToStr(totalActivePoints), - InitialPrice: initialPrice, - NowBasalRate: utils.Float64ToStr(nowBasalRate), - NowTeamRate: utils.Float64ToStr(NowTeamRate), - NickName: user.Nickname, + LeaveTimer: utils.Int64ToStr(residueTimes), + IsSign: isSign, + SignEndTime: signCountdown, + TotalEggEnergy: totalEggEnergyDecimal.String(), + TotalEggEnergyValue: totalEggEnergyValueDecimal.String(), + TotalActivePoints: utils.Float64ToStr(totalActivePoints), + InitialPrice: initialPrice, + NowBasalRate: utils.Float64ToStr(nowBasalRate), + NowTeamRate: utils.Float64ToStr(NowTeamRate), + NickName: user.Nickname, } e.OutSuc(c, resp, nil) diff --git a/app/md/md_home_page.go b/app/md/md_home_page.go index 86eb24d..4f4ec92 100644 --- a/app/md/md_home_page.go +++ b/app/md/md_home_page.go @@ -1,15 +1,16 @@ package md type HomePageResp struct { - IsSign bool `json:"is_sign"` // 是否开始签到 - SignEndTime string `json:"sign_end_time"` // 签到截止时间 - TotalEggEnergy string `json:"total_egg_energy"` // 总蛋蛋能量 - TotalActivePoints string `json:"total_active_points"` // 总蛋蛋积分 - InitialPrice string `json:"initial_price"` // 蛋蛋能量初始价格 - NowBasalRate string `json:"now_basal_rate"` // 当前基础速率/小时 - NowTeamRate string `json:"now_team_rate"` // 当前团队速率/小时 - NickName string `json:"nick_name"` // 用户名称 - LeaveTimer string `json:"leave_timer"` // 可签到剩余时间 秒 + IsSign bool `json:"is_sign"` // 是否开始签到 + SignEndTime string `json:"sign_end_time"` // 签到截止时间 + TotalEggEnergy string `json:"total_egg_energy"` // 总蛋蛋能量 (个人+团队+预估) + TotalEggEnergyValue string `json:"total_egg_energy_value"` // 总蛋蛋能量价值 + TotalActivePoints string `json:"total_active_points"` // 总蛋蛋积分 + InitialPrice string `json:"initial_price"` // 蛋蛋能量初始价格 + NowBasalRate string `json:"now_basal_rate"` // 当前基础速率/小时 + NowTeamRate string `json:"now_team_rate"` // 当前团队速率/小时 + NickName string `json:"nick_name"` // 用户名称 + LeaveTimer string `json:"leave_timer"` // 可签到剩余时间 秒 } type HomePageWatchAdRuleResp struct {