/// <summary> /// 增加一条数据 /// </summary> public int Add(ColoPay.Model.Pay.PaymentTypes model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Pay_PaymentTypes("); strSql.Append("MerchantCode,EmailAddress,SecretKey,SecondKey,Password,Partner,Name,Description,Gateway,DisplaySequence,Charge,IsPercent,AllowRecharge,Logo,DrivePath)"); strSql.Append(" values ("); strSql.Append("@MerchantCode,@EmailAddress,@SecretKey,@SecondKey,@Password,@Partner,@Name,@Description,@Gateway,@DisplaySequence,@Charge,@IsPercent,@AllowRecharge,@Logo,@DrivePath)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MerchantCode", SqlDbType.NVarChar, 300), new SqlParameter("@EmailAddress", SqlDbType.NVarChar, 255), new SqlParameter("@SecretKey", SqlDbType.NVarChar, 4000), new SqlParameter("@SecondKey", SqlDbType.NVarChar, 4000), new SqlParameter("@Password", SqlDbType.NVarChar, 4000), new SqlParameter("@Partner", SqlDbType.NVarChar, 300), new SqlParameter("@Name", SqlDbType.NVarChar, 100), new SqlParameter("@Description", SqlDbType.NText), new SqlParameter("@Gateway", SqlDbType.NVarChar, 200), new SqlParameter("@DisplaySequence", SqlDbType.Int, 4), new SqlParameter("@Charge", SqlDbType.Money, 8), new SqlParameter("@IsPercent", SqlDbType.Bit, 1), new SqlParameter("@AllowRecharge", SqlDbType.Bit, 1), new SqlParameter("@Logo", SqlDbType.NVarChar, 255), new SqlParameter("@DrivePath", SqlDbType.NVarChar, 255) }; parameters[0].Value = model.MerchantCode; parameters[1].Value = model.EmailAddress; parameters[2].Value = model.SecretKey; parameters[3].Value = model.SecondKey; parameters[4].Value = model.Password; parameters[5].Value = model.Partner; parameters[6].Value = model.Name; parameters[7].Value = model.Description; parameters[8].Value = model.Gateway; parameters[9].Value = model.DisplaySequence; parameters[10].Value = model.Charge; parameters[11].Value = model.IsPercent; parameters[12].Value = model.AllowRecharge; parameters[13].Value = model.Logo; parameters[14].Value = model.DrivePath; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * SqlParameter[] parameters = { * new SqlParameter("@tblName", SqlDbType.VarChar, 255), * new SqlParameter("@fldName", SqlDbType.VarChar, 255), * new SqlParameter("@PageSize", SqlDbType.Int), * new SqlParameter("@PageIndex", SqlDbType.Int), * new SqlParameter("@IsReCount", SqlDbType.Bit), * new SqlParameter("@OrderType", SqlDbType.Bit), * new SqlParameter("@strWhere", SqlDbType.VarChar,1000), * }; * parameters[0].Value = "Pay_PaymentTypes"; * parameters[1].Value = "ModeId"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ #endregion BasicMethod #region ExtensionMethod public ColoPay.Model.Pay.PaymentTypes GetPaymentInfo(string type) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ModeId,MerchantCode,EmailAddress,SecretKey,SecondKey,Password,Partner,Name,Description,Gateway,DisplaySequence,Charge,IsPercent,AllowRecharge,Logo,DrivePath from Pay_PaymentTypes "); strSql.Append(" where Gateway=@Gateway"); SqlParameter[] parameters = { new SqlParameter("@Gateway", SqlDbType.NVarChar, 200) }; parameters[0].Value = type; ColoPay.Model.Pay.PaymentTypes model = new ColoPay.Model.Pay.PaymentTypes(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void ShowInfoPayType(string strPayTypeid) { PaytypesModel = PaytypesBll.GetModel(int.Parse(strPayTypeid)); lbPayTypeName.Text = PaytypesModel.Name; }
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)); }
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") }); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ColoPay.Model.Pay.PaymentTypes DataRowToModel(DataRow row) { ColoPay.Model.Pay.PaymentTypes model = new ColoPay.Model.Pay.PaymentTypes(); if (row != null) { if (row["ModeId"] != null && row["ModeId"].ToString() != "") { model.ModeId = int.Parse(row["ModeId"].ToString()); } if (row["MerchantCode"] != null) { model.MerchantCode = row["MerchantCode"].ToString(); } if (row["EmailAddress"] != null) { model.EmailAddress = row["EmailAddress"].ToString(); } if (row["SecretKey"] != null) { model.SecretKey = row["SecretKey"].ToString(); } if (row["SecondKey"] != null) { model.SecondKey = row["SecondKey"].ToString(); } if (row["Password"] != null) { model.Password = row["Password"].ToString(); } if (row["Partner"] != null) { model.Partner = row["Partner"].ToString(); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Description"] != null) { model.Description = row["Description"].ToString(); } if (row["Gateway"] != null) { model.Gateway = row["Gateway"].ToString(); } if (row["DisplaySequence"] != null && row["DisplaySequence"].ToString() != "") { model.DisplaySequence = int.Parse(row["DisplaySequence"].ToString()); } if (row["Charge"] != null && row["Charge"].ToString() != "") { model.Charge = decimal.Parse(row["Charge"].ToString()); } if (row["IsPercent"] != null && row["IsPercent"].ToString() != "") { if ((row["IsPercent"].ToString() == "1") || (row["IsPercent"].ToString().ToLower() == "true")) { model.IsPercent = true; } else { model.IsPercent = false; } } if (row["AllowRecharge"] != null && row["AllowRecharge"].ToString() != "") { if ((row["AllowRecharge"].ToString() == "1") || (row["AllowRecharge"].ToString().ToLower() == "true")) { model.AllowRecharge = true; } else { model.AllowRecharge = false; } } if (row["Logo"] != null) { model.Logo = row["Logo"].ToString(); } if (row["DrivePath"] != null) { model.DrivePath = row["DrivePath"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ColoPay.Model.Pay.PaymentTypes model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Pay_PaymentTypes set "); strSql.Append("MerchantCode=@MerchantCode,"); strSql.Append("EmailAddress=@EmailAddress,"); strSql.Append("SecretKey=@SecretKey,"); strSql.Append("SecondKey=@SecondKey,"); strSql.Append("Password=@Password,"); strSql.Append("Partner=@Partner,"); strSql.Append("Name=@Name,"); strSql.Append("Description=@Description,"); strSql.Append("Gateway=@Gateway,"); strSql.Append("DisplaySequence=@DisplaySequence,"); strSql.Append("Charge=@Charge,"); strSql.Append("IsPercent=@IsPercent,"); strSql.Append("AllowRecharge=@AllowRecharge,"); strSql.Append("Logo=@Logo,"); strSql.Append("DrivePath=@DrivePath"); strSql.Append(" where ModeId=@ModeId"); SqlParameter[] parameters = { new SqlParameter("@MerchantCode", SqlDbType.NVarChar, 300), new SqlParameter("@EmailAddress", SqlDbType.NVarChar, 255), new SqlParameter("@SecretKey", SqlDbType.NVarChar, 4000), new SqlParameter("@SecondKey", SqlDbType.NVarChar, 4000), new SqlParameter("@Password", SqlDbType.NVarChar, 4000), new SqlParameter("@Partner", SqlDbType.NVarChar, 300), new SqlParameter("@Name", SqlDbType.NVarChar, 100), new SqlParameter("@Description", SqlDbType.NText), new SqlParameter("@Gateway", SqlDbType.NVarChar, 200), new SqlParameter("@DisplaySequence", SqlDbType.Int, 4), new SqlParameter("@Charge", SqlDbType.Money, 8), new SqlParameter("@IsPercent", SqlDbType.Bit, 1), new SqlParameter("@AllowRecharge", SqlDbType.Bit, 1), new SqlParameter("@Logo", SqlDbType.NVarChar, 255), new SqlParameter("@DrivePath", SqlDbType.NVarChar, 255), new SqlParameter("@ModeId", SqlDbType.Int, 4) }; parameters[0].Value = model.MerchantCode; parameters[1].Value = model.EmailAddress; parameters[2].Value = model.SecretKey; parameters[3].Value = model.SecondKey; parameters[4].Value = model.Password; parameters[5].Value = model.Partner; parameters[6].Value = model.Name; parameters[7].Value = model.Description; parameters[8].Value = model.Gateway; parameters[9].Value = model.DisplaySequence; parameters[10].Value = model.Charge; parameters[11].Value = model.IsPercent; parameters[12].Value = model.AllowRecharge; parameters[13].Value = model.Logo; parameters[14].Value = model.DrivePath; parameters[15].Value = model.ModeId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }