瀏覽代碼

fixed 门店预约功能

fushengqian 8 月之前
父節點
當前提交
2d0a0fe8b0

+ 73 - 0
fuint-application/src/main/java/com/fuint/common/dto/BookItemDto.java

@@ -0,0 +1,73 @@
+package com.fuint.common.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 预约订单Dto
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Data
+public class BookItemDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("自增ID")
+    private Integer id;
+
+    @ApiModelProperty("所属商户ID")
+    private Integer merchantId;
+
+    @ApiModelProperty("所属店铺ID")
+    private Integer storeId;
+
+    @ApiModelProperty("预约分类ID")
+    private Integer cateId;
+
+    @ApiModelProperty("预约项目ID")
+    private Integer bookId;
+
+    @ApiModelProperty("预约项目名称")
+    private String bookName;
+
+    @ApiModelProperty("预约用户ID")
+    private Integer userId;
+
+    @ApiModelProperty("商品ID")
+    private Integer goodsId;
+
+    @ApiModelProperty("预约联系人")
+    private String contact;
+
+    @ApiModelProperty("预约手机号")
+    private String mobile;
+
+    @ApiModelProperty("预约日期")
+    private Date serviceDate;
+
+    @ApiModelProperty("预约时间段")
+    private String serviceTime;
+
+    @ApiModelProperty("预约备注")
+    private String remark;
+
+    @ApiModelProperty("预约员工ID")
+    private Integer serviceStaffId;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("更新时间")
+    private Date updateTime;
+
+    @ApiModelProperty("最后操作人")
+    private String operator;
+
+    @ApiModelProperty("A:已提交;B:审核通过;C:审核未通过;D:删除;E:已完成")
+    private String status;
+
+}

+ 2 - 1
fuint-application/src/main/java/com/fuint/common/service/BookItemService.java

@@ -1,6 +1,7 @@
 package com.fuint.common.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fuint.common.dto.BookItemDto;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.exception.BusinessCheckException;
