Esempio n. 1
0
        public ColoPay.Model.Pay.Order GetModelEx(string enterOrder, int enterpriseID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 OrderId,OrderCode,EnterOrder,EnterpriseID,Agentd,Amount,PaymentFee,FeeRate,OrderAmount,PayModeId,PaymentTypeName,PaymentGateway,PaymentStatus,OrderStatus,OrderInfo,AppId,AppSecrit,AppUrl,AppReturnUrl,AppNotifyUrl,CreatedTime,Remark from Pay_Order ");
            strSql.Append(" where EnterOrder=@EnterOrder and EnterpriseID=@EnterpriseID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EnterOrder",   SqlDbType.NVarChar, 200),
                new SqlParameter("@EnterpriseID", SqlDbType.Int, 4)
            };
            parameters[0].Value = enterOrder;
            parameters[1].Value = enterpriseID;

            ColoPay.Model.Pay.Order model = new ColoPay.Model.Pay.Order();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 public ResponseResult Query([FromBody] QueryInfo query)
 {
     ColoPay.Model.Pay.Enterprise CurrEnterprise = bll.GetEnterpriseInfo(query.appid, query.secrit);
     if (CurrEnterprise == null)
     {
         return(FailResult(ResponseCode.ParamError, "appid or secrit is illegal"));
     }
     //判断订单是否存在
     ColoPay.Model.Pay.Order orderInfo = orderBll.GetModelEx(query.order_no, CurrEnterprise.EnterpriseID);
     if (orderInfo.PaymentStatus != 2)//订单状态未支付,则去支付平台查询一次
     {
         bool hasPaid = ColoPay.WebApi.PayApi.BZ_Pay.HasPaid(orderInfo.OrderCode);
         if (hasPaid)
         {
             bool isSuccess = orderBll.CompleteOrder(orderInfo);
             if (isSuccess)
             {
                 orderInfo.PaymentStatus = 2;
                 orderInfo.OrderStatus   = 1;
                 orderBll.HasNotify(orderInfo.OrderId);
             }
         }
     }
     YSWL.Json.JsonObject jsonObject = new JsonObject();
     jsonObject["appid"]      = query.appid;
     jsonObject["secrit"]     = query.secrit;
     jsonObject["order_no"]   = orderInfo.EnterOrder;
     jsonObject["amount"]     = orderInfo.Amount.ToString();
     jsonObject["sdorder_no"] = orderInfo.OrderCode;
     jsonObject["paytype"]    = orderInfo.PaymentGateway;
     jsonObject["status"]     = orderInfo.PaymentStatus.ToString();
     return(SuccessResult(jsonObject));
 }
Esempio n. 3
0
        protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Pay")
            {
                string orderCode = e.CommandArgument.ToString();
                ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(orderCode);
                bool isSuccess = true;
                if (orderInfo.PaymentStatus < 2)
                {
                    isSuccess = orderBll.CompleteOrder(orderInfo);
                }
                if (isSuccess)//成功之后需要回调商家回调地址
                {
                    try
                    {
                        ColoPay.BLL.Pay.Enterprise.Notify(orderInfo);
                    }
                    catch (Exception ex)
                    {
                        ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace);
                    }
                }
                MessageBox.ShowSuccessTip(this, "操作成功!");
            }

            if (e.CommandName == "Notify")
            {
                string orderCode = e.CommandArgument.ToString();
                ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(orderCode);
                bool   isSuccess   = true;
                string responseStr = "";
                if (orderInfo.PaymentStatus < 2)
                {
                    isSuccess = orderBll.CompleteOrder(orderInfo);
                }
                if (isSuccess)//成功之后需要回调商家回调地址
                {
                    try
                    {
                        responseStr = ColoPay.BLL.Pay.Enterprise.Notify(orderInfo);
                    }
                    catch (Exception ex)
                    {
                        responseStr = ex.Message;
                        ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace);
                    }
                }
                if (responseStr == "success")
                {
                    MessageBox.ShowSuccessTip(this, "操作成功!");
                }
                else
                {
                    responseStr = "回调通知失败," + responseStr;
                    MessageBox.ShowFailTip(this, responseStr);
                }
            }
            gridView.OnBind();
        }
