/// <summary>
        /// 联系客服(菜单)
        /// </summary>
        /// <param name="recMsg"></param>
        /// <returns></returns>
        public async Task <string> ContactKf(PubReceiveMsg recMsg)
        {
            try
            {
                var timeStamp = ComHelper.ConvertDateTimeInt(DateTime.Now);
                if (!IsWorkTime())
                {
                    var msg = "您好!现在非客服上班时间,请您在每天9-22点联系我们的客服美眉!";
                    return(await wxAutoComResponse.SendWxText(recMsg.FromUserName, recMsg.ToUserName, timeStamp, msg));
                }
                else
                {
                    PubKfApi.SendTextMsg(recMsg.FromUserName, "正在为你转接在线客服,请稍后.....");
                    var msg = PubMsgApi.BuildKfTransferMsg(recMsg.FromUserName, recMsg.ToUserName, timeStamp);
                    logHelper.Debug("ContactKf:msg:" + msg.JsonSerialize());
                    // 发送客服消息提醒
                    return(await wxAutoComResponse.AutoMsgResponse(msg));
                }
            }
            catch (Exception ex)
            {
                logHelper.Error("ContactKf:联系客服失败:" + ex.Message + "        " + ex.StackTrace);
            }

            return(wxAutoComResponse.ResponseOK());;
        }
Esempio n. 2
0
        /// <summary>
        /// 根据不同类型推送消息
        /// </summary>
        /// <param name="gzhClient"></param>
        /// <param name="gzhSever"></param>
        /// <param name="autoKeyword"></param>
        /// <param name="wxUser"></param>
        /// <returns></returns>
        public async Task <string> SendMsgByPush(string gzhClient, string gzhSever, WxAutoKeywordShow autoKeyword, WxUserInfo wxUser)
        {
            logHelper.Debug("SendMsgByPush:autoPushing:" + autoKeyword.JsonSerialize());
            var dtNow     = DateTime.Now;
            var timeStamp = ComHelper.ConvertDateTimeInt(dtNow);
            var apType    = ComHelper.GetEnumValueByStr <Enum_ApMsgType>(autoKeyword.ContentType);

            switch (apType)
            {
            case Enum_ApMsgType.Text:
            {
                var msg = autoKeyword.TextContent.Replace("{nickname}", wxUser.NickName);
                logHelper.Debug("SendMsgByPush:Msg:" + msg);
                return(await wxAutoComResponse.SendWxText(gzhClient, gzhSever, timeStamp, msg));
            }

            case Enum_ApMsgType.Image:
            {
                var msg = PubMsgApi.BuildImageMsg(gzhClient, gzhSever, autoKeyword.MediaId, timeStamp);
                return(await wxAutoComResponse.AutoMsgResponse(msg));
            }

            case Enum_ApMsgType.Voice:
            {
                var msg = PubMsgApi.BuildVoiceMsg(gzhClient, gzhSever, autoKeyword.MediaId, timeStamp);
                return(await wxAutoComResponse.AutoMsgResponse(msg));
            }

            case Enum_ApMsgType.News:
            {
                var lstArt = await wxAutoConvertHelper.GetResponseWxNews(autoKeyword);

                var msg = PubMsgApi.BuildArticleMsg(gzhClient, gzhSever, timeStamp, lstArt);
                return(await wxAutoComResponse.AutoMsgResponse(msg));
            }

            case Enum_ApMsgType.Video:
            {
                var msg = PubMsgApi.BuildVideoMsg(gzhClient, gzhSever, autoKeyword.MediaId, autoKeyword.VideoTitle, autoKeyword.VideoDescription, timeStamp);
                return(await wxAutoComResponse.AutoMsgResponse(msg));
            }

            case Enum_ApMsgType.BackNews:
            {
                var lstIds = autoKeyword.ArtIds.StrSplitList().Select(x => Convert.ToInt64(x)).ToList();
                if (lstIds.Count > 0)
                {
                    var lstWxArts = await wxAutoConvertHelper.GetResponseBackNews(autoKeyword, lstIds);

                    var msg = PubMsgApi.BuildArticleMsg(gzhClient, gzhSever, timeStamp, lstWxArts);
                    return(await wxAutoComResponse.AutoMsgResponse(msg));
                }
            }
            break;

            case Enum_ApMsgType.RedBag:
            {
                return(await wxAutoConvertHelper.SendResponseRedPack(gzhClient, gzhSever, autoKeyword, dtNow, timeStamp));
            }

            default:
                break;
            }

            return(wxAutoComResponse.ResponseOK());
        }