Quellcode durchsuchen

发送模板消息修改

yeshijie vor 7 Jahren
Ursprung
Commit
9c691e593e

+ 1 - 0
src/server/include/commons.js

@ -199,6 +199,7 @@ const DB_TABLES = {
    StickySessions: "sticky_sessions",
    WlyyConsult:"wlyy_consults",
    WlyyConsultTeam:"wlyy.wlyy_consult_team",
    WlyyConsultS:"wlyy.wlyy_consult",
    sessionTypeToTableName: function (sessionType) {
        if (sessionType == SESSION_TYPES.SYSTEM)

+ 7 - 7
src/server/models/client/wechat.client.js

@ -253,7 +253,7 @@ class WechatClient extends RedisModel {
                },
                // 获取议题信息
                function (map, callback) {
                    TopicRepo.findLastTopicStatus(message.session_id, function (err, res) {
                    TopicRepo.findLastTopicStatusAndType(message.session_id, function (err, res) {
                        if (err) {
                            ModelUtil.logError("Get topic failed", err);
                            return;
@ -284,6 +284,7 @@ class WechatClient extends RedisModel {
                    map.delete("openid");
                    let mainOpenId = patient.openid;
                    let agent = topic.agent;
                    let url = config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html";
                    if(agent){//代理人发起的议题
                        var agentOpenid = "";
                        if(map.size>0){
@ -297,7 +298,7 @@ class WechatClient extends RedisModel {
                                    WechatSDK.sendTemplateMessage({
                                        touser: openid,
                                        template_id: config.wechatConfig.template.consultTemplate,
                                        url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + openid +
                                        url: url + "?openid=" + openid + "&type="+topic.type+"&doctor="+message.sender_id+
                                        "&consult=" + topic.id + "&toUser=" + member.code + "&toName=" + member.name+"&represented="+patient.code,
                                        data: {
                                            first: {value: first, color: "#000000"}
@ -313,13 +314,12 @@ class WechatClient extends RedisModel {
                            }
                        }
                        if(mainOpenId!=agentOpenid){
                            var openid = mainOpenId;
                            var first = "您的健康咨询有新的回复";
                            // 发送模板消息
                            WechatSDK.sendTemplateMessage({
                                touser: openid,
                                touser: mainOpenId,
                                template_id: config.wechatConfig.template.consultTemplate,
                                url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + openid +
                                url: url + "?openid=" + mainOpenId +"&type="+topic.type+"&doctor="+message.sender_id+
                                "&consult=" + topic.id + "&toUser=" + targetUserId + "&toName=" + targetUserName+"&represented="+patient.code,
                                data: {
                                    first: {value: first, color: "#000000"}
@ -338,7 +338,7 @@ class WechatClient extends RedisModel {
                        WechatSDK.sendTemplateMessage({
                            touser: mainOpenId,
                            template_id: config.wechatConfig.template.consultTemplate,
                            url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + mainOpenId +
                            url: url + "?openid=" + mainOpenId +"&type="+topic.type+"&doctor="+message.sender_id+
                            "&consult=" + topic.id + "&toUser=" + targetUserId + "&toName=" + targetUserName+"&represented="+patient.code,
                            data: {
                                first: {value: "您的健康咨询有新的回复", color: "#000000"}
@ -360,7 +360,7 @@ class WechatClient extends RedisModel {
                                    WechatSDK.sendTemplateMessage({
                                        touser: openid,
                                        template_id: config.wechatConfig.template.consultTemplate,
                                        url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + openid +
                                        url: url + "?openid=" + openid +"&type="+topic.type+"&doctor="+message.sender_id+
                                        "&consult=" + topic.id + "&toUser=" + member.code + "&toName=" + member.name+"&represented="+patient.code,
                                        data: {
                                            first: {value: first, color: "#000000"}

+ 27 - 0
src/server/repository/mysql/topics.repo.js

@ -187,6 +187,21 @@ class TopicRepo {
        });
    }
    static findLastTopicStatusAndType(sessionId, handler) {
        let sql = "select id from " + DB_TABLES.Topics + " where  session_id = ? order by create_time desc limit 0, 1";
        ImDb.execQuery({
            sql: sql,
            args: [sessionId],
            handler: function (err, res) {
                if (res.length == 0) {
                    handler(null, null);
                } else {
                    TopicRepo.findTopicStatusAndType(res[0].id, handler);
                }
            }
        });
    }
    static findTopicStatus(topicId, handler) {
        let sql = "select id, name, description, status,agent from " + DB_TABLES.Topics + " where id = ?";
@ -200,6 +215,18 @@ class TopicRepo {
        });
    }
    static findTopicStatusAndType(topicId, handler) {
        let sql = "select t.id, t.name, t.description, t.status,t.agent,c.type from topics t,wlyy.wlyy_consult c where t.id = ? and t.id = c.code";
        ImDb.execQuery({
            sql: sql,
            args: [topicId],
            handler: handler || function (err, res) {
                if (err) log.error(err);
            }
        });
    }
    /**
     * 获取会话中的议题。
     *