Browse Source

add 预约功能接口服务

fushengqian 11 months ago
parent
commit
6a2a94673b

+ 63 - 0
fuint-application/src/main/java/com/fuint/common/service/BookCateService.java

@@ -0,0 +1,63 @@
+package com.fuint.common.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fuint.framework.pagination.PaginationRequest;
+import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.framework.exception.BusinessCheckException;
+import com.fuint.repository.model.MtBookCate;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 预约类别业务接口
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+public interface BookCateService extends IService<MtBookCate> {
+
+    /**
+     * 分页查询列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    PaginationResponse<MtBookCate> queryBookCateListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
+
+    /**
+     * 添加预约类别
+     *
+     * @param  mtBookCate
+     * @throws BusinessCheckException
+     * @return
+     */
+    MtBookCate addBookCate(MtBookCate mtBookCate) throws BusinessCheckException;
+
+    /**
+     * 根据ID获取预约类别
+     *
+     * @param  id
+     * @throws BusinessCheckException
+     * @return
+     */
+    MtBookCate getBookCateById(Integer id) throws BusinessCheckException;
+
+    /**
+     * 更新预约类别
+     *
+     * @param  mtBookCate
+     * @throws BusinessCheckException
+     * @return
+     * */
+    MtBookCate updateBookCate(MtBookCate mtBookCate) throws BusinessCheckException;
+
+    /**
+     * 根据条件搜索预约类别
+     *
+     * @param  params 查询参数
+     * @throws BusinessCheckException
+     * @return
+     * */
+    List<MtBookCate> queryBookCateListByParams(Map<String, Object> params) throws BusinessCheckException;
+
+}

+ 62 - 0
fuint-application/src/main/java/com/fuint/common/service/BookItemService.java

@@ -0,0 +1,62 @@
+package com.fuint.common.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fuint.framework.pagination.PaginationRequest;
+import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.framework.exception.BusinessCheckException;
+import com.fuint.repository.model.MtBookItem;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 预约订单业务接口
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+public interface BookItemService extends IService<MtBookItem> {
+
+    /**
+     * 分页查询列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    PaginationResponse<MtBookItem> queryBookItemListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
+
+    /**
+     * 添加预约订单
+     *
+     * @param  mtBookItem
+     * @throws BusinessCheckException
+     * @return
+     */
+    MtBookItem addBookItem(MtBookItem mtBookItem) throws BusinessCheckException;
+
+    /**
+     * 根据ID获取预约订单信息
+     *
+     * @param  id 预约订单ID
+     * @throws BusinessCheckException
+     * @return
+     */
+    MtBookItem getBookItemById(Integer id) throws BusinessCheckException;
+
+    /**
+     * 更新预约订单
+     *
+     * @param  mtBookItem
+     * @throws BusinessCheckException
+     * @return
+     * */
+    MtBookItem updateBookItem(MtBookItem mtBookItem) throws BusinessCheckException;
+
+    /**
+     * 根据条件搜索预约订单
+     *
+     * @param  params 查询参数
+     * @throws BusinessCheckException
+     * @return
+     * */
+    List<MtBookItem> queryBookItemListByParams(Map<String, Object> params) throws BusinessCheckException;
+}

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

@@ -0,0 +1,63 @@
+package com.fuint.common.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fuint.framework.pagination.PaginationRequest;
+import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.framework.exception.BusinessCheckException;
+import com.fuint.repository.model.MtBook;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 预约业务接口
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+public interface BookService extends IService<MtBook> {
+
+    /**
+     * 分页查询预约列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    PaginationResponse<MtBook> queryBookListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
+
+    /**
+     * 添加预约
+     *
+     * @param  mtBook
+     * @throws BusinessCheckException
+     * @return
+     */
+    MtBook addBook(MtBook mtBook) throws BusinessCheckException;
+
+    /**
+     * 根据ID获取预约信息
+     *
+     * @param  id 预约ID
+     * @throws BusinessCheckException
+     * @return
+     */
+    MtBook getBookById(Integer id) throws BusinessCheckException;
+
+    /**
+     * 更新预约
+     *
+     * @param  mtBook
+     * @throws BusinessCheckException
+     * @return
+     * */
+    MtBook updateBook(MtBook mtBook) throws BusinessCheckException;
+
+    /**
+     * 根据条件搜索预约
+     *
+     * @param  params 查询参数
+     * @throws BusinessCheckException
+     * @return
+     * */
+    List<MtBook> queryBookListByParams(Map<String, Object> params) throws BusinessCheckException;
+
+}

