Эх сурвалжийг харах

[fix]
1、增加预定校验

limeng 5 сар өмнө
parent
commit
9e7476c429

+ 4 - 0
application-webadmin/src/main/java/com/tourism/webadmin/app/website/dto/TourismBookProjectDto.java

@@ -22,4 +22,8 @@ public class TourismBookProjectDto {
 
     @NotNull(message = "预定日期不能为空!")
     private Date startDate;
+
+    public String getString() {
+        return type + "_" + projectId + "_" + adultNumber + "_" + childrenNumber + "_" + startDate;
+    }
 }

+ 6 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/service/impl/TourismProjectToWebServiceImpl.java

@@ -194,18 +194,23 @@ public class TourismProjectToWebServiceImpl implements TourismProjectToWebServic
     }
 
     @Override
-    public Boolean bookProject(HttpServletRequest request,@MyRequestBody TourismBookProjectDto tourBookInfoDto) {
+    public Boolean bookProject(HttpServletRequest request, TourismBookProjectDto tourBookInfoDto) {
         //获取用户的手机号
         Long userId = TokenData.takeFromRequest().getUserId();
         TourUser tourUser = tourUserService.getById(userId);
         String mobile = tourUser.getMobile();
 
+        if(tourBookInfoDto == null){
+            throw new RuntimeException("预定参数为空!");
+        }
+
         //根据当前日期,查询当天的项目日历价格
         TourismDatePrice tourismDatePrice = new TourismDatePrice();
         tourismDatePrice.setProjectId(tourBookInfoDto.getProjectId());
         tourismDatePrice.setDepartureDate(tourBookInfoDto.getStartDate());
         TourismDatePrice tourismDatePriceOne = tourismDatePriceService.getOne(tourismDatePrice);
 
+
         //构建预定的数据进行保存
         TourBookInfo tourBookInfo = new TourBookInfo();
         tourBookInfo.setType(tourBookInfoDto.getType());

+ 5 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/model/TourBookInfo.java

@@ -136,4 +136,9 @@ public class TourBookInfo extends BaseModel {
             dictCode = "IsHandle")
     @TableField(exist = false)
     private Map<String, Object> isHandleDictMap;
+
+
+    public String getString() {
+        return type + "_" + projectId + "_" + adultNumber + "_" + childrenNumber + "_" + startTime;
+    }
 }