Beispiel #1
0
        /// <summary>
        /// 生成银行订单
        /// </summary>
        /// <param name="merId">商户号</param>
        /// <param name="orderId">订单ID</param>
        /// <param name="txnTime">订单开始时间</param>
        /// <param name="total_fee">总金额分</param>
        /// <param name="R">是否成功生成订单</param>
        /// <returns></returns>
        public string GenerateBankOrder(string CommunityId, string out_trade_no, string txnTime, string total_fee, ref bool R, ref string prepay_str)
        {
            DataTable CommunityTable = new DbHelperSQLP(PubConstant.GetConnectionString("APPConnection")).Query("SELECT * FROM Tb_HSPR_Community WHERE CommID='" + CommunityId.ToString() + "'").Tables[0];

            Dictionary <string, string> sPara = new Dictionary <string, string>();

            sPara.Add("partner", c.partner.ToString());
            sPara.Add("seller_id", c.seller_id.ToString());
            sPara.Add("out_trade_no", out_trade_no.ToString());
            if (CommunityTable != null && CommunityTable.Columns.Contains("CommName") && CommunityTable.Rows.Count > 0)
            {
                sPara.Add("subject", CommunityTable.Rows[0]["CommName"].ToString() + "-物管费用");
            }
            else
            {
                sPara.Add("subject", "物管费用");
            }

            sPara.Add("body", CommunityId);
            sPara.Add("total_fee", total_fee.ToString());
            sPara.Add("notify_url", c.notify_url.ToString());
            sPara.Add("service", c.service.ToString());
            sPara.Add("payment_type", c.payment_type.ToString());    //支付类型
            sPara.Add("_input_charset", c.input_charset.ToString()); //参数编码字符集
            sPara.Add("it_b_pay", "30m");                            //未付款交易的超时时间

            //将获取的订单信息,按照“参数=参数值”的模式用“&”字符拼接成字符串.
            string data = Core.CreateLinkString(sPara);

            //使用商户的私钥进行RSA签名,并且把sign做一次urleccode.
            string sign = System.Web.HttpUtility.UrlEncode(RSA.sign(data, c.private_key, c.input_charset));

            sPara.Add("sign", sign);             //签名

            sPara.Add("sign_type", c.sign_type); //签名方式

            //拼接请求字符串(注意:不要忘记参数值的引号).
            data = data + "&sign=\"" + sign + "\"&sign_type=\"" + c.sign_type + "\"";

            log.Info("支付宝订单请求:" + data.ToString());

            //返回给客户端请求.
            //prepay_str = data;

            prepay_str = JSONHelper.FromObject(sPara);
            R          = true;
            return("success");
        }
        /// <summary>
        /// 生成三方预支付单
        /// </summary>
        /// <param name="BussId"></param>
        /// <param name="out_trade_no"></param>
        /// <param name="txnTime"></param>
        /// <param name="total_fee"></param>
        /// <param name="R"></param>
        /// <param name="prepay_str"></param>
        /// <returns></returns>
        public string GenerateBankOrder(string BussId, string out_trade_no, string txnTime, decimal total_fee, ref bool R, ref string prepay_str, string subject = "")
        {
            Dictionary <string, string> sPara = new Dictionary <string, string>();

            sPara.Add("partner", c.partner.ToString());
            sPara.Add("seller_id", c.seller_id.ToString());
            sPara.Add("out_trade_no", out_trade_no.ToString());
            sPara.Add("subject", string.IsNullOrEmpty(subject) ? "商品购买" : subject);
            sPara.Add("body", BussId);
            sPara.Add("total_fee", total_fee.ToString("#0.00"));
            sPara.Add("notify_url", c.notify_url.ToString());
            sPara.Add("service", c.service.ToString());
            sPara.Add("payment_type", c.payment_type.ToString());    //支付类型
            sPara.Add("_input_charset", c.input_charset.ToString()); //参数编码字符集
            sPara.Add("it_b_pay", "30m");                            //未付款交易的超时时间

            //将获取的订单信息,按照“参数=参数值”的模式用“&”字符拼接成字符串.
            string data = Core.CreateLinkString(sPara);

            //使用商户的私钥进行RSA签名,并且把sign做一次urleccode.
            string sign = System.Web.HttpUtility.UrlEncode(RSA.sign(data, c.private_key, c.input_charset));

            sPara.Add("sign", sign);             //签名

            sPara.Add("sign_type", c.sign_type); //签名方式

            //拼接请求字符串(注意:不要忘记参数值的引号).
            data = data + "&sign=\"" + sign + "\"&sign_type=\"" + c.sign_type + "\"";

            log.Info("支付宝订单请求:" + data.ToString());

            //返回给客户端请求.
            //prepay_str = data;

            prepay_str = JSONHelper.FromObject(sPara);
            R          = true;
            return("success");
        }
