private ReturnValue SendSystemNoticeToPersonals(SystemNotice systemNotice, string personals) { BLLJIMP.BLLUser bllUser = new BLLUser(""); BLLJIMP.BLLWeixin bllWeixin = new BLLWeixin(""); BLLWeixin.TMTaskNotification notificaiton = new BLLWeixin.TMTaskNotification(); notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/SystemMessageBox.aspx", System.Web.HttpContext.Current.Request.Url.Host); var accessToken = bllWeixin.GetAccessToken(); string[] userArray = personals.Split(','); int successCount = 0; foreach (string userId in userArray) { successCount += SendSystemNoticeToUserId(systemNotice, userId) ? 1 : 0; try { notificaiton.First = "您好,您有新系统消息"; notificaiton.Keyword1 = systemNotice.Title; notificaiton.Keyword2 = systemNotice.NoticeTypeString; notificaiton.Remark = "点击查看"; bllWeixin.SendTemplateMessage(accessToken, bllUser.GetUserInfo(userId).WXOpenId, notificaiton); } catch (Exception) { continue; } } return(new ReturnValue { Code = 0, Msg = string.Format("成功将消息发送到{0}个人.", successCount) }); }
/// <summary> ///客服接口 群发 /// </summary> /// <param name="timingTask"></param> /// <returns></returns> public bool SendImageTextMessage(TimingTask timingTask) { BLLWeixin bllWeixin = new BLLWeixin(""); List <BLLWeixin.WeiXinArticle> articleList = new List <BLLWeixin.WeiXinArticle>(); string[] idarray = timingTask.TaskInfo.Split(','); foreach (string id in idarray) { WeixinMsgSourceInfo msg = bllWeixin.Get <WeixinMsgSourceInfo>(string.Format("SourceID={0}", id)); articleList.Add(new BLLWeixin.WeiXinArticle() { Title = msg.Title, Description = msg.Description, Url = msg.Url, PicUrl = msg.PicUrl }); } switch ((ReceiverType)timingTask.ReceiverType) { case ReceiverType.All: bllWeixin.BroadcastKeFuMessageImageText(timingTask.WebsiteOwner, articleList, timingTask.TaskInfo); return(true); case ReceiverType.Group: return(false); case ReceiverType.List: string[] openidArray = timingTask.Receivers.Split(','); foreach (string openid in openidArray) { bllWeixin.SendKeFuMessageImageText(bllWeixin.GetAccessToken(timingTask.WebsiteOwner), openid, articleList); } return(openidArray.Length > 0); default: return(false); } }
private ReturnValue SendSystemNoticeToAll(SystemNotice systemNotice, string websiteOwner) { BLLJIMP.BLLWeixin bllWeixin = new BLLWeixin(""); BLLWeixin.TMTaskNotification notificaiton = new BLLWeixin.TMTaskNotification(); notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/SystemMessageBox.aspx", System.Web.HttpContext.Current.Request.Url.Host); var acctoken = bllWeixin.GetAccessToken(); List <UserInfo> userList = new List <UserInfo>(); if (WebsiteOwner.Equals("wubuhui")) { userList = this.GetList <UserInfo>(string.Format("WebsiteOwner='{0}' and Phone is not null and Phone <>''", websiteOwner)); } else { userList = this.GetList <UserInfo>(string.Format("WebsiteOwner='{0}'", websiteOwner)); } int successCount = 0; foreach (UserInfo uinfo in userList) { successCount += SendSystemNoticeToUserId(systemNotice, uinfo.UserID) ? 1 : 0; try { notificaiton.First = "您好,您有新系统消息"; notificaiton.Keyword1 = systemNotice.Title; notificaiton.Keyword2 = systemNotice.NoticeTypeString; notificaiton.Remark = "点击查看"; bllWeixin.SendTemplateMessage(acctoken, uinfo.WXOpenId, notificaiton); } catch (Exception) { continue; } } return(new ReturnValue { Code = 0, Msg = string.Format("成功将消息发送到{0}个人.", successCount) }); }
private ReturnValue SendSystemNoticeToGroups(SystemNotice systemNotice, string groups, string websiteOwner) { BLLJIMP.BLLWeixin bllWeixin = new BLLWeixin(""); BLLWeixin.TMTaskNotification notificaiton = new BLLWeixin.TMTaskNotification(); notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/SystemMessageBox.aspx", System.Web.HttpContext.Current.Request.Url.Host); var acctoken = bllWeixin.GetAccessToken(); string[] groupArray = groups.Split(','); string strWhere = string.Format("TagName like '%{0}%'", groupArray[0].Trim()); foreach (string group in groupArray) { strWhere += string.Format(" or TagName like '%{0}%'", group); } List <UserInfo> userList = this.GetList <UserInfo>(string.Format("WebsiteOwner='{0}' and ({1})", websiteOwner, strWhere)); int successCount = 0; foreach (UserInfo uinfo in userList) { successCount += SendSystemNoticeToUserId(systemNotice, uinfo.UserID) ? 1 : 0; try { notificaiton.First = "您好,您有新系统消息"; notificaiton.Keyword1 = systemNotice.Title; notificaiton.Keyword2 = systemNotice.NoticeTypeString; notificaiton.Remark = "点击查看"; bllWeixin.SendTemplateMessage(acctoken, uinfo.WXOpenId, notificaiton); } catch (Exception) { continue; } } return(new ReturnValue { Code = 0, Msg = string.Format("成功将消息发送到{0}个人.", successCount) }); }
public static string SendTMUserScoreDailyAccountBillNotify(string receiverUserId, string websiteOwner) { BLLWeixin bllWeixin = new BLLWeixin(""); BLLWeixin.TMScoreNotification notificaiton = new BLLWeixin.TMScoreNotification(); notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/Index.aspx", System.Web.HttpContext.Current.Request.Url.Host); notificaiton.TemplateId = "8JLCEV3HmIYV3C3bDiGARxRBJqAZosnQEOI4C0d5He4"; notificaiton.First = "您今日的积分对账单,详情如下"; notificaiton.Account = "积分账户"; notificaiton.Time = DateTime.Now.ToString(); notificaiton.Type = "每日积分对账单"; //notificaiton.CreditChange = "每日积分对账单"; UserInfo userInfo = bllWeixin.Get <UserInfo>(string.Format("UserId='{0}' and WebsiteOwner='{1}'", receiverUserId, websiteOwner)); if (userInfo == null) { return(string.Format("用户 {0} 不存在", receiverUserId)); } notificaiton.Number = userInfo.TotalScore.ToString(); notificaiton.Amount = userInfo.TotalScore.ToString(); notificaiton.Remark = "您可以点击下方菜单进入五步会,赚取更多积分!"; return(bllWeixin.SendTemplateMessage(bllWeixin.GetAccessToken(), userInfo.WXOpenId, notificaiton)); }
/// <summary> /// 新分销会员通知 /// </summary> /// <param name="messageInfo"></param> /// <param name="ramark"></param> /// <param name="errMsg"></param> public void DistNewMemberNotice(MessageInfo messageInfo, out string ramark, out string errMsg) { Console.WriteLine("正在处理新分销会员通知"); BLLUserDistributionMember bllUserDistributionMember = new BLLUserDistributionMember(); BLLUser bllUser = new BLLUser(); BLLWeixin bllWeixin = new BLLWeixin(); ramark = ""; errMsg = ""; var msgBody = JsonConvert.DeserializeObject <Model.MQ.DistNewMemberNoticeInfo>(messageInfo.Msg); Console.WriteLine("转换完msgBody"); //获取分销员和会员 var distUser = bllUser.GetUserInfoByAutoID(int.Parse(msgBody.DistributionOwnerAutoId), messageInfo.WebsiteOwner); var member = bllUser.GetUserInfoByAutoID(int.Parse(msgBody.MemberAutoId), messageInfo.WebsiteOwner); //记录到会员表 bllUserDistributionMember.SetUserDistributionOwnerInMember(new List <string>() { member.UserID }, distUser.UserID, member.WebsiteOwner); //获取当前是第几位会员 var rowCount = bllUserDistributionMember.GetMemberRowCount(member.UserID, distUser.UserID, member.WebsiteOwner); Console.WriteLine("排名:" + rowCount); //获取会员昵称 if (string.IsNullOrWhiteSpace(member.WXNickname) && !string.IsNullOrWhiteSpace(member.WXOpenId)) { Console.WriteLine("无微信昵称,开始获取微信昵称"); var accessToken = bllWeixin.GetAccessToken(messageInfo.WebsiteOwner); if (!string.IsNullOrEmpty(accessToken)) { Console.WriteLine("获取到accessToken,开始获取会员信息"); var wxUserInfo = bllWeixin.GetWeixinUserInfo(accessToken, member.WXOpenId); Console.WriteLine("处理完获取会员信息"); if (wxUserInfo != null) { Console.WriteLine("获取到会员信息"); member.WXHeadimgurl = wxUserInfo.headimgurl; member.WXNickname = string.IsNullOrWhiteSpace(wxUserInfo.nickname) ? "" : wxUserInfo.nickname.Replace("'", ""); member.WXProvince = wxUserInfo.province; member.WXCity = wxUserInfo.city; bllUser.Update(new UserInfo(), string.Format(" WXHeadimgurl='{0}',WXNickname='{1}',WXProvince='{2}',WXCity='{3}' ", member.WXHeadimgurl, member.WXNickname, member.WXProvince, member.WXCity ), string.Format(" UserId = '{0}' AND WebsiteOwner = '{1}' ", member.UserID, member.WebsiteOwner)); } else { Console.WriteLine("获取不到会员信息"); } } else { Console.WriteLine("获取不到accessToken"); } } var notice = string.Format("恭喜 {0} 成为您的第{1}号会员", member.WXNickname, rowCount); Console.WriteLine("开始发通知"); //发送通知 bllWeixin.SendTemplateMessageNotifyComm(distUser, string.Format("新会员通知"), notice); Console.WriteLine(notice); }
/// <summary> ///创建卡券 /// </summary> /// <param name="model">卡券实体</param> /// <param name="cardId">卡券Id</param> /// <returns></returns> public bool Create(WeixinCard model, out string cardId) { //接口文档地址 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025056&token=&lang=zh_CN string postUrl = string.Format(" https://api.weixin.qq.com/card/create?access_token={0}", bllWeixin.GetAccessToken()); cardId = ""; var postData = new { card = new { card_type = model.CardType, general_coupon = new //卡券信息 { base_info = new //基本信息 { logo_url = model.LogoUrl, code_type = model.CodeType, brand_name = model.BrandName, title = model.Title, color = model.Color, notice = model.Notice, service_phone = model.ServicePhone, description = model.Description, date_info = new { type = model.Type, begin_timestamp = model.BeginTimeStamp, end_timestamp = model.EndTimeStamp, fixed_term = model.FixedTerm, fixed_begin_term = model.FixedBeginTerm, }, sku = new { quantity = model.Quantity }, use_limit = model.UseLimit, get_limit = model.GetLimit, use_custom_code = model.UseCustomCode, bind_openid = model.BindOpenId, can_share = model.CanShare, can_give_friend = model.CanGiveFriend, center_title = model.CenterTitle, center_sub_title = model.CenterSubTitle, center_url = model.CenterUrl, custom_url_name = model.CustomUrlName, custom_url = model.CustomUrl, custom_url_sub_title = model.CustomUrlSubTitle, promotion_url_name = model.PromotionUrlName, promotion_url = model.PromotionUrl, source = model.Source, location_id_list = model.LocationIdList }, advanced_info = new { temp_abstract = new { temp_abstract = "", icon_url_list = new string[] { model.Image } } },//高级信息 default_detail = model.DefaultDetail } } }; string postDataJson = ZentCloud.Common.JSONHelper.ObjectToJson(postData); postDataJson = postDataJson.Replace("temp_abstract", "abstract"); string result = request.PostWebRequest(postDataJson, postUrl, Encoding.UTF8); JToken jToken = JToken.Parse(result); if (jToken["errcode"].ToString() == "0") { cardId = jToken["card_id"].ToString(); return(true); } return(false); }
public void ProcessRequest(HttpContext context) { string title = context.Request["title"]; string detail = context.Request["detail"]; string time = context.Request["time"]; if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(detail)) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "标题,内容不能为空"; bllActivity.ContextResponse(context, resp); return; } string receiverOpenid = context.Request["receiveropenid"]; if (string.IsNullOrWhiteSpace(receiverOpenid)) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "接收者OpenId不能为空"; bllActivity.ContextResponse(context, resp); return; } string url = context.Request.Form["toUrl"]; string haveUrl = context.Request["haveUrl"]; if (string.IsNullOrWhiteSpace(time)) { time = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } string accessToken = bllWeixin.GetAccessToken(); JToken sendData = JToken.Parse("{}"); sendData["touser"] = receiverOpenid; string activityId = string.Empty; if (!string.IsNullOrWhiteSpace(url)) { sendData["url"] = url; } else if (haveUrl == "1") { activityId = bllActivity.GetGUID(TransacType.ActivityAdd); sendData["url"] = "http://guoye.gotocloud8.net/customize/guoye/#/tongzhi/" + activityId; //SendData["url"] = "http://guoyetest.comeoncloud.net/customize/guoye/#/tongzhi/" + ActivityID; } sendData["K1"] = "标题:" + title; sendData["K2"] = detail; sendData["K3"] = time; sendData["K4"] = ""; resp.errmsg = bllWeixin.SendTemplateMessage(accessToken, keyValueId, sendData); if (!string.IsNullOrWhiteSpace(resp.errmsg)) { resp.errcode = (int)APIErrCode.OperateFail; bllActivity.ContextResponse(context, resp); return; } if (string.IsNullOrWhiteSpace(url) && haveUrl == "1") { JuActivityInfo activity = new JuActivityInfo(); activity.JuActivityID = Convert.ToInt32(activityId); activity.ActivityName = title; activity.ActivityDescription = detail; activity.ArticleType = CommonPlatform.Helper.EnumStringHelper.ToString(ContentType.Notice); activity.CategoryId = categoryId; activity.K8 = time; activity.K12 = context.Request["url"]; activity.K13 = context.Request["haveUrl"]; activity.WebsiteOwner = bllWeixin.WebsiteOwner; if (context.Session[SessionKey.UserID] == null) { activity.UserID = activity.WebsiteOwner; } else { activity.UserID = context.Session[SessionKey.UserID].ToString(); } if (bllActivity.Add(activity)) { resp.isSuccess = true; } else { resp.errmsg = "发送成功,但记录失败"; resp.errcode = (int)APIErrCode.OperateFail; } } else { resp.isSuccess = true; } bllActivity.ContextResponse(context, resp); }
/// <summary> /// 生成微信客户端菜单 /// </summary> /// <returns></returns> private string CreateWeixinClientMenu() { //if (currentUserInfo.WeixinIsEnableMenu == null || currentUserInfo.WeixinIsEnableMenu == 0) //{ // return "请先在 微信平台-公众号配置 页面中启用自定义菜单。"; //} //if (string.IsNullOrEmpty(currentUserInfo.WeixinAppId) || string.IsNullOrEmpty(currentUserInfo.WeixinAppSecret)) //{ // return "请先在 微信平台-公众号配置 页面中填写 AppId与 AppSecret"; //} // //获取AccessToken string accessToken = bllWeixin.GetAccessToken(); if (accessToken == string.Empty) { return("AppId 或AppSecret 不正确,请在 微信公众号-公众号接口配置 页面中检查"); } //获取AccessToken List <WeixinMenu> lstFirstLevel = bllWeixin.GetList <WeixinMenu>(string.Format("UserID='{0}' and PreID=0", currentUserInfo.UserID)).OrderBy(p => p.MenuSort).ToList(); //构造菜单字符串 StringBuilder sbMenu = new StringBuilder(); sbMenu.Append("{\"button\":["); for (int i = 0; i < lstFirstLevel.Count; i++) { List <WeixinMenu> lstSendcondLevel = bllWeixin.GetList <WeixinMenu>(string.Format("UserID='{0}' and PreID={1}", currentUserInfo.UserID, lstFirstLevel[i].MenuID)).OrderByDescending(p => p.MenuSort).ToList(); sbMenu.Append("{"); if (lstSendcondLevel.Count == 0)//无子菜单 { sbMenu.AppendFormat("\"type\":\"{0}\",", lstFirstLevel[i].Type.Trim()); sbMenu.AppendFormat("\"name\":\"{0}\",", lstFirstLevel[i].NodeName); if (lstFirstLevel[i].Type.Trim().Equals("click")) { sbMenu.AppendFormat("\"key\":\"{0}\"", lstFirstLevel[i].KeyOrUrl); } else { sbMenu.AppendFormat("\"url\":\"{0}\"", lstFirstLevel[i].KeyOrUrl); } } else//有子菜单 { sbMenu.AppendFormat("\"name\":\"{0}\",", lstFirstLevel[i].NodeName); sbMenu.Append("\"sub_button\":["); for (int j = 0; j < lstSendcondLevel.Count; j++) { sbMenu.Append("{"); sbMenu.AppendFormat("\"type\":\"{0}\",", lstSendcondLevel[j].Type.Trim()); sbMenu.AppendFormat("\"name\":\"{0}\",", lstSendcondLevel[j].NodeName); if (lstSendcondLevel[j].Type.Trim().Equals("click")) { sbMenu.AppendFormat("\"key\":\"{0}\"", lstSendcondLevel[j].KeyOrUrl); } else { sbMenu.AppendFormat("\"url\":\"{0}\"", lstSendcondLevel[j].KeyOrUrl); } sbMenu.Append("}"); if (j < lstSendcondLevel.Count - 1) { sbMenu.Append(","); } } sbMenu.Append("]"); } sbMenu.Append("}"); if (i < lstFirstLevel.Count - 1) { sbMenu.Append(","); } } sbMenu.Append("]}"); //构造菜单字符串 WeixinAccessToken result = bllWeixin.CreateWeixinClientMenu(accessToken, sbMenu.ToString()); return(bllWeixin.GetCodeMessage(result.errcode)); }
public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; if (string.IsNullOrWhiteSpace(id)) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "消息模板编号不能为空"; bllWeixin.ContextResponse(context, resp); return; } string openId = context.Request["openid"]; string userId = context.Request["userid"]; if (string.IsNullOrWhiteSpace(openId) && string.IsNullOrWhiteSpace(userId)) { BLLJIMP.Model.UserInfo toUser = bllWeixin.GetCurrentUserInfo(); if (toUser != null && !string.IsNullOrWhiteSpace(toUser.WXOpenId)) { openId = toUser.WXOpenId; } } else if (string.IsNullOrWhiteSpace(openId) && !string.IsNullOrWhiteSpace(userId)) { BLLJIMP.Model.UserInfo toUser = bllWeixin.GetByKey <BLLJIMP.Model.UserInfo>("UserID", userId); if (toUser != null && !string.IsNullOrWhiteSpace(toUser.WXOpenId)) { openId = toUser.WXOpenId; } } if (string.IsNullOrWhiteSpace(openId)) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "接收者openId不能为空"; bllWeixin.ContextResponse(context, resp); return; } string k1 = context.Request["k1"]; string k2 = context.Request["k2"]; string k3 = context.Request["k3"]; string k4 = context.Request["k4"]; string k5 = context.Request["k5"]; string k6 = context.Request["k6"]; string k7 = context.Request["k7"]; string k8 = context.Request["k8"]; string k9 = context.Request["k9"]; string k10 = context.Request["k10"]; JToken sendData = JToken.Parse("{}"); sendData["touser"] = openId; if (!string.IsNullOrWhiteSpace(k1)) { sendData["K1"] = k1; } if (!string.IsNullOrWhiteSpace(k2)) { sendData["K2"] = k2; } if (!string.IsNullOrWhiteSpace(k3)) { sendData["K3"] = k3; } if (!string.IsNullOrWhiteSpace(k4)) { sendData["K4"] = k4; } if (!string.IsNullOrWhiteSpace(k5)) { sendData["K5"] = k5; } if (!string.IsNullOrWhiteSpace(k6)) { sendData["K6"] = k6; } if (!string.IsNullOrWhiteSpace(k7)) { sendData["K7"] = k7; } if (!string.IsNullOrWhiteSpace(k8)) { sendData["K8"] = k8; } if (!string.IsNullOrWhiteSpace(k9)) { sendData["K9"] = k9; } if (!string.IsNullOrWhiteSpace(k10)) { sendData["K10"] = k10; } string url = context.Request.Form["toUrl"]; if (!string.IsNullOrWhiteSpace(url)) { sendData["url"] = url; } string accessToken = bllWeixin.GetAccessToken(); resp.errmsg = bllWeixin.SendTemplateMessage(accessToken, id, sendData); if (!string.IsNullOrWhiteSpace(resp.errmsg)) { resp.errcode = (int)APIErrCode.OperateFail; bllWeixin.ContextResponse(context, resp); return; } resp.isSuccess = true; bllWeixin.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { string accessToken = bllWeixin.GetAccessToken(); //dealid 要约id //buyerid 买方id //buyername 买方名字 //sellerid 卖方id //sellername 卖方名字 //receiveropenid 微信接收方openid //receiverphone 微信接收方手机 //identity 0是买方,1是卖方 //title 标题 //detail 要约详情 //time 发布时间,精确到分钟 string title = context.Request["title"]; string detail = context.Request["detail"]; if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(detail)) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "标题,内容不能为空"; bllActivity.ContextResponse(context, resp); return; } string receiverOpenid = context.Request["receiveropenid"]; if (string.IsNullOrWhiteSpace(receiverOpenid)) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "接收者OpenId不能为空"; bllActivity.ContextResponse(context, resp); return; } JuActivityInfo activity = new JuActivityInfo(); activity.JuActivityID = Convert.ToInt32(bllActivity.GetGUID(TransacType.ActivityAdd)); activity.ActivityName = title; activity.ActivityDescription = detail; activity.ArticleType = CommonPlatform.Helper.EnumStringHelper.ToString(ContentType.YaoYue); activity.K1 = context.Request["buyerid"]; activity.K2 = context.Request["buyername"]; activity.K3 = context.Request["sellerid"]; activity.K4 = context.Request["sellername"]; activity.K5 = context.Request["receiveropenid"]; activity.K6 = context.Request["receiverphone"]; activity.K7 = context.Request["dealid"]; activity.K8 = context.Request["time"]; if (string.IsNullOrWhiteSpace(activity.K8)) { activity.K8 = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } activity.K9 = context.Request["identity"]; activity.CreateDate = DateTime.Now; activity.WebsiteOwner = bllWeixin.WebsiteOwner; if (context.Session[SessionKey.UserID] == null) { activity.UserID = activity.WebsiteOwner; } else { activity.UserID = context.Session[SessionKey.UserID].ToString(); } if (activity.K9 == "1") { activity.CategoryId = categoryId1; } else { activity.CategoryId = categoryId0; } if (bllActivity.Add(activity)) { JToken sendData = JToken.Parse("{}"); sendData["touser"] = activity.K5; sendData["url"] = "http://guoye.gotocloud8.net/customize/guoye/#/yaoyue/" + activity.JuActivityID; //SendData["url"] = "http://guoyetest.comeoncloud.net/customize/guoye/#/yaoyue/" + activity.JuActivityID; sendData["K1"] = "要约编号:" + activity.K7; string sender = "国烨网\n"; if (activity.K9 == "1") { sender += "买家:" + activity.K2; } else { sender += "卖家:" + activity.K4; } sendData["K2"] = sender; sendData["K3"] = activity.K8; sendData["K4"] = "标题:" + activity.ActivityName + "\n要约内容:" + activity.ActivityDescription; resp.errmsg = bllWeixin.SendTemplateMessage(accessToken, keyValueId, sendData); resp.isSuccess = true; } else { resp.errmsg = "提交失败"; } bllWeixin.ContextResponse(context, resp); }
public static bool SendTMAllUserScoreDailyAccountBillNotify(string websiteOwner) { BLLWeixin bllWeixin = new BLLWeixin(""); WeixinFollowers model = Common.JSONHelper.JsonToModel <WeixinFollowers>(bllWeixin.GetFollower(bllWeixin.GetAccessToken(), string.Empty)); while (model.count > 0) { Dictionary <string, object> dicOpenId = (Dictionary <string, object>)model.data; object[] openidArry = (object[])dicOpenId.First().Value; foreach (var openid in openidArry) { UserInfo userInfo = bllWeixin.Get <UserInfo>(string.Format("WXOpenId='{0}' and WebsiteOwner='{1}'", openid, websiteOwner)); if (userInfo == null) { continue; } SendTMUserScoreDailyAccountBillNotify(userInfo.UserID, websiteOwner); } model = Common.JSONHelper.JsonToModel <WeixinFollowers>(bllWeixin.GetFollower(bllWeixin.GetAccessToken(), string.Empty)); } return(true); }
/// <summary> /// 注册用户 /// </summary> /// <param name="context"></param> /// <returns></returns> private string SaveInfo(HttpContext context) { string name = context.Request["Uname"]; string phone = context.Request["UPhone"]; string email = context.Request["UEmail"]; string company = context.Request["UCompanyl"]; string recommendUserId = context.Request["UserId"];//推荐人用户名 //string SmsVerCode = context.Request["SmsVerCode"]; string position = context.Request["Postion"]; if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(company)) { resp.Status = -1; resp.Msg = "请填写完整信息"; goto outF; } if (name.Length >= 15) { resp.Status = -1; resp.Msg = "姓名长度在15字内"; goto outF; } if (bllUser.GetCount <UserInfo>(string.Format(" WebsiteOwner='{0}' And Phone='{1}'", bllUser.WebsiteOwner, phone)) > 0) { resp.Status = -1; resp.Msg = "手机号已经注册过"; goto outF; } //if (string.IsNullOrEmpty(SmsVerCode)) //{ // resp.Status = -1; // resp.Msg = "请输入通关密码"; // goto outF; //} //if (context.Session["SmsVerificationCode"] == null) //{ // resp.Status = -1; // resp.Msg = "请输入通关密码"; // goto outF; //} //if (!context.Session["SmsVerificationCode"].ToString().Equals(SmsVerCode)) //{ // resp.Status = -1; // resp.Msg = "通关密码不正确"; // goto outF; //} //注册会员加积分 BLLUserScore bllScore = new BLLUserScore(this.currentUserInfo.UserID); bllScore.UpdateUserScoreWithWXTMNotify(bllScore.GetDefinedUserScore(BLLUserScore.UserScoreType.RegistWebSite), bllWeixin.GetAccessToken()); //转发人加积分 if (!string.IsNullOrEmpty(recommendUserId))//有转发人 { SavaForwardingRecord(recommendUserId); //转发人加积分 bllScore = new BLLUserScore(recommendUserId); if (IsTutor(recommendUserId)) { bllScore.UpdateUserScoreWithWXTMNotify(bllScore.GetDefinedUserScore(BLLUserScore.UserScoreType.TutorInviteFriendRegister), new ZentCloud.BLLJIMP.BLLWeixin("").GetAccessToken()); } else { bllScore.UpdateUserScoreWithWXTMNotify(bllScore.GetDefinedUserScore(BLLUserScore.UserScoreType.InviteFriendRegister), new ZentCloud.BLLJIMP.BLLWeixin("").GetAccessToken()); } //SaveCurrUser();//注册会员加积分 //SaveRecordUser(UserId); //转发人加积分 } currentUserInfo = bllUser.GetCurrentUserInfo(); currentUserInfo.TrueName = name; currentUserInfo.Phone = phone; currentUserInfo.Email = email; currentUserInfo.Company = company; currentUserInfo.Regtime = DateTime.Now; currentUserInfo.Postion = position; bool isSuccess = bllUser.Update(currentUserInfo); if (isSuccess) { resp.Status = 0; resp.Msg = "添加成功"; } else { resp.Status = -1; resp.Msg = "添加失败"; } outF: return(Common.JSONHelper.ObjectToJson(resp)); }