|
|
@@ -39,26 +39,11 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string) (err erro |
|
|
|
var rewardEndValue = zhios_order_relate_utils.StrToFloat64(teamRewardSetting.RewardEndValue) //奖励结束值 |
|
|
|
fmt.Println("rewardDecrement>>>>>>>>>>>>", rewardDecrement) |
|
|
|
fmt.Println("rewardEndValue>>>>>>>>>>>>", rewardEndValue) |
|
|
|
var signInRewards []*md2.SignInRewardStruct |
|
|
|
err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.VipEquitySetting), &signInRewards) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
if len(signInRewards) == 0 { |
|
|
|
err = errors.New("未设置签到奖励!") |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//2、统计全网用户数 |
|
|
|
sqlStr := "SELECT COUNT(*) AS total FROM USER " |
|
|
|
nativeString, _ := db.QueryNativeString(engine, sqlStr) |
|
|
|
userCount := zhios_order_relate_utils.StrToInt64(nativeString[0]["total"]) |
|
|
|
|
|
|
|
var rewardValue string |
|
|
|
for _, v := range signInRewards { |
|
|
|
if zhios_order_relate_utils.StrToInt64(v.VipMemberEndNums) <= userCount && userCount <= zhios_order_relate_utils.StrToInt64(v.VipMemberStartNums) { |
|
|
|
rewardValue = zhios_order_relate_utils.Float64ToStrPrec8(zhios_order_relate_utils.StrToFloat64(v.RewardValue) * float64(oneRoundDuration) * 60 * 60) |
|
|
|
} |
|
|
|
//2、获取当前签到收益 |
|
|
|
err, rewardValue := CalcNowSignInGreenEnergy(engine, oneCirclesGreenEnergyBasicSetting) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
//3、统计签到结束的用户数据 |
|
|
@@ -139,6 +124,42 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string) (err erro |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// CalcNowSignInGreenEnergy 计算当前签到拿多少绿色能量/秒 |
|
|
|
func CalcNowSignInGreenEnergy(engine *xorm.Engine, oneCirclesGreenEnergyBasicSetting *model.OneCirclesGreenEnergyBasicSetting) (err error, rewardValue string) { |
|
|
|
if oneCirclesGreenEnergyBasicSetting == nil { |
|
|
|
//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 signInRewards []*md2.SignInRewardStruct |
|
|
|
err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.VipEquitySetting), &signInRewards) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
if len(signInRewards) == 0 { |
|
|
|
err = errors.New("未设置签到奖励!") |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//2、统计全网用户数 |
|
|
|
sqlStr := "SELECT COUNT(*) AS total FROM USER " |
|
|
|
nativeString, _ := db.QueryNativeString(engine, sqlStr) |
|
|
|
userCount := zhios_order_relate_utils.StrToInt64(nativeString[0]["total"]) |
|
|
|
|
|
|
|
for _, v := range signInRewards { |
|
|
|
if zhios_order_relate_utils.StrToInt64(v.VipMemberEndNums) <= userCount && userCount <= zhios_order_relate_utils.StrToInt64(v.VipMemberStartNums) { |
|
|
|
rewardValue = zhios_order_relate_utils.Float64ToStrPrec8(zhios_order_relate_utils.StrToFloat64(v.RewardValue) * float64(oneRoundDuration) * 60 * 60) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// CalcTodayGreenEnergyPriceRises 计算绿色能量今日价格涨幅 |
|
|
|
func CalcTodayGreenEnergyPriceRises(engine *xorm.Engine, oneCirclesGreenEnergyBasicSetting *model.OneCirclesGreenEnergyBasicSetting) (err error, rises float64, isRises bool) { |
|
|
|
now := time.Now() |
|
|
|