Ejemplo n.º 1
0
        /// <summary>
        /// 根据公司Id获取机票平台的公司账户信息
        /// </summary>
        /// <param name="CompanyId">公司Id</param>
        /// <returns>返回公司账户信息集合</returns>
        public virtual IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> GetList(string CompanyId)
        {
            if (string.IsNullOrEmpty(CompanyId))
            {
                return(null);
            }
            IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> ResultList = new List <EyouSoft.Model.TicketStructure.TicketCompanyAccount>();
            DbCommand dc = base.TourStore.GetSqlStringCommand(Sql_Select_TicketCompanyAccount);

            this._db.AddInParameter(dc, "CompanyId", DbType.AnsiStringFixedLength, CompanyId);
            using (IDataReader dr = DbHelper.ExecuteReader(dc, this._db))
            {
                EyouSoft.Model.TicketStructure.TicketCompanyAccount model = null;
                while (dr.Read())
                {
                    model               = new EyouSoft.Model.TicketStructure.TicketCompanyAccount();
                    model.Id            = dr.GetInt32(dr.GetOrdinal("id"));
                    model.CompanyId     = dr.GetString(dr.GetOrdinal("companyid"));
                    model.AccountNumber = dr.GetString(dr.GetOrdinal("AccountNumber"));
                    model.InterfaceType = (EyouSoft.Model.TicketStructure.TicketAccountType)Enum.Parse(typeof(EyouSoft.Model.TicketStructure.TicketAccountType), dr.GetByte(dr.GetOrdinal("InterfaceType")).ToString());
                    model.IsSign        = dr.GetString(dr.GetOrdinal("IsSign")) == "1" ? true : false;

                    ResultList.Add(model);
                }
                model = null;
            }
            return(ResultList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取公司账户信息实体(机票平台)
        /// </summary>
        /// <param name="AcountId">帐号Id(主键)</param>
        /// <returns></returns>
        public virtual EyouSoft.Model.TicketStructure.TicketCompanyAccount GetModel(int AcountId)
        {
            string    StrSql = " SELECT [Id],[CompanyId],[AccountNumber],[InterfaceType],[IsSign] FROM [tbl_TicketCompanyAccount]  WHERE [id]=@AcountId ";
            DbCommand dc     = null;

            dc = base.TourStore.GetSqlStringCommand(StrSql);
            base.TourStore.AddInParameter(dc, "AcountId", DbType.Int32, AcountId);
            EyouSoft.Model.TicketStructure.TicketCompanyAccount model = null;
            using (IDataReader dr = DbHelper.ExecuteReader(dc, base.TicketStore))
            {
                while (dr.Read())
                {
                    model    = new EyouSoft.Model.TicketStructure.TicketCompanyAccount();
                    model.Id = dr.GetInt32(dr.GetOrdinal("Id"));
                    if (!dr.IsDBNull(dr.GetOrdinal("InterfaceType")))
                    {
                        model.InterfaceType = (EyouSoft.Model.TicketStructure.TicketAccountType)Enum.Parse(typeof(EyouSoft.Model.TicketStructure.TicketAccountType), dr.GetByte(dr.GetOrdinal("InterfaceType")).ToString());
                    }
                    model.IsSign        = dr.GetString(dr.GetOrdinal("IsSign")) != "0" ? false : true;
                    model.CompanyId     = dr.GetString(dr.GetOrdinal("CompanyId"));
                    model.AccountNumber = dr.GetString(dr.GetOrdinal("AccountNumber"));
                }
            }
            return(model);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新平台机票供应商
 /// </summary>
 /// <param name="model">平台机票供应商(采购商)公司账户信息实体</param>
 /// <returns></returns>
 public bool UpdateTicketCompanyAccount(EyouSoft.Model.TicketStructure.TicketCompanyAccount model)
 {
     if (idal.Update(model) > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据账户类型和公司ID返回公司账户实体
        /// </summary>
        /// <param name="companyId">公司ID</param>
        /// <param name="accountType">账户类型</param>
        /// <returns></returns>
        public EyouSoft.Model.TicketStructure.TicketCompanyAccount GetModel(string companyId, EyouSoft.Model.TicketStructure.TicketAccountType accountType)
        {
            IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = GetTicketCompanyAccountList(companyId);

            EyouSoft.Model.TicketStructure.TicketCompanyAccount model = null;

            if (list != null)
            {
                model = list.FirstOrDefault(i => i.InterfaceType == accountType);
            }
            return(model);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 查询用户是否已经加入支付圈
        /// </summary>
        protected void IsSign()
        {
            int    accountType          = Utils.GetInt(Request.QueryString["accountType"]); //接口类型
            string currentUserCompanyId = SiteUserInfo.CompanyID;                           //当前用户的公司ID

            //判断接口类型是否有效
            if (accountType < 1 || accountType > 7)//无效
            {
                Utils.ResponseMeg(false, "无效的接口类型");
                return;
            }

            //接口类型
            EyouSoft.Model.TicketStructure.TicketAccountType ticketAccountType =
                (EyouSoft.Model.TicketStructure.TicketAccountType)accountType;

            EyouSoft.IBLL.TicketStructure.ITicketCompanyAccount bll =
                EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance();

            EyouSoft.Model.TicketStructure.TicketCompanyAccount model =
                bll.GetModel(currentUserCompanyId, ticketAccountType);

            //判断是否已经绑定过当前接口类型的帐户信息
            if (model == null)//没有绑定过
            {
                Response.Clear();
                Response.Write("{isBind:false}");
                Response.End();
            }

            Response.Clear();
            if (!model.IsSign)                                                             //没有进行过签约
            {
                string qianyueUrl = GetQianYueUrl(ticketAccountType, model.AccountNumber); //获取用于签约的URL

                Response.Write("{isBind:true,isSign:" + model.IsSign.ToString().ToLower() + ",accountNumber:'" + model.AccountNumber + "',qianyueurl:'" + Server.UrlEncode(qianyueUrl) + "'}");
            }
            else//进行过签约
            {
                Response.Write("{isBind:true,isSign:true,accountNumber:'" + model.AccountNumber + "'}");
            }


            Response.End();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加机票公司账户信息
        /// </summary>
        /// <param name="model">平台机票供应商(采购商)公司账户信息实体</param>
        /// <returns>1:成功,0:失败</returns>
        public virtual int Add(EyouSoft.Model.TicketStructure.TicketCompanyAccount model)
        {
            int EffectCount = 0;

            if (model == null)
            {
                return(EffectCount);
            }
            DbCommand dc = this._db.GetSqlStringCommand(Sql_Insert_TicketCompanyAccount);

            this._db.AddInParameter(dc, "CompanyId", DbType.AnsiStringFixedLength, model.CompanyId);
            this._db.AddInParameter(dc, "AccountNumber", DbType.AnsiString, model.AccountNumber);
            this._db.AddInParameter(dc, "InterfaceType", DbType.Byte, (int)model.InterfaceType);
            this._db.AddInParameter(dc, "IsSign", DbType.AnsiStringFixedLength, model.IsSign ? "1" : "0");

            EffectCount = DbHelper.ExecuteSql(dc, this._db);
            return(EffectCount);
        }
Ejemplo n.º 7
0
        /// <param name="opearType">操作类型</param>
        private void OrderOperate(string opearType)
        {
            string OrderNum = Utils.GetFormValue("OrderId"); //订单ID
            bool   result   = false;                         //保存操作结果
            string ErrorStr = string.Empty;

            if (!string.IsNullOrEmpty(opearType))
            {
                if (opearType == "0")        //只能执行采购商信息修改操作
                {
                    string mobile = Utils.GetFormValue("Mobile");
                    if (!Utils.IsMobile(mobile))
                    {
                        Utils.ResponseMeg(false, "采购商手机号码填写错误!");
                        return;
                    }
                    result = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().UpdateBuyerContact(OrderNum, Utils.GetFormValue("CompanyName"), Utils.GetFormValue("LinkName"), mobile, Utils.GetFormValue("Address"));
                }
                else if (opearType == "5")         //服务备注
                {
                    result = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().UpdateServiceRemark(OrderNum, Utils.GetFormValue("Content"));
                }
                else if (opearType == "6")      //修改特殊备注
                {
                    result = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().UpdateBuyerRemark(OrderNum, Utils.GetFormValue("Content"));
                }
                else if (opearType == "InsertAccount")  //支付前处理操作
                {
                    string  orderId   = Utils.GetFormValue("orderId");
                    string  orderNo   = Utils.GetFormValue("orderNo");
                    string  sellCId   = Utils.GetFormValue("sellcId");
                    string  batchNo   = "";
                    string  total     = Utils.GetFormValue("total");
                    string  currUId   = SiteUserInfo.ID;
                    string  currCId   = SiteUserInfo.CompanyID;
                    string  payType   = Utils.GetFormValue("PayType");
                    decimal IntoRatio = decimal.Parse(AlipayParameters.TongyeFee);      //平台交易费
                    EyouSoft.IBLL.TicketStructure.ITicketCompanyAccount bll = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance();
                    //当前只能判断支付宝接口的帐户
                    IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = bll.GetTicketCompanyAccountList(sellCId);
                    EyouSoft.Model.TicketStructure.ItemType?         itemType        = EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单;                                                  //流水金额记录项类型
                    IList <EyouSoft.Model.TicketStructure.TicketPay> payList         = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().GetPayList(orderId, itemType, orderNo, ""); //获取交易记录
                    EyouSoft.Model.TicketStructure.TicketAccountType accountType     = (EyouSoft.Model.TicketStructure.TicketAccountType)Utils.GetInt(payType);                              //获取支付类型
                    string sellAccount = "";                                                                                                                                                 //供应商账户
                    EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == accountType);                                             //获取供应商账户实体
                    if (accountModel != null)
                    {
                        sellAccount = accountModel.AccountNumber;//赋值供应商账户
                    }
                    else
                    {
                        Utils.ResponseMegError();//如果对应接口账户不存在则输出失败
                        return;
                    }
                    if (payList == null || payList.Count == 0 || (payList != null && payList.Where(i => i.PayState == EyouSoft.Model.TicketStructure.PayState.交易完成).Count() < 1))
                    {
                        result = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().PayBefore(orderId, orderNo, sellAccount, IntoRatio, SiteUserInfo.ID, SiteUserInfo.CompanyID, Convert.ToDecimal(total), accountType, sellCId, "", out batchNo);
                    }
                    else if (payList != null && payList.Where(i => i.PayState == EyouSoft.Model.TicketStructure.PayState.交易完成).Count() > 0)
                    {
                        Utils.ResponseMeg(false, "你已经支付过,并且交易完成了!");
                        return;
                    }
                    else
                    {
                        result = true;
                    }
                }
                else        //退/作废/改/签操作
                {
                    EyouSoft.Model.TicketStructure.OrderChangeInfo changeinfo = new EyouSoft.Model.TicketStructure.OrderChangeInfo();
                    changeinfo.ChangeState     = EyouSoft.Model.TicketStructure.OrderChangeState.申请;
                    changeinfo.ChangeTime      = DateTime.Now;
                    changeinfo.ChangeUId       = this.SiteUserInfo.ID;
                    changeinfo.OrderId         = OrderNum;
                    changeinfo.ChangeId        = Guid.NewGuid().ToString();
                    changeinfo.Travellers      = new List <string>();
                    changeinfo.ChangeUFullName = SiteUserInfo.UserName;
                    //IList<string> ids = null;
                    string strids = Utils.GetFormValue("CheckperIds");
                    if (string.IsNullOrEmpty(strids))
                    {
                        Utils.ResponseMeg(false, "请选择旅客!");
                        return;
                    }
                    else
                    {
                        //ids = new List<string>();
                        foreach (string item in StringValidate.Split(strids, ","))
                        {
                            changeinfo.Travellers.Add(item);
                        }
                    }
                    IsTravellerStateSucces(changeinfo.Travellers);   //判断某旅客状态是否为退票成功
                    switch (opearType)
                    {
                    case "1":            //退票
                        changeinfo.RefundTicketType = (EyouSoft.Model.TicketStructure.RefundTicketType)Enum.Parse(typeof(EyouSoft.Model.TicketStructure.RefundTicketType), Utils.GetFormValue("Content"));
                        changeinfo.ChangeType       = EyouSoft.Model.TicketStructure.OrderChangeType.退票;
                        changeinfo.ChangeState      = EyouSoft.Model.TicketStructure.OrderChangeState.申请;
                        break;

                    case "2":        //作废
                        changeinfo.RefundTicketType = (EyouSoft.Model.TicketStructure.RefundTicketType)Enum.Parse(typeof(EyouSoft.Model.TicketStructure.RefundTicketType), Utils.GetFormValue("Content"));
                        changeinfo.ChangeType       = EyouSoft.Model.TicketStructure.OrderChangeType.作废;
                        changeinfo.ChangeState      = EyouSoft.Model.TicketStructure.OrderChangeState.申请;
                        break;

                    case "3":        //改期
                        changeinfo.ChangeRemark = Utils.GetFormValue("Content");
                        changeinfo.ChangeType   = EyouSoft.Model.TicketStructure.OrderChangeType.改期;
                        changeinfo.ChangeState  = EyouSoft.Model.TicketStructure.OrderChangeState.申请;
                        break;

                    case "4":        //改签
                        changeinfo.ChangeRemark = Utils.GetFormValue("Content");
                        changeinfo.ChangeType   = EyouSoft.Model.TicketStructure.OrderChangeType.改签;
                        changeinfo.ChangeState  = EyouSoft.Model.TicketStructure.OrderChangeState.申请;
                        break;

                    default:
                        break;
                    }
                    switch (EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance().SetOrderChange(changeinfo))
                    {
                    case 0:
                        result = true;
                        break;

                    case 1:
                        result   = false;
                        ErrorStr = "不能申请旅客状态变更!";
                        break;

                    case 2:
                        result = false;
                        break;
                    }
                }
                if (result)     //根据操作结果提示
                {
                    Utils.ResponseMeg(true, "操作成功!");
                    return;
                }
                else
                {
                    if (string.IsNullOrEmpty(ErrorStr))
                    {
                        ErrorStr = "操作失败!";
                    }
                    Utils.ResponseMeg(false, ErrorStr);
                    return;
                }
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //密钥
            string key = TenpayParameters.Key;

            //创建PayResponseHandler实例
            PayResponseHandler resHandler = new PayResponseHandler(Context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                //交易单号
                string trade_no = resHandler.getParameter("transaction_id");
                //金额金额,以分为单位
                decimal total_fee = decimal.Parse(resHandler.getParameter("total_fee")) / 100;
                //支付结果
                string pay_result = resHandler.getParameter("pay_result");
                //订单号
                string order_no = resHandler.getParameter("sp_billno");
                //支付账号
                string buyer_email = "";


                EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();
                EyouSoft.Model.TicketStructure.OrderInfo   info     = orderBll.GetOrderInfoByNo(order_no);
                if (info.OrderState == EyouSoft.Model.TicketStructure.OrderState.审核通过)
                {
                    IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(info.SupplierCId); //获取供应商所有账户
                    string sellAccount = "";                                                                                                                                                             //供应商账户
                    EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == EyouSoft.Model.TicketStructure.TicketAccountType.财付通);                //获取供应商账户实体
                    if (accountModel != null)
                    {
                        sellAccount = accountModel.AccountNumber;//赋值供应商账户
                    }
                    string  batchNo   = "";
                    decimal IntoRatio = decimal.Parse(TenpayParameters.TongyeFee);
                    IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList(info.OrderId, EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单, order_no, null);
                    if ("0".Equals(pay_result))
                    {
                        if (payList != null && payList.Count > 0)
                        {
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }
                        else
                        {
                            orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, total_fee, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }

                        //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示show.aspx页面.
                        resHandler.doShow(string.Format("/AirTickets/tenpay/directpay/Show.aspx?order_no={0}&total_fee={1}&result={2}", order_no, total_fee, "1"));
                    }
                    else
                    {
                        //当做不成功处理
                        if (payList != null && payList.Count > 0)
                        {
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }
                        else
                        {
                            orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, total_fee, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }
                        resHandler.doShow(string.Format("/AirTickets/tenpay/directpay/Show.aspx?order_no={0}&total_fee={1}&result={2}", order_no, total_fee, "0"));
                        //Response.Write("支付失败");
                    }
                }

                //获取debug信息,建议把debug信息写入日志,方便定位问题
                //string debuginfo = resHandler.getDebugInfo();
                //Response.Write("<br/>debuginfo:" + debuginfo + "<br/>");
            }
            else
            {
                Response.Write("认证签名失败");
            }
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string method = Utils.GetFormValue("method");

            this.Title = "支付-组团预定/散拼-机票";
            if (method != "InsertAccount")
            {
                this.Master.Naviagtion = AirTicketNavigation.团队预定散拼;
                orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();
                string orderId = Utils.GetQueryStringValue("orderId");
                orderInfo = orderBll.GetOrderInfoById(orderId);
                EyouSoft.Model.TicketStructure.TicketFlightCompany companyModel = EyouSoft.BLL.TicketStructure.TicketFlightCompany.CreateInstance().GetTicketFlightCompany(orderInfo.FlightId);
                if (companyModel != null)
                {
                    flightName = companyModel.AirportName;
                }


                companyName       = SiteUserInfo.CompanyName;
                contactName       = SiteUserInfo.ContactInfo.ContactName;
                address           = "";
                moible            = SiteUserInfo.ContactInfo.Mobile;
                buyInsCount       = orderInfo.Travellers.Where(i => i.IsBuyIns).Count();       //保险数
                buyItineraryCount = orderInfo.Travellers.Where(i => i.IsBuyItinerary).Count(); //行程单数
                supplierInfo      = EyouSoft.BLL.TicketStructure.TicketSupplierInfo.CreateInstance().GetSupplierInfo(orderInfo.SupplierCId);
                acl_rptCustomerList.DataSource = orderInfo.Travellers;
                acl_rptCustomerList.DataBind();
                list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(orderInfo.SupplierCId);
            }
            else
            {
                string  payWhich    = Utils.GetFormValue("paywhich");
                string  freightType = Utils.GetFormValue("freightType");
                string  orderId     = Utils.GetFormValue("orderId");
                string  orderNo     = Utils.GetFormValue("orderNo");
                string  sellCId     = Utils.GetFormValue("sellcId");
                string  batchNo     = "";
                decimal total       = decimal.Parse(Utils.GetFormValue("total"));
                string  companyName = Utils.GetFormValue("companyname");
                string  contactName = Utils.GetFormValue("contactname");
                string  moible      = Utils.GetFormValue("moible");
                string  address     = Utils.GetFormValue("address");
                string  currUId     = SiteUserInfo.ID;
                string  currCId     = SiteUserInfo.CompanyID;
                string  theUrl      = GetPayUrl(payWhich, orderNo, total, freightType);
                decimal IntoRatio   = decimal.Parse(AlipayParameters.TongyeFee);                                                                         //平台交易费
                orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();
                orderBll.UpdateBuyerContact(orderId, companyName, contactName, moible, address);                                                         //修改订单联系方式
                EyouSoft.Model.TicketStructure.ItemType?         itemType = EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单;                         //流水金额记录项类型
                IList <EyouSoft.Model.TicketStructure.TicketPay> payList  = orderBll.GetPayList(orderId, itemType, orderNo, "");                         //获取交易记录
                list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(sellCId);                          //获取供应商所有账户
                EyouSoft.Model.TicketStructure.TicketAccountType accountType = (EyouSoft.Model.TicketStructure.TicketAccountType)Utils.GetInt(payWhich); //获取支付类型
                string sellAccount = "";                                                                                                                 //供应商账户
                EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == accountType);             //获取供应商账户实体
                if (accountModel != null)
                {
                    sellAccount = accountModel.AccountNumber; //赋值供应商账户
                }
                else
                {
                    Utils.ResponseMegError(); //如果对应接口账户不存在则输出失败
                    return;
                }
                if (payList == null || payList.Count == 0 || (payList != null && payList.Where(i => i.PayState == EyouSoft.Model.TicketStructure.PayState.交易完成).Count() < 1))//如果交易记录不存在或交易状态不是完成则添加支付前交易记录
                {
                    if (orderBll.PayBefore(orderId, orderNo, sellAccount, IntoRatio, SiteUserInfo.ID, SiteUserInfo.CompanyID, total, accountType, sellCId, "", out batchNo))
                    {
                        Utils.ResponseMeg(true, theUrl);
                    }
                    else
                    {
                        Utils.ResponseMegError();
                    }
                }

                else if (payList != null && payList.Where(i => i.PayState == EyouSoft.Model.TicketStructure.PayState.交易完成).Count() > 0)
                {
                    Utils.ResponseMeg(false, "你已经支付过,并且交易完成了!");
                }
                else
                {
                    Utils.ResponseMeg(true, theUrl);
                }
            }
        }
Ejemplo n.º 10
0
        protected string orderid;      //订单编号

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "完成-组团预定/散拼-机票";
            SortedDictionary <string, string> sArrary = GetRequestGet();
            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            string partner       = AlipayParameters.Partner;       //合作身份者ID
            string key           = AlipayParameters.Key;           //安全检验码
            string input_charset = AlipayParameters.Input_Charset; //字符编码格式 目前支持 gbk 或 utf-8
            string sign_type     = AlipayParameters.SignType;      //加密方式 不需修改
            string transport     = "http";                         //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http

            //////////////////////////////////////////////////////////////////////////////////////////////

            if (sArrary.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify   = new AlipayNotify(sArrary, Request.QueryString["notify_id"], partner, key, input_charset, sign_type, transport);
                string       responseTxt = aliNotify.ResponseTxt;       //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
                string       sign        = Request.QueryString["sign"]; //获取支付宝反馈回来的sign结果
                string       mysign      = aliNotify.Mysign;            //获取通知返回后计算后(验证)的加密结果

                ////写日志记录(若要调试,请取消下面两行注释)
                //string sWord = "Return_URL:responseTxt=" + responseTxt + "\n return_url_log:sign=" + Request.QueryString["sign"] + "&mysign=" + mysign + "\n return回来的参数:" + aliNotify.PreSignStr;
                //AlipayFunction.log_result(Server.MapPath("../log/" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord);

                //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                if (responseTxt == "true" && sign == mysign)//验证成功
                {
                    //请根据您的业务逻辑来编写程序(以下代码仅作参考)
                    //获取支付宝的通知返回参数
                    string trade_no = Request.QueryString["trade_no"];              //支付宝交易号
                    order_no  = Request.QueryString["out_trade_no"];                //获取订单号
                    total_fee = Request.QueryString["total_fee"];                   //获取总金额
                    string subject           = Request.QueryString["subject"];      //商品名称、订单名称
                    string body              = Request.QueryString["body"];         //商品描述、订单备注、描述
                    string buyer_email       = Request.QueryString["buyer_email"];  //买家支付宝账号
                    string trade_status      = Request.QueryString["trade_status"]; //交易状态
                    int    sOld_trade_status = 0;                                   //获取商户数据库中查询得到该笔交易当前的交易状态
                    proName      = string.Format("同业114机票平台(订单号:{0})", order_no);
                    buyerAccount = buyer_email;
                    string notify_id   = Request.QueryString["notify_id"];
                    string notify_time = Request.QueryString["notify_time"];
                    string buyer_id    = Request.QueryString["buyer_id"];

                    //打印页面
                    //lbTrade_no.Text = trade_no;
                    //lbOut_trade_no.Text = order_no;
                    //lbTotal_fee.Text = total_fee;
                    //lbSubject.Text = subject;
                    //lbBody.Text = body;
                    //lbBuyer_email.Text = buyer_email;
                    //lbTrade_status.Text = trade_status;
                    //lbVerify.Text = "验证成功";

                    //lblNotifyId.Text = notify_id;
                    //lblNotifyTime.Text = notify_time;
                    //lblBuyerID.Text = buyer_id;

                    //假设:
                    //sOld_trade_status="0"	表示订单未处理;
                    //sOld_trade_status="1"	表示交易成功(TRADE_FINISHED/TRADE_SUCCESS)

                    EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();
                    EyouSoft.Model.TicketStructure.OrderInfo   info     = orderBll.GetOrderInfoByNo(order_no);
                    orderid = info.OrderId;
                    if (info.FreightType == EyouSoft.Model.TicketStructure.FreightType.单程)
                    {
                        proDetail = string.Format("订单号:{0}/航程信息:单程 {1}/{2}至{3}/", order_no, info.LeaveTime.ToString("yyyy-MM-dd"), info.HomeCityName, info.DestCityName);
                    }
                    else
                    {
                        proDetail = string.Format("订单号:{0}/航程信息:去程 {1}/{2}至{3}/回程 {4}/{5}-{6}", order_no, info.LeaveTime.ToString("yyyy-MM-dd"), info.HomeCityName, info.DestCityName, info.ReturnTime, info.DestCityName, info.HomeCityName);
                    }
                    if (info.OrderState == EyouSoft.Model.TicketStructure.OrderState.审核通过)
                    {
                        IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(info.SupplierCId); //获取供应商所有账户
                        string sellAccount = "";                                                                                                                                                             //供应商账户
                        EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == EyouSoft.Model.TicketStructure.TicketAccountType.支付宝);                //获取供应商账户实体
                        if (accountModel != null)
                        {
                            sellAccount = accountModel.AccountNumber;//赋值供应商账户
                        }
                        string batchNo = "";
                        //decimal IntoRatio = EyouSoft.BLL.TicketStructure.TicketSupplierInfo.CreateInstance().GetSupplierInfo(info.SupplierCId).IntoRatio;
                        decimal IntoRatio = decimal.Parse(AlipayParameters.TongyeFee);
                        IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList(info.OrderId, EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单, order_no, null);


                        if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                        {
                            //为了保证不被重复调用,或重复执行数据库更新程序,请判断该笔交易状态是否是订单未处理状态
                            //string order_no="201011080010";
                            //string trade_no="2010110861004313";
                            //string total_fee="0.01";
                            //string buyer_email="*****@*****.**";
                            //string seller_mailer="*****@*****.**";

                            if (payList != null && payList.Count > 0)
                            {
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }

                            resultMess = "交易成功";
                            //if (sOld_trade_status < 1)
                            //{
                            //    //根据订单号更新订单,把订单状态处理成交易成功
                            //}
                        }
                        else
                        {
                            if (payList != null && payList.Count > 0)
                            {
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            //Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                            resultMess = "交易失败";
                        }
                    }
                    else
                    {
                        resultMess = info.OrderState.ToString();
                    }
                    // 请根据您的业务逻辑来编写程序(以上代码仅作参考)
                }
                else//验证失败
                {
                    resultMess = "验证失败";
                }
            }
            else
            {
                resultMess = "无返回参数";
            }
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Error += new EventHandler(Page_Error);
            SortedDictionary <string, string> sArrary = GetRequestPost();
            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            string partner       = AlipayParameters.Partner;       //合作身份者ID
            string key           = AlipayParameters.Key;           //安全检验码
            string input_charset = AlipayParameters.Input_Charset; //字符编码格式 目前支持 gbk 或 utf-8
            string sign_type     = AlipayParameters.SignType;      //加密方式 不需修改
            string transport     = "http";                         //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http

            //////////////////////////////////////////////////////////////////////////////////////////////

            if (sArrary.Count > 0)//判断是否有带返回参数
            {
                AlipayNotify aliNotify   = new AlipayNotify(sArrary, Request.Form["notify_id"], partner, key, input_charset, sign_type, transport);
                string       responseTxt = aliNotify.ResponseTxt; //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
                string       sign        = Request.Form["sign"];  //获取支付宝反馈回来的sign结果
                string       mysign      = aliNotify.Mysign;      //获取通知返回后计算后(验证)的加密结果

                ////写日志记录(若要调试,请取消下面两行注释)
                string sWord = "Notify_URL:responseTxt=" + responseTxt + "\n notify_url_log:sign=" + Request.Form["sign"] + "&mysign=" + mysign + "\n notify回来的参数:" + aliNotify.PreSignStr;


                //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                if (responseTxt == "true" && sign == mysign)//验证成功
                {
                    //请根据您的业务逻辑来编写程序(以下代码仅作参考)
                    //获取支付宝的通知返回参数
                    string trade_no     = Request.Form["trade_no"];     //支付宝交易号
                    string order_no     = Request.Form["out_trade_no"]; //获取订单号
                    string total_fee    = Request.Form["total_fee"];    //获取总金额
                    string subject      = Request.Form["subject"];      //商品名称、订单名称
                    string body         = Request.Form["body"];         //商品描述、订单备注、描述
                    string buyer_email  = Request.Form["buyer_email"];  //买家支付宝账号
                    string trade_status = Request.Form["trade_status"]; //交易状态



                    //string notify_id = Request.QueryString["notify_id"];
                    //string notify_time = Request.QueryString["notify_time"];
                    //string buyer_id = Request.QueryString["buyer_id"];

                    //string gmt_create = Request.QueryString["gmt_create"];
                    //string gmt_payment = Request.QueryString["gmt_payment"];

                    sWord += "\n TRUE";


                    //表示交易成功(TRADE_FINISHED/TRADE_SUCCESS)
                    EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();

                    EyouSoft.Model.TicketStructure.OrderInfo info = orderBll.GetOrderInfoByNo(order_no);
                    if (info.OrderState == EyouSoft.Model.TicketStructure.OrderState.审核通过)
                    {
                        IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(info.SupplierCId); //获取供应商所有账户
                        string sellAccount = "";                                                                                                                                                             //供应商账户
                        EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == EyouSoft.Model.TicketStructure.TicketAccountType.支付宝);                //获取供应商账户实体
                        if (accountModel != null)
                        {
                            sellAccount = accountModel.AccountNumber;//赋值供应商账户
                        }
                        string  batchNo   = "";
                        decimal IntoRatio = decimal.Parse(AlipayParameters.TongyeFee);
                        IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList(info.OrderId, EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单, order_no, null);


                        if (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS")
                        {
                            sWord += "/n 交易成功";
                            //为了保证不被重复调用,或重复执行数据库更新程序,请判断该笔交易状态是否是订单未处理状态
                            //string order_no="201011080010";
                            //string trade_no="2010110861004313";
                            //string total_fee="0.01";
                            //string buyer_email="*****@*****.**";
                            //string seller_mailer="*****@*****.**";
                            if (payList != null && payList.Count > 0)
                            {
                                sWord += "/n you";
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                sWord += "/n meiyou";
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                        }
                        else
                        {
                            sWord += "/n 交易失败";
                            if (payList != null && payList.Count > 0)
                            {
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                            else
                            {
                                orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                                orderBll.PayAfterCallBack(trade_no, decimal.Parse(total_fee), EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, buyer_email, "", order_no, DateTime.Now, "");
                            }
                        }

                        AlipayFunction.log_result(Server.MapPath("../log/" + order_no + "-" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord);
                    }
                    Response.Write("success");
                }
                else//验证失败
                {
                    //sWord += "\n FAIL";
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }