Exemplo n.º 1
0
 /// <summary>
 /// 优惠券回滚
 /// </summary>
 /// <param name="orderId"></param>
 public void couponUnUse(string orderId)
 {
     LVWEIBA.DAL.MemberCoupon   DalCoupon   = new LVWEIBA.DAL.MemberCoupon();
     LVWEIBA.Model.MemberCoupon couponModel = DalCoupon.GetModel(" Order_Id='" + orderId + "'");
     //是否使用了优惠券
     if (couponModel != null)
     {
         couponModel.Order_Id = "";
         couponModel.ZT       = "0";
         DalCoupon.Update(couponModel);
     }
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserAuthorizationModel userInfo = UserAuthorization.userLogin(this.Page);

        if (userInfo.openId == null || userInfo.openId == "")
        {
            openid_db = userInfo.mobile;
        }
        else
        {
            openid_db = userInfo.openId;
        }
        //Session["openid"] = openid;

        if (string.IsNullOrEmpty(Request.QueryString["code"]))
        {
            Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + GetWeiXinInf.appid + "&redirect_uri=http://wx.lvwei8.com/index/CouponForNinety.aspx&response_type=code&scope=snsapi_base&state=123#wechat_redirect");
        }

        else
        {
            string code = Request.QueryString["code"];
            openid_wx = new WEIxinUserApi().GetUserOpenid(code);
            //Session["openid"] = openid;

            if (openid_wx.Length < 10)
            {
                Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + GetWeiXinInf.appid + "&redirect_uri=http://wx.lvwei8.com/index/CouponForNinety.aspx&response_type=code&scope=snsapi_base&state=123#wechat_redirect");
            }
            else
            {
            }
        }

        if (IsPostBack)
        {
            string mobile = Request.Form["tel"];
            string code   = Request.Form["code"];

            object codeCache = HttpContext.Current.Cache.Get("code" + mobile);
            if (codeCache == null)
            {
                Jscript.NorefLocation(this.Page, "验证码失效请重新获取!手机号为:" + mobile + "code is:" + code, "CouponForNinety.aspx");
            }
            else
            {
                if (code != codeCache.ToString())
                {
                    Jscript.NorefLocation(this.Page, "验证码不正确!", "CouponForNinety.aspx");
                }
                else
                {
                    var member = new LVWEIBA.BLL.MemberInfo().GetModel(openid_db);
                    if (member != null)
                    {
                        if (member.Tel == "" || member.Tel == null || openid_db != openid_wx)
                        {
                            //更新用户信息
                            var bll = new LVWEIBA.BLL.MemberInfo();
                            member.Tel    = mobile.Trim();
                            member.openid = openid_wx;
                            bll.Update(member);
                            //发放礼券(50元一张,20元俩张)
                            LVWEIBA.BLL.MemberCoupon bllCoupon = new LVWEIBA.BLL.MemberCoupon();
                            for (int i = 0; i < 2; i++)
                            {
                                List <LVWEIBA.Model.MemberCoupon> list = new List <LVWEIBA.Model.MemberCoupon>();
                                LVWEIBA.Model.MemberCoupon        mdl  = new LVWEIBA.Model.MemberCoupon();
                                mdl.CouponID = "0020160604000001KBW1";
                                mdl.Userid   = openid_wx;
                                mdl.ZT       = "0";
                                mdl.Count    = 2;
                                mdl.Sj       = DateTime.Now;
                                mdl.Order_Id = "";
                                list.Add(mdl);
                                bllCoupon.SendCouton(list, "0020160604000001KBW1", 1);
                            }
                            //50元
                            List <LVWEIBA.Model.MemberCoupon> listForFifty = new List <LVWEIBA.Model.MemberCoupon>();
                            LVWEIBA.Model.MemberCoupon        mdlForFifty  = new LVWEIBA.Model.MemberCoupon();
                            mdlForFifty.CouponID = "0020160604000001L511";
                            mdlForFifty.Userid   = openid_wx;
                            mdlForFifty.ZT       = "0";
                            mdlForFifty.Count    = 1;
                            mdlForFifty.Sj       = DateTime.Now;
                            mdlForFifty.Order_Id = "";
                            listForFifty.Add(mdlForFifty);
                            bllCoupon.SendCouton(listForFifty, "0020160604000001L511", 1);
                            //删除缓存
                            HttpContext.Current.Cache.Remove("code" + mobile);
                            Jscript.NorefLocation(this.Page, "领取成功!", "Coupon.aspx");
                        }
                        else
                        {
                            //删除缓存
                            HttpContext.Current.Cache.Remove("code" + mobile);
                            Jscript.NorefLocation(this.Page, "该手机号已经验证过!", "CouponForNinety.aspx");
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserAuthorizationModel userInfo = UserAuthorization.userLogin(this.Page);

        if (userInfo.openId == null || userInfo.openId == "")
        {
            openid = userInfo.mobile;
        }
        else
        {
            openid = userInfo.openId;
        }
        Session["openid"] = openid;

        if (IsPostBack)
        {
            string mobile = Request.Form["tel"];
            string code   = Request.Form["code"];

            object codeCache = HttpContext.Current.Cache.Get("code" + mobile);
            if (codeCache == null)
            {
                Jscript.NorefLocation(this.Page, "验证码失效请重新获取!手机号为:" + mobile + "code is:" + code, "CouponForOneThousand.aspx");
            }
            else
            {
                if (code != codeCache.ToString())
                {
                    Jscript.NorefLocation(this.Page, "验证码不正确!", "CouponForOneThousand.aspx");
                }
                else
                {
                    var member = new LVWEIBA.BLL.MemberInfo().GetModel(openid);
                    if (member != null)
                    {
                        if (member.Tel == "" || member.Tel == null)
                        {
                            //更新用户信息
                            var bll = new LVWEIBA.BLL.MemberInfo();
                            member.Tel = mobile.Trim();
                            bll.Update(member);
                            //发放礼券(500一张,300元一张,50元2张,20元5张)
                            LVWEIBA.BLL.MemberCoupon bllCoupon = new LVWEIBA.BLL.MemberCoupon();
                            //20元
                            for (int i = 0; i < 5; i++)
                            {
                                List <LVWEIBA.Model.MemberCoupon> list = new List <LVWEIBA.Model.MemberCoupon>();
                                LVWEIBA.Model.MemberCoupon        mdl  = new LVWEIBA.Model.MemberCoupon();
                                mdl.CouponID = "0020160604000001KBW1";
                                mdl.Userid   = openid;
                                mdl.ZT       = "0";
                                mdl.Count    = 5;
                                mdl.Sj       = DateTime.Now;
                                mdl.Order_Id = "";
                                list.Add(mdl);
                                bllCoupon.SendCouton(list, "0020160604000001KBW1", 1);
                            }
                            //50元
                            for (int i = 0; i < 2; i++)
                            {
                                List <LVWEIBA.Model.MemberCoupon> listForFifty = new List <LVWEIBA.Model.MemberCoupon>();
                                LVWEIBA.Model.MemberCoupon        mdlForFifty  = new LVWEIBA.Model.MemberCoupon();
                                mdlForFifty.CouponID = "0020160604000001L511";
                                mdlForFifty.Userid   = openid;
                                mdlForFifty.ZT       = "0";
                                mdlForFifty.Count    = 2;
                                mdlForFifty.Sj       = DateTime.Now;
                                mdlForFifty.Order_Id = "";
                                listForFifty.Add(mdlForFifty);
                                bllCoupon.SendCouton(listForFifty, "0020160604000001L511", 1);
                            }
                            //300元
                            List <LVWEIBA.Model.MemberCoupon> listForThreeHundred = new List <LVWEIBA.Model.MemberCoupon>();
                            LVWEIBA.Model.MemberCoupon        mdlForThreeHundred  = new LVWEIBA.Model.MemberCoupon();
                            mdlForThreeHundred.CouponID = "002016060400000164Q5";
                            mdlForThreeHundred.Userid   = openid;
                            mdlForThreeHundred.ZT       = "0";
                            mdlForThreeHundred.Count    = 1;
                            mdlForThreeHundred.Sj       = DateTime.Now;
                            mdlForThreeHundred.Order_Id = "";
                            listForThreeHundred.Add(mdlForThreeHundred);
                            bllCoupon.SendCouton(listForThreeHundred, "002016060400000164Q5", 1);
                            //500元
                            List <LVWEIBA.Model.MemberCoupon> listForFiveHundred = new List <LVWEIBA.Model.MemberCoupon>();
                            LVWEIBA.Model.MemberCoupon        mdlForFiveHundred  = new LVWEIBA.Model.MemberCoupon();
                            mdlForFiveHundred.CouponID = "00201606200000011KA9";
                            mdlForFiveHundred.Userid   = openid;
                            mdlForFiveHundred.ZT       = "0";
                            mdlForFiveHundred.Count    = 1;
                            mdlForFiveHundred.Sj       = DateTime.Now;
                            mdlForFiveHundred.Order_Id = "";
                            listForFiveHundred.Add(mdlForFiveHundred);
                            bllCoupon.SendCouton(listForFiveHundred, "00201606200000011KA9", 1);

                            //删除缓存
                            HttpContext.Current.Cache.Remove("code" + mobile);
                            Jscript.NorefLocation(this.Page, "领取成功!", "Coupon.aspx");
                        }
                        else
                        {
                            //删除缓存
                            HttpContext.Current.Cache.Remove("code" + mobile);
                            Jscript.NorefLocation(this.Page, "请先验证手机!", "bindPhone.aspx");
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserAuthorizationModel userInfo = UserAuthorization.userLogin(this.Page);

        if (userInfo.openId == null || userInfo.openId == "")
        {
            openId = userInfo.mobile;
        }
        else
        {
            openId = userInfo.openId;
        }
        //商户订单号,商户网站订单系统中唯一订单号,必填
        string out_trade_no = Request.QueryString["orderid"].Trim();

        //付款金额,必填
        string total_fee = Request.QueryString["feee"].Trim();

        //收银台页面上,商品展示的超链接,必填
        string show_url = "http://lvwei8.com/index/showline.aspx?code=160928113527452356B&lineid=656";

        //商品描述,可空
        string jinbi        = Request.QueryString["jinbi"].Trim();
        string couponId     = Request.QueryString["couponid"].Trim();
        string useMoneyLeft = Request.QueryString["usemoneyleft"].Trim();


        Response.ContentType = "text/html;charset=utf-8";
        moneyFreeze(useMoneyLeft, out_trade_no, openId);
        //使用优惠券(加入订单号)
        if (couponId != "0")
        {
            LVWEIBA.BLL.MemberCoupon coupon = new LVWEIBA.BLL.MemberCoupon();
            int id = int.Parse(couponId);
            LVWEIBA.Model.MemberCoupon couponModel = coupon.GetModel(id);
            couponModel.Order_Id = out_trade_no;
            couponModel.ZT       = "1";//变为已使用
            coupon.Update(couponModel);
        }
        try
        {
            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
            sParaTemp.Add("partner", Config.partner);
            sParaTemp.Add("seller_id", Config.seller_id);
            sParaTemp.Add("_input_charset", Config.input_charset.ToLower());
            sParaTemp.Add("service", Config.service);
            sParaTemp.Add("payment_type", Config.payment_type);
            sParaTemp.Add("notify_url", Config.notify_url);
            sParaTemp.Add("return_url", Config.return_url);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("subject", "驴尾巴商品");
            sParaTemp.Add("total_fee", total_fee);
            sParaTemp.Add("show_url", show_url);
            //sParaTemp.Add("app_pay","Y");//启用此参数可唤起钱包APP支付。
            sParaTemp.Add("body", openId);
            //其他业务参数根据在线开发文档,添加参数.文档地址:https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.2Z6TSk&treeId=60&articleId=103693&docType=1
            //如sParaTemp.Add("参数名","参数值");
            //建立请求
            log4netHelper.WriteDebugLog(typeof(index_control_AliPayHandler), "index_control_AliPayHandler", "orderid is:" + out_trade_no + "total_fee:" + total_fee + "paramters: " + sParaTemp.ToString());
            submitLit.Text = Submit.BuildRequest(sParaTemp, "get", "确认");
        }
        catch (Exception ex)
        {
            log4netHelper.WriteExceptionLog(typeof(index_control_AliPayHandler), "index_control_AliPayHandler Error", ex);
        }
    }