protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { if (this.Session["MemID"] != null) { int memID = int.Parse(this.Session["MemID"].ToString()); this.txtMemID.Value = memID.ToString(); if (base.Request["MoneyID"] != null) { string moneyID = base.Request["MoneyID"].ToString(); this.BindWeiXinMoney(int.Parse(base.Request["MoneyID"])); this.txtGetMoneyID.Value = base.Request["MoneyID"]; } string openid = new Chain.BLL.Mem().GetWeiXinMemCardbyMemID(memID); this.OpenID.Value = openid; if (base.Request["Win"] != null) { Chain.BLL.WeiXinMoney bllWeiXinMoney = new Chain.BLL.WeiXinMoney(); Chain.Model.WeiXinMoney modelWeiXinMoney = bllWeiXinMoney.GetModel(int.Parse(this.txtGetMoneyID.Value)); decimal givemoney = new Chain.BLL.WeiXinGiveMoney().GetMoneySum(" MoneyID=" + modelWeiXinMoney.MoneyID); decimal totalmoney = modelWeiXinMoney.TotalMoney; if (totalmoney - givemoney < 1m) { this.IsWin.Value = "-1"; this.txtMsg.Value = "红包已抢完!"; } else { int intWin = this.isWin(decimal.Parse(this.MoneyRate.Value), int.Parse(this.MemtotalCount.Value)); this.IsWin.Value = intWin.ToString(); if (intWin == 0) { Chain.BLL.WeiXinGiveMoney bllWeiXinGiveMoney = new Chain.BLL.WeiXinGiveMoney(); bllWeiXinGiveMoney.Add(new Chain.Model.WeiXinGiveMoney { MemID = int.Parse(this.txtMemID.Value), MoneyID = int.Parse(this.txtGetMoneyID.Value), GiveMoney = 0m, GiveTime = DateTime.Now, IsWin = 0 }); } } } if (base.Request["IsSuccess"] != null) { this.IsSuccess.Value = base.Request["IsSuccess"]; } this.rptWinListBind(); } else { base.Response.Redirect("login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { if (this.Session["MemID"] != null) { int memID = int.Parse(this.Session["MemID"].ToString()); this.txtMemID.Value = memID.ToString(); if (base.Request.QueryString["MoneyID"] != null) { this.txtMoneyID.Value = base.Request.QueryString["MoneyID"].ToString(); this.BindWeiXinMoney(int.Parse(this.txtMoneyID.Value)); } if (int.Parse(this.MemCount.Value) > 0) { string openid = new Chain.BLL.Mem().GetModel(memID).MemWeiXinCard; if (string.IsNullOrEmpty(openid)) { base.Response.Write("<span style='color:#FF0000;font-size:20px'>页面传参出错,请返回重试</span>"); } else { double getmoney = double.Parse(this.txtgetmoney.Value); Chain.BLL.WeiXinMoney bllWeiXinMoney = new Chain.BLL.WeiXinMoney(); Chain.Model.WeiXinMoney modelWeiXinMoney = bllWeiXinMoney.GetModel(int.Parse(this.txtMoneyID.Value)); string mch_billno = DateTime.Now.ToString("yyMMddHHmmssffff"); int total_amount = int.Parse((getmoney * 100.0).ToString("")); string wishing = modelWeiXinMoney.MoneyWish; string remark = modelWeiXinMoney.MoneyDesc; string act_name = modelWeiXinMoney.MoneyTitle; string re_openid = openid; WxPayData data = new WxPayData(); data.SetValue("mch_billno", mch_billno); data.SetValue("mch_id", PubFunction.curParameter.strMchid); data.SetValue("wxappid", PubFunction.curParameter.strWeiXinAppID); data.SetValue("send_name", "智络"); data.SetValue("re_openid", re_openid); data.SetValue("total_amount", total_amount); data.SetValue("total_num", 1); data.SetValue("wishing", wishing); data.SetValue("client_ip", PubFunction.ipAdress); data.SetValue("act_name", act_name); data.SetValue("remark", remark); WxPayData result = WxPayApi.Sendredpack(data, PubFunction.curParameter.strMchKey, "cert\\apiclient_cert.p12", PubFunction.curParameter.strMchid, 10); if (!result.IsSet("return_code") || result.GetValue("return_code").ToString() == "FAIL") { string arg_2DD_0 = result.IsSet("return_msg") ? result.GetValue("return_msg").ToString() : ""; this.spGetMoney.InnerHtml = ""; this.spResultInfo.InnerHtml = "红包接口调用失败!" + result.GetValue("return_msg").ToString(); } else if (result.GetValue("return_code").ToString() == "SUCCESS" && result.GetValue("result_code").ToString() == "SUCCESS") { if (int.Parse(this.MemCount.Value) > 0) { Chain.BLL.WeiXinGiveMoney bllWeiXinGiveMoney = new Chain.BLL.WeiXinGiveMoney(); bllWeiXinGiveMoney.Add(new Chain.Model.WeiXinGiveMoney { MemID = int.Parse(this.txtMemID.Value), MoneyID = int.Parse(this.txtMoneyID.Value), GiveMoney = decimal.Parse(getmoney.ToString()), GiveTime = DateTime.Now, IsWin = 1 }); bllWeiXinMoney.UpdateGiveMoney(int.Parse(this.txtMoneyID.Value), decimal.Parse(getmoney.ToString())); this.spResultInfo.InnerHtml = "红包发放成功!"; this.spGetMoney.InnerHtml = getmoney.ToString("#0.00"); this.moneyInfo.Visible = true; } else { this.spGetMoney.InnerHtml = ""; this.spResultInfo.InnerHtml = "您的红包领取次数已用完!"; } } else { this.spGetMoney.InnerHtml = ""; this.spResultInfo.InnerHtml = "红包发放失败!" + result.GetValue("return_msg").ToString(); } } } } else { base.Response.Redirect("login.aspx"); } } }