Bläddra i källkod

[feat]
1、参与拼团接口;2、其他接口修改

limeng 2 månader sedan
förälder
incheckning
a76c0fd5b1

+ 46 - 13
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/TourismOrderController.java

@@ -15,14 +15,8 @@ import com.tourism.common.core.validator.AddGroup;
 import com.tourism.common.core.validator.UpdateGroup;
 import com.tourism.webadmin.app.website.dto.TourismBookProjectDto;
 import com.tourism.webadmin.back.dto.TourOrderDto;
-import com.tourism.webadmin.back.model.TourOrder;
-import com.tourism.webadmin.back.model.TourOrderPassenage;
-import com.tourism.webadmin.back.model.TourismDatePrice;
-import com.tourism.webadmin.back.model.TourismProject;
-import com.tourism.webadmin.back.service.TourOrderPassenageService;
-import com.tourism.webadmin.back.service.TourOrderService;
-import com.tourism.webadmin.back.service.TourismDatePriceService;
-import com.tourism.webadmin.back.service.TourismProjectService;
+import com.tourism.webadmin.back.model.*;
+import com.tourism.webadmin.back.service.*;
 import com.tourism.webadmin.back.vo.TourOrderVo;
 import com.tourism.webadmin.back.vo.TourOrderPassenageVo;
 import com.tourism.webadmin.back.vo.TourismProjectVo;
