コード例 #1
0
ファイル: PayController.cs プロジェクト: dmhai/ColoPay
 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));
 }
コード例 #2
0
        public void ShowInfo(string strEnerpid)
        {
            EnterPriseModel = EnterpriseBll.GetModel(int.Parse(strEnerpid));

            txtName.Text            = EnterPriseModel.Name;
            txtSimpleName.Text      = EnterPriseModel.SimpleName;
            txtEnterpriseNum.Text   = EnterPriseModel.EnterpriseNum;
            txtBusinessLicense.Text = EnterPriseModel.BusinessLicense;
            txtCellPhone.Text       = EnterPriseModel.CellPhone;
            //txtAccountBank.Text = EnterPriseModel.AccountBank;
            txtAccountInfo.Text = EnterPriseModel.AccountInfo;
            txtAccountNum.Text  = EnterPriseModel.AccountNum;
            //txtWithdrawBank.Text = EnterPriseModel.WithdrawBank;
            txtWithdrawInfo.Text = EnterPriseModel.WithdrawInfo;
            txtWithdrawNum.Text  = EnterPriseModel.WithdrawNum;
            txtBalance.Text      = EnterPriseModel.Balance.ToString();
            txtAppId.Text        = EnterPriseModel.AppId;
            txtAppSecrit.Text    = EnterPriseModel.AppSecrit;
            txtAppUrl.Text       = EnterPriseModel.AppUrl;
            txtAppReturnUrl.Text = EnterPriseModel.AppReturnUrl;
            // txtContactMail.Text = EnterPriseModel.ContactMail;
            //  txtAddress.Text = EnterPriseModel.Address;
            ddlEnteRank.SelectedValue = EnterPriseModel.EnteRank.ToString();

            //txtRemark.Text = EnterPriseModel.Remark;
        }
コード例 #3
0
        public ColoPay.Model.Pay.Enterprise GetEnterpriseInfo(string appid, string secrit)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 EnterpriseID,AgentId,UserName,Name,SimpleName,Status,EnterpriseNum,BusinessLicense,TelPhone,CellPhone,AccountBank,AccountInfo,AccountNum,WithdrawBank,WithdrawInfo,WithdrawNum,Balance,AppId,AppSecrit,AppUrl,AppReturnUrl,ContactMail,Address,EnteRank,CreatedDate,CreatedUserID,RegisterIp,Remark from Pay_Enterprise ");
            strSql.Append(" where AppId=@AppId and AppSecrit=@AppSecrit and Status=1");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AppId",     SqlDbType.NVarChar, 200),
                new SqlParameter("@AppSecrit", SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = appid;
            parameters[1].Value = secrit;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: OrderList.aspx.cs プロジェクト: dmhai/ColoPay
        /// <summary>
        /// 获取商家名称
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        protected string GetEnterpriseName(object target)
        {
            int enterpriseId = YSWL.Common.Globals.SafeInt(target, 0);

            ColoPay.Model.Pay.Enterprise enterpriseModel = enterpriseBll.GetModelByCache(enterpriseId);

            return(enterpriseModel == null ? "未知" : enterpriseModel.Name);
        }
コード例 #5
0
ファイル: PayInfo.aspx.cs プロジェクト: dmhai/ColoPay
        public void ShowInfo(string strEnerpid)
        {
            EnterPriseModel = EnterpriseBll.GetModel(int.Parse(strEnerpid));

            txtAppId.Text        = EnterPriseModel.AppId;
            txtAppSecrit.Text    = EnterPriseModel.AppSecrit;
            txtAppUrl.Text       = EnterPriseModel.AppUrl;
            txtAppReturnUrl.Text = EnterPriseModel.AppReturnUrl;
        }
コード例 #6
0
ファイル: WithdrawAdd.aspx.cs プロジェクト: dmhai/ColoPay
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ColoPay.Model.Pay.Enterprise enterpriseModel = enterpriseBll.GetModel(CurrEnterpriseID);
         this.txtAmount.Text       = enterpriseModel.Balance.ToString("F");
         this.txtWithdrawBank.Text = enterpriseModel.WithdrawBank;
         this.txtWithdrawInfo.Text = enterpriseModel.WithdrawInfo;
         this.txtWithdrawNum.Text  = enterpriseModel.WithdrawNum;
     }
 }
