Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            userId = WebUserAuth.UserId.Value;
            if (!IsPostBack)
            {
                UserBLL userBll = new UserBLL();
                userModel = userBll.GetUserBasicInfoModelById(userId);

                DrawType = WEBRequest.GetQueryInt("drawtype", 2);
                if (DrawType != 1 && DrawType != 2)
                {
                    DrawType = 2;
                }
                string            strSQL   = "select Id, ActualWithdrawDeposit, merchanType from AppWithdrewFund where UserId=@userId  order by AppDate desc";
                DynamicParameters dyParams = new DynamicParameters();
                dyParams.Add("@userId", userId);

                WXAppWithdrewFund appWith = PublicConn.QuerySingleWrite <WXAppWithdrewFund>(strSQL, ref dyParams);
                if (appWith != null)
                {
                    Amout = appWith.ActualWithdrawDeposit ?? 0;
                    if (DrawType == 1)
                    {
                        strSQL   = " update AppWithdrewFund set merchanType=9 where Id=@id";
                        dyParams = new DynamicParameters();
                        dyParams.Add("@id", appWith.Id);
                        PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams);
                    }
                }
            }
        }
Example #2
0
        private int UpdateAccountRechare(AccountRechareInfo Info)
        {
            string strSQL = " Update AccountRechare Set" +
                            " [From]=@From WHERE TranOrder=@TranOrder";
            var paramData = new Dapper.DynamicParameters();

            paramData.Add("@From", Info.From);
            paramData.Add("@TranOrder", Info.TranOrder);
            return(PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref paramData));
        }
Example #3
0
        private int UpdateAccountRechare(byte?From, string TranOrder)
        {
            int result = 0;

            string strSQL = " Update AccountRechare Set" +
                            " [From]=@From WHERE TranOrder=@TranOrder";
            var paramData = new Dapper.DynamicParameters();

            paramData.Add("@From", From);
            paramData.Add("@TranOrder", TranOrder);
            result = PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref paramData);
            return(result);
        }
Example #4
0
        //获取复投宝的待收本息
        public Tuple <decimal, decimal> GetFTBDueInAmountInterest(Guid userId)
        {
            var dyParams = new Dapper.DynamicParameters();

            dyParams.Add("@UserId", userId);
            dyParams.Add("@totalAmount", 0, DbType.Decimal, ParameterDirection.Output, 18, null, 2);
            dyParams.Add("@totalInterest", 0, DbType.Decimal, ParameterDirection.Output, 18, null, 2);

            string strSQL = "select @totalAmount=RecoverBorrowOut, @totalInterest=DueComeInterest from We_FundAccountInfo with(nolock) where UserId=@UserId";

            PublicConn.ExecuteTD(PublicConn.DBWriteType.Read, strSQL, ref dyParams);
            Tuple <decimal, decimal> result = new Tuple <decimal, decimal>(dyParams.Get <decimal?>("@totalAmount") ?? 0, dyParams.Get <decimal?>("@totalInterest") ?? 0);

            return(result);
        }
Example #5
0
        protected void LoadData()
        {
            ProjectBLL bll = new ProjectBLL();

            var dyParams = new Dapper.DynamicParameters();

            dyParams.Add("@SubscribeId", TransferId);
            dyParams.Add("@projectId", null, DbType.Guid, ParameterDirection.Output, 36);
            dyParams.Add("@addDate", null, DbType.DateTime, ParameterDirection.Output, 0);
            dyParams.Add("@refundedMonths", null, DbType.Int32, ParameterDirection.Output, 0);
            string strSQL = @"select @projectId=ProjectId, @addDate=AddDate,@refundedMonths= RefundedMonths FROM dbo.Subscribe WITH(NOLOCK) where Id=@SubscribeId";

            PublicConn.ExecuteTD(PublicConn.DBWriteType.Read, strSQL, ref dyParams);
            Guid projectId = dyParams.Get <Guid>("@projectId");

            //获取项目信息
            model = bll.GetProjectDetailInfo(projectId);
            DateTime investDate     = dyParams.Get <DateTime>("@addDate");
            int      refundedMonths = dyParams.Get <Int32>("@refundedMonths");
            string   sql            = string.Empty;

            if (model.RepaymentType.Value == 1)//到期还本息
            {
                sql = "SELECT dateDiff(day,@BeginDate,getdate())-1";
            }
            else
            {
                sql = "SELECT dateDiff(day,dbo.f_GetRepaymentAdvance_Date(@BeginDate,@Month),getdate())";
            }
            dyParams = new Dapper.DynamicParameters();
            dyParams.Add("@BeginDate", investDate);
            dyParams.Add("@Month", refundedMonths);
            DiffDay = PublicConn.QuerySingle <int>(sql, ref dyParams);

            WebSettingBLL websetbll = new WebSettingBLL();

            WebSettingEntity = websetbll.GetWebSettingInfo("588B23C6-56EC-40C1-80A6-09B19C6F21E1");
            if (WebSettingEntity == null)
            {
                WebSettingEntity = new WebSettingInfo();
            }

            zqzrRateSet = websetbll.GetWebSettingInfo("63C10EF7-3961-4CA3-B277-147AAD8E7D42");
            if (zqzrRateSet.Param1Value == "1" && DateTime.Parse(zqzrRateSet.Param2Value) < DateTime.Now && DateTime.Now < DateTime.Parse(zqzrRateSet.Param3Value))
            {
                IsOpenRateLimit = true;
            }
        }