@@ -22,7 +23,7 @@ public interface BookItemService extends IService<MtBookItem> {
      * @param paginationRequest
      * @return
      */
-    PaginationResponse<MtBookItem> queryBookItemListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
+    PaginationResponse<BookItemDto> queryBookItemListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
 
     /**
      * 添加预约订单

+ 57 - 18
fuint-application/src/main/java/com/fuint/common/service/impl/BookItemServiceImpl.java

@@ -3,6 +3,8 @@ 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.dto.BookItemDto;
+import com.fuint.common.enums.BookStatusEnum;
 import com.fuint.common.service.BookItemService;
 import com.fuint.common.service.StoreService;
 import com.fuint.framework.annoation.OperationServiceLog;
@@ -10,8 +12,9 @@ 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.mapper.MtBookMapper;
+import com.fuint.repository.model.MtBook;
 import com.fuint.repository.model.MtBookItem;
 import com.fuint.repository.model.MtStore;
 import com.github.pagehelper.PageHelper;
@@ -20,6 +23,7 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.github.pagehelper.Page;
+import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -40,10 +44,7 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
 
     private MtBookItemMapper mtBookItemMapper;
 
-    /**
-     * 系统设置服务接口
-     * */
-    private SettingService settingService;
+    private MtBookMapper mtBookMapper;
 
     /**
      * 店铺接口
@@ -57,7 +58,7 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
      * @return
      */
     @Override
-    public PaginationResponse<MtBookItem> queryBookItemListByPagination(PaginationRequest paginationRequest) {
+    public PaginationResponse<BookItemDto> queryBookItemListByPagination(PaginationRequest paginationRequest) {
         Page<MtBookItem> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
         LambdaQueryWrapper<MtBookItem> lambdaQueryWrapper = Wrappers.lambdaQuery();
         lambdaQueryWrapper.ne(MtBookItem::getStatus, StatusEnum.DISABLE.getKey());
@@ -66,6 +67,10 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
         if (StringUtils.isNotBlank(mobile)) {
             lambdaQueryWrapper.like(MtBookItem::getMobile, mobile);
         }
+        String contact = paginationRequest.getSearchParams().get("contact") == null ? "" : paginationRequest.getSearchParams().get("contact").toString();
+        if (StringUtils.isNotBlank(contact)) {
+            lambdaQueryWrapper.like(MtBookItem::getContact, contact);
+        }
         String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString();
         if (StringUtils.isNotBlank(status)) {
             lambdaQueryWrapper.eq(MtBookItem::getStatus, status);
@@ -78,13 +83,33 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
         if (StringUtils.isNotBlank(storeId)) {
             lambdaQueryWrapper.eq(MtBookItem::getStoreId, storeId);
         }
+        String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString();
+        if (StringUtils.isNotBlank(userId)) {
+            lambdaQueryWrapper.eq(MtBookItem::getUserId, userId);
+        }
+        String cateId = paginationRequest.getSearchParams().get("cateId") == null ? "" : paginationRequest.getSearchParams().get("cateId").toString();
+        if (StringUtils.isNotBlank(cateId)) {
+            lambdaQueryWrapper.eq(MtBookItem::getCateId, cateId);
+        }
 
         lambdaQueryWrapper.orderByDesc(MtBookItem::getId);
-        List<MtBookItem> dataList = mtBookItemMapper.selectList(lambdaQueryWrapper);
+        List<MtBookItem> bookItemList = mtBookItemMapper.selectList(lambdaQueryWrapper);
+        List<BookItemDto> dataList = new ArrayList<>();
+        if (bookItemList != null && bookItemList.size() > 0) {
+            for (MtBookItem mtBookItem : bookItemList) {
+                 BookItemDto bookItemDto = new BookItemDto();
+                 BeanUtils.copyProperties(mtBookItem, bookItemDto);
+                 MtBook mtBook = mtBookMapper.selectById(mtBookItem.getBookId());
+                 if (mtBook != null) {
+                     bookItemDto.setBookName(mtBook.getName());
+                 }
+                 dataList.add(bookItemDto);
+            }
+        }
 
         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<BookItemDto> paginationResponse = new PaginationResponse(pageImpl, BookItemDto.class);
         paginationResponse.setTotalPages(pageHelper.getPages());
         paginationResponse.setTotalElements(pageHelper.getTotal());
         paginationResponse.setContent(dataList);
@@ -101,7 +126,6 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
     @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("新增预约订单失败:所属商户不能为空!");
@@ -109,19 +133,30 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
         if (mtBookItem.getMerchantId() == null || mtBookItem.getMerchantId() <= 0) {
             MtStore mtStore = storeService.queryStoreById(storeId);
             if (mtStore != null) {
-                bookItem.setMerchantId(mtStore.getMerchantId());
+                mtBookItem.setMerchantId(mtStore.getMerchantId());
             }
         }
-        bookItem.setStoreId(storeId);
-        bookItem.setStatus(StatusEnum.ENABLED.getKey());
-        bookItem.setUpdateTime(new Date());
-        bookItem.setCreateTime(new Date());
-        Integer id = mtBookItemMapper.insert(bookItem);
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("merchantId", mtBookItem.getMerchantId());
+        params.put("storeId", mtBookItem.getMerchantId());
+        params.put("bookId", mtBookItem.getBookId());
+        params.put("mobile", mtBookItem.getMobile());
+        params.put("status", BookStatusEnum.CREATED.getKey());
+        List<MtBookItem> data = queryBookItemListByParams(params);
+        if (data != null && data.size() > 0) {
+            throw new BusinessCheckException("您已提交预约,请等待确认!");
+        }
+
+        mtBookItem.setStatus(BookStatusEnum.CREATED.getKey());
+        mtBookItem.setUpdateTime(new Date());
+        mtBookItem.setCreateTime(new Date());
+        Integer id = mtBookItemMapper.insert(mtBookItem);
         if (id > 0) {
-            return bookItem;
+            return mtBookItem;
         } else {
-            logger.error("新增预约订单失败.");
-            throw new BusinessCheckException("抱歉,新增预约订单失败!");
+            logger.error("新增预约记录失败.");
+            throw new BusinessCheckException("抱歉,新增预约记录失败!");
         }
     }
 
@@ -191,6 +226,7 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
         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();
+        String bookId = params.get("bookId") == null ? "" : params.get("bookId").toString();
 
         LambdaQueryWrapper<MtBookItem> lambdaQueryWrapper = Wrappers.lambdaQuery();
         if (StringUtils.isNotBlank(mobile)) {
@@ -199,6 +235,9 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
         if (StringUtils.isNotBlank(contact)) {
             lambdaQueryWrapper.like(MtBookItem::getContact, contact);
         }
+        if (StringUtils.isNotBlank(bookId)) {
+            lambdaQueryWrapper.like(MtBookItem::getBookId, bookId);
+        }
         if (StringUtils.isNotBlank(status)) {
             lambdaQueryWrapper.eq(MtBookItem::getStatus, status);
         }

+ 2 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/BookServiceImpl.java

@@ -189,7 +189,8 @@ public class BookServiceImpl extends ServiceImpl<MtBookMapper, MtBook> implement
             if (times.size() > 0) {
                 for (String time : times) {
                      TimeDto timeDto = new TimeDto();
-                     timeDto.setTime(time);
+                     String arr[] = time.split("-");
+                     timeDto.setTime(arr[0] + "-" + arr[1]);
                      timeDto.setEnable(true);
                      timeList.add(timeDto);
                 }

+ 49 - 7
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendBookItemController.java

@@ -1,6 +1,10 @@
 package com.fuint.module.backendApi.controller;
 
 import com.fuint.common.dto.AccountInfo;
+import com.fuint.common.dto.BookItemDto;
+import com.fuint.common.dto.ParamDto;
+import com.fuint.common.enums.BookStatusEnum;
+import com.fuint.common.service.BookCateService;
 import com.fuint.common.service.BookItemService;
 import com.fuint.common.service.StoreService;
 import com.fuint.common.util.TokenUtil;
@@ -12,6 +16,7 @@ import com.fuint.common.service.SettingService;
 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 com.fuint.repository.model.MtBookItem;
 import com.fuint.repository.model.MtStore;
 import com.fuint.utils.StringUtil;
@@ -21,6 +26,7 @@ import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -52,6 +58,11 @@ public class BackendBookItemController extends BaseController {
      */
     private StoreService storeService;
 
+    /**
+     * 预约分类服务接口
+     */
+    private BookCateService bookCateService;
+
     /**
      * 预约订单列表查询
      *
@@ -66,9 +77,11 @@ public class BackendBookItemController extends BaseController {
         String token = request.getHeader("Access-Token");
         Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
         Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
-        String name = request.getParameter("name");
+        String mobile = request.getParameter("mobile");
+        String contact = request.getParameter("contact");
         String status = request.getParameter("status");
-        String searchStoreId = request.getParameter("storeId");
+        String userId = request.getParameter("userId");
+        String cateId = request.getParameter("cateId");
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         Integer storeId;
@@ -86,20 +99,26 @@ public class BackendBookItemController extends BaseController {
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
             params.put("merchantId", accountInfo.getMerchantId());
         }
-        if (StringUtil.isNotEmpty(name)) {
-            params.put("name", name);
+        if (StringUtil.isNotEmpty(mobile)) {
+            params.put("mobile", mobile);
         }
         if (StringUtil.isNotEmpty(status)) {
             params.put("status", status);
         }
-        if (StringUtil.isNotEmpty(searchStoreId)) {
-            params.put("storeId", searchStoreId);
+        if (StringUtil.isNotEmpty(userId)) {
+            params.put("userId", userId);
+        }
+        if (StringUtil.isNotEmpty(cateId)) {
+            params.put("cateId", cateId);
+        }
+        if (StringUtil.isNotEmpty(contact)) {
+            params.put("contact", contact);
         }
         if (storeId != null && storeId > 0) {
             params.put("storeId", storeId);
         }
         paginationRequest.setSearchParams(params);
-        PaginationResponse<MtBookItem> paginationResponse = bookItemService.queryBookItemListByPagination(paginationRequest);
+        PaginationResponse<BookItemDto> paginationResponse = bookItemService.queryBookItemListByPagination(paginationRequest);
 
         Map<String, Object> paramsStore = new HashMap<>();
         paramsStore.put("status", StatusEnum.ENABLED.getKey());
@@ -113,10 +132,33 @@ public class BackendBookItemController extends BaseController {
         List<MtStore> storeList = storeService.queryStoresByParams(paramsStore);
         String imagePath = settingService.getUploadBasePath();
 
+        // 预约状态列表
+        BookStatusEnum[] bookStatusEnum = BookStatusEnum.values();
+        List<ParamDto> bookStatusList = new ArrayList<>();
+        for (BookStatusEnum enumItem : bookStatusEnum) {
+            ParamDto paramDto = new ParamDto();
+            paramDto.setKey(enumItem.getKey());
+            paramDto.setName(enumItem.getValue());
+            paramDto.setValue(enumItem.getKey());
+            bookStatusList.add(paramDto);
+        }
+
+        Map<String, Object> param = new HashMap<>();
+        param.put("status", StatusEnum.ENABLED.getKey());
+        if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
+            param.put("storeId", accountInfo.getStoreId().toString());
+        }
+        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
+            param.put("merchantId", accountInfo.getMerchantId());
+        }
+        List<MtBookCate> cateList = bookCateService.queryBookCateListByParams(param);
+
         Map<String, Object> result = new HashMap<>();
         result.put("dataList", paginationResponse);
         result.put("imagePath", imagePath);
         result.put("storeList", storeList);
+        result.put("bookStatusList", bookStatusList);
+        result.put("cateList", cateList);
 
         return getSuccessResult(result);
     }

+ 59 - 4
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientBookController.java

@@ -2,19 +2,21 @@ package com.fuint.module.clientApi.controller;
 
 import com.fuint.common.Constants;
 import com.fuint.common.dto.BookDto;
+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.service.BookCateService;
-import com.fuint.common.service.BookService;
-import com.fuint.common.service.MerchantService;
+import com.fuint.common.service.*;
+import com.fuint.common.util.DateUtil;
+import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
-import com.fuint.repository.model.MtBook;
 import com.fuint.repository.model.MtBookCate;
+import com.fuint.repository.model.MtBookItem;
+import com.fuint.repository.model.MtUser;
 import com.fuint.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -49,11 +51,21 @@ public class ClientBookController extends BaseController {
      * */
     private BookCateService bookCateService;
 
+    /**
+     * 预约记录服务接口
+     * */
+    private BookItemService bookItemService;
+
     /**
      * 商户服务接口
      */
     private MerchantService merchantService;
 
+    /**
+     * 会员服务接口
+     */
+    private MemberService memberService;
+
     /**
      * 获取预约项目列表
      */
@@ -136,4 +148,47 @@ public class ClientBookController extends BaseController {
 
         return getSuccessResult(result);
     }
+
+    /**
+     * 预约提交
+     */
+    @ApiOperation(value = "预约提交")
+    @RequestMapping(value = "/submit", method = RequestMethod.POST)
+    @CrossOrigin
+    public ResponseObject submit(HttpServletRequest request, @RequestBody Map<String, Object> param) throws BusinessCheckException, ParseException {
+        String token = request.getHeader("Access-Token");
+        Integer storeId = request.getHeader("storeId") == null ? 0 : Integer.parseInt(request.getHeader("storeId"));
+        String bookId = param.get("bookId") == null ? "" : param.get("bookId").toString();
+        String remark = param.get("remark") == null ? "" : param.get("remark").toString();
+        String mobile = param.get("mobile") == null ? "" : param.get("mobile").toString();
+        String contact = param.get("contact") == null ? "" : param.get("contact").toString();
+        String date = param.get("date") == null ? "" : param.get("date").toString();
+        String time = param.get("time") == null ? "" : param.get("time").toString();
+
+        UserInfo loginInfo = TokenUtil.getUserInfoByToken(token);
+        if (null == loginInfo) {
+            return getFailureResult(1001);
+        }
+
+        MtUser mtUser = memberService.queryMemberById(loginInfo.getId());
+        BookDto bookInfo = bookService.getBookById(Integer.parseInt(bookId));
+        if (bookInfo == null) {
+            return getFailureResult(2001);
+        }
+
+        MtBookItem mtBookItem = new MtBookItem();
+        mtBookItem.setCateId(bookInfo.getCateId());
+        mtBookItem.setUserId(mtUser.getId());
+        mtBookItem.setRemark(remark);
+        mtBookItem.setMerchantId(mtUser.getMerchantId());
+        mtBookItem.setStoreId(storeId);
+        mtBookItem.setMobile(mobile);
+        mtBookItem.setContact(contact);
+        mtBookItem.setBookId(bookInfo.getId());
+        mtBookItem.setServiceDate(DateUtil.parseDate(date));
+        mtBookItem.setServiceTime(time);
+        MtBookItem result = bookItemService.addBookItem(mtBookItem);
+
+        return getSuccessResult(result);
+    }
 }

+ 4 - 1
fuint-repository/src/main/java/com/fuint/repository/model/MtBookItem.java

@@ -34,6 +34,9 @@ public class MtBookItem implements Serializable {
     @ApiModelProperty("所属店铺ID")
     private Integer storeId;
 
+    @ApiModelProperty("预约分类ID")
+    private Integer cateId;
+
     @ApiModelProperty("预约ID")
     private Integer bookId;
 
@@ -53,7 +56,7 @@ public class MtBookItem implements Serializable {
     private Date serviceDate;
 
     @ApiModelProperty("预约时间段")
-    private Date serviceTime;
+    private String serviceTime;
 
     @ApiModelProperty("预约备注")
     private String remark;