|
@@ -112,12 +112,11 @@ public class ConversationRecordFacade {
|
|
|
* 发送聊天消息
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void sendMsg(ConversationMsgDTO dto) {
|
|
|
+ public R<String> sendMsg(ConversationMsgDTO dto) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
//保存消息
|
|
|
ConversationMsgRecord conversationMsgRecord = ConversationMsgRecord.builder()
|
|
|
.conversationRecordId(dto.getConversationRecordId())
|
|
|
- .senderId(user.getUserId())
|
|
|
.userId(dto.getUserId())
|
|
|
.volunteerId(dto.getVolunteerId())
|
|
|
.msgType(dto.getMsgType())
|
|
@@ -134,30 +133,39 @@ public class ConversationRecordFacade {
|
|
|
Long receiver = null;
|
|
|
if (dto.getSystem() == 1){
|
|
|
//用户发送,设置用户已读
|
|
|
+ conversationMsgRecord.setSenderId(user.getUserId());
|
|
|
conversationMsgRecord.setUserReadFlag("2");
|
|
|
// 目前系统消息不允许发送,如果为订单消息则设置接收人为志愿者,如果是客服消息则设置区域编号和名称
|
|
|
if ("2".equals(dto.getConversationType())){
|
|
|
receiver = dto.getVolunteerId();
|
|
|
- }else {
|
|
|
+ }else if ("3".equals(dto.getConversationType())){
|
|
|
+ receiver = Long.valueOf(user.getDistrictCode());
|
|
|
conversationMsgRecord.setDistrictCode(user.getDistrictCode());
|
|
|
conversationMsgRecord.setDistrictName(user.getDistrictName());
|
|
|
+ }else {
|
|
|
+ return R.fail("不能和系统发送消息");
|
|
|
}
|
|
|
//设置会话
|
|
|
wrapper.set(ConversationRecord::getVolunteerDelFlag, "0");
|
|
|
} else if (dto.getSystem() == 2) {
|
|
|
//志愿者发送,设置志愿者已读
|
|
|
conversationMsgRecord.setVolunteerReadFlag("2");
|
|
|
+ conversationMsgRecord.setSenderId(user.getUserId());
|
|
|
// 目前系统消息不允许发送,如果为订单消息则设置接收人为志愿者,如果是客服消息则设置区域编号和名称
|
|
|
if ("2".equals(dto.getConversationType())){
|
|
|
receiver = dto.getUserId();
|
|
|
- }else {
|
|
|
+ }else if ("3".equals(dto.getConversationType())){
|
|
|
+ receiver = Long.valueOf(user.getDistrictCode());
|
|
|
conversationMsgRecord.setDistrictCode(user.getDistrictCode());
|
|
|
conversationMsgRecord.setDistrictName(user.getDistrictName());
|
|
|
+ }else {
|
|
|
+ return R.fail("不能和系统发送消息");
|
|
|
}
|
|
|
//设置会话
|
|
|
wrapper.set(ConversationRecord::getUserDelFlag, "0");
|
|
|
}else if (dto.getSystem() == 3){
|
|
|
//系统发送,设置系统已读
|
|
|
+ conversationMsgRecord.setSenderId(Long.valueOf(user.getDistrictCode()));
|
|
|
conversationMsgRecord.setCustomerServiceReadFlag("2");
|
|
|
conversationMsgRecord.setUserId(dto.getUserId());
|
|
|
conversationMsgRecord.setVolunteerId(dto.getVolunteerId());
|
|
@@ -177,6 +185,7 @@ public class ConversationRecordFacade {
|
|
|
webSocketService.sendMessage(receiver,JSONUtil.toJsonStr(msgVO,new JSONConfig().setDateFormat("yyyy-MM-dd HH:mm:ss")));
|
|
|
//推送总数
|
|
|
conversationMsgRecordService.getUnreadMsgCountByUserId(dto.getSystem(), user.getUserId());
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -196,11 +205,12 @@ public class ConversationRecordFacade {
|
|
|
wrapper.eq(ConversationMsgRecord::getVolunteerReadFlag, "0");
|
|
|
wrapper.set(ConversationMsgRecord::getVolunteerReadFlag, "2");
|
|
|
} else if (dto.getSystem() == 3) {
|
|
|
- //后台,设置客服已读
|
|
|
- wrapper.eq(ObjectUtil.isNotNull(dto.getUserId()),ConversationMsgRecord::getUserId, dto.getUserId());
|
|
|
- wrapper.set(ObjectUtil.isNotNull(dto.getUserId()),ConversationMsgRecord::getUserReadFlag, "2");
|
|
|
- wrapper.eq(ObjectUtil.isNotNull(dto.getVolunteerId()),ConversationMsgRecord::getVolunteerId, dto.getVolunteerId());
|
|
|
- wrapper.set(ObjectUtil.isNotNull(dto.getVolunteerId()),ConversationMsgRecord::getVolunteerReadFlag, "2");
|
|
|
+ //后台发送,设置客服已读
|
|
|
+// wrapper.eq(ObjectUtil.isNotNull(dto.getUserId()),ConversationMsgRecord::getUserId, dto.getUserId());
|
|
|
+// wrapper.set(ObjectUtil.isNotNull(dto.getUserId()),ConversationMsgRecord::getUserReadFlag, "2");
|
|
|
+// wrapper.eq(ObjectUtil.isNotNull(dto.getVolunteerId()),ConversationMsgRecord::getVolunteerId, dto.getVolunteerId());
|
|
|
+// wrapper.set(ObjectUtil.isNotNull(dto.getVolunteerId()),ConversationMsgRecord::getVolunteerReadFlag, "2");
|
|
|
+ wrapper.set(ConversationMsgRecord::getCustomerServiceReadFlag, "2");
|
|
|
}
|
|
|
conversationMsgRecordService.update(wrapper);
|
|
|
//推送总数
|
|
@@ -233,7 +243,7 @@ public class ConversationRecordFacade {
|
|
|
.eq(SysDept::getAreaType, "3"));
|
|
|
//如果不存在区域中心,则提示
|
|
|
if (ObjectUtil.isNull(dept)){
|
|
|
- return R.fail("当前所在地区还未开展服务,如需加盟请联系XXXX");
|
|
|
+ return R.fail("当前所在地区还未开展服务,如需加盟请联系王先生 13372727333");
|
|
|
}
|
|
|
ConversationRecordVO vo = new ConversationRecordVO();
|
|
|
LambdaQueryWrapper<ConversationRecord> wrapper = new LambdaQueryWrapper<ConversationRecord>().eq(ConversationRecord::getConversationType, "3");
|
|
@@ -251,6 +261,7 @@ public class ConversationRecordFacade {
|
|
|
.msgType("1")
|
|
|
.msgContent("您好,请问需要什么帮助")
|
|
|
.msgSendTime(LocalDateTime.now())
|
|
|
+ .senderId(Long.valueOf(districtCode))
|
|
|
.userReadFlag("2")
|
|
|
.districtName(dept.getDistrictName())
|
|
|
.districtCode(dept.getDistrictCode())
|
|
@@ -270,7 +281,7 @@ public class ConversationRecordFacade {
|
|
|
conversationRecord.setUserName(SecurityUtils.getUsername());
|
|
|
conversationRecord.setUserOrVolunteer("1");
|
|
|
conversationMsgRecord.setUserId(SecurityUtils.getUserId());
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
//设置会话信息
|
|
|
conversationRecord.setVolunteerId(SecurityUtils.getUserId());
|
|
|
conversationRecord.setVolunteerName(SecurityUtils.getUsername());
|