public bool SendCGUrlToManager(string oldurl, int memid) { bool returnresult = false; string _redirecturl = oldurl; VWMemberEntity _memen = MemberBLL.Instance.GetVWMember(memid); WeChatNavigationEntity _entity = WeChatNavigationBLL.Instance.GetNavigationByUrl(_redirecturl); if (_entity == null || _entity.Id == 0) { _entity.RedirectUrl = _redirecturl; //_entity.Id = WeChatNavigationBLL.Instance.AddWeChatNavigation(_entity); } _entity.WeChatUrlType = (int)WeChatUrTypeEnum.Temp; _entity.Remark = "供应商临时登录报价"; //_entity.WeChatUrl = string.Format(WeiXinConfig.URL_FORMAT_KHRedirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.WeChatWebUrl), _entity.Id); _entity.WeChatUrl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(_redirecturl), _entity.Id); int _result = WeChatNavigationBLL.Instance.UpdateWeChatNavigation(_entity); IList <VWMemberEntity> memlist = MemberBLL.Instance.GetMemByAuthCode(MemberAuthEnum.InquiryOrderQuote); if (memlist != null && memlist.Count > 0) { foreach (VWMemberEntity mem in memlist) { if (!string.IsNullOrEmpty(mem.WeChat)) { MemWeChatMsgEntity wecharmsg = MemWeChatMsgBLL.Instance.GetMsgByAppUnionId(WeiXinConfig.GetAppId(), mem.WeChat); if (wecharmsg != null && !string.IsNullOrEmpty(wecharmsg.OpenId)) { WeiXinCustomerEntity customer = new WeiXinCustomerEntity(); customer.touser = wecharmsg.OpenId; customer.msgtype = WeiXinCustomerMsgtypeEnum.text; WeiXinCustomerTextEntity text = new WeiXinCustomerTextEntity(); text.content = "亲爱的" + _memen.CompanyName + "\n易店心来新的询价单,赶紧点击网址抢单额\n抢单网址:" + _entity.WeChatUrl; customer.text = text; returnresult = WeiXinJsSdk.Instance.SendWeiXinCustomerNote(customer); } } } } return(returnresult); }
public bool SendWeiXinCustomerNote(WeiXinCustomerEntity customer) { bool success = false; string url = string.Format(WeiXinConfig.Customer_Format_Send, WeiXinJsSdk.Instance.GetAccessToken(false)); string json = JsonJC.ObjectToJson(customer); string result = WebServiceClient.QueryPostWebServiceJson(url, json); WeiXinFailEntity resulten = JsonJC.JsonToObject <WeiXinFailEntity>(result); ///发送微信备案 WeChatMsgEntity msg = new WeChatMsgEntity(); msg.ParamStr = json; msg.WeChatOpenId = ""; msg.RedirectUrl = ""; msg.WeChatUrl = url; msg.TemplateIid = ""; msg.Result = result; msg.Id = WeChatMsgBLL.Instance.AddWeChatMsg(msg); if (resulten.errmsg.ToLower() == "ok") { success = true; } return(success); }
/// <summary> /// 通知供应商 /// </summary> /// <param name="code"></param> /// <returns></returns> public bool NoteToCGMemForQuote(string code) { bool result = false; string emailnote = "供应商发送微信情况<br/>"; emailnote += "订单号:" + code + "<br/>"; InquiryOrderEntity order = InquiryOrderBLL.Instance.GetInquiryOrderByCode(code); string memidsold = CGMemQuotedBLL.Instance.GetQuotedCGMemByCode(order.Code); string memidsnew = MemCGScopeBLL.Instance.GetCGMemIdsByCarBrand(order.ScopeType, order.CarBrandName, memidsold); //获取虚拟报价员 IList <VWMemberEntity> memlist = MemberBLL.Instance.GetMemByAuthCode(MemberAuthEnum.InquiryOrderQuote); string[] memidsoldattr = memidsold.Split(','); string[] memidnewattr = memidsnew.Split(','); bool hascg = false; if (!string.IsNullOrEmpty(memidsnew)) { hascg = true; } if (memlist != null && memlist.Count > 0) { foreach (VWMemberEntity cgmemsup in memlist) { bool oldhas = false; if (memidsoldattr != null && memidsoldattr.Length > 0) { foreach (string memidoleen in memidsoldattr) { if (cgmemsup.MemId.ToString() == memidoleen) { oldhas = true; break; } } if (!oldhas) { foreach (string memidnewen in memidnewattr) { if (cgmemsup.MemId.ToString() == memidnewen) { oldhas = true; break; } } } } if (!oldhas) { memidsnew += "," + cgmemsup.MemId.ToString(); } } } int resultrowi = CGMemQuotedBLL.Instance.AddInquiryToCGMemQuoted(order.Code, memidsnew); //获取要发送的供应商,并发送通知 //InquiryOrderBLL.Instance.UpdateQuoteStatus(order.Code, (int)QuoteStatusEnum.HasSend); IList <CGMemQuotedEntity> _sendlist = CGMemQuotedBLL.Instance.GetCGMemQuotedNeedSend(order.Code); string redirecturl = ConfigCore.Instance.ConfigCommonEntity.InquiryWebUrl + string.Format(WebUrlEnum.InquiryCGMemNote, code); //int navid = WeChatNavigationBLL.Instance.GetIdByUrl(redirecturl); //string url = string.Format(WeiXinConfig.URL_FORMAT_SendMsg, WeiXinJsSdk.Instance.GetAccessToken(false)); if (!hascg) { emailnote += "没有找到供应商<br/>"; } if (_sendlist != null && _sendlist.Count > 0) { foreach (CGMemQuotedEntity entity in _sendlist) { if (!hascg) { string title = "您的询价单没有找到供应商额,订单编号:" + order.Code; string ordercode = entity.InquiryOrderCode; try { //获取链接导航Id int memid = entity.CGMemId; VWMemberEntity memen = MemberBLL.Instance.GetVWMember(memid); emailnote += memen.CompanyName + memen.MobilePhone + memen.CompanyAddress + " "; if (!string.IsNullOrEmpty(memen.WeChat)) { Hashtable hashentity = new Hashtable(); hashentity.Add("first", new WeiXinUnitEntity() { value = title }); hashentity.Add("keyword1", new WeiXinUnitEntity() { value = "无" }); hashentity.Add("keyword2", new WeiXinUnitEntity() { value = order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss") }); hashentity.Add("keyword3", new WeiXinUnitEntity() { value = order.CarBrandName }); hashentity.Add("keyword4", new WeiXinUnitEntity() { value = "备注" + order.Remark }); hashentity.Add("remark", new WeiXinUnitEntity() { value = "" }); bool sendsuccess = WeiXinJsSdk.Instance.SendWeiXinMsgNote(memen.WeChat, redirecturl, WeiXinTemplet.InquiryNeedNote, hashentity); if (sendsuccess) { result = sendsuccess; //发送微信成功备份 CGMemQuotedBLL.Instance.CGQuotedSend(memid, ordercode); emailnote += "发送成功<br/>"; } } else { emailnote += "没有绑定微信<br/>"; ////需发邮件提醒 //EmailSendEntity email = new EmailSendEntity(); //email.CreateTime = DateTime.Now; //email.Body = "询价单编号:" + order.Code + "<br/> 供应商:" + memen.MemCode + "(" + memen.MobilePhone + ")" + memen.MemGradeName + ",<br/>网址:" + redirecturl; //var emailsendstr = SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.SendMailManager; //if (emailsendstr == null || string.IsNullOrEmpty(emailsendstr.ToString())) //{ // email.Email = "*****@*****.**"; //} //else //{ // email.Email = emailsendstr.ToString(); //} //email.Title = "询价单发送微信错误供应商未登记微信"; //email.Status = 0; //EmailSendBLL.Instance.AddEmailSend(email); } } catch (Exception ex) { emailnote += "发送错误" + ex.Message + "<br/>"; LogUtil.Log("微信发送询价出错:订单号:" + ordercode, ex.Message); } } else { string title = "您有订单需要报价啦,赶紧抢单,订单编号:" + order.Code; if (entity.HasSend == 1) { title = "客户修改了询价单信息,请完善报价,订单编号:" + order.Code; } string ordercode = entity.InquiryOrderCode; try { //获取链接导航Id int memid = entity.CGMemId; VWMemberEntity memen = MemberBLL.Instance.GetVWMember(memid); emailnote += memen.CompanyName + memen.MobilePhone + memen.CompanyAddress + " "; if (!string.IsNullOrEmpty(memen.WeChat)) { Hashtable hashentity = new Hashtable(); hashentity.Add("first", new WeiXinUnitEntity() { value = title }); hashentity.Add("tradeDateTime", new WeiXinUnitEntity() { value = order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss") }); hashentity.Add("orderType", new WeiXinUnitEntity() { value = "询价订单" }); hashentity.Add("customerInfo", new WeiXinUnitEntity() { value = "易店心" }); hashentity.Add("orderItemName", new WeiXinUnitEntity() { value = "备注" }); hashentity.Add("orderItemData", new WeiXinUnitEntity() { value = order.Remark }); hashentity.Add("remark", new WeiXinUnitEntity() { value = "" }); bool sendsuccess = WeiXinJsSdk.Instance.SendWeiXinMsgNote(memen.WeChat, redirecturl, WeiXinTemplet.InquiryQuoteSend, hashentity); if (sendsuccess) { result = sendsuccess; //发送微信成功备份 CGMemQuotedBLL.Instance.CGQuotedSend(memid, ordercode); emailnote += "发送成功<br/>"; } else { emailnote += "发送失败<br/>"; } //else //{ // //需发邮件提醒 // EmailSendEntity email = new EmailSendEntity(); // email.CreateTime = DateTime.Now; // email.Body = "询价单编号:" + order.Code + "<br/> 供应商:" + memen.MemCode + "(" + memen.MobilePhone + ")" + memen.MemGradeName + ",<br/>网址:" + redirecturl; // var emailsendstr = SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.SendMailManager; // if (emailsendstr == null || string.IsNullOrEmpty(emailsendstr.ToString())) // { // email.Email = "*****@*****.**"; // } // else // { // email.Email = emailsendstr.ToString(); // } // email.Title = "询价单发送微信通知失败"; // email.Status = 0; // EmailSendBLL.Instance.AddEmailSend(email); //} } else { emailnote += "没有绑定微信<br/>"; ////需发邮件提醒 //EmailSendEntity email = new EmailSendEntity(); //email.CreateTime = DateTime.Now; //email.Body = "询价单编号:" + order.Code + "<br/> 供应商:" + memen.MemCode + "(" + memen.MobilePhone + ")" + memen.MemGradeName + ",<br/>网址:" + redirecturl; //var emailsendstr = SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.SendMailManager; //if (emailsendstr == null || string.IsNullOrEmpty(emailsendstr.ToString())) //{ // email.Email = "*****@*****.**"; //} //else //{ // email.Email = emailsendstr.ToString(); //} //email.Title = "询价单发送微信错误供应商未登记微信"; //email.Status = 0; //EmailSendBLL.Instance.AddEmailSend(email); } } catch (Exception ex) { emailnote += "发送错误" + ex.Message + "<br/>"; LogUtil.Log("微信发送询价出错:订单号:" + ordercode, ex.Message); } } } } else { InquiryOrderBLL.Instance.UpdateQuoteStatus(order.Code, (int)QuoteStatusEnum.SendFail); } string notemsg = emailnote + "报价网址" + redirecturl + "<br/>"; notemsg += "转移到线下网址:" + SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.InquiryMobileWebUrl + "/Check/copyinquiry?code=" + order.Code + "<br/>"; //notemsg+="订单信息:订单号:" + order.Code+"<br/>"; //notemsg+="备注" + order.Remark+ "<br/>"; //notemsg+="图片信息" + "<br/>"; //if(!string.IsNullOrEmpty(order.VinPic)) //{ // notemsg += "<img src='" + SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.ImagesServerUrl + order.VinPic + "' />"; //} //if (!string.IsNullOrEmpty(order.EngineModelPic)) //{ // notemsg += "<img src='" + SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.ImagesServerUrl + order.EngineModelPic + "' />"; //} //if (order.OrderPics!=null&& order.OrderPics.Count>0) //{ // foreach(InquiryOrderPicsEntity pic in order.OrderPics) // { // notemsg += "<img src='" + SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.ImagesServerUrl + pic.PicUrl + "' />"; // } //} //notemsg +="<br/>"; //notemsg += "产品信息" + "<br/>"; //if (order.OrderProducts != null && order.OrderProducts.Count > 0 && order.OrderProductSubs!=null && order.OrderProductSubs.Count>0) //{ // Dictionary<int, IList<InquiryProductSubEntity>> prosubdic = new Dictionary<int, IList<InquiryProductSubEntity>>(); // foreach (InquiryProductSubEntity prosub in order.OrderProductSubs) // { // if(!prosubdic.ContainsKey(prosub.InquiryProductId)) // { // prosubdic.Add(prosub.InquiryProductId, new List<InquiryProductSubEntity>()); // } // prosubdic[prosub.InquiryProductId].Add(prosub); // } // foreach(InquiryProductEntity pro in order.OrderProducts) // { // if(prosubdic.ContainsKey(pro.Id)) // { // IList <InquiryProductSubEntity> prosublist = prosubdic[pro.Id]; // if(prosublist!=null&& prosublist.Count>0) // { // foreach(InquiryProductSubEntity prosub in prosublist) // { // notemsg += pro.ProductName + " " + prosub.InquiryProductTypeName + "<br/>"; // } // } // } // } //} if (memlist != null && memlist.Count > 0) { foreach (VWMemberEntity cgmemsup in memlist) { MemWeChatMsgEntity wecharmsg = MemWeChatMsgBLL.Instance.GetMsgByAppUnionId(WeiXinConfig.GetAppId(), cgmemsup.WeChat); WeiXinCustomerEntity customer = new WeiXinCustomerEntity(); customer.touser = wecharmsg.OpenId; customer.msgtype = WeiXinCustomerMsgtypeEnum.text; WeiXinCustomerTextEntity text = new WeiXinCustomerTextEntity(); text.content = notemsg.Replace("<br/>", "\n"); customer.text = text; WeiXinJsSdk.Instance.SendWeiXinCustomerNote(customer); } } //需发邮件提醒 EmailSendEntity email = new EmailSendEntity(); email.CreateTime = DateTime.Now; email.Body = notemsg; var emailsendstr = SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.SendMailManager; if (emailsendstr == null || string.IsNullOrEmpty(emailsendstr.ToString())) { email.Email = "*****@*****.**"; } else { email.Email = emailsendstr.ToString(); } email.Title = "询价单没有找到供应商进行报价"; email.Status = 0; EmailSendBLL.Instance.AddEmailSend(email); return(result); }