Пример #1
0
        public bool Add(Model_UserOrder model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into UserOrder(");
            builder.Append("UserOrder_Id,UserId,UserOrder_No,UserOrder_Time,UserOrder_Paytool,UsreOrder_Buyeremail,UserOrder_Remark,UserOrder_Type,UserOrder_Amount,UserOrder_Status,UserOrder_FinishTime,Book_Id,Book_Name,Book_Price,BookImg_Url,trade_no,trade_status)");
            builder.Append(" values (");
            builder.Append("@UserOrder_Id,@UserId,@UserOrder_No,@UserOrder_Time,@UserOrder_Paytool,@UsreOrder_Buyeremail,@UserOrder_Remark,@UserOrder_Type,@UserOrder_Amount,@UserOrder_Status,@UserOrder_FinishTime,@Book_Id,@Book_Name,@Book_Price,@BookImg_Url,@trade_no,@trade_status)");
            SqlParameter[] cmdParms = new SqlParameter[] {
                new SqlParameter("@UserOrder_Id", SqlDbType.Char, 0x24), new SqlParameter("@UserId", SqlDbType.Char, 0x24), new SqlParameter("@UserOrder_No", SqlDbType.VarChar, 50), new SqlParameter("@UserOrder_Time", SqlDbType.DateTime), new SqlParameter("@UserOrder_Paytool", SqlDbType.VarChar, 50), new SqlParameter("@UsreOrder_Buyeremail", SqlDbType.VarChar, 100), new SqlParameter("@UserOrder_Remark", SqlDbType.VarChar, 500), new SqlParameter("@UserOrder_Type", SqlDbType.VarChar, 10), new SqlParameter("@UserOrder_Amount", SqlDbType.Decimal, 9), new SqlParameter("@UserOrder_Status", SqlDbType.Int, 4), new SqlParameter("@UserOrder_FinishTime", SqlDbType.DateTime), new SqlParameter("@Book_Id", SqlDbType.Char, 0x24), new SqlParameter("@Book_Name", SqlDbType.NVarChar, 100), new SqlParameter("@Book_Price", SqlDbType.Decimal, 9), new SqlParameter("@BookImg_Url", SqlDbType.VarChar, 500), new SqlParameter("@trade_no", SqlDbType.NVarChar, 100),
                new SqlParameter("@trade_status", SqlDbType.NVarChar, 50)
            };
            cmdParms[0].Value    = model.UserOrder_Id;
            cmdParms[1].Value    = model.UserId;
            cmdParms[2].Value    = model.UserOrder_No;
            cmdParms[3].Value    = model.UserOrder_Time;
            cmdParms[4].Value    = model.UserOrder_Paytool;
            cmdParms[5].Value    = model.UsreOrder_Buyeremail;
            cmdParms[6].Value    = model.UserOrder_Remark;
            cmdParms[7].Value    = model.UserOrder_Type;
            cmdParms[8].Value    = model.UserOrder_Amount;
            cmdParms[9].Value    = model.UserOrder_Status;
            cmdParms[10].Value   = model.UserOrder_FinishTime;
            cmdParms[11].Value   = model.Book_Id;
            cmdParms[12].Value   = model.Book_Name;
            cmdParms[13].Value   = model.Book_Price;
            cmdParms[14].Value   = model.BookImg_Url;
            cmdParms[15].Value   = model.trade_no;
            cmdParms[0x10].Value = model.trade_status;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Пример #2
0
        public bool Update(Model_UserOrder model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update UserOrder set ");
            builder.Append("UserId=@UserId,");
            builder.Append("UserOrder_No=@UserOrder_No,");
            builder.Append("UserOrder_Time=@UserOrder_Time,");
            builder.Append("UserOrder_Paytool=@UserOrder_Paytool,");
            builder.Append("UsreOrder_Buyeremail=@UsreOrder_Buyeremail,");
            builder.Append("UserOrder_Remark=@UserOrder_Remark,");
            builder.Append("UserOrder_Type=@UserOrder_Type,");
            builder.Append("UserOrder_Amount=@UserOrder_Amount,");
            builder.Append("UserOrder_Status=@UserOrder_Status,");
            builder.Append("UserOrder_FinishTime=@UserOrder_FinishTime,");
            builder.Append("Book_Id=@Book_Id,");
            builder.Append("Book_Name=@Book_Name,");
            builder.Append("Book_Price=@Book_Price,");
            builder.Append("BookImg_Url=@BookImg_Url,");
            builder.Append("trade_no=@trade_no,");
            builder.Append("trade_status=@trade_status");
            builder.Append(" where UserOrder_Id=@UserOrder_Id ");
            SqlParameter[] cmdParms = new SqlParameter[] {
                new SqlParameter("@UserId", SqlDbType.Char, 0x24), new SqlParameter("@UserOrder_No", SqlDbType.VarChar, 50), new SqlParameter("@UserOrder_Time", SqlDbType.DateTime), new SqlParameter("@UserOrder_Paytool", SqlDbType.VarChar, 50), new SqlParameter("@UsreOrder_Buyeremail", SqlDbType.VarChar, 100), new SqlParameter("@UserOrder_Remark", SqlDbType.VarChar, 500), new SqlParameter("@UserOrder_Type", SqlDbType.VarChar, 10), new SqlParameter("@UserOrder_Amount", SqlDbType.Decimal, 9), new SqlParameter("@UserOrder_Status", SqlDbType.Int, 4), new SqlParameter("@UserOrder_FinishTime", SqlDbType.DateTime), new SqlParameter("@Book_Id", SqlDbType.Char, 0x24), new SqlParameter("@Book_Name", SqlDbType.NVarChar, 100), new SqlParameter("@Book_Price", SqlDbType.Decimal, 9), new SqlParameter("@BookImg_Url", SqlDbType.VarChar, 500), new SqlParameter("@trade_no", SqlDbType.NVarChar, 100), new SqlParameter("@trade_status", SqlDbType.NVarChar, 50),
                new SqlParameter("@UserOrder_Id", SqlDbType.Char, 0x24)
            };
            cmdParms[0].Value    = model.UserId;
            cmdParms[1].Value    = model.UserOrder_No;
            cmdParms[2].Value    = model.UserOrder_Time;
            cmdParms[3].Value    = model.UserOrder_Paytool;
            cmdParms[4].Value    = model.UsreOrder_Buyeremail;
            cmdParms[5].Value    = model.UserOrder_Remark;
            cmdParms[6].Value    = model.UserOrder_Type;
            cmdParms[7].Value    = model.UserOrder_Amount;
            cmdParms[8].Value    = model.UserOrder_Status;
            cmdParms[9].Value    = model.UserOrder_FinishTime;
            cmdParms[10].Value   = model.Book_Id;
            cmdParms[11].Value   = model.Book_Name;
            cmdParms[12].Value   = model.Book_Price;
            cmdParms[13].Value   = model.BookImg_Url;
            cmdParms[14].Value   = model.trade_no;
            cmdParms[15].Value   = model.trade_status;
            cmdParms[0x10].Value = model.UserOrder_Id;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Пример #3
0
        public List <Model_UserOrder> DataTableToList(DataTable dt)
        {
            List <Model_UserOrder> list = new List <Model_UserOrder>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Model_UserOrder item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Пример #4
0
        /**
         * 生成直接支付url,支付url有效期为2小时,模式二
         * @param rId 订单ID加密
         * @return 模式二URL
         */
        public string GetPayUrl(string rId)
        {
            //Log.Info(this.GetType().ToString(), "Native pay mode 2 url is producing...");

            rId = Rc.Common.DBUtility.DESEncrypt.Decrypt(rId);
            Model_UserOrder model = new Model_UserOrder();
            BLL_UserOrder   bll   = new BLL_UserOrder();

            model = bll.GetModelByOrderNo(rId);
            int total_fee = Convert.ToInt32(model.UserOrder_Amount * 100);

            WxPayData data = new WxPayData();

            data.SetValue("body", Rc.Cloud.Web.Common.pfunction.GetSubstring(model.Book_Name, 20, false));//商品描述 示例值:腾讯充值中心-QQ会员充值
            //data.SetValue("detail", model.Book_Name); // 商品详情
            //data.SetValue("attach", "test");//附加数据
            data.SetValue("out_trade_no", model.UserOrder_No); //订单号 //随机字符串WxPayApi.GenerateOutTradeNo()
            data.SetValue("total_fee", total_fee);             //总金额
            //data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));//交易起始时间
            //data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));//交易结束时间
            //data.SetValue("goods_tag", "jjj");//商品标记
            data.SetValue("trade_type", "NATIVE");                                                                                                 //交易类型
            data.SetValue("product_id", model.Book_Id);                                                                                            //商品ID
            data.SetValue("notify_url", string.Format("{0}/Payment/WxPayAPI/ResultNotifyPage.aspx", Rc.Cloud.Web.Common.pfunction.getHostPath())); //异步通知url

            WxPayData result = WxPayApi.UnifiedOrder(data);                                                                                        //调用统一下单接口
            //Log.Info(this.GetType().ToString(), "调用统一下单接口返回数据 : " + result.ToXml());
            string url = string.Empty;

            if (result.GetValue("return_code").ToString() == "SUCCESS" && result.GetValue("result_code").ToString() == "SUCCESS")
            {
                url = result.GetValue("code_url").ToString();//获得统一下单接口返回的二维码链接
            }
            else
            {
                Log.Error("Get native pay mode 2 url ", result.ToXml());
            }

            //Log.Info(this.GetType().ToString(), "Get native pay mode 2 url : " + url);
            return(url);
        }
Пример #5
0
        public bool UpdateAndAddUserBuyResources(Model_UserOrder modelUO, Model_UserBuyResources buyModel)
        {
            Dictionary <string, SqlParameter[]> dictionary = new Dictionary <string, SqlParameter[]>();
            StringBuilder builder = new StringBuilder();

            builder = new StringBuilder();
            builder.Append("update UserOrder set ");
            builder.Append("UserOrder_Paytool=@UserOrder_Paytool,");
            builder.Append("UsreOrder_Buyeremail=@UsreOrder_Buyeremail,");
            builder.Append("UserOrder_Status=@UserOrder_Status,");
            builder.Append("UserOrder_FinishTime=@UserOrder_FinishTime,");
            builder.Append("trade_no=@trade_no,");
            builder.Append("trade_status=@trade_status");
            builder.Append(" where UserOrder_Id=@UserOrder_Id ");
            SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@UserOrder_Paytool", SqlDbType.VarChar, 50), new SqlParameter("@UsreOrder_Buyeremail", SqlDbType.VarChar, 100), new SqlParameter("@UserOrder_Status", SqlDbType.Int, 4), new SqlParameter("@UserOrder_FinishTime", SqlDbType.DateTime), new SqlParameter("@trade_no", SqlDbType.NVarChar, 100), new SqlParameter("@trade_status", SqlDbType.NVarChar, 50), new SqlParameter("@UserOrder_Id", SqlDbType.Char, 0x24) };
            parameterArray[0].Value = modelUO.UserOrder_Paytool;
            parameterArray[1].Value = modelUO.UsreOrder_Buyeremail;
            parameterArray[2].Value = modelUO.UserOrder_Status;
            parameterArray[3].Value = modelUO.UserOrder_FinishTime;
            parameterArray[4].Value = modelUO.trade_no;
            parameterArray[5].Value = modelUO.trade_status;
            parameterArray[6].Value = modelUO.UserOrder_Id;
            dictionary.Add(builder.ToString(), parameterArray);
            builder = new StringBuilder();
            builder.Append("insert into UserBuyResources(");
            builder.Append("UserBuyResources_ID,UserId,Book_id,BookPrice,BuyType,CreateTime,CreateUser)");
            builder.Append(" values (");
            builder.Append("@UserBuyResources_ID,@UserId,@Book_id,@BookPrice,@BuyType,@CreateTime,@CreateUser)");
            SqlParameter[] parameterArray2 = new SqlParameter[] { new SqlParameter("@UserBuyResources_ID", SqlDbType.Char, 0x24), new SqlParameter("@UserId", SqlDbType.Char, 0x24), new SqlParameter("@Book_id", SqlDbType.Char, 0x24), new SqlParameter("@BookPrice", SqlDbType.Decimal, 5), new SqlParameter("@BuyType", SqlDbType.VarChar, 20), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@CreateUser", SqlDbType.Char, 0x24) };
            parameterArray2[0].Value = buyModel.UserBuyResources_ID;
            parameterArray2[1].Value = buyModel.UserId;
            parameterArray2[2].Value = buyModel.Book_id;
            parameterArray2[3].Value = buyModel.BookPrice;
            parameterArray2[4].Value = buyModel.BuyType;
            parameterArray2[5].Value = buyModel.CreateTime;
            parameterArray2[6].Value = buyModel.CreateUser;
            dictionary.Add(builder.ToString(), parameterArray2);
            return(DbHelperSQL.ExecuteSqlTran(dictionary) > 0);
        }
Пример #6
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         string rid = context.Request.QueryString["rid"].Filter();
         rid = Rc.Common.DBUtility.DESEncrypt.Decrypt(rid);
         Model_UserOrder model = new Model_UserOrder();
         BLL_UserOrder   bll   = new BLL_UserOrder();
         model = bll.GetModelByOrderNo(rid);
         if (model.UserOrder_Status == (int)UOrderStatus.完成 && !string.IsNullOrEmpty(model.trade_no) && !string.IsNullOrEmpty(model.trade_status))
         {
             context.Response.Write("success");
         }
         else
         {
             context.Response.Write("fail");
         }
     }
     catch (Exception ex)
     {
         new Rc.Cloud.BLL.BLL_clsAuth().AddLogErrorFromBS("", string.Format("类:{0},方法{1},错误信息:{2}", ex.TargetSite.DeclaringType.ToString(), ex.TargetSite.Name.ToString(), ex.Message));
         context.Response.Write("error");
     }
 }
Пример #7
0
 public bool UpdateAndAddUserBuyResources(Model_UserOrder model, Model_UserBuyResources buyModel)
 {
     return(this.dal.UpdateAndAddUserBuyResources(model, buyModel));
 }
Пример #8
0
 public bool Update(Model_UserOrder model)
 {
     return(this.dal.Update(model));
 }
Пример #9
0
 public bool Add(Model_UserOrder model)
 {
     return(this.dal.Add(model));
 }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string rid    = Request.QueryString["rid"].Filter();
                string key    = Request.QueryString["key"].Filter();
                string bankId = Request.QueryString["defaultbank"].Filter();
                rid = Rc.Common.DBUtility.DESEncrypt.Decrypt(rid);
                Model_UserOrder model = new Model_UserOrder();
                BLL_UserOrder   bll   = new BLL_UserOrder();
                model = bll.GetModelByOrderNo(rid);
                string domain = Rc.Cloud.Web.Common.pfunction.getHostPath();

                ////////////////////////////////////////////请求参数////////////////////////////////////////////

                //支付类型
                string payment_type = "1";
                //必填,不能修改
                //服务器异步通知页面路径
                string notify_url = string.Format("{0}/Payment/notify_Alipay.aspx", domain);
                //需http://格式的完整路径,不能加?id=123这类自定义参数

                //页面跳转同步通知页面路径
                string return_url = string.Format("{0}/Payment/return_Alipay.aspx", domain);

                //商户订单号
                string out_trade_no = model.UserOrder_No;
                //商户网站订单系统中唯一订单号,必填

                //订单名称
                string subject = model.Book_Name;
                //必填

                //付款金额
                string total_fee = model.UserOrder_Amount.ToString();
                //必填

                //订单描述
                string body = model.Book_Name;

                //默认支付方式
                string paymethod = "bankPay";
                //必填
                //默认网银
                string defaultbank = bankId;
                //必填,银行简码请参考接口技术文档

                //商品展示地址
                string show_url = "";// string.Format("http://{0}/Show.aspx", domain);
                //需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html

                //防钓鱼时间戳
                string anti_phishing_key = Submit.Query_timestamp();
                //若要使用请调用类文件submit中的query_timestamp函数

                //客户端的IP地址
                string exter_invoke_ip = Rc.Cloud.Web.Common.pfunction.GetRealIP();
                //非局域网的外网IP地址,如:221.0.0.1

                //把请求参数打包成数组
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                if (key == "platform")
                {
                    #region 即时到账交易
                    sParaTemp.Add("service", "create_direct_pay_by_user");
                    sParaTemp.Add("partner", Config.Partner);
                    sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                    sParaTemp.Add("notify_url", notify_url);
                    sParaTemp.Add("return_url", return_url);
                    //业务参数
                    sParaTemp.Add("out_trade_no", out_trade_no);
                    sParaTemp.Add("subject", subject);
                    sParaTemp.Add("payment_type", payment_type);
                    sParaTemp.Add("total_fee", total_fee);
                    sParaTemp.Add("seller_id", Config.Partner);
                    sParaTemp.Add("seller_email", Config.Seller_email);
                    sParaTemp.Add("body", body);
                    sParaTemp.Add("show_url", show_url);
                    sParaTemp.Add("anti_phishing_key", anti_phishing_key);
                    sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);
                    sParaTemp.Add("qr_pay_mode", "4");
                    sParaTemp.Add("qrcode_width", "200");
                    #endregion
                }
                else if (key == "bank")
                {
                    #region 网银支付
                    sParaTemp.Add("service", "create_direct_pay_by_user");
                    sParaTemp.Add("partner", Config.Partner);
                    sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                    sParaTemp.Add("notify_url", notify_url);
                    sParaTemp.Add("return_url", return_url);
                    //业务参数
                    sParaTemp.Add("out_trade_no", out_trade_no);
                    sParaTemp.Add("subject", subject);
                    sParaTemp.Add("payment_type", payment_type);
                    sParaTemp.Add("total_fee", total_fee);
                    sParaTemp.Add("seller_id", Config.Partner);
                    sParaTemp.Add("seller_email", Config.Seller_email);
                    sParaTemp.Add("body", body);
                    sParaTemp.Add("paymethod", paymethod);
                    sParaTemp.Add("defaultbank", defaultbank);
                    sParaTemp.Add("show_url", show_url);
                    sParaTemp.Add("anti_phishing_key", anti_phishing_key);
                    sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);
                    #endregion
                }


                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                Response.Write(sHtmlText);
            }
            catch (Exception)
            {
                Response.Write("<script language=\"javascript\">alert('请求失败,请返回重新操作');</script>");
            }
        }
