/// <summary> /// /// </summary> private void Process() { var szxresult = new ChargeCardDirentResult { R0_Cmd = "ChargeCardDirect", R6_Order = DirectCardInfo.p2_Order }; string rCode = viviapi.SysInterface.Card.YeePay.ChargeCardDirect.CheckParameter(DirectCardInfo); if (rCode != "1") { #region 记录日志 if (this.DebuglogOpen) { var debugInfo = new viviapi.Model.Sys.debuginfo { userid = DirectCardInfo.UserId, addtime = DateTime.Now, bugtype = viviapi.Model.Sys.debugtypeenum.卡类订单, errorcode = rCode, errorinfo = DirectCardInfo.Msg, userorder = DirectCardInfo.p2_Order, url = Request.RawUrl, detail = "" }; viviapi.BLL.Sys.Debuglog.Insert(debugInfo); } #endregion } else { string sysOrderNo = Factory.Instance.GenerateOrderId(OrderPrefix); bool initTotal = true; if (DirectCardInfo.CardNum > 1) { initTotal = InitTotalOrder(sysOrderNo, DirectCardInfo); } //成功提交个数 int succSummit = 0; if (initTotal) { for (int i = 0; i < DirectCardInfo.CardNum; i++) { #region 明细项 var item = new ChargeCardDirectDetails { TypeId = DirectCardInfo.TypeId, CardType = DirectCardInfo.CardType, UserId = DirectCardInfo.UserId, ManageId = DirectCardInfo.ManageId, APIkey = DirectCardInfo.APIkey, CardNo = DirectCardInfo.CardNos[i], CardPwd = DirectCardInfo.CardPwds[i], Refervalue = DirectCardInfo.CardFaceValues[i], SerialNumber = i.ToString("00") }; if (DirectCardInfo.CardNum > 1) { item.UserOrderNo = DirectCardInfo.p2_Order + "_" + item.SerialNumber; item.SysOrderNo = sysOrderNo + "_" + item.SerialNumber; } else { item.UserOrderNo = DirectCardInfo.p2_Order; item.SysOrderNo = sysOrderNo; } string chk = viviapi.SysInterface.Card.YeePay.ChargeCardDirect.CheckChargeCardDirectDetails(item); if (chk == "0") { var orderInfo = InitOrder(DirectCardInfo.CardNum, sysOrderNo, item.SysOrderNo, item); if (orderInfo == null) { rCode = "-1"; DirectCardInfo.Msg = "系统故障,请联系商务"; break; } else { var suppResponse = new CardSynchCallBack(); if (item.ProcessMode == 1) { #region 通过接口 var supp = (SupplierCode)item.SupplierId; suppResponse = OrderCardUtils.SynchSubmit(supp , item.SysOrderNo , item.TypeId , item.CardNo , item.CardPwd , decimal.ToInt32(item.Refervalue) , string.Empty , 1); if (suppResponse.SummitStatus == 0) { item.CardStatus = "-1"; string viewMsg = suppResponse.SuppErrorMsg; var response = new CardOrderSupplierResponse() { Sync = 1, SupplierId = item.SupplierId, SuppTransNo = suppResponse.SuppTransNo, SysOrderNo = item.SysOrderNo, OrderAmt = 0M, SuppAmt = 0M, OrderStatus = 4, SuppErrorCode = suppResponse.SuppErrorCode, Opstate = rCode, SuppErrorMsg = suppResponse.SuppErrorMsg, ViewMsg = viewMsg, Method = 1 }; OrderCardUtils.FinishForSync(orderInfo, response); } else { succSummit++; item.CardStatus = "0"; item.Msg = "提卡成功,等待处理结果"; } #endregion } else { succSummit++; #region 系统自已处理 item.SupplierId = 0; suppResponse.SuppTransNo = DateTime.Now.ToString("yyyyMMddHHmmssfff"); suppResponse.OrderStatus = 2; suppResponse.SuppErrorMsg = "支付成功"; suppResponse.SuppErrorCode = "0"; suppResponse.SuccAmt = decimal.ToInt32(item.Refervalue); #endregion } if (item.ProcessMode == 2 || suppResponse.OrderStatus == 2) { #region 系统自处理 var resInfo = new CardProcessResultInfo { supplierId = 0, orderid = item.SysOrderNo, supplierOrder = suppResponse.SuppTransNo, status = 2, opstate = "0", msg = suppResponse.SuppErrorMsg, userViewMsg = suppResponse.SuppErrorMsg, tranAMT = suppResponse.SuccAmt, suppAmt = 0M, errtype = "0", method = item.ProcessMode, count = 0 }; item.Msg = "提卡成功,等待处理结果"; var process = new SystemProcessCard(); var tmr = new System.Threading.Timer(process.Process, resInfo, 1000, 0); resInfo.tmr = tmr; #endregion } } } #endregion } if (succSummit == 0) { rCode = "-1"; DirectCardInfo.Msg = "未有成功提卡记录"; } else { rCode = "1"; DirectCardInfo.Msg = "接收成功,等待结果"; } } else { rCode = "-1"; DirectCardInfo.Msg = "系统繁忙,请稍后再试"; } } szxresult.R1_Code = rCode; szxresult.Rq_ReturnMsg = DirectCardInfo.Msg; string text = viviapi.SysInterface.Card.YeePay.ChargeCardDirect.GetResponseText(szxresult, ""); Response.Write(text); }
/// <summary> /// /// </summary> private void Process(HttpContext context) { var apiCardInfo = new CardInfo(context); string opstate = Utility.CheckParameter(apiCardInfo); if (opstate == "0") { string sysOrderId = Factory.Instance.GenerateOrderId(OrderPrefix); var orderInfo = InitOrder(sysOrderId, apiCardInfo); if (orderInfo == null) { apiCardInfo.Msg = "初始化订单失败,系统繁忙"; opstate = "-999"; } else { var suppResponse = new CardSynchCallBack(); if (apiCardInfo.ProcessMode == 1) { #region 通过接口 var supp = (SupplierCode)apiCardInfo.SupplierId; suppResponse = OrderCardUtils.SynchSubmit(supp , sysOrderId , apiCardInfo.TypeId , apiCardInfo.CardNo , apiCardInfo.CardPwd , apiCardInfo.OrderAmt , string.Empty , 1); if (suppResponse.SummitStatus == 0) { opstate = Utility.ConvertSynchronousErrorCode(supp, suppResponse.SuppErrorCode); string viewMsg = Utility.GetMessageByCode(opstate); var response = new CardOrderSupplierResponse() { Sync = 1, SupplierId = apiCardInfo.SupplierId, SuppTransNo = suppResponse.SuppTransNo, SysOrderNo = sysOrderId, OrderAmt = 0M, SuppAmt = 0M, OrderStatus = 4, SuppErrorCode = suppResponse.SuppErrorCode, SuppErrorMsg = suppResponse.SuppErrorMsg, Opstate = opstate, ViewMsg = viewMsg, Method = 1 }; OrderCardUtils.FinishForSync(orderInfo, response); } else { apiCardInfo.Msg = "提卡成功,等待处理结果"; } #endregion } else { #region 系统自已处理 apiCardInfo.SupplierId = 0; suppResponse.SuppTransNo = DateTime.Now.ToString("yyyyMMddHHmmssfff"); suppResponse.OrderStatus = 2; suppResponse.SuppErrorMsg = "支付成功"; suppResponse.SuppErrorCode = "0"; suppResponse.SuccAmt = apiCardInfo.OrderAmt; #endregion } if (apiCardInfo.ProcessMode == 2 || suppResponse.OrderStatus == 2) { #region 系统自处理 var resInfo = new CardProcessResultInfo { supplierId = 0, orderid = sysOrderId, supplierOrder = suppResponse.SuppTransNo, status = 2, opstate = "0", msg = suppResponse.SuppErrorMsg, userViewMsg = suppResponse.SuppErrorMsg, tranAMT = suppResponse.SuccAmt, suppAmt = 0M, errtype = suppResponse.SuppErrorCode, method = apiCardInfo.ProcessMode, count = 0 }; apiCardInfo.Msg = "提卡成功,等待处理结果"; var process = new SystemProcessCard(); var tmr = new System.Threading.Timer(process.Process, resInfo, 1000, 0); resInfo.tmr = tmr; #endregion } } } if (opstate != "0") { #region 记录日志 if (this.DebuglogOpen) { var debugInfo = new viviapi.Model.Sys.debuginfo { userid = apiCardInfo.UserId, addtime = DateTime.Now, bugtype = viviapi.Model.Sys.debugtypeenum.卡类订单, errorcode = opstate, errorinfo = apiCardInfo.Msg, userorder = apiCardInfo.orderid, url = context.Request.RawUrl, detail = "" }; Debuglog.Insert(debugInfo); } #endregion } string retcode = string.Format("opstate={0}", opstate); context.Response.ContentType = "text/plain"; context.Response.Write(retcode); }
protected void PostCardToSupplier(object _context) { var context = (HttpContext)_context; string opstate = "1"; CardInfoList cardInfoList = new CardInfoList(context); foreach (CardInfo apiCardInfo in cardInfoList) { opstate = viviapi.SysInterface.Card.MyAPI.Utility.CheckParameter(apiCardInfo, context); //if (opstate == "1") //{ string sysOrderId = Factory.Instance.GenerateOrderId(OrderPrefix); var orderInfo = InitOrder(context, sysOrderId, apiCardInfo); if (orderInfo == null) { apiCardInfo.Msg = "初始化订单失败,系统繁忙"; opstate = "13"; } else { var suppResponse = new CardSynchCallBack(); if (apiCardInfo.ProcessMode == 1) { #region 通过接口 var supp = (SupplierCode)apiCardInfo.SupplierId; suppResponse = OrderCardUtils.SynchSubmit(supp , sysOrderId , apiCardInfo.TypeId , apiCardInfo.CardNo , apiCardInfo.CardPwd , apiCardInfo.OrderAmt , string.Empty , 1); //订单没有提交成功(提交到接口商没有成功) if (suppResponse.SummitStatus == 0) { //错误代码 opstate = viviapi.SysInterface.Card.MyAPI.Utility.ConvertSynchronousErrorCode(supp, suppResponse.SuppErrorCode); //错误信息 string viewMsg = viviapi.SysInterface.Card.MyAPI.Utility.GetMessageByCode(opstate); var response = new CardOrderSupplierResponse() { Sync = 1, SupplierId = apiCardInfo.SupplierId, SuppTransNo = suppResponse.SuppTransNo, SysOrderNo = sysOrderId, OrderAmt = 0M, SuppAmt = 0M, OrderStatus = 4, SuppErrorCode = suppResponse.SuppErrorCode, SuppErrorMsg = string.IsNullOrEmpty(suppResponse.SuppErrorMsg) ? suppResponse.Message : suppResponse.SuppErrorMsg, Opstate = opstate, ViewMsg = viewMsg, Method = 1 }; OrderCardUtils.FinishForSync(orderInfo, response); } else { apiCardInfo.Msg = "提卡成功,等待处理结果"; } #endregion } else { #region 系统自已处理 apiCardInfo.SupplierId = 0; suppResponse.SuppTransNo = DateTime.Now.ToString("yyyyMMddHHmmssfff"); suppResponse.OrderStatus = 2; suppResponse.SuppErrorMsg = "支付成功"; suppResponse.SuppErrorCode = "0"; suppResponse.SuccAmt = apiCardInfo.OrderAmt; #endregion } if (apiCardInfo.ProcessMode == 2 || suppResponse.OrderStatus == 2) { #region 系统自处理 var resInfo = new CardProcessResultInfo { supplierId = 0, orderid = sysOrderId, status = 2, opstate = "0", supplierOrder = suppResponse.SuppTransNo, msg = suppResponse.SuppErrorMsg, userViewMsg = suppResponse.SuppErrorMsg, tranAMT = suppResponse.SuccAmt, suppAmt = 0M, errtype = "0", method = apiCardInfo.ProcessMode, count = 0 }; apiCardInfo.Msg = "提卡成功,等待处理结果"; var process = new SystemProcessCard(); var tmr = new System.Threading.Timer(process.Process, resInfo, 1000, 0); resInfo.tmr = tmr; #endregion } } // } } }
/// <summary> /// /// </summary> private void Process() { var szxresult = new SZXResult { R0_Cmd = "AnnulCard", R2_TrxId = Factory.Instance.GenerateOrderId(OrderPrefix), R6_Order = AnnulCardInfo.p2_Order }; string rCode = viviapi.SysInterface.Card.YeePay.AnnulCard.CheckParameter(AnnulCardInfo); if (rCode != "1") { #region 记录日志 if (this.DebuglogOpen) { var debugInfo = new viviapi.Model.Sys.debuginfo { userid = AnnulCardInfo.UserId, addtime = DateTime.Now, bugtype = viviapi.Model.Sys.debugtypeenum.卡类订单, errorcode = rCode, errorinfo = AnnulCardInfo.Msg, userorder = AnnulCardInfo.p2_Order, url = Request.RawUrl, detail = "" }; viviapi.BLL.Sys.Debuglog.Insert(debugInfo); } #endregion } if (rCode == "1") { var orderInfo = InitOrder(szxresult.R2_TrxId, AnnulCardInfo); if (orderInfo == null) { rCode = "-1"; } else { var suppResponse = new CardSynchCallBack(); if (AnnulCardInfo.ProcessMode == 1) { #region 通过接口 var supp = (SupplierCode)AnnulCardInfo.SupplierId; suppResponse = OrderCardUtils.SynchSubmit(supp , szxresult.R2_TrxId , AnnulCardInfo.TypeId , AnnulCardInfo.CardNo , AnnulCardInfo.CardPwd , AnnulCardInfo.OrderAmt , string.Empty , 1); if (suppResponse.SummitStatus == 0) { rCode = "-1"; string viewMsg = suppResponse.SuppErrorMsg; var response = new CardOrderSupplierResponse() { Sync = 1, SupplierId = AnnulCardInfo.SupplierId, SuppTransNo = suppResponse.SuppTransNo, SysOrderNo = szxresult.R2_TrxId, OrderAmt = 0M, SuppAmt = 0M, OrderStatus = 4, SuppErrorCode = suppResponse.SuppErrorCode, Opstate = rCode, SuppErrorMsg = suppResponse.SuppErrorMsg, ViewMsg = viewMsg, Method = 1 }; OrderCardUtils.FinishForSync(orderInfo, response); } else { AnnulCardInfo.Msg = "提卡成功,等待处理结果"; } #endregion } else { #region 系统自已处理 AnnulCardInfo.SupplierId = 0; suppResponse.SuppTransNo = DateTime.Now.ToString("yyyyMMddHHmmssfff"); suppResponse.OrderStatus = 2; suppResponse.SuppErrorMsg = "支付成功"; suppResponse.SuppErrorCode = "0"; suppResponse.SuccAmt = AnnulCardInfo.OrderAmt; #endregion } if (AnnulCardInfo.ProcessMode == 2 || suppResponse.OrderStatus == 2) { #region 系统自处理 var resInfo = new CardProcessResultInfo { supplierId = 0, orderid = szxresult.R2_TrxId, supplierOrder = suppResponse.SuppTransNo, status = 2, opstate = "0", msg = suppResponse.SuppErrorMsg, userViewMsg = suppResponse.SuppErrorMsg, tranAMT = suppResponse.SuccAmt, suppAmt = 0M, errtype = "0", method = AnnulCardInfo.ProcessMode, count = 0 }; AnnulCardInfo.Msg = "提卡成功,等待处理结果"; var process = new SystemProcessCard(); var tmr = new System.Threading.Timer(process.Process, resInfo, 1000, 0); resInfo.tmr = tmr; #endregion } } } szxresult.R1_Code = rCode; szxresult.Rq_ReturnMsg = AnnulCardInfo.Msg; string text = viviapi.SysInterface.Card.YeePay.AnnulCard.GetResponseText(szxresult, ""); Response.Write(text); }
/// <summary> /// /// </summary> /// <param name="stateInfo"></param> public void Process(Object stateInfo) { CardProcessResultInfo procRes = (CardProcessResultInfo)stateInfo; BLL.OrderCard bll = new viviapi.BLL.OrderCard(); var response = new CardOrderSupplierResponse() { SupplierId = procRes.supplierId, SuppTransNo = procRes.supplierOrder, SysOrderNo = procRes.orderid, OrderAmt = procRes.tranAMT, SuppAmt = 0M, OrderStatus = procRes.status, SuppErrorCode = procRes.errtype, Opstate = procRes.opstate, SuppErrorMsg = procRes.msg, ViewMsg = procRes.userViewMsg, Method = procRes.method }; OrderCardUtils.Finish(response); //bll.ReceiveSuppResult( // procRes.supplierId // , procRes.orderid // , procRes.supplierOrder // , procRes.status // , procRes.opstate // , procRes.msg // , procRes.userViewMsg // , procRes.tranAMT // , procRes.suppAmt // , procRes.errtype // , procRes.method); procRes.count++; bool timerflag = false; if (procRes.tmr != null) { switch (procRes.count) { case 1: timerflag = (procRes.tmr).Change(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(200)); break; case 2: timerflag = (procRes.tmr).Change(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(200)); //1分钟 break; case 3: timerflag = (procRes.tmr).Change(TimeSpan.FromMinutes(2), TimeSpan.FromSeconds(200)); //2分钟 break; } } if (procRes != null) { if (procRes.count >= 4) { if (procRes != null) { procRes.tmr.Dispose(); procRes.tmr = null; } } } }