Example #6
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);
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TuanDai.Payment.Log.Info(this.GetType().ToString(), "开始易宝回调");
            string callback_result = "";

            try
            {
                if (Request["data"] == null || Request["encryptkey"] == null)
                {
                    TuanDai.Payment.Log.Info(this.GetType().ToString(), "参数不正确");
                    Response.Write("参数不正确!");
                    Response.End();
                }

                TuanDai.Payment.Log.Info(this.GetType().ToString(), "易宝回调加密参数:" + Request["data"] + ",密钥:" + Request["encryptkey"]);
                //商户注意:接收到易宝的回调信息后一定要回写success用以保证握手成功!

                string data       = Request["data"];       //回调中的参数data
                string encryptkey = Request["encryptkey"]; //回调中的参数encryptkey
                callback_result = YJPayUtil.checkYbCallbackResult(data, encryptkey);
                var resultData = JsonConvert.DeserializeObject <SortedDictionary <string, string> >(callback_result);
                TuanDai.Payment.Log.Info(this.GetType().ToString(), "The Pay result is Values  : " + callback_result);

                if (resultData == null || resultData.ContainsKey("error_msg"))
                {
                    Response.Write("参数不正确!");
                    Response.End();
                }

                var status         = resultData["status"].ToString();
                var rechargeMoney  = resultData["amount"].ToString();
                var out_trade_no   = resultData["orderid"].ToString();
                var transaction_id = resultData["yborderid"].ToString();

                string            strSQL   = "p_OnLineRechargeHandler";
                DynamicParameters dyParams = new DynamicParameters();
                dyParams.Add("@orderno", out_trade_no);
                dyParams.Add("@MediumMoney", decimal.Parse(rechargeMoney) / 100);
                dyParams.Add("@MediumOrderNo", transaction_id);
                dyParams.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output, 20);
                if (status == "1")
                {
                    dyParams.Add("@handlerStatus", 2);
                }
                else
                {
                    dyParams.Add("@handlerStatus", 1);
                }
                PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams, CommandType.StoredProcedure);

                int result = dyParams.Get <int>("@outStatus");
                if (result == 1)
                {
                    AccountRechareInfo accountRechare = getAccountRechare(out_trade_no);
                    if (accountRechare != null)
                    {
                        //List<int> typeList = new List<int>() { 2, 3, 4, 6, 8,9,11, 12 };
                        //if (db.AccountRechare.Count(p => p.UserId == accountRechare.UserId && p.Status == 2 && typeList.Contains(p.type)) == 1)
                        //{
                        //    TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(accountRechare.UserId, (int)ConstString.UserGrowthType.FirstReCharge, null, 0);
                        //}

                        TuanDai.PortalSystem.BLL.UserBLL bll = new TuanDai.PortalSystem.BLL.UserBLL();
                        UserBasicInfoInfo userBasicInfo      = bll.GetUserBasicInfoModelById(accountRechare.UserId);
                        if (userBasicInfo != null)
                        {
                            var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0");
                            if (isNewSmsRequest == "0")
                            {
                                var parameters = new Dictionary <string, object>();
                                parameters.Add("User", userBasicInfo);
                                parameters.Add("CurrentDate", DateTime.Now);
                                parameters.Add("RechargeMoney", rechargeMoney);
                                parameters.Add("Host", GlobalUtils.WebURL);

                                var messageSender = new BusinessDll.MessageSend();
                                messageSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters,
                                                           mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id);
                            }
                            else
                            {
                                SmsRequest rechargeSuccessSmsRequest = new SmsRequest();
                                rechargeSuccessSmsRequest.EventCode      = MsgTemplatesType.RechargeSuccess;
                                rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc;
                                rechargeSuccessSmsRequest.UserId         = userBasicInfo.Id;
                                rechargeSuccessSmsRequest.EmailAddress   = userBasicInfo.Email;
                                rechargeSuccessSmsRequest.Mobile         = userBasicInfo.TelNo;
                                rechargeSuccessSmsRequest.Parameters     = new Dictionary <string, object>();
                                rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", rechargeMoney);

                                string errorMessage = string.Empty;
                                SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage);
                            }
                        }
                    }
                }

                //NetLog.WriteBatchwithdrawHandler("交易成功", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方处理状态:", result.ToString().Trim(), "连连处理状态:", sPara["result_pay"].ToString()));
                Response.Write(@"SUCCESS");
                Response.End();

                //SoftLog.LogStr("支付成功回调信息:" + callback_result, "yeepay/CallbackLog");
            }
            catch (Exception err)
            {
                TuanDai.Payment.Log.Info(this.GetType().ToString(), "支付失败:" + err.ToString() + "," + Request["data"] + Environment.NewLine + Request["encryptkey"] + "处理结果:" + callback_result);
                //SoftLog.LogStr("支付失败:" + err.ToString() + "," + Request["data"] + Environment.NewLine + Request["encryptkey"] + "处理结果:" + callback_result, "yeepay/CallbackLog");
                Response.Write("支付失败!");
                Response.End();
            }
            finally
            {
                //SoftLog.LogStr("支付回调信息" + Request["data"] + Environment.NewLine + Request["encryptkey"] + "处理结果:" + callback_result, "yeepay/CallbackLog");
            }
        }
