private int UpdateAccountRechare(AccountRechareInfo Info) { string strSQL = " Update AccountRechare Set" + " [From]=@From WHERE TranOrder=@TranOrder"; var paramData = new Dapper.DynamicParameters(); paramData.Add("@From", Info.From); paramData.Add("@TranOrder", Info.TranOrder); return(PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref paramData)); }
private AccountRechareInfo getAccountRechare(string TranOrder) { AccountRechareInfo model = null; string strSQL = " select Id,TranOrder,Amount from AccountRechare WITH(NOLOCK) WHERE TranOrder=@TranOrder"; DynamicParameters paramData = new DynamicParameters(); paramData.Add("@TranOrder", TranOrder); model = PublicConn.QuerySingleWrite <AccountRechareInfo>(strSQL, ref paramData); return(model); }
protected void DoAfterPay(TuanDai.Payment.ResultNotify resultNotify) { if (resultNotify.IsSuccess) { AccountRechareInfo accountRechare = getAccountRechare(resultNotify.OutTradeNo); if (accountRechare != null) { //调用第三方渠道 try { TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack(accountRechare.Id, accountRechare.UserId); } catch (Exception ex) { new TuanDai.LogSystem.LogClient.LogClients().WriteErrorLog( "TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack", "", "", ex.Message); } UserBasicInfoInfo userBasicInfo = new UserBLL().GetUserBasicInfoModelById(accountRechare.UserId); if (userBasicInfo != null) { var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0"); if (isNewSmsRequest == "0") { var parameters = new Dictionary<string, object>(); parameters.Add("CurrentDate", DateTime.Now); parameters.Add("RechargeMoney", resultNotify.TradeMoney); parameters.Add("User", userBasicInfo); parameters.Add("Host", GlobalUtils.WebURL); var msgSender = new BusinessDll.MessageSend(); msgSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters, mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id); } else { SmsRequest rechargeSuccessSmsRequest = new SmsRequest(); rechargeSuccessSmsRequest.EventCode = MsgTemplatesType.RechargeSuccess; rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc; rechargeSuccessSmsRequest.UserId = userBasicInfo.Id; rechargeSuccessSmsRequest.EmailAddress = userBasicInfo.Email; rechargeSuccessSmsRequest.Mobile = userBasicInfo.TelNo; rechargeSuccessSmsRequest.Parameters = new Dictionary<string, object>(); rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", resultNotify.TradeMoney); string errorMessage = string.Empty; SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage); } } } } }
protected void Page_Load(object sender, EventArgs e) { WebSettingInfo webSetting = new WebSettingBLL().GetWebSettingInfo("fe5e5a30-b12c-4888-9858-12cbe80e1018"); // 商户唯一订单号 string no_order = "" + Request.QueryString["orderno"]; //LogHelper.WriteLog("宝付支付我方订单号", "", no_order); SysLogHelper.WriteTraceLog("宝付支付我方订单号", no_order); AccountRechareInfo rechargemodel = getAccountRechare(no_order); if (null == rechargemodel) { Response.Write("您好,获取充值记录为null!"); return; } string strMd5Key; strMemberID = "100000178"; //webSetting.Param1Value.ToString().Trim();//商户号 strPayID = ""; //Request.Params["PayID"];//招商银行是1001 strTradeDate = DateTime.Now.ToString("yyyyMMddHHmmss"); strTransID = rechargemodel.TranOrder.Trim(); //strMemberID + DateTime.Now.ToString("MMddHHmmss");//商户订单号(交易流水号)(建议使用商户订单号加上贵方的唯一标识号) strOrderMoney = (float.Parse(rechargemodel.Amount.ToString("f2")) * 100).ToString(); //订单金额,需要和卡面额一致(此处以分为单位) strProductName = "宝付在线充值"; //商品名称 strAmount = "1"; //商品数量,为1 strUsername = ""; strAdditionalInfo = ""; strPageUrl = GlobalUtils.WebURL + "/PaymentPlatform/Baofu/page_url.aspx"; //客户端跳转地址 strReturnUrl = GlobalUtils.WebURL + "/PaymentPlatform/Baofu/return_url.aspx"; //ConfigurationManager.AppSettings["BaofuNotifyUrl"];//ConfigurationManager.AppSettings["ReturnUrl"];//服务器端返回地址 strNoticeType = "1"; //0 不跳转 1 会跳转 strMd5Key = "abcdefg"; //webSetting.Param2Value.Trim();//ConfigurationManager.AppSettings["Md5key"];//密钥 双方约定 strTerminalID = "10000001"; //webSetting.Param3Value.Trim();//ConfigurationManager.AppSettings["TerminalID"];//终端 strInterfaceVersion = "4.0"; // webSetting.Param4Value.Trim();//ConfigurationManager.AppSettings["InterfaceVersion"];//版本 当前为4.0请勿修改 strKeyType = webSetting.Param5Value.Trim(); //ConfigurationManager.AppSettings["KeyType"]; //加密方式默认1 MD5 strSignature = GetMd5Sign(strMemberID, strPayID, strTradeDate, strTransID, strOrderMoney, strPageUrl, strReturnUrl, strNoticeType, strMd5Key); //LogHelper.WriteLog("支付请求签名", "", strSignature); SysLogHelper.WriteTraceLog("支付请求签名", no_order); }
protected SortedDictionary <string, string> getBaseParamDict() { if (WebUserAuth.UserId != Guid.Empty) { userid = WebUserAuth.UserId.Value; } else { Response.Redirect("~/user/login.aspx"); return(null); } /**订单信息**/ // 商户唯一订单号 string no_order = "" + Request.QueryString["orderno"]; // 商户订单时间 string dt_order = PaymentUtil.GetCurrentDateTimeStr(); AccountRechareInfo rechargemodel = getAccountRechare(no_order); if (rechargemodel == null) { return(null); } // 交易金额 单位为RMB-元 string money_order = rechargemodel.Amount.ToString("f2"); // 商品名称 string name_goods = "Online Recharge"; // 订单描述 string info_order = "Online Recharge"; //var userInfo = db.UserBasicInfo.FirstOrDefault(x => x.AuditRecordId == userid); //if (null == userInfo) //{ //} SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); try { UserBLL bll = new UserBLL(); userInfo = bll.GetUserBasicInfoModelById(userid); //从UserBasicInfo表获取银行卡号 if (string.IsNullOrEmpty(userInfo.BankAccountNo)) { string sql = @"SELECT BankAccountNo as BankNo FROM UserBasicInfo WITH(NOLOCK) WHERE Id = @UserId "; DynamicParameters para = new DynamicParameters(); para.Add("@UserId", userid); userInfo.BankAccountNo = PublicConn.QuerySingle <string>(sql, ref para); } /** 商户提交参数**/ string version = partnerConfig.Version; //接口版本号 string oid_partner = partnerConfig.OidPartner; //商户编号 user_id = userid.ToString(); //用户ID string sign_type = partnerConfig.SignType; //签名类型:RSA/MD5 string busi_partner = partnerConfig.BusiPartner; //业务类型 虚拟商品销售 // string notify_url = ConfigurationManager.AppSettings["WebUrl"] + "/PaymentPlatform/lianlian/notify_url.aspx";//接收异步通知地 string notify_url = "https://www.tuandai.com/PaymentPlatform/lianlian/notify_url.aspx"; string url_return = ConfigurationManager.AppSettings["WebUrl"] + "/PaymentPlatform/lianlian/urlReturn.aspx"; //支付结束后返回地址 string userreq_ip = PaymentUtil.LocalIPAddress(); //IP * //string url_order = ""; string valid_order = "10080"; // 订单有效期 单位分钟,可以为空,默认7天 string timestamp = PaymentUtil.GetCurrentDateTimeStr(); //时间戳 //string idType = "0"; //证件类型 string idNo = userInfo.IdentityCard; //"623026199206016992"; acctName = userInfo.RealName; //"彭思微"; telno = userInfo.TelNo; sParaTemp.Add("app_request", "3"); sParaTemp.Add("bg_color", "d93f3f"); sParaTemp.Add("busi_partner", busi_partner); sParaTemp.Add("card_no", userInfo.BankAccountNo); sParaTemp.Add("dt_order", dt_order); sParaTemp.Add("id_no", idNo); sParaTemp.Add("info_order", info_order); sParaTemp.Add("money_order", money_order); sParaTemp.Add("name_goods", name_goods); //sParaTemp.Add("no_agree", ""); sParaTemp.Add("no_order", no_order); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("oid_partner", oid_partner); sParaTemp.Add("acct_name", acctName); sParaTemp.Add("risk_item", createRiskItem(userid, acctName, idNo, userInfo.TelNo, userInfo.AddDate.Value.ToString("yyyyMMddHHmmss"))); // sParaTemp.Add("risk_item", createRiskItemOld(user_id, acctName)); sParaTemp.Add("sign_type", sign_type); sParaTemp.Add("url_return", url_return); sParaTemp.Add("user_id", telno); sParaTemp.Add("valid_order", valid_order); NetLog.WriteBatchwithdrawHandler("连连充值请求", string.Concat("签名方式", sign_type, "订单号:", no_order, ",用户编号:", user_id, "充值金额", money_order, "IP地址", userreq_ip), "触屏版"); //LogHelper.WriteLog("连连充值请求", "", string.Concat("签名方式", sign_type, "订单号:", no_order, ",用户编号:", user_id, "充值金额", money_order, "IP地址", userreq_ip)); } catch (Exception ex) { string errormessage = "内部错误:" + ex.InnerException + "\r\n堆栈:" + ex.StackTrace + "\r\n信息:" + ex.Message + "\r\n来源:" + ex.Source; //LogTextHelper.Instance.AddLog(errormessage); TuanDai.LogSystem.LogClient.LogClients.ErrorLog("WXTouch", "连连充值请求", "", errormessage); } return(sParaTemp); }
private void ConfirmPay() { Guid userid; if (WebUserAuth.UserId != null) { userid = WebUserAuth.UserId.Value; } else { PrintJson("0", "您还未登录!"); return; } string orderId = WEBRequest.GetFormString("OrderId"); string valCode = WEBRequest.GetFormString("SMSCode"); string isBindCard = WEBRequest.GetFormString("IsBindCard"); try { if (isBindCard == "1") { AccountRechareInfo ar = getAccountRechare(orderId); if (null == ar) { PrintJson("0", "充值交易未成功!"); return; } BankCardPay.ConfirmBindBankCard(orderId, valCode); } else { //获取个人信息 UserBLL userbll = new UserBLL(); UserBasicInfoInfo userInfo = userbll.GetUserBasicInfoModelById(userid); if (null == userInfo) { PrintJson("0", "获取用户信息错误!"); return; } GetBankCardNo(userInfo, userid); //是否绑定银行卡 if (string.IsNullOrEmpty(userInfo.BankAccountNo)) { PrintJson("0", "银行卡未绑定!"); return; } string requestId = WEBRequest.GetFormString("RequestId").ToUpper(); //确认绑卡 BindBankCard.ConfirmBindBankCard(requestId, valCode); //无短信充值 AccountRechareInfo ar = getAccountRechare(orderId); if (null == ar) { PrintJson("0", "充值交易未成功!"); return; } var identityId = userInfo.Id.ToString().Replace("-", string.Empty).ToUpper(); var bindCardModel = BindBankCardList.GetBindCardList(identityId, userInfo.BankAccountNo.Trim()); var rechargeAmount = (int)(ar.Amount * 100); BindBankCardPay.BindPay(new BankCardPayRequestModel { Amount = rechargeAmount, CallBackUrl = EBNotifyUrl, CardLast = bindCardModel.Card_Last, CardTop = bindCardModel.Card_Top, IdentityId = identityId, OrderId = orderId }); } } catch (Exception ex) { SysLogHelper.WriteErrorLog("易宝充值出错:ConfirmPay", Tool.ExceptionHelper.GetExceptionMessage(ex)); PrintJson("0", "发生错误:" + ex.Message); return; } PrintJson("1", ""); }
protected void Page_Load(object sender, EventArgs e) { TuanDai.Payment.Log.Info(this.GetType().ToString(), "开始易宝回调"); string callback_result = ""; try { if (Request["data"] == null || Request["encryptkey"] == null) { TuanDai.Payment.Log.Info(this.GetType().ToString(), "参数不正确"); Response.Write("参数不正确!"); Response.End(); } TuanDai.Payment.Log.Info(this.GetType().ToString(), "易宝回调加密参数:" + Request["data"] + ",密钥:" + Request["encryptkey"]); //商户注意:接收到易宝的回调信息后一定要回写success用以保证握手成功! string data = Request["data"]; //回调中的参数data string encryptkey = Request["encryptkey"]; //回调中的参数encryptkey callback_result = YJPayUtil.checkYbCallbackResult(data, encryptkey); var resultData = JsonConvert.DeserializeObject <SortedDictionary <string, string> >(callback_result); TuanDai.Payment.Log.Info(this.GetType().ToString(), "The Pay result is Values : " + callback_result); if (resultData == null || resultData.ContainsKey("error_msg")) { Response.Write("参数不正确!"); Response.End(); } var status = resultData["status"].ToString(); var rechargeMoney = resultData["amount"].ToString(); var out_trade_no = resultData["orderid"].ToString(); var transaction_id = resultData["yborderid"].ToString(); string strSQL = "p_OnLineRechargeHandler"; DynamicParameters dyParams = new DynamicParameters(); dyParams.Add("@orderno", out_trade_no); dyParams.Add("@MediumMoney", decimal.Parse(rechargeMoney) / 100); dyParams.Add("@MediumOrderNo", transaction_id); dyParams.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output, 20); if (status == "1") { dyParams.Add("@handlerStatus", 2); } else { dyParams.Add("@handlerStatus", 1); } PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams, CommandType.StoredProcedure); int result = dyParams.Get <int>("@outStatus"); if (result == 1) { AccountRechareInfo accountRechare = getAccountRechare(out_trade_no); if (accountRechare != null) { //List<int> typeList = new List<int>() { 2, 3, 4, 6, 8,9,11, 12 }; //if (db.AccountRechare.Count(p => p.UserId == accountRechare.UserId && p.Status == 2 && typeList.Contains(p.type)) == 1) //{ // TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(accountRechare.UserId, (int)ConstString.UserGrowthType.FirstReCharge, null, 0); //} TuanDai.PortalSystem.BLL.UserBLL bll = new TuanDai.PortalSystem.BLL.UserBLL(); UserBasicInfoInfo userBasicInfo = bll.GetUserBasicInfoModelById(accountRechare.UserId); if (userBasicInfo != null) { var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0"); if (isNewSmsRequest == "0") { var parameters = new Dictionary <string, object>(); parameters.Add("User", userBasicInfo); parameters.Add("CurrentDate", DateTime.Now); parameters.Add("RechargeMoney", rechargeMoney); parameters.Add("Host", GlobalUtils.WebURL); var messageSender = new BusinessDll.MessageSend(); messageSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters, mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id); } else { SmsRequest rechargeSuccessSmsRequest = new SmsRequest(); rechargeSuccessSmsRequest.EventCode = MsgTemplatesType.RechargeSuccess; rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc; rechargeSuccessSmsRequest.UserId = userBasicInfo.Id; rechargeSuccessSmsRequest.EmailAddress = userBasicInfo.Email; rechargeSuccessSmsRequest.Mobile = userBasicInfo.TelNo; rechargeSuccessSmsRequest.Parameters = new Dictionary <string, object>(); rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", rechargeMoney); string errorMessage = string.Empty; SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage); } } } } //NetLog.WriteBatchwithdrawHandler("交易成功", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方处理状态:", result.ToString().Trim(), "连连处理状态:", sPara["result_pay"].ToString())); Response.Write(@"SUCCESS"); Response.End(); //SoftLog.LogStr("支付成功回调信息:" + callback_result, "yeepay/CallbackLog"); } catch (Exception err) { TuanDai.Payment.Log.Info(this.GetType().ToString(), "支付失败:" + err.ToString() + "," + Request["data"] + Environment.NewLine + Request["encryptkey"] + "处理结果:" + callback_result); //SoftLog.LogStr("支付失败:" + err.ToString() + "," + Request["data"] + Environment.NewLine + Request["encryptkey"] + "处理结果:" + callback_result, "yeepay/CallbackLog"); Response.Write("支付失败!"); Response.End(); } finally { //SoftLog.LogStr("支付回调信息" + Request["data"] + Environment.NewLine + Request["encryptkey"] + "处理结果:" + callback_result, "yeepay/CallbackLog"); } }
protected void Page_Load(object sender, EventArgs e) { Guid userid = WebUserAuth.UserId.Value; decimal Amount = Tool.SafeConvert.ToDecimal(Request.Params["Amount"], 0); //if (Amount < 100) //{ // Response.Write("您好,充值金额必须大于或者等于100!"); // return; //} if (Amount > 5000000) { Response.Write("单次充值不能超过500万!"); return; } NoHandler noHandler = new NoHandler(); string orderNo = noHandler.OnLineRechare(); if (orderNo == "0") { Response.Write("您好,您的提交失败请重试!"); return; } int Sel = Tool.SafeConvert.ToInt32(Request.Params["Sel"], 12); Guid rechargeId = Guid.NewGuid(); int outStatus = 0; //string bankcode = ""; //bankcode = Request.Params["bankcode"]; ////if (Request.Params["bankcode"] != null) ////{ ////} //if (string.IsNullOrEmpty(bankcode)) //{ // Response.Write("您好,银行编号获取错误!" + Request.QueryString["bankcode"]); // return; //} string userIP = Tool.WebFormHandler.GetIP(); var paramData = new Dapper.DynamicParameters(); paramData.Add("@userid", userid); paramData.Add("@type", Sel); paramData.Add("@amount", Amount); paramData.Add("@orderNo", orderNo); paramData.Add("@backcode", ""); paramData.Add("@clientIp", userIP); paramData.Add("@from", "5"); paramData.Add("@outStatus", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output); TuanDai.WXApiWeb.PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, "AccountRechargeInit", ref paramData, CommandType.StoredProcedure); outStatus = paramData.Get <int>("@outStatus"); int result = outStatus; //NetLog.WriteLoginHandler("宝付5-调用写入充值记录存储过AccountRechargeInit", "UserId:"+userid+",Sel:"+Sel+",Amount:"+Amount+",OrderNo:"+orderNo+",bankcode:"+bankcode+",OutStatus:"+outStatus.Value.ToString()); if (result > 0) { //NetLog.WriteLoginHandler("宝付6","进入写入来源" ); AccountRechareInfo ar = null; lock (lockstatus) { ar = getAccountRechare(orderNo); } //1:PC if (null == ar) { Response.Write("您好,您的提交失败请重试!"); } ar.From = 5; //ar.CradNo = db.UserBasicInfo.FirstOrDefault(x => x.Id == userid).BankAccountNo; if (UpdateAccountRechare(ar) <= 0) { Response.Write("您好,您的提交失败请重试!"); return; } //NetLog.WriteLoginHandler("宝付7", "进入跳转"); var url = "/PaymentPlatform/Baofu/pay_post.aspx?orderno=" + orderNo + "&totalprice=" + Amount + "&PayID="; //NetLog.WriteLoginHandler("宝付8--跳转的URL", url); try { Response.Redirect(url, false); } catch (Exception ex) { SysLogHelper.WriteErrorLog("宝付9跳转错误", "错误详细信息:" + ex.Message + "|" + ex.StackTrace); } } else { Response.Write("您好,您的提交失败请重试!"); } }
protected void Page_Load(object sender, EventArgs e) { WebSettingInfo webSetting = new WebSettingBLL().GetWebSettingInfo("E27798C9-9301-4176-AC0B-6F3916F389EA"); partnerConfig = new PartnerConfig(webSetting.Param1Value, webSetting.Param2Value, webSetting.Param3Value, webSetting.Param5Value); SortedDictionary <string, string> sPara = GetRequestPost(); if (null == sPara) { Response.End(); } if (sPara.Count > 0)//判断是否有带返回参数 { NetLog.WriteBatchwithdrawHandler("接收连连支付异步通知数据", string.Concat("【", "签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方订单号:", sPara["no_order"].ToString(), "充值金额:", sPara["money_order"].ToString(), "连连订单号:", sPara["oid_paybill"].ToString(), "】")); if (!PaymentUtil.CheckSign(sPara, partnerConfig.YTPublicKey, //验证失败 partnerConfig.MD5Key)) { var out_trade_no = sPara["no_order"].ToString(); var rechargeMoney = sPara["money_order"].ToString(); var transaction_id = sPara["oid_paybill"].ToString(); //ObjectParameter outStatus = new ObjectParameter("outStatus", "0"); //db.p_OnLineRechargeHandler(1, out_trade_no, decimal.Parse(rechargeMoney), transaction_id, outStatus); //int result = int.Parse(outStatus.Value.ToString()); NetLog.WriteBatchwithdrawHandler("连连验签失败", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "连连处理状态:9999")); Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""验签失败""}"); Response.End(); } else { var out_trade_no = sPara["no_order"].ToString(); var rechargeMoney = sPara["money_order"].ToString(); var transaction_id = sPara["oid_paybill"].ToString(); string strSQL = "p_OnLineRechargeHandler"; DynamicParameters dyParams = new DynamicParameters(); dyParams.Add("@orderno", out_trade_no); dyParams.Add("@MediumMoney", decimal.Parse(rechargeMoney)); dyParams.Add("@MediumOrderNo", transaction_id); dyParams.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output, 20); if (sPara["result_pay"].ToString().ToLower() == "success".ToLower()) { dyParams.Add("@handlerStatus", 2); } else { dyParams.Add("@handlerStatus", 1); } PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams, CommandType.StoredProcedure); int result = dyParams.Get <int>("@outStatus"); AccountRechareInfo accountRechare = getAccountRechare(out_trade_no); if (accountRechare != null) { var para = new DynamicParameters(); para.Add("@UserId", accountRechare.UserId); var count = PublicConn.QuerySingleWrite <int>("select count(0) from AccountRechare with(nolock) where UserId=@UserId and Status =2 and type in (2, 3, 4, 6, 8, 12)", ref para); if (count == 1) { TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(accountRechare.UserId, (int)ConstString.UserGrowthType.FirstReCharge, null, 0); } UserBasicInfoInfo userBasicInfo = new UserBLL().GetUserBasicInfoModelById(accountRechare.UserId); if (userBasicInfo != null) { var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0"); if (isNewSmsRequest == "0") { var parameters = new Dictionary <string, object>(); parameters.Add("User", userBasicInfo); parameters.Add("CurrentDate", DateTime.Now); parameters.Add("RechargeMoney", rechargeMoney); parameters.Add("Host", GlobalUtils.WebURL); var messageSender = new BusinessDll.MessageSend(); messageSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters, mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id); } else { SmsRequest rechargeSuccessSmsRequest = new SmsRequest(); rechargeSuccessSmsRequest.EventCode = MsgTemplatesType.RechargeSuccess; rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc; rechargeSuccessSmsRequest.UserId = userBasicInfo.Id; rechargeSuccessSmsRequest.EmailAddress = userBasicInfo.Email; rechargeSuccessSmsRequest.Mobile = userBasicInfo.TelNo; rechargeSuccessSmsRequest.Parameters = new Dictionary <string, object>(); rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", rechargeMoney); string errorMessage = string.Empty; SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage); } //第三方渠道回调 try { TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack(accountRechare.Id, accountRechare.UserId); } catch (Exception ex) { new TuanDai.LogSystem.LogClient.LogClients().WriteErrorLog( "TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack", "", "", ex.Message); } } } NetLog.WriteTraceLogHandler("交易成功", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方处理状态:", result.ToString().Trim(), "连连处理状态:", sPara["result_pay"].ToString())); Response.Write(@"{""ret_code"":""0000"",""ret_msg"":""交易成功""}"); Response.End(); } } else { //var out_trade_no = sPara["no_order"].ToString(); //var rechargeMoney = sPara["money_order"].ToString(); //var transaction_id = sPara["oid_paybill"].ToString(); //ObjectParameter outStatus = new ObjectParameter("outStatus", "0"); //db.p_OnLineRechargeHandler(1, out_trade_no, decimal.Parse(rechargeMoney), transaction_id, outStatus); ////Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""验签失败""}"); //int result = int.Parse(outStatus.Value.ToString()); NetLog.WriteBatchwithdrawHandler("连连交易参数为空失败", "连连处理状态:9999"); Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""交易失败""}"); Response.End(); } // 解析异步通知对象 // sPara 字典对象 // TODO:更新订单,发货等后续处理 }
private void InitData() { try { WebSettingInfo webSetting = new WebSettingBLL().GetWebSettingInfo("fe5e5a30-b12c-4888-9858-12cbe80e1018"); string MemberID = Request.Params["MemberID"]; //商户号 string TerminalID = Request.Params["TerminalID"]; //商户终端号 string TransID = Request.Params["TransID"]; //商户流水号 string Result = Request.Params["Result"]; //支付结果(1:成功,0:失败) string ResultDesc = Request.Params["ResultDesc"]; //支付结果描述 string FactMoney = Request.Params["FactMoney"]; //实际成交金额 string AdditionalInfo = Request.Params["AdditionalInfo"]; //订单附加消息 string SuccTime = Request.Params["SuccTime"]; //交易成功时间 string Md5Sign = Request.Params["Md5Sign"].ToLower(); //md5签名 string Md5Key = "abcdefg"; //webSetting.Param2Value;//ConfigurationManager.AppSettings["Md5key"];//密钥 双方约定 String mark = "~|~"; //分隔符 //string _Md5Key = "100000178";//测试商户号//webSetting.Param1Value;//WebConfigurationManager.AppSettings["Md5key"]; string _WaitSign = "MemberID=" + MemberID + mark + "TerminalID=" + TerminalID + mark + "TransID=" + TransID + mark + "Result=" + Result + mark + "ResultDesc=" + ResultDesc + mark + "FactMoney=" + FactMoney + mark + "AdditionalInfo=" + AdditionalInfo + mark + "SuccTime=" + SuccTime + mark + "Md5Sign=" + Md5Key; SysLogHelper.WriteTraceLog("等待验签参数", _WaitSign); //验证签名成功 if (Md5Sign.ToLower() == Md5Encrypt(_WaitSign).ToLower()) { ///支付结果(1:成功,0:失败) DynamicParameters dyParams = new DynamicParameters(); string strSQL = ""; if (Result == "1") { strSQL = "p_OnLineRechargeHandler"; dyParams = new DynamicParameters(); dyParams.Add("@handlerStatus", 2); dyParams.Add("@MediumMoney", decimal.Divide(decimal.Parse(FactMoney), 100)); dyParams.Add("@MediumOrderNo", (TransID + SuccTime).Trim()); dyParams.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output, 20); PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams, CommandType.StoredProcedure); int presult = dyParams.Get <int>("@outStatus"); SysLogHelper.WriteTraceLog("宝付支付交易成功", string.Concat("签名:", Md5Sign.ToLower(), "签名方式:", "MD5", "我方处理状态:", presult.ToString().Trim(), "宝付处理状态:", Result, "支付单号:", TransID)); AccountRechareInfo accountRechare = getAccountRechare(TransID); if (accountRechare != null) { strSQL = "select count(1) from AccountRechare where UserId=@userId and Status=2 and [type] in(2, 3, 4, 6, 8, 12)"; dyParams = new DynamicParameters(); dyParams.Add("@userId", accountRechare.UserId); int iCount = PublicConn.QuerySingleWrite <int>(strSQL, ref dyParams); if (iCount > 0) { TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(accountRechare.UserId, (int)ConstString.UserGrowthType.FirstReCharge, null, 0); } UserBasicInfoInfo userBasicInfo = new UserBLL().GetUserBasicInfoModelById(accountRechare.UserId); if (userBasicInfo != null) { var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0"); if (isNewSmsRequest == "0") { var parameters = new Dictionary <string, object>(); parameters.Add("CurrentDate", DateTime.Now); //parameters.Add("RechargeMoney", FactMoney); parameters.Add("RechargeMoney", decimal.Divide(decimal.Parse(FactMoney), 100));//宝付充值以分为单位 parameters.Add("User", userBasicInfo); parameters.Add("Host", GlobalUtils.WebURL); var msgSender = new BusinessDll.MessageSend(); msgSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters, mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id); } else { SmsRequest rechargeSuccessSmsRequest = new SmsRequest(); rechargeSuccessSmsRequest.EventCode = MsgTemplatesType.RechargeSuccess; rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc; rechargeSuccessSmsRequest.UserId = userBasicInfo.Id; rechargeSuccessSmsRequest.EmailAddress = userBasicInfo.Email; rechargeSuccessSmsRequest.Mobile = userBasicInfo.TelNo; rechargeSuccessSmsRequest.Parameters = new Dictionary <string, object>(); rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", FactMoney); string errorMessage = string.Empty; SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage); } } } Response.Write("OK"); Response.End(); } //if (Result == "0") //{ // db.p_OnLineRechargeHandler(1, TransID.Trim(), decimal.Divide(decimal.Parse(FactMoney), 100), (TransID + SuccTime).Trim(), outStatus); // int presult = int.Parse(outStatus.Value.ToString()); // NetLog.WriteLoginHandler("宝付支付交易失败", string.Concat("签名:", Md5Sign.ToLower(), "签名方式:", "MD5", "我方处理状态:", presult.ToString().Trim(), "宝付处理状态:", Result, "支付单号:", TransID)); // Response.Write("Fail"); //} } else { SysLogHelper.WriteTraceLog("宝付验签失败", string.Concat("宝付返回签名:", Md5Sign.ToLower(), "等待验签", Md5Encrypt(_WaitSign).ToLower(), "签名方式:", "MD5", "宝付处理状态:", Result)); Response.Write("校验失败"); Response.End(); } } catch (Exception ex) { SysLogHelper.WriteErrorLog("宝付支付失败", "错误详细信息:" + ex.Message + "|" + ex.StackTrace); Response.Write("Fail"); Response.End(); } }