/// <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);
        }
Exemple #2
0
        /// <summary>
        /// 购买回调。
        /// </summary>
        /// <returns></returns>
        public static void BuyCallBack(string content)
        {
            Loggers.DEFAULT.Debug(new DebugLogInfo {
                Message = "BuyCallBack: " + DateTime.Now
            });

            //解析strXML为SendBuyMessage响应对象
            SendBuyMessage model  = GetBuyModelResponse(content);
            Hashtable      htComm = GetCommonreturn(model.Commonreturn);

            string customerId    = htComm["CustomerID"].ToString();
            string userId        = htComm["UserID"].ToString();
            string houseDetailId = htComm["HouseDetailID"].ToString();
            string seqNo         = htComm["SeqNO"].ToString();
            string merchantdate  = htComm["Merchantdate"].ToString();
            string houseId       = htComm["HouseID"].ToString();

            Loggers.DEFAULT.Debug(new DebugLogInfo {
                Message = "SeqNo: " + seqNo
            });

            string orgtotalamt        = model.Orgtotalamt; //实际交易额
            var    loggingSessionInfo = Default.GetBSLoggingSession(customerId, userId);

            //1判断会员楼盘明细映射是否存在记录
            var     bll       = new WXHouseVipMappingBLL(loggingSessionInfo);
            DataSet ds        = bll.VerifWXHouseVipMapping(userId, houseDetailId, 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不存在
                //插入会员楼盘明细映射表
                var houserVipMappingEntity = new WXHouseVipMappingEntity
                {
                    MappingID  = mappingId,
                    DetailID   = new Guid(houseDetailId),
                    CustomerID = customerId,
                    VIPID      = userId,
                    ReserveNo  = seqNo
                };
                houserVipMappingEntity.CustomerID = customerId;
                bll.Create(houserVipMappingEntity);
            }

            DateTime dt      = DateTime.Now;
            string   orderNo = GenerateOrderNo(dt);

            #region  1.4插入订单信息
            var  orderBll     = new WXHouseOrderBLL(loggingSessionInfo);
            var  orderEntity  = new WXHouseOrderEntity();
            Guid prePaymentId = Guid.NewGuid();  //订单表ID
            orderEntity.PrePaymentID = prePaymentId;
            orderEntity.MappingID    = mappingId;
            orderEntity.OrderNO      = orderNo;
            orderEntity.OrderDate    = Convert.ToDateTime(dt.ToString("yyyy-MM-dd HH:mm:ss"));
            orderEntity.RealPay      = Convert.ToDecimal(orgtotalamt); //实付金额
            var assignbuyerBll = new WXHouseAssignbuyerBLL(loggingSessionInfo);
            WXHouseAssignbuyerEntity buyerEntity = assignbuyerBll.GetWXHouseAssignbuyer(customerId, userId);
            if (buyerEntity != null)
            {
                orderEntity.AssignbuyerID = buyerEntity.AssignbuyerID;
            }
            orderEntity.ThirdOrderNo   = model.Logisticsinfo;
            orderEntity.Assbuyeridtp   = model.Assbuyeridtp;
            orderEntity.Assbuyername   = model.Assbuyername;
            orderEntity.Assbuyermobile = model.Assbuyermobile;

            orderEntity.CustomerID = customerId;
            orderBll.Create(orderEntity);
            #endregion


            #region  购买基金
            var fundBll    = new WXHouseBuyFundBLL(loggingSessionInfo);
            var fundEntity = new WXHouseBuyFundEntity
            {
                BuyFundID    = Guid.NewGuid(),
                PrePaymentID = prePaymentId,
                Fundtype     = 2101,
                PayDate      = dt.ToString("yyyy-MM-dd HH:mm:ss"),
                Merchantdate = merchantdate,
                SeqNO        = seqNo,
                Retmsg       = model.Retmsg,
                CustomerID   = customerId
            };

            Loggers.DEFAULT.Debug(new DebugLogInfo {
                Message = "Retcode" + model.Retcode
            });

            string retMsg;
            int    fundState;
            //判断华安赎回返回Retcode状态
            if (model.Retcode == "0000")
            {
                //2 更改楼盘表销售数量 HouseDetailID
                var buildBll = new WXHouseBuildBLL(loggingSessionInfo);
                WXHouseBuildEntity buildEntity = buildBll.GetByID(houseId);
                if (buildEntity != null)
                {
                    buildEntity.SaleHoseNum += 1;
                    buildBll.Update(buildEntity);
                }

                retMsg    = "支付成功";
                fundState = (int)FundStateEnum.Success;
            }
            else if (model.Retcode == "0999")
            {
                retMsg    = "委托已受理";
                fundState = (int)FundStateEnum.Order;
            }
            else
            {
                retMsg    = "支付失败";
                fundState = (int)FundStateEnum.Error;
            }

            fundEntity.Retcode   = model.Retcode;
            fundEntity.FundState = fundState;
            fundBll.Create(fundEntity);
            #endregion

            //页面跳转
            string toPageUrl = htComm["ToPageURL"] + "&type=1&retStatus=" + fundState + "&retMsg=" + retMsg + "&Retcode=" + model.Retcode;
            RedirectUrl(toPageUrl);
        }