|
@@ -1,20 +1,24 @@
|
|
|
package com.game.business.task;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.game.business.domain.*;
|
|
|
import com.game.business.service.*;
|
|
|
+import com.game.business.util.im.HttpClientUtils;
|
|
|
+import com.game.business.vo.OffLineUserVo;
|
|
|
import com.game.common.constant.CacheConstants;
|
|
|
import com.game.common.constant.finance.FinTranType1;
|
|
|
import com.game.common.constant.finance.FinTranType2;
|
|
|
import com.game.common.constant.finance.FinTranType3;
|
|
|
import com.game.common.core.domain.HttpRet;
|
|
|
+import com.game.common.core.domain.R;
|
|
|
import com.game.common.core.redis.RedisCache;
|
|
|
import com.game.common.entity.KeyValue;
|
|
|
import com.game.common.utils.DateUtils;
|
|
|
import com.game.common.utils.StringUtils;
|
|
|
+import com.game.system.service.ISysConfigService;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -63,6 +67,9 @@ public class AppUserCountTask {
|
|
|
@Autowired
|
|
|
private IAppUserCountDividendService appUserCountDividendService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
@@ -694,4 +701,30 @@ public class AppUserCountTask {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void dealOffLive(){
|
|
|
+ List<OffLineUserVo> list = appUserService.selectOffLineUser();
|
|
|
+ if(null != list && list.size() > 0){
|
|
|
+ Date now = DateUtil.date();
|
|
|
+ list.forEach(e->{
|
|
|
+ if(now.getTime() - e.getOffTime().getTime() >= 1*60*1000){
|
|
|
+ log.info("{}离线已超过1分钟,自动关播",e.getUserId());
|
|
|
+ //离线超过一分钟 自动关播
|
|
|
+ String url = sysConfigService.selectConfigByKey("sys_live_apiurl").concat("/api/live/httpOpenCloseLive");
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("roomId", String.valueOf(e.getRoomId()));
|
|
|
+ map.put("liveType", "1");
|
|
|
+ map.put("isLive", String.valueOf(e.getIsLive()));
|
|
|
+ map.put("description", "关播");
|
|
|
+
|
|
|
+ String res = HttpClientUtils.ajaxPost(url,map);
|
|
|
+ if(org.apache.commons.lang3.StringUtils.isBlank(res) || !JSONObject.parseObject(res).getString("code").equals("1")){
|
|
|
+ log.info("{}自动关播失败===============》》".concat(res),e.getUserId());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ log.info("{}离线未超过1分钟,停止自动关播",e.getUserId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|