Esempio n. 4
0
        public static bool VerifyNotify(FengHeNotify notifyinfo)
        {
            //-------记录请求参数
            YSWL.Log.LogHelper.AddInfoLog("FengHe-->VerifyNotify", String.Format("参数为:memberid-->{0}&returncode-->{1}&orderid-->{2}&amount-->{3}&datetime-->{4}&transaction_id-->{5}&attach-->{6}&sign--->{7}", notifyinfo.memberid, notifyinfo.returncode, notifyinfo.orderid, notifyinfo.amount, notifyinfo.datetime, notifyinfo.transaction_id, notifyinfo.attach, notifyinfo.sign));

            if (String.IsNullOrWhiteSpace(notifyinfo.memberid) || String.IsNullOrWhiteSpace(notifyinfo.orderid))
            {
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【FengHe支付回调通知失败"), "参数错误");
                return(false);
            }


            string signStr = StringHelper.GetMD5(String.Format("amount={0}&datetime={1}&memberid={2}&orderid={3}&returncode={4}&transaction_id={5}&key={6}", notifyinfo.amount, notifyinfo.datetime, notifyinfo.memberid, notifyinfo.orderid, notifyinfo.returncode, notifyinfo.transaction_id, apikey)).ToUpper();

            if (signStr == notifyinfo.sign)
            {
                if (notifyinfo.returncode == "00")
                {
                    ColoPay.BLL.Pay.Order   orderBll  = new BLL.Pay.Order();
                    ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.orderid);
                    if (orderInfo == null)
                    {
                        return(false);
                    }
                    if (orderInfo.PaymentStatus == 2)
                    {
                        return(true);
                    }
                    bool isSuccess = orderBll.CompleteOrder(orderInfo);
                    if (isSuccess)//成功之后需要回调商家回调地址
                    {
                        try
                        {
                            ColoPay.BLL.Pay.Enterprise.Notify(orderInfo);
                        }
                        catch (Exception ex)
                        {
                            ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】FengHe支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace);
                            return(isSuccess);
                        }
                    }

                    return(isSuccess);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                YSWL.Log.LogHelper.AddErrorLog(String.Format("订单【{0}】FengHe支付验证失败", notifyinfo.orderid), String.Format("参数为:memberid-->{0}&returncode-->{1}&orderid-->{2}&amount-->{3}&datetime-->{4}&transaction_id-->{5}&attach-->{6}&sign--->{7}", notifyinfo.memberid, notifyinfo.returncode, notifyinfo.orderid, notifyinfo.amount, notifyinfo.datetime, notifyinfo.transaction_id, notifyinfo.attach, notifyinfo.sign));
                //验证失败,记录日志
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】FengHe支付验证失败", notifyinfo.orderid), String.Format("参数为:memberid-->{0}&returncode-->{1}&orderid-->{2}&amount-->{3}&datetime-->{4}&transaction_id-->{5}&attach-->{6}&sign--->{7}", notifyinfo.memberid, notifyinfo.returncode, notifyinfo.orderid, notifyinfo.amount, notifyinfo.datetime, notifyinfo.transaction_id, notifyinfo.attach, notifyinfo.sign));
                return(false);
            }
        }
