|
|
@@ -377,21 +377,6 @@ func BasalRate(c *gin.Context) { |
|
|
|
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
energyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db) |
|
|
|
eggEnergyBasicSetting, err := energyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{ |
|
|
|
"key": "is_open", |
|
|
|
"value": 1, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
coinID := eggEnergyBasicSetting.PersonEggEnergyCoinId |
|
|
|
coinDb := implement.NewVirtualCoinDb(db.Db) |
|
|
|
coin, err := coinDb.VirtualCoinGetOneByParams(map[string]interface{}{ |
|
|
|
"key": "id", |
|
|
|
"value": coinID, |
|
|
|
}) |
|
|
|
now := time.Now() |
|
|
|
nowStr := now.Format("2006-01-02 15:04:05") |
|
|
|
signInDb := implement.NewEggSignInDb(db.Db) |
|
|
@@ -415,11 +400,6 @@ func BasalRate(c *gin.Context) { |
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
ratio, err := decimal.NewFromString(coin.ExchangeRatio) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_UNMARSHAL, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
estimatePerSecondEggEnergyValue, err := decimal.NewFromString(eggSignIn.EstimatePerSecondPersonEggEnergyValue) |
|
|
|
if err != nil { |
|
|
@@ -430,16 +410,14 @@ func BasalRate(c *gin.Context) { |
|
|
|
consumedTimeSec := now.Unix() - utils.TimeParseStd(eggSignIn.StartTime).Unix() |
|
|
|
consumedTime := decimal.NewFromInt(consumedTimeSec).Div(decimal.NewFromInt(60 * 60)) |
|
|
|
consumedEggEnergy := decimal.NewFromInt(consumedTimeSec).Mul(estimatePerSecondEggEnergyValue) |
|
|
|
consumedAmount := consumedEggEnergy.Div(ratio) |
|
|
|
|
|
|
|
// 剩余时间、待收益 |
|
|
|
remainingTimeSec := utils.TimeParseStd(eggSignIn.EndTime).Unix() - now.Unix() |
|
|
|
remainingTime := decimal.NewFromInt(remainingTimeSec).Div(decimal.NewFromInt(60 * 60)) |
|
|
|
remainingEggEnergy := decimal.NewFromInt(remainingTimeSec).Mul(estimatePerSecondEggEnergyValue) |
|
|
|
remainingAmount := remainingEggEnergy.Div(ratio) |
|
|
|
|
|
|
|
// 预估收益 |
|
|
|
estimatedRevenue := consumedAmount.Add(remainingAmount) |
|
|
|
estimatedRevenue := consumedEggEnergy.Add(remainingEggEnergy) |
|
|
|
// 基础速率 / 每小时 |
|
|
|
basalRateDecimal, err := decimal.NewFromString(eggSignIn.EstimatePerSecondPersonEggEnergyValue) |
|
|
|
if err != nil { |
|
|
|