///// <summary>
        ///// 世联支付,过户。
        ///// </summary>
        ///// <param name="dt"></param>
        ///// <returns></returns>
        //private ReceivePayMessage AssertPay(LoggingSessionInfo pLoggingSessionInfo, string customerID, string userID, string detailID, DateTime dt)
        //{
        //    //获取会员信息
        //    VipBLL vbll = new VipBLL(pLoggingSessionInfo);
        //    VipEntity vipEntity = vbll.GetVipDetailByVipID(userID);
        //    if (vipEntity == null)
        //    {
        //        throw new Exception("没有找到该用户信息");
        //    }

        //    //获取订单相关信息。
        //    WXHousePrePaymentBLL mappingBll = new WXHousePrePaymentBLL(pLoggingSessionInfo);
        //    WXHousePrePaymentEntity pay = mappingBll.GetWXHousePrePayment(detailID, customerID);
        //    if (pay == null)
        //    {
        //        throw new Exception("未找到该用户的订单信息!");
        //    }

        //    //获取楼盘详细信息
        //    WXHouseDetailBLL wxhdbll = new WXHouseDetailBLL(pLoggingSessionInfo);
        //    DataSet ds = wxhdbll.GetHouseDetailByDetailID(customerID, detailID);
        //    HouseDetailViewModel detailEntity = null;
        //    if (ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
        //    {
        //        detailEntity = DataTableToObject.ConvertToObject<HouseDetailViewModel>(ds.Tables[0].Rows[0]);
        //    }
        //    if (detailEntity == null) throw new Exception("该楼盘不存在。");

        //    ReceivePayMessage pEnity = new ReceivePayMessage();
        //    pEnity.MerchantID = HuaAnConst.MerchantID;
        //    pEnity.Merchantdate = dt.ToString("yyyyMMdd");
        //    pEnity.OrderNO = pay.OrderNo;  //订单号
        //    pEnity.Totalpay = pay.RealPay.HasValue ? pay.RealPay.Value.ToString() : null;
        //    pEnity.Assignbuyer = vipEntity.VipCode;  //客户协议号
        //    pEnity.Assbuyername = vipEntity.VipName;
        //    pEnity.Assbuyermobile = vipEntity.Phone;
        //    pEnity.Totaldiscount = "0";
        //    pEnity.Totaldeduction = "0";
        //    pEnity.Actualtotal = pay.RealPay.HasValue ? pay.RealPay.Value.ToString() : null;
        //    pEnity.Feetype = "0";
        //    pEnity.Fee = "0";
        //    pEnity.Logisticsinfo = m_logisticsinfo;  //交易号

        //    Goodsinfo info = new Goodsinfo
        //    {
        //        id = detailEntity.DetailID.ToString(),
        //        Goodsname = detailEntity.HouseName,
        //        GoodsURL = "",
        //        Goodspicture = "",
        //        Goodsmodle = detailEntity.HouseID.ToString(),
        //        Goodsdesc = "",
        //        Goodsunit = "",
        //        Goodsprice = "",
        //        Goodsquantity = "",
        //        Goodsdiscount = "",
        //        Goodsdeduction = "",
        //        Goodstotalpay = "",
        //        Goodsactualtotal = detailEntity.RealPay.ToString(),
        //        memo = ""
        //    };
        //    //用于回调更新 &=>&amp;
        //    pEnity.Commonreturn = "";
        //    pEnity.ISDirectRedeem = "0";
        //    //回调url
        //    pEnity.PageURL = string.Format(HuaAnConst.CallBackPageUrl, "TransferCallBack");
        //    pEnity.Memo = "";
        //    pEnity.RetURL = "";

        //    return pEnity;
        //}
        #endregion

        #region  购买基金
        /// <summary>
        /// 购买基金 2101。
        /// </summary>
        ///
        //http://222.66.40.26/huaan-worldunion/t/ReservationPurchase.action
        private void Buy()
        {
            string mappingID = "123", prePaymentID = "456";
            //世联通讯流水号
            string   seqNO = "20141517";
            DateTime dt    = DateTime.Now;

            //处理调用华安请求From表单对象
            Receive.ReceiveBuyMessage pEnity = AssignmentBuy(mappingID, prePaymentID, dt);   //基金购买
            string strContent            = Utility.GetRequsetXml(pEnity);
            HanAnRequestMessage rMessage = new HuaAnFactory().FormRequestContent(dt, strContent, HuaAnConfigurationAppSitting.Buy, seqNO);

            Model = rMessage;

            /*   回调回来的。
             *  http://o2oapi.aladingyidong.com/ApplicationInterface/Project/HuaAn/HuaAnCallBack.aspx?type=Project&req={}&action=PayCallBack
             *
             * <?xml version="1.0" encoding="UTF-8"?
             *
             * ><order><MerchantID>10000008</MerchantID><Retcode>0000</Retcode><Merchantdate>20140529</Merchantdate><Orgtotalamt>20000</Orgtotalamt><Assignbuyer>Vip00003698</Assignbu
             *
             * yer><Assbuyername>谢伯恩
             *
             * </Assbuyername><Assbuyermobile>18621698771</Assbuyermobile><Assbuyeridtp>0</Assbuyeridtp><Logisticsinfo>08889230000002725</Logisticsinfo><Fee>0</Fee><Fundtype>1</Fundt
             *
             * ype><Commonreturn>mappingID=123&prePaymentID=456</Commonreturn></order>
             */
        }
        /// <summary>
        /// 基金赎回。
        /// </summary>
        /// <param name="rRequest"></param>
        /// <returns></returns>
        private void FundRansom()
        {
            string seqNO = HuaAnFactory.GenerateSeqNO();
            var    loggingSessionInfo = Default.GetBSLoggingSession(m_customerID, m_userID);

            //处理调用华安请求From表单对象
            DateTime             dt     = DateTime.Now;
            ReceiveRansomMessage pEnity = AssertRanson(loggingSessionInfo, m_customerID, m_userID, m_detailID, dt);
            string strContent           = Utility.GetRequsetXml(pEnity);

            //HanAnRequestMessage rMessage = new HuaAnFactory().FormRequestContent(dt, strContent, HuaAnConst.Redemption, seqNO);

            Model = new HuaAnFactory().FormRequestContent(dt, Utility.GetRequsetXml(pEnity), HuaAnConfigurationAppSitting.Redemption, seqNO);
        }
        /// <summary>
        /// 获取华安接口中:每万份收益、年化收益率(5002)
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        private void GetProfit()
        {
            DateTime dt = DateTime.Now;

            string seqNO = HuaAnFactory.GenerateSeqNO();

            //处理调用华安请求From表单对象
            //ReceiveProfitSelectMessage entity = AssignmentProfit(dt);  //查询年化收益率
            // ReceivePaySingleQueryMessage entity = AssignmentSingleQuery(dt);  //3001
            ReceiveFundProfitMessage entity = Assignment5000(dt);   //500
            string strContent            = Utility.GetRequsetXml(entity);
            HanAnRequestMessage rMessage = new HuaAnFactory().FormRequestContent(dt, strContent, 5001, seqNO);

            IDictionary <string, string> dic = HuaAnFactory.SetFormPara(rMessage);
            HttpWebResponse webResponse      = HttpHelper.CreatePostHttpResponse(HuaAnConfigurationAppSitting.ReservationServletUrl, dic, null, null, Encoding.UTF8, null);
            string          content          = HttpHelper.GetResponseString(webResponse);

            Hashtable    htComm = GetCommonreturn(content);
            HanAnMessage msg    = new HanAnMessage
            {
                verNum  = htComm["verNum"].ToString(),
                sysdate = htComm["sysdate"].ToString(),
                systime = htComm["systime"].ToString(),
                txcode  = htComm["txcode"].ToString(),
                seqNO   = htComm["seqNO"].ToString(),
                maccode = htComm["maccode"].ToString(),
                content = htComm["content"].ToString()
            };


            if (msg != null)
            {
                string decrypt = Utility.AESDecrypt(msg.content, HuaAnConfigurationAppSitting.AesKey);
                SendFundProfitMessage profitMsg = GetProfitMsg(decrypt);
                string[] profitN = profitMsg.Content.Split('\n');
                foreach (var item in profitN)
                {
                    string   profit      = item;
                    string[] profitArray = profit.Split('|');
                }
                //   string[] profit = profitMsg.Content.Split('|');
            }

            Model = rMessage;
        }
        /// <summary>
        /// 支付 2001
        /// </summary>
        //http://222.66.40.26/huaan-worldunion/t/ReservationPay.action
        private void Pay()
        {
            // string mappingID = "123", prePaymentID = "456";
            //世联通讯流水号
            string   seqNO = "20141517";
            DateTime dt    = DateTime.Now;

            //处理调用华安请求From表单对象
            Receive.ReceivePayMessage pEnity = Pay(DateTime.Now);   //基金购买
            string strContent            = Utility.GetRequsetXml(pEnity);
            HanAnRequestMessage rMessage = new HuaAnFactory().FormRequestContent(dt, strContent, HuaAnConfigurationAppSitting.Pay, seqNO);

            Model = rMessage;

            /*
             *
             */
        }
        /// <summary>
        /// 基金赎回 2201
        /// </summary>
        //http://222.66.40.26/huaan-worldunion/t/ReservationRedeem.action
        private void ShuHui()
        {
            //string mappingID = "123", prePaymentID = "456";
            //世联通讯流水号
            string   seqNO = "2014154501";
            DateTime dt    = DateTime.Now;

            //处理调用华安请求From表单对象
            ReceiveRansomMessage pEnity  = Ranson(DateTime.Now);
            string strContent            = Utility.GetRequsetXml(pEnity);
            HanAnRequestMessage rMessage = new HuaAnFactory().FormRequestContent(dt, strContent, HuaAnConfigurationAppSitting.Redemption, seqNO);

            Model = rMessage;

            /*
             * http://o2oapi.aladingyidong.com/ApplicationInterface/Project/HuaAn/HuaAnCallBack.aspx?type=Project&req={}&action=RansomCallBack
             *
             */
        }
        /// <summary>
        /// 基金购买
        /// </summary>
        /// <param name="reqContent"></param>
        /// <returns></returns>
        public void BuyFund()
        {
            DateTime dt                 = DateTime.Now;
            string   orderNO            = HuaAnFactory.GenerateSeqNO();
            var      loggingSessionInfo = Default.GetBSLoggingSession(m_customerID, m_userID);

            WXHouseDetailBLL    wxhdbll = new WXHouseDetailBLL(loggingSessionInfo);
            WXHouseDetailEntity wxhde   = wxhdbll.GetDetailByID(m_customerID, m_detailID);

            if (wxhde == null)
            {
                throw new Exception("没有找到该楼盘信息。");
            }

            string realPay = wxhde.RealPay.ToString();

            //产生订单号
            TUnitExpandBLL TUeBll = new TUnitExpandBLL(loggingSessionInfo);
            // string seqNO = TUeBll.GetUnitOrderNo(loggingSessionInfo, "ed7d227564b54778a4cffb7335a8b078");

            string seqNO = HuaAnFactory.GenerateSeqNO();
            //1判断会员楼盘明细映射是否存在记录
            WXHouseVipMappingBLL bll = new WXHouseVipMappingBLL(loggingSessionInfo);
            DataSet ds        = bll.VerifWXHouseVipMapping(m_userID, m_detailID, m_customerID);
            Guid    mappingID = Guid.NewGuid();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                //1.1存在
                mappingID = new Guid(ds.Tables[0].Rows[0]["MappingID"].ToString());
            }
            else
            {
                //1.2不存在
                //插入会员楼盘明细映射表
                WXHouseVipMappingEntity WXHvmEntity = new WXHouseVipMappingEntity();
                WXHvmEntity.MappingID  = mappingID;
                WXHvmEntity.DetailID   = new Guid(m_detailID);
                WXHvmEntity.CustomerID = m_customerID;
                WXHvmEntity.VIPID      = m_userID;
                //WXHvmEntity.HouseSaleNo = "";//预售号码
                WXHvmEntity.ReserveNo = orderNO;
                //WXHvmEntity.HoseMessage = "";//房子描述信息
                WXHvmEntity.HoseState = 0;
                WXHvmEntity.IsBuyHose = (int)PayHouseStateEnum.Unknown;
                WXHvmEntity.IsBuyFund = 1;
                WXHvmEntity.IsRedeem  = (int)FundStateEnum.Unknown;
                bll.Create(WXHvmEntity);
            }
            //1.3插入交易手续费表
            Guid feeID = Guid.NewGuid();
            WXHouseTradeFeeEntity WXHtfEntity = new WXHouseTradeFeeEntity();

            WXHtfEntity.FeeID      = feeID;
            WXHtfEntity.TradeType  = 0;
            WXHtfEntity.FeeType    = 0;
            WXHtfEntity.Fee        = 0;
            WXHtfEntity.CustomerID = m_customerID;
            WXHouseTradeFeeBLL WXHtfBll = new WXHouseTradeFeeBLL(loggingSessionInfo);

            WXHtfBll.Create(WXHtfEntity);
            ////1.4插入预付款订单
            //WXHousePrePaymentEntity WXHppEntity = new WXHousePrePaymentEntity();
            //Guid prePaymentID = Guid.NewGuid();
            //WXHppEntity.PrePaymentID = prePaymentID;
            //WXHppEntity.FeeID = feeID;
            //WXHppEntity.MappingID = mappingID;
            //WXHppEntity.OrderNo = orderNO;
            //WXHppEntity.RealPay = Convert.ToDecimal(realPay);
            //WXHppEntity.OrderDate = dt.ToString();
            //WXHppEntity.CustomerID = m_customerID;
            //WXHousePrePaymentBLL WXHppBll = new WXHousePrePaymentBLL(loggingSessionInfo);
            //WXHppBll.Create(WXHppEntity);

            //创建会员客户协议号映射
            //CreateClientAgreementNO(rp, loggingSessionInfo);

            //处理调用华安请求From表单对象
            Receive.ReceiveBuyMessage pEnity = new Receive.ReceiveBuyMessage();
            pEnity.MerchantID   = HuaAnConfigurationAppSitting.MerchantID;
            pEnity.Merchantdate = dt.ToString("yyyyMMdd");
            pEnity.Totalamt     = Convert.ToDecimal(realPay);
            VipBLL    vbll = new VipBLL(loggingSessionInfo);
            VipEntity ve   = vbll.GetVipDetailByVipID(m_userID);

            pEnity.Assignbuyer    = ve.VipCode;
            pEnity.Assbuyername   = ve.VipName;
            pEnity.Assbuyermobile = ve.Phone;
            pEnity.Fee            = "0";
            //用于回调更新
            string strCommon = "CustomerID=" + m_customerID;

            strCommon += "|UserID=" + m_userID;
            strCommon += "|HouseDetailID=" + m_detailID;
            strCommon += "|MappingID=" + mappingID.ToString();
            //  strCommon += "|PrePaymentID=" + prePaymentID.ToString();
            strCommon          += "|ToPageURL=http://o2oapi.aladingyidong.com/ApplicationInterface/Project/HuaAn/HuaAnCallBack.aspx?action=BuyCallBack";
            pEnity.Commonreturn = strCommon;
            //回调url
            pEnity.RetURL  = "";
            pEnity.PageURL = string.Format(HuaAnConfigurationAppSitting.CallBackPageUrl, "BuyCallBack");
            //pEnity.PageURL = "http://o2oapi.aladingyidong.com/ApplicationInterface/Project/HuaAn/HuaAnCallBack.aspx?action=BuyCallBack";
            pEnity.Memo = "";
            //请求表单对象
            var fromList = new HuaAnFactory().FormRequestContent(dt, Utility.GetRequsetXml(pEnity), HuaAnConfigurationAppSitting.Buy, orderNO);
            var rdData   = new PayEntityRD();

            rdData.FormData = fromList;
            //华安url
            rdData.Url = HuaAnConfigurationAppSitting.ReservationPurchaseUrl;
            //请求表单对象
            Model = new HuaAnFactory().FormRequestContent(dt, Utility.GetRequsetXml(pEnity), HuaAnConfigurationAppSitting.Buy, seqNO);
        }