Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SiEn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
SiEn
Commits
3eed56ed
Commit
3eed56ed
authored
Nov 12, 2020
by
zhangjw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1:修改mq配置
2:完善客服模块订单处理逻辑 (待完善)
parent
420847db
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
11 deletions
+56
-11
config/src/main/resources/config/application-dev.yml
+2
-2
customer-service/src/main/java/com/ym/im/entity/MsgBody.java
+5
-1
customer-service/src/main/java/com/ym/im/mq/Receiver.java
+47
-6
customer-service/src/main/resources/application-dev.yml
+2
-2
No files found.
config/src/main/resources/config/application-dev.yml
View file @
3eed56ed
...
...
@@ -21,8 +21,8 @@ spring:
# Redis配置
redis
:
database
:
0
host
:
localhost
password
:
123456
host
:
47.99.47.225
password
:
temple
123456
port
:
6379
rabbitmq
:
...
...
customer-service/src/main/java/com/ym/im/entity/MsgBody.java
View file @
3eed56ed
...
...
@@ -29,6 +29,8 @@ public class MsgBody<T> implements Serializable {
public
static
final
int
ORDER
=
5
;
public
static
final
int
DISTRIBUTION_STAFF
=
6
;
public
static
final
int
BINDINGFAILURE
=
7
;
public
static
final
int
MERCHANTS_OFFLINE
=
8
;
@NotNull
(
message
=
"{error.msg_body_status_empty}"
,
groups
=
MsgBodyGroup
.
class
)
@ApiModelProperty
(
value
=
" * 操作类型说明\n"
+
...
...
@@ -41,7 +43,9 @@ public class MsgBody<T> implements Serializable {
" * 4、用户上线\n"
+
" * 5、订单"
+
" * 6、分配客服"
+
" * 7、绑定失败"
" * 7、绑定失败"
+
" * 8、当前客服不在线,请稍后等待"
)
private
Integer
code
;
...
...
customer-service/src/main/java/com/ym/im/mq/Receiver.java
View file @
3eed56ed
package
com
.
ym
.
im
.
mq
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.ym.im.entity.*
;
import
com.ym.im.entity.base.NettyConstant
;
import
com.ym.im.entity.model.IdModel
;
import
com.ym.im.handler.ChannelGroupHandler
;
import
com.ym.im.service.ChatRecordService
;
import
com.ym.im.service.ChatService
;
import
com.ym.im.service.SessionListService
;
import
com.ym.im.service.StaffService
;
import
com.ym.im.util.JsonUtils
;
import
lombok.SneakyThrows
;
...
...
@@ -18,6 +21,8 @@ import javax.annotation.Resource;
import
java.util.Date
;
import
java.util.Set
;
import
static
com
.
ym
.
im
.
entity
.
ChatRecord
.
RECEIVE
;
/**
* @author: JJww
* @Date:2019-05-30
...
...
@@ -38,6 +43,18 @@ public class Receiver {
@Autowired
private
ChatService
staffSingleChatServiceImpl
;
@Autowired
private
SessionListService
sessiontListService
;
@Autowired
private
ChatRecordService
chatRecordService
;
/**
* 卓美亚商户ID 默认商户
*/
private
static
final
Long
JUMEIRAH_ID
=
1L
;
@RabbitListener
(
queues
=
"#{staffOfflineQueue.name}"
)
public
void
offlineHandler
(
StaffSocketInfo
staffSocketInfo
)
{
...
...
@@ -79,14 +96,37 @@ public class Receiver {
return
;
}
final
StaffSocketInfo
staffSocketInfo
=
channelGroup
.
getMerchantStaff
(
userSocketInfo
.
getStaffId
(
stroke
.
getMcId
()))
==
null
?
staffService
.
getIdleStaff
(
mcId
,
userId
)
:
channelGroup
.
getMerchantStaff
(
userSocketInfo
.
getStaffId
(
stroke
.
getMcId
()));
final
ChatRecord
chatRecord
=
new
ChatRecord
().
setMsgInfo
(
json
).
setUserId
(
userId
).
setSendTime
(
new
Date
()).
setMsgType
(
MsgBody
.
ORDER
);
final
MsgBody
<
ChatRecord
>
orderInfo
=
new
MsgBody
<
ChatRecord
>().
setCode
(
MsgBody
.
ORDER
).
setData
(
chatRecord
);
staffSingleChatServiceImpl
.
save
(
staffSocketInfo
.
getStaffId
(),
orderInfo
);
if
(
staffSocketInfo
!=
null
)
{
staffSocketInfo
.
writeAndFlush
(
orderInfo
);
log
.
info
(
"客服订单: "
+
"给客服("
+
staffSocketInfo
.
getStaffId
()
+
")发送订单:"
+
json
);
final
MsgBody
<
ChatRecord
>
orderInfo
=
new
MsgBody
<
ChatRecord
>().
setCode
(
MsgBody
.
ORDER
).
setData
(
new
ChatRecord
().
setMsgInfo
(
json
).
setUserId
(
userId
).
setSendTime
(
new
Date
()).
setMsgType
(
MsgBody
.
ORDER
));
if
(
staffSocketInfo
==
null
)
{
//没有商户在线 逻辑待优化....完善
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
);
this
.
updateMerchantList
(
orderInfo
);
staffSocketInfo
.
writeAndFlush
(
orderInfo
);
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
customer-service/src/main/resources/application-dev.yml
View file @
3eed56ed
...
...
@@ -28,8 +28,8 @@ spring:
port
:
5672
username
:
root
password
:
root
staff-offline-Queue-Name
:
staff.offline
order-queue-name
:
push.order
staff-offline-Queue-Name
:
staff.offline
.dev
order-queue-name
:
push.order
.dev
exchange-name
:
delay.exchange
listener
:
simple
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment