/// <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());; }
/// <summary> /// 联系客服 /// </summary> /// <param name="recMsg"></param> /// <returns></returns> public Result <string> ChatWithKf(PubReceiveMsgCData recMsg) { try { if (IsWorkTime() && IsIn5Min(recMsg.FromUserName) && IsKfMsg(recMsg)) { PubKfApi.SendTextMsg(recMsg.FromUserName, "正在为你转接在线客服,请稍后....."); var msg = PubMsgApi.BuildKfTransferMsg(recMsg.FromUserName, recMsg.ToUserName, recMsg.CreateTime); return(new Result <string> { IsSucc = true, Data = msg }); } } catch (Exception ex) { logHelper.Error("ChatWithKf:联系客服失败:" + ex.Message + " " + ex.StackTrace); } return(new Result <string> { Message = "联系客服失败!" }); }
/// <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()); }
/// <summary> /// 发送微信应答 /// </summary> /// <param name="gzhClient"></param> /// <param name="gzhSever"></param> /// <param name="timeStamp"></param> /// <param name="text"></param> /// <returns></returns> public async Task <string> SendWxText(string gzhClient, string gzhSever, int timeStamp, string text) { var msg = PubMsgApi.BuildTextMsg(gzhClient, gzhSever, timeStamp, text); return(await AutoMsgResponse(msg)); }