コード例 #1
0
        private void GetEBPayCheck()
        {
            Guid userid;

            if (WebUserAuth.UserId != null)
            {
                userid = WebUserAuth.UserId.Value;
            }
            else
            {
                PrintJson("0", "您还未登录!");
                return;
            }

            decimal        Amount            = Tool.SafeConvert.ToDecimal(Request.QueryString["Amount"], 0);
            WebSettingInfo rechargeSet       = new TuanDai.PortalSystem.DAL.WebSettingDAL().GetWebSettingInfo("9A89CBAE-6550-4EA1-8224-EB645F38F8FA");
            decimal        MinRechargeAmount = decimal.Parse(rechargeSet.Param1Value);

            if (Amount < MinRechargeAmount)
            {
                PrintJson("0", "您好,充值金额必须大于或者等于" + MinRechargeAmount.ToString("N2") + "!");
                return;
            }

            if (Amount > 5000000)
            {
                PrintJson("0", "单次充值不能超过500万!");
                return;
            }
            NoHandler noHandler = new NoHandler();
            string    orderNo   = noHandler.OnLineRechare();

            if (orderNo == "0")
            {
                PrintJson("0", "您好,您的提交失败请重试!");
                return;
            }

            int    Sel        = 11;
            Guid   rechargeId = Guid.NewGuid();
            string bankcode   = "";

            string            userIP    = Tool.WebFormHandler.GetIP();
            int               outStatus = 0;
            DynamicParameters paras     = new DynamicParameters();

            paras.Add("@userid", userid);
            paras.Add("@type", Sel);
            paras.Add("@amount", Amount);
            paras.Add("@orderNo", orderNo);
            paras.Add("@backcode", bankcode);
            paras.Add("@clientIp", userIP);
            paras.Add("@from", "5");
            paras.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output);
            PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, "AccountRechargeInit", ref paras, CommandType.StoredProcedure);
            outStatus = paras.Get <int>("@outStatus");

            int result = outStatus;

            if (result <= 0)
            {
                PrintJson("0", "您好,您的提交失败请重试!");
            }

            UserBLL           bll      = new UserBLL();
            UserBasicInfoInfo userInfo = bll.GetUserBasicInfoModelById(userid);

            //获取个人信息
            if (null == userInfo)
            {
                PrintJson("0", "获取用户信息错误!");
                return;
            }

            //如果查询没有身份或者真实姓名
            if (string.IsNullOrEmpty(userInfo.IdentityCard) || string.IsNullOrEmpty(userInfo.RealName) || !userInfo.IsValidateIdentity)
            {
                PrintJson("0", "没有获取到用户实名信息(身份证和真实姓名)");
                return;
            }
            GetBankCardNo(userInfo, userid);
            //是否绑定银行卡
            if (string.IsNullOrEmpty(userInfo.BankAccountNo))
            {
                PrintJson("0", "银行卡未绑定");
                return;
            }
            //是否绑定手机
            if (string.IsNullOrEmpty(userInfo.TelNo) || !userInfo.IsValidateMobile)
            {
                PrintJson("0", "未完成手机或实名认证");
                return;
            }

            EBRechargeInfo orderInfo = new EBRechargeInfo();

            orderInfo.IsBindCard = 0;
            orderInfo.OrderId    = orderNo;
            //申请充值
            try
            {
                var bankAccountNo  = userInfo.BankAccountNo.Trim();
                var identityId     = userInfo.Id.ToString().Replace("-", string.Empty).ToUpper();
                var bindCardModel  = BindBankCardList.GetBindCardList(identityId, bankAccountNo);
                var rechargeAmount = (int)(Amount * 100);
                if (bindCardModel == null)
                {
                    var model = new BindCardRequestModel
                    {
                        CardNo        = bankAccountNo,
                        IdCardNo      = userInfo.IdentityCard,
                        IdentityId    = identityId,
                        Phone         = userInfo.TelNo,
                        RegisterPhone = userInfo.TelNo,
                        UserName      = userInfo.RealName,
                    };

                    model.RequestId     = string.Concat("D", identityId);
                    orderInfo.RequestId = model.RequestId;
                    BindBankCard.BindCard(model);
                }
                else
                {
                    orderInfo.RequestId  = string.Concat("D", identityId);
                    orderInfo.IsBindCard = 1;
                    BankCardPay.BindPay(new BankCardPayRequestModel
                    {
                        Amount      = rechargeAmount,
                        CallBackUrl = EBNotifyUrl,
                        CardLast    = bindCardModel.Card_Last,
                        CardTop     = bindCardModel.Card_Top,
                        IdentityId  = identityId,
                        OrderId     = orderNo
                    });
                }
            }
            catch (Exception ex)
            {
                SysLogHelper.WriteErrorLog("易宝充值出错:GetEBPayCheck", Tool.ExceptionHelper.GetExceptionMessage(ex));
                PrintJson("0", "发生错误:" + ex.Message);
                return;
            }
            var ResponseData = new { result = "1", msg = JsonHelper.ToJson(orderInfo) };

            PrintJson(ResponseData);
        }
