Esempio n. 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int     SuppId      = int.Parse(this.txtSuppId.Text);
            string  SuppTransNo = "test_sup" + DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
            string  SysOrderNo  = txtSysOrderId.Text;
            decimal TranAmt     = decimal.Parse(this.txtTranAmt.Text);

            var response = new CardOrderSupplierResponse()
            {
                SupplierId    = SuppId,
                SuppTransNo   = SuppTransNo,
                SysOrderNo    = SysOrderNo,
                OrderAmt      = TranAmt,
                SuppAmt       = 0M,
                OrderStatus   = 2,
                SuppErrorCode = txterrCode.Text.Trim(),
                Opstate       = "",
                SuppErrorMsg  = txterrCode.Text.Trim(),
                ViewMsg       = txterrCode.Text.Trim(),
                Method        = 1
            };


            OrderCardUtils.SuppNotify(response, "");
        }
Esempio n. 2
0
        /// <summary>
        /// 更新订单状态
        /// </summary>
        /// <param name="orderInfo"></param>
        /// <param name="response"></param>
        public static bool FinishForSync(OrderCardInfo orderInfo, CardOrderSupplierResponse response)
        {
            if (orderInfo == null)
            {
                return(false);
            }

            try
            {
                byte continueSubmit = 0;

                int seq = 1;

                bool processFlag = true;

                UpdateOrder(seq, orderInfo, response);

                Cache.WebCache.GetCacheService().RemoveObject(response.SysOrderNo);

                return(true);
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);

                return(false);
            }
        }
Esempio n. 3
0
        public void Notify()
        {
            HttpRequest request         = HttpContext.Current.Request;
            string      orderId         = request.QueryString["orderid"];
            string      opstate         = request.QueryString["opstate"];
            string      ovalue          = request.QueryString["ovalue"];
            string      sign            = request.QueryString["sign"];
            string      supplierOrderId = request.QueryString["sysorderid"];
            string      str6            = request.QueryString["completiontime"];
            string      attach          = request.QueryString["attach"];
            string      msg             = request.QueryString["msg"];
            string      str8            = Cryptography.MD5(string.Format("orderid={0}&opstate={1}&ovalue={2}{3}", new object[] { orderId, opstate, ovalue, base.SuppKey }));

            try
            {
                if (str8 == sign)
                {
                    string opstate1 = "-1";
                    int    status   = 4;
                    if (opstate.ToLower() == "0")
                    {
                        opstate1 = "0";
                        status   = 2;
                    }
                    string viewMsg = "成功";

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = suppId,
                        SuppTransNo   = supplierOrderId,
                        SysOrderNo    = orderId,
                        OrderAmt      = decimal.Parse(ovalue),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = opstate,
                        Opstate       = opstate1,
                        SuppErrorMsg  = viewMsg,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };


                    OrderBankUtils.SuppNotify(suppId, orderId, supplierOrderId, status, opstate, "", decimal.Parse(ovalue), 0M, "opstate=0", "opstate=-1");

                    HttpContext.Current.Response.Write("opstate=0");
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 更新订单状态,并返回是否成功的标志码
        /// </summary>
        /// <param name="response"></param>
        /// <param name="succflag"></param>
        public static void SuppNotify(CardOrderSupplierResponse response, string succflag)
        {
            bool execResult = Finish(response);

            if (execResult == true)
            {
                HttpContext.Current.Response.Write(succflag);
            }
            else
            {
                HttpContext.Current.Response.Write("fail");
            }
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                if (OrderCard.status == 1)
                {
                    bool    result  = false;
                    int     SuppId  = Convert.ToInt32(this.ddlSupp.SelectedValue);
                    decimal TranAmt = decimal.Parse(this.txtOrderAmt.Text.Trim());
                    if (TranAmt <= 0M)
                    {
                        ShowMessageBox("金额不能为0");
                        return;
                    }
                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = "Sys" + DateTime.Now.Ticks.ToString(),
                        SysOrderNo    = OrderCard.orderid,
                        OrderAmt      = TranAmt,
                        SuppAmt       = 0M,
                        OrderStatus   = int.Parse(rblstatus.SelectedValue),
                        SuppErrorCode = txtCode.Text,
                        Opstate       = "",
                        SuppErrorMsg  = txtMsg.Text,
                        ViewMsg       = "",
                        Method        = 1
                    };


                    OrderCardUtils.SuppNotify(response, "");

                    ShowMessageBox("操作成功");
                }
                else
                {
                    ShowMessageBox("订单状态不正确");
                }
            }
        }
Esempio n. 6
0
        public bool Finish(QueryResponse response)
        {
            bool success = false;

            if (response.State != "0")
            {
                int    status  = response.State == "1" ? 2 : 4;
                string opstate = "0";
                string viewMsg = "支付成功";
                if (status == 4)
                {
                    opstate = "99";
                    viewMsg = "其它错误";
                }

                var resp = new CardOrderSupplierResponse()
                {
                    SupplierId    = SuppId,
                    SuppTransNo   = response.Sd51No,
                    SysOrderNo    = response.SysOrderNo,
                    OrderAmt      = decimal.Parse(response.Ordermoney),
                    SuppAmt       = 0M,
                    OrderStatus   = status,
                    SuppErrorCode = response.State,
                    SuppErrorMsg  = viewMsg,
                    Opstate       = opstate,
                    ViewMsg       = viewMsg,
                    Method        = 1
                };

                OrderCardUtils.Finish(resp);

                success = true;
            }

            return(success);
        }
