Java银行存取款程序:操作、货币兑换及账户管理

版权申诉
5星 · 超过95%的资源 0 下载量 97 浏览量 更新于2024-10-12 收藏 11KB RAR 举报
资源摘要信息:"这是一个关于银行存取款操作的Java程序。该程序设计用于实现个人账户的存取款功能以及汇率兑换和查看账户信息等操作。程序采用面向对象的方法,涉及的类包括Bank(银行类)、Account(账户类)、Customer(顾客类)、Money(货币的抽象基类)、Rate(汇率类)以及RMB和USD类(分别代表人民币和美元类)。开发和调试环境为Java SDK 1.3.1,操作系统的环境为Windows 2000。" 知识点详细说明: 1. Java编程语言基础 - Java是一种广泛使用的面向对象的编程语言,具有跨平台特性。 - Java SDK(Software Development Kit)是Java开发工具包,提供开发Java程序所需的编译器、调试器和其他工具。 - 面向对象编程(OOP)的三大特征:封装、继承和多态性。 2. 银行存取款操作 - 存款(Deposit):将货币存入银行账户的操作。 - 取款(Withdrawal):从银行账户中取出货币的操作。 - 账户信息查询(Account Information Inquiry):查看个人账户的余额、交易记录等信息。 - 货币兑换(Currency Exchange):根据汇率将一种货币兑换为另一种货币。 - 银行业务(Banking Services):银行提供的所有与金钱相关的服务。 3. 程序设计概念 - 类(Class):在Java中,类是创建对象的模板或蓝图。 - 对象(Object):类的实例,代表具有特定属性和行为的实体。 - 线程(Thread):程序中的一个执行路径,允许并发执行任务。 - 抽象类(Abstract Class):不能直接实例化的类,通常作为其他类的基类。 4. Java集合框架 - Java集合框架是一组接口和类,用于存储和操作对象集合。 - 常用的集合类包括ArrayList、HashMap等,适合存储和管理账户信息。 5. 异常处理 - Java中的异常处理机制允许程序在遇到错误时优雅地恢复。 - 常用的异常处理语句包括try-catch块。 6. 数据类型和变量 - 基本数据类型(如int, float)和引用数据类型(如类的实例)。 - 变量的声明、初始化和使用。 7. 操作系统和开发环境 - Windows 2000是微软发布的一个桌面操作系统版本。 - 开发环境对Java程序的构建、测试和部署至关重要。 8. 银行软件开发的特定概念 - 账户类通常包含账户号码、余额、账户类型等属性。 - 银行类负责管理多个账户、执行交易、记录日志等。 - 汇率类处理货币之间的兑换率,并更新相关的汇率信息。 - 程序需要考虑事务处理的原子性和一致性,确保银行操作的安全性。 9. 汇率机制 - 汇率是不同货币之间的兑换比率。 - 程序中通常需要一个汇率类来计算不同货币间的兑换值。 10. 多线程编程 - Java中的多线程编程允许多个线程同时执行,提高程序效率。 - 需要考虑同步问题,避免竞态条件和数据不一致的问题。 通过以上知识点,可以全面了解开发一个银行存取款系统所需掌握的编程技术和概念,以及涉及到的业务逻辑和软件工程实践。这些知识点为编写一个稳定、高效和安全的银行业务系统提供了坚实的基础。

