Quellcode durchsuchen

Merge branch 'master' of https://e.coding.net/chuanghaikeji/jinganxiangsu/Homestay_app_houtai

lijie vor 2 Jahren
Ursprung
Commit
98ef97271c

+ 19 - 1
mhotel/src/com/happy/Until/TimeExchange.java

@@ -412,6 +412,24 @@ public class TimeExchange {
     }
 
     /**
+     * 获取指定月份有多少天
+     *
+     * @param month
+     * @return
+     */
+    public static int getMonthDays(String date, int month) {
+        int year = Integer.valueOf(date.substring(0, 4));
+        int[] arr = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+        int day = arr[month - 1];//天数对应=数组-1
+        if (month == 2 && year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
+            day = 29;
+        }
+
+        return day;
+
+    }
+
+    /**
      * Date转为String
      * @param time 时间
      * @param FormatStr 自定义时间格式
@@ -541,7 +559,7 @@ public class TimeExchange {
 
         int lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
         c.set(Calendar.DAY_OF_MONTH, lastDay);
-        String endDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()) + " 23:59:59";
+        String endDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
 
         return new String[]{startDate, endDate};
     }

+ 7 - 2
mhotel/src/com/happy/action/AppHomePageAction.java

@@ -22,6 +22,7 @@ import org.apache.struts2.interceptor.ServletRequestAware;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Comparator;
@@ -242,13 +243,17 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
             dateStrs.add(date);
         }
         List<House> houseList = hotel.getHouseList();
-        for (House houseData : houseList) {
+        for (House houseData:houseList) {
+            BigDecimal todayPrice = BigDecimal.ZERO;
             for (String dateStr:dateStrs){
                 Optional<HousePriceOneDataVo> oneData = oneDatas.stream().filter(e -> e.getHouseId().equals(houseData.getId()) && e.getSetDate().equals(dateStr)).sorted(Comparator.comparing(HousePriceOneDataVo::getCreateDate,Comparator.reverseOrder())).findFirst();
                 if(oneData != null && oneData.isPresent()){
-                    houseData.setPrice(houseData.getPrice() + oneData.get().getPrice());
+                    todayPrice = todayPrice.add(BigDecimal.valueOf(oneData.get().getPrice()));
+                }else{
+                    todayPrice = todayPrice.add(BigDecimal.valueOf(houseData.getPrice()));
                 }
             }
+            houseData.setPrice(todayPrice.doubleValue());
             if(dateStrs.size() > 0){
                 houseData.setPrice(houseData.getPrice() == 0.0 ? 0.0 : (houseData.getPrice() / dateStrs.size()));
             }

+ 9 - 28
mhotel/src/com/happy/action/HousePriceAction.java

@@ -171,44 +171,25 @@ public class HousePriceAction extends BaseController implements ModelDriven<Hous
             return null;
         }
         if (startTime == null) {
-            resultJson.put("message", "入住时间不能为空");
+            resultJson.put("message", "月份时间不能为空");
             resultJson.put("code", 500);
             ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             return null;
         }
 
+        int days = TimeExchange.getMonthDays(startTime, Integer.valueOf(startTime.substring(5, 7)));
+        String[] months = TimeExchange.getCurrentMonthTimeFrame(startTime);
+        String startDate = months[0];
+        String endDate = months[1];
         List<HousePriceResultVo> result = new ArrayList<>();
         List<String> dateStrs = new ArrayList<>();
-        String DateNow = TimeExchange.DateToString(new Date(), "yyyy-MM-dd");
-        //离店时间为空的话 则拿入店时间的前三天和后七天数据
-        boolean IsDurStart = TimeExchange.CompareDate(DateNow, startTime, "yyyy-MM-dd");
-        if (IsDurStart) {
-            for (int i = 1; i <= 3; i++) {
-                String date = TimeExchange.TimeDesD(startTime, -i);
-                if (date.equals(DateNow)) {
-                    dateStrs.add(date);
-                    break;
-                }
-                dateStrs.add(date);
-            }
-        }
-
-        dateStrs.add(startTime);
-
-        int dateNum = 7;
-        if (endTime != null) {
-            //后七天
-            dateNum = TimeExchange.daysBetween(startTime, endTime);
-        }
-
-        for (int i = 1; i <= dateNum; i++) {
+        for (int i = 0; i < days; i++) {
             String date = TimeExchange.TimeDesD(startTime, i);
             dateStrs.add(date);
         }
-
         Collections.sort(dateStrs);
 
-        List<HousePriceDataVo> hprd = housePriceService.queryHousePriceDatas(merchantId, dateStrs.get(0), dateStrs.get(dateStrs.size() - 1));
+        List<HousePriceDataVo> hprd = housePriceService.queryHousePriceDatas(merchantId, startDate, endDate);
         List<HousePriceOneDataVo> oneDatas = new ArrayList<>();
         //将数据处理成单天的
         for (HousePriceDataVo hp : hprd) {
@@ -262,9 +243,9 @@ public class HousePriceAction extends BaseController implements ModelDriven<Hous
             List<HousePriceOneDataVo> priceDatas = oneDatas.stream().filter(e -> e.getSetDate().equals(str)).sorted(Comparator.comparing(HousePriceOneDataVo::getPrice)).collect(Collectors.toList());
 
             if (priceDatas.size() > 0) {
-                data.setTopinfo("¥" + priceDatas.get(0).getPrice());
+                data.setTopinfo("¥" + priceDatas.get(0).getPrice() + "起");
             } else {
-                data.setTopinfo("¥" + minPrice);
+                data.setTopinfo("¥" + minPrice + "起");
             }
             result.add(data);
         }

+ 4 - 4
mhotel/src/com/happy/vo/EvaluatePageVo.java

@@ -8,13 +8,13 @@ public class EvaluatePageVo {
 
 //    总分
     private Double score;
-//    λÖÃÆÀ·Ö
+//    位置评分
     private Double scoreWz;
-//    ÎÀÉúÆÀ·Ö
+//    卫生评分
     private Double scoreWs;
-//    ÉèÊ©ÆÀ·Ö
+//    设施评分
     private Double scoreSs;
-//    ·þÎñÆÀ·Ö
+//    服务评分
     private Double scoreFw;
 
     private Integer totalCount;

+ 8 - 10
mhotel/src/com/happy/vo/PersonageCommentVo.java

@@ -1,33 +1,31 @@
 package com.happy.vo;
 
 public class PersonageCommentVo {
-//    ¶©µ¥id
+//    数据ID
     private String id;
-//    ÆÀÂÛid
+//    评论id
     private String bookingCommentId;
-//    ÃûËÞÃû³Æ
+//    酒店名称
     private String hotelName;
 
-//     ¶©·¿ÊýÁ¿
+//     房型预定数量
     private Integer houseOrderNumber;
 
-//    ·¿ÐÍÃû³Æ
+//    房型数量
     private String houseName;
 
-//    Èëסʱ¼ä
+//    入住时间
     private String liveTime;
 
-//    Àëµêʱ¼ä
+//    离店时间
     private String checkOutTime;
 
-//    ʵ¼ÊÖ§¸¶½ð¶î
+//    支付账号
     private Double payAccount;
 
 //    图片
     private String url;
 
-//  ����ͼƬ
-
 
     public String getUrl() {
         return url;