Esempio n. 7
0
        public void Process(Object stateInfo)
        {
            var procRes = (CardProcessResultInfo)stateInfo;

            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);

            procRes.tmr.Dispose();
            procRes.tmr = null;
        }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
        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
                    }
                }
                // }
            }
        }
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="callback"></param>
        public void Finish(orderQueryResponse callback)
        {
            if (callback != null)
            {
                string opstate = "";
                int    status  = 4;

                string transStatus = callback.transStatus;
                string errCode     = callback.returnInfo.errorCode;
                string errorMsg    = callback.returnInfo.errorMsg;
                if (errCode == "B0532006")
                {
                    return;
                }

                errCode = "";
                string errMsg = "";

                if (!string.IsNullOrEmpty(errorMsg))
                {
                    var ja = (Newtonsoft.Json.Linq.JArray)JsonConvert.DeserializeObject(errorMsg);
                    foreach (Newtonsoft.Json.Linq.JObject item in ja)
                    {
                        if (item["errorCode"] != null)
                        {
                            errCode = item["errorCode"].ToString().Replace("\"", "");
                        }
                        if (item["errorMsg"] != null)
                        {
                            errMsg = item["errorMsg"].ToString().Replace("\"", "");
                        }
                    }
                }

                if (errCode == "F1032")
                {
                    return;
                }

                switch (transStatus)
                {
                case "":
                case "00":
                    opstate = "";
                    break;

                case "01":
                    errCode = "0";
                    opstate = "0";
                    status  = 2;
                    break;

                case "02":
                case "03":
                    opstate = "-1";
                    status  = 4;
                    break;
                }

                if (!string.IsNullOrEmpty(opstate))
                {
                    string viewMsg  = errMsg;
                    var    response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = callback.transNo,
                        SysOrderNo    = callback.orderNo,
                        OrderAmt      = decimal.Parse(callback.transAmoumt),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = errCode,
                        Opstate       = opstate,
                        SuppErrorMsg  = callback.returnInfo.errorMsg,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };

                    OrderCardUtils.Finish(response);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            try
            {
                int     status   = 0;
                string  msg      = "";
                string  viewMsg  = "";
                string  opstate  = "";
                decimal orderAmt = 0M;

                string canresubmit     = HttpContext.Current.Request.Form["canresubmit"];
                string customerorderid = HttpContext.Current.Request.Form["customerorderid"];
                string remark          = HttpContext.Current.Request.Form["remark"];
                string settleparvalue  = HttpContext.Current.Request.Form["settleparvalue"];
                string usestatus       = HttpContext.Current.Request.Form["usestatus"];
                string sign            = HttpContext.Current.Request.Form["sign"];


                string plain = string.Format("canresubmit={5}customerorderid={0}remark={1}settleparvalue={2}usestatus={3}{4}"
                                             , customerorderid
                                             , remark
                                             , settleparvalue
                                             , usestatus
                                             , suppKey
                                             , canresubmit
                                             );
                log("Notify plain " + plain);

                string localsign = viviLib.Security.Cryptography.MD5(plain, "utf-8");

                log("Notify localsign " + localsign);

                log("Notify sign " + sign);

                if (String.Equals(localsign, sign, StringComparison.CurrentCultureIgnoreCase))
                {
                    switch (usestatus.ToLower())
                    {
                    case "4":
                        orderAmt = decimal.Parse(settleparvalue);
                        status   = 2;
                        opstate  = "0";
                        msg      = "支付成功";
                        viewMsg  = msg;
                        break;

                    case "1":
                    case "5":
                        status  = 4;
                        opstate = "99";
                        msg     = remark;
                        viewMsg = SellCard20.GetMsgToUserView(opstate);
                        break;
                    }

                    if (status > 0)
                    {
                        var response = new CardOrderSupplierResponse()
                        {
                            SupplierId    = SuppId,
                            SuppTransNo   = "",
                            SysOrderNo    = customerorderid,
                            OrderAmt      = orderAmt,
                            SuppAmt       = 0M,
                            OrderStatus   = status,
                            SuppErrorCode = "99",
                            Opstate       = opstate,
                            SuppErrorMsg  = msg,
                            ViewMsg       = viewMsg,
                            Method        = 1
                        };

                        string backXML = string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
<root>   
<ret>
<status>{0}</status>
</ret>
</root>", "true");

                        OrderCardUtils.SuppNotify(response, backXML);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                HttpContext.Current.Response.Write("error");
                //HttpContext.Current.Response.End();
            }
        }
Esempio n. 12
0
        /// <summary>
        ///
        /// </summary>
        public void CardNotify()
        {
            HttpRequest req = HttpContext.Current.Request;

            AsynsRetLogger(req.RawUrl);

            if (req.Form.Count > 0)
            {
                string data = WebClientHelper.FormatRequestData(req.Form, System.Text.Encoding.Default);
                AsynsRetLogger(data);
            }

            String state      = req["state"].Trim();                                                                                                  //商户在51支付网关上的订单状态,0为失败,1为成功
            String customerid = req["customerid"].Trim();                                                                                             //商户在51支付网关上的ID
            String sd51No     = req["sd51no"].Trim();                                                                                                 //51支付订单流水号
            String sdcustomno = req["sdcustomno"].Trim();                                                                                             //商户提交的订单流水号
            String ordermoney = req["ordermoney"].Trim();                                                                                             //商户订单金额,注意可能与商户时提交不一致,51支付结果是以卡的面值来结算的
            String mark       = req["mark"].Trim();                                                                                                   //商户自定义原样返回
            String sign       = req["sign"].Trim();                                                                                                   //51支付提交过来的MD5签名
            String des        = req["des"].Trim();                                                                                                    //
            String signText   = "customerid=" + customerid + "&sd51no=" + sd51No + "&sdcustomno=" + sdcustomno + "&mark=" + mark + "&key=" + SuppKey; //'生成MD5签名
            String localSign  = Cryptography.MD5(signText);

            try
            {
                if (localSign == sign)
                {
                    int    status  = state == "1" ? 2: 4;
                    string opstate = "0";
                    string viewMsg = "支付成功";
                    if (status == 4)
                    {
                        opstate = "99";
                        viewMsg = "其它错误";
                    }

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = sd51No,
                        SysOrderNo    = sdcustomno,
                        OrderAmt      = decimal.Parse(ordermoney),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = state,
                        SuppErrorMsg  = des,
                        Opstate       = opstate,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, Succflag);
                }
                else
                {
                    HttpContext.Current.Response.Write(signText);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        public void CardNotify()
        {
            HttpRequest req         = HttpContext.Current.Request;
            string      _orderid    = req.QueryString["orderid"];
            string      _opstate    = req.QueryString["opstate"];
            string      _ovalue     = req.QueryString["ovalue"];
            string      _sign       = req.QueryString["sign"];
            string      _sysorderid = req.QueryString["sysorderid"];
            string      _systime    = req.QueryString["systime"]; //

            //'生成MD5签名
            String plain     = string.Format("orderid={0}&opstate={1}&ovalue={2}{3}", _orderid, _opstate, _ovalue, SuppKey);
            String localSign = viviLib.Security.Cryptography.MD5(plain);

            try
            {
                if (localSign == _sign)
                {
                    string opstate = "-1";
                    int    status  = 4;

                    if (_opstate.ToLower() == "0")
                    {
                        opstate = "0";
                        status  = 2;
                    }

                    BLL.OrderCard bll = new viviapi.BLL.OrderCard();

                    string suppmsg = GetMsgInfo("opstate=" + opstate, _ovalue);
                    string viewMsg = suppmsg;

                    //bll.ReceiveSuppResult(suppId
                    //    , _orderid
                    //    , _sysorderid
                    //    , status
                    //    , opstate
                    //    , suppmsg
                    //    , viewMsg
                    //    , decimal.Parse(_ovalue)
                    //    , 0M
                    //    , opstate
                    //    , 1);

                    //HttpContext.Current.Response.Write("opstate=0");

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = _sysorderid,
                        SysOrderNo    = _orderid,
                        OrderAmt      = decimal.Parse(_ovalue),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = opstate,
                        Opstate       = opstate,
                        SuppErrorMsg  = suppmsg,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, succflag);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);
            }
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="seq"></param>
        /// <param name="orderInfo"></param>
        /// <param name="response"></param>
        public static OrderCardInfo UpdateOrder(int seq, OrderCardInfo orderInfo, CardOrderSupplierResponse response)
        {
            if (orderInfo == null)
            {
                return(null);
            }

            if (response.Method == 1)
            {
                #region 接口处理
                orderInfo.supplierId = response.SupplierId;

                UserInfo userInfo
                    = BLL.User.Factory.GetCacheUserBaseInfo(orderInfo.userid);

                orderInfo.method        = 1;
                orderInfo.cardversion   = userInfo.cardversion;
                orderInfo.orderid       = response.SysOrderNo;
                orderInfo.status        = response.OrderStatus;
                orderInfo.opstate       = response.Opstate;
                orderInfo.msg           = response.SuppErrorMsg;
                orderInfo.supplierOrder = "";
                if (!string.IsNullOrEmpty(response.SuppTransNo))
                {
                    orderInfo.supplierOrder = response.SuppTransNo;
                }

                orderInfo.errtype       = response.SuppErrorCode;
                orderInfo.withhold_type = 0;
                orderInfo.withholdAmt   = 0M;
                orderInfo.faceValue     = response.OrderAmt;
                orderInfo.userViewMsg   = response.ViewMsg;

                #region 是否扣单

                if (true && BLL.Sys.TransactionSettings.OpenDeduct && response.OrderStatus == 2)
                {
                    if (new Random(Guid.NewGuid().GetHashCode()).Next(1, 1000) <= userInfo.CPSDrate)
                    {
                        orderInfo.status = 8;
                    }
                }

                #endregion

                orderInfo.realvalue    = response.OrderAmt;
                orderInfo.supplierId   = response.SupplierId;
                orderInfo.completetime = DateTime.Now;

                orderInfo.payRate      = 0M;
                orderInfo.payAmt       = 0M;
                orderInfo.supplierRate = 0M;
                orderInfo.supplierAmt  = 0M;
                orderInfo.promRate     = 0M;
                orderInfo.promAmt      = 0M;
                orderInfo.profits      = 0M;

                if (response.OrderStatus == 2)
                {
                    #region 商户费率

                    if (orderInfo.payRate <= 0M)
                    {
                        if (orderInfo.ordertype == 8)
                        {
                            orderInfo.payRate = BLL.Channel.Channelsupplier.GetPayRate(orderInfo.typeId,
                                                                                       orderInfo.supplierId);
                        }
                        if (orderInfo.payRate <= 0M)
                        {
                            orderInfo.payRate = BLL.Finance.PayRate.Instance.GetUserPayRate(orderInfo.userid,
                                                                                            orderInfo.typeId);
                        }
                    }
                    orderInfo.payAmt = orderInfo.payRate * response.OrderAmt;

                    #endregion

                    #region 供应商给平台的费率

                    if (response.SuppAmt > 0)
                    {
                        orderInfo.supplierRate = response.SuppAmt / response.OrderAmt;
                        orderInfo.supplierAmt  = response.SuppAmt;
                    }
                    else
                    {
                        decimal suppRate = viviapi.BLL.Finance.PayRate.Instance.GetSupplierPayRate(response.SupplierId,
                                                                                                   orderInfo.typeId);
                        orderInfo.supplierRate = suppRate;
                        orderInfo.supplierAmt  = suppRate * response.OrderAmt;
                    }

                    #endregion

                    #region 代理

                    //代理
                    if (orderInfo.agentId > 0)
                    {
                        //代理费率
                        orderInfo.promRate = BLL.Finance.PayRate.Instance.GetUserPayRate(orderInfo.agentId,
                                                                                         orderInfo.typeId);
                        //代理金额
                        orderInfo.promAmt = (orderInfo.promRate - orderInfo.payRate) * response.OrderAmt;

                        if (orderInfo.promAmt < 0)
                        {
                            orderInfo.promAmt = 0;
                        }
                    }
                    orderInfo.profits = orderInfo.supplierAmt - orderInfo.payAmt - orderInfo.promAmt;

                    #endregion

                    if (seq == 1)
                    {
                        if (orderInfo.cardversion == 1)
                        {
                            #region 扣卡面值

                            if (orderInfo.refervalue < response.OrderAmt) //提交金额小于实际面额
                            {
                                #region 小提大

                                orderInfo.realvalue     = orderInfo.refervalue;//充值金额为实际提交面额
                                orderInfo.withhold_type = 1;
                                orderInfo.withholdAmt   = response.OrderAmt - orderInfo.refervalue;

                                orderInfo.payAmt  = orderInfo.payRate * orderInfo.refervalue;
                                orderInfo.promAmt = (orderInfo.promRate - orderInfo.payRate) * orderInfo.refervalue;

                                orderInfo.supplierAmt = orderInfo.supplierRate * orderInfo.refervalue;
                                orderInfo.profits     = orderInfo.supplierAmt - orderInfo.payAmt - orderInfo.promAmt;

                                if (orderInfo.promAmt < 0)
                                {
                                    orderInfo.promAmt = 0;
                                }

                                #endregion
                            }
                            else if (orderInfo.refervalue > response.OrderAmt)
                            {
                                #region 大提小,用户提交金额大于卡面值时

                                orderInfo.withhold_type = 2;

                                //orderInfo.realvalue = orderInfo.payRate * response.OrderAmt;

                                orderInfo.withholdAmt = response.OrderAmt;

                                //orderInfo.payAmt = orderInfo.payRate * response.OrderAmt;
                                //orderInfo.promAmt = (orderInfo.promRate - orderInfo.payRate) * response.OrderAmt;

                                //orderInfo.supplierAmt = orderInfo.supplierRate * response.OrderAmt;
                                //orderInfo.profits = orderInfo.supplierAmt - orderInfo.payAmt - orderInfo.promAmt;


                                //以下为原来系统的
                                //orderInfo.status = 4;
                                //orderInfo.errtype = "10";
                                //orderInfo.opstate = "10";
                                //orderInfo.userViewMsg = "充值卡卡号或者密码无效";
                                //orderInfo.realvalue = 0M;

                                //orderInfo.withholdAmt = response.OrderAmt;
                                //orderInfo.payAmt = 0M;
                                //orderInfo.promAmt = 0M;

                                //orderInfo.withholdAmt = response.OrderAmt;
                                //orderInfo.profits = 0M;

                                if (orderInfo.promAmt < 0)
                                {
                                    orderInfo.promAmt = 0;
                                }

                                #endregion
                            }

                            #endregion
                        }
                    }
                    else
                    {
                        WithholdBll.Insert(orderInfo);
                    }
                }

                if (seq == 1)
                {
                    BllCard.Complete(orderInfo);
                }

                #endregion
            }
            else if (response.Method == 2)
            {
                #region 系统处理
                orderInfo.realvalue   = orderInfo.refervalue;
                orderInfo.status      = response.OrderStatus;
                orderInfo.opstate     = response.Opstate;
                orderInfo.errtype     = response.SuppErrorCode;
                orderInfo.msg         = response.SuppErrorMsg;
                orderInfo.userViewMsg = response.ViewMsg;

                orderInfo = BLL.Order.Card.Factory.Instance.SystemHandleOrder(orderInfo);
                #endregion
            }

            return(orderInfo);
        }
Esempio n. 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        public static bool Finish(CardOrderSupplierResponse response)
        {
            string cacheKey = "OrderBankComplete" + response.SysOrderNo + response.SupplierId.ToString(CultureInfo.InvariantCulture);

            object flag = Cache.WebCache.GetCacheService().RetrieveObject(cacheKey);

            if (flag != null)
            {
                return(true);
            }

            var orderInfo = Cache.WebCache.GetCacheService().RetrieveObject(response.SysOrderNo) as OrderCardInfo;

            if (orderInfo == null)
            {
                orderInfo = BLL.Order.Card.Factory.Instance.GetModelByOrderId(response.SysOrderNo);
            }
            if (orderInfo == null)
            {
                return(false);
            }

            try
            {
                byte continueSubmit = 0;

                int seq = 1, continueSupp = 0;

                bool processFlag = true;

                if (response.Method == 1)
                {
                    if (response.OrderStatus != 2)
                    {
                        #region 继续提交
                        var suppInfo = BLL.Supplier.Factory.GetCacheModel(response.SupplierId);
                        if (suppInfo != null)
                        {
                            if (!string.IsNullOrEmpty(suppInfo.AsynsRetCode))
                            {
                                string[] arr = suppInfo.AsynsRetCode.Split(',');
                                if (arr.Any(s => s == response.SuppErrorCode))
                                {
                                    continueSubmit = 1;
                                }
                            }
                        }
                        #endregion
                    }

                    DataRow resultRow = BLL.Order.Card.Factory.Instance.CallbackInsert(response.SysOrderNo
                                                                                       , response.SupplierId
                                                                                       , response.OrderStatus
                                                                                       , response.SuppErrorCode
                                                                                       , response.SuppErrorMsg
                                                                                       , continueSubmit);

                    if (resultRow != null)
                    {
                        seq          = Convert.ToInt32(resultRow["seq"]);
                        continueSupp = Convert.ToInt32(resultRow["suppId"]);
                    }

                    if (continueSubmit == 1 && continueSupp > 0)
                    {
                        #region 再次提交
                        try
                        {
                            if (resultRow != null)
                            {
                                var o = new CardOrderSummitArgs()
                                {
                                    SysOrderNo = response.SysOrderNo,
                                    CardTypeId = Convert.ToInt32(resultRow["typeid"]),
                                    CardNo     = resultRow["cardno"].ToString(),
                                    CardPass   = resultRow["cardpass"].ToString(),
                                    FaceValue  = decimal.ToInt32(Convert.ToDecimal(resultRow["facevalue"])),
                                    Attach     = "",
                                    Source     = 2
                                };
                                var callBack = SendCard((SupplierCode)continueSupp, o);
                                if (callBack.SummitStatus == 1)
                                {
                                    processFlag = false;
                                }
                            }
                        }
                        catch
                        {
                        }
                        #endregion
                    }
                    else
                    {
                        processFlag = (seq == 1) || ((seq > 1) && (response.OrderStatus == 2));
                    }
                }

                if (processFlag)
                {
                    orderInfo = UpdateOrder(seq, orderInfo, response);

                    if (seq == 1 && orderInfo != null)
                    {
                        //APINotification.DoAsynchronousNotify(orderInfo);

                        APINotification.SynchronousNotifyX(orderInfo);
                    }
                }
                Cache.WebCache.GetCacheService().AddObject(cacheKey, response.OrderStatus, 5);

                return(true);
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);

                return(false);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// returncode=1
        /// &orderid=14032617162212060589
        /// &realmoney=15.0000
        /// &cardstatus=1
        /// &sign=3eedb92c7cb6bedd6aab483dc35375db
        /// &errtype=
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public bool Finish(string orderid, string callback)
        {
            bool result = false;

            try
            {
                if (!string.IsNullOrEmpty(callback))
                {
                    string opstate = "-1";
                    int    status  = 4;

                    string returncode = GetVal(callback, "returncode");
                    string realmoney  = GetVal(callback, "realmoney");
                    string message    = GetVal(callback, "errtype");

                    if (message == "成功")
                    {
                        message = "支付成功";
                    }

                    if (returncode == "1")
                    {
                        opstate = "0";
                        status  = 2;
                    }
                    else if (returncode == "8" || returncode == "-1" || returncode == "2") //“2”代表售卡处理中
                    {
                        opstate = string.Empty;
                    }

                    if (!string.IsNullOrEmpty(opstate))
                    {
                        decimal amount = 0M;
                        if (decimal.TryParse(realmoney, out amount))
                        {
                            var response = new CardOrderSupplierResponse()
                            {
                                SupplierId    = SuppId,
                                SuppTransNo   = "",
                                SysOrderNo    = orderid,
                                OrderAmt      = amount,
                                SuppAmt       = 0M,
                                OrderStatus   = status,
                                SuppErrorCode = returncode,
                                Opstate       = opstate,
                                SuppErrorMsg  = message,
                                ViewMsg       = message,
                                Method        = 1
                            };
                            OrderCardUtils.Finish(response);

                            result = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);
            }

            return(result);
        }
Esempio n. 17
0
        /// <summary>
        ///
        /// </summary>
        public void CardNotify()
        {
            try
            {
                string returncode = HttpContext.Current.Request.QueryString["returncode"].ToString().Trim().ToLower();
                string userid     = HttpContext.Current.Request.QueryString["userid"].ToString().Trim().ToLower();
                string orderid    = HttpContext.Current.Request.QueryString["orderid"].ToString().Trim().ToLower();
                string typeid     = HttpContext.Current.Request.QueryString["typeid"].ToString().Trim().ToLower();
                string productid  = HttpContext.Current.Request.QueryString["productid"].ToString().Trim().ToLower();
                string cardno     = HttpContext.Current.Request.QueryString["cardno"].ToString().Trim().ToLower();
                string cardpwd    = HttpContext.Current.Request.QueryString["cardpwd"].ToString().Trim().ToLower();
                string money      = HttpContext.Current.Request.QueryString["money"].ToString().Trim().ToLower();
                string realmoney  = HttpContext.Current.Request.QueryString["realmoney"].ToString().Trim().ToLower();
                string cardstatus = HttpContext.Current.Request.QueryString["cardstatus"].ToString().Trim().ToLower();
                string sign       = HttpContext.Current.Request.QueryString["sign"].ToString().Trim().ToLower();
                string ext        = HttpContext.Current.Request.QueryString["ext"].ToString().Trim().ToLower();
                string errtype    = HttpContext.Current.Request.QueryString["errtype"].ToString().Trim();
                string keyvalue   = this.SuppKey;

                string localunsign = string.Format("returncode={0}&userid={1}&orderid={2}&typeid={3}&productid={4}&cardno={5}&cardpwd={6}&money={7}&realmoney={8}&cardstatus={9}&keyvalue={10}"
                                                   , returncode
                                                   , userid
                                                   , orderid
                                                   , typeid
                                                   , productid
                                                   , cardno
                                                   , cardpwd
                                                   , money
                                                   , realmoney
                                                   , cardstatus
                                                   , keyvalue
                                                   );

                string localsign = MD5(localunsign);//, "utf-8"
                if (localsign == sign)
                {
                    string opstate = "-1";
                    if (returncode == "1")
                    {
                        opstate = "0";
                    }
                    else
                    {
                        opstate = ConvertCode(opstate);
                    }

                    int status = (returncode == "1") ? 2 : 4;

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = "",
                        SysOrderNo    = orderid,
                        OrderAmt      = decimal.Parse(realmoney),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = errtype,
                        Opstate       = opstate,
                        SuppErrorMsg  = GetMsgInfo2(errtype),
                        ViewMsg       = GetMsgInfo2(errtype),
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, Succflag);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }
Esempio n. 18
0
        /// <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);
        }
Esempio n. 19
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            try
            {
                string retCode        = HttpContext.Current.Request.QueryString["ret_code"];
                string retMsg         = HttpContext.Current.Request.QueryString["ret_msg"];
                string agentID        = HttpContext.Current.Request.QueryString["agent_id"];
                string billID         = HttpContext.Current.Request.QueryString["bill_id"];
                string jnetBillNO     = HttpContext.Current.Request.QueryString["jnet_bill_no"];
                string billStatus     = HttpContext.Current.Request.QueryString["bill_status"];
                string cardRealAMT    = HttpContext.Current.Request.QueryString["card_real_amt"];
                string cardSettleAMT  = HttpContext.Current.Request.QueryString["card_settle_amt"];
                string cardDetailData = HttpContext.Current.Request.QueryString["card_detail_data"];
                string extParam       = HttpContext.Current.Request.QueryString["ext_param"];

                string sign = HttpContext.Current.Request.QueryString["sign"];

                string plain = string.Format("ret_code={0}&agent_id={1}&bill_id={2}&jnet_bill_no={3}&bill_status={4}&card_real_amt={5}&card_settle_amt={6}&card_detail_data={7}|||{8}"
                                             , retCode
                                             , agentID
                                             , billID
                                             , jnetBillNO
                                             , billStatus
                                             , cardRealAMT
                                             , cardSettleAMT
                                             , cardDetailData
                                             , SuppKey
                                             );

                AsynsRetLogger(plain);

                string localsign = md5sign(plain);

                if (localsign.ToLower() == sign.ToLower())
                {
                    string msg     = GetMsgInfo(retCode);
                    int    status  = (retCode == "0" && billStatus == "1") ? 2 : 4;
                    string opstate = "-1";
                    if (status == 2)
                    {
                        opstate = "0";

                        msg = "支付成功";
                    }
                    else
                    {
                        opstate = ConvertCode(retCode);
                    }

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = billID,
                        SysOrderNo    = billID,
                        OrderAmt      = decimal.Parse(cardRealAMT),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = retCode,
                        Opstate       = opstate,
                        SuppErrorMsg  = msg,
                        ViewMsg       = msg,
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, Succflag);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                HttpContext.Current.Response.Write("error");
            }
        }
Esempio n. 20
0
        public void CardNotifyV25()
        {
            HttpContext.Current.Request.ContentEncoding = Encoding.UTF8;
            string returncode      = HttpContext.Current.Request.QueryString["returncode"].ToString().Trim();
            string supplierOrderId = HttpContext.Current.Request.QueryString["yzchorderno"].ToString().Trim();
            string userid          = HttpContext.Current.Request.QueryString["userid"].ToString().Trim();
            string orderId         = HttpContext.Current.Request.QueryString["orderno"].ToString().Trim();
            string money           = HttpContext.Current.Request.QueryString["money"].ToString().Trim();
            string realmoney       = HttpContext.Current.Request.QueryString["realmoney"].ToString().Trim();
            string sign            = HttpContext.Current.Request.QueryString["sign"].ToString().Trim();
            string ext             = HttpContext.Current.Request.QueryString["ext"].ToString().Trim();
            string errtype         = HttpContext.Current.Request.QueryString["errtpe"].ToString().Trim();
            string msg             = HttpContext.Current.Request.QueryString["message"].ToString();
            string SuppKey         = base.SuppKey;

            try
            {
                string data  = string.Format("returncode={0}&yzchorderno={1}&userid={2}&orderno={3}&money={4}&realmoney={5}&keyvalue={6}", new object[] { returncode, supplierOrderId, userid, orderId, money, realmoney, SuppKey });
                string str12 = MD5(data);
                if (str12 == sign)
                {
                    string opstate = "-1";
                    //returncode:“1”代表售卡成功,
                    //“0”代表售卡失败

                    if (returncode == "1")
                    {
                        opstate = "0";
                    }
                    int       status = (returncode == "1") ? 2 : 4;
                    OrderCard card   = new OrderCard();
                    string    info   = "";
                    if (!string.IsNullOrEmpty(msg))
                    {
                        info = msg.Replace("message=", "").Split(new char[] { ',' })[0];
                    }
                    if (msg == "成功")
                    {
                        info = "支付成功";
                    }
                    status = (returncode == "1" || returncode == "2") ? 2 : 4;
                    if (status == 2)
                    {
                        opstate = "0";
                    }
                    else
                    {
                        opstate = ConvertCode(returncode);
                    }

                    string viewMsg = msg;

                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = supplierOrderId,
                        SysOrderNo    = orderId,
                        OrderAmt      = decimal.Parse(money),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = errtype,
                        Opstate       = opstate,
                        SuppErrorMsg  = msg,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, Succflag);
                }
                else
                {
                    LogHelper.Write(string.Format("70card 原字串{0} 本地sign{1},接口商sign:{2}", data, str12, sign));
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
            HttpContext.Current.Response.Write("ok");
            HttpContext.Current.Response.End();
        }
Esempio n. 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="retText"></param>
        /// <returns></returns>
        public bool Finish(string retText)
        {
            bool success = false;

            try
            {
                //orderid=2014040116392194&opstate=&ovalue=0.00&sign=5757b4b2928fd919444a0a55ee90ffb4
                if (!string.IsNullOrEmpty(retText))
                {
                    string[] arr     = retText.Split('&');
                    string   orderid = arr[0].Replace("orderid=", "");
                    string   opstate = arr[1].Replace("opstate=", "");
                    string   ovalue  = arr[2].Replace("ovalue=", "");
                    string   sign    = arr[3].Replace("sign=", "");

                    string localsign = string.Format("orderid={0}&opstate={0}&ovalue={0}", orderid, opstate, ovalue);
                    localsign = viviLib.Security.Cryptography.MD5(localsign + SuppKey);

                    if (localsign == sign)
                    {
                        string op = string.Empty;

                        int status = 4;
                        if (opstate != "1")
                        {
                            if (opstate == "2")
                            {
                                op = "0";
                            }
                            else
                            {
                                status = 4;
                                op     = opstate;
                            }

                            if (!string.IsNullOrEmpty(op))
                            {
                                //BLL.OrderCard bll = new viviapi.BLL.OrderCard();

                                //bll.ReceiveSuppResult(suppId
                                //   , orderid
                                //   , string.Empty
                                //   , status
                                //   , op
                                //   , opstate
                                //   , decimal.Parse(ovalue)
                                //   , 0M
                                //   , opstate);

                                string msg      = GetMsgInfo("opstate=" + opstate, ovalue);
                                var    response = new CardOrderSupplierResponse()
                                {
                                    SupplierId    = SuppId,
                                    SuppTransNo   = "",
                                    SysOrderNo    = orderid,
                                    OrderAmt      = decimal.Parse(ovalue),
                                    SuppAmt       = 0M,
                                    OrderStatus   = status,
                                    SuppErrorCode = opstate,
                                    Opstate       = opstate,
                                    SuppErrorMsg  = msg,
                                    ViewMsg       = msg,
                                    Method        = 1
                                };

                                OrderCardUtils.Finish(response);

                                success = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);
            }

            return(success);
        }
Esempio n. 22
0
        public bool Finish(string callback)
        {
            bool result = false;

            try
            {
                if (!string.IsNullOrEmpty(callback))
                {
                    string[] arr = callback.Split('&');

                    if (arr.Length == 11)
                    {
                        string retCode        = arr[0];
                        string retMsg         = arr[1];
                        string agentID        = arr[2];
                        string billID         = arr[3];
                        string jnetBillNO     = arr[4];
                        string billStatus     = arr[5];
                        string cardRealAMT    = arr[6];
                        string cardSettleAMT  = arr[7];
                        string cardDetailData = arr[8];
                        string extParam       = arr[9];
                        string sign           = arr[10];

                        string plain = string.Format("{0}&{1}&{2}&{3}&{4}&{5}&{6}&{7}|||{8}"
                                                     , retCode
                                                     , agentID
                                                     , billID
                                                     , jnetBillNO
                                                     , billStatus
                                                     , cardRealAMT
                                                     , cardSettleAMT
                                                     , cardDetailData
                                                     , SuppKey);

                        string locationsign = md5sign(plain);

                        if (sign.Replace("sign=", "") == locationsign)
                        {
                            billID      = billID.Replace("bill_id=", "");
                            retCode     = retCode.Replace("ret_code=", "");
                            billStatus  = billStatus.Replace("bill_status=", "");
                            retMsg      = retMsg.Replace("ret_msg=", "");
                            jnetBillNO  = jnetBillNO.Replace("jnet_bill_no=", "");
                            cardRealAMT = cardRealAMT.Replace("card_real_amt=", "");

                            string opstate = "-1";
                            int    status  = 4;
                            string msg     = GetMsgInfo(retCode);
                            if (retCode == "0")
                            {
                                if (billStatus == "0")
                                {
                                    opstate = string.Empty; //需要再次查询
                                }
                                else if (billStatus == "1")
                                {
                                    opstate = "0";
                                    status  = 2;
                                    msg     = "支付成功";
                                }
                            }
                            else if (retCode != "99")
                            {
                                opstate = "-1";
                            }

                            if (!string.IsNullOrEmpty(opstate))
                            {
                                decimal realAMT = 0;
                                if (decimal.TryParse(cardRealAMT.Trim(), out realAMT))
                                {
                                    var response = new CardOrderSupplierResponse()
                                    {
                                        SupplierId    = SuppId,
                                        SuppTransNo   = jnetBillNO,
                                        SysOrderNo    = billID,
                                        OrderAmt      = realAMT,
                                        SuppAmt       = 0M,
                                        OrderStatus   = status,
                                        SuppErrorCode = retCode,
                                        Opstate       = opstate,
                                        SuppErrorMsg  = msg,
                                        ViewMsg       = msg,
                                        Method        = 1
                                    };
                                    OrderCardUtils.Finish(response);
                                }
                                result = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }

            return(result);
        }
Esempio n. 23
0
        /// <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);
        }
Esempio n. 24
0
        /// <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;
                    }
                }
            }
        }
Esempio n. 25
0
        public bool Finish(string orderid, string callback)
        {
            bool flag = false;

            try
            {
                if (string.IsNullOrEmpty(callback))
                {
                    return(flag);
                }
                string[] strArray = callback.Split(new char[] { '&' });
                if (strArray.Length != 3)
                {
                    return(flag);
                }
                string str    = "-1";
                int    status = 4;
                //returncode={}&realmoney={}&usermoney={}&message={}&errtype={}
                //“-1”代表售卡无记录
                //“0”代表售卡失败,
                //“1”代表售卡成功,
                //“2”代表售卡处理中
                string returncode = strArray[0].Replace("returncode=", "");
                string realmoney  = strArray[1].Replace("realmoney=", "");
                string usermoney  = strArray[2].Replace("usermoney=", "");
                string msg        = strArray[3].Replace("message=", "");
                string errtype2   = strArray[4].Replace("errtype=", "");

                if (returncode == "1")
                {
                    str    = "0";
                    status = 2;
                }
                else if ((returncode == "-1") || (returncode == "2"))
                {
                    str = string.Empty;
                }
                if (!string.IsNullOrEmpty(str))
                {
                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = "",
                        SysOrderNo    = orderid,
                        OrderAmt      = decimal.Parse(realmoney),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = errtype2,
                        Opstate       = str,
                        SuppErrorMsg  = msg,
                        ViewMsg       = GetMsgInfo(errtype2),
                        Method        = 1
                    };

                    OrderCardUtils.Finish(response);
                    //new OrderCard().ReceiveSuppResult(suppId, orderid, string.Empty, status, str, msg, decimal.Parse(s), 0M, errtype);
                    flag = true;
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
            }
            return(flag);
        }
Esempio n. 26
0
        /// <summary>
        /// 处理完成,返回通知
        /// </summary>
        public void Notify()
        {
            AsynsRetLogger(HttpContext.Current.Request.RawUrl);

            if (HttpContext.Current.Request.Form.Count > 0)
            {
                string data = WebClientHelper.FormatRequestData(HttpContext.Current.Request.Form, System.Text.Encoding.Default);
                AsynsRetLogger(data);
            }

            try
            {
                string md5key       = SuppKey;
                int    status       = 4;
                string opstate      = "-1";
                string usercode     = HttpContext.Current.Request.Form["usercode"];
                string mode         = HttpContext.Current.Request.Form["mode"];
                string version      = HttpContext.Current.Request.Form["version"];
                string orderno      = HttpContext.Current.Request.Form["orderno"]; //本系统内部单号
                string billid       = HttpContext.Current.Request.Form["billid"];  //欧飞单号
                string result       = HttpContext.Current.Request.Form["result"];  //返回处理结果代码
                string info         = HttpContext.Current.Request.Form["info"];    //交易情况说明
                string value        = HttpContext.Current.Request.Form["value"];   //面值
                string accountvalue = HttpContext.Current.Request.Form["accountvalue"];
                string datetime     = HttpContext.Current.Request.Form["datetime"];
                string sign         = HttpContext.Current.Request.Form["sign"];

                string srcStr = usercode + mode + version + orderno + billid + result + info + value + accountvalue + datetime + md5key;
                string md5str = md5sign(srcStr);

                if (md5str.ToLower() == sign.ToLower())
                {      //status=2 支付成功 status=4支付失败
                    status = (result == "2000" || result == "2011") ? 2 : 4;
                    if (status == 2)
                    {
                        opstate = "0";
                    }
                    else
                    {
                        opstate = ConvertCode(result);
                    }
                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = billid,
                        SysOrderNo    = orderno,
                        OrderAmt      = decimal.Parse(value),
                        SuppAmt       = decimal.Parse(accountvalue),
                        OrderStatus   = status,
                        SuppErrorCode = result,
                        Opstate       = opstate,
                        SuppErrorMsg  = info,
                        ViewMsg       = info,
                        Method        = 1
                    };

                    OrderCardUtils.SuppNotify(response, Succflag);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }
Esempio n. 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="callBackText"></param>
        /// <returns></returns>
        public bool Finish(string callBackText)
        {
            bool result = false;

            try
            {
                if (!string.IsNullOrEmpty(callBackText))
                {
                    string retcode = "";
                    string retmsg  = "";

                    string orderid         = "";
                    string cardnumber      = "";
                    string cardpwd         = "";
                    string storagetime     = "";
                    string usetime         = "";
                    string usestatus       = "";
                    string customerorderid = "";
                    string settleparvalue  = "";
                    string settlediscount  = "";
                    string settlemoney     = "";

                    #region xml
                    var xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(callBackText);

                    var xmlNodeList = xmlDocument.SelectSingleNode("Root/Ret");
                    if (xmlNodeList != null)
                    {
                        foreach (XmlNode list in xmlNodeList)
                        {
                            switch (list.Name.ToLower())
                            {
                            case "retcode":
                                retcode = list.InnerText;
                                break;

                            case "retmsg":
                                retmsg = list.InnerText;
                                break;
                            }
                        }
                    }

                    xmlNodeList = xmlDocument.SelectSingleNode("Root/Card");
                    if (xmlNodeList != null)
                    {
                        foreach (XmlNode list in xmlNodeList)
                        {
                            switch (list.Name.ToLower())
                            {
                            case "orderid":
                                orderid = list.InnerText;
                                break;

                            case "cardnumber":
                                cardnumber = list.InnerText;
                                break;

                            case "storagetime":
                                storagetime = list.InnerText;
                                break;

                            case "usetime":
                                usetime = list.InnerText;
                                break;

                            case "usestatus":
                                usestatus = list.InnerText;
                                break;

                            case "customerorderid":
                                customerorderid = list.InnerText;
                                break;

                            case "settleparvalue":
                                settleparvalue = list.InnerText;
                                break;

                            case "settlediscount":
                                settlediscount = list.InnerText;
                                break;

                            case "settlemoney":
                                settlemoney = list.InnerText;
                                break;
                            }
                        }
                    }
                    #endregion

                    if (retcode == "30001")
                    {
                        #region
                        int     status = 0;
                        string  opstate = "";
                        decimal orderAmt = 0M;
                        string  msg = "", viewMsg = "";

                        switch (usestatus)
                        {
                        case "4":
                            orderAmt = decimal.Parse(settleparvalue);
                            status   = 2;
                            opstate  = "0";
                            msg      = "支付成功";
                            viewMsg  = msg;
                            break;

                        case "1":
                        case "5":
                            status  = 4;
                            opstate = ConvertCode(retcode);
                            msg     = retmsg;
                            viewMsg = SellCard20.GetMsgToUserView(opstate);
                            break;
                        }

                        if (status > 0)
                        {
                            var response = new CardOrderSupplierResponse()
                            {
                                SupplierId    = SuppId,
                                SuppTransNo   = orderid,
                                SysOrderNo    = customerorderid,
                                OrderAmt      = orderAmt,
                                SuppAmt       = 0M,
                                OrderStatus   = status,
                                SuppErrorCode = retcode,
                                Opstate       = opstate,
                                SuppErrorMsg  = msg,
                                ViewMsg       = viewMsg,
                                Method        = 1
                            };

                            OrderCardUtils.Finish(response);
                            result = true;
                        }
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }

            return(result);
        }
Esempio n. 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public bool Finish(string callback)
        {
            bool success = false;

            #region 返回数据格式
            //<?xml version="1.0" encoding="gbk"?>
            //    <root><usercode>A1081794</usercode>
            //<mode>q</mode>
            //<version>1.0</version>
            //<orderno>C5669548794170966980</orderno>
            //<billid>R151006270963751</billid>
            //<result>2016</result>
            //<info>密码错误</info>
            //<value>0</value>
            //<accountvalue>0</accountvalue>
            //<datetime>20151007002546</datetime>
            //<sign>f9371497b583390bb15c70ccfd152108</sign>
            //    </root>
            #endregion
            try
            {
                if (!string.IsNullOrEmpty(callback))
                {
                    var doc = new System.Xml.XmlDocument();
                    doc.LoadXml(callback);

                    string usercode     = doc.GetElementsByTagName("usercode")[0].InnerText;
                    string mode         = doc.GetElementsByTagName("mode")[0].InnerText;
                    string version      = doc.GetElementsByTagName("version")[0].InnerText;
                    string orderno      = doc.GetElementsByTagName("orderno")[0].InnerText;      //翁贝系统生成的订单号
                    string billid       = doc.GetElementsByTagName("billid")[0].InnerText;       //欧飞订单号
                    string result       = doc.GetElementsByTagName("result")[0].InnerText;       //返回代码
                    string info         = doc.GetElementsByTagName("info")[0].InnerText;         //交易情况说明
                    string value        = doc.GetElementsByTagName("value")[0].InnerText;        //充值卡面值
                    string accountvalue = doc.GetElementsByTagName("accountvalue")[0].InnerText; //结算金额
                    string datetime     = doc.GetElementsByTagName("datetime")[0].InnerText;     //日期时间,格式:YYYYMMDDHHMMSS
                    string sign         = doc.GetElementsByTagName("sign")[0].InnerText;

                    string srcStr = usercode + mode + version + orderno + billid + result + info + value + accountvalue + datetime + SuppKey;
                    string md5Str = md5sign(srcStr);

                    string opstate = "-1";
                    int    status  = 4;

                    if (md5Str.ToLower() == sign.ToLower())
                    {
                        if (result == "2000" || result == "2011")
                        {
                            opstate = "0";
                            status  = 2;
                        }

                        if (result == "2014" || result == "2001")
                        {
                            opstate = string.Empty;
                        }

                        if (!string.IsNullOrEmpty(opstate))
                        {
                            var response = new CardOrderSupplierResponse()
                            {
                                SupplierId    = SuppId,
                                SuppTransNo   = billid,
                                SysOrderNo    = orderno,
                                OrderAmt      = decimal.Parse(value),
                                SuppAmt       = decimal.Parse(accountvalue),
                                OrderStatus   = status,
                                SuppErrorCode = result,
                                Opstate       = opstate,
                                SuppErrorMsg  = info,
                                ViewMsg       = info,
                                Method        = 1
                            };

                            OrderCardUtils.Finish(response);

                            success = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex);
            }

            return(success);
        }
Esempio n. 29
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            //string MerchantKey = suppKey;
            string name        = GetValue("Name");
            string version     = GetValue("Version");
            string charset     = GetValue("Charset");
            string traceNo     = GetValue("TraceNo");
            string msgSender   = GetValue("MsgSender");
            string sendTime    = GetValue("SendTime");
            string instCode    = GetValue("InstCode");
            string orderNo     = GetValue("OrderNo");
            string orderAmount = GetValue("OrderAmount");
            string transNo     = GetValue("TransNo");
            string transAmount = GetValue("TransAmount");
            string transStatus = GetValue("TransStatus");
            string transType   = GetValue("TransType");
            string transTime   = GetValue("TransTime");
            string merchantNo  = GetValue("MerchantNo");
            string errorCode   = GetValue("ErrorCode");
            string errorMsg    = GetValue("ErrorMsg");
            string ext1        = GetValue("Ext1");
            string signType    = GetValue("SignType");
            string signMsg     = GetValue("SignMsg");

            string sign = name + version + charset + traceNo + msgSender
                          + sendTime + instCode + orderNo + orderAmount + transNo
                          + transAmount + transStatus + transType + transTime
                          + merchantNo + errorCode + errorMsg + ext1 + signType + MerchantKey;
            string localsignMsg = MD5(sign);


            if (signMsg == localsignMsg)
            {
                var bll = new viviapi.BLL.OrderCard();

                string opstate = "-1";
                int    status  = (transStatus == "01") ? 2 : 4;



                string viewMsg = "";

                string errCode = "";
                string errMsg  = "";

                if (!string.IsNullOrEmpty(errorMsg))
                {
                    var ja = (Newtonsoft.Json.Linq.JArray)JsonConvert.DeserializeObject(errorMsg);
                    foreach (Newtonsoft.Json.Linq.JObject item in ja)
                    {
                        if (item["errorCode"] != null)
                        {
                            errCode = item["errorCode"].ToString().Replace("\"", "");
                        }
                        if (item["errorMsg"] != null)
                        {
                            errMsg = item["errorMsg"].ToString().Replace("\"", "");
                        }
                    }
                }

                if (status == 2)
                {
                    opstate   = "0";
                    errorCode = "0";
                    viewMsg   = "支付成功";
                }
                else
                {
                    opstate = ConvertCode(errCode);
                    viewMsg = SysInterface.Card.MyAPI.Utility.GetMessageByCode(opstate);
                }

                var response = new CardOrderSupplierResponse()
                {
                    SupplierId    = SuppId,
                    SuppTransNo   = transNo,
                    SysOrderNo    = orderNo,
                    OrderAmt      = decimal.Parse(transAmount),
                    SuppAmt       = 0M,
                    OrderStatus   = status,
                    SuppErrorCode = errCode,
                    SuppErrorMsg  = errMsg,
                    Opstate       = opstate,
                    ViewMsg       = viewMsg,
                    Method        = 1
                };

                OrderCardUtils.SuppNotify(response, "OK");
            }
        }
Esempio n. 30
0
        public void Return(HttpContext context)
        {
            //SZX.logURL(context.Request.RawUrl);

            // 校验返回数据包
            SZXCallbackResult result = SZX.VerifyCallback(SuppKey
                                                          , FormatQueryString.GetQueryString("r0_Cmd")
                                                          , FormatQueryString.GetQueryString("r1_Code")
                                                          , FormatQueryString.GetQueryString("p1_MerId")
                                                          , FormatQueryString.GetQueryString("p2_Order")
                                                          , FormatQueryString.GetQueryString("p3_Amt")
                                                          , FormatQueryString.GetQueryString("p4_FrpId")
                                                          , FormatQueryString.GetQueryString("p5_CardNo")
                                                          , FormatQueryString.GetQueryString("p6_confirmAmount")
                                                          , FormatQueryString.GetQueryString("p7_realAmount")
                                                          , FormatQueryString.GetQueryString("p8_cardStatus")
                                                          , FormatQueryString.GetQueryString("p9_MP")
                                                          , FormatQueryString.GetQueryString("pb_BalanceAmt")
                                                          , FormatQueryString.GetQueryString("pc_BalanceAct")
                                                          , FormatQueryString.GetQueryString("hmac"));

            if (string.IsNullOrEmpty(result.ErrMsg))
            {
                //使用应答机制时 必须回写success
                string viewMsg = "";
                string msg     = GetMsgInfo(result.P8_cardStatus);
                string opstate = "-1";
                /*成功还是失败*/
                int status = (result.R1_Code == "1") ? 2 : 4;
                if (status == 2)
                {
                    opstate = "0";
                    viewMsg = "支付成功";
                }
                else
                {
                    viewMsg = msg;
                }

                var response = new CardOrderSupplierResponse()
                {
                    SupplierId    = SuppId,
                    SuppTransNo   = "",
                    SysOrderNo    = result.P2_Order,
                    OrderAmt      = decimal.Parse(result.P3_Amt),
                    SuppAmt       = 0M,
                    OrderStatus   = status,
                    SuppErrorCode = result.P8_cardStatus,
                    Opstate       = opstate,
                    SuppErrorMsg  = result.ErrMsg,
                    ViewMsg       = viewMsg,
                    Method        = 1
                };

                OrderCardUtils.SuppNotify(response, Succflag);
            }
            else
            {
                context.Response.Write("交易签名无效!");
                context.Response.Write("<BR>YeePay-HMAC:" + result.Hmac);
                context.Response.Write("<BR>LocalHost:" + result.ErrMsg);
            }
        }