Esempio n. 5
0
        public static bool VerifyNotify(QrNotify notifyinfo)
        {
            //-------记录请求参数
            YSWL.Log.LogHelper.AddInfoLog("QR_Pay-->VerifyNotify", String.Format("参数为:customerid-->{0}&status-->{1}&sdpayno-->{2}&sdorderno-->{3}&total_fee-->{4}&paytype-->{5}&apikey-->{6}&sign--->{7}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey, notifyinfo.sign));

            if (notifyinfo.customerid == 0 || String.IsNullOrWhiteSpace(notifyinfo.sdpayno) || String.IsNullOrWhiteSpace(notifyinfo.sdorderno) || String.IsNullOrWhiteSpace(notifyinfo.paytype))
            {
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【QRPay支付回调通知失败"), "参数错误");
                return(false);
            }


            string signStr = StringHelper.GetMD5(String.Format("customerid={0}&status={1}&sdpayno={2}&sdorderno={3}&total_fee={4}&paytype={5}&{6}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey));

            if (signStr == notifyinfo.sign)
            {
                if (notifyinfo.status == 1)
                {
                    ColoPay.BLL.Pay.Order   orderBll  = new BLL.Pay.Order();
                    ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.sdorderno);
                    if (orderInfo == null)
                    {
                        return(false);
                    }
                    if (orderInfo.PaymentStatus == 2)
                    {
                        return(true);
                    }
                    bool isSuccess = orderBll.CompleteOrder(orderInfo);
                    if (isSuccess)//成功之后需要回调商家回调地址
                    {
                        try
                        {
                            ColoPay.BLL.Pay.Enterprise.Notify(orderInfo);
                        }
                        catch (Exception ex)
                        {
                            ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】QrPay支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace);
                            return(isSuccess);
                        }
                    }

                    return(isSuccess);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                YSWL.Log.LogHelper.AddInfoLog(String.Format("订单【{0}】QrPay支付验证失败", notifyinfo.sdorderno), String.Format("参数为:customerid-->{0}&status-->{1}&sdpayno-->{2}&sdorderno-->{3}&total_fee-->{4}&paytype-->{5}&apikey-->{6}&sign--->{7}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey, notifyinfo.sign));
                //验证失败,记录日志
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】QrPay支付验证失败", notifyinfo.sdorderno), String.Format("参数为:customerid-->{0}&status-->{1}&sdpayno-->{2}&sdorderno-->{3}&total_fee-->{4}&paytype-->{5}&apikey-->{6}&sign--->{7}", notifyinfo.customerid, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.sdorderno, notifyinfo.total_fee, notifyinfo.paytype, apikey, notifyinfo.sign));
                return(false);
            }
        }
Esempio n. 6
0
        public static bool VerifyNotify(DaNotify notifyinfo)
        {
            //-------记录请求参数
            YSWL.Log.LogHelper.AddInfoLog("DaDaBank-->VerifyNotify", String.Format("参数为:order-->{0}&code-->{1}&mount-->{2}&msg-->{3}&time-->{4}&sign-->{5}", notifyinfo.order, notifyinfo.code, notifyinfo.mount, notifyinfo.msg, notifyinfo.time, notifyinfo.sign));

            if (String.IsNullOrWhiteSpace(notifyinfo.order) || String.IsNullOrWhiteSpace(notifyinfo.code))
            {
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【DaPay支付回调通知失败"), "参数错误");
                return(false);
            }
            string signStr = GetNotifySignStr(notifyinfo.order, notifyinfo.mount, notifyinfo.code, notifyinfo.msg, notifyinfo.time); //StringHelper.GetMD5(String.Format("mch_id={0}&status={1}&sdpayno={2}&order_no={3}&money={4}&paytype={5}&{6}", notifyinfo.mch_id, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.order_no, notifyinfo.money, notifyinfo.paytype, apikey));

            if (signStr == notifyinfo.sign)
            {
                if (notifyinfo.code == "200")
                {
                    ColoPay.BLL.Pay.Order   orderBll  = new BLL.Pay.Order();
                    ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.order);
                    if (orderInfo == null)
                    {
                        return(false);
                    }
                    if (orderInfo.PaymentStatus == 2)
                    {
                        return(true);
                    }
                    bool isSuccess = orderBll.CompleteOrder(orderInfo);
                    if (isSuccess)//成功之后需要回调商家回调地址
                    {
                        try
                        {
                            ColoPay.BLL.Pay.Enterprise.Notify(orderInfo);
                        }
                        catch (Exception ex)
                        {
                            ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】DaPay支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace);
                            return(isSuccess);
                        }
                    }

                    return(isSuccess);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单DaPay支付回调通知失败"), String.Format("加密签名错误:接口签名字段为【{0}】---生成的签名为【{1}】", notifyinfo.sign, signStr));
                //验证失败,记录日志
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】DaPay支付验证失败", notifyinfo.order), String.Format("参数为:order-->{0}&code-->{1}&mount-->{2}&msg-->{3}&time-->{4}", notifyinfo.order, notifyinfo.code, notifyinfo.mount, notifyinfo.msg, notifyinfo.time));
                return(false);
            }
        }
Esempio n. 7
0
        public static bool VerifyNotify(BZNotify notifyinfo)
        {
            if (String.IsNullOrWhiteSpace(notifyinfo.mch_id) || String.IsNullOrWhiteSpace(notifyinfo.sdpayno) || String.IsNullOrWhiteSpace(notifyinfo.order_no) || String.IsNullOrWhiteSpace(notifyinfo.paytype))
            {
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【BZPay支付回调通知失败"), "参数错误");
                return(false);
            }
            string signStr = StringHelper.GetMD5(String.Format("mch_id={0}&status={1}&sdpayno={2}&order_no={3}&money={4}&paytype={5}&{6}", notifyinfo.mch_id, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.order_no, notifyinfo.money, notifyinfo.paytype, apikey));

            if (signStr == notifyinfo.sign)
            {
                if (notifyinfo.status == 1)
                {
                    ColoPay.BLL.Pay.Order   orderBll  = new BLL.Pay.Order();
                    ColoPay.Model.Pay.Order orderInfo = orderBll.GetModel(notifyinfo.order_no);
                    if (orderInfo == null)
                    {
                        return(false);
                    }
                    if (orderInfo.PaymentStatus == 2)
                    {
                        return(true);
                    }
                    bool isSuccess = orderBll.CompleteOrder(orderInfo);
                    if (isSuccess)//成功之后需要回调商家回调地址
                    {
                        try
                        {
                            ColoPay.BLL.Pay.Enterprise.Notify(orderInfo);
                        }
                        catch (Exception ex)
                        {
                            ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】BZPay支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace);
                            return(isSuccess);
                        }
                    }

                    return(isSuccess);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                //验证失败,记录日志
                ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】BZPay支付验证失败", notifyinfo.order_no), String.Format("参数为:mch_id-->{0}&status-->{1}&sdpayno-->{2}&order_no-->{3}&money-->{4}&paytype-->{5}&apikey-->{6}", notifyinfo.mch_id, notifyinfo.status, notifyinfo.sdpayno, notifyinfo.order_no, notifyinfo.money, notifyinfo.paytype, apikey));
                return(false);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ColoPay.Model.Pay.Order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Pay_Order(");
            strSql.Append("OrderCode,EnterOrder,EnterpriseID,Agentd,Amount,PaymentFee,FeeRate,OrderAmount,PayModeId,PaymentTypeName,PaymentGateway,PaymentStatus,OrderStatus,OrderInfo,AppId,AppSecrit,AppUrl,AppReturnUrl,AppNotifyUrl,CreatedTime,Remark)");
            strSql.Append(" values (");
            strSql.Append("@OrderCode,@EnterOrder,@EnterpriseID,@Agentd,@Amount,@PaymentFee,@FeeRate,@OrderAmount,@PayModeId,@PaymentTypeName,@PaymentGateway,@PaymentStatus,@OrderStatus,@OrderInfo,@AppId,@AppSecrit,@AppUrl,@AppReturnUrl,@AppNotifyUrl,@CreatedTime,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderCode",       SqlDbType.NVarChar,  300),
                new SqlParameter("@EnterOrder",      SqlDbType.NVarChar,  300),
                new SqlParameter("@EnterpriseID",    SqlDbType.Int,         4),
                new SqlParameter("@Agentd",          SqlDbType.Int,         4),
                new SqlParameter("@Amount",          SqlDbType.Money,       8),
                new SqlParameter("@PaymentFee",      SqlDbType.Money,       8),
                new SqlParameter("@FeeRate",         SqlDbType.Decimal,     9),
                new SqlParameter("@OrderAmount",     SqlDbType.Money,       8),
                new SqlParameter("@PayModeId",       SqlDbType.Int,         4),
                new SqlParameter("@PaymentTypeName", SqlDbType.NVarChar,   50),
                new SqlParameter("@PaymentGateway",  SqlDbType.NVarChar,   50),
                new SqlParameter("@PaymentStatus",   SqlDbType.Int,         4),
                new SqlParameter("@OrderStatus",     SqlDbType.Int,         4),
                new SqlParameter("@OrderInfo",       SqlDbType.NVarChar,  300),
                new SqlParameter("@AppId",           SqlDbType.NVarChar,  200),
                new SqlParameter("@AppSecrit",       SqlDbType.NVarChar,  200),
                new SqlParameter("@AppUrl",          SqlDbType.NVarChar,  200),
                new SqlParameter("@AppReturnUrl",    SqlDbType.NVarChar,  200),
                new SqlParameter("@AppNotifyUrl",    SqlDbType.NVarChar,  200),
                new SqlParameter("@CreatedTime",     SqlDbType.DateTime),
                new SqlParameter("@Remark",          SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value  = model.OrderCode;
            parameters[1].Value  = model.EnterOrder;
            parameters[2].Value  = model.EnterpriseID;
            parameters[3].Value  = model.Agentd;
            parameters[4].Value  = model.Amount;
            parameters[5].Value  = model.PaymentFee;
            parameters[6].Value  = model.FeeRate;
            parameters[7].Value  = model.OrderAmount;
            parameters[8].Value  = model.PayModeId;
            parameters[9].Value  = model.PaymentTypeName;
            parameters[10].Value = model.PaymentGateway;
            parameters[11].Value = model.PaymentStatus;
            parameters[12].Value = model.OrderStatus;
            parameters[13].Value = model.OrderInfo;
            parameters[14].Value = model.AppId;
            parameters[15].Value = model.AppSecrit;
            parameters[16].Value = model.AppUrl;
            parameters[17].Value = model.AppReturnUrl;
            parameters[18].Value = model.AppNotifyUrl;
            parameters[19].Value = model.CreatedTime;
            parameters[20].Value = model.Remark;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 9
0
        public bool CompleteOrder(ColoPay.Model.Pay.Order orderInfo)
        {
            //事务处理
            List <CommandInfo> sqllist = new List <CommandInfo>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Pay_Order set ");
            strSql.Append(" PaymentStatus=2,OrderStatus=1 where OrderCode=@OrderCode");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderCode", SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = orderInfo.OrderCode;

            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);
            //更新商家余额
            StringBuilder strSql1 = new StringBuilder();

            strSql1.Append("update Pay_Enterprise set  Balance=Balance+@OrderAmount ");
            strSql1.Append(" where EnterpriseID=@EnterpriseID  ");
            SqlParameter[] parameters1 =
            {
                new SqlParameter("@EnterpriseID", SqlDbType.Int, 4),
                new SqlParameter("@OrderAmount",  SqlDbType.Decimal)
            };
            parameters1[0].Value = orderInfo.EnterpriseID;
            parameters1[1].Value = orderInfo.OrderAmount;
            cmd = new CommandInfo(strSql1.ToString(), parameters1);
            sqllist.Add(cmd);
            //增加商家资金明细

            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("insert into Pay_BalanceDetail(");
            strSql2.Append("EnterpriseID,PayType,OriginalId,OriginalCode,PaymentFee,OrderAmount,Amount,CreatedTime)");
            strSql2.Append(" values (");
            strSql2.Append("@EnterpriseID,@PayType,@OriginalId,@OriginalCode,@PaymentFee,@OrderAmount,@Amount,@CreatedTime)");
            SqlParameter[] parameters2 =
            {
                new SqlParameter("@EnterpriseID", SqlDbType.Int,        4),
                new SqlParameter("@PayType",      SqlDbType.Int,        4),
                new SqlParameter("@OriginalId",   SqlDbType.Int,        4),
                new SqlParameter("@OriginalCode", SqlDbType.NVarChar, 100),
                new SqlParameter("@PaymentFee",   SqlDbType.Money,      8),
                new SqlParameter("@OrderAmount",  SqlDbType.Money,      8),
                new SqlParameter("@Amount",       SqlDbType.Money,      8),
                new SqlParameter("@CreatedTime",  SqlDbType.DateTime)
            };
            parameters2[0].Value = orderInfo.EnterpriseID;
            parameters2[1].Value = 0;
            parameters2[2].Value = orderInfo.OrderId;
            parameters2[3].Value = orderInfo.OrderCode;
            parameters2[4].Value = orderInfo.PaymentFee;
            parameters2[5].Value = orderInfo.OrderAmount;
            parameters2[6].Value = orderInfo.Amount;
            parameters2[7].Value = DateTime.Now;

            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);


            return(DBHelper.DefaultDBHelper.ExecuteSqlTran(sqllist) > 0 ? true : false);
        }
Esempio n. 10
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ColoPay.Model.Pay.Order DataRowToModel(DataRow row)
 {
     ColoPay.Model.Pay.Order model = new ColoPay.Model.Pay.Order();
     if (row != null)
     {
         if (row["OrderId"] != null && row["OrderId"].ToString() != "")
         {
             model.OrderId = int.Parse(row["OrderId"].ToString());
         }
         if (row["OrderCode"] != null)
         {
             model.OrderCode = row["OrderCode"].ToString();
         }
         if (row["EnterOrder"] != null)
         {
             model.EnterOrder = row["EnterOrder"].ToString();
         }
         if (row["EnterpriseID"] != null && row["EnterpriseID"].ToString() != "")
         {
             model.EnterpriseID = int.Parse(row["EnterpriseID"].ToString());
         }
         if (row["Agentd"] != null && row["Agentd"].ToString() != "")
         {
             model.Agentd = int.Parse(row["Agentd"].ToString());
         }
         if (row["Amount"] != null && row["Amount"].ToString() != "")
         {
             model.Amount = decimal.Parse(row["Amount"].ToString());
         }
         if (row["PaymentFee"] != null && row["PaymentFee"].ToString() != "")
         {
             model.PaymentFee = decimal.Parse(row["PaymentFee"].ToString());
         }
         if (row["FeeRate"] != null && row["FeeRate"].ToString() != "")
         {
             model.FeeRate = decimal.Parse(row["FeeRate"].ToString());
         }
         if (row["OrderAmount"] != null && row["OrderAmount"].ToString() != "")
         {
             model.OrderAmount = decimal.Parse(row["OrderAmount"].ToString());
         }
         if (row["PayModeId"] != null && row["PayModeId"].ToString() != "")
         {
             model.PayModeId = int.Parse(row["PayModeId"].ToString());
         }
         if (row["PaymentTypeName"] != null)
         {
             model.PaymentTypeName = row["PaymentTypeName"].ToString();
         }
         if (row["PaymentGateway"] != null)
         {
             model.PaymentGateway = row["PaymentGateway"].ToString();
         }
         if (row["PaymentStatus"] != null && row["PaymentStatus"].ToString() != "")
         {
             model.PaymentStatus = int.Parse(row["PaymentStatus"].ToString());
         }
         if (row["OrderStatus"] != null && row["OrderStatus"].ToString() != "")
         {
             model.OrderStatus = int.Parse(row["OrderStatus"].ToString());
         }
         if (row["OrderInfo"] != null)
         {
             model.OrderInfo = row["OrderInfo"].ToString();
         }
         if (row["AppId"] != null)
         {
             model.AppId = row["AppId"].ToString();
         }
         if (row["AppSecrit"] != null)
         {
             model.AppSecrit = row["AppSecrit"].ToString();
         }
         if (row["AppUrl"] != null)
         {
             model.AppUrl = row["AppUrl"].ToString();
         }
         if (row["AppReturnUrl"] != null)
         {
             model.AppReturnUrl = row["AppReturnUrl"].ToString();
         }
         if (row["AppNotifyUrl"] != null)
         {
             model.AppNotifyUrl = row["AppNotifyUrl"].ToString();
         }
         if (row["CreatedTime"] != null && row["CreatedTime"].ToString() != "")
         {
             model.CreatedTime = DateTime.Parse(row["CreatedTime"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }
Esempio n. 11
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ColoPay.Model.Pay.Order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Pay_Order set ");
            strSql.Append("OrderCode=@OrderCode,");
            strSql.Append("EnterOrder=@EnterOrder,");
            strSql.Append("EnterpriseID=@EnterpriseID,");
            strSql.Append("Agentd=@Agentd,");
            strSql.Append("Amount=@Amount,");
            strSql.Append("PaymentFee=@PaymentFee,");
            strSql.Append("FeeRate=@FeeRate,");
            strSql.Append("OrderAmount=@OrderAmount,");
            strSql.Append("PayModeId=@PayModeId,");
            strSql.Append("PaymentTypeName=@PaymentTypeName,");
            strSql.Append("PaymentGateway=@PaymentGateway,");
            strSql.Append("PaymentStatus=@PaymentStatus,");
            strSql.Append("OrderStatus=@OrderStatus,");
            strSql.Append("OrderInfo=@OrderInfo,");
            strSql.Append("AppId=@AppId,");
            strSql.Append("AppSecrit=@AppSecrit,");
            strSql.Append("AppUrl=@AppUrl,");
            strSql.Append("AppReturnUrl=@AppReturnUrl,");
            strSql.Append("AppNotifyUrl=@AppNotifyUrl,");
            strSql.Append("CreatedTime=@CreatedTime,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where OrderId=@OrderId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderCode",       SqlDbType.NVarChar,   300),
                new SqlParameter("@EnterOrder",      SqlDbType.NVarChar,   300),
                new SqlParameter("@EnterpriseID",    SqlDbType.Int,          4),
                new SqlParameter("@Agentd",          SqlDbType.Int,          4),
                new SqlParameter("@Amount",          SqlDbType.Money,        8),
                new SqlParameter("@PaymentFee",      SqlDbType.Money,        8),
                new SqlParameter("@FeeRate",         SqlDbType.Decimal,      9),
                new SqlParameter("@OrderAmount",     SqlDbType.Money,        8),
                new SqlParameter("@PayModeId",       SqlDbType.Int,          4),
                new SqlParameter("@PaymentTypeName", SqlDbType.NVarChar,    50),
                new SqlParameter("@PaymentGateway",  SqlDbType.NVarChar,    50),
                new SqlParameter("@PaymentStatus",   SqlDbType.Int,          4),
                new SqlParameter("@OrderStatus",     SqlDbType.Int,          4),
                new SqlParameter("@OrderInfo",       SqlDbType.NVarChar,   300),
                new SqlParameter("@AppId",           SqlDbType.NVarChar,   200),
                new SqlParameter("@AppSecrit",       SqlDbType.NVarChar,   200),
                new SqlParameter("@AppUrl",          SqlDbType.NVarChar,   200),
                new SqlParameter("@AppReturnUrl",    SqlDbType.NVarChar,   200),
                new SqlParameter("@AppNotifyUrl",    SqlDbType.NVarChar,   200),
                new SqlParameter("@CreatedTime",     SqlDbType.DateTime),
                new SqlParameter("@Remark",          SqlDbType.NVarChar,  1000),
                new SqlParameter("@OrderId",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.OrderCode;
            parameters[1].Value  = model.EnterOrder;
            parameters[2].Value  = model.EnterpriseID;
            parameters[3].Value  = model.Agentd;
            parameters[4].Value  = model.Amount;
            parameters[5].Value  = model.PaymentFee;
            parameters[6].Value  = model.FeeRate;
            parameters[7].Value  = model.OrderAmount;
            parameters[8].Value  = model.PayModeId;
            parameters[9].Value  = model.PaymentTypeName;
            parameters[10].Value = model.PaymentGateway;
            parameters[11].Value = model.PaymentStatus;
            parameters[12].Value = model.OrderStatus;
            parameters[13].Value = model.OrderInfo;
            parameters[14].Value = model.AppId;
            parameters[15].Value = model.AppSecrit;
            parameters[16].Value = model.AppUrl;
            parameters[17].Value = model.AppReturnUrl;
            parameters[18].Value = model.AppNotifyUrl;
            parameters[19].Value = model.CreatedTime;
            parameters[20].Value = model.Remark;
            parameters[21].Value = model.OrderId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
        public ResponseResult SubmitOrder([FromBody] PayInfo payinfo)
        {
            //YSWL.Common.DEncrypt.DEncrypt.GetMD5FromStr
            //验证是否数据安全性
            if (payinfo.amount < 0)
            {
                return(FailResult(ResponseCode.ParamError, "amount is illegal"));
            }
            if (String.IsNullOrWhiteSpace(payinfo.order_no))
            {
                return(FailResult(ResponseCode.ParamError, "ordercode is illegal"));
            }


            ColoPay.Model.Pay.Enterprise CurrEnterprise = bll.GetEnterpriseInfo(payinfo.appid, payinfo.secrit);
            if (CurrEnterprise == null)
            {
                return(FailResult(ResponseCode.ParamError, "appid or secrit is illegal"));
            }
            //判断订单是否存在
            ColoPay.Model.Pay.Order orderInfo = orderBll.GetModelEx(payinfo.order_no, CurrEnterprise.EnterpriseID);

            if (orderInfo == null)
            {
                //创建订单
                orderInfo              = new Model.Pay.Order();
                orderInfo.Agentd       = CurrEnterprise.AgentId;
                orderInfo.Amount       = payinfo.amount;
                orderInfo.AppId        = CurrEnterprise.AppId;
                orderInfo.AppReturnUrl = String.IsNullOrWhiteSpace(payinfo.return_url) ? CurrEnterprise.AppReturnUrl : payinfo.return_url;
                orderInfo.AppSecrit    = CurrEnterprise.AppSecrit;
                orderInfo.AppUrl       = HttpContext.Current.Request.Url.ToString();
                orderInfo.CreatedTime  = DateTime.Now;
                orderInfo.EnterOrder   = payinfo.order_no;
                orderInfo.EnterpriseID = CurrEnterprise.EnterpriseID;
                orderInfo.OrderCode    = DateTime.Now.ToString("yyyyMMddHHmmssfff") + CurrEnterprise.EnterpriseID;
                //获取支付方式
                ColoPay.Model.Pay.PaymentTypes typeInfo = typeBll.GetPaymentInfo(payinfo.paytype);
                if (typeInfo == null)
                {
                    return(FailResult(ResponseCode.ParamError, "paytype is illegal"));
                }
                //获取支付费率

                ColoPay.Model.Pay.EnterprisePayFee feeInfo = feeBll.GetModel(CurrEnterprise.EnterpriseID, typeInfo.ModeId);
                if (feeInfo == null)
                {
                    return(FailResult(ResponseCode.ParamError, "paytype is illegal"));
                }
                orderInfo.FeeRate         = feeInfo.FeeRate;
                orderInfo.PaymentFee      = payinfo.amount * (feeInfo.FeeRate / 100);
                orderInfo.OrderAmount     = payinfo.amount - orderInfo.PaymentFee;
                orderInfo.PaymentGateway  = typeInfo.Gateway;
                orderInfo.PaymentStatus   = 0;
                orderInfo.AppNotifyUrl    = CurrEnterprise.AppReturnUrl;
                orderInfo.PaymentTypeName = typeInfo.Name;
                orderInfo.PayModeId       = typeInfo.ModeId;
                orderInfo.OrderInfo       = String.IsNullOrWhiteSpace(payinfo.remark) ? "" : payinfo.remark;
                orderInfo.OrderId         = orderBll.Add(orderInfo);
                if (orderInfo.OrderId == 0)//创建订单失败
                {
                    return(FailResult(ResponseCode.ServiceUnavailable, "payorder is error"));
                }
            }
            else //订单已经存在了
            {
                if (orderInfo.Amount != payinfo.amount)//金额不一样,说明订单不一样
                {
                    return(FailResult(ResponseCode.OrderExists, "order_no has exist"));
                }
                if (orderInfo.PaymentStatus == 2)
                {
                    return(FailResult(ResponseCode.HasPaid, "order has paid"));
                }
            }
            string resullt = "";

            //BZ 支付金额必须要为整数,有点扯淡
            //开始支付

            if (!payinfo.istest)
            {
                //tuzh BZ_Pay 支付接口已失效
                // resullt = ColoPay.WebApi.PayApi.BZ_Pay.PayRequest(orderInfo.OrderCode, payinfo.amount, orderInfo.PaymentGateway, payinfo.get_code, orderInfo.OrderInfo);
                // 如果是网银或者快捷支付,走丰核支付
                YSWL.Log.LogHelper.AddInfoLog("支付网关", "PaymentGateway--->" + orderInfo.PaymentGateway);
                switch (orderInfo.PaymentGateway)
                {
                case "wangyin":
                case "kuaijie":
                    resullt = ColoPay.WebApi.PayApi.FengHe.PayRequest(orderInfo.OrderCode, payinfo.amount, orderInfo.PaymentGateway, orderInfo.OrderInfo);
                    break;

                case "onlinekj":
                    resullt = ColoPay.WebApi.PayApi.YiYuan.PayRequest(orderInfo.OrderCode, payinfo.amount, payinfo.bankcard, payinfo.moblie, payinfo.idcard, payinfo.realname, payinfo.remark);
                    break;

                case "wx":
                case "ali":
                case "aliwap":
                    resullt = ColoPay.WebApi.PayApi.MidoPay.PayRequest(orderInfo.OrderCode, payinfo.amount, orderInfo.PaymentGateway, payinfo.bankcard, payinfo.title, payinfo.product, orderInfo.Remark);
                    break;

                default:
                    resullt = ColoPay.WebApi.PayApi.MidoPay.PayRequest(orderInfo.OrderCode, payinfo.amount, orderInfo.PaymentGateway, payinfo.bankcard, payinfo.title, payinfo.product, orderInfo.Remark);
                    break;
                }
            }
            else //测试支付
            {
                bool isSuccess = orderBll.CompleteOrder(orderInfo);
                if (isSuccess)//成功之后需要回调商家回调地址
                {
                    try
                    {
                        orderInfo.PaymentStatus = 2;
                        ColoPay.BLL.Pay.Enterprise.Notify(orderInfo);
                    }
                    catch (Exception ex)
                    {
                        ColoPay.BLL.SysManage.LogHelp.AddErrorLog(String.Format("订单【{0}】BZPay支付回调通知失败:{1}", orderInfo.OrderCode, ex.Message), ex.StackTrace);
                    }
                }
            }

            return(SuccessResult(resullt));
        }
Esempio n. 13
0
        public HttpResponseMessage PayBankOrder([FromBody] PayInfo payinfo)
        {
            //YSWL.Common.DEncrypt.DEncrypt.GetMD5FromStr
            //验证是否数据安全性
            if (payinfo.amount < 0)
            {
                return(new HttpResponseMessage {
                    Content = new StringContent("amount is illegal", Encoding.GetEncoding("UTF-8"), "text/plain")
                });
            }
            if (String.IsNullOrWhiteSpace(payinfo.order_no))
            {
                return(new HttpResponseMessage {
                    Content = new StringContent("ordercode is illegal", Encoding.GetEncoding("UTF-8"), "text/plain")
                });
            }


            ColoPay.Model.Pay.Enterprise CurrEnterprise = bll.GetEnterpriseInfo(payinfo.appid, payinfo.secrit);
            if (CurrEnterprise == null)
            {
                return(new HttpResponseMessage {
                    Content = new StringContent("appid or secrit is illegal", Encoding.GetEncoding("UTF-8"), "text/plain")
                });
            }
            //判断订单是否存在
            ColoPay.Model.Pay.Order orderInfo = orderBll.GetModelEx(payinfo.order_no, CurrEnterprise.EnterpriseID);

            if (orderInfo == null)
            {
                //创建订单
                orderInfo              = new Model.Pay.Order();
                orderInfo.Agentd       = CurrEnterprise.AgentId;
                orderInfo.Amount       = payinfo.amount;
                orderInfo.AppId        = CurrEnterprise.AppId;
                orderInfo.AppReturnUrl = String.IsNullOrWhiteSpace(payinfo.return_url) ? CurrEnterprise.AppReturnUrl : payinfo.return_url;
                orderInfo.AppSecrit    = CurrEnterprise.AppSecrit;
                orderInfo.AppUrl       = HttpContext.Current.Request.Url.ToString();
                orderInfo.CreatedTime  = DateTime.Now;
                orderInfo.EnterOrder   = payinfo.order_no;
                orderInfo.EnterpriseID = CurrEnterprise.EnterpriseID;
                orderInfo.OrderCode    = "P" + CurrEnterprise.EnterpriseID + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                //获取支付方式
                ColoPay.Model.Pay.PaymentTypes typeInfo = typeBll.GetPaymentInfo(payinfo.paytype);
                if (typeInfo == null)
                {
                    return(new HttpResponseMessage {
                        Content = new StringContent("paytype is illegal", Encoding.GetEncoding("UTF-8"), "text/plain")
                    });
                }
                //获取支付费率

                ColoPay.Model.Pay.EnterprisePayFee feeInfo = feeBll.GetModel(CurrEnterprise.EnterpriseID, typeInfo.ModeId);
                if (feeInfo == null)
                {
                    return(new HttpResponseMessage {
                        Content = new StringContent("paytype is illegal", Encoding.GetEncoding("UTF-8"), "text/plain")
                    });
                }
                orderInfo.FeeRate         = feeInfo.FeeRate;
                orderInfo.PaymentFee      = payinfo.amount * (feeInfo.FeeRate / 100);
                orderInfo.OrderAmount     = payinfo.amount - orderInfo.PaymentFee;
                orderInfo.PaymentGateway  = typeInfo.Gateway;
                orderInfo.PaymentStatus   = 0;
                orderInfo.AppNotifyUrl    = CurrEnterprise.AppReturnUrl;
                orderInfo.PaymentTypeName = typeInfo.Name;
                orderInfo.PayModeId       = typeInfo.ModeId;
                orderInfo.OrderInfo       = String.IsNullOrWhiteSpace(payinfo.remark) ? "" : payinfo.remark;
                orderInfo.OrderId         = orderBll.Add(orderInfo);
                if (orderInfo.OrderId == 0)//创建订单失败
                {
                    return(new HttpResponseMessage {
                        Content = new StringContent("payorder is error", Encoding.GetEncoding("UTF-8"), "text/plain")
                    });
                }
            }
            else //订单已经存在了
            {
                if (orderInfo.Amount != payinfo.amount)//金额不一样,说明订单不一样
                {
                    return(new HttpResponseMessage {
                        Content = new StringContent("order_no has exist", Encoding.GetEncoding("UTF-8"), "text/plain")
                    });
                }
                if (orderInfo.PaymentStatus == 2)
                {
                    return(new HttpResponseMessage {
                        Content = new StringContent("order has paid", Encoding.GetEncoding("UTF-8"), "text/plain")
                    });
                }
            }

            string resullt = ColoPay.WebApi.PayApi.DaDaBank.PayRequest(orderInfo.OrderCode, payinfo.amount, payinfo.bankcode, orderInfo.OrderInfo);

            YSWL.Json.JsonObject jsonObject = JsonConvert.Import <JsonObject>(resullt);
            if (jsonObject["bxstatus"].ToString() == "SUCCESS")
            {
                string pay_url           = jsonObject["pay_url"].ToString();
                HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.Moved);
                resp.Headers.Location = new Uri(pay_url);
                return(resp);
            }
            else
            {
                return(new HttpResponseMessage {
                    Content = new StringContent(jsonObject["bxmsg"].ToString(), Encoding.GetEncoding("UTF-8"), "text/plain")
                });
            }
        }