ソースを参照

update

master
DengBiao 9ヶ月前
コミット
4a6aaed0bb
1個のファイルの変更40行の追加19行の削除
  1. +40
    -19
      rule/one_circles/one_circles_sign_in_green_energy_settlement.go

+ 40
- 19
rule/one_circles/one_circles_sign_in_green_energy_settlement.go ファイルの表示

@@ -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()


読み込み中…
キャンセル
保存