/// <summary> /// 客户下完订单之后,系统处理微信推送 /// </summary> /// <param name="OrderId">订单标识</param> /// <param name="msgUrl">微信推送地址</param> /// <param name="distance">距离</param> /// <param name="strError">错误提示</param> /// <returns></returns> public bool SetPushOrder(string OrderId, string msgUrl, float distance, out string strError) { string content = string.Empty; try { DataSet ds = new DataSet(); IList <VipEntity> vipListInfo = new List <VipEntity>(); ds = _currentDAO.GetFieldwork(distance, OrderId); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { vipListInfo = DataTableToObject.ConvertToList <VipEntity>(ds.Tables[0]); foreach (VipEntity vipInfo in vipListInfo) { var orderInfo = GetByID(OrderId); //string msgUrl = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim(); //string msgText = string.Format("信息提示用户。{0}分钟内,工号为{1}的员工将上门收取衣物,该员工的手机号为{2}", // "5", vipInfo.VipCode, vipInfo.Phone); Random rad = new Random(); //string msgText = "您有一个订单,<a href='http://o2oapi.aladingyidong.com/wap/xiyi/sureOrder.html?rid="+rad.Next(1000,100000)+"&customerId=" + this.CurrentUserInfo..Customer_Id + "&orderId=" + OrderId + "&userId=" + vipInfo.VIPID + "&openId=" + vipInfo.WeiXinUserId + "&address=" + HttpUtility.UrlEncode(orderInfo.Address) + "&phone=" + orderInfo.Phone + "&Cnumber=" + orderInfo.Qty + "&status="+orderInfo.Status+"'>点击确认订单.</a>"; string msgText = "您有一个订单,<a href='http://o2oapi.aladingyidong.com/wap/xiyi/sureOrder.html?rid=" + rad.Next(1000, 100000) + "&customerId=" + this.CurrentUserInfo.CurrentUser.customer_id + "&orderId=" + OrderId + "&userId=" + vipInfo.VIPID + "&openId=" + vipInfo.WeiXinUserId + "'>点击确认订单.</a>"; string msgData = "<xml><OpenID><![CDATA[" + vipInfo.WeiXinUserId + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>"; var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); #region 发送日志 MarketSendLogBLL logServer = new MarketSendLogBLL(CurrentUserInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.IsSuccess = 1; logInfo.MarketEventId = OrderId; logInfo.SendTypeId = "2"; logInfo.TemplateContent = msgData; logInfo.VipId = vipInfo.VIPID; logInfo.WeiXinUserId = vipInfo.WeiXinUserId; logInfo.CreateTime = System.DateTime.Now; logServer.Create(logInfo); #endregion } } strError = "成功"; return(true); } catch (Exception ex) { strError = ex.ToString(); return(false); } }
/// <summary> /// 确认收单,并且推送消息告知客户 /// </summary> /// <param name="orderId">确认单据</param> /// <param name="userId">收单确认人</param> /// <returns></returns> public bool GetReceiptConfirm(string orderId, string userId, string msgUrl, out string strError) { try { DataSet ds = new DataSet(); ds = _currentDAO.GetReceiptConfirm(orderId, userId); VipEntity vipInfo = new VipEntity(); if (ds != null && ds.Tables[0].Rows.Count > 0) { vipInfo = DataTableToObject.ConvertToObject <VipEntity>(ds.Tables[0].Rows[0]); string msgText = string.Format("信息提示用户。{0}分钟内,工号为{1}的员工将上门收取衣物,该员工的手机号为{2}", "30", vipInfo.VipCode, vipInfo.Phone); string msgData = "<xml><OpenID><![CDATA[" + vipInfo.WeiXinUserId + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>"; var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); #region 发送日志 MarketSendLogBLL logServer = new MarketSendLogBLL(CurrentUserInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.IsSuccess = 1; logInfo.MarketEventId = orderId; logInfo.SendTypeId = "2"; logInfo.TemplateContent = msgData; logInfo.VipId = vipInfo.VIPID; logInfo.WeiXinUserId = vipInfo.WeiXinUserId; logInfo.CreateTime = System.DateTime.Now; logServer.Create(logInfo); #endregion } strError = ""; return(true); } catch (Exception ex) { strError = ex.ToString(); return(false); } }
/// <summary> /// 获取Access Token /// </summary> /// <param name="code"></param> private void GetAccessToken(string code) { MarketSendLogBLL sendServer = new MarketSendLogBLL(loggingSessionInfo); MarketSendLogEntity sendInfo = new MarketSendLogEntity(); Random rad = new Random(); int iRad = rad.Next(1000, 100000); try { sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 1; sendInfo.MarketEventId = "GetAccessToken"; sendInfo.SendTypeId = "220"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = "GetAccessToken:code:" + code + ",strAppId:" + strAppId + ",strAppSecret:" + strAppSecret; sendInfo.VipId = code; sendInfo.WeiXinUserId = "1111"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); var sendObjList = sendServer.QueryByEntity(new MarketSendLogEntity { VipId = code , WeiXinUserId = "AccessToken" , IsDelete = 0 }, null); string data = string.Empty; if (sendObjList == null || sendObjList.Length == 0 || sendObjList[0] == null) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3; string url = "https://api.weixin.qq.com/sns/oauth2/access_token"; WebClient myWebClient = new WebClient(); // 注意这种拼字符串的ContentType myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); // 转化成二进制数组 var postData = "appid=" + strAppId + "&secret=" + strAppSecret + "&code=" + code + "&grant_type=authorization_code"; sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 1; sendInfo.MarketEventId = "GetAccessToken转化成二进制数组"; sendInfo.SendTypeId = "220"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("{0}", postData); sendInfo.VipId = code; sendInfo.WeiXinUserId = "AccessToken-Para"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); byte[] byteArray = Encoding.UTF8.GetBytes(postData); // 上传数据,并获取返回的二进制数据. byte[] responseArray = myWebClient.UploadData(url, "POST", byteArray); data = System.Text.Encoding.UTF8.GetString(responseArray); if (data.IndexOf("errcode") > 1) { var sendObjList1 = sendServer.QueryByEntity(new MarketSendLogEntity { VipId = code , WeiXinUserId = "AccessToken" , IsDelete = 0 , IsSuccess = 1 }, null); if (sendObjList1 == null || sendObjList1.Length == 0 || sendObjList1[0] == null) { } else { data = sendObjList1[0].TemplateContent.ToString().Trim(); } } sendInfo.LogId = BaseService.NewGuidPub(); if (data.IndexOf("errcode") > 1) { sendInfo.IsSuccess = 0; } else { sendInfo.IsSuccess = 1; } sendInfo.MarketEventId = "GetAccessToken-3"; sendInfo.SendTypeId = "220"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("{0}", data); sendInfo.VipId = code; sendInfo.WeiXinUserId = "AccessToken"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); } else { data = sendObjList[0].TemplateContent.ToString().Trim(); sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 1; sendInfo.MarketEventId = "GetAccessToken-3-2"; sendInfo.SendTypeId = "220"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("{0}", data); sendInfo.VipId = code; sendInfo.WeiXinUserId = "AccessToken--重复2"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); } var tokenInfo = data.DeserializeJSONTo <cAccessTokenReturn>(); //Response.Write("<br/>"); //Response.Write("获取Access Token"); if (tokenInfo != null) { //Response.Write("<br/>"); //Response.Write("获取Access Token不为空"); GetUserIdByOpenId(tokenInfo.openid); } Loggers.Debug(new DebugLogInfo() { Message = string.Format("GetAccessToken: {0}", data) }); } catch (Exception ex) { Loggers.Exception(new ExceptionLogInfo() { ErrorMessage = string.Format("GetAccessToken错误: {0}", ex.ToString()) }); Response.Write("向微信请求认证Access Token出错,请联系管理员尽快处理."); sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 0; sendInfo.MarketEventId = "向微信请求认证Access Token出错"; sendInfo.SendTypeId = "200"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("GetAccessToken错误: {0}", ex.ToString()); sendInfo.VipId = code; sendInfo.WeiXinUserId = "1111"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); Response.End(); } }
public void PushWeiXin(string OpenId, LoggingSessionInfo loggingSessionInfo, string OrderId, string VipId) { string webUrl = ConfigurationManager.AppSettings["website_url"]; string msgUrl = ConfigurationManager.AppSettings["push_weixin_msg_url"];; Random rad = new Random(); string msgText = "<a href='" + webUrl + "wap/Event/20131109/aboutEvent.htm'>点击查看本次活动议程</a>"; string msgData = "<xml><OpenID><![CDATA[" + OpenId + "]]></OpenID>" + "<Content><![CDATA[" + msgText + "]]></Content></xml>"; //var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); #region 发送日志 MarketSendLogBLL logServer = new MarketSendLogBLL(loggingSessionInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.IsSuccess = 1; logInfo.MarketEventId = OrderId; logInfo.SendTypeId = "2"; logInfo.TemplateContent = msgData; logInfo.VipId = VipId; logInfo.WeiXinUserId = OpenId; logInfo.CreateTime = System.DateTime.Now; logServer.Create(logInfo); #endregion #region msgText = "亲爱的,为答谢您参加本次活动,主办方推出多个奖品的刮刮卡等你来刮,快来试试运气,<a href='" + webUrl + "OnlineClothing/1109guagua.html?customerId=" + loggingSessionInfo.CurrentUser.customer_id + "&userId=" + VipId + "&openId=" + OpenId + "&eventId=" + OrderId + "'>点击试试手气</a>"; //msgData = "<xml><OpenID><![CDATA[" + OpenId + "]]></OpenID>" // + "<Content><![CDATA[" + msgText + "]]></Content></xml>"; LEventsBLL eventServer = new LEventsBLL(loggingSessionInfo); LEventsEntity eventInfo = new LEventsEntity(); eventInfo = eventServer.GetByID(OrderId); if (eventInfo != null && eventInfo.EventID != null) { string picUrl1 = eventInfo.Content; string Url1 = "" + webUrl + "OnlineClothing/1109guagua.html?customerId=" + loggingSessionInfo.CurrentUser.customer_id + "&userId=" + VipId + "&openId=" + OpenId + "&eventId=" + OrderId + ""; msgData = "<xml>" + "<OpenID><![CDATA[" + OpenId + "]]></OpenID>" + "<MsgType><![CDATA[news]]></MsgType>" + "<Articles>" + "<item>" + "<Title><![CDATA[活动刮刮卡,惊喜享不停!]]></Title> " + "<Description><![CDATA[亲!为答谢您来参加本次活动,我们特别推出刮刮卡,大量精美奖品等你来取,快来试试运气吧。]]></Description> " + "<Url><![CDATA[" + Url1 + "]]></Url> " + "<PicUrl><![CDATA[" + picUrl1 + "]]></PicUrl> " + "</item>" + "</Articles>" + "</xml>"; var msgResult1 = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); } #endregion #region 发送日志 MarketSendLogEntity logInfo1 = new MarketSendLogEntity(); logInfo1.LogId = BaseService.NewGuidPub(); logInfo1.IsSuccess = 1; logInfo1.MarketEventId = OrderId; logInfo1.SendTypeId = "2"; logInfo1.TemplateContent = msgData; logInfo1.VipId = VipId; logInfo1.WeiXinUserId = OpenId; logInfo1.CreateTime = System.DateTime.Now; logServer.Create(logInfo1); #endregion }
public static void WXLocation(HttpContext httpContext, CommonBLL commonService, RequestParams requestParams, string locationX, string locationY) { WMenuDAO wMenuDAO = new WMenuDAO(requestParams.LoggingSessionInfo); var custId = wMenuDAO.GetCustomerIdByWx(requestParams.WeixinId); if (requestParams.LoggingSessionInfo.CurrentUser == null) { requestParams.LoggingSessionInfo.CurrentUser = new Entity.User.UserInfo(); } requestParams.LoggingSessionInfo.CurrentUser.customer_id = custId; BaseService.WriteLogWeixin("customerId:---------------" + custId); BaseService.WriteLogWeixin("openID:---------------" + requestParams.OpenId); BaseService.WriteLogWeixin("weixinID:---------------" + requestParams.WeixinId); string HandlerLocation_xyds = ConfigurationManager.AppSettings["HandlerLocation_xyds"]; BaseService.WriteLogWeixin("HandlerLocation_xyds:---------------" + HandlerLocation_xyds); if (HandlerLocation_xyds != null && HandlerLocation_xyds.Length > 0 && HandlerLocation_xyds.Contains(requestParams.WeixinId)) { BaseService.WriteLogWeixin("xyds:---------------"); VipBLL server = new VipBLL(requestParams.LoggingSessionInfo); var vipInfo = server.SearchVipInfoLocation(new VipSearchEntity() { RoleCode = "CampusAmbassadors", Longitude = locationY, Latitude = locationX, OrderBy = " a.Distance asc ", Page = 1, PageSize = 1, }); if (vipInfo != null && vipInfo.vipInfoList != null && vipInfo.vipInfoList.Count > 0) { var vip = vipInfo.vipInfoList[0]; if (vip != null) { var content = ""; content += "目前离你最近的校园产品专家是{0},电话:{1},{2},距离{3}米。如有任何疑问也可直接回复消息与我们联系,我们将尽快答复。"; content = string.Format( content, vip.VipName, vip.Phone, vip.DeliveryAddress, vip.Distance * 1000 ); BaseService.WriteLogWeixin("发送微信消息:---------------"); commonService.ResponseTextMessage(requestParams.WeixinId, requestParams.OpenId, content, httpContext, requestParams); BaseService.WriteLogWeixin("发送微信消息完成:---------------"); MarketSendLogBLL marketSendLogBLL = new BLL.MarketSendLogBLL(requestParams.LoggingSessionInfo); var logObj = new MarketSendLogEntity() { LogId = Common.Utils.NewGuid(), VipId = vip.VIPID, MarketEventId = "华硕校园大使推介活动", TemplateContent = content, SendTypeId = "1", WeiXinUserId = vip.WeiXinUserId, Phone = vip.Phone, IsSuccess = 0 }; marketSendLogBLL.Create(logObj); VipVipMappingBLL vipVipMappingBLL = new VipVipMappingBLL(requestParams.LoggingSessionInfo); var vipMapObj = new VipVipMappingEntity() { MappingId = Guid.NewGuid(), VipIdSrc = vip.VIPID, VipIdDst = requestParams.OpenId }; vipVipMappingBLL.Create(vipMapObj); logObj.IsSuccess = 1; marketSendLogBLL.Update(logObj, false); } } } else { string strError = ""; StoreBrandMappingBLL server = new StoreBrandMappingBLL(requestParams.LoggingSessionInfo); var storeInfo = server.GetStoreListByItem(null , 1 , 10 , locationY , locationX , out strError); if (storeInfo != null && storeInfo.StoreBrandList != null && storeInfo.StoreBrandList.Count > 0) { var newsList = new List <WMaterialTextEntity>(); var original_url = ConfigurationManager.AppSettings["website_WWW"].ToString(); if (!original_url.EndsWith("/")) { original_url += "/"; } foreach (var store in storeInfo.StoreBrandList) { var url = original_url + "HtmlApps/Auth.html?pageName=Map&customerId=" + requestParams.LoggingSessionInfo.CurrentUser.customer_id; url += "&lng=" + store.Longitude + "&lat=" + store.Latitude; url += "&storeId=" + store.StoreId; url += "&addr=" + HttpUtility.UrlEncode(store.Address); url += "&store=" + HttpUtility.UrlEncode(store.StoreName); #region 分享业务 链接后面加上openId和userId //if (url.IndexOf("ParAll=") != -1) //{ // var vipId = string.Empty; // VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo); // var vipEntity = vipService.QueryByEntity(new VipEntity { WeiXinUserId = requestParams.OpenId, WeiXin = requestParams.WeixinId }, null); // if (vipEntity != null && vipEntity.Length > 0) // { // vipId = vipEntity.FirstOrDefault().VIPID; // } // url += "&openId=" + requestParams.OpenId + "&userId=" + vipId; //} #endregion newsList.Add(new WMaterialTextEntity() { Title = store.StoreName + "(" + store.Distance.ToString("f1") + "公里)", // Title Text = store.StoreName + "(" + store.Distance.ToString("f1") + "公里)", // Author CoverImageUrl = store.ImageUrl, // CoverImageUrl OriginalUrl = url }); } commonService.ResponseNewsMessage(requestParams.WeixinId, requestParams.OpenId, newsList, httpContext, requestParams); } } }
/// <summary> /// 第二步:通过code换取网页授权access_token /// </summary> /// <param name="code">填写第一步获取的code参数</param> /// <param name="strAppId">公众号的唯一标识</param> /// <param name="strAppSecret">公众号的appsecret</param> /// <param name="loggingSessionInfo"></param> /// <param name="iRad"></param> /// <returns></returns> public string GetAccessToken(string code, string strAppId, string strAppSecret, LoggingSessionInfo loggingSessionInfo, int iRad, out string token, string openOAuthAppid = null) { MarketSendLogBLL sendServer = new MarketSendLogBLL(loggingSessionInfo); MarketSendLogEntity sendInfo = new MarketSendLogEntity(); //Random rad = new Random(); //int iRad = rad.Next(1000, 100000); try { sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 1; sendInfo.MarketEventId = "GetAccessToken-1"; sendInfo.SendTypeId = "200"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = "GetAccessToken:code:" + code + ",strAppId:" + strAppId + ",strAppSecret:" + strAppSecret; sendInfo.VipId = code; sendInfo.WeiXinUserId = "1111"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); var sendObjList = sendServer.QueryByEntity(new MarketSendLogEntity { VipId = code , WeiXinUserId = "AccessToken" , IsDelete = 0 }, null); string data = string.Empty; if (sendObjList == null || sendObjList.Length == 0 || sendObjList[0] == null) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3; string url = "https://api.weixin.qq.com/sns/oauth2/access_token"; WebClient myWebClient = new WebClient(); // 注意这种拼字符串的ContentType myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); // 转化成二进制数组 var postData = string.Empty; if (string.IsNullOrEmpty(strAppSecret))//已登录授权了 { if (string.IsNullOrEmpty(openOAuthAppid)) { var wailist = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity { AppID = strAppId, CustomerId = loggingSessionInfo.ClientID }, null).FirstOrDefault(); openOAuthAppid = wailist != null ? wailist.OpenOAuthAppid : string.Empty; } //openOAuthAppid = !string.IsNullOrEmpty(openOAuthAppid) ? openOAuthAppid : "wx691c2f2bbac04b4b"; var openOAuthUrl = ConfigurationManager.AppSettings["openOAuthUrl"]; var openuri = openOAuthUrl + "/OpenOAuth/GetComponentAccessToken"; var opendata = CommonBLL.GetRemoteData(openuri, "GET", string.Empty).Replace("\"", "");//先获取第三方平台的component_access_token var url2 = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=" + strAppId + "&code=" + code + "&grant_type=authorization_code&component_appid=" + openOAuthAppid + "&component_access_token=" + opendata + ""; opendata = CommonBLL.GetRemoteData(url2, "GET", string.Empty); data = opendata; } else//未授权的情况下 { postData = "appid=" + strAppId + "&secret=" + strAppSecret + "&code=" + code + "&grant_type=authorization_code"; sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 1; sendInfo.MarketEventId = "GetAccessToken-2"; sendInfo.SendTypeId = "200"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("{0}", postData); sendInfo.VipId = code; sendInfo.WeiXinUserId = "GetAccessToken-Para"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); byte[] byteArray = Encoding.UTF8.GetBytes(postData); // 上传数据,并获取返回的二进制数据. byte[] responseArray = myWebClient.UploadData(url, "POST", byteArray); data = System.Text.Encoding.UTF8.GetString(responseArray); } if (data.IndexOf("errcode") > 1) { var sendObjList1 = sendServer.QueryByEntity(new MarketSendLogEntity { VipId = code , WeiXinUserId = "AccessToken" , IsDelete = 0 , IsSuccess = 1 }, null); if (sendObjList1 == null || sendObjList1.Length == 0 || sendObjList1[0] == null) { } else { data = sendObjList1[0].TemplateContent.ToString().Trim(); } } sendInfo.LogId = BaseService.NewGuidPub(); if (data.IndexOf("errcode") > 1) { sendInfo.IsSuccess = 0; } else { sendInfo.IsSuccess = 1; } sendInfo.MarketEventId = "GetAccessToken-3"; sendInfo.SendTypeId = "200"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("{0}", data); sendInfo.VipId = code; sendInfo.WeiXinUserId = "AccessToken"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); } else { data = sendObjList[0].TemplateContent.ToString().Trim(); sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 1; sendInfo.MarketEventId = "GetAccessToken-3-2"; sendInfo.SendTypeId = "200"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("{0}", data); sendInfo.VipId = code; sendInfo.WeiXinUserId = "AccessToken--重复2"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); } var tokenInfo = data.DeserializeJSONTo <cAccessTokenReturn>(); //Response.Write("<br/>"); //Response.Write("获取Access Token"); token = ""; if (tokenInfo != null) { //Response.Write("<br/>"); //Response.Write("获取Access Token不为空"); token = tokenInfo.access_token; return(tokenInfo.openid); } else { return(""); } Loggers.Debug(new DebugLogInfo() { Message = string.Format("GetAccessToken: {0}", data) }); //Response.Write(data); } catch (Exception ex) { Loggers.Debug(new DebugLogInfo() { Message = string.Format("GetAccessToken错误: {0}", ex.ToString()) }); sendInfo.LogId = BaseService.NewGuidPub(); sendInfo.IsSuccess = 0; sendInfo.MarketEventId = "GetAccessToken-4"; sendInfo.SendTypeId = "200"; sendInfo.Phone = iRad.ToString(); sendInfo.TemplateContent = string.Format("GetAccessToken错误: {0}", ex.ToString()); sendInfo.VipId = code; sendInfo.WeiXinUserId = "1111"; sendInfo.CreateTime = System.DateTime.Now; sendServer.Create(sendInfo); token = ""; return(""); } }
public void Update(MarketSendLogEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran) { _currentDAO.Update(pEntity, pIsUpdateNullField, pTran); }
/// <summary> /// 创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> public void Create(MarketSendLogEntity pEntity) { _currentDAO.Create(pEntity); }
/// <summary> /// 在事务内创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Create(MarketSendLogEntity pEntity, IDbTransaction pTran) { _currentDAO.Create(pEntity, pTran); }
/// <summary> /// 根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public MarketSendLogEntity[] QueryByEntity(MarketSendLogEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <MarketSendLogEntity> PagedQueryByEntity(MarketSendLogEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex) { return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex)); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(MarketSendLogEntity pEntity) { _currentDAO.Delete(pEntity); }
public void Update(MarketSendLogEntity pEntity, bool pIsUpdateNullField) { _currentDAO.Update(pEntity, pIsUpdateNullField); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> public void Update(MarketSendLogEntity pEntity) { Update(pEntity, true); }
public bool SetEventWXPush(LEventsEntity eventInfo, string WeiXin, string OpenId, string VipId, string msgUrl, out string strError, string AuthUrl, int iRad) { try { MarketSendLogBLL logServer = new MarketSendLogBLL(this.CurrentUserInfo); Random rad = new Random(); if (eventInfo == null || eventInfo.ModelId == null || eventInfo.ModelId.Equals("")) { strError = "获取信息不全,缺少模板。"; return(false); } #region WEventUserMappingBLL eventUserMapping = new WEventUserMappingBLL(CurrentUserInfo); int eventPersonCount = 0; eventPersonCount = eventUserMapping.GetEventSignInCount(eventInfo.EventID); #endregion WApplicationInterfaceBLL wAServer = new WApplicationInterfaceBLL(this.CurrentUserInfo); var wxArray = wAServer.QueryByEntity(new WApplicationInterfaceEntity { WeiXinID = WeiXin , IsDelete = 0 , CustomerId = this.CurrentUserInfo.CurrentUser.customer_id }, null); if (wxArray == null || wxArray.Length == 0 || wxArray[0].AppID == null || wxArray[0].AppID.Equals("")) { strError = "不存在对应的微信帐号"; return(false); } else { WApplicationInterfaceEntity wxInfo = wxArray[0]; WX.CommonBLL server = new WX.CommonBLL(); JIT.CPOS.BS.Entity.WX.SendMessageEntity sendMessageInfo = new Entity.WX.SendMessageEntity(); WMaterialTextBLL wTextServer = new WMaterialTextBLL(this.CurrentUserInfo); IList <WMaterialTextEntity> textlist = new List <WMaterialTextEntity>(); textlist = wTextServer.GetMaterialTextListByModelId(eventInfo.ModelId); if (textlist != null && textlist.Count > 0 && textlist[0].TextId != null) { #region VipBLL vipServer = new VipBLL(CurrentUserInfo); VipEntity vipInfo = vipServer.GetByID(VipId); sendMessageInfo.msgtype = "news"; sendMessageInfo.touser = OpenId; List <JIT.CPOS.BS.Entity.WX.NewsEntity> newsList = new List <JIT.CPOS.BS.Entity.WX.NewsEntity>(); foreach (var info in textlist) { JIT.CPOS.BS.Entity.WX.NewsEntity newsInfo = new Entity.WX.NewsEntity(); newsInfo.title = info.Title; if (vipInfo != null && !vipInfo.VIPID.Equals("")) { newsInfo.description = info.Author.Replace("#VIPNAME#", vipInfo.VipName); } else { newsInfo.description = info.Author; } newsInfo.description = newsInfo.description.Replace("#PERSONCOUNT#", Convert.ToString(eventPersonCount)); //string url = info.OriginalUrl; //JIT.Utility.Log.Loggers.Debug(new DebugLogInfo() //{ // Message = string.Format("处理原文链接出错:{0},url:{1};Status:{2};",) //}); if (info.OriginalUrl != null && !info.OriginalUrl.Equals("") && vipInfo.Status != null && !vipInfo.Status.ToString().Equals("")) { if (vipInfo.Status.Equals(1) && info.OriginalUrl.IndexOf("Fuxing") > 0) { newsInfo.description = info.Text; } else { } } if (info.OriginalUrl.IndexOf("?") > 0) { newsInfo.url = info.OriginalUrl + "&rnd=" + rad.Next(1000, 100000) + ""; } else { string goUrl = info.OriginalUrl + "?1=1&applicationId=" + wxInfo.ApplicationId + "&eventId=" + eventInfo.EventID + "&openId=" + OpenId + "&userId=" + VipId + ""; goUrl = HttpUtility.UrlEncode(goUrl); newsInfo.url = AuthUrl + "OnlineClothing/go.htm?customerId=" + this.CurrentUserInfo.CurrentUser.customer_id + "&applicationId=" + wxInfo.ApplicationId + "&openId=" + OpenId + "&userId=" + VipId + "&backUrl=" + goUrl + ""; } //OnlineClothing/go.htm?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + ""; newsInfo.picurl = info.CoverImageUrl; newsList.Add(newsInfo); } sendMessageInfo.articles = newsList; #endregion #region 发送日志 MarketSendLogEntity logInfo1 = new MarketSendLogEntity(); logInfo1.LogId = BaseService.NewGuidPub(); logInfo1.IsSuccess = 1; logInfo1.MarketEventId = eventInfo.EventID; logInfo1.SendTypeId = "2"; logInfo1.Phone = iRad.ToString(); if (sendMessageInfo.ToJSON().ToString().Length > 2000) { logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString().Substring(1, 1999); } else { logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString(); } logInfo1.VipId = VipId; logInfo1.WeiXinUserId = OpenId; logInfo1.CreateTime = System.DateTime.Now; logServer.Create(logInfo1); #endregion } var ResultEntity = server.SendMessage(sendMessageInfo, wxInfo.AppID, wxInfo.AppSecret, this.CurrentUserInfo, true); #region Jermyn20140110 处理复星年会的座位信息,是临时的 //FStaffBLL staffServer = new FStaffBLL(this.CurrentUserInfo); //bool bReturn = staffServer.SetStaffSeatsPush(VipId, eventInfo.EventID, out strError); //MarketSendLogEntity logInfo2 = new MarketSendLogEntity(); //logInfo2.LogId = BaseService.NewGuidPub(); //logInfo2.IsSuccess = 1; //logInfo2.MarketEventId = eventInfo.EventID; //logInfo2.SendTypeId = "2"; //logInfo2.TemplateContent = strError; //logInfo2.Phone = iRad.ToString(); //logInfo2.VipId = VipId; //logInfo2.WeiXinUserId = OpenId; //logInfo2.CreateTime = System.DateTime.Now; //logServer.Create(logInfo2); #endregion strError = "ok"; return(true); } } catch (Exception ex) { strError = ex.ToString(); return(false); } }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(MarketSendLogEntity pEntity, IDbTransaction pTran) { Update(pEntity, true, pTran); }
/// <summary> /// 主动给用户推送订单消息 /// </summary> /// <returns></returns> public string SetOrderPush() { var respData = new RespData(); if (string.IsNullOrEmpty(Request["WeiXinId"]) || string.IsNullOrEmpty(Request["OpenId"]) || string.IsNullOrEmpty(Request["OrdeNo"])) { respData.Code = "103"; respData.Description = "数据库操作错误"; respData.Exception = "请求的数据不能为空"; return(respData.ToJSON()); } string content = string.Empty; try { string vipID = string.Empty; string vipName = string.Empty; var loggingSessionInfo = Default.GetLjLoggingSession(); //根据客户标识获取连接字符串 qianzhi 2013-07-30 if (!string.IsNullOrEmpty(Request["customerId"])) { loggingSessionInfo = Default.GetBSLoggingSession(Request["customerId"].Trim(), ""); } #region 获取VIP信息 VipBLL vipService = new VipBLL(loggingSessionInfo); var vipList = vipService.QueryByEntity(new VipEntity() { WeiXinUserId = Request["OpenId"], WeiXin = Request["WeiXinId"] }, null); if (vipList == null || vipList.Length == 0) { respData.Code = "103"; respData.Description = "未查找到匹配的VIP信息"; return(respData.ToJSON()); } else { vipID = vipList.FirstOrDefault().VIPID; vipName = vipList.FirstOrDefault().VipName; } #endregion // 推送消息 string msgUrl = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim(); string msgText = string.Format("亲爱的会员{1},您单号为{0}的购买请求我们已经收到,请您到指定渠道下交纳钱款。谢谢再次惠顾!", Request["OrdeNo"], vipName); string msgData = "<xml><OpenID><![CDATA[" + Request["OpenId"] + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>"; var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); #region 发送日志 MarketSendLogBLL logServer = new MarketSendLogBLL(loggingSessionInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.IsSuccess = 1; logInfo.MarketEventId = Request["OrdeNo"]; logInfo.SendTypeId = "2"; logInfo.TemplateContent = msgData; logInfo.VipId = vipID; logInfo.WeiXinUserId = Request["OpenId"]; logInfo.CreateTime = System.DateTime.Now; logServer.Create(logInfo); #endregion Loggers.Debug(new DebugLogInfo() { Message = string.Format("PushMsgResult:{0}", msgResult) }); } catch (Exception ex) { respData.Code = "201"; respData.Description = "操作失败"; respData.Exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
/// <summary> /// 订单支付成功修改状态 /// </summary> /// <param name="orderId">订单标识</param> /// <param name="strError">错误提示</param> /// <param name="ChannelId">支付渠道标识</param> /// <returns></returns> public bool SetOrderPayment(string orderId, out string strError, string ChannelId = null, string SerialPay = null) //public bool SetOrderPayment(string orderId, out string strError, string ChannelId = null) { MarketSendLogBLL logSerer = new MarketSendLogBLL(this.CurrentUserInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.VipId = "System"; logInfo.MarketEventId = orderId; logInfo.Phone = ChannelId; logInfo.SendTypeId = "3"; try { bool bReturn = this._currentDAO.SetOrderPayment(orderId, out strError, ChannelId); if (bReturn) { //算积分 //var bll = new JIT.CPOS.BS.BLL.InoutService(this.CurrentUserInfo); //var orderInfo = bll.GetInoutInfoById(orderId); //VipIntegralBLL vipIntegralServer = new VipIntegralBLL(this.CurrentUserInfo); //Loggers.Debug(new DebugLogInfo() //{ // Message = string.Format("SetOrderPayment-参数: sourceId={0},customerId={1},vipId={2},orderId={3}", 1, this.CurrentUserInfo.CurrentUser.customer_id, orderInfo.vip_no, orderId) //}); //vipIntegralServer.ProcessPoint(1, this.CurrentUserInfo.CurrentUser.customer_id, orderInfo.vip_no, orderId); this._currentDAO.OrderPayCallBack(orderId, SerialPay, this.CurrentUserInfo.ClientID, Convert.ToInt32(ChannelId)); strError = "成功."; logInfo.TemplateContent = strError; logSerer.Create(logInfo); //记录日志 qianzhi 2014-03-17 //var inoutStatus = new TInoutStatusBLL(CurrentUserInfo); //TInoutStatusEntity info = new TInoutStatusEntity(); //info.InoutStatusID = Guid.Parse(Utils.NewGuid()); //info.OrderID = orderId; //info.CustomerID = CurrentUserInfo.CurrentLoggingManager.Customer_Id; //info.OrderStatus = 10000; //支付方式 //info.Remark = "支付成功"; //info.StatusRemark = "订单支付成功[操作人:" + CurrentUserInfo.CurrentUser.User_Name + "]"; //inoutStatus.Create(info); T_InoutBLL inoutBLL = new T_InoutBLL(this.CurrentUserInfo); inoutBLL.SetVirtualItem(CurrentUserInfo, orderId); //支付回调/收款处理虚拟商品订单 return(true); } return(bReturn); } catch (Exception ex) { strError = ex.ToString(); Loggers.Debug(new DebugLogInfo() { Message = string.Format("SetOrderPayment-失败: {0}", strError) }); logInfo.TemplateContent = strError.Substring(0, 100); logInfo.IsSuccess = 0; logSerer.Create(logInfo); return(false); } }