コード例 #7
0
ファイル: WithdrawAdd.aspx.cs プロジェクト: dmhai/ColoPay
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            ColoPay.Model.Pay.Enterprise enterpriseModel = enterpriseBll.GetModel(CurrEnterpriseID);
            decimal amount = YSWL.Common.Globals.SafeDecimal(this.txtAmount.Text, 0);

            string withdrawBank = this.txtWithdrawBank.Text;
            string withdrawInfo = this.txtWithdrawInfo.Text;
            string withdrawNum  = this.txtWithdrawNum.Text;
            string userName     = this.txtUserName.Text;

            if (amount > enterpriseModel.Balance)
            {
                lblMsg.Text = "提现金额不能超过余额,请重新输入!";
                return;
            }
            if (String.IsNullOrWhiteSpace(withdrawBank) || String.IsNullOrWhiteSpace(withdrawInfo) || String.IsNullOrWhiteSpace(withdrawNum))
            {
                lblMsg.Text = "提现银行不完善,请检查!";
                return;
            }
            ColoPay.Model.Pay.Withdraw model = new Model.Pay.Withdraw();
            model.AgentId       = 0;
            model.WithdrawCode  = "TX" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
            model.Amount        = amount;
            model.CreatedDate   = DateTime.Now;
            model.CreatedUserId = currentUser.UserID;
            model.UserName      = userName;
            model.EnterpriseID  = CurrEnterpriseID;
            model.Type          = 0;
            model.WithdrawBank  = withdrawBank;
            model.WithdrawInfo  = withdrawInfo;
            model.WithdrawNum   = withdrawNum;
            model.Remark        = txtRemark.Text;
            model.Status        = 0;
            bool isSuccess = withdrawBll.AddWithdraw(model);

            //申请成功
            if (isSuccess)
            {
                YSWL.Common.MessageBox.ShowSuccessTip(this, "申请提现成功!");
                Response.Redirect("WithdrawList.aspx");
            }
            else
            {
                YSWL.Common.MessageBox.ShowFailTip(this, "申请提现失败,请稍后再试!");
                return;
            }
        }
コード例 #8
0
        /// <summary>
        /// 更新回调应用地址
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnAppReturnUrl_Click(object sender, EventArgs e)
        {
            string strAppReturnUrl = YSWL.Common.InjectionFilter.SqlFilter(txtAppReturnUrl.Text);

            if (strAppReturnUrl.Length > 0)
            {
                EnterPriseModel = EnterpriseBll.GetModel(int.Parse(lbEnterPid.Text));
                EnterPriseModel.AppReturnUrl = strAppReturnUrl;
                EnterpriseBll.Update(EnterPriseModel);
                YSWL.Common.MessageBox.ShowSuccessTip(this, "回调地址设置成功!");
            }
            else
            {
                YSWL.Common.MessageBox.ShowFailTip(this, "请填写回调地址!");
            }
        }
コード例 #9
0
ファイル: WithdrawList.aspx.cs プロジェクト: dmhai/ColoPay
        /// <summary>
        /// 获取企业名称
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        protected string GetEnterpriseName(object objEnterprise, object objAgent, object objType)
        {
            int enterpriseId = YSWL.Common.Globals.SafeInt(objEnterprise, 0);
            int agentId      = YSWL.Common.Globals.SafeInt(objAgent, 0);
            int type         = YSWL.Common.Globals.SafeInt(objType, 0);

            if (type == 0)
            {
                ColoPay.Model.Pay.Enterprise enterpriseModel = enterpriseBll.GetModelByCache(enterpriseId);
                return(enterpriseModel == null ? "未知" : enterpriseModel.Name);
            }
            else
            {
                ColoPay.Model.Pay.Agent agentModel = agentBll.GetModelByCache(agentId);
                return(agentModel == null ? "未知" : agentModel.Name);
            }
        }