Example #8
0
        //获取用户信用档案
        private void GetBorrowerData()
        {
            userCreditInfo = bll.WXGetUserCreditInfo(model.UserId.Value);

            //特殊处理
            Guid tempBorrowUserId = Guid.Parse("73810E55-E2D4-4F40-8FF9-F0A23F909A75");

            if (borrowerUserInfo.Id == tempBorrowUserId)
            {
                Guid tempProjectId = Guid.Parse("EA7A69C1-38B4-4073-A69D-CFBE2944B4E3");
                ProjectDetailInfo tempProjectModel = bll.GetProjectDetailInfo(tempProjectId);
                userCreditInfo.DueOutPAndI = userCreditInfo.DueOutPAndI - ((tempProjectModel.TotalAmount ?? 0) + (tempProjectModel.TotalInterest ?? 0) - (tempProjectModel.RefundInterest ?? 0) - (tempProjectModel.RefundCaptital ?? 0));

                //LogHelper.WriteLog("待还本息特殊处理", "", tempProjectModel.TotalAmount.Value.ToString());
                // SysLogHelper.WriteTraceLog("待还本息特殊处理", tempProjectModel.TotalAmount.Value.ToString());
            }

            string sql      = @" SELECT @prepaymentTime=count(CASE WHEN  IsRepayAdvance=1   THEN 1 ELSE NULL END ),  
                                   @sumTime=count(CASE WHEN  Status=6    THEN 1 ELSE NULL END ) 
                            FROM Project (NOLOCK)    where   Type=6 and UserId=@userId ;
                        SELECT @OverdueCount=COUNT(0) FROM (SELECT  ProjectId,periods FROM dbo.OverDueRecord with(nolock) WHERE PublisherUserId=@userId and isnull(IsHide,0)=0 GROUP BY ProjectId,periods)t;
                        select @OverdueAdvanceTime=COUNT(0)  from (SELECT DISTINCT m_Period,m_ProjectId  FROM dbo.t_AdvanceDetail(NOLOCK)   where m_BorrowUserid=@UserId ) A;
                        SELECT @TotalOverdue=(ISNULL(SUM(ActualCost),0)+ISNULL(SUM(ActualInterest),0)) FROM dbo.OverDueRecord(NOLOCK) WHERE PublisherUserId=@userId  AND IsBorrow=0 and isnull(IsHide,0)=0  ";
            var    dyParams = new Dapper.DynamicParameters();

            dyParams.Add("@userId", model.UserId);
            dyParams.Add("@prepaymentTime", 0, DbType.Int32, ParameterDirection.Output, 20);
            dyParams.Add("@sumTime", 0, DbType.Int32, ParameterDirection.Output, 20);
            dyParams.Add("@OverdueCount", 0, DbType.Int32, ParameterDirection.Output, 20);
            dyParams.Add("@OverdueAdvanceTime", 0, DbType.Int32, ParameterDirection.Output, 20);
            dyParams.Add("@TotalOverdue", 0, DbType.Decimal, ParameterDirection.Output, 20);

            PublicConn.ExecuteTD(PublicConn.DBWriteType.Read, sql, ref dyParams);
            PrepaymentTime = dyParams.Get <int>("@prepaymentTime");
            int sumTime = dyParams.Get <int>("@sumTime");

            OnTimepayTime      = sumTime - PrepaymentTime;
            overdueNum         = dyParams.Get <int>("@OverdueCount");
            OverdueAdvanceTime = dyParams.Get <int>("@OverdueAdvanceTime");
            TotalOverdue       = dyParams.Get <decimal>("@TotalOverdue");

            //垫付次数大于逾期次数,显示逾期次数,否则是逾期垫付次数。
            if (overdueNum < OverdueAdvanceTime)
            {
                OverdueAdvanceTime = overdueNum;
            }

            #region 会员等级 2016-04-16
            string            strSQL      = @"declare @PreNetWorth numeric(18, 2)=0
                              SELECT @PreNetWorth=ISNULL(PreNetWorth,0) FROM dbo.MUserVipInfo WITH(NOLOCK) WHERE UserId=@UserId
                              SELECT Level FROM dbo.MVipLevel WITH(NOLOCK) WHERE MinNetWorth<=@PreNetWorth AND MaxNetWorth>@PreNetWorth ";
            string            level       = string.Empty;
            DynamicParameters whereParams = new DynamicParameters();
            whereParams.Add("@UserId", this.model.UserId);
            level = PublicConn.QueryVipSingle <string>(strSQL, ref whereParams);
            if (DateTime.Now < DateTime.Parse("2018-01-01 02:00:00") && level == "9")
            {
                level = "8";
            }
            VipLevel = "V" + (level ?? "1");//会员等级
            #endregion


            string sqlText = @"select a.FullName,a.image from UserInEnterpriseProject_ZC u left join AssureOrganization a 
                      on u.EnterpriseUserId=a.UserId where ProjectId=@projectId";
            var    para    = new DynamicParameters();
            para.Add("@projectId", model.Id);
            assureModel = PublicConn.QuerySingle <AssureOrganizationInfo>(sqlText, ref para);
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid userid = WebUserAuth.UserId.Value;

            var bankmodel = new BankInfoBLL().GetBankInfoListByUserId(userid);

            if (bankmodel != null && bankmodel.Count > 0)
            {
                if (bankmodel.Any(p => p.Status == 2))
                {
                    Response.Write("您好,银行卡在审核中不允许充值!");
                    ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('您好,银行卡在审核中不允许充值!','1','确定');</script>");
                    return;
                }
            }

            decimal Amount    = Tool.SafeConvert.ToDecimal(Request.Params["Amount"], 0);
            decimal tmpAmount = Math.Floor(Amount * 100) / 100;

            if (tmpAmount != Amount)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('充值金额最多只能2位小数,如106.32!','1','确定');</script>");
                return;
            }
            TuanDai.PortalSystem.Model.WebSettingInfo rechargeSet = new TuanDai.PortalSystem.DAL.WebSettingDAL().GetWebSettingInfo("9A89CBAE-6550-4EA1-8224-EB645F38F8FA");
            decimal minRecharge = decimal.Parse(rechargeSet.Param1Value);

            if (Amount < minRecharge)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('单次充值最少" + minRecharge.ToString("N2") + "元!','1','确定');</script>");
                return;
            }
            if (Amount > 500000)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('单次充值不能超过50万!','1','确定');</script>");
                return;
            }
            NoHandler noHandler = new NoHandler();
            string    orderNo   = noHandler.OnLineRechare();

            if (orderNo == "0")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('您好,您的提交失败请重试!','1','确定');</script>");
                return;
            }

            int    Sel        = Tool.SafeConvert.ToInt32(Request.Params["Sel"], 8);
            Guid   rechargeId = Guid.NewGuid();
            int    outStatus  = 0;
            string bankcode   = "";

            if (Request.Params["bankcode"] != null)
            {
                bankcode = Request.Params["bankcode"];
            }
            string userIP = Tool.WebFormHandler.GetIP();

            var paramData = new Dapper.DynamicParameters();

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

            int result = outStatus;

            if (result > 0)
            {
                lock (lockstatus)
                {
                    if (UpdateAccountRechare(5, orderNo) <= 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('您好,您的提交失败请重试!','1','确定');</script>");
                        return;
                    }

                    Response.Redirect("/PaymentPlatform/lianlian/plainPay.aspx?orderno=" + orderNo + "&totalprice=" + Amount + "&bankcode=" + bankcode);
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('您好,您的提交失败请重试!','1','确定');</script>");
            }
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid userid = WebUserAuth.UserId.Value;
            //if (GetBankInfo(userid, 2) == 1)
            //{
            //    //if (bankmodel.Status==2)
            //    //{
            //    //Response.Write("您好,银行卡在审核中不允许充值!");
            //    ClientScript.RegisterStartupScript(this.GetType(), "ss",
            //        "<script>ShowMsg('您好,银行卡在审核中不允许充值!','1','确定');</script>");
            //    return;
            //    //}
            //}
            decimal Amount    = Tool.SafeConvert.ToDecimal(Request.Params["Amount"], 0);
            decimal tmpAmount = Math.Floor(Amount * 100) / 100;

            if (tmpAmount != Amount)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss",
                                                   "<script>ShowMsg('充值金额最多只能2位小数,如106.32!','1','确定');</script>");
                return;
            }
            TuanDai.PortalSystem.Model.WebSettingInfo rechargeSet =
                new TuanDai.PortalSystem.DAL.WebSettingDAL().GetWebSettingInfo("9A89CBAE-6550-4EA1-8224-EB645F38F8FA");
            decimal minRecharge = decimal.Parse(rechargeSet.Param1Value);

            if (Amount < minRecharge)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss",
                                                   "<script>ShowMsg('单次充值最少" + minRecharge.ToString("N2") + "元!','1','确定');</script>");
                return;
            }
            if (Amount > 500000)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss",
                                                   "<script>ShowMsg('单次充值不能超过50万!','1','确定');</script>");
                return;
            }

            var cgtMode = new QueryClient().GetUserByPlatformUserNo(userid);

            if (cgtMode == null)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss",
                                                   "<script>ShowMsg('存管通未开通,不能进行充值!','1','确定');</script>");
                return;
            }
            if (!cgtMode.isActivate)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss",
                                                   "<script>ShowMsg('存管通未激活,不能进行充值!','1','确定');</script>");
                return;
            }

            NoHandler noHandler = new NoHandler();
            string    orderNo   = noHandler.OnLineRechare();

            if (orderNo == "0")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss",
                                                   "<script>ShowMsg('您好,您的提交失败请重试!','1','确定');</script>");
                return;
            }

            string err        = string.Empty;
            bool   isRecharge = new CgtCheckBLL().GetUserCgtIsOper(userid, "recharge", ref err);

            if (!isRecharge)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ss",
                                                   "<script>ShowMsg('" + err + "','1','确定');</script>");
                return;
            }
            //获取银行卡号
            string bankNo  = Request["bankno"];
            string outCode = string.Empty;

            if (!string.IsNullOrEmpty(bankNo))
            {
                try
                {
                    bankNo = Tool.DESC.Decrypt(bankNo);
                }
                catch (Exception)
                {
                    bankNo = null;
                }
            }

            BankFromJavaService bankJavaService = new BankFromJavaService();

            if (GlobalUtils.IsBankService)
            {
                var bankInfoFromJava = bankJavaService.GetBankInfo(userid, ServiceType.NotTuomin);
                if (bankInfoFromJava != null && bankInfoFromJava.respData != null)
                {
                    bankNo  = bankInfoFromJava.respData.bankNo;
                    outCode = bankInfoFromJava.respData.bankCode;
                }
            }
            else
            {
                var userInfo = new PortalSystem.BLL.UserBLL().GetUserBasicInfoModelById(userid);
                if (userInfo == null || string.IsNullOrEmpty(userInfo.BankAccountNo))
                {
                    var bankInfo = GlobalUtils.GetBankInfo(userid);
                    bankNo = bankInfo.BankNo;
                }
                else
                {
                    bankNo = userInfo.BankAccountNo;
                }
            }

            string userIP = Tool.WebFormHandler.GetIP();

            if (!GlobalUtils.IsBankService)
            {
                var sss = TuanDai.Payment.Client.BankInfo.GetPayBankInfo(userid);

                TuanDai.Payment.Models.PayRoute.RouteInfo bank = new TuanDai.Payment.Client.Recharge().GetCgtRechargeInfo(userid, sss.BankNo);
                int Sel = bank.Sel;

                int    outStatus = 0;
                string bankcode  = "";
                if (Request.Params["bankcode"] != null)
                {
                    bankcode = Request.Params["bankcode"];
                }


                var paramData = new Dapper.DynamicParameters();
                paramData.Add("@userid", userid);
                paramData.Add("@type", Sel);
                paramData.Add("@amount", Amount);
                paramData.Add("@orderNo", orderNo);
                paramData.Add("@backcode", bankcode);
                paramData.Add("@clientIp", userIP);
                paramData.Add("@from", "5");
                if (bank.RouteId.IsEmpty())
                {
                    paramData.Add("@RouteId", null);
                }
                else
                {
                    paramData.Add("@RouteId", bank.RouteId);
                }
                paramData.Add("@outStatus", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output);
                paramData.Add("@cmorderNo", "");
                PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, "p_cgt_AccountRechargeInit", ref paramData, CommandType.StoredProcedure);
                outStatus = paramData.Get <int>("@outStatus");

                int result = outStatus;
                if (result > 0)
                {
                    lock (lockstatus)
                    {
                        var isCallBackPayment =
                            System.Configuration.ConfigurationManager.AppSettings["IsCallBackPayment"];
                        var    paymentUrl  = System.Configuration.ConfigurationManager.AppSettings["PaymentUrl"];
                        string callBackUrl = paymentUrl + "/PaymentPlatform/H5/commonCallBack.aspx";
                        if (isCallBackPayment == "0")
                        {
                            callBackUrl = CgtCallBackConfig.GetCgtCallBackUrl(CgtCallBackConfig.CgtCallBackType.Recharge);
                        }
                        var recharInfo = new Payment.Client.Recharge().GetCgtRechargeInfo(userid, bankNo);
                        var url        = CunGuanTong.Client.FundClient.RECHARGE_Req(new CunGuanTong.Model.RECHARGE_Request
                        {
                            rechargeWay      = rechargeWay.SWIFT,
                            requestNo        = orderNo,
                            amount           = Amount,
                            bankcode         = recharInfo.OutCode,
                            callbackMode     = "DIRECT_CALLBACK",
                            platformUserNo   = userid.ToString(),
                            expectPayCompany = recharInfo.CgtPayCompany,
                            //callbackUrl = CgtCallBackConfig.GetCgtCallBackUrl(CgtCallBackConfig.CgtCallBackType.Recharge),
                            callbackUrl = callBackUrl,
                            userDevice  = CunGuanTong.Model.userDevice.MOBILE
                        });

                        if (string.IsNullOrEmpty(url))
                        {
                            if (Request.UrlReferrer != null)
                            {
                                url = Request.UrlReferrer.ToString();
                            }
                            else
                            {
                                url = GlobalUtils.WebURL;
                            }
                        }
                        Response.Redirect(url);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>ShowMsg('您好,充值提交失败请重试!','1','确定');</script>");
                }
            }
            else
            {  //走Java银行卡服务
                string retUrl = bankJavaService.GetCgtRechargeUrl(userid, bankNo, Amount, userIP, outCode);
                if (!string.IsNullOrEmpty(retUrl))
                {
                    Response.Redirect(retUrl);
                }
            }
        }
