|
|
@@ -10,6 +10,7 @@ import ( |
|
|
|
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/svc" |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
@@ -228,38 +229,43 @@ func HandleSettlementSignInGreenEnergy(ch *rabbit.Channel, engine *xorm.Engine, |
|
|
|
|
|
|
|
// 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, |
|
|
|
}) |
|
|
|
rewardValue, _ = cache.GetString("one_circle_reward_value") |
|
|
|
if rewardValue == "" { |
|
|
|
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.SignInReward), &signInRewards) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var signInRewards []*md2.SignInRewardStruct |
|
|
|
err = json.Unmarshal([]byte(oneCirclesGreenEnergyBasicSetting.SignInReward), &signInRewards) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
if len(signInRewards) == 0 { |
|
|
|
err = errors.New("未设置签到奖励!") |
|
|
|
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"]) |
|
|
|
//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) |
|
|
|
rewardValue = v.RewardValue |
|
|
|
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) |
|
|
|
rewardValue = v.RewardValue |
|
|
|
} |
|
|
|
} |
|
|
|
cache.SetEx("one_circle_reward_value", rewardValue, 3600*8) //8小时 |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|