コード例 #10
0
ファイル: PayFeeEdit.aspx.cs プロジェクト: dmhai/ColoPay
        /// <summary>
        /// 保存操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            if (txtPayFree.Text.Trim() == "")
            {
                YSWL.Common.MessageBox.ShowSuccessTip(this, string.Format("设置费率{0}!", ""));
                return;
            }

            PayFreeModel.EnterpriseID = int.Parse(lbEnterPid.Text);
            PayFreeModel.PayModeId    = int.Parse(lbPayModelid.Text);
            PayFreeModel.FeeRate      = decimal.Parse(txtPayFree.Text);

            EnterPriseModel = EnterpriseBll.GetModel(int.Parse(lbEnterPid.Text));
            if (EnterPriseModel != null)
            {
                if (EnterPriseModel.AgentId.ToString() == lbAgentId.Text)
                {
                    if (lbType.Text == "0")
                    {
                        //开通通道
                        if (PayFreeBll.Add(PayFreeModel))
                        {
                            YSWL.Common.MessageBox.ShowSuccessTip(this, string.Format("开通通道成功,费率:【{0}】!", txtPayFree.Text));
                            LogHelp.AddUserLog(CurrentUser.UserName, CurrentUser.UserType, string.Format(" 商户" + lbEnterPid.Text + " ,设置费率:【{0}】", txtPayFree.Text), this);
                            Response.Redirect("PayFeeList.aspx?Enterpid=" + lbEnterPid.Text + "");
                        }
                    }
                    else
                    {
                        if (PayFreeBll.Update(PayFreeModel))
                        {
                            YSWL.Common.MessageBox.ShowSuccessTip(this, string.Format("修改费率:【{0}】成功!", txtPayFree.Text));
                            LogHelp.AddUserLog(CurrentUser.UserName, CurrentUser.UserType, string.Format(" 商户" + lbEnterPid.Text + " ,设置费率:【{0}】", txtPayFree.Text), this);
                            Response.Redirect("PayFeeList.aspx?Enterpid=" + lbEnterPid.Text + "");
                        }
                    }
                }
                else
                {
                    YSWL.Common.MessageBox.ShowSuccessTip(this, string.Format("不可修改别家商户的数据!用户:【{0}】", CurrentUser.UserName));
                    LogHelp.AddUserLog(CurrentUser.UserName, CurrentUser.UserType, string.Format(" 商户" + lbEnterPid.Text + " ,不可修改别家商户的数据", txtPayFree.Text), this);
                }
            }
        }
コード例 #11
0
ファイル: PayFeeList.aspx.cs プロジェクト: dmhai/ColoPay
        public void ShowInfo(string strEnerpid)
        {
            EnterPriseModel = EnterpriseBll.GetModel(int.Parse(strEnerpid));

            lbEnterName.Text = EnterPriseModel.Name;
        }
コード例 #12
0
ファイル: EnterpriseAdd.aspx.cs プロジェクト: dmhai/ColoPay
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            if (lbEnterPid.Text.Trim() != "")
            {
                EnterPriseModel = EnterpriseBll.GetModel(int.Parse(lbEnterPid.Text));
                userModel       = userbll.GetModel(EnterPriseModel.UserName);
            }

            User newUser = new User();

#pragma warning disable CS0219 // 变量“strErr”已被赋值,但从未使用过它的值
            string strErr = "";
