Commit 10f6e30a authored by Alex朱枝文's avatar Alex朱枝文

机器人消息上报

parent d526fc42
......@@ -484,6 +484,7 @@
047AA3F82C5CC7B0009C4554 /* YHShareStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F72C5CC7B0009C4554 /* YHShareStepView.swift */; };
047AA3FA2C60739E009C4554 /* YHInvitationWithGiftsSelectItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F92C60739E009C4554 /* YHInvitationWithGiftsSelectItemView.swift */; };
047AA3FC2C61EE7F009C4554 /* YHSignAppendStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3FB2C61EE7F009C4554 /* YHSignAppendStepView.swift */; };
047AB5E62CD083CE002A3573 /* YHButlerMessageReportHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AB5E52CD083CE002A3573 /* YHButlerMessageReportHandler.swift */; };
0480582F2C7CA77900502CAA /* YHDisappointHKAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480582E2C7CA77900502CAA /* YHDisappointHKAlertView.swift */; };
048058312C7DBDC900502CAA /* YHTravelCertificateTipsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058302C7DBDC900502CAA /* YHTravelCertificateTipsView.swift */; };
048058332C7DC0CF00502CAA /* YHTravelCertificateTipsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058322C7DC0CF00502CAA /* YHTravelCertificateTipsCell.swift */; };
......@@ -1452,6 +1453,7 @@
047AA3F72C5CC7B0009C4554 /* YHShareStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHShareStepView.swift; sourceTree = "<group>"; };
047AA3F92C60739E009C4554 /* YHInvitationWithGiftsSelectItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInvitationWithGiftsSelectItemView.swift; sourceTree = "<group>"; };
047AA3FB2C61EE7F009C4554 /* YHSignAppendStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSignAppendStepView.swift; sourceTree = "<group>"; };
047AB5E52CD083CE002A3573 /* YHButlerMessageReportHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHButlerMessageReportHandler.swift; sourceTree = "<group>"; };
0480582E2C7CA77900502CAA /* YHDisappointHKAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHDisappointHKAlertView.swift; sourceTree = "<group>"; };
048058302C7DBDC900502CAA /* YHTravelCertificateTipsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTravelCertificateTipsView.swift; sourceTree = "<group>"; };
048058322C7DC0CF00502CAA /* YHTravelCertificateTipsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTravelCertificateTipsCell.swift; sourceTree = "<group>"; };
......@@ -1965,6 +1967,7 @@
0414708C2C895A1800B7B688 /* VM */,
0414708A2C88627B00B7B688 /* YHButlerServiceManager.swift */,
04B4B8D62C8AE77C00ED82BC /* YHButlerServiceMessageHandler.swift */,
047AB5E52CD083CE002A3573 /* YHButlerMessageReportHandler.swift */,
);
path = "ButlerServiceManager(银河管家)";
sourceTree = "<group>";
......@@ -5491,6 +5494,7 @@
0430E6582C7434F2000511E2 /* YHAdopterNewPeopleViewController.swift in Sources */,
A582B2452BBA4CF9009D098C /* YHHKPlanDocModel.swift in Sources */,
045EEF142B9F171A0022A143 /* YHItemModel.swift in Sources */,
047AB5E62CD083CE002A3573 /* YHButlerMessageReportHandler.swift in Sources */,
045EEED72B9F171A0022A143 /* YHEducationInfo.swift in Sources */,
047AA3D92C4A4A91009C4554 /* YHInvatationShareViewController.swift in Sources */,
045EEEDE2B9F171A0022A143 /* YHEducationInfoCell.swift in Sources */,
......
......@@ -42,4 +42,22 @@ class YHButlerServiceViewModel {
}
return nil
}
// 当收到机器人非招呼消息时,发送用户id给后端,后端触发发送企业微信
func sendUserIdInChat(_ userId: String, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let params: [String: Any] = ["yh_id": userId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.QiYu.sendUserIdInChat
_ = YHNetRequest.postRequest(url: strUrl, params: params) { json, code in
// 1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
callBackBlock(true, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callBackBlock(false, err)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
......@@ -26,6 +26,8 @@ class YHButlerServiceManager: NSObject {
private var curentPresentedVC: UIViewController?
private lazy var reportHandler: YHButlerMessageReportHandler = YHButlerMessageReportHandler()
var lastMessage: YHButlerServiceMessage? {
getLastMessage()
}
......@@ -237,6 +239,7 @@ extension YHButlerServiceManager {
guard isUatAllowed() else {
return
}
reportHandler.reset()
initSDKAccountAndLastMessage { _ in
// 为了更新状态
DispatchQueue.main.async {
......@@ -348,13 +351,15 @@ extension YHButlerServiceManager: QYConversationManagerDelegate {
/// 会话列表变化;非平台电商用户,只有一个会话项,平台电商用户,有多个会话项 用这个方法可以拿到最新的完整的消息内容
func onSessionListChanged(_ sessionList: [QYSessionInfo]!) {
printLog("$$$$onSessionListChanged \(sessionList.first?.lastMessageText ?? "") \(sessionList.first?.lastMessageType.rawValue ?? 0) \(sessionList.first?.lastMessageTimeStamp ?? 0) \(sessionList.first?.lastMessage?.messageId ?? "")")
NotificationCenter.default.post(name: YhConstant.YhNotification.didQiYuReceiveNewMsgNotification, object: nil)
printLog("$$$$onSessionListChanged \(sessionList.first?.lastMessage?.from ?? "") \(sessionList.first?.lastMessageText ?? "") \(sessionList.first?.lastMessageType.rawValue ?? 0) \(sessionList.first?.lastMessageTimeStamp ?? 0) \(sessionList.first?.lastMessage?.messageId ?? "")")
}
/// 接收消息(进聊天页面会刷新, 目前不用这个方法打点记录)
func onReceiveMessage(_ message: QYMessageInfo!) {
printLog("$$$$onReceiveMessage \(message?.text ?? "") \(message?.type.rawValue ?? 0) \(message?.timeStamp ?? 0)")
if let latestMessage = getSessionList().last {
reportHandler.handleMessage(latestMessage)
}
}
/// 会话未读数变化(进聊天页面会刷新)
......
......@@ -360,7 +360,6 @@ private extension YHHomePageViewController {
func setupNotification() {
// 改为不监听消息到来,而是未读消息数量改变
// NotificationCenter.default.addObserver(self, selector: #selector(didQiYuReceiveNewMsg), name: YhConstant.YhNotification.didQiYuReceiveNewMsgNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didQiYuReceiveNewMsg), name: YhConstant.YhNotification.didQiYuUnReadMsgCountChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didRevUatParam), name: YhConstant.YhNotification.didRevUatParam, object: nil)
}
......
......@@ -287,9 +287,6 @@ extension YhConstant {
// 改变底部tabbar上 分享View的展示状态
public static let changeShareViewStatusOnTabBarNotifiction = Notification.Name(rawValue: "com.yinhe.change.shareView.status")
// 七鱼有新消息
public static let didQiYuReceiveNewMsgNotification = Notification.Name(rawValue: "com.yinhe.qiyu.receiveNewMsg")
// 七鱼未读消息数量变化
public static let didQiYuUnReadMsgCountChangeNotification = Notification.Name(rawValue: "com.yinhe.qiyu.unReadMsgCountChange")
......
......@@ -518,6 +518,8 @@ class YHAllApiName {
struct QiYu {
// 获取个人信息
static let userInfomation = "super-app/qiyu/user/information"
// 当收到机器人非招呼消息时,发送用户id给后端,后端触发发送企业微信
static let sendUserIdInChat = "super-app/approval/send-wechat-message"
}
// 续签资料
......
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