Explorar o código

fixed 预约功能优化

fushengqian hai 10 meses
pai
achega
bfb25400d3

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

@@ -2,6 +2,8 @@ package com.fuint.common.dto;
 
 import java.io.Serializable;
 import java.util.Date;
+
+import com.fuint.repository.model.MtStore;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -25,6 +27,9 @@ public class BookItemDto implements Serializable {
     @ApiModelProperty("所属店铺ID")
     private Integer storeId;
 
+    @ApiModelProperty("所属店铺信息")
+    private MtStore storeInfo;
+
     @ApiModelProperty("预约分类ID")
     private Integer cateId;
 
@@ -40,6 +45,9 @@ public class BookItemDto implements Serializable {
     @ApiModelProperty("商品ID")
     private Integer goodsId;
 
+    @ApiModelProperty("核销码")
+    private String verifyCode;
+
     @ApiModelProperty("预约联系人")
     private String contact;
 

+ 3 - 2
fuint-application/src/main/java/com/fuint/common/enums/BookStatusEnum.java

@@ -7,9 +7,10 @@ package com.fuint.common.enums;
  * CopyRight https://www.fuint.cn
  */
 public enum BookStatusEnum {
-    CREATED("A", "已提交"),
+    CREATED("A", "待审核"),
     CONFIRM("B", "审核通过"),
-    CANCEL("C", "审核未通过"),
+    FAIL("F", "审核未通过"),
+    CANCEL("C", "已取消"),
     DELETE("D", "已删除"),
     COMPLETE("E", "已完成");
 

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

@@ -43,6 +43,15 @@ public interface BookItemService extends IService<MtBookItem> {
      */
     MtBookItem getBookItemById(Integer id) throws BusinessCheckException;
 
+    /**
+     * 根据ID获取预约订单详情
+     *
+     * @param  id 预约订单ID
+     * @throws BusinessCheckException
+     * @return
+     */
+    BookItemDto getBookDetail(Integer id) throws BusinessCheckException;
+
     /**
      * 更新预约订单
      *

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

@@ -9,6 +9,7 @@ import com.fuint.common.param.BookableParam;
 import com.fuint.common.service.BookItemService;
 import com.fuint.common.service.BookService;
 import com.fuint.common.service.StoreService;
+import com.fuint.common.util.SeqUtil;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
@@ -16,6 +17,7 @@ import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.repository.mapper.MtBookItemMapper;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.repository.mapper.MtBookMapper;
+import com.fuint.repository.mapper.MtStoreMapper;
 import com.fuint.repository.model.MtBook;
 import com.fuint.repository.model.MtBookItem;
 import com.fuint.repository.model.MtStore;
@@ -49,6 +51,8 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
 
     private MtBookMapper mtBookMapper;
 
+    private MtStoreMapper mtStoreMapper;
+
     /**
      * 店铺接口
      */
@@ -168,6 +172,7 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
         mtBookItem.setStatus(BookStatusEnum.CREATED.getKey());
         mtBookItem.setUpdateTime(new Date());
         mtBookItem.setCreateTime(new Date());
+        mtBookItem.setVerifyCode(SeqUtil.getRandomNumber(6));
         Integer id = mtBookItemMapper.insert(mtBookItem);
         if (id > 0) {
             return mtBookItem;
@@ -188,6 +193,38 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
         return mtBookItemMapper.selectById(id);
     }
 
+    /**
+     * 根据ID获取预约订单详情
+     *
+     * @param  id 预约订单ID
+     * @throws BusinessCheckException
+     * @return
+     */
+    @Override
+    public BookItemDto getBookDetail(Integer id) throws BusinessCheckException {
+        MtBookItem mtBookItem = mtBookItemMapper.selectById(id);
+        if (mtBookItem == null) {
+            throw new BusinessCheckException("预约不存在.");
+        }
+        BookItemDto bookItemDto = new BookItemDto();
+        BeanUtils.copyProperties(mtBookItem, bookItemDto);
+
+        MtBook mtBook = mtBookMapper.selectById(mtBookItem.getBookId());
+        if (mtBook != null) {
+            bookItemDto.setBookName(mtBook.getName());
+        }
+
+        if (mtBookItem.getStoreId() != null) {
+            MtStore mtStore = mtStoreMapper.selectById(mtBookItem.getStoreId());
+            if (mtStore != null) {
+                bookItemDto.setStoreInfo(mtStore);
+            }
+        }
+
+
+        return bookItemDto;
+    }
+
     /**
      * 修改预约订单
      *

+ 19 - 3
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientBookController.java

@@ -273,6 +273,7 @@ public class ClientBookController extends BaseController {
     @CrossOrigin
     public ResponseObject cancel(HttpServletRequest request) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
+        String bookId = request.getParameter("bookId");
         String remark = request.getParameter("remark") == null ? "会员取消" : request.getParameter("remark");
         UserInfo mtUser = TokenUtil.getUserInfoByToken(token);
 
@@ -280,12 +281,11 @@ public class ClientBookController extends BaseController {
             return getFailureResult(1001, "用户未登录");
         }
 
-        String orderId = request.getParameter("orderId");
-        if (StringUtil.isEmpty(orderId)) {
+        if (StringUtil.isEmpty(bookId)) {
             return getFailureResult(2000, "订单不能为空");
         }
 
-        MtBookItem bookItem = bookItemService.getBookItemById(Integer.parseInt(orderId));
+        MtBookItem bookItem = bookItemService.getBookItemById(Integer.parseInt(bookId));
         if (bookItem == null || !bookItem.getUserId().equals(mtUser.getId())) {
             return getFailureResult(2000, "预约信息有误");
         }
@@ -293,4 +293,20 @@ public class ClientBookController extends BaseController {
         Boolean result = bookItemService.cancelBook(bookItem.getId(), remark);
         return getSuccessResult(result);
     }
+
+    /**
+     * 获取我的预约详情
+     */
+    @ApiOperation(value="获取我的预约详情", notes="根据ID获取我的预约详情")
+    @RequestMapping(value = "/myBookDetail", method = RequestMethod.POST)
+    @CrossOrigin
+    public ResponseObject myBookDetail(@RequestBody BookDetailParam param) throws BusinessCheckException {
+        Integer bookId = param.getBookId() == null ? 0 : param.getBookId();
+
+        BookItemDto bookInfo = bookItemService.getBookDetail(bookId);
+        Map<String, Object> result = new HashMap<>();
+        result.put("bookInfo", bookInfo);
+
+        return getSuccessResult(result);
+    }
 }

+ 3 - 0
fuint-repository/src/main/java/com/fuint/repository/model/MtBookItem.java

@@ -46,6 +46,9 @@ public class MtBookItem implements Serializable {
     @ApiModelProperty("商品ID")
     private Integer goodsId;
 
+    @ApiModelProperty("核销码")
+    private String verifyCode;
+
     @ApiModelProperty("预约联系人")
     private String contact;