Esempio n. 1
0
        public override void ProcessNotify()
        {
            WxPayData notifyData = GetNotifyData();

            //检查支付结果中transaction_id是否存在
            if (!notifyData.IsSet("transaction_id"))
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中微信订单号不存在");
                Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }

            string transaction_id = notifyData.GetValue("transaction_id").ToString();

            //查询订单,判断订单真实性
            if (!QueryOrder(transaction_id))
            {
                //若订单查询失败,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "订单查询失败");
                Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
            //查询订单成功
            else
            {
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "SUCCESS");
                res.SetValue("return_msg", "OK");

                string attach = notifyData.GetValue("attach").ToString();
                if (!string.IsNullOrEmpty(attach))
                {
                    OrderFactory.UpdateOrderStatus(attach, 5);//更新订单支付状态

                    //更新产品销量和库存
                    OrderModel orderinfo = OrderFactory.Get(attach);
                    foreach (OrderProduct op in orderinfo.productlist)
                    {
                        ProductFactory.UpdateSalecount(op.productinfo.productid, op.count);
                    }

                    //更新用户积分,按照支付产品总价计算积分,邮费不产生积分
                    VShopConfig shopconfig = VShopConfigHelper.Get();
                    UserFactory.UpdateJf(orderinfo.uid, Int32.Parse(orderinfo.productprice.ToString()) * shopconfig.MoneyToJfRate);
                }

                Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            VShopConfig vs = VShopConfigHelper.Get();

            vs.ShopName      = this.txtShopName.Text.Trim();
            vs.ShopAddress   = this.txtShopAddress.Text.Trim();
            vs.ShopTel       = this.txtShopTel.Text.Trim();
            vs.MoneyToJfRate = Int32.Parse(this.txtMoneyToJfRate.Text.Trim());
            vs.ShopLogo      = this.txtShopLogo.Text.Trim();

            vs.HomeCommendProductCount = Int32.Parse(this.txtHomeCommendProductCount.Text.Trim());
            vs.HomeLatestProductCount  = Int32.Parse(this.txtHomeLatestProductCount.Text.Trim());

            vs.PostAge     = Decimal.Parse(this.txtPostAge.Text.Trim());
            vs.FreePostAge = Decimal.Parse(this.txtFreePostAge.Text.Trim());

            VShopConfigHelper.Save(vs);

            ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('配置信息修改成功!');window.location='vshopconfig.aspx';</script>");
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Security.CheckAdministerAndRedirect();
            if (!Page.IsPostBack)
            {
                VShopConfig vs = VShopConfigHelper.Get();

                this.txtShopName.Text      = vs.ShopName;
                this.txtShopAddress.Text   = vs.ShopAddress;
                this.txtShopTel.Text       = vs.ShopTel;
                this.txtMoneyToJfRate.Text = vs.MoneyToJfRate.ToString();
                this.txtShopLogo.Text      = vs.ShopLogo;

                this.txtPostAge.Text     = vs.PostAge.ToString();
                this.txtFreePostAge.Text = vs.FreePostAge.ToString();

                this.txtHomeCommendProductCount.Text = vs.HomeCommendProductCount.ToString();
                this.txtHomeLatestProductCount.Text  = vs.HomeLatestProductCount.ToString();
            }
        }
Esempio n. 4
0
        public static VShopConfig Get()
        {
            if (!File.Exists(_VShopConfigPath))
            {
                Save(new VShopConfig());  //如果文件不存在,则生成一个默认的配置文件。
            }

            //如果当前配置文件的修改时间小于上次的修改时间,则认为配置文件已经被修改,需重新加载
            if (config == null || configFileModifyDate < System.IO.File.GetLastWriteTime(_VShopConfigPath))
            {
                try
                {
                    config = (VShopConfig)SerializeHelper.LoadFromFile(new VShopConfig().GetType(), _VShopConfigPath);
                    configFileModifyDate = DateTime.Now;
                }
                catch { }
            }


            return(config);
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                VShopConfig vsconfig = VShopConfigHelper.Get();

                //获取从wxProcess.aspx传递过来的跳转地址reurl
                if (Request.QueryString["reurl"] != null && Request.QueryString["reurl"] != "")
                {
                    reurl = Request.QueryString["reurl"].ToString();
                }

                string code = "";
                if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
                {
                    //获取微信回传的code
                    code = Request.QueryString["code"].ToString();
                    OAuth_Token Model           = Get_token(code);                      //获取token
                    OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                    if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                    {
                        //在页面上输出用户信息
                        //Response.Write("用户OPENID:" + OAuthUser_Model.openid + "<br>用户昵称:" + OAuthUser_Model.nickname + "<br>性别:" + OAuthUser_Model.sex + "<br>所在省:" + OAuthUser_Model.province + "<br>所在市:" + OAuthUser_Model.city + "<br>所在国家:" + OAuthUser_Model.country + "<br>头像地址:" + OAuthUser_Model.headimgurl + "<br>用户特权信息:" + OAuthUser_Model.privilege);

                        //先判断该用户之前是否注册过
                        UserModel oLoginUser = UserFactory.Get(OAuthUser_Model.openid);
                        if (oLoginUser == null)  //没注册,则重新注册一个
                        {
                            UserModel regu = new UserModel();
                            regu.openid     = OAuthUser_Model.openid;
                            regu.nickname   = Utils.RemoveEmoji(OAuthUser_Model.nickname);
                            regu.sex        = OAuthUser_Model.sex == "1" ? "男性" : "女性";
                            regu.headpicurl = OAuthUser_Model.headimgurl;
                            regu.address    = string.Empty; //OAuthUser_Model.province + OAuthUser_Model.city;

                            UserFactory.Add(regu);

                            oLoginUser = UserFactory.Get(OAuthUser_Model.openid);
                            OdnShop.Core.PageControler.WebPageBase.WriteUidCookie(oLoginUser.uid, 0);

                            if (reurl.ToLower().IndexOf("share.aspx") >= 0)
                            {
                                reurl += "&regnew=1";
                            }
                        }
                        else   //有注册过
                        {
                            oLoginUser.headpicurl = OAuthUser_Model.headimgurl;
                            UserFactory.Update(oLoginUser);

                            OdnShop.Core.PageControler.WebPageBase.WriteUidCookie(oLoginUser.uid, 0);
                        }

                        //或跳转到自己的页面,想怎么处理就怎么处理
                        Response.Redirect(reurl);
                    }
                    else  //未获得openid,回到原始页面
                    {
                        Response.Redirect(reurl);
                    }
                }
            }
        }
Esempio n. 6
0
 public static void Save(VShopConfig info)
 {
     SerializeHelper.SaveToFile(info, _VShopConfigPath);
 }