| 
					
				 | 
			
			
				@@ -14,7 +14,7 @@ import com.zanxiang.game.module.manage.utils.RedisUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.module.mybatis.entity.KfRoom; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.module.mybatis.entity.KfRoomMsg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.game.module.mybatis.entity.KfSessionUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.zanxiang.module.redis.service.IDistributedLockComponent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.zanxiang.game.module.mybatis.entity.KfSystemReply; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.module.util.JsonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.logging.log4j.util.Strings; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -27,10 +27,7 @@ import reactor.util.function.Tuple2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @author : lingfeng 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -55,7 +52,10 @@ public class KfMsgWebsocketHandler implements WebSocketHandler { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IKfRoomMsgService kfRoomMsgService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private IDistributedLockComponent distributedLockComponent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IKfSystemReplyService kfSystemReplyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private KfWxApiService kfWxApiService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private KfWxApiService wxApiService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -434,6 +434,47 @@ public class KfMsgWebsocketHandler implements WebSocketHandler { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .gameId(param.getGameId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .waitUserList(waitUserList) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //发送欢迎语 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.sendWelcomeMsg(param.getGameId(), param.getOpenId(), roomId, kfSessionUser.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void sendWelcomeMsg(Long gameId, String openId, Long roomId, Long userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取自动回复配置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        KfSystemReply kfSystemReply = kfSystemReplyService.getById(gameId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (kfSystemReply == null || Strings.isBlank(kfSystemReply.getWorkSysReply())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //休息时间, 发送指定消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> textMap = new HashMap<>(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        textMap.put("content", kfSystemReply.getWorkSysReply()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> msgParamMap = new HashMap<>(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        msgParamMap.put("touser", openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        msgParamMap.put("text", textMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        msgParamMap.put("msgtype", KfRoomMsgTypeEnum.KF_MSG_TYPE_TEXT.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        kfWxApiService.sendCustomMessageApi(gameId, msgParamMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //保存消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> kfRoomMsgMap = new HashMap<>(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        kfRoomMsgMap.put("text", kfSystemReply.getWorkSysReply()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        kfRoomMsgService.save(this.transform(openId, gameId, roomId, userId, JsonUtil.toString(kfRoomMsgMap))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private KfRoomMsg transform(String openId, Long gameId, Long roomId, Long userId, String msgContent) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return KfRoomMsg.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .msgId(UUID.randomUUID().toString().replace("-", "")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .msgType(KfRoomMsgTypeEnum.KF_MSG_TYPE_TEXT.getValue()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .gameId(gameId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .openId(openId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .userId(userId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .readStatus(Boolean.TRUE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .roomId(roomId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .kfUserId(SecurityUtil.getUserId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .msgOwner(KfRoomMsgOwnerEnum.KF_MSG_OWNER_SYSTEM.getValue()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .content(msgContent) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .source(msgContent) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .sortTime(System.currentTimeMillis()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .createTime(LocalDateTime.now()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .updateTime(LocalDateTime.now()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void kfCreateConnect(WebSocketSession session, KfWebSocketMsgEnum msgTypeEnum, Long gameId) { 
			 |