#pragma warning restore CS0219 // 变量“strErr”已被赋值,但从未使用过它的值
            //if (newUser.HasUserByUserName(txtUserName.Text))
            //{
            //    strErr += Resources.Site.TooltipUserExist;
            //}
            //if (strErr != "")
            //{
            //    YSWL.Common.MessageBox.ShowSuccessTip(this, strErr);
            //    return;
            //}
            newUser.UserName = txtUserName.Text;
            newUser.Password = AccountsPrincipal.EncryptPassword("111111");
            newUser.NickName = newUser.UserName;    //昵称和用户名相同 SNS模块使用
            newUser.TrueName = txtName.Text;
            newUser.Sex      = "1";


            newUser.EmployeeID      = 0;
            newUser.Activity        = true;
            newUser.UserType        = "EE";
            newUser.Style           = 1;
            newUser.User_dateCreate = DateTime.Now;
            newUser.User_iCreator   = CurrentUser.UserID;
            newUser.User_dateValid  = DateTime.Now;
            newUser.User_cLang      = "zh-CN";


            EnterPriseModel.UserName        = txtUserName.Text;
            EnterPriseModel.Name            = txtName.Text;
            EnterPriseModel.SimpleName      = txtSimpleName.Text;
            EnterPriseModel.Status          = 0;
            EnterPriseModel.EnterpriseNum   = txtEnterpriseNum.Text;
            EnterPriseModel.BusinessLicense = txtBusinessLicense.Text;
            EnterPriseModel.TelPhone        = txtTelPhone.Text;
            EnterPriseModel.CellPhone       = txtCellPhone.Text;
            EnterPriseModel.AccountBank     = txtAccountBank.Text;
            EnterPriseModel.AccountInfo     = txtAccountInfo.Text;
            EnterPriseModel.AccountNum      = txtAccountNum.Text;
            EnterPriseModel.WithdrawBank    = txtWithdrawBank.Text;
            EnterPriseModel.WithdrawInfo    = txtWithdrawInfo.Text;
            EnterPriseModel.WithdrawNum     = txtWithdrawNum.Text;
            EnterPriseModel.Balance         = 0;
            EnterPriseModel.AppId           = txtAppId.Text;
            EnterPriseModel.AppSecrit       = txtAppSecrit.Text;
            EnterPriseModel.AppUrl          = txtAppUrl.Text;
            EnterPriseModel.AppReturnUrl    = txtAppReturnUrl.Text;
            EnterPriseModel.ContactMail     = txtContactMail.Text;
            EnterPriseModel.Address         = txtAddress.Text;
            EnterPriseModel.EnteRank        = 1;
            EnterPriseModel.CreatedDate     = DateTime.Now;
            EnterPriseModel.CreatedUserID   = CurrentUser.UserID;

            EnterPriseModel.RegisterIp = "";
            EnterPriseModel.Remark     = txtRemark.Text;

            EnterPriseModel.AgentId = int.Parse(lbAgentId.Text);

            if (lbEnterPid.Text == "")
            {
                if (EnterpriseBll.ExistsUsername(txtUserName.Text))
                {
                    lblMsg.Text = "用户名已存在,请重新输入!";
                    return;
                }

                if (EnterpriseBll.ExistsName(txtName.Text))
                {
                    lblMsg.Text = "商户名称已存在,请重新输入!";
                    return;
                }
                else
                {
                    int userid = newUser.Create();
                    if (userid == -100)
                    {
                        //ERROR
                        YSWL.Common.MessageBox.ShowSuccessTip(this, Resources.Site.TooltipUserExist);
                        return;
                    }

                    //新增商户成功
                    if (EnterpriseBll.Add(EnterPriseModel) > 0)
                    {
                        YSWL.Common.MessageBox.ShowSuccessTip(this, string.Format("新增商户:【{0}】成功!", txtUserName.Text));
                        LogHelp.AddUserLog(CurrentUser.UserName, CurrentUser.UserType, string.Format("新增商户:【{0}】", txtUserName.Text), this);
                        Response.Redirect("EnterpriseList.aspx");
                    }
                }
            }
            else
            {
                if (EnterpriseBll.ExistsUsername(lbEnterPid.Text, txtUserName.Text))
                {
                    lblMsg.Text = "用户名已存在,请重新输入!";
                }
                if (EnterpriseBll.ExistsName(lbEnterPid.Text, txtName.Text))
                {
                    lblMsg.Text = "商户名称已存在,请重新输入!";
                    return;
                }
                else
                {
                    userModel.UserName = txtUserName.Text;
                    EnterpriseBll.Update(EnterPriseModel);//修改企业信息
                    YSWL.Common.MessageBox.ShowSuccessTip(this, string.Format("修改商户信息:【{0}】成功!", txtUserName.Text));
                    Response.Redirect("EnterpriseList.aspx");
                }
            }
        }
