ソースを参照

fixed 预约业务逻辑优化

fushengqian 11 ヶ月 前
コミット
8a2bd53e03

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

@@ -5,7 +5,9 @@ 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.param.BookableParam;
 import com.fuint.common.service.BookItemService;
+import com.fuint.common.service.BookService;
 import com.fuint.common.service.StoreService;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
@@ -51,6 +53,11 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
      */
     private StoreService storeService;
 
+    /**
+     * 预约项目服务接口
+     * */
+    private BookService bookService;
+
     /**
      * 分页查询预约订单列表
      *
@@ -137,6 +144,15 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
             }
         }
 
+        BookableParam param = new BookableParam();
+        param.setBookId(mtBookItem.getBookId());
+        param.setDate(mtBookItem.getServiceDate());
+        param.setTime(mtBookItem.getServiceTime());
+        Boolean bookable = bookService.isBookable(param);
+        if (!bookable) {
+            throw new BusinessCheckException("当前时间段不可预约,请重新选择!");
+        }
+
         Map<String, Object> params = new HashMap<>();
         params.put("merchantId", mtBookItem.getMerchantId());
         params.put("storeId", mtBookItem.getMerchantId());

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

@@ -282,7 +282,26 @@ public class BookServiceImpl extends ServiceImpl<MtBookMapper, MtBook> implement
            throw new BusinessCheckException("预约项目不存在");
        }
        Integer bookNum = mtBookItemMapper.getBookNum(param.getBookId(), param.getDate(), param.getTime());
-       return true;
+       Integer limit = 0;
+       String serviceTime = mtBook.getServiceTimes();
+       if (StringUtil.isNotEmpty(serviceTime)) {
+           String[] times = serviceTime.split(",");
+           if (times.length > 0) {
+               for (String str : times) {
+                    if (str.indexOf(param.getTime()) >= 0) {
+                        String[] timeArr = str.split("-");
+                        if (timeArr.length > 2) {
+                            limit = Integer.parseInt(timeArr[2]);
+                        }
+                    }
+               }
+           }
+       }
+       if (bookNum >= limit) {
+           return false;
+       } else {
+           return true;
+       }
     }
 
     /**

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

@@ -197,7 +197,7 @@ public class ClientBookController extends BaseController {
         mtBookItem.setMobile(mobile);
         mtBookItem.setContact(contact);
         mtBookItem.setBookId(bookInfo.getId());
-        mtBookItem.setServiceDate(DateUtil.parseDate(date));
+        mtBookItem.setServiceDate(date);
         mtBookItem.setServiceTime(time);
         MtBookItem result = bookItemService.addBookItem(mtBookItem);
 

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

@@ -53,7 +53,7 @@ public class MtBookItem implements Serializable {
     private String mobile;
 
     @ApiModelProperty("预约日期")
-    private Date serviceDate;
+    private String serviceDate;
 
     @ApiModelProperty("预约时间段")
     private String serviceTime;