Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void CheckPayPwd()
        {
            Guid userid = WebUserAuth.UserId.Value;

            if (userid == Guid.Empty)
            {
                PrintJson("-99", "登录已失效");
            }
            string msg          = string.Empty;
            var    isWithdrawal = new CgtCheckBLL().GetUserCgtIsOper(userid, "tixian", ref msg);

            if (!isWithdrawal)
            {
                PrintJson("-199", msg + ",不允许提现");
                return;
            }

            string  amountStr       = Context.Request.Form["amount"];
            string  couponAmountStr = Context.Request.Form["couponAmount"];
            decimal amount          = 0m;
            decimal couponAmount    = 0m;

            if (!string.IsNullOrEmpty(amountStr))
            {
                amount = Convert.ToDecimal(amountStr);
            }
            if (!string.IsNullOrEmpty(couponAmountStr))
            {
                couponAmount = Convert.ToDecimal(couponAmountStr);
            }
            string userPrizeId = Context.Request.Form["userPrizeId"];
            Guid   couponId    = new Guid();

            if (!string.IsNullOrEmpty(userPrizeId))
            {
                couponId = Guid.Parse(userPrizeId);//优惠券Id
            }
            //可提现金额
            decimal aviMoney = new UserBLL().GetDrawAviAmount(userid);

            if (amount > aviMoney)
            {
                PrintJson("-1", "申请提现金额大于可用金额");
                return;
            }

            string withdrawNo = string.Empty;

            if (GlobalUtils.IsBankService)
            {
                WXResponsePublicInfo <WXResponseWithdrawInit> init =
                    new BankFromJavaService().WithdrawalInit(new WXRequestPublicInfo <WXRequestWithdrawInit>
                {
                    serverName = TdConfig.ApplicationName,
                    reqData    = new WXRequestWithdrawInit
                    {
                        amount       = amount,
                        couponId     = couponId,
                        couponAmount = couponAmount,
                        fundType     = "USER",
                        userId       = userid,
                        withdrawType = "GATEWAY"
                    }
                });
                if (init != null)
                {
                    withdrawNo = init.respData.withdrawNo;
                }
                else
                {
                    PrintJson("-1", "生成提现申请出错");
                    return;
                }
            }
            else
            {
                string err = "";
                WithdrawResponseModel resmodel = TuanDai.Payment.Client.Withdraw.ApplyWithdraw(new WithdrawRequestModel
                {
                    Amount       = amount,
                    CouponAmount = couponAmount,
                    CouponId     = couponId,
                    FundType     = 0,
                    UserId       = userid,
                    WithdrawType = 1//1:存管通,2:定期
                }, ref err);

                if (resmodel == null)
                {
                    TuanDai.LogSystem.LogClient.LogClients.ErrorLog(TdConfig.ApplicationName, "生成提现申请出错", "", err);
                    PrintJson("-1", "生成提现申请出错");
                    return;
                }
                if (resmodel.ReturnCode != 1)
                {
                    TuanDai.LogSystem.LogClient.LogClients.ErrorLog("WXTouch", "TuanDai.Payment.Client.Withdraw.ApplyWithdraw", "提现申请错误", resmodel.ReturnMessage);
                    PrintJson("-1", resmodel.ReturnMessage);
                }

                withdrawNo = resmodel.WithdrawNo;
            }


            //申请提现金额
            //decimal handingcharge= decimal.Parse(resmodel.HandingCharge.ToString());
            //if ((aviMoney - amount - handingcharge) < 0)
            //{
            //    amount = amount - handingcharge;
            //}
            string strSQL = "SELECT TOP 1 * FROM AppWithdrewFund WHERE UserId=@UserId and WithdrawNo=@WithdrawNo";

            var dyParams = new Dapper.DynamicParameters();

            dyParams.Add("@UserId", userid);
            dyParams.Add("@WithdrawNo", withdrawNo);
            WXAppWithdrewFund fundInfo = TuanDai.DB.TuanDaiDB.QuerySingleOrDefault <WXAppWithdrewFund>(TdConfig.ApplicationName, TdConfig.DBRealRead, strSQL, ref dyParams);

            if (fundInfo == null)
            {
                PrintJson("-1", "获取提现金额失败");
                return;
            }
            var    isCallBackPayment = System.Configuration.ConfigurationManager.AppSettings["IsCallBackPayment"];
            var    paymentUrl        = System.Configuration.ConfigurationManager.AppSettings["PaymentUrl"];
            string callBackUrl       = paymentUrl + "/PaymentPlatform/H5/commonCallBack.aspx";

            if (isCallBackPayment != "1")
            {
                callBackUrl = CgtCallBackConfig.GetCgtCallBackUrl(CgtCallBackConfig.CgtCallBackType.Withdraw);
            }
            TuanDai.CunGuanTong.Model.WITHDRAW_Request info = new TuanDai.CunGuanTong.Model.WITHDRAW_Request
            {
                callbackUrl    = callBackUrl,
                platformUserNo = userid.ToString(),
                userDevice     = TuanDai.CunGuanTong.Model.userDevice.MOBILE,
                amount         = decimal.Parse(fundInfo.ActualWithdrawDeposit.Value.ToString("0.00")),
                commission     = fundInfo.HandingCharge.HasValue ? decimal.Parse(fundInfo.HandingCharge.Value.ToString("0.00")) : decimal.Zero, //,//提现手续费
                requestNo      = withdrawNo                                                                                                     //提现订单流水号
            };
            string responseStr = TuanDai.CunGuanTong.Client.FundClient.WITHDRAW_Req(info);

            PrintJson("1", responseStr);
        }