Example #1
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);
        }
Example #2
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);
                }
            }
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
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);
        }
Example #7
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;
                    }
                }
            }
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public bool Finish(string callback)
        {
            bool result = false;

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

                    if (arr.Length == 10)
                    {
                        string retCode       = GetValue(arr[0]);
                        string agentID       = GetValue(arr[1]);
                        string billID        = GetValue(arr[2]);
                        string huisuBillID   = GetValue(arr[3]);
                        string billStatus    = GetValue(arr[4]);
                        string cardRealPrice = GetValue(arr[5]);
                        string cardSettleAmt = GetValue(arr[6]);
                        string retMsg        = GetValue(arr[7]);
                        string extParam      = GetValue(arr[8]);
                        string sign          = GetValue(arr[9]);

                        string plain = string.Format("ret_code={0}&agent_id={1}&bill_id={2}&huisu_bill_id={3}&bill_status={4}&card_real_price={5}&card_settle_amt={6}|||{7}"
                                                     , retCode
                                                     , agentID
                                                     , billID
                                                     , huisuBillID
                                                     , billStatus
                                                     , cardRealPrice
                                                     , cardSettleAmt
                                                     , SuppKey);

                        string locationsign = Md5Sign(plain);

                        if (sign == locationsign)
                        {
                            if (retCode == "0")
                            {
                                int     status = 0;
                                string  opstate = "";
                                decimal orderAmt = 0M;
                                string  msg = "", viewMsg = "";

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

                                case "-1":
                                    status  = 4;
                                    opstate = ConvertCode(retMsg);
                                    msg     = GetMsgInfo(retMsg);
                                    viewMsg = SysInterface.Card.MyAPI.Utility.GetMessageByCode(opstate);
                                    break;
                                }

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

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

            return(result);
        }