Commit 2b4abe25 by zhangjw

Revert "1:修改mq配置 2:完善客服模块订单处理逻辑 (待完善)"

This reverts commit 3eed56ed
parent be4059d0
...@@ -29,8 +29,6 @@ public class MsgBody<T> implements Serializable { ...@@ -29,8 +29,6 @@ public class MsgBody<T> implements Serializable {
public static final int ORDER = 5; public static final int ORDER = 5;
public static final int DISTRIBUTION_STAFF = 6; public static final int DISTRIBUTION_STAFF = 6;
public static final int BINDINGFAILURE = 7; public static final int BINDINGFAILURE = 7;
public static final int MERCHANTS_OFFLINE = 8;
@NotNull(message = "{error.msg_body_status_empty}", groups = MsgBodyGroup.class) @NotNull(message = "{error.msg_body_status_empty}", groups = MsgBodyGroup.class)
@ApiModelProperty(value = " * 操作类型说明\n" + @ApiModelProperty(value = " * 操作类型说明\n" +
...@@ -43,9 +41,7 @@ public class MsgBody<T> implements Serializable { ...@@ -43,9 +41,7 @@ public class MsgBody<T> implements Serializable {
" * 4、用户上线\n" + " * 4、用户上线\n" +
" * 5、订单" + " * 5、订单" +
" * 6、分配客服" + " * 6、分配客服" +
" * 7、绑定失败" + " * 7、绑定失败"
" * 8、当前客服不在线,请稍后等待"
) )
private Integer code; private Integer code;
......
package com.ym.im.mq; package com.ym.im.mq;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.ym.im.entity.*; import com.ym.im.entity.*;
import com.ym.im.entity.base.NettyConstant; import com.ym.im.entity.base.NettyConstant;
import com.ym.im.entity.model.IdModel; import com.ym.im.entity.model.IdModel;
import com.ym.im.handler.ChannelGroupHandler; import com.ym.im.handler.ChannelGroupHandler;
import com.ym.im.service.ChatRecordService;
import com.ym.im.service.ChatService; import com.ym.im.service.ChatService;
import com.ym.im.service.SessionListService;
import com.ym.im.service.StaffService; import com.ym.im.service.StaffService;
import com.ym.im.util.JsonUtils; import com.ym.im.util.JsonUtils;
import lombok.SneakyThrows; import lombok.SneakyThrows;
...@@ -21,8 +18,6 @@ import javax.annotation.Resource; ...@@ -21,8 +18,6 @@ import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
import static com.ym.im.entity.ChatRecord.RECEIVE;
/** /**
* @author: JJww * @author: JJww
* @Date:2019-05-30 * @Date:2019-05-30
...@@ -43,18 +38,6 @@ public class Receiver { ...@@ -43,18 +38,6 @@ public class Receiver {
@Autowired @Autowired
private ChatService staffSingleChatServiceImpl; private ChatService staffSingleChatServiceImpl;
@Autowired
private SessionListService sessiontListService;
@Autowired
private ChatRecordService chatRecordService;
/**
* 卓美亚商户ID 默认商户
*/
private static final Long JUMEIRAH_ID = 1L;
@RabbitListener(queues = "#{staffOfflineQueue.name}") @RabbitListener(queues = "#{staffOfflineQueue.name}")
public void offlineHandler(StaffSocketInfo staffSocketInfo) { public void offlineHandler(StaffSocketInfo staffSocketInfo) {
...@@ -96,37 +79,14 @@ public class Receiver { ...@@ -96,37 +79,14 @@ public class Receiver {
return; return;
} }
final StaffSocketInfo staffSocketInfo = channelGroup.getMerchantStaff(userSocketInfo.getStaffId(stroke.getMcId())) == null ? staffService.getIdleStaff(mcId, userId) : channelGroup.getMerchantStaff(userSocketInfo.getStaffId(stroke.getMcId())); final StaffSocketInfo staffSocketInfo = channelGroup.getMerchantStaff(userSocketInfo.getStaffId(stroke.getMcId())) == null ? staffService.getIdleStaff(mcId, userId) : channelGroup.getMerchantStaff(userSocketInfo.getStaffId(stroke.getMcId()));
final MsgBody<ChatRecord> orderInfo = new MsgBody<ChatRecord>().setCode(MsgBody.ORDER).setData(new ChatRecord().setMsgInfo(json).setUserId(userId).setSendTime(new Date()).setMsgType(MsgBody.ORDER)); final ChatRecord chatRecord = new ChatRecord().setMsgInfo(json).setUserId(userId).setSendTime(new Date()).setMsgType(MsgBody.ORDER);
if (staffSocketInfo == null) {//没有商户在线 逻辑待优化....完善 final MsgBody<ChatRecord> orderInfo = new MsgBody<ChatRecord>().setCode(MsgBody.ORDER).setData(chatRecord);
log.info("当前客服不在线,请稍后等待!");
final ChatRecord chatRecord = orderInfo.getData();
chatRecord.setId(IdWorker.getId())
.setMerchantId(JUMEIRAH_ID)
.setSendReceive(RECEIVE)
.setCreateTime(new Date());
chatRecordService.insertSelective(chatRecord);
this.updateMerchantList(orderInfo);
userSocketInfo.writeAndFlush(new MsgBody<>().setCode(MsgBody.MERCHANTS_OFFLINE));
return;
}
orderInfo.getData().setMerchantId(staffSocketInfo.getMerchantId());
staffSingleChatServiceImpl.save(staffSocketInfo.getStaffId(), orderInfo); staffSingleChatServiceImpl.save(staffSocketInfo.getStaffId(), orderInfo);
this.updateMerchantList(orderInfo); if (staffSocketInfo != null) {
staffSocketInfo.writeAndFlush(orderInfo); staffSocketInfo.writeAndFlush(orderInfo);
log.info("客服订单: " + "给客服(" + staffSocketInfo.getStaffId() + ")发送订单:" + json); log.info("客服订单: " + "给客服(" + staffSocketInfo.getStaffId() + ")发送订单:" + json);
}
private void updateMerchantList(MsgBody<ChatRecord> msgBody) {
final Date now = new Date();
final ChatRecord chatRecord = msgBody.getData();
final Long userId = chatRecord.getUserId();
final Long merchantId = chatRecord.getMerchantId();
final Set<Long> merchantList = channelGroup.USER_GROUP.get(userId).getSessionList();
if (!merchantList.contains(merchantId)) {
sessiontListService.save(new Session().setId(IdWorker.getId()).setUserId(userId).setMerchantId(merchantId).setCreateTime(now).setModifyTime(now));
merchantList.add(merchantId);
} }
} }
} }
\ No newline at end of file
...@@ -28,8 +28,8 @@ spring: ...@@ -28,8 +28,8 @@ spring:
port: 5672 port: 5672
username: root username: root
password: root password: root
staff-offline-Queue-Name: staff.offline.dev staff-offline-Queue-Name: staff.offline
order-queue-name: push.order.dev order-queue-name: push.order
exchange-name: delay.exchange exchange-name: delay.exchange
listener: listener:
simple: simple:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment