public void AcceptRequestGetMoney(long id, string operateUserId, string message) { try { using (ILHDBTran tran = BeginTran()) { UserManager userManager = new UserManager(tran); MoneyManager moneyManager = new MoneyManager(tran); MoneyGetDetailEntity moneyGetDetail = moneyManager.GetMoneyGetDetailEntity(id); if (moneyGetDetail.Status != (int)MoneyGetStatus.Requesting) { throw new FacadeException("此请求已经被处理!"); } UserBalanceEntity balance = userManager.GetBalance(moneyGetDetail.UserId); if (balance.Freeze.Value < moneyGetDetail.RequestMoney) { throw new FacadeException("用户账户发生异常,冻结金额不足!"); } moneyGetDetail.Status = (int)MoneyGetStatus.Accepted; moneyGetDetail.ResponseUserId = operateUserId; moneyGetDetail.ResponseMoney = moneyGetDetail.RequestMoney; moneyGetDetail.ResponseMessage = message; moneyManager.ModifyMoneyGetResponseStatus(moneyGetDetail); balance.Freeze -= moneyGetDetail.RequestMoney; balance.Balance -= moneyGetDetail.RequestMoney; userManager.ModifyBalance(balance); tran.Commit(); } } catch (FacadeException ex) { throw ex; } catch (Exception ex) { HandleException(LogCategory.Money, "处理接受提款申请失败!", ex); throw new FacadeException("处理接受提款申请失败!"); } }
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("申请提款失败!"); } }