diff --git a/app/hdl/hdl_add_friend.go b/app/hdl/hdl_add_friend.go index 105ccae..9df0661 100644 --- a/app/hdl/hdl_add_friend.go +++ b/app/hdl/hdl_add_friend.go @@ -106,7 +106,7 @@ func EggEnergyDetails(c *gin.Context) { list = append(list, tmp) } - //3、获取当前用户 蛋蛋能量(可用+结算)、 预估总价值 + //3、获取当前用户 蛋蛋能量(可用+结算+预估)、 预估总价值 virtualAmountDb := implement.NewUserVirtualAmountDb(db.Db) personEggEnergy, err := virtualAmountDb.GetUserVirtualWalletBySession(user.Id, eggEnergyBasicSetting.PersonEggEnergyCoinId) if err != nil { @@ -124,7 +124,40 @@ func EggEnergyDetails(c *gin.Context) { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } - totalEggEnergy := utils.StrToFloat64(personEggEnergy.Amount) + utils.StrToFloat64(teamEggEnergy.Amount) + + now := time.Now() + signInDb := implement.NewEggSignInDb(db.Db) + nowStr := now.Format("2006-01-02 15:04:05") + has, signIn, err := signInDb.EggSignINGetOneByTimeAndUid("", nowStr, user.Id, 0) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + var estimatePersonEggEnergyValue decimal.Decimal + var estimateTeamEggEnergyValue decimal.Decimal + if has && utils.TimeParseStd(signIn.EndTime).After(now) { + //获取预估每秒获得蛋蛋能量数 + estimatePerSecondPersonEggEnergyValue, err1 := decimal.NewFromString(signIn.EstimatePerSecondPersonEggEnergyValue) + if err1 != nil { + e.OutErr(c, e.ERR, err1.Error()) + return + } + estimatePerSecondTeamEggEnergyValue, err1 := decimal.NewFromString(signIn.EstimatePerSecondTeamEggEnergyValue) + if err1 != nil { + e.OutErr(c, e.ERR, err1.Error()) + return + } + + //3.2.2 计算预估获得的蛋蛋能量数 + estimateTimeSec := now.Unix() - utils.TimeParseStd(signIn.StartTime).Unix() + estimatePersonEggEnergyValue = decimal.NewFromInt(estimateTimeSec).Mul(estimatePerSecondPersonEggEnergyValue) + estimateTeamEggEnergyValue = decimal.NewFromInt(estimateTimeSec).Mul(estimatePerSecondTeamEggEnergyValue) + } + personEggEnergyValue, _ := decimal.NewFromString(personEggEnergy.Amount) + teamEggEnergyValue, _ := decimal.NewFromString(teamEggEnergy.Amount) + + totalEggEnergy, _ := personEggEnergyValue.Add(teamEggEnergyValue).Add(estimatePersonEggEnergyValue).Add(estimateTeamEggEnergyValue).Float64() totalEggEnergyPrice := totalEggEnergy * utils.StrToFloat64(coreData.NowPrice) transferTypeList := md.TransferTypeList{