Example #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, "");
        }
Example #2
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            string message = SaveInfo();

            if (string.IsNullOrEmpty(message))
            {
                int supplierId = int.Parse(ddlSupp.SelectedValue);
                if (Model != null)
                {
                    string supporderid  = string.Empty;
                    string errorinfo    = string.Empty;
                    string errorerrcode = string.Empty;

                    decimal amt = decimal.Parse(this.txtOrderAmt.Text.Trim());

                    var supp = (SupplierCode)supplierId;

                    var callBack = OrderCardUtils.SynchSubmit(supp
                                                              , OrderId
                                                              , Model.typeId
                                                              , Model.cardNo
                                                              , Model.cardPwd
                                                              , Convert.ToInt32(decimal.Round(amt, 0))
                                                              , ""
                                                              , 1);

                    if (callBack.SummitStatus == 0)
                    {
                        message = "提交失败";
                    }
                    else
                    {
                        message = "提交成功";
                    }
                }
                else
                {
                    message = "操作失败";
                }
            }

            ShowMessageBox(message);
        }
Example #3
0
        string Sell(int _suppId, string _sysorderid, int _serial, string _cardno, string _cardpwd, int _typeid, string _cardvalue, out string _supporderid, out string _errmsg)
        {
            string retruncode = "";

            _supporderid = string.Empty;
            _errmsg      = string.Empty;
            string suppErrCode = string.Empty;

            decimal _temp_num = 0;

            decimal.TryParse(_cardvalue, out _temp_num);

            var supp = (viviapi.Model.supplier.SupplierCode)_suppId;

            //string retruncode = ETAPI.SellFactory.SellCard(supp
            //    , _sysorderid
            //    , _typeid
            //    , _cardno
            //    , _cardpwd
            //    , string.Empty
            //    , Convert.ToInt32(decimal.Round(_temp_num, 0))
            //    , out _supporderid
            //    , out suppErrCode
            //    , out _errmsg);

            int faceValue = Convert.ToInt32(decimal.Round(_temp_num, 0));

            var callBack = OrderCardUtils.SynchSubmit(supp, _sysorderid, _typeid, _cardno, _cardpwd, faceValue, "", 1);

            if (callBack.SummitStatus == 1)
            {
                retruncode = "0";
            }
            else
            {
                retruncode = "-1";
            }

            return(retruncode);
        }
Example #4
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("订单状态不正确");
                }
            }
        }
Example #5
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 #6
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);
        }
Example #7
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
                    }
                }
                // }
            }
        }
Example #8
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);
        }
Example #9
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 #10
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();
            }
        }
Example #11
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");
            }
        }
Example #12
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);
            }
        }
Example #13
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 #14
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);
            }
        }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        string SendToSupp()
        {
            try
            {
                int    userid = currentUser.ID;
                string msg    = string.Empty;

                int supplierId = 0;

                bool isxunhuan = typeInfo.runmode == 1;


                ChannelInfo chanelInfo
                    = viviapi.BLL.Channel.Channel.GetModel(typeId, faceValue, userid, isxunhuan);

                if (chanelInfo == null ||
                    chanelInfo.supplier.HasValue == false ||
                    chanelInfo.supplier == 0)
                {
                    msg = "找不到通道,请联系商务或系统管理员处理。";
                }
                else
                {
                    supplierId = chanelInfo.supplier.Value;
                }

                if (supplierId > 0 && string.IsNullOrEmpty(msg))
                {
                    var order
                        = new viviapi.Model.Order.OrderCardInfo();

                    order.orderid       = viviapi.BLL.Order.Card.Factory.Instance.GenerateOrderId("");
                    order.addtime       = DateTime.Now;
                    order.attach        = "cardsell";
                    order.notifycontext = string.Empty;
                    order.notifycount   = 0;
                    order.notifystat    = 0;
                    order.notifyurl     = string.Empty;
                    order.clientip      = ServerVariables.TrueIP;
                    order.completetime  = DateTime.Now;
                    order.ordertype     = 8;
                    order.typeId        = typeId;
                    order.paymodeId     = typeId.ToString("0000") + faceValue.ToString();// chanelInfo.code;
                    order.payRate       = 0M;
                    order.supplierId    = supplierId;
                    order.supplierOrder = string.Empty;
                    order.userid        = userid;
                    order.userorder     = order.orderid + userid.ToString();
                    order.refervalue    = faceValue;
                    order.referUrl      = string.Empty;
                    order.cardNo        = cardNo;
                    order.cardPwd       = cardPwd;
                    order.server        = viviapi.SysConfig.RuntimeSetting.ServerId;
                    order.cardnum       = 1;
                    order.version       = "";
                    order.agentId       = Factory.GetPromID(userid);

                    //订单所属业务
                    order.manageId = currentUser.manageId;

                    bll.Insert(order);


                    string supporderid = string.Empty;
                    string errorinfo   = string.Empty;
                    string errorCode   = string.Empty;

                    msg = "true";

                    var supp = (viviapi.Model.supplier.SupplierCode)supplierId;

                    var callBack = OrderCardUtils.SynchSubmit(supp
                                                              , order.orderid
                                                              , typeId
                                                              , order.cardNo
                                                              , order.cardPwd
                                                              , faceValue
                                                              , ""
                                                              , 1);

                    if (callBack.SummitStatus == 0)
                    {
                        msg = errorinfo;

                        //bll.ReceiveSuppResult(supplierId
                        //    , order.orderid
                        //    , order.cardNo
                        //    , 4
                        //    , callBack.SuppErrorCode
                        //    , errorinfo
                        //    , 0M
                        //    , 0M
                        //    , string.Empty);
                    }
                }

                return(msg);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Example #16
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);
            }
        }