+ 223 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/BookCateServiceImpl.java

@@ -0,0 +1,223 @@
+package com.fuint.common.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fuint.common.service.BookCateService;
+import com.fuint.common.service.StoreService;
+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.MtBookCateMapper;
+import com.fuint.common.service.SettingService;
+import com.fuint.common.enums.StatusEnum;
+import com.fuint.repository.model.MtBookCate;
+import com.fuint.repository.model.MtStore;
+import com.github.pagehelper.PageHelper;
+import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.github.pagehelper.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.*;
+
+/**
+ * 预约分类服务接口
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Service
+@AllArgsConstructor
+public class BookCateServiceImpl extends ServiceImpl<MtBookCateMapper, MtBookCate> implements BookCateService {
+
+    private static final Logger logger = LoggerFactory.getLogger(BookCateServiceImpl.class);
+
+    private MtBookCateMapper mtBookCateMapper;
+
+    /**
+     * 系统设置服务接口
+     * */
+    private SettingService settingService;
+
+    /**
+     * 店铺接口
+     */
+    private StoreService storeService;
+
+    /**
+     * 分页查询预约分类列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    @Override
+    public PaginationResponse<MtBookCate> queryBookCateListByPagination(PaginationRequest paginationRequest) {
+        Page<MtBookCate> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        LambdaQueryWrapper<MtBookCate> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        lambdaQueryWrapper.ne(MtBookCate::getStatus, StatusEnum.DISABLE.getKey());
+
+        String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString();
+        if (StringUtils.isNotBlank(name)) {
+            lambdaQueryWrapper.like(MtBookCate::getName, name);
+        }
+        String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString();
+        if (StringUtils.isNotBlank(status)) {
+            lambdaQueryWrapper.eq(MtBookCate::getStatus, status);
+        }
+        String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString();
+        if (StringUtils.isNotBlank(merchantId)) {
+            lambdaQueryWrapper.eq(MtBookCate::getMerchantId, merchantId);
+        }
+        String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString();
+        if (StringUtils.isNotBlank(storeId)) {
+            lambdaQueryWrapper.eq(MtBookCate::getStoreId, storeId);
+        }
+
+        lambdaQueryWrapper.orderByAsc(MtBookCate::getSort);
+        List<MtBookCate> dataList = mtBookCateMapper.selectList(lambdaQueryWrapper);
+
+        PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
+        PaginationResponse<MtBookCate> paginationResponse = new PaginationResponse(pageImpl, MtBookCate.class);
+        paginationResponse.setTotalPages(pageHelper.getPages());
+        paginationResponse.setTotalElements(pageHelper.getTotal());
+        paginationResponse.setContent(dataList);
+
+        return paginationResponse;
+    }
+
+    /**
+     * 添加预约分类
+     *
+     * @param mtBookCate 分类信息
+     * @return
+     */
+    @Override
+    @OperationServiceLog(description = "添加预约分类")
+    public MtBookCate addBookCate(MtBookCate mtBookCate) throws BusinessCheckException {
+        MtBookCate bookCate = new MtBookCate();
+        Integer storeId = mtBookCate.getStoreId() == null ? 0 : mtBookCate.getStoreId();
+        if (mtBookCate.getMerchantId() == null || mtBookCate.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                bookCate.setMerchantId(mtStore.getMerchantId());
+            }
+        }
+        if (bookCate.getMerchantId() == null || bookCate.getMerchantId() <= 0) {
+            throw new BusinessCheckException("新增预约分类失败:所属商户不能为空!");
+        }
+        bookCate.setStoreId(storeId);
+        bookCate.setStatus(StatusEnum.ENABLED.getKey());
+        bookCate.setUpdateTime(new Date());
+        bookCate.setCreateTime(new Date());
+        Integer id = mtBookCateMapper.insert(bookCate);
+        if (id > 0) {
+            return bookCate;
+        } else {
+            logger.error("新增预约分类失败.");
+            throw new BusinessCheckException("抱歉,新增预约分类失败!");
+        }
+    }
+
+    /**
+     * 根据ID获取预约分类信息
+     *
+     * @param id 预约分类ID
+     * @return
+     */
+    @Override
+    public MtBookCate getBookCateById(Integer id) {
+        return mtBookCateMapper.selectById(id);
+    }
+
+    /**
+     * 修改预约分类
+     *
+     * @param  mtBookCate
+     * @throws BusinessCheckException
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @OperationServiceLog(description = "修改预约分类")
+    public MtBookCate updateBookCate(MtBookCate mtBookCate) throws BusinessCheckException {
+        MtBookCate bookCate = getBookCateById(mtBookCate.getId());
+        if (bookCate == null) {
+            throw new BusinessCheckException("该预约分类状态异常");
+        }
+
+        bookCate.setId(mtBookCate.getId());
+        if (mtBookCate.getLogo() != null) {
+            bookCate.setLogo(mtBookCate.getLogo());
+        }
+        if (mtBookCate.getName() != null) {
+            bookCate.setName(mtBookCate.getName());
+        }
+        if (mtBookCate.getStoreId() != null) {
+            bookCate.setStoreId(mtBookCate.getStoreId());
+        }
+        if (mtBookCate.getDescription() != null) {
+            bookCate.setDescription(mtBookCate.getDescription());
+        }
+        if (mtBookCate.getOperator() != null) {
+            bookCate.setOperator(mtBookCate.getOperator());
+        }
+        if (mtBookCate.getStatus() != null) {
+            bookCate.setStatus(mtBookCate.getStatus());
+        }
+        if (mtBookCate.getSort() != null) {
+            bookCate.setSort(mtBookCate.getSort());
+        }
+        bookCate.setUpdateTime(new Date());
+        mtBookCateMapper.updateById(bookCate);
+
+        return bookCate;
+    }
+
+    /**
+     * 根据条件搜索焦点图
+     *
+     * @param params 查询参数
+     * @throws BusinessCheckException
+     * @return
+     * */
+    @Override
+    public List<MtBookCate> queryBookCateListByParams(Map<String, Object> params) {
+        String status =  params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString();
+        String storeId =  params.get("storeId") == null ? "" : params.get("storeId").toString();
+        String merchantId =  params.get("merchantId") == null ? "" : params.get("merchantId").toString();
+        String name = params.get("name") == null ? "" : params.get("name").toString();
+
+        LambdaQueryWrapper<MtBookCate> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        if (StringUtils.isNotBlank(name)) {
+            lambdaQueryWrapper.like(MtBookCate::getName, name);
+        }
+        if (StringUtils.isNotBlank(status)) {
+            lambdaQueryWrapper.eq(MtBookCate::getStatus, status);
+        }
+        if (StringUtils.isNotBlank(merchantId)) {
+            lambdaQueryWrapper.eq(MtBookCate::getMerchantId, merchantId);
+        }
+        if (StringUtils.isNotBlank(storeId)) {
+            lambdaQueryWrapper.eq(MtBookCate::getStoreId, storeId);
+        }
+
+        lambdaQueryWrapper.orderByAsc(MtBookCate::getSort);
+        List<MtBookCate> dataList = mtBookCateMapper.selectList(lambdaQueryWrapper);
+        String baseImage = settingService.getUploadBasePath();
+
+        if (dataList.size() > 0) {
+            for (MtBookCate mtBookCate : dataList) {
+                 mtBookCate.setLogo(baseImage + mtBookCate.getLogo());
+            }
+        }
+
+        return dataList;
+    }
+}