优化这段代码 // 判断该用户是否是自研用户 if (!OverseaUtils.isOversea(clientId)) { throw new BusinessException(180000, "非自研用户,无法使用基金提取至银行卡"); } // 判断币种信息 if ("0".equals(request.getCurrency())) { throw new BusinessException(180001, "人民币无法使用该功能"); } DepositBalanceResponse depositBalanceResponse = new DepositBalanceResponse(); WithdrawalsFundReq withdrawalsFundReq = new WithdrawalsFundReq(); InComeReq inComeReq = new InComeReq(); inComeReq.setIncomeCurrency(request.getCurrency()); List<OwnBankCardVo> allOwnBankCards = bankCardManagerAppService.getAllOwnBankCards(clientId, null, RequestUtil.getClientIp(), inComeReq); if (allOwnBankCards.size() > 0) { boolean verifyBankWithdrawFunds = verifyBankWithdrawFundsRepository.verifyBankWithdrawFunds(clientId, allOwnBankCards.get(0).getNumber(), deviceId); if (!verifyBankWithdrawFunds) { throw new BusinessException(180021, "根据监管要求,请使用单笔入金达到10000港币(或等值其他货币)的银行卡进行出金操作"); } if (allOwnBankCards.get(0).isBoundTrans() && allOwnBankCards.get(0).getOutcomeStatus().contains(request.getCurrency())) { withdrawalsFundReq.withdrawalMode = "4"; depositBalanceResponse.setManner("0"); } else { withdrawalsFundReq.withdrawalMode = "6"; depositBalanceResponse.setManner("1"); } } else { throw new BusinessException(180003, "请输入正确的eid"); } withdrawalsFundReq.bankEid = request.getEid(); withdrawalsFundReq.balance = request.getBalance(); withdrawalsFundReq.stockCode = request.getStockCode(); withdrawalsFundReq.clientId = clientId; BaseResponse<WithdrawalsFundDTO> withdrawalsFundDTOBaseResponse = tradeFundHandler.withdrawalsFund(withdrawalsFundReq); if (withdrawalsFundDTOBaseResponse != null) { if (withdrawalsFundDTOBaseResponse.getStatus() == 0 && withdrawalsFundDTOBaseResponse.getData() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); depositBalanceResponse.setClientId(clientId); depositBalanceResponse.setCommitTime(simpleDateFormat.format(new Date())); depositBalanceResponse.setEid(withdrawalsFundDTOBaseResponse.getData().eid); } if (withdrawalsFundDTOBaseResponse.getStatus() != 0) { if (-2302004 == withdrawalsFundDTOBaseResponse.getStatus()) { throw new BusinessException(OutComeEnum.BANKING_SECURITIES_BUSINESS_IS_NOT_ALLOWED.getId(), OutComeEnum.BANKING_SECURITIES_BUSINESS_IS_NOT_ALLOWED.getName()); } throw new BusinessException(withdrawalsFundDTOBaseResponse.getStatus(), withdrawalsFundDTOBaseResponse.getMessage(), false); } } return depositBalanceResponse;

2023-02-08 上传

优化一下代码并给出详细代码 // 判断该用户是否是自研用户 if (!OverseaUtils.isOversea(clientId)) { throw new BusinessException(180000, "非自研用户,无法使用基金提取至银行卡"); } // 判断币种信息 if ("0".equals(request.getCurrency())) { throw new BusinessException(180001, "人民币无法使用该功能"); } DepositBalanceResponse depositBalanceResponse = new DepositBalanceResponse(); WithdrawalsFundReq withdrawalsFundReq = new WithdrawalsFundReq(); InComeReq inComeReq = new InComeReq(); inComeReq.setIncomeCurrency(request.getCurrency()); List<OwnBankCardVo> allOwnBankCards = bankCardManagerAppService.getAllOwnBankCards(clientId, null, RequestUtil.getClientIp(), inComeReq); if (allOwnBankCards.size() > 0) { boolean verifyBankWithdrawFunds = verifyBankWithdrawFundsRepository.verifyBankWithdrawFunds(clientId, allOwnBankCards.get(0).getNumber(), deviceId); if (!verifyBankWithdrawFunds) { throw new BusinessException(180021, "根据监管要求,请使用单笔入金达到10000港币(或等值其他货币)的银行卡进行出金操作"); } if (allOwnBankCards.get(0).isBoundTrans() && allOwnBankCards.get(0).getOutcomeStatus().contains(request.getCurrency())) { withdrawalsFundReq.withdrawalMode = "4"; depositBalanceResponse.setManner("0"); } else { withdrawalsFundReq.withdrawalMode = "6"; depositBalanceResponse.setManner("1"); } } else { throw new BusinessException(180003, "请输入正确的eid"); } withdrawalsFundReq.bankEid = request.getEid(); withdrawalsFundReq.balance = request.getBalance(); withdrawalsFundReq.stockCode = request.getStockCode(); withdrawalsFundReq.clientId = clientId; BaseResponse<WithdrawalsFundDTO> withdrawalsFundDTOBaseResponse = tradeFundHandler.withdrawalsFund(withdrawalsFundReq); if (withdrawalsFundDTOBaseResponse != null) { if (withdrawalsFundDTOBaseResponse.getStatus() == 0 && withdrawalsFundDTOBaseResponse.getData() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); depositBalanceResponse.setClientId(clientId); depositBalanceResponse.setCommitTime(simpleDateFormat.format(new Date())); depositBalanceResponse.setEid(withdrawalsFundDTOBaseResponse.getData().eid); } if (withdrawalsFundDTOBaseResponse.getStatus() != 0) { if (-2302004 == withdrawalsFundDTOBaseResponse.getStatus()) { throw new BusinessException(OutComeEnum.BANKING_SECURITIES_BUSINESS_IS_NOT_ALLOWED.getId(), OutComeEnum.BANKING_SECURITIES_BUSINESS_IS_NOT_ALLOWED.getName()); } throw new BusinessException(withdrawalsFundDTOBaseResponse.getStatus(), withdrawalsFundDTOBaseResponse.getMessage(), false); } } return depositBalanceResponse;

2023-02-08 上传