@@ -62,6 +56,8 @@ public class TourismOrderController {
     private TourismDatePriceService tourismDatePriceService;
     @Autowired
     private RedissonClient redissonClient;
+    @Autowired
+    private TourProjectGroupPurchaseService tourProjectGroupPurchaseService;
 
     /**
      * 列出符合过滤条件个人订单列表。
@@ -135,7 +131,45 @@ public class TourismOrderController {
      * @return 应答结果对象,包含查询结果集。
      */
     @PostMapping("/add")
-    public ResponseResult<Integer> add(@MyRequestBody TourismBookProjectDto tourBookInfoDto) {
+    public ResponseResult<Integer> add(@RequestBody TourismBookProjectDto tourBookInfoDto) {
+        TourOrderDto tourOrderDto = new TourOrderDto();
+        // 判断拼团ID是否为空,如果不为空,根据拼团ID查询拼团信息,看拼团是否已经截止
+        TourProjectGroupPurchase groupPurchase = null;
+        if (tourBookInfoDto.getGroupId() != null) {
+            groupPurchase = tourProjectGroupPurchaseService.getById(tourBookInfoDto.getGroupId());
+            if (groupPurchase != null) {
+                // 先判断下拼团信息是不是过期了
+                if (groupPurchase.getEndTime().getTime() < System.currentTimeMillis()) {
+                    return ResponseResult.error(ErrorCodeEnum.GROUP_BUYING_HAS_EXPIRED);
+                }
+            }else {
+                return ResponseResult.error(ErrorCodeEnum.GROUP_BUYING_DOES_NOT_EXIST);
+            }
+            // 计算此次订单参加拼团人数
+            Integer groupCount = tourBookInfoDto.getAdultNumber() + tourBookInfoDto.getChildrenNumber();
+            // 判断人数是不是超了,如果超了或者人数满了,自动开个完全一样的新团,直接在新团上加数量
+            if(groupCount + groupPurchase.getNowCount() >= groupPurchase.getMaxCount()) {
+                // 复制团购设置
+                TourProjectGroupPurchase newGroupPurchase = MyModelUtil.copyTo(groupPurchase, TourProjectGroupPurchase.class);
+                newGroupPurchase.setId(null);
+                newGroupPurchase.setNowCount(0);
+
+                // 增加人数,修改原有数据
+                if(groupCount + groupPurchase.getNowCount() == groupPurchase.getMaxCount()){
+                    groupPurchase.setNowCount(groupCount + groupPurchase.getNowCount());
+                    tourProjectGroupPurchaseService.updateById(groupPurchase);
+                    tourProjectGroupPurchaseService.save(newGroupPurchase);
+                }else {
+                    newGroupPurchase.setNowCount(tourBookInfoDto.getAdultNumber() + tourBookInfoDto.getChildrenNumber());
+                    tourProjectGroupPurchaseService.save(newGroupPurchase);
+                    tourBookInfoDto.setGroupId(newGroupPurchase.getId());
+                }
+            }else {
+                groupPurchase.setNowCount(groupCount + groupPurchase.getNowCount());
+                tourProjectGroupPurchaseService.updateById(groupPurchase);
+            }
+            tourOrderDto.setType(1);
+        }
 
         RBucket<Object> bucket = redissonClient.getBucket(tourBookInfoDto.getString().concat(tourBookInfoDto.getCustomerMobile()));
         if (bucket.get() != null) {
@@ -145,8 +179,8 @@ public class TourismOrderController {
         if (errorMessage != null) {
             return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
         }
-        //类型转换
-        TourOrderDto tourOrderDto = new TourOrderDto();
+
+        // 赋值
         tourOrderDto.setCustomerName(tourBookInfoDto.getCustomerName());
         tourOrderDto.setDepartureDate(tourBookInfoDto.getStartDate());
         tourOrderDto.setAdultNumber(tourBookInfoDto.getAdultNumber());
@@ -155,6 +189,7 @@ public class TourismOrderController {
         tourOrderDto.setCustomerMobile(tourBookInfoDto.getCustomerMobile());
         tourOrderDto.setCustomerMobileStandby(tourBookInfoDto.getCustomerMobileStandby());
         tourOrderDto.setCustomerWechat(tourBookInfoDto.getCustomerWechat());
+        tourOrderDto.setGroupPurchaseProgressId(tourBookInfoDto.getGroupId());
 
         TourismProject tourismProject = tourismProjectService.getById(tourOrderDto.getProjectId());
         if (tourismProject == null) {
@@ -215,6 +250,4 @@ public class TourismOrderController {
         }
         return ResponseResult.success();
     }
-
-
 }

+ 1 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebsiteProjectGroupPurchaseController.java

@@ -58,7 +58,7 @@ public class WebsiteProjectGroupPurchaseController {
      */
     @SaIgnore
     @GetMapping("/list")
-    public ResponseResult<MyPageData<com.tourism.webadmin.back.vo.TourProjectGroupPurchaseVo>> list(TourProjectGroupPurchaseDtoToWebDto dto) {
+    public ResponseResult<MyPageData<TourProjectGroupPurchaseVo>> list(TourProjectGroupPurchaseDtoToWebDto dto) {
         if (dto != null) {
             PageMethod.startPage(dto.getPageNum(), dto.getPageSize(), dto.getCount());
         }

+ 1 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/dto/TourProjectGroupPurchaseDetailDtoToWebDto.java

@@ -132,7 +132,7 @@ public class TourProjectGroupPurchaseDetailDtoToWebDto {
      * 是否统计totalCount。
      */
     @Schema(description = "是否统计totalCount。")
-    private Boolean count;
+    private Boolean count = true;
 
     /**
      * 排序。

+ 1 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/dto/TourProjectGroupPurchaseDtoToWebDto.java

@@ -213,7 +213,7 @@ public class TourProjectGroupPurchaseDtoToWebDto {
      * 每页大小。
      */
     @Schema(description = "每页大小。")
-    private Integer pageSize = 10;
+    private Integer pageSize = 100;
 
     /**
      * 是否统计totalCount。

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

@@ -43,6 +43,11 @@ public class TourismBookProjectDto {
     @NotNull(message = "开始日期不能为空!", groups = {AddGroup.class})
     private Date startDate;
 
+    /**
+     * 拼团id
+     */
+    private Long groupId;
+
     public String getString() {
         return type + "_" + projectId + "_" + adultNumber + "_" + childrenNumber + "_" + startDate + "_" + customerName + "_" + customerMobile + "_" + customerMobileStandby;
     }

+ 6 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/dto/TourOrderDto.java

@@ -218,4 +218,10 @@ public class TourOrderDto {
      */
     @Schema(description = "LIKE模糊搜索字符串")
     private String searchString;
+
+    @Schema(description = "团购ID")
+    private Long groupPurchaseProgressId;
+
+    @Schema(description = "订单类型(0.普通订单;1.拼团的订单)")
+    private Integer type;
 }

+ 6 - 7
application-webadmin/src/main/java/com/tourism/webadmin/back/vo/TourProjectGroupPurchaseVo.java

@@ -1,13 +1,12 @@
 package com.tourism.webadmin.back.vo;
 
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.tourism.common.core.base.vo.BaseVo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.math.BigDecimal;
-import java.util.Date;
+import java.time.LocalDate;
 import java.util.Map;
 
 /**
@@ -25,7 +24,7 @@ public class TourProjectGroupPurchaseVo extends BaseVo {
      * 主键id。
      */
     @Schema(description = "主键id")
-    private Long id;
+    private String id;
 
     /**
      * 项目id。
@@ -37,19 +36,19 @@ public class TourProjectGroupPurchaseVo extends BaseVo {
      * 拼团结束时间。
      */
     @Schema(description = "拼团结束时间")
-    private Date endTime;
+    private LocalDate endTime;
 
     /**
      * 出行开始时间。
      */
     @Schema(description = "出行开始时间")
-    private Date travelStartTime;
+    private LocalDate travelStartTime;
 
     /**
      * 出行结束时间。
      */
     @Schema(description = "出行结束时间")
-    private Date travelEndTime;
+    private LocalDate travelEndTime;
 
     /**
      * 拼团状态(0禁用,1启用)。
@@ -85,7 +84,7 @@ public class TourProjectGroupPurchaseVo extends BaseVo {
      * 关联字段(与从表)。
      */
     @Schema(description = "关联字段(与从表)")
-    private Long code;
+    private String code;
 
     /**
      * 当前拼团的人数。

+ 2 - 1
common/common-core/src/main/java/com/tourism/common/core/constant/ErrorCodeEnum.java

@@ -94,7 +94,8 @@ public enum ErrorCodeEnum {
     TOUR_ORDER_DRIVER_ALREADY_INORDER("司机已经被占用,请刷新页面重新下单!"),
 
     MISS_PROJECT_ID("缺少必填参数【groupPurchaseCode】"),
-
+    GROUP_BUYING_HAS_EXPIRED("团购已过期,请刷新重试!"),
+    GROUP_BUYING_DOES_NOT_EXIST("团购不存在,请刷新重试!"),
     ;
     // 下面的枚举值为特定枚举值,即开发者可以根据自己的项目需求定义更多的非通用枚举值