Example #11
0
        public void GetWXJsApiParam()
        {
            string strOpenId = GlobalUtils.OpenId;

            if (strOpenId.IsEmpty())
            {
                PrintJson("-1", "微信未授权,取不到OpenId值");
                return;
            }
            Guid?userId = WebUserAuth.UserId;

            if (userId == null || userId == Guid.Empty)
            {
                PrintJson("-1", "对不起,您还未登录!");
                return;
            }
            decimal Amount = Tool.SafeConvert.ToDecimal(WEBRequest.GetQueryString("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("-1", "最低充值金额为" + MinRechargeAmount.ToString("N2") + "元!");
                return;
            }
            if (Amount > 500000)
            {
                PrintJson("-1", "单次充值不能超过50万!");
                return;
            }


            NoHandler noHandler = new NoHandler();
            string    orderNo   = noHandler.OnLineRechare();

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

            int    Sel        = 9; //标记是微信支付
            Guid   rechargeId = Guid.NewGuid();
            int    outStatus  = 0;
            string bankcode   = "";
            string userIP     = Tool.WebFormHandler.GetIP();

            DynamicParameters paramData = new DynamicParameters();

            paramData.Add("@userid", userId);
            paramData.Add("@type", Sel);
            paramData.Add("@amount", Amount);
            paramData.Add("@orderNo", orderNo);
            paramData.Add("@backcode", bankcode);
            paramData.Add("@clientIp", userIP);
            paramData.Add("@from", "5");
            paramData.Add("@outStatus", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output);

            PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, "AccountRechargeInit", ref paramData, System.Data.CommandType.StoredProcedure);
            outStatus = paramData.Get <int>("@outStatus");

            int result = outStatus;

            if (result > 0)
            {
                TuanDai.Payment.PaymentBLL jsApiPay           = new TuanDai.Payment.PaymentBLL("JSAPI", strOpenId, orderNo, userModel.RealName, userModel.IdentityCard);
                TuanDai.Payment.WxPayData  unifiedOrderResult = null;
                try
                {
                    int PayAmount = int.Parse(double.Parse((Amount * 100).ToString()).ToString());

                    unifiedOrderResult = jsApiPay.WXJsApiUnifiedOrder(PayAmount.ToString());
                }
                catch (Exception ex)
                {
                    PrintJson("-1", ex.Message);
                    return;
                }
                wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数
                PrintJson("1", "");
            }
            else
            {
                PrintJson("-1", "您好,您的提交失败请重试!");
                return;
            }
        }
