一、引言

1.1 迭代目标

完成各项关键功能的完整测试,保证系统稳定运行

1.2 迭代测试记录

编号 内容 测试人员 更新时间
1 测试 王绍威 2020/3/31

二、前端实现

  • 1、实现入住办理页面

    • ①实现输入顾客信息(姓名、身份证、性别等)便出现用户预定的房间类型,而后跳转至入住页面,由前台工作人员为其挑选对应房型的房号

      1. /** 入住按钮操作 */
      2. handleCheckIn(row) {
      3. this.resetForm();
      4. this.checkDTO.roomId = row.roomId;
      5. getRoom(row.roomId).then((response) => {
      6. this.form = response.data;
      7. this.openci = true;
      8. this.title = "入住办理";
      9. });
      10. },
      11. /** 入住提交按钮 */
      12. submitCheckIn() {
      13. CheckIn(this.checkDTO).then((response) => {
      14. this.$message.success(response.data);
      15. });
      16. },
      17. /** 查询入住人员信息 */
      18. QueryCheckIn() {
      19. QueryCI(this.personform).then((response) => {
      20. setTimeout(100000)
      21. this.personform = response.data.customer1;
      22. // this.checkDTO = response.data;
      23. this.personform.fromDate = response.data.fromDate;
      24. this.personform.toDate = response.data.toDate;
      25. this.checkDTO.customerName=response.data.customer1.customerName;
      26. });
      27. },
    • ②如用户未提前预定,需要工作人员进行现场为其办理入住,则需要输入顾客信息以及顾客需要的房型、入住时间、退房时间等相应信息进行办理,再给予顾客对应房型的房号信息

      1. methods: {
      2. submitForm() {
      3. this.formData.customerStringList =
      4. '[{customerName:"' +
      5. this.formData.customerName +
      6. '","idCard":"' +
      7. this.formData.idCard +
      8. '","customerPhone":"' +
      9. this.formData.customerPhone +
      10. '"}]';
      11. // this.formData.customerStringList="customerName";
      12. submitOrder(this.formData).then((response) => {
      13. this.orderId = response.data;
      14. if (response.data) {
      15. this.$message.success("提交成功");
      16. this.open=true;
      17. } else {
      18. this.$message.error("提交失败,请重新提交");
      19. }
      20. });
      21. },
      22. handlePayMoney(){
      23. paymoney(this.orderId).then((response)=>{
      24. if(response.data){
      25. this.$message.success("付款成功");
      26. }
      27. this.open=false;
      28. })
      29. },
      30. handleSumOfOrder() {
      31. orderSumPrice(this.formData).then((response) => {
      32. this.sumPrice = response.data
      33. });
      34. },
      35. /** 数据编辑对话框取消按钮 */
      36. cancel() {
      37. this.open = false;
      38. },
      39. resetForm() {
      40. this.$refs["Form"].resetFields();
      41. },
      42. },
  • 2、实现对后端接口的响应

    • 对以上操作行为对后端服务器做出响应,使得服务器能实时返回对应的订单总金额、以及顾客预定的订单信息、入住信息等对应数据

      1. // 入住,参数为房间号和人
      2. export function CheckIn(data) {
      3. return request({
      4. url: "/hotCheck/checkIn",
      5. method: "get",
      6. params: data
      7. })
      8. }
      9. // 查询入住人订的房
      10. export function QueryCI(data) {
      11. return request({
      12. url: "/hotCheck/getOrderDetail",
      13. method: "get",
      14. params: data
      15. })
      16. }
    • 实时响应入住的房型房号是否处于可预定状态,动态显示未被预定、未清理及入住等相应情况的房间。(白为可预订、黄为未清理、红为已预定或已入住)

      1. // 查询room列表
      2. export function submitOrder(data) {
      3. return request({
      4. url: "/booking",
      5. method: "post",
      6. params: data
      7. })
      8. }
      9. export function orderSumPrice(data) {
      10. return request({
      11. url: "/hotCalculate/totalPrice",
      12. method: "get",
      13. params: data
      14. })
      15. }
      16. export function paymoney(orderId) {
      17. return request({
      18. url: "/hotOrderPay/paid/"+orderId,
      19. method: "get"
      20. })
      21. }

      三、后端实现

  • 1、实现预定办理接口booking:

    • 规范化输入及查询关联信息

      1. /**
      2. * 预定房型的接口
      3. *
      4. * @param bookingDTO
      5. * @return 是否成功
      6. */
      7. @Override
      8. public boolean booking(BookingDTO bookingDTO) {
      9. if (!normalizedInput(bookingDTO)) {
      10. return false;
      11. }
      12. //BookingDTO 转换为 HotOrder
      13. HotOrder hotOrder = this.convertor.convertor(bookingDTO,HotOrder.class);
      14. //插入订单信息到数据库
      15. HotOrder order = insert(hotOrder);
      16. //获取顾客信息并插入到顾客信息表
      17. List<HotCustomer> customerList = bookingDTO.getCustomerList();
      18. for (HotCustomer customer : customerList) {
      19. customer.setOrderId(order.getOrderId());
      20. hotCustomerMapper.insert(customer);
      21. }
      22. return true;
      23. }
      24. /**
      25. * 规范化输入,获取流水号,订单创建时间,设定订单状态
      26. *
      27. * @param bookingDTO
      28. * @return 是否合规
      29. */
      30. @Override
      31. public boolean normalizedInput(BookingDTO bookingDTO) {
      32. if (bookingDTO.getTypeId() == null) {
      33. return false;
      34. }
      35. if (bookingDTO.getDiscountId() == null) {
      36. return false;
      37. }
      38. if (bookingDTO.getFromDate() == null) {
      39. return false;
      40. }
      41. if (bookingDTO.getToDate() == null) {
      42. return false;
      43. }
      44. if (bookingDTO.getCustomerStringList() == null) {
      45. return false;
      46. }
      47. //str转list
      48. String customerStringList = bookingDTO.getCustomerStringList();
      49. List<HotCustomer> customerList = JSONObject.parseArray(customerStringList,HotCustomer.class);
      50. bookingDTO.setCustomerList(customerList);
      51. //获取当前时间为订单创建时间
      52. Date date = new Date();
      53. bookingDTO.setOrderBuildTime(date);
      54. //获取最新流水号
      55. bookingDTO.setOrderNo(SerialNumber.newInstance("HO",date).toString());
      56. //设定订单状态为创建未完成支付
      57. bookingDTO.setOrderStatus(0);
      58. return true;
      59. }
  • 2、入住业务实现

    • 检查前端输入的客户信息,通过顾客预留信息查询关联的预定订单信息,显示对应房型信息 ```java /**
      • 通过房型查询房间信息 *
      • @param hotType
      • @return List 该房型所属的房间对象 */ @Override public List queryByHotType(HotType hotType) { Integer typeId = hotType.getTypeId(); HotRoom hotRoom = new HotRoom(); hotRoom.setTypeId(typeId); return hotRoomMapper.queryAll(hotRoom); }

/**

  • 通过时间段, 房型id, 查询对应时间内每一天的房型剩余间数 *
  • @param hotOrder 需要有fromDate,toDate
  • @return HashMap<日期时间戳,剩余间数> */ @Override public HashMap getReserve(HotOrder hotOrder) { // 对结果集进行初始化,在hashmap中增加n个<日期,最大库存数> HashMap res = new HashMap<>(); //查询的开始和结束时间 long fromDate = hotOrder.getFromDate().getTime(); long toDate = hotOrder.getToDate().getTime(); long tempDate = fromDate; while (tempDate <= toDate) {

    1. HotRoom hotRoom = new HotRoom();
    2. hotRoom.setTypeId(hotOrder.getTypeId());
    3. res.put(tempDate,hotRoomMapper.count(hotRoom));

    // 时间戳增加一天

    1. tempDate += 1000 * 60 * 60 * 24;

    } // 查询订单表,返回在输入的时间范围内的订单对象 List hotOrders = hotOrderMapper.queryAll(hotOrder); for (HotOrder order : hotOrders) {

    1. tempDate = order.getFromDate().getTime();
    2. long endDate = order.getToDate().getTime();
    3. // 当前时间<=订单结束时间||查询结束时间
    4. while (tempDate <= endDate && tempDate <= toDate) {
    5. //当前时间<查询开始时间
    6. if (tempDate < fromDate) {
    7. tempDate += 1000 * 60 * 60 * 24;
    8. continue;
    9. }
    10. res.put(tempDate,res.get(tempDate) == null ? -1000 : res.get(tempDate) - 1);
    11. //时间戳增加一天
    12. tempDate += 1000 * 60 * 60 * 24;
    13. }

    } return res; } ```

    • 由前台人员现场办理入住并手动输入顾客及相应房型信息

      四、数据存储与处理实现

  • 简化数据库的SQL,减少对数据库操作、例如count函数以及进行左右连接等需求。基本在程序代码上对SQL进行改进,增加服务器的代码容量,减少数据库的压力。只对数据库进行查数据,进行每个表的单独查询,操作数据的事交给服务器利用Java代码实现。

    测试报告

    单元测试

  • 1、预定房型功能

    • 后端返回

image.png

  • 前端显示
    • 2、入住功能
  • 后端返回顾客信息预留信息的对应房型信息
  • 前端通过后端传回的数据或自行输入的数据给予后端对应数据以获取对应订单号即准许前台人员对入住顾客进行房号分配(未办理预定的则需现场输入房型等信息)

image.png

用例测试

序号 用例 实现
1 前台询问顾客入住房型。 通过
2 工作人员查询对应房型的空房数量。 通过
3 顾客出示身份证办理入住 通过
4 前台工作人员填写顾客个人信息和入住/退房时间 通过
5 工作人员告知顾客应付房费 通过
6 顾客付款 通过

步骤:

  • 顾客下单订单,选择对应可住房型(房型仍然有房间空着),入住时间及退房时间等;

image.png
image.png
image.png

  • 挑选完毕,付款后可以到前台工作人员查询并为其挑选房间;

image.png

  • 顾客出示身份信息并作登记,与订房订单等作绑定操作,方便后续查询

image.png

  • 按下回车,显示预定的预留订单信息

image.png

  • 前台工作人员为其挑选对应房型房间,提交订单,入住手续办理完毕image.png