Beispiel #3
0
        /// <summary>
        /// 生成银行订单
        /// </summary>
        /// <param name="merId">商户号</param>
        /// <param name="orderId">订单ID</param>
        /// <param name="txnTime">订单开始时间</param>
        /// <param name="total_fee">总金额分</param>
        /// <param name="R">是否成功生成订单</param>
        /// <returns></returns>
        public string GenerateBankOrder(string CommunityId, string userId, string feesId, string out_trade_no, string txnTime, decimal total_fee, ref bool R, ref string prepay_str)
        {
            Dictionary <string, string> sPara = new Dictionary <string, string>();

            #region 此部分内容,先后顺序不能改变,否则将导致签名错误(支付宝V1版本接口)
            // 顺序严格按照partner,seller_id,out_trade_no,subject,body,total_fee,notify_url,service,payment_type,_input_charset,it_b_pay进行拼接后才能进行签名
            // 顺序不能变,否则会导致签名问题,支付控件提示ALIN10070错误.
            // 支付宝配置指南,生成1024位的RSA密钥,配置支付宝开放平台中的mapi网关产品密钥(RSA1密钥)
            sPara.Add("partner", c.partner.ToString());
            sPara.Add("seller_id", c.seller_id.ToString());
            sPara.Add("out_trade_no", out_trade_no.ToString());

            using (var conn = new SqlConnection(PubConstant.UnifiedContionString.ToString()))
            {
                dynamic commInfo = conn.Query("SELECT * FROM Tb_Community WHERE Id=@CommunityId OR CommID=@CommunityId",
                                              new { CommunityId = CommunityId }).FirstOrDefault();

                if (commInfo != null)
                {
                    // 俊发
                    //if (commInfo.CorpID == 1985)
                    //{
                    //    sPara.Add("subject", commInfo.CommName.ToString() + "物管费用");
                    //}
                    //else
                    //{
                    using (var erpConn = new SqlConnection(PubConstant.hmWyglConnectionString))
                    {
                        dynamic feesInfo = erpConn.Query(@"SELECT
                            (SELECT isnull(c.CommName,'') FROM Tb_HSPR_Community c WHERE x.CommID=c.CommID) AS CommName,
                            (SELECT isnull(isnull(a.RoomName,a.RoomSign),'') 
                                FROM Tb_HSPR_Room a WHERE a.RoomID=x.RoomID) AS RoomName,
                            (SELECT isnull(b.CustName,'') FROM Tb_HSPR_Customer b WHERE b.CustID=x.CustID) AS CustName
                            FROM Tb_HSPR_Fees x WHERE FeesID=@FeesID;", new { FeesID = feesId }).FirstOrDefault();

                        if (feesInfo != null)
                        {
                            string commName = feesInfo.CommName == null ? "" : feesInfo.CommName.ToString();
                            string roomName = feesInfo.RoomName == null ? "" : feesInfo.RoomName.ToString();
                            string custName = feesInfo.CustName == null ? "" : ",业主:" + feesInfo.CustName.ToString();

                            if (!string.IsNullOrEmpty(roomName))
                            {
                                roomName = roomName.Replace("幢", "-").Replace("栋", "-").Replace("单元", "-").Replace("楼", "-").Replace("号", "-").Replace("房", "-")
                                           .Replace("--", "-");
                            }

                            sPara.Add("subject", $"{commName}{roomName}物管费用{custName}");
                        }
                        else
                        {
                            sPara.Add("subject", "物管费用");
                        }
                    }
                    //}
                }
                else
                {
                    sPara.Add("subject", "物管费用");
                }
            }

            sPara.Add("body", CommunityId + "," + userId);
            sPara.Add("total_fee", total_fee.ToString("#0.00"));
            sPara.Add("notify_url", c.notify_url.ToString());
            sPara.Add("service", c.service.ToString());
            sPara.Add("payment_type", c.payment_type.ToString());    //支付类型
            sPara.Add("_input_charset", c.input_charset.ToString()); //参数编码字符集
            sPara.Add("it_b_pay", "30m");                            //未付款交易的超时时间

            #endregion

            //将获取的订单信息,按照“参数=参数值”的模式用“&”字符拼接成字符串.
            string data = Core.CreateLinkString(sPara);

            //使用商户的私钥进行RSA签名,并且把sign做一次urleccode.
            string sign = System.Web.HttpUtility.UrlEncode(RSA.sign(data, c.private_key, c.input_charset));
            sPara.Add("sign", sign);             //签名
            sPara.Add("sign_type", c.sign_type); //签名方式

            //拼接请求字符串(注意:不要忘记参数值的引号).
            data = data + "&sign=\"" + sign + "\"&sign_type=\"" + c.sign_type + "\"";

            log.Info("支付宝订单请求:" + data.ToString());

            //返回给客户端请求.
            //prepay_str = data;

            prepay_str = JSONHelper.FromObject(sPara);
            R          = true;
            return("success");
        }
Beispiel #4
0
        /// <summary>
        /// 生成银行订单
        /// </summary>
        /// <param name="merId">商户号</param>
        /// <param name="orderId">订单ID</param>
        /// <param name="txnTime">订单开始时间</param>
        /// <param name="total_fee">总金额分</param>
        /// <param name="R">是否成功生成订单</param>
        /// <returns></returns>
        public string GenerateBankOrder(string CommunityId, string CustID, string RoomID, string out_trade_no, string txnTime, string total_fee, ref bool R, ref string prepay_str)
        {
            DataTable CommunityTable = new DbHelperSQLP(PubConstant.UnifiedContionString.ToString()).Query(string.Format("SELECT * FROM Tb_Community WHERE Id='{0}' OR CommID='{0}'", CommunityId.ToString())).Tables[0];

            Dictionary <string, string> sPara = new Dictionary <string, string>();

            sPara.Add("partner", c.partner.ToString());
            sPara.Add("seller_id", c.seller_id.ToString());
            sPara.Add("out_trade_no", out_trade_no.ToString());

            using (var conn = new SqlConnection(PubConstant.UnifiedContionString.ToString()))
            {
                dynamic commInfo = conn.Query("SELECT * FROM Tb_Community WHERE Id=@CommunityId OR CommID=@CommunityId",
                                              new { CommunityId = CommunityId }).FirstOrDefault();

                if (commInfo != null)
                {
                    using (var erpConn = new SqlConnection(PubConstant.hmWyglConnectionString))
                    {
                        dynamic roomInfo = erpConn.Query(@"SELECT 
                                (SELECT isnull(c.CommName,'') FROM Tb_HSPR_Community c WHERE 
                                    c.CommID=(SELECT d.CommID FROM Tb_HSPR_Room d WHERE d.RoomID=x.RoomID)) AS CommName,
                                (SELECT isnull(isnull(e.RoomName,e.RoomSign),'') FROM Tb_HSPR_Room e WHERE e.RoomID=x.RoomID) AS RoomName,
                                (SELECT isnull(b.CustName,'') FROM Tb_HSPR_Customer b WHERE b.CustID=x.CustID) AS CustName
                                FROM Tb_HSPR_CustomerLive x WHERE x.RoomID=@RoomID AND x.IsDelLive=0 AND x.LiveType=1;",
                                                         new { RoomID = RoomID }).FirstOrDefault();

                        if (roomInfo != null)
                        {
                            string commName = roomInfo.CommName == null ? "" : roomInfo.CommName.ToString();
                            string roomName = roomInfo.RoomName == null ? "" : roomInfo.RoomName.ToString();
                            string custName = roomInfo.CustName == null ? "" : ",业主:" + roomInfo.CustName.ToString();

                            if (!string.IsNullOrEmpty(roomName))
                            {
                                roomName = roomName.Replace("幢", "-").Replace("栋", "-").Replace("单元", "-").Replace("楼", "-").Replace("号", "-").Replace("房", "-")
                                           .Replace("--", "-");
                            }

                            sPara.Add("subject", $"{commName}{roomName}预存费用{custName}");
                        }
                        else
                        {
                            sPara.Add("subject", "预存费用");
                        }
                    }
                }
                else
                {
                    sPara.Add("subject", "预存费用");
                }
            }

            sPara.Add("body", CommunityId);
            sPara.Add("total_fee", total_fee.ToString());
            sPara.Add("notify_url", c.notify_url.ToString());
            sPara.Add("service", c.service.ToString());
            sPara.Add("payment_type", c.payment_type.ToString());    //支付类型
            sPara.Add("_input_charset", c.input_charset.ToString()); //参数编码字符集
            sPara.Add("it_b_pay", "30m");                            //未付款交易的超时时间

            //将获取的订单信息,按照“参数=参数值”的模式用“&”字符拼接成字符串.
            string data = Core.CreateLinkString(sPara);

            //使用商户的私钥进行RSA签名,并且把sign做一次urleccode.
            string sign = System.Web.HttpUtility.UrlEncode(RSA.sign(data, c.private_key, c.input_charset));

            sPara.Add("sign", sign);             //签名
            sPara.Add("sign_type", c.sign_type); //签名方式

            //拼接请求字符串(注意:不要忘记参数值的引号).
            data = data + "&sign=\"" + sign + "\"&sign_type=\"" + c.sign_type + "\"";

            log.Info("支付宝订单请求:" + data.ToString());

            //返回给客户端请求.
            //prepay_str = data;

            prepay_str = JSONHelper.FromObject(sPara);
            R          = true;
            return("success");
        }