Пример #11
0
        private void LoadData()
        {
            Model_Bookshelves modelBook = new BLL_Bookshelves().GetModel(rid);
            BLL_UserOrder     bll       = new BLL_UserOrder();
            Model_UserOrder   model     = new Model_UserOrder();

            try
            {
                //if (bll.GetRecordCount("UserId='" + userId + "' and Book_Id='" + rid + "' and UserOrder_Status='" + (int)UOrderStatus.完成 + "' ") > 0)
                //{
                //    ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "您已购买此教材,无需重复购买."));
                //    return;
                //}
                decimal amount = Convert.ToDecimal(modelBook.BookPrice);
                ltlAmount.Text = amount.ToString();
                if (amount <= 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单."));
                    return;
                }
                if (string.IsNullOrEmpty(orderNo))
                {
                    string    userId = FloginUser.UserId;
                    DataTable dt     = bll.GetList("UserId='" + userId + "' and Book_Id='" + rid + "'").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        DataRow[] dr = dt.Select("UserOrder_Status='" + (int)UOrderStatus.完成 + "'");
                        if (dr.Length > 0)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "您已购买此教材,无需重复购买."));
                            return;
                        }
                        DataRow[] dr1 = dt.Select("UserOrder_Status='" + (int)UOrderStatus.待付款 + "'");
                        if (dr1.Length > 0)
                        {
                            orderNo              = dr1[0]["UserOrder_No"].ToString();
                            enOrderNo            = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo);
                            ltlUserOrder_No.Text = orderNo;
                        }
                        else
                        {
                            DataRow[] dr2 = dt.Select("UserOrder_Status='" + (int)UOrderStatus.已取消 + "'");
                            if (dr2.Length > 0)
                            {
                                orderNo = GenerateUMOrderNo();
                                //if (bll.GetRecordCount("UserOrder_No='" + orderNo + "'") > 0)
                                //{
                                //    ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单."));
                                //    return;
                                //}
                                enOrderNo                  = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo);
                                ltlUserOrder_No.Text       = orderNo;
                                model.UserOrder_Id         = Guid.NewGuid().ToString();
                                model.UserId               = userId;
                                model.UserOrder_No         = orderNo;
                                model.UserOrder_Time       = DateTime.Now;
                                model.UserOrder_Paytool    = "";
                                model.UsreOrder_Buyeremail = "";
                                model.UserOrder_Type       = orderType;
                                model.UserOrder_Amount     = amount;
                                model.UserOrder_Status     = (int)Rc.Model.Resources.UOrderStatus.待付款;
                                model.Book_Id              = modelBook.ResourceFolder_Id;
                                model.Book_Name            = modelBook.Book_Name;
                                model.Book_Price           = Convert.ToDecimal(modelBook.BookPrice);
                                model.BookImg_Url          = modelBook.BookImg_Url;
                                if (!bll.Add(model))
                                {
                                    ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单..."));
                                    return;
                                }
                                else
                                {
                                    #region 0元资源,自动购买,暂不启用
                                    //model.UserOrder_Status = (int)UOrderStatus.完成;
                                    //model.UserOrder_FinishTime = DateTime.Now;
                                    //#region 用户购买资源表
                                    //Model_UserBuyResources buyModel = new Model_UserBuyResources();
                                    //buyModel.UserBuyResources_ID = Guid.NewGuid().ToString();
                                    //buyModel.UserId = model.UserId;
                                    //buyModel.Book_id = model.Book_Id;
                                    //buyModel.BookPrice = model.Book_Price;
                                    //buyModel.BuyType = UserOrder_PaytoolEnum.FREE.ToString();
                                    //buyModel.CreateTime = DateTime.Now;
                                    //#endregion
                                    //bll.UpdateAndAddUserBuyResources(model, buyModel);
                                    #endregion
                                }
                            }
                        }
                    }
                    else
                    {
                        orderNo = GenerateUMOrderNo();
                        if (bll.GetRecordCount("UserOrder_No='" + orderNo + "'") > 0)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单."));
                            return;
                        }
                        enOrderNo                  = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo);
                        ltlUserOrder_No.Text       = orderNo;
                        model.UserOrder_Id         = Guid.NewGuid().ToString();
                        model.UserId               = userId;
                        model.UserOrder_No         = orderNo;
                        model.UserOrder_Time       = DateTime.Now;
                        model.UserOrder_Paytool    = "";
                        model.UsreOrder_Buyeremail = "";
                        model.UserOrder_Type       = orderType;
                        model.UserOrder_Amount     = amount;
                        model.UserOrder_Status     = (int)Rc.Model.Resources.UOrderStatus.待付款;
                        model.Book_Id              = modelBook.ResourceFolder_Id;
                        model.Book_Name            = modelBook.Book_Name;
                        model.Book_Price           = Convert.ToDecimal(modelBook.BookPrice);
                        model.BookImg_Url          = modelBook.BookImg_Url;
                        if (!bll.Add(model))
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单..."));
                            return;
                        }
                        else
                        {
                            #region 0元资源,自动购买,暂不启用
                            //model.UserOrder_Status = (int)UOrderStatus.完成;
                            //model.UserOrder_FinishTime = DateTime.Now;
                            //#region 用户购买资源表
                            //Model_UserBuyResources buyModel = new Model_UserBuyResources();
                            //buyModel.UserBuyResources_ID = Guid.NewGuid().ToString();
                            //buyModel.UserId = model.UserId;
                            //buyModel.Book_id = model.Book_Id;
                            //buyModel.BookPrice = model.Book_Price;
                            //buyModel.BuyType = UserOrder_PaytoolEnum.FREE.ToString();
                            //buyModel.CreateTime = DateTime.Now;
                            //#endregion
                            //bll.UpdateAndAddUserBuyResources(model, buyModel);
                            #endregion
                        }
                    }
                }
                else
                {
                    enOrderNo            = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo);
                    ltlUserOrder_No.Text = orderNo;
                }
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单...."));
                return;
            }
        }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                Notify aliNotify    = new Notify();
                bool   verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);

                if (verifyResult)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码


                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                    //商户订单号

                    string out_trade_no = Request.Form["out_trade_no"].Filter();

                    //支付宝交易号

                    string trade_no = Request.Form["trade_no"].Filter();

                    //交易状态
                    string trade_status = Request.Form["trade_status"].Filter();

                    //买家支付宝账号
                    string buyer_email = Request.Form["buyer_email"];

                    int orderStatus = 1;// (int)XHZ.Model.UOrderStatus.等待付款;
                    if (trade_status.ToUpper() == "TRADE_FINISHED")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序

                        //注意:
                        //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
                        orderStatus = (int)UOrderStatus.付款成功;
                    }
                    else if (trade_status.ToUpper() == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序

                        //注意:
                        //付款完成后,支付宝系统发送该交易状态通知
                        orderStatus = (int)UOrderStatus.付款成功;
                    }
                    else
                    {
                    }

                    //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                    Rc.Web.Payment.Core.LogHandler.WriteLogForPay(out_trade_no, "付款成功", trade_no);

                    #region 付款成功 异步更新订单表 author:Ethan
                    Model_UserOrder model = new Model_UserOrder();
                    BLL_UserOrder   bll   = new BLL_UserOrder();
                    model = bll.GetModelByOrderNo(out_trade_no);

                    if (orderStatus == (int)UOrderStatus.付款成功 && model.UserOrder_Status == (int)UOrderStatus.待付款)
                    {
                        model.UserOrder_Paytool    = UserOrder_PaytoolEnum.ALIPAY.ToString();
                        model.UsreOrder_Buyeremail = buyer_email;
                        model.trade_no             = trade_no;
                        model.trade_status         = trade_status;
                        model.UserOrder_Status     = (int)UOrderStatus.完成;
                        model.UserOrder_FinishTime = DateTime.Now;

                        bool executeFlag = false;
                        if (new BLL_UserBuyResources().GetRecordCount(string.Format("UserId='{0}' and Book_id='{1}' ", model.UserId, model.Book_Id)) == 0)
                        {
                            #region 用户购买资源表
                            Model_UserBuyResources buyModel = new Model_UserBuyResources();
                            buyModel.UserBuyResources_ID = Guid.NewGuid().ToString();
                            buyModel.UserId     = model.UserId;
                            buyModel.Book_id    = model.Book_Id;
                            buyModel.BookPrice  = model.Book_Price;
                            buyModel.BuyType    = UserOrder_PaytoolEnum.ALIPAY.ToString();
                            buyModel.CreateTime = DateTime.Now;
                            buyModel.CreateUser = "******";
                            #endregion
                            executeFlag = bll.UpdateAndAddUserBuyResources(model, buyModel);
                        }
                        else
                        {
                            executeFlag = bll.Update(model);
                        }

                        if (executeFlag)
                        {
                            //try
                            //{
                            //    P_User userModel = new P_UserBLL().GetModel(model.user_id);
                            //    pfunction.SendSMS(userModel.moblie, "您的订单" + model.OrderNo + "已支付成功");
                            //}
                            //catch
                            //{

                            //}
                            //if (new U_OrdersHandleBLL().GetRecordCount("OrderId='" + model.OrderId + "' and OperateUser='******'") == 0)
                            //{
                            //    pfunction.InsertOrderHandle(model.OrderId, "您已" + XHZ.Common.EnumService.GetDescription<UOrderStatus>(orderStatus), "支付接口异步回调");
                            //}
                            new Rc.Cloud.BLL.BLL_clsAuth().AddLogFromBS(Request.Url.ToString(), string.Format("支付宝回调。购买资源成功,购买人:{0},资源标识:{1}"
                                                                                                              , model.UserId, model.Book_Id));
                            Response.Write("success");  //请不要修改或删除
                        }
                    }
                    #endregion

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
Пример #13
0
        public Model_UserOrder DataRowToModel(DataRow row)
        {
            Model_UserOrder order = new Model_UserOrder();

            if (row != null)
            {
                if (row["UserOrder_Id"] != null)
                {
                    order.UserOrder_Id = row["UserOrder_Id"].ToString();
                }
                if (row["UserId"] != null)
                {
                    order.UserId = row["UserId"].ToString();
                }
                if (row["UserOrder_No"] != null)
                {
                    order.UserOrder_No = row["UserOrder_No"].ToString();
                }
                if ((row["UserOrder_Time"] != null) && (row["UserOrder_Time"].ToString() != ""))
                {
                    order.UserOrder_Time = DateTime.Parse(row["UserOrder_Time"].ToString());
                }
                if (row["UserOrder_Paytool"] != null)
                {
                    order.UserOrder_Paytool = row["UserOrder_Paytool"].ToString();
                }
                if (row["UsreOrder_Buyeremail"] != null)
                {
                    order.UsreOrder_Buyeremail = row["UsreOrder_Buyeremail"].ToString();
                }
                if (row["UserOrder_Remark"] != null)
                {
                    order.UserOrder_Remark = row["UserOrder_Remark"].ToString();
                }
                if (row["UserOrder_Type"] != null)
                {
                    order.UserOrder_Type = row["UserOrder_Type"].ToString();
                }
                if ((row["UserOrder_Amount"] != null) && (row["UserOrder_Amount"].ToString() != ""))
                {
                    order.UserOrder_Amount = decimal.Parse(row["UserOrder_Amount"].ToString());
                }
                if ((row["UserOrder_Status"] != null) && (row["UserOrder_Status"].ToString() != ""))
                {
                    order.UserOrder_Status = int.Parse(row["UserOrder_Status"].ToString());
                }
                if ((row["UserOrder_FinishTime"] != null) && (row["UserOrder_FinishTime"].ToString() != ""))
                {
                    order.UserOrder_FinishTime = DateTime.Parse(row["UserOrder_FinishTime"].ToString());
                }
                if (row["Book_Id"] != null)
                {
                    order.Book_Id = row["Book_Id"].ToString();
                }
                if (row["Book_Name"] != null)
                {
                    order.Book_Name = row["Book_Name"].ToString();
                }
                if ((row["Book_Price"] != null) && (row["Book_Price"].ToString() != ""))
                {
                    order.Book_Price = decimal.Parse(row["Book_Price"].ToString());
                }
                if (row["BookImg_Url"] != null)
                {
                    order.BookImg_Url = row["BookImg_Url"].ToString();
                }
                if (row["trade_no"] != null)
                {
                    order.trade_no = row["trade_no"].ToString();
                }
                if (row["trade_status"] != null)
                {
                    order.trade_status = row["trade_status"].ToString();
                }
            }
            return(order);
        }
Пример #14
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
            {
                Log.Info(this.GetType().ToString(), "订单支付成功,异步回调");

                #region 支付成功,异步更新订单表2016-06-30TS
                Model_UserOrder model = new Model_UserOrder();
                BLL_UserOrder   bll   = new BLL_UserOrder();
                model = bll.GetModelByOrderNo(notifyData.GetValue("out_trade_no").ToString());

                if (model.UserOrder_Status == (int)UOrderStatus.待付款 || string.IsNullOrEmpty(model.trade_no) || string.IsNullOrEmpty(model.trade_status))
                {
                    model.UserOrder_Paytool    = UserOrder_PaytoolEnum.WXPAY.ToString();
                    model.UsreOrder_Buyeremail = notifyData.GetValue("openid").ToString();
                    model.trade_no             = notifyData.GetValue("transaction_id").ToString();
                    model.trade_status         = notifyData.GetValue("return_code").ToString();
                    model.UserOrder_Status     = (int)UOrderStatus.完成;
                    model.UserOrder_FinishTime = DateTime.Now;

                    bool executeFlag = false;
                    if (new BLL_UserBuyResources().GetRecordCount(string.Format("UserId='{0}' and Book_id='{1}' ", model.UserId, model.Book_Id)) == 0)
                    {
                        #region 用户购买资源表
                        Model_UserBuyResources buyModel = new Model_UserBuyResources();
                        buyModel.UserBuyResources_ID = Guid.NewGuid().ToString();
                        buyModel.UserId     = model.UserId;
                        buyModel.Book_id    = model.Book_Id;
                        buyModel.BookPrice  = model.Book_Price;
                        buyModel.BuyType    = UserOrder_PaytoolEnum.WXPAY.ToString();
                        buyModel.CreateTime = DateTime.Now;
                        buyModel.CreateUser = "******";
                        #endregion
                        executeFlag = bll.UpdateAndAddUserBuyResources(model, buyModel);
                    }
                    else
                    {
                        executeFlag = bll.Update(model);
                    }
                    if (executeFlag)
                    {
                        new Rc.Cloud.BLL.BLL_clsAuth().AddLogFromBS(page.Request.Url.ToString(), string.Format("微信回调。购买资源成功,购买人:{0},资源标识:{1}"
                                                                                                               , model.UserId, model.Book_Id));
                    }
                }
                #endregion

                WxPayData res = new WxPayData();
                res.SetValue("return_code", "SUCCESS");
                res.SetValue("return_msg", "OK");

                page.Response.Write(res.ToXml());
                page.Response.End();
            }
        }