예제 #1
0
        public void RequestGetMoney(string userId, int bankType, string bankName, string cardNumber, decimal money)
        {
            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    UserManager  userManager  = new UserManager(tran);
                    MoneyManager moneyManager = new MoneyManager(tran);

                    UserBalanceEntity balance = userManager.GetBalance(userId);
                    if (money > balance.EnableMoney)
                    {
                        throw new FacadeException("余额不足");
                    }
                    MoneyGetDetailEntity moneyGetRequest = new MoneyGetDetailEntity();
                    moneyGetRequest.UserId         = userId;
                    moneyGetRequest.BankType       = bankType;
                    moneyGetRequest.BankName       = bankName;
                    moneyGetRequest.BankCardNumber = cardNumber;
                    moneyGetRequest.RequestMoney   = money;
                    moneyGetRequest.Status         = (int)MoneyGetStatus.Requesting;
                    moneyManager.AddMoneyGetRequest(moneyGetRequest);

                    if (balance.Freeze.HasValue)
                    {
                        balance.Freeze = balance.Freeze.Value + money;
                    }
                    else
                    {
                        balance.Freeze = money;
                    }
                    userManager.ModifyBalance(balance);

                    tran.Commit();
                }
            }
            catch (FacadeException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                HandleException(LogCategory.Money, "申请提款失败!", ex);
                throw new FacadeException("申请提款失败!");
            }
        }