Prechádzať zdrojové kódy

fixed 优化是否可以预约功能

fushengqian 11 mesiacov pred
rodič
commit
35f227485d

+ 25 - 0
fuint-application/src/main/java/com/fuint/common/param/BookableParam.java

@@ -0,0 +1,25 @@
+package com.fuint.common.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+
+/**
+ * 可否预约请求参数
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Data
+public class BookableParam implements Serializable {
+
+    @ApiModelProperty(value="预约ID", name="bookId")
+    private Integer bookId;
+
+    @ApiModelProperty(value="预约日期", name="date")
+    private String date;
+
+    @ApiModelProperty(value="预约时间", name="time")
+    private String time;
+
+}

+ 10 - 0
fuint-application/src/main/java/com/fuint/common/service/BookService.java

@@ -2,6 +2,7 @@ package com.fuint.common.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fuint.common.dto.BookDto;
+import com.fuint.common.param.BookableParam;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.exception.BusinessCheckException;
@@ -53,6 +54,15 @@ public interface BookService extends IService<MtBook> {
      * */
     MtBook updateBook(MtBook mtBook) throws BusinessCheckException;
 
+    /**
+     * 是否可预约
+     *
+     * @param  param
+     * @throws BusinessCheckException
+     * @return
+     * */
+    Boolean isBookable(BookableParam param) throws BusinessCheckException;
+
     /**
      * 根据条件搜索预约项目
      *

+ 21 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/BookServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.dto.BookDto;
 import com.fuint.common.dto.DayDto;
 import com.fuint.common.dto.TimeDto;
+import com.fuint.common.param.BookableParam;
 import com.fuint.common.service.BookService;
 import com.fuint.common.service.StoreService;
 import com.fuint.common.util.DateUtil;
@@ -13,6 +14,7 @@ import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.repository.mapper.MtBookItemMapper;
 import com.fuint.repository.mapper.MtBookMapper;
 import com.fuint.repository.model.MtBanner;
 import com.fuint.common.service.SettingService;
@@ -50,6 +52,8 @@ public class BookServiceImpl extends ServiceImpl<MtBookMapper, MtBook> implement
 
     private MtBookMapper mtBookMapper;
 
+    private MtBookItemMapper mtBookItemMapper;
+
     /**
      * 系统设置服务接口
      * */
@@ -264,6 +268,23 @@ public class BookServiceImpl extends ServiceImpl<MtBookMapper, MtBook> implement
         return book;
     }
 
+    /**
+     * 是否可预约
+     *
+     * @param  param
+     * @throws BusinessCheckException
+     * @return
+     * */
+    @Override
+    public Boolean isBookable(BookableParam param) throws BusinessCheckException {
+       MtBook mtBook = mtBookMapper.selectById(param.getBookId());
+       if (mtBook == null) {
+           throw new BusinessCheckException("预约项目不存在");
+       }
+       Integer bookNum = mtBookItemMapper.getBookNum(param.getBookId(), param.getDate(), param.getTime());
+       return true;
+    }
+
     /**
      * 根据条件搜索预约项目
      *

+ 12 - 0
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientBookController.java

@@ -6,6 +6,7 @@ import com.fuint.common.dto.UserInfo;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.param.BookDetailParam;
 import com.fuint.common.param.BookListParam;
+import com.fuint.common.param.BookableParam;
 import com.fuint.common.service.*;
 import com.fuint.common.util.DateUtil;
 import com.fuint.common.util.TokenUtil;
@@ -149,6 +150,17 @@ public class ClientBookController extends BaseController {
         return getSuccessResult(result);
     }
 
+    /**
+     * 是否可预约
+     */
+    @ApiOperation(value="获取预约项目详情", notes="根据ID获取预约项目详情")
+    @RequestMapping(value = "/bookable", method = RequestMethod.POST)
+    @CrossOrigin
+    public ResponseObject bookable(@RequestBody BookableParam param) throws BusinessCheckException {
+        Boolean bookable = bookService.isBookable(param);
+        return getSuccessResult(bookable);
+    }
+
     /**
      * 预约提交
      */

+ 3 - 0
fuint-repository/src/main/java/com/fuint/repository/mapper/MtBookItemMapper.java

@@ -2,6 +2,7 @@ package com.fuint.repository.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fuint.repository.model.MtBookItem;
+import org.apache.ibatis.annotations.Param;
 
 /**
  *  预约订单 Mapper 接口
@@ -11,4 +12,6 @@ import com.fuint.repository.model.MtBookItem;
  */
 public interface MtBookItemMapper extends BaseMapper<MtBookItem> {
 
+    Integer getBookNum(@Param("bookId") Integer bookId, @Param("date") String date, @Param("time") String time);
+
 }

+ 7 - 0
fuint-repository/src/main/resources/mapper/MtBookItemMapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fuint.repository.mapper.MtBookItemMapper">
+    <select id="getBookNum" resultType="java.lang.Integer">
+        SELECT sum(t.id) as num FROM mt_book_item t where t.BOOK_ID = #{bookId} and t.SERVICE_DATE = #{date} and t.SERVICE_TIME = #{time} and t.STATUS !='D'
+    </select>
+</mapper>