Example #17
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 #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);
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            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 pay_result     = req["pay_result"].Trim();     //交易结果0为成功,3为失败
            String bargainor_id   = req["bargainor_id"].Trim();   //15173交易订单号
            String transaction_id = req["transaction_id"].Trim(); //商户ID
            String sp_billno      = req["sp_billno"].Trim();      //商户请求交易时候提交的订单号
            String total_fee      = req["total_fee"].Trim();      //实际交易交易金额(注意:可能和商户请求交易提交过来的total_fee不一样!)
            String sign           = req["sign"].Trim();
            String attach         = req["attach"].Trim();
            String pay_info       = req["pay_info"].Trim();//交易类型中文说明

            //'生成MD5签名
            String sign_text = String.Format("pay_result={0}&bargainor_id={1}&sp_billno={2}&total_fee={3}&attach={4}&key={5}"
                                             , pay_result
                                             , bargainor_id
                                             , sp_billno
                                             , total_fee
                                             , attach
                                             , SuppKey);

            String localSign = viviLib.Security.Cryptography.MD5(sign_text).ToUpper();

            try
            {
                if (localSign == sign)
                {
                    string viewMsg = string.Empty;
                    string opstate = "-1";
                    int    status  = 4;

                    if (pay_result == "0")
                    {
                        opstate = "0";
                        status  = 2;
                        viewMsg = "支付成功";
                    }
                    else
                    {
                        viewMsg = "支付失败";
                    }
                    var response = new CardOrderSupplierResponse()
                    {
                        SupplierId    = SuppId,
                        SuppTransNo   = bargainor_id,
                        SysOrderNo    = sp_billno,
                        OrderAmt      = decimal.Parse(total_fee),
                        SuppAmt       = 0M,
                        OrderStatus   = status,
                        SuppErrorCode = status.ToString(),
                        Opstate       = opstate,
                        SuppErrorMsg  = viewMsg,
                        ViewMsg       = viewMsg,
                        Method        = 1
                    };
                    OrderCardUtils.SuppNotify(response, Succflag);
                    //BLL.OrderCard bll = new viviapi.BLL.OrderCard();
                    //bll.ReceiveSuppResult(SuppId, sp_billno, transaction_id, status, opstate, pay_result, decimal.Parse(total_fee), 0M, pay_result);
                    //HttpContext.Current.Response.Write("OK");
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                HttpContext.Current.Response.Write("error");
            }
        }
Example #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();
        }
Example #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);
        }
Example #22
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);
            }
        }
Example #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);
        }
Example #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;
                    }
                }
            }
        }
Example #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);
        }
Example #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);
            }
        }
Example #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);
        }
Example #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);
        }
Example #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");
            }
        }
Example #30
0
        /// <summary>
        ///
        /// </summary>
        public void Notify()
        {
            try
            {
                int     status   = 0;
                string  msg      = "";
                string  viewMsg  = "";
                string  opstate  = "";
                decimal orderAmt = 0M;

                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 huisuBillID   = HttpContext.Current.Request.QueryString["huisu_bill_id"];
                string billStatus    = HttpContext.Current.Request.QueryString["bill_status"];
                string cardRealPrice = HttpContext.Current.Request.QueryString["card_real_price"];
                string cardSettleAmt = HttpContext.Current.Request.QueryString["card_settle_amt"];
                string extParam      = HttpContext.Current.Request.QueryString["ext_param"];
                string sign          = HttpContext.Current.Request.QueryString["sign"];

                AsynsRetLogger(sign);

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

                AsynsRetLogger("plain" + plain);

                string localsign = Md5Sign(plain);

                AsynsRetLogger("localsign" + localsign);

                if (String.Equals(localsign, sign, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (retCode != "0")
                    {
                        return;
                    }

                    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.SuppNotify(response, Succflag);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                HttpContext.Current.Response.Write("error");
                //HttpContext.Current.Response.End();
            }
        }