Example #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        WebSettingInfo webSetting = new WebSettingBLL().GetWebSettingInfo("E27798C9-9301-4176-AC0B-6F3916F389EA");

        partnerConfig = new PartnerConfig(webSetting.Param1Value, webSetting.Param2Value, webSetting.Param3Value, webSetting.Param5Value);
        SortedDictionary <string, string> sPara = GetRequestPost();

        if (null == sPara)
        {
            Response.End();
        }

        if (sPara.Count > 0)//判断是否有带返回参数
        {
            NetLog.WriteBatchwithdrawHandler("接收连连支付异步通知数据", string.Concat("【", "签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方订单号:", sPara["no_order"].ToString(), "充值金额:", sPara["money_order"].ToString(), "连连订单号:", sPara["oid_paybill"].ToString(), "】"));

            if (!PaymentUtil.CheckSign(sPara, partnerConfig.YTPublicKey, //验证失败
                                       partnerConfig.MD5Key))
            {
                var out_trade_no   = sPara["no_order"].ToString();
                var rechargeMoney  = sPara["money_order"].ToString();
                var transaction_id = sPara["oid_paybill"].ToString();

                //ObjectParameter outStatus = new ObjectParameter("outStatus", "0");
                //db.p_OnLineRechargeHandler(1, out_trade_no, decimal.Parse(rechargeMoney), transaction_id, outStatus);
                //int result = int.Parse(outStatus.Value.ToString());

                NetLog.WriteBatchwithdrawHandler("连连验签失败", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "连连处理状态:9999"));

                Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""验签失败""}");
                Response.End();
            }
            else
            {
                var out_trade_no   = sPara["no_order"].ToString();
                var rechargeMoney  = sPara["money_order"].ToString();
                var transaction_id = sPara["oid_paybill"].ToString();

                string            strSQL   = "p_OnLineRechargeHandler";
                DynamicParameters dyParams = new DynamicParameters();
                dyParams.Add("@orderno", out_trade_no);
                dyParams.Add("@MediumMoney", decimal.Parse(rechargeMoney));
                dyParams.Add("@MediumOrderNo", transaction_id);
                dyParams.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output, 20);

                if (sPara["result_pay"].ToString().ToLower() == "success".ToLower())
                {
                    dyParams.Add("@handlerStatus", 2);
                }
                else
                {
                    dyParams.Add("@handlerStatus", 1);
                }
                PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams, CommandType.StoredProcedure);
                int result = dyParams.Get <int>("@outStatus");

                AccountRechareInfo accountRechare = getAccountRechare(out_trade_no);
                if (accountRechare != null)
                {
                    var para = new DynamicParameters();
                    para.Add("@UserId", accountRechare.UserId);
                    var count = PublicConn.QuerySingleWrite <int>("select count(0) from AccountRechare with(nolock) where UserId=@UserId and Status =2   and type in (2, 3, 4, 6, 8, 12)", ref para);
                    if (count == 1)
                    {
                        TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(accountRechare.UserId, (int)ConstString.UserGrowthType.FirstReCharge, null, 0);
                    }

                    UserBasicInfoInfo userBasicInfo = new UserBLL().GetUserBasicInfoModelById(accountRechare.UserId);
                    if (userBasicInfo != null)
                    {
                        var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0");
                        if (isNewSmsRequest == "0")
                        {
                            var parameters = new Dictionary <string, object>();
                            parameters.Add("User", userBasicInfo);
                            parameters.Add("CurrentDate", DateTime.Now);
                            parameters.Add("RechargeMoney", rechargeMoney);
                            parameters.Add("Host", GlobalUtils.WebURL);

                            var messageSender = new BusinessDll.MessageSend();
                            messageSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters,
                                                       mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id);
                        }
                        else
                        {
                            SmsRequest rechargeSuccessSmsRequest = new SmsRequest();
                            rechargeSuccessSmsRequest.EventCode      = MsgTemplatesType.RechargeSuccess;
                            rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc;
                            rechargeSuccessSmsRequest.UserId         = userBasicInfo.Id;
                            rechargeSuccessSmsRequest.EmailAddress   = userBasicInfo.Email;
                            rechargeSuccessSmsRequest.Mobile         = userBasicInfo.TelNo;
                            rechargeSuccessSmsRequest.Parameters     = new Dictionary <string, object>();
                            rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", rechargeMoney);

                            string errorMessage = string.Empty;
                            SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage);
                        }



                        //第三方渠道回调
                        try
                        {
                            TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack(accountRechare.Id, accountRechare.UserId);
                        }
                        catch (Exception ex)
                        {
                            new TuanDai.LogSystem.LogClient.LogClients().WriteErrorLog(
                                "TuanDai.PortalSystem.BLL.ThirdPartyChannel.RechargeCallBack",
                                "", "", ex.Message);
                        }
                    }
                }

                NetLog.WriteTraceLogHandler("交易成功", string.Concat("签名:", sPara["sign"].ToString(), "签名方式:", sPara["sign_type"].ToString(), "我方处理状态:", result.ToString().Trim(), "连连处理状态:", sPara["result_pay"].ToString()));
                Response.Write(@"{""ret_code"":""0000"",""ret_msg"":""交易成功""}");
                Response.End();
            }
        }
        else
        {
            //var out_trade_no = sPara["no_order"].ToString();
            //var rechargeMoney = sPara["money_order"].ToString();
            //var transaction_id = sPara["oid_paybill"].ToString();

            //ObjectParameter outStatus = new ObjectParameter("outStatus", "0");
            //db.p_OnLineRechargeHandler(1, out_trade_no, decimal.Parse(rechargeMoney), transaction_id, outStatus);
            ////Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""验签失败""}");

            //int result = int.Parse(outStatus.Value.ToString());

            NetLog.WriteBatchwithdrawHandler("连连交易参数为空失败", "连连处理状态:9999");
            Response.Write(@"{""ret_code"":""9999"",""ret_msg"":""交易失败""}");
            Response.End();
        }

        // 解析异步通知对象
        // sPara 字典对象
        // TODO:更新订单,发货等后续处理
    }
