| | |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | Object cacheObject = redisService.getCacheObject("ONLINE_" + userid); |
| | | if(null == cacheObject){ |
| | | redisService.setCacheObject("ONLINE_" + userid, System.currentTimeMillis(), 1L, TimeUnit.HOURS); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("time", System.currentTimeMillis()); |
| | | jsonObject.put("online", 0); |
| | | redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS); |
| | | }else{ |
| | | Long duration = (Long) cacheObject; |
| | | long time = (System.currentTimeMillis() - duration) / 3600000; |
| | | JSONObject jsonObject = (JSONObject) cacheObject; |
| | | long time = System.currentTimeMillis() - jsonObject.getInteger("time"); |
| | | Integer online = jsonObject.getInteger("online"); |
| | | online += 10; |
| | | //满足一个小时,开始发放积分,计时归0 |
| | | if(1 >= time){ |
| | | redisService.setCacheObject("ONLINE_" + userid, System.currentTimeMillis(), 1L, TimeUnit.HOURS); |
| | | if(time >= 3600000L && 60 <= online){ |
| | | jsonObject.put("time", System.currentTimeMillis()); |
| | | jsonObject.put("online", 0); |
| | | redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS); |
| | | AppUser appUser = this.getById(userid); |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | if(null != pointSetting){ |
| | |
| | | //变更等级 |
| | | vipUpgrade(appUser.getId()); |
| | | } |
| | | }else{ |
| | | jsonObject.put("online", online); |
| | | redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS); |
| | | } |
| | | } |
| | | } |