|
@@ -110,6 +110,9 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
@Autowired
|
|
|
private IKfAppletReplyService kfAppletReplyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserAppletService userAppletService;
|
|
|
+
|
|
|
@Override
|
|
|
public void appletMsg(String postData) {
|
|
|
log.error("接收到客服消息 : {}", postData);
|
|
@@ -157,7 +160,8 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
//客服休息时间, 发送自动回复
|
|
|
this.systemReplyHandle(gameApplet.getGameId(), kfAppletMsgDTO.getFromUserName(), kfRoom);
|
|
|
//小程序自动回复
|
|
|
- this.appletReplyHandle(gameApplet.getGameId(), kfAppletMsgDTO.getFromUserName(), kfRoom, kfAppletMsgDTO.getSessionFrom());
|
|
|
+ this.appletReplyHandle(gameApplet.getGameId(), kfAppletMsgDTO.getFromUserName(), kfRoom,
|
|
|
+ kfAppletMsgDTO.getSessionFrom(), gameApplet.getAppId());
|
|
|
//消息报警监测
|
|
|
this.monitorWordHandle(gameApplet, kfAppletMsgDTO);
|
|
|
//保存房间消息
|
|
@@ -176,7 +180,7 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
this.pushMessage(this.transform(kfRoom, gameApplet.getGameId(), kfAppletMsgDTO.getFromUserName(), kfRoomMsg, msgContent));
|
|
|
}
|
|
|
|
|
|
- private void appletReplyHandle(Long gameId, String openId, KfRoom kfRoom, String sessionFrom) {
|
|
|
+ private void appletReplyHandle(Long gameId, String openId, KfRoom kfRoom, String sessionFrom, String appId) {
|
|
|
//来源类型
|
|
|
KfSessionFromEnum kfSessionFrom = KfSessionFromEnum.getKfSessionFrom(sessionFrom);
|
|
|
if (kfSessionFrom == null) {
|
|
@@ -196,22 +200,40 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
}
|
|
|
//判断是否来源于广告
|
|
|
if (Objects.equals(sessionFrom, KfSessionFromEnum.KF_SESSION_FROM_AD.getValue())) {
|
|
|
+ //存在文本消息发送
|
|
|
+ if (Strings.isNotBlank(kfAppletReply.getReplyText())) {
|
|
|
+ this.sysMsgSend(gameId, openId, kfAppletReply.getReplyText(), kfRoom);
|
|
|
+ }
|
|
|
//存在图片发送
|
|
|
if (Strings.isNotBlank(kfAppletReply.getReplyImg())) {
|
|
|
this.sysImgMsgSend(gameId, openId, kfAppletReply.getReplyImg(), kfRoom);
|
|
|
}
|
|
|
//存在链接发送
|
|
|
if (Strings.isNotBlank(kfAppletReply.getReplyLink())) {
|
|
|
- this.sysLinkMsgSend(gameId, openId, kfRoom, kfAppletReply.getReplyLink());
|
|
|
+ //链接消息参数转换
|
|
|
+ Map<String, String> linkMap = JsonUtil.toMap(kfAppletReply.getReplyLink(), Map.class, String.class);
|
|
|
+ String url = linkMap.get("url");
|
|
|
+ //链接拼接短链id
|
|
|
+ if (Strings.isNotBlank(url)) {
|
|
|
+ UserApplet userApplet = userAppletService.getOne(new LambdaQueryWrapper<UserApplet>()
|
|
|
+ .eq(UserApplet::getAppId, appId)
|
|
|
+ .eq(UserApplet::getOpenId, openId)
|
|
|
+ .orderByDesc(UserApplet::getCreateTime)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (userApplet != null) {
|
|
|
+ linkMap.put("url", url + "?customer_channel=" + userApplet.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.sysLinkMsgSend(gameId, openId, kfRoom, linkMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void sysLinkMsgSend(Long gameId, String openId, KfRoom kfRoom, String linkJson) {
|
|
|
+ private void sysLinkMsgSend(Long gameId, String openId, KfRoom kfRoom, Map<String, String> linkMap) {
|
|
|
//发送消息
|
|
|
Map<String, Object> msgParamMap = new HashMap<>(3);
|
|
|
msgParamMap.put("touser", openId);
|
|
|
- msgParamMap.put("link", JsonUtil.toMap(linkJson, Map.class, Object.class));
|
|
|
+ msgParamMap.put("link", linkMap);
|
|
|
msgParamMap.put("msgtype", KfRoomMsgTypeEnum.KF_MSG_TYPE_LINK.getValue());
|
|
|
Tuple2<Long, String> tuple2 = kfWxApiService.sendCustomMessageApi(gameId, msgParamMap);
|
|
|
//发送失败
|