コード例 #13
0
ファイル: PayController.cs プロジェクト: dmhai/ColoPay
        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));
        }
コード例 #14
0
ファイル: PayController.cs プロジェクト: dmhai/ColoPay
        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")
                });
            }
        }
コード例 #15
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ColoPay.Model.Pay.Enterprise model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Pay_Enterprise set ");
            strSql.Append("AgentId=@AgentId,");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Name=@Name,");
            strSql.Append("SimpleName=@SimpleName,");
            strSql.Append("Status=@Status,");
            strSql.Append("EnterpriseNum=@EnterpriseNum,");
            strSql.Append("BusinessLicense=@BusinessLicense,");
            strSql.Append("TelPhone=@TelPhone,");
            strSql.Append("CellPhone=@CellPhone,");
            strSql.Append("AccountBank=@AccountBank,");
            strSql.Append("AccountInfo=@AccountInfo,");
            strSql.Append("AccountNum=@AccountNum,");
            strSql.Append("WithdrawBank=@WithdrawBank,");
            strSql.Append("WithdrawInfo=@WithdrawInfo,");
            strSql.Append("WithdrawNum=@WithdrawNum,");
            strSql.Append("Balance=@Balance,");
            strSql.Append("AppId=@AppId,");
            strSql.Append("AppSecrit=@AppSecrit,");
            strSql.Append("AppUrl=@AppUrl,");
            strSql.Append("AppReturnUrl=@AppReturnUrl,");
            strSql.Append("ContactMail=@ContactMail,");
            strSql.Append("Address=@Address,");
            strSql.Append("EnteRank=@EnteRank,");
            strSql.Append("CreatedDate=@CreatedDate,");
            strSql.Append("CreatedUserID=@CreatedUserID,");
            strSql.Append("RegisterIp=@RegisterIp,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where EnterpriseID=@EnterpriseID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AgentId",         SqlDbType.Int,          4),
                new SqlParameter("@UserName",        SqlDbType.NVarChar,    50),
                new SqlParameter("@Name",            SqlDbType.NVarChar,   200),
                new SqlParameter("@SimpleName",      SqlDbType.NVarChar,   200),
                new SqlParameter("@Status",          SqlDbType.SmallInt,     2),
                new SqlParameter("@EnterpriseNum",   SqlDbType.NVarChar,   200),
                new SqlParameter("@BusinessLicense", SqlDbType.NVarChar,   200),
                new SqlParameter("@TelPhone",        SqlDbType.NVarChar,    50),
                new SqlParameter("@CellPhone",       SqlDbType.NVarChar,    50),
                new SqlParameter("@AccountBank",     SqlDbType.NVarChar,   300),
                new SqlParameter("@AccountInfo",     SqlDbType.NVarChar,   200),
                new SqlParameter("@AccountNum",      SqlDbType.NVarChar,   200),
                new SqlParameter("@WithdrawBank",    SqlDbType.NVarChar,   300),
                new SqlParameter("@WithdrawInfo",    SqlDbType.NVarChar,   200),
                new SqlParameter("@WithdrawNum",     SqlDbType.NVarChar,   200),
                new SqlParameter("@Balance",         SqlDbType.Money,        8),
                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("@ContactMail",     SqlDbType.NVarChar,    50),
                new SqlParameter("@Address",         SqlDbType.NVarChar,    50),
                new SqlParameter("@EnteRank",        SqlDbType.Int,          4),
                new SqlParameter("@CreatedDate",     SqlDbType.DateTime),
                new SqlParameter("@CreatedUserID",   SqlDbType.Int,          4),
                new SqlParameter("@RegisterIp",      SqlDbType.NVarChar,    50),
                new SqlParameter("@Remark",          SqlDbType.NVarChar,  1000),
                new SqlParameter("@EnterpriseID",    SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.AgentId;
            parameters[1].Value  = model.UserName;
            parameters[2].Value  = model.Name;
            parameters[3].Value  = model.SimpleName;
            parameters[4].Value  = model.Status;
            parameters[5].Value  = model.EnterpriseNum;
            parameters[6].Value  = model.BusinessLicense;
            parameters[7].Value  = model.TelPhone;
            parameters[8].Value  = model.CellPhone;
            parameters[9].Value  = model.AccountBank;
            parameters[10].Value = model.AccountInfo;
            parameters[11].Value = model.AccountNum;
            parameters[12].Value = model.WithdrawBank;
            parameters[13].Value = model.WithdrawInfo;
            parameters[14].Value = model.WithdrawNum;
            parameters[15].Value = model.Balance;
            parameters[16].Value = model.AppId;
            parameters[17].Value = model.AppSecrit;
            parameters[18].Value = model.AppUrl;
            parameters[19].Value = model.AppReturnUrl;
            parameters[20].Value = model.ContactMail;
            parameters[21].Value = model.Address;
            parameters[22].Value = model.EnteRank;
            parameters[23].Value = model.CreatedDate;
            parameters[24].Value = model.CreatedUserID;
            parameters[25].Value = model.RegisterIp;
            parameters[26].Value = model.Remark;
            parameters[27].Value = model.EnterpriseID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #16
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ColoPay.Model.Pay.Enterprise model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Pay_Enterprise(");
            strSql.Append("AgentId,UserName,Name,SimpleName,Status,EnterpriseNum,BusinessLicense,TelPhone,CellPhone,AccountBank,AccountInfo,AccountNum,WithdrawBank,WithdrawInfo,WithdrawNum,Balance,AppId,AppSecrit,AppUrl,AppReturnUrl,ContactMail,Address,EnteRank,CreatedDate,CreatedUserID,RegisterIp,Remark)");
            strSql.Append(" values (");
            strSql.Append("@AgentId,@UserName,@Name,@SimpleName,@Status,@EnterpriseNum,@BusinessLicense,@TelPhone,@CellPhone,@AccountBank,@AccountInfo,@AccountNum,@WithdrawBank,@WithdrawInfo,@WithdrawNum,@Balance,@AppId,@AppSecrit,@AppUrl,@AppReturnUrl,@ContactMail,@Address,@EnteRank,@CreatedDate,@CreatedUserID,@RegisterIp,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AgentId",         SqlDbType.Int,         4),
                new SqlParameter("@UserName",        SqlDbType.NVarChar,   50),
                new SqlParameter("@Name",            SqlDbType.NVarChar,  200),
                new SqlParameter("@SimpleName",      SqlDbType.NVarChar,  200),
                new SqlParameter("@Status",          SqlDbType.SmallInt,    2),
                new SqlParameter("@EnterpriseNum",   SqlDbType.NVarChar,  200),
                new SqlParameter("@BusinessLicense", SqlDbType.NVarChar,  200),
                new SqlParameter("@TelPhone",        SqlDbType.NVarChar,   50),
                new SqlParameter("@CellPhone",       SqlDbType.NVarChar,   50),
                new SqlParameter("@AccountBank",     SqlDbType.NVarChar,  300),
                new SqlParameter("@AccountInfo",     SqlDbType.NVarChar,  200),
                new SqlParameter("@AccountNum",      SqlDbType.NVarChar,  200),
                new SqlParameter("@WithdrawBank",    SqlDbType.NVarChar,  300),
                new SqlParameter("@WithdrawInfo",    SqlDbType.NVarChar,  200),
                new SqlParameter("@WithdrawNum",     SqlDbType.NVarChar,  200),
                new SqlParameter("@Balance",         SqlDbType.Money,       8),
                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("@ContactMail",     SqlDbType.NVarChar,   50),
                new SqlParameter("@Address",         SqlDbType.NVarChar,   50),
                new SqlParameter("@EnteRank",        SqlDbType.Int,         4),
                new SqlParameter("@CreatedDate",     SqlDbType.DateTime),
                new SqlParameter("@CreatedUserID",   SqlDbType.Int,         4),
                new SqlParameter("@RegisterIp",      SqlDbType.NVarChar,   50),
                new SqlParameter("@Remark",          SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value  = model.AgentId;
            parameters[1].Value  = model.UserName;
            parameters[2].Value  = model.Name;
            parameters[3].Value  = model.SimpleName;
            parameters[4].Value  = model.Status;
            parameters[5].Value  = model.EnterpriseNum;
            parameters[6].Value  = model.BusinessLicense;
            parameters[7].Value  = model.TelPhone;
            parameters[8].Value  = model.CellPhone;
            parameters[9].Value  = model.AccountBank;
            parameters[10].Value = model.AccountInfo;
            parameters[11].Value = model.AccountNum;
            parameters[12].Value = model.WithdrawBank;
            parameters[13].Value = model.WithdrawInfo;
            parameters[14].Value = model.WithdrawNum;
            parameters[15].Value = model.Balance;
            parameters[16].Value = model.AppId;
            parameters[17].Value = model.AppSecrit;
            parameters[18].Value = model.AppUrl;
            parameters[19].Value = model.AppReturnUrl;
            parameters[20].Value = model.ContactMail;
            parameters[21].Value = model.Address;
            parameters[22].Value = model.EnteRank;
            parameters[23].Value = model.CreatedDate;
            parameters[24].Value = model.CreatedUserID;
            parameters[25].Value = model.RegisterIp;
            parameters[26].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #17
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ColoPay.Model.Pay.Enterprise DataRowToModel(DataRow row)
 {
     ColoPay.Model.Pay.Enterprise model = new ColoPay.Model.Pay.Enterprise();
     if (row != null)
     {
         if (row["EnterpriseID"] != null && row["EnterpriseID"].ToString() != "")
         {
             model.EnterpriseID = int.Parse(row["EnterpriseID"].ToString());
         }
         if (row["AgentId"] != null && row["AgentId"].ToString() != "")
         {
             model.AgentId = int.Parse(row["AgentId"].ToString());
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["SimpleName"] != null)
         {
             model.SimpleName = row["SimpleName"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = int.Parse(row["Status"].ToString());
         }
         if (row["EnterpriseNum"] != null)
         {
             model.EnterpriseNum = row["EnterpriseNum"].ToString();
         }
         if (row["BusinessLicense"] != null)
         {
             model.BusinessLicense = row["BusinessLicense"].ToString();
         }
         if (row["TelPhone"] != null)
         {
             model.TelPhone = row["TelPhone"].ToString();
         }
         if (row["CellPhone"] != null)
         {
             model.CellPhone = row["CellPhone"].ToString();
         }
         if (row["AccountBank"] != null)
         {
             model.AccountBank = row["AccountBank"].ToString();
         }
         if (row["AccountInfo"] != null)
         {
             model.AccountInfo = row["AccountInfo"].ToString();
         }
         if (row["AccountNum"] != null)
         {
             model.AccountNum = row["AccountNum"].ToString();
         }
         if (row["WithdrawBank"] != null)
         {
             model.WithdrawBank = row["WithdrawBank"].ToString();
         }
         if (row["WithdrawInfo"] != null)
         {
             model.WithdrawInfo = row["WithdrawInfo"].ToString();
         }
         if (row["WithdrawNum"] != null)
         {
             model.WithdrawNum = row["WithdrawNum"].ToString();
         }
         if (row["Balance"] != null && row["Balance"].ToString() != "")
         {
             model.Balance = decimal.Parse(row["Balance"].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["ContactMail"] != null)
         {
             model.ContactMail = row["ContactMail"].ToString();
         }
         if (row["Address"] != null)
         {
             model.Address = row["Address"].ToString();
         }
         if (row["EnteRank"] != null && row["EnteRank"].ToString() != "")
         {
             model.EnteRank = int.Parse(row["EnteRank"].ToString());
         }
         if (row["CreatedDate"] != null && row["CreatedDate"].ToString() != "")
         {
             model.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString());
         }
         if (row["CreatedUserID"] != null && row["CreatedUserID"].ToString() != "")
         {
             model.CreatedUserID = int.Parse(row["CreatedUserID"].ToString());
         }
         if (row["RegisterIp"] != null)
         {
             model.RegisterIp = row["RegisterIp"].ToString();
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }