浏览代码

Merge branches 'dev' and 'feature-1.2.6' of http://192.168.1.220:10080/Amoy/im.doctor into dev

8 年之前
父节点
当前提交
97c970fa86
共有 2 个文件被更改,包括 24 次插入9 次删除
  1. 2 1
      src/doctor/models/group.js
  2. 22 8
      src/doctor/models/patient.js

+ 2 - 1
src/doctor/models/group.js

@ -86,9 +86,10 @@ class GroupMessage extends BaseModel {
                                            to: userId,
                                            contentType: message.contentType,
                                            content: message.content,
                                            msgId: groupMsg[0].msg_id,
                                            group: message.group
                                        };
                                        new Patient().sendMessage(msg);
                                        new Patient().pushGroupMessage(msg);
                                    },
                                    function () {
                                        Doctor.pushMessage(message, 'group_msg');

+ 22 - 8
src/doctor/models/patient.js

@ -104,6 +104,25 @@ class Patient extends BaseModel {
        });
    };
    /**
     * 推送群组消息给居民
     *
     * @param message
     */
    pushGroupMessage(message) {
        let self = this;
        // 通过Web Socket推送给患者
        let patientClient = clientCache.findById(message.to);
        if (!patientClient) {
            log.warn("User is not online, user id: ", message.to);
            //发送微信模板消息
            self.sendConsultWechatReplyTempMsg(message);
            return;
        }
        patientClient.socketServer.sockets.emit('message', message);
    };
    /**
     * 发送微信模板消息给居民
     *
@ -113,10 +132,10 @@ class Patient extends BaseModel {
        let selt = this;
        // 发送微信消息
        function sendWxMessage(openid, name, consult){
        function sendWxMessage(openid, name, consult) {
            var replyContent = message.content;
            switch(Number.parseInt(message.contentType)){
            switch (Number.parseInt(message.contentType)) {
                case CONTENT_TYPES.Image:
                    replyContent = "[图片]";
                    break;
@ -127,14 +146,9 @@ class Patient extends BaseModel {
                    replyContent = "[文章]";
                    break;
                case CONTENT_TYPES.GoTo:
                    return;
                    break;
                case CONTENT_TYPES.SessionBegin:
                    return;
                    break;
                case CONTENT_TYPES.SessionEnd:
                    return;
                    break;
                default:
                    break;
            }
@ -178,7 +192,7 @@ class Patient extends BaseModel {
                        var name = result[0].name;
                        if (message.group) {
                            groupRepo.getGroupConsultInfo(message.group, function(err, result){
                            groupRepo.getGroupConsultInfo(message.group, function (err, result) {
                                if (err) {
                                    modelUtil.emitDbError(self.eventEmitter, "get patient and doctor consult info failed", err);
                                    return;