Browse Source

[feat]
1、拼团接口增加默认查询时间

limeng 2 months ago
parent
commit
9c59714885

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

@@ -223,7 +223,7 @@ public class TourismOrderController {
             // 如果参与了团购
             // 超过拼团截止日期的不允许取消
             TourProjectGroupPurchase groupPurchase = tourProjectGroupPurchaseService.getById(tourOrder.getGroupPurchaseProgressId());
-            Date newDate = MyDateUtil.AddDays(groupPurchase.getEndTime(), 1);
+            Date newDate = MyDateUtil.addDays(groupPurchase.getEndTime(), 1);
             if (newDate.getTime() < System.currentTimeMillis()) {
                 throw new MyRuntimeException(ErrorCodeEnum.GROUP_BUYING_HAS_EXPIRED_CANNOT_BE_CANCELLED.getErrorMessage());
             }

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

@@ -13,7 +13,6 @@ import com.tourism.webadmin.app.website.vo.TourGroupPurchaseUserVo;
 import com.tourism.webadmin.back.model.TourProjectGroupPurchase;
 import com.tourism.webadmin.back.model.TourProjectGroupPurchaseDetail;
 import com.tourism.webadmin.back.model.TourUser;
-import com.tourism.webadmin.back.model.TourismDatePrice;
 import com.tourism.webadmin.back.service.TourOrderService;
 import com.tourism.webadmin.back.service.TourProjectGroupPurchaseDetailService;
 import com.tourism.webadmin.back.service.TourProjectGroupPurchaseService;
@@ -21,11 +20,13 @@ import com.tourism.webadmin.back.service.TourismDatePriceService;
 import com.tourism.webadmin.back.vo.TourProjectGroupPurchaseVo;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.time.ZoneId;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -64,7 +65,16 @@ public class WebsiteProjectGroupPurchaseController {
         if (dto != null) {
             PageMethod.startPage(dto.getPageNum(), dto.getPageSize(), dto.getCount());
         }
-//        dto.setSuccess(0);
+
+        // 判断是不是有出发日期查询条件,如果没传,默认查前后30天的数据
+        if(StringUtils.isBlank(dto.getTravelStartTimeStart()) && StringUtils.isBlank(dto.getTravelStartTimeEnd())) {
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date startDate = MyDateUtil.addDays(new Date(), -30);
+            Date endDate = MyDateUtil.addDays(new Date(), 30);
+
+            dto.setTravelStartTimeStart(format.format(startDate));
+            dto.setTravelStartTimeEnd(format.format(endDate));
+        }
         TourProjectGroupPurchase tourProjectGroupPurchaseFilter = MyModelUtil.copyTo(dto, TourProjectGroupPurchase.class);
         MyOrderParam myOrderParam = new MyOrderParam();
         // 如果项目id不为空,说明是项目详情中进行查询的,那么按照出发时间正序排序,如果不为空,则是列表页查询的,按照设定的排序规则进行排序

+ 1 - 1
application-webadmin/src/main/java/com/tourism/webadmin/back/service/impl/TourProjectGroupPurchaseServiceImpl.java

@@ -179,7 +179,7 @@ public class TourProjectGroupPurchaseServiceImpl extends BaseService<TourProject
         TourProjectGroupPurchase groupPurchase = this.getById(paramDTO.getGroupId());
         if (groupPurchase != null) {
             // 先判断下拼团信息是不是过期了  由于这里默认是yyyy-MM-dd 00:00:00  所以要加一天
-            Date newDate = MyDateUtil.AddDays(groupPurchase.getEndTime(), 1);
+            Date newDate = MyDateUtil.addDays(groupPurchase.getEndTime(), 1);
             if (newDate.getTime() < System.currentTimeMillis()) {
                 throw new MyRuntimeException(ErrorCodeEnum.GROUP_BUYING_HAS_EXPIRED.getErrorMessage());
             }

+ 2 - 6
common/common-core/src/main/java/com/tourism/common/core/util/MyDateUtil.java

@@ -335,14 +335,10 @@ public class MyDateUtil {
         long daysDifference = ChronoUnit.DAYS.between(today, date);
 
         // 如果日期是今天或未来,则返回相对天数
-        if (daysDifference >= 0) {
-            return (int) daysDifference + 1;
-        } else {
-            throw new IllegalArgumentException("The provided date is in the past");
-        }
+        return (int) daysDifference + 1;
     }
 
-    public static Date AddDays(Date date, int days) {
+    public static Date addDays(Date date, int days) {
         // 先判断下拼团信息是不是过期了  由于这里默认是yyyy-MM-dd 00:00:00  所以要加一天
         Calendar calendar = Calendar.getInstance();
         // 将 Date 设置到 Calendar