コード例 #2
0
        private void ConfirmPay()
        {
            Guid userid;

            if (WebUserAuth.UserId != null)
            {
                userid = WebUserAuth.UserId.Value;
            }
            else
            {
                PrintJson("0", "您还未登录!");
                return;
            }
            string orderId    = WEBRequest.GetFormString("OrderId");
            string valCode    = WEBRequest.GetFormString("SMSCode");
            string isBindCard = WEBRequest.GetFormString("IsBindCard");

            try
            {
                if (isBindCard == "1")
                {
                    AccountRechareInfo ar = getAccountRechare(orderId);
                    if (null == ar)
                    {
                        PrintJson("0", "充值交易未成功!");
                        return;
                    }

                    BankCardPay.ConfirmBindBankCard(orderId, valCode);
                }
                else
                {
                    //获取个人信息
                    UserBLL           userbll  = new UserBLL();
                    UserBasicInfoInfo userInfo = userbll.GetUserBasicInfoModelById(userid);
                    if (null == userInfo)
                    {
                        PrintJson("0", "获取用户信息错误!");
                        return;
                    }
                    GetBankCardNo(userInfo, userid);
                    //是否绑定银行卡
                    if (string.IsNullOrEmpty(userInfo.BankAccountNo))
                    {
                        PrintJson("0", "银行卡未绑定!");
                        return;
                    }
                    string requestId = WEBRequest.GetFormString("RequestId").ToUpper();
                    //确认绑卡
                    BindBankCard.ConfirmBindBankCard(requestId, valCode);

                    //无短信充值
                    AccountRechareInfo ar = getAccountRechare(orderId);
                    if (null == ar)
                    {
                        PrintJson("0", "充值交易未成功!");
                        return;
                    }

                    var identityId     = userInfo.Id.ToString().Replace("-", string.Empty).ToUpper();
                    var bindCardModel  = BindBankCardList.GetBindCardList(identityId, userInfo.BankAccountNo.Trim());
                    var rechargeAmount = (int)(ar.Amount * 100);
                    BindBankCardPay.BindPay(new BankCardPayRequestModel
                    {
                        Amount      = rechargeAmount,
                        CallBackUrl = EBNotifyUrl,
                        CardLast    = bindCardModel.Card_Last,
                        CardTop     = bindCardModel.Card_Top,
                        IdentityId  = identityId,
                        OrderId     = orderId
                    });
                }
            }
            catch (Exception ex)
            {
                SysLogHelper.WriteErrorLog("易宝充值出错:ConfirmPay", Tool.ExceptionHelper.GetExceptionMessage(ex));
                PrintJson("0", "发生错误:" + ex.Message);
                return;
            }
            PrintJson("1", "");
        }