public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { if (!MemberApplication.VerificationPayPwd(base.CurrentUser.Id, pwd)) { throw new HimallException("支付密码不对,请重新输入!"); } if (!((applyType != UserWithdrawType.ALiPay.GetHashCode()) || base.CurrentSiteSetting.Withdraw_AlipayEnable)) { throw new HimallException("不支持支付宝提现方式!"); } CapitalInfo capitalInfo = this._iMemberCapitalService.GetCapitalInfo(base.CurrentUser.Id); if (amount > capitalInfo.Balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0M) { throw new HimallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid) && (applyType == UserWithdrawType.WeiChat.GetHashCode())) { openid = WebHelper.GetCookie("Himall-User_OpenId"); } if (string.IsNullOrWhiteSpace(nickname) && (applyType == UserWithdrawType.ALiPay.GetHashCode())) { throw new HimallException("数据异常,真实姓名不可为空!"); } if (!string.IsNullOrWhiteSpace(openid) && (applyType == UserWithdrawType.WeiChat.GetHashCode())) { openid = SecureHelper.AESDecrypt(openid, "Mobile"); SiteSettingsInfo siteSettings = this._iSiteSettingService.GetSiteSettings(); if (!string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret)) { WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false), openid); if (userInfo != null) { nickname = userInfo.nickname; } } } if (string.IsNullOrWhiteSpace(openid)) { throw new HimallException("数据异常,OpenId或收款账号不可为空!"); } ApplyWithDrawInfo model = new ApplyWithDrawInfo { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = base.CurrentUser.Id, OpenId = openid, NickName = nickname, ApplyType = new UserWithdrawType?((UserWithdrawType)applyType) }; this._iMemberCapitalService.AddWithDrawApply(model); return(base.Json(new { success = true })); }
/// <summary> /// 用户信息接口 /// </summary> /// <param name="accessToken"></param> /// <param name="openId"></param> /// <returns></returns> public static WeixinUserInfoResult GetUserInfo(string accessToken, string openId) { var url = string.Format("http://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}", accessToken, openId); WeixinUserInfoResult result = HTTPGet.GetJson <WeixinUserInfoResult>(url); return(result); }
/// <summary> /// 订阅(关注)事件 /// </summary> /// <returns></returns> public override IResponseMessageBase OnEvent_SubscribeRequest(RequestMessageEvent_Subscribe requestMessage) { //var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage); //responseMessage.Content = GetWelcomeInfo(); //if (!string.IsNullOrEmpty(requestMessage.EventKey)) //{ // responseMessage.Content += "\r\n============\r\n场景值:" + requestMessage.EventKey; //} var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage); WeixinUserInfoResult user = null; try { user = WeixinApi.GetUserInfo(AccessTokenHelper.GetTokenForSqlServer(ConfigurationManager.AppSettings["WeixinAppId"], ConfigurationManager.AppSettings["WeixinAppSecret"]), WeixinOpenId); responseMessage.Articles.Add(new Article() { Title = user.nickname + ",您有一个0元设计未领", PicUrl = "http://material-ui.net/content/zixun.jpg", Url = "http://material-ui.net/booking.html", Description = user.nickname + ",您有一个0元设计未领。实力整装,省钱,省力,省心。" }); } catch (Exception ex) { responseMessage.Articles.Add(new Article() { Title = "您有一个0元设计未领", PicUrl = "http://material-ui.net/content/zixun.jpg", Url = "http://material-ui.net/booking.html", Description = "您有一个0元设计未领。实力整装,省钱,省力,省心。" + ex.Message }); } //获取订阅用户昵称 //responseMessage.Articles.Add(new Article() { Title = user.nickname+",您有一个0元设计未领", PicUrl = "http://material-ui.net/content/zixun.jpg", Url = "http://material-ui.net/booking.html", Description = user.nickname+",您有一个0元设计未领。实力整装,省钱,省力,省心。" }); //推送消息 //下载文档 //if (requestMessage.EventKey.StartsWith("qrscene_")) //{ // var sceneId = long.Parse(requestMessage.EventKey.Replace("qrscene_", "")); // //var configHelper = new ConfigHelper(new HttpContextWrapper(HttpContext.Current)); // var codeRecord = // ConfigHelper.CodeCollection.Values.FirstOrDefault(z => z.QrCodeTicket != null && z.QrCodeId == sceneId); // if (codeRecord != null) // { // //确认可以下载 // codeRecord.AllowDownload = true; // AdvancedAPIs.CustomApi.SendText(null, WeixinOpenId, GetDownloadInfo(codeRecord)); // } //} return(responseMessage); }
/// <summary> /// 用户信息接口 /// </summary> /// <param name="accessTokenOrAppId"></param> /// <param name="openId"></param> /// <returns></returns> public static WeixinUserInfoResult GetUserInfo(string accessTokenOrAppId, string openId) { return(ApiHandlerWapper.TryCommonApi(accessToken => { var url = string.Format("http://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}", accessToken.AsUrlData(), openId.AsUrlData()); WeixinUserInfoResult result = Get.GetJson <WeixinUserInfoResult>(url); return result; }, accessTokenOrAppId)); }
public static WeixinUserInfoResult GetUserInfo(string accessTokenOrAppId, string openId) { return(ApiHandlerWapper.TryCommonApi(accessToken => { var url = string.Format(Config.ApiMpHost + "/cgi-bin/user/info?access_token={0}&openid={1}", accessToken.AsUrlData(), openId.AsUrlData()); WeixinUserInfoResult result = CommonJsonSend.Send <WeixinUserInfoResult>(null, url, null, CommonJsonSendType.GET); return result; }, accessTokenOrAppId)); }
public static WeixinUserInfoResult GetUserInfo(string accessTokenOrAppId, string openId) { return(ApiHandlerWapper.TryCommonApi(accessToken => { var url = string.Format(Config.ApiMpHost + "/cgi-bin/user/info?access_token={0}&openid={1}", accessToken.AsUrlData(), openId.AsUrlData()); WeixinUserInfoResult result = CO2NET.HttpUtility.Get.GetJson <WeixinUserInfoResult>(url); return result; }, accessTokenOrAppId)); }
public JsonResult ApplyWithDrawSubmit(string nickname, decimal amount, string pwd) { if (ServiceHelper.Create <IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null) { throw new HimallException("支付密码不对,请重新输入!"); } CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id); decimal num = amount; decimal? balance = capitalInfo.Balance; if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue)) { throw new HimallException("提现金额不能超出可用金额!"); } string cookie = WebHelper.GetCookie("Himall-User_OpenId"); string empty = string.Empty; if (string.IsNullOrWhiteSpace(cookie)) { throw new HimallException("数据异常,OpenId不能为空!"); } cookie = SecureHelper.AESDecrypt(cookie, "Mobile"); SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings(); if (!string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret)) { //string str = AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false); string str = CommonApi.GetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret).access_token; // WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(str, cookie); if (userInfo != null) { empty = userInfo.nickname; } } ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = base.CurrentUser.Id, OpenId = cookie, NickName = empty }; ServiceHelper.Create <IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo); return(Json(new { success = true })); }
private string ProcessWithDrawScene(RequestMessageEventBase weixinMsg, string sceneid, SceneModel model) { try { string str = CacheKeyCollection.SceneReturn(sceneid); if (!(Cache.Get(str) is ApplyWithDrawInfo)) { SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings(); if (string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) || string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret)) { Log.Error("微信事件回调:未设置公众号配置参数!"); } else { //string str1 = AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false); string str1 = CommonApi.GetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret).access_token; // WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(str1, weixinMsg.FromUserName); ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo() { MemId = long.Parse(model.Object.ToString()), OpenId = weixinMsg.FromUserName, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, NickName = userInfo.nickname }; ApplyWithDrawInfo applyWithDrawInfo1 = applyWithDrawInfo; if (Cache.Get(str) != null) { Cache.Remove(str); } Cache.Insert(str, applyWithDrawInfo1, 300); } } } catch (Exception exception) { Log.Error(string.Concat("ProcessWithDrawScene:", exception.Message)); } return(string.Empty); }