Example #13
0
        private void InitData()
        {
            try
            {
                WebSettingInfo webSetting = new WebSettingBLL().GetWebSettingInfo("fe5e5a30-b12c-4888-9858-12cbe80e1018");

                string MemberID       = Request.Params["MemberID"];          //商户号
                string TerminalID     = Request.Params["TerminalID"];        //商户终端号
                string TransID        = Request.Params["TransID"];           //商户流水号
                string Result         = Request.Params["Result"];            //支付结果(1:成功,0:失败)
                string ResultDesc     = Request.Params["ResultDesc"];        //支付结果描述
                string FactMoney      = Request.Params["FactMoney"];         //实际成交金额
                string AdditionalInfo = Request.Params["AdditionalInfo"];    //订单附加消息
                string SuccTime       = Request.Params["SuccTime"];          //交易成功时间
                string Md5Sign        = Request.Params["Md5Sign"].ToLower(); //md5签名
                string Md5Key         = "abcdefg";                           //webSetting.Param2Value;//ConfigurationManager.AppSettings["Md5key"];//密钥 双方约定
                String mark           = "~|~";                               //分隔符

                //string _Md5Key = "100000178";//测试商户号//webSetting.Param1Value;//WebConfigurationManager.AppSettings["Md5key"];

                string _WaitSign = "MemberID=" + MemberID + mark + "TerminalID=" + TerminalID + mark + "TransID=" + TransID + mark + "Result=" + Result + mark + "ResultDesc=" + ResultDesc + mark
                                   + "FactMoney=" + FactMoney + mark + "AdditionalInfo=" + AdditionalInfo + mark + "SuccTime=" + SuccTime
                                   + mark + "Md5Sign=" + Md5Key;

                SysLogHelper.WriteTraceLog("等待验签参数", _WaitSign);
                //验证签名成功
                if (Md5Sign.ToLower() == Md5Encrypt(_WaitSign).ToLower())
                {
                    ///支付结果(1:成功,0:失败)
                    DynamicParameters dyParams = new DynamicParameters();
                    string            strSQL   = "";
                    if (Result == "1")
                    {
                        strSQL   = "p_OnLineRechargeHandler";
                        dyParams = new DynamicParameters();
                        dyParams.Add("@handlerStatus", 2);
                        dyParams.Add("@MediumMoney", decimal.Divide(decimal.Parse(FactMoney), 100));
                        dyParams.Add("@MediumOrderNo", (TransID + SuccTime).Trim());
                        dyParams.Add("@outStatus", 0, DbType.Int32, ParameterDirection.Output, 20);

                        PublicConn.ExecuteTD(PublicConn.DBWriteType.FundWrite, strSQL, ref dyParams, CommandType.StoredProcedure);

                        int presult = dyParams.Get <int>("@outStatus");

                        SysLogHelper.WriteTraceLog("宝付支付交易成功", string.Concat("签名:", Md5Sign.ToLower(), "签名方式:", "MD5", "我方处理状态:", presult.ToString().Trim(), "宝付处理状态:", Result, "支付单号:", TransID));

                        AccountRechareInfo accountRechare = getAccountRechare(TransID);
                        if (accountRechare != null)
                        {
                            strSQL   = "select count(1) from AccountRechare where UserId=@userId and Status=2 and  [type] in(2, 3, 4, 6, 8, 12)";
                            dyParams = new DynamicParameters();
                            dyParams.Add("@userId", accountRechare.UserId);
                            int iCount = PublicConn.QuerySingleWrite <int>(strSQL, ref dyParams);
                            if (iCount > 0)
                            {
                                TuanDai.PortalSystem.BLL.VipGetWorthBLL.AddGetWorth(accountRechare.UserId, (int)ConstString.UserGrowthType.FirstReCharge, null, 0);
                            }
                            UserBasicInfoInfo userBasicInfo = new UserBLL().GetUserBasicInfoModelById(accountRechare.UserId);
                            if (userBasicInfo != null)
                            {
                                var isNewSmsRequest = ConfigHelper.getConfigString("IsNewSmsRequest", "0");
                                if (isNewSmsRequest == "0")
                                {
                                    var parameters = new Dictionary <string, object>();
                                    parameters.Add("CurrentDate", DateTime.Now);
                                    //parameters.Add("RechargeMoney", FactMoney);
                                    parameters.Add("RechargeMoney", decimal.Divide(decimal.Parse(FactMoney), 100));//宝付充值以分为单位
                                    parameters.Add("User", userBasicInfo);
                                    parameters.Add("Host", GlobalUtils.WebURL);

                                    var msgSender = new BusinessDll.MessageSend();
                                    msgSender.SendMessage2(eventCode: MessageTemplates.RechargeSuccess, parameters: parameters,
                                                           mobile: userBasicInfo.TelNo, email: userBasicInfo.Email, userId: userBasicInfo.Id);
                                }
                                else
                                {
                                    SmsRequest rechargeSuccessSmsRequest = new SmsRequest();
                                    rechargeSuccessSmsRequest.EventCode      = MsgTemplatesType.RechargeSuccess;
                                    rechargeSuccessSmsRequest.PlatformSource = PlatformSource.Pc;
                                    rechargeSuccessSmsRequest.UserId         = userBasicInfo.Id;
                                    rechargeSuccessSmsRequest.EmailAddress   = userBasicInfo.Email;
                                    rechargeSuccessSmsRequest.Mobile         = userBasicInfo.TelNo;
                                    rechargeSuccessSmsRequest.Parameters     = new Dictionary <string, object>();
                                    rechargeSuccessSmsRequest.Parameters.Add("RechargeMoney", FactMoney);

                                    string errorMessage = string.Empty;
                                    SmsClient.SendMessage(rechargeSuccessSmsRequest, ref errorMessage);
                                }
                            }
                        }
                        Response.Write("OK");
                        Response.End();
                    }

                    //if (Result == "0")
                    //{
                    //    db.p_OnLineRechargeHandler(1, TransID.Trim(), decimal.Divide(decimal.Parse(FactMoney), 100), (TransID + SuccTime).Trim(), outStatus);
                    //    int presult = int.Parse(outStatus.Value.ToString());
                    //    NetLog.WriteLoginHandler("宝付支付交易失败", string.Concat("签名:", Md5Sign.ToLower(), "签名方式:", "MD5", "我方处理状态:", presult.ToString().Trim(), "宝付处理状态:", Result, "支付单号:", TransID));

                    //    Response.Write("Fail");
                    //}
                }
                else
                {
                    SysLogHelper.WriteTraceLog("宝付验签失败", string.Concat("宝付返回签名:", Md5Sign.ToLower(), "等待验签", Md5Encrypt(_WaitSign).ToLower(), "签名方式:", "MD5", "宝付处理状态:", Result));
                    Response.Write("校验失败");
                    Response.End();
                }
            }
            catch (Exception ex)
            {
                SysLogHelper.WriteErrorLog("宝付支付失败", "错误详细信息:" + ex.Message + "|" + ex.StackTrace);
                Response.Write("Fail");
                Response.End();
            }
        }