+ 217 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/BookItemServiceImpl.java

@@ -0,0 +1,217 @@
+package com.fuint.common.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fuint.common.service.BookItemService;
+import com.fuint.common.service.StoreService;
+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.common.service.SettingService;
+import com.fuint.common.enums.StatusEnum;
+import com.fuint.repository.model.MtBookItem;
+import com.fuint.repository.model.MtStore;
+import com.github.pagehelper.PageHelper;
+import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.github.pagehelper.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.*;
+
+/**
+ * 预约订单服务接口
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Service
+@AllArgsConstructor
+public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookItem> implements BookItemService {
+
+    private static final Logger logger = LoggerFactory.getLogger(BookItemServiceImpl.class);
+
+    private MtBookItemMapper mtBookItemMapper;
+
+    /**
+     * 系统设置服务接口
+     * */
+    private SettingService settingService;
+
+    /**
+     * 店铺接口
+     */
+    private StoreService storeService;
+
+    /**
+     * 分页查询预约订单列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    @Override
+    public PaginationResponse<MtBookItem> queryBookItemListByPagination(PaginationRequest paginationRequest) {
+        Page<MtBookItem> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        LambdaQueryWrapper<MtBookItem> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        lambdaQueryWrapper.ne(MtBookItem::getStatus, StatusEnum.DISABLE.getKey());
+
+        String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString();
+        if (StringUtils.isNotBlank(mobile)) {
+            lambdaQueryWrapper.like(MtBookItem::getMobile, mobile);
+        }
+        String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString();
+        if (StringUtils.isNotBlank(status)) {
+            lambdaQueryWrapper.eq(MtBookItem::getStatus, status);
+        }
+        String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString();
+        if (StringUtils.isNotBlank(merchantId)) {
+            lambdaQueryWrapper.eq(MtBookItem::getMerchantId, merchantId);
+        }
+        String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString();
+        if (StringUtils.isNotBlank(storeId)) {
+            lambdaQueryWrapper.eq(MtBookItem::getStoreId, storeId);
+        }
+
+        lambdaQueryWrapper.orderByDesc(MtBookItem::getId);
+        List<MtBookItem> dataList = mtBookItemMapper.selectList(lambdaQueryWrapper);
+
+        PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
+        PaginationResponse<MtBookItem> paginationResponse = new PaginationResponse(pageImpl, MtBookItem.class);
+        paginationResponse.setTotalPages(pageHelper.getPages());
+        paginationResponse.setTotalElements(pageHelper.getTotal());
+        paginationResponse.setContent(dataList);
+
+        return paginationResponse;
+    }
+
+    /**
+     * 新增预约订单
+     *
+     * @param mtBookItem 预约信息
+     * @return
+     */
+    @Override
+    @OperationServiceLog(description = "新增预约订单")
+    public MtBookItem addBookItem(MtBookItem mtBookItem) throws BusinessCheckException {
+        MtBookItem bookItem = new MtBookItem();
+        Integer storeId = mtBookItem.getStoreId() == null ? 0 : mtBookItem.getStoreId();
+        if (mtBookItem.getMerchantId() == null || mtBookItem.getMerchantId() <= 0) {
+            throw new BusinessCheckException("新增预约订单失败:所属商户不能为空!");
+        }
+        if (mtBookItem.getMerchantId() == null || mtBookItem.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                bookItem.setMerchantId(mtStore.getMerchantId());
+            }
+        }
+        bookItem.setStoreId(storeId);
+        bookItem.setStatus(StatusEnum.ENABLED.getKey());
+        bookItem.setUpdateTime(new Date());
+        bookItem.setCreateTime(new Date());
+        Integer id = mtBookItemMapper.insert(bookItem);
+        if (id > 0) {
+            return bookItem;
+        } else {
+            logger.error("新增预约订单失败.");
+            throw new BusinessCheckException("抱歉,新增预约订单失败!");
+        }
+    }
+
+    /**
+     * 根据ID获取预约订单信息
+     *
+     * @param id 预约订单ID
+     * @return
+     */
+    @Override
+    public MtBookItem getBookItemById(Integer id) {
+        return mtBookItemMapper.selectById(id);
+    }
+
+    /**
+     * 修改预约订单
+     *
+     * @param  mtBookItem
+     * @throws BusinessCheckException
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @OperationServiceLog(description = "修改预约订单")
+    public MtBookItem updateBookItem(MtBookItem mtBookItem) throws BusinessCheckException {
+        MtBookItem bookItem = getBookItemById(mtBookItem.getId());
+        if (bookItem == null) {
+            throw new BusinessCheckException("该预约订单信息异常");
+        }
+
+        bookItem.setId(mtBookItem.getId());
+        if (mtBookItem.getBookId() != null) {
+            bookItem.setBookId(mtBookItem.getBookId());
+        }
+        if (mtBookItem.getStoreId() != null) {
+            bookItem.setStoreId(mtBookItem.getStoreId());
+        }
+        if (mtBookItem.getRemark() != null) {
+            bookItem.setRemark(mtBookItem.getRemark());
+        }
+        if (mtBookItem.getOperator() != null) {
+            bookItem.setOperator(mtBookItem.getOperator());
+        }
+        if (mtBookItem.getStatus() != null) {
+            bookItem.setStatus(mtBookItem.getStatus());
+        }
+        if (mtBookItem.getMobile() != null) {
+            bookItem.setMobile(mtBookItem.getMobile());
+        }
+
+        bookItem.setUpdateTime(new Date());
+        mtBookItemMapper.updateById(bookItem);
+        return bookItem;
+    }
+
+    /**
+     * 根据条件搜索预约订单
+     *
+     * @param  params 查询参数
+     * @throws BusinessCheckException
+     * @return
+     * */
+    @Override
+    public List<MtBookItem> queryBookItemListByParams(Map<String, Object> params) {
+        String status =  params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString();
+        String storeId =  params.get("storeId") == null ? "" : params.get("storeId").toString();
+        String merchantId =  params.get("merchantId") == null ? "" : params.get("merchantId").toString();
+        String mobile = params.get("mobile") == null ? "" : params.get("mobile").toString();
+        String contact = params.get("contact") == null ? "" : params.get("contact").toString();
+
+        LambdaQueryWrapper<MtBookItem> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        if (StringUtils.isNotBlank(mobile)) {
+            lambdaQueryWrapper.eq(MtBookItem::getMobile, mobile);
+        }
+        if (StringUtils.isNotBlank(contact)) {
+            lambdaQueryWrapper.like(MtBookItem::getContact, contact);
+        }
+        if (StringUtils.isNotBlank(status)) {
+            lambdaQueryWrapper.eq(MtBookItem::getStatus, status);
+        }
+        if (StringUtils.isNotBlank(merchantId)) {
+            lambdaQueryWrapper.eq(MtBookItem::getMerchantId, merchantId);
+        }
+        if (StringUtils.isNotBlank(storeId)) {
+            lambdaQueryWrapper.eq(MtBookItem::getStoreId, storeId);
+        }
+
+        lambdaQueryWrapper.orderByDesc(MtBookItem::getId);
+        List<MtBookItem> dataList = mtBookItemMapper.selectList(lambdaQueryWrapper);
+
+        return dataList;
+    }
+}

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

