public void ProcessRequest(HttpContext context) { if (context.Request.HttpMethod != "POST") { resp.code = (int)APIErrCode.OperateFail; resp.msg = "请用POST提交"; bllUser.ContextResponse(context, resp); return; } string openId = context.Request["openid"]; //openId string json = context.Request["json"]; //json string serialNumber = context.Request["serial_number"]; //流水号 json = HttpUtility.UrlDecode(json); if (string.IsNullOrEmpty(openId)) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "openid 参数必传"; bllWeixin.ContextResponse(context, resp); return; } if (string.IsNullOrEmpty(json)) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "json 参数必传"; bllWeixin.ContextResponse(context, resp); return; } UserInfo userInfo = bllUser.GetUserInfoByOpenId(openId); if (userInfo == null && (bllUser.WebsiteOwner == "dongwu" || bllUser.WebsiteOwner == "dongwudev")) { userInfo = bllUser.CreateNewUser(bllUser.WebsiteOwner, openId, ""); } if (userInfo == null) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "openid 不存在"; bllWeixin.ContextResponse(context, resp); return; } string msg = ""; var isSuccess = bllWeixin.SendTemplateMessageCustomize(json, out msg); if (isSuccess) { resp.status = true; resp.msg = "ok"; bllLog.Add(bllLog.WebsiteOwner, EnumApiModule.WeixinMessage, string.Format("发送微信消息\njson内容{0}", json), openId, userInfo.UserID, serialNumber); } else { resp.code = (int)APIErrCode.OperateFail; resp.msg = msg; } bllWeixin.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { if (context.Request.HttpMethod != "POST") { resp.code = (int)APIErrCode.OperateFail; resp.msg = "请用POST提交"; bllScore.ContextResponse(context, resp); return; } string openId = context.Request["openid"]; //openId string serialNumber = context.Request["serial_number"]; //流水号 if (string.IsNullOrEmpty(openId)) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "openid 参数必传"; bllScore.ContextResponse(context, resp); return; } UserInfo userInfo = bllUser.GetUserInfoByOpenId(openId); if (userInfo == null && (bllUser.WebsiteOwner == "dongwu" || bllUser.WebsiteOwner == "dongwudev")) { userInfo = bllUser.CreateNewUser(bllUser.WebsiteOwner, openId, ""); } if (userInfo == null) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "openid 不存在"; bllScore.ContextResponse(context, resp); return; } if (bllLog.Add(bllLog.WebsiteOwner, EnumApiModule.Score, "获取用户积分", openId, userInfo.UserID, serialNumber)) { resp.status = true; resp.msg = "ok"; resp.result = new { score = userInfo.TotalScore, history_totalscore = userInfo.HistoryTotalScore, used_totalscore = Math.Abs(bllScore.GetUsedTotalScore(userInfo.UserID)) }; } else { resp.code = (int)APIErrCode.OperateFail; resp.msg = "操作失败"; } bllScore.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { if (context.Request.HttpMethod != "POST") { resp.code = (int)APIErrCode.OperateFail; resp.msg = "请用POST提交"; bllUser.ContextResponse(context, resp); return; } string openId = context.Request["openid"]; //openId string title = context.Request["title"]; //标题 string content = context.Request["content"]; //备注 string link = context.Request["link"]; //网页链接 string serialNumber = context.Request["serial_number"]; //流水号 title = HttpUtility.UrlDecode(title); content = HttpUtility.UrlDecode(content); if (string.IsNullOrEmpty(openId)) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "openid 参数必传"; bllWeixin.ContextResponse(context, resp); return; } if (string.IsNullOrEmpty(title)) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "title 参数必传"; bllWeixin.ContextResponse(context, resp); return; } if (string.IsNullOrEmpty(content)) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "content 参数必传"; bllWeixin.ContextResponse(context, resp); return; } UserInfo userInfo = bllUser.GetUserInfoByOpenId(openId); if (userInfo == null && (bllUser.WebsiteOwner == "dongwu" || bllUser.WebsiteOwner == "dongwudev")) { userInfo = bllUser.CreateNewUser(bllUser.WebsiteOwner, openId, ""); } if (userInfo == null) { resp.code = (int)APIErrCode.PrimaryKeyIncomplete; resp.msg = "openid 不存在"; bllWeixin.ContextResponse(context, resp); return; } var isSuccess = bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, link); if (isSuccess) { resp.status = true; resp.msg = "ok"; bllLog.Add(bllLog.WebsiteOwner, EnumApiModule.WeixinMessage, string.Format("发送微信消息\n标题:{0},内容:{1},链接:{2}", title, content, link), openId, userInfo.UserID, serialNumber); } else { resp.code = (int)APIErrCode.OperateFail; resp.msg = "发送失败"; } bllWeixin.ContextResponse(context, resp); }