Example #14
0
        private void GetBind()
        {
            interestBillInfo = new InterestBillInfo();

            #region
            string            sqlText    = @"
                                DECLARE @ExtendKey NVARCHAR(50);
                                SELECT @UserAddDate=AddDate,@UserAddDay=DATEDIFF(Day,AddDate,GETDATE()),@ExtendKey=ExtendKey,@Sex=Sex,@HeadImage=HeadImage FROM dbo.UserBasicInfo WITH(NOLOCK) WHERE Id=@UserId;

                                SELECT @ExtendCount=COUNT(0) FROM dbo.UserBasicInfo WITH(NOLOCK)
                                WHERE ExtenderKey=@ExtendKey;
                    
                                SELECT @ReturnInMoney=SUM(ISNULL(InterestAmout,0)+ISNULL(Amount,0)) FROM dbo.SubscribeDetail WITH(NOLOCK)
                                WHERE SubscribeUserId=@UserId; 
                                
                                SELECT @TotalInMoney= SUM(A1)+SUM(A2)+SUM(A3)+SUM(A4) FROM --收益
                                (
                                SELECT  SUM(ISNULL(InterestAmout,0)) AS A1,0 AS A2,0 AS A3,0 AS A4 FROM dbo.SubscribeDetail WITH(NOLOCK)
                                WHERE SubscribeUserId=@UserId 
                                UNION ALL
                                SELECT 0 AS A1,SUM(ISNULL(A.RealInterestAmout,0)) AS A2 ,ISNULL(SUM(B.Interest),0)+ISNULL(SUM(B.PenaltyAmount),0)/2 AS A3,0 AS A4
                                FROM dbo.SubscribeDetailHistory A WITH(NOLOCK) LEFT JOIN dbo.OverDueRecord B WITH(NOLOCK) ON A.SubscribeId=B.SubscribeId AND B.IsBorrow=0
                                WHERE A.SubscribeUserId=@UserId
                                
                                ) T;
                                
                                DECLARE @temp1 NUMERIC(18,2)=0
                                DECLARE @temp2 NUMERIC(18,2)=0
                                SELECT @temp2= COUNT(0) FROM FundAccountInfo WITH(NOLOCK)
                                
                                SELECT @temp1= A.TotalInvestRank FROM (
                                SELECT ROW_NUMBER() OVER(ORDER BY TotalIncomeInvest DESC) AS TotalInvestRank,UserId FROM dbo.FundAccountInfo WITH(NOLOCK))
                                AS A WHERE A.UserId=@UserId
                                SELECT @TotalInMoneyPercent= CAST((@temp2-@temp1)/@temp2*100 AS NUMERIC(18,2));
                                
                                ";
            DynamicParameters paramDatas = new DynamicParameters();
            paramDatas.Add("@UserId", WebUserAuth.UserId.Value);
            paramDatas.Add("@UserAddDate", null, DbType.DateTime, ParameterDirection.Output);
            paramDatas.Add("@UserAddDay", 0, DbType.Int32, ParameterDirection.Output);
            paramDatas.Add("@ExtendCount", 0, DbType.Int32, ParameterDirection.Output);
            paramDatas.Add("@Sex", 0, DbType.Int32, ParameterDirection.Output);
            paramDatas.Add("@ReturnInMoney", 0, DbType.Double, ParameterDirection.Output);
            paramDatas.Add("@TotalInMoney", 0, DbType.Double, ParameterDirection.Output);
            paramDatas.Add("@TotalInMoneyPercent", 0, DbType.Double, ParameterDirection.Output);
            paramDatas.Add("@HeadImage", "", DbType.String, ParameterDirection.Output);

            PublicConn.ExecuteTD(PublicConn.DBWriteType.Read, sqlText, ref paramDatas);

            interestBillInfo.UserAddDate         = paramDatas.Get <DateTime>("@UserAddDate");
            interestBillInfo.UserAddDay          = paramDatas.Get <Int32>("@UserAddDay");
            interestBillInfo.ExtendCount         = paramDatas.Get <Int32>("@ExtendCount");
            interestBillInfo.Sex                 = paramDatas.Get <Int32?>("@Sex");
            interestBillInfo.ReturnInMoney       = paramDatas.Get <Double?>("@ReturnInMoney");
            interestBillInfo.TotalInMoney        = paramDatas.Get <Double?>("@TotalInMoney");
            interestBillInfo.TotalInMoneyPercent = paramDatas.Get <Double?>("@TotalInMoneyPercent");
            interestBillInfo.HeadImage           = paramDatas.Get <String>("@HeadImage");
            if (string.IsNullOrWhiteSpace(interestBillInfo.HeadImage))
            {
                interestBillInfo.HeadImage = "/imgs/users/avatar/bav_head.gif";
            }

            int temp = (int)(interestBillInfo.ReturnInMoney == null ? 0 : interestBillInfo.ReturnInMoney);
            interestBillInfo.ReturnIntegral = temp / 1000 > 100 ? 100 : temp / 1000;
            //
            var r    = 1.08 / 100;
            var d    = Math.Pow(1 + r, 10 * 12);
            var P    = temp * d;
            var P2   = temp * ((d - 1) / r);
            var pSum = P + P2;
            tenMoney = Math.Round(pSum);     //价值
            tenMoney = tenMoney < 100000 ? 100000 : tenMoney;

            double money = interestBillInfo.TotalInMoney == null ? 0 : Convert.ToDouble(interestBillInfo.TotalInMoney);
            int    sex   = interestBillInfo.Sex == null ? 1 : Convert.ToInt32(interestBillInfo.Sex);
            if (money <= 10000)
            {
                name  = sex == 1 ? "普通男青年" : "普通女青年";
                image = name == "普通男青年" ? "images/role/role1.png" : "images/role/普通女青年-.png";
            }
            else if (money > 10000 && money <= 20000)
            {
                name  = sex == 1 ? "文艺男青年" : "文艺女青年";
                image = name == "文艺男青年" ? "images/role/文艺男青年-.png" : "images/role/文艺女青年-.png";
            }
            else if (money > 20000 && money <= 30000)
            {
                name  = sex == 1 ? "经济适用男" : "小家碧玉";
                image = name == "经济适用男" ? "images/role/经济适用男.png" : "images/role/小家碧玉.png";
            }
            else if (money > 30000 && money <= 50000)
            {
                name  = sex == 1 ? "小资男" : "陀枪师姐";
                image = name == "小资男" ? "images/role/小姿男.png" : "images/role/陀枪师姐.png";
            }
            else if (money > 50000 && money <= 70000)
            {
                name  = sex == 1 ? "城市精英" : "百变御姐";
                image = name == "城市精英" ? "images/role/城市精英.png" : "images/role/百变御姐.png";
            }
            else if (money > 70000 && money <= 100000)
            {
                name  = sex == 1 ? "多金男" : "白富美";
                image = name == "多金男" ? "images/role/多金男.png" : "images/role/白富美.png";
            }
            else if (money > 100000 && money <= 150000)
            {
                name  = sex == 1 ? "土豪" : "选美皇后";
                image = name == "土豪" ? "images/role/土豪.png" : "images/role/选美皇后.png";
            }
            else if (money > 150000 && money <= 300000)
            {
                name  = sex == 1 ? "国民老公" : "国民美女";
                image = name == "国民老公" ? "images/role/国民老公.png" : "images/role/国民美女.png";
            }
            else if (money > 300000)
            {
                name  = sex == 1 ? "霸道总裁" : "富婆";
                image = name == "霸道总裁" ? "images/role/霸道总裁-.png" : "images/role/富婆.png";
            }

            #endregion

            #region
            InvestList = new List <BillInfo>();
            sqlText    = @"SELECT ISNULL(SUM(t.ParaValue3),0) AS ParaValue3,t.ParaValue1 FROM
                            (
                            SELECT ISNULL(Amount,0) AS ParaValue3,ParaValue1=
                            CASE WHEN AddDate>='2012-07-01' AND AddDate<'2013-01-01' THEN 1
                            WHEN AddDate>='2013-01-01' AND AddDate<'2013-07-01' THEN 2
                            WHEN AddDate>='2013-07-01' AND AddDate<'2014-01-01' THEN 3
                            WHEN AddDate>='2014-01-01' AND AddDate<'2014-07-01' THEN 4
                            WHEN AddDate>='2014-07-01' AND AddDate<'2015-01-01' THEN 5
                            WHEN AddDate>='2015-01-01' AND AddDate<'2015-07-01' THEN 6
                            ELSE 0 END
                            FROM dbo.Subscribe WITH(NOLOCK) WHERE SubscribeUserId=@UserId
                            ) t GROUP BY t.ParaValue1";
            DynamicParameters param = new DynamicParameters();
            param.Add("@UserId", WebUserAuth.UserId.Value);
            InvestList = PublicConn.QueryBySql <BillInfo>(sqlText, ref param);

            InvestMoney = InvestList.Where(p => p.ParaValue1 != 0).Sum(p => p.ParaValue3);
            #endregion

            #region
            ReturnList = new List <BillInfo>();
            sqlText    = @"SELECT ISNULL(SUM(t.ParaValue3),0) AS ParaValue3,t.ParaValue1 FROM
                            (
                            SELECT ISNULL(RealInterestAmout,0) AS ParaValue3,ParaValue1=
                            CASE WHEN CycDate>='2012-07-01' AND CycDate<'2013-01-01' THEN 1
                            WHEN CycDate>='2013-01-01' AND CycDate<'2013-07-01' THEN 2
                            WHEN CycDate>='2013-07-01' AND CycDate<'2014-01-01' THEN 3
                            WHEN CycDate>='2014-01-01' AND CycDate<'2014-07-01' THEN 4
                            WHEN CycDate>='2014-07-01' AND CycDate<'2015-01-01' THEN 5
                            WHEN CycDate>='2015-01-01' AND CycDate<'2015-07-01' THEN 6
                            ELSE 0 END
                            FROM dbo.SubscribeDetailHistory WITH(NOLOCK) WHERE SubscribeUserId=@UserId
                            ) t GROUP BY t.ParaValue1";
            DynamicParameters para = new DynamicParameters();
            para.Add("@UserId", WebUserAuth.UserId.Value);
            ReturnList  = PublicConn.QueryBySql <BillInfo>(sqlText, ref para);
            ReturnMoney = ReturnList.Where(p => p.ParaValue1 != 0).Sum(p => p.ParaValue3);
            #endregion
            #region
            ProjectList = new List <BillInfo>();
            sqlText     = @"SELECT ParaValue2,COUNT(0) AS ParaValue3 FROM
                            (
                            SELECT ParaValue2 =
                            CASE WHEN  dbo.f_ProjectPartition(p.Type)=1 THEN '小微企业'
                            WHEN  dbo.f_ProjectPartition(p.Type)=2 THEN '微团贷'
                            WHEN  dbo.f_ProjectPartition(p.Type)=3 THEN '证券宝'
                            WHEN  dbo.f_ProjectPartition(p.Type)=4 THEN '分期宝'
                            ELSE '净股专区' END
                            FROM dbo.Subscribe s WITH(NOLOCK)
                            LEFT JOIN Project p WITH(NOLOCK) ON s.ProjectId=p.Id
                            WHERE s.SubscribeUserId=@UserId AND dbo.f_ProjectPartition(p.Type) IS NOT NULL
                            ) t GROUP BY t.ParaValue2";
            DynamicParameters paramm = new DynamicParameters();
            paramm.Add("@UserId", WebUserAuth.UserId.Value);
            ProjectList = PublicConn.QueryBySql <BillInfo>(sqlText, ref paramm);
            double projectCount = ProjectList.Sum(p => p.ParaValue3);
            int    percent      = 0;
            for (int i = 0; i < ProjectList.Count; i++)
            {
                if (i == ProjectList.Count - 1)
                {
                    ProjectList[i].ParaValue1 = 100 - percent;
                }
                else
                {
                    ProjectList[i].ParaValue1 = (int)(ProjectList[i].ParaValue3 / projectCount * 100);
                    percent += ProjectList[i].ParaValue1;
                }
            }
            #endregion
            #region
            ExtendtList = new List <BillInfo>();
            sqlText     = @"DECLARE @ExtendKey NVARCHAR(50);
                            SELECT @ExtendKey=ExtendKey FROM dbo.UserBasicInfo WITH(NOLOCK) WHERE Id=@UserId;
                            SELECT TOP 7 NickName AS ParaValue2,HeadImage AS ParaValue4 FROM dbo.UserBasicInfo WITH(NOLOCK)
                            WHERE ExtenderKey=@ExtendKey ORDER BY AddDate DESC;
                           ";
            DynamicParameters parammm = new DynamicParameters();
            parammm.Add("@UserId", WebUserAuth.UserId.Value);
            ExtendtList = PublicConn.QueryBySql <BillInfo>(sqlText, ref parammm);
            foreach (var item in ExtendtList)
            {
                if (string.IsNullOrWhiteSpace(item.ParaValue4))
                {
                    item.ParaValue4 = "/imgs/users/avatar/bav_head.gif";
                }
            }
            #endregion
        }