@@ -0,0 +1,225 @@
+package com.fuint.common.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import com.fuint.common.service.BookService;
+import com.fuint.common.service.StoreService;
+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.MtBookMapper;
+import com.fuint.repository.model.MtBanner;
+import com.fuint.common.service.SettingService;
+import com.fuint.common.enums.StatusEnum;
+import com.fuint.repository.model.MtBook;
+import com.fuint.repository.model.MtStore;
+import com.github.pagehelper.PageHelper;
+import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.github.pagehelper.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.*;
+
+/**
+ * 预约服务接口
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Service
+@AllArgsConstructor
+public class BookServiceImpl extends ServiceImpl<MtBookMapper, MtBook> implements BookService {
+
+    private static final Logger logger = LoggerFactory.getLogger(BookServiceImpl.class);
+
+    private MtBookMapper mtBookMapper;
+
+    /**
+     * 系统设置服务接口
+     * */
+    private SettingService settingService;
+
+    /**
+     * 店铺接口
+     */
+    private StoreService storeService;
+
+    /**
+     * 分页查询预约列表
+     *
+     * @param paginationRequest
+     * @return
+     */
+    @Override
+    public PaginationResponse<MtBook> queryBookListByPagination(PaginationRequest paginationRequest) {
+        Page<MtBanner> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        LambdaQueryWrapper<MtBook> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        lambdaQueryWrapper.ne(MtBook::getStatus, StatusEnum.DISABLE.getKey());
+
+        String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString();
+        if (StringUtils.isNotBlank(name)) {
+            lambdaQueryWrapper.like(MtBook::getName, name);
+        }
+        String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString();
+        if (StringUtils.isNotBlank(status)) {
+            lambdaQueryWrapper.eq(MtBook::getStatus, status);
+        }
+        String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString();
+        if (StringUtils.isNotBlank(merchantId)) {
+            lambdaQueryWrapper.eq(MtBook::getMerchantId, merchantId);
+        }
+        String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString();
+        if (StringUtils.isNotBlank(storeId)) {
+            lambdaQueryWrapper.eq(MtBook::getStoreId, storeId);
+        }
+
+        lambdaQueryWrapper.orderByAsc(MtBook::getSort);
+        List<MtBook> dataList = mtBookMapper.selectList(lambdaQueryWrapper);
+
+        PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
+        PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
+        PaginationResponse<MtBook> paginationResponse = new PaginationResponse(pageImpl, MtBook.class);
+        paginationResponse.setTotalPages(pageHelper.getPages());
+        paginationResponse.setTotalElements(pageHelper.getTotal());
+        paginationResponse.setContent(dataList);
+
+        return paginationResponse;
+    }
+
+    /**
+     * 添加预约
+     *
+     * @param mtBook 预约信息
+     * @return
+     */
+    @Override
+    @OperationServiceLog(description = "添加预约")
+    public MtBook addBook(MtBook mtBook) throws BusinessCheckException {
+        Integer storeId = mtBook.getStoreId() == null ? 0 : mtBook.getStoreId();
+        if (mtBook.getMerchantId() == null || mtBook.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                mtBook.setMerchantId(mtStore.getMerchantId());
+            }
+        }
+        if (mtBook.getMerchantId() == null || mtBook.getMerchantId() <= 0) {
+            throw new BusinessCheckException("新增预约失败:所属商户不能为空!");
+        }
+        mtBook.setStoreId(storeId);
+        mtBook.setStatus(StatusEnum.ENABLED.getKey());
+        mtBook.setUpdateTime(new Date());
+        mtBook.setCreateTime(new Date());
+        Integer id = mtBookMapper.insert(mtBook);
+        if (id > 0) {
+            return mtBook;
+        } else {
+            logger.error("新增预约失败.");
+            throw new BusinessCheckException("抱歉,新增预约失败!");
+        }
+    }
+
+    /**
+     * 根据ID获取预约信息
+     *
+     * @param id 预约ID
+     * @return
+     */
+    @Override
+    public MtBook getBookById(Integer id) {
+        return mtBookMapper.selectById(id);
+    }
+
+    /**
+     * 修改预约
+     *
+     * @param  mtBook
+     * @throws BusinessCheckException
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @OperationServiceLog(description = "修改预约")
+    public MtBook updateBook(MtBook mtBook) throws BusinessCheckException {
+        MtBook book = getBookById(mtBook.getId());
+        if (book == null) {
+            throw new BusinessCheckException("该预约状态异常");
+        }
+        book.setId(book.getId());
+        if (book.getLogo() != null) {
+            book.setLogo(mtBook.getLogo());
+        }
+        if (book.getName() != null) {
+            book.setName(mtBook.getName());
+        }
+        if (mtBook.getStoreId() != null) {
+            book.setStoreId(mtBook.getStoreId());
+        }
+        if (mtBook.getDescription() != null) {
+            book.setDescription(mtBook.getDescription());
+        }
+        if (mtBook.getOperator() != null) {
+            book.setOperator(mtBook.getOperator());
+        }
+        if (mtBook.getStatus() != null) {
+            book.setStatus(mtBook.getStatus());
+        }
+        if (mtBook.getGoodsId() != null) {
+            book.setGoodsId(mtBook.getGoodsId());
+        }
+        if (mtBook.getSort() != null) {
+            book.setSort(mtBook.getSort());
+        }
+        book.setUpdateTime(new Date());
+        mtBookMapper.updateById(book);
+        return book;
+    }
+
+    /**
+     * 根据条件搜索预约
+     *
+     * @param  params 查询参数
+     * @throws BusinessCheckException
+     * @return
+     * */
+    @Override
+    public List<MtBook> queryBookListByParams(Map<String, Object> params) {
+        String status =  params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString();
+        String storeId =  params.get("storeId") == null ? "" : params.get("storeId").toString();
+        String merchantId =  params.get("merchantId") == null ? "" : params.get("merchantId").toString();
+        String name = params.get("name") == null ? "" : params.get("name").toString();
+
+        LambdaQueryWrapper<MtBook> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        if (StringUtils.isNotBlank(name)) {
+            lambdaQueryWrapper.like(MtBook::getName, name);
+        }
+        if (StringUtils.isNotBlank(status)) {
+            lambdaQueryWrapper.eq(MtBook::getStatus, status);
+        }
+        if (StringUtils.isNotBlank(merchantId)) {
+            lambdaQueryWrapper.eq(MtBook::getMerchantId, merchantId);
+        }
+        if (StringUtils.isNotBlank(storeId)) {
+            lambdaQueryWrapper.eq(MtBook::getStoreId, storeId);
+        }
+
+        lambdaQueryWrapper.orderByAsc(MtBook::getSort);
+        List<MtBook> dataList = mtBookMapper.selectList(lambdaQueryWrapper);
+        String baseImage = settingService.getUploadBasePath();
+
+        if (dataList.size() > 0) {
+            for (MtBook book : dataList) {
+                 book.setLogo(baseImage + book.getLogo());
+            }
+        }
+
+        return dataList;
+    }
+}