/// <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="item"></param> /// <param name="openId"></param> /// <returns></returns> public async Task <Result <string> > AutoRespond(WxAutoKeywordShow item, string openId) { try { // 自动推送类型 Enum_ApMsgType type = ComHelper.GetEnumValueByStr <Enum_ApMsgType>(item.ContentType); // 发送客服消息预览 PubApiResult apiRes = new PubApiResult(); switch (type) { case Enum_ApMsgType.Text: item.TextContent = item.TextContent.Replace("{nickname}", string.Empty); apiRes = PubKfApi.SendTextMsg(openId, item.TextContent); break; case Enum_ApMsgType.Image: apiRes = PubKfApi.SendImageMsg(openId, item.MediaId); break; case Enum_ApMsgType.Voice: apiRes = PubKfApi.SendVoiceMsg(openId, item.MediaId); break; case Enum_ApMsgType.News: apiRes = PubKfApi.SendMpNewsMsg(openId, item.MediaId); break; case Enum_ApMsgType.Video: apiRes = PubKfApi.SendVideoMsg(openId, item.MediaId, item.VideoThumbMediaId, item.VideoTitle, item.VideoDescription); break; case Enum_ApMsgType.BackNews: var lstArts = await wxAutoConvertHelper.GetAutoKeywordBackNews(item); apiRes = PubKfApi.SendNewsMsg(openId, lstArts); break; case Enum_ApMsgType.RedBag: return(await wxAutoConvertHelper.SendAutoKeywordRedPack(item, openId)); default: break; } logHelper.Debug("PrevKeyword:预览返回结果:" + ComHelper.JsonSerialize(apiRes)); if (!apiRes.IsSuss) { var msg = "预览出错:" + apiRes.errcode + " " + apiRes.errmsg; logHelper.Error("PrevKeyword:" + msg); return(new Result <string> { Message = msg }); } return(new Result <string> { IsSucc = true, Message = "发送预览消息成功!" }); } catch (Exception ex) { logHelper.Error("PrevKeyword:发送预览消息失败:" + ex.Message + " " + ex.StackTrace); } return(new Result <string> { Message = "发送预览消息失败!" }); }