|
@@ -28,10 +28,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Comparator;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -191,8 +188,14 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
|
|
|
}
|
|
}
|
|
|
AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
|
|
AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
|
|
|
hotel.setType(String.valueOf(adminManager.getType()));
|
|
hotel.setType(String.valueOf(adminManager.getType()));
|
|
|
- Optional<HotelPriceOneDataVo> one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
- Optional<PriceHotelDataVo> min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
|
|
+ Optional<HotelPriceOneDataVo> one = null;
|
|
|
|
|
+ if (newOneDatas!=null){
|
|
|
|
|
+ one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
+ }
|
|
|
|
|
+ Optional<PriceHotelDataVo> min = null;
|
|
|
|
|
+ if (mins!=null){
|
|
|
|
|
+ min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
+ }
|
|
|
if (one != null && one.isPresent() && min != null && min.isPresent()) {
|
|
if (one != null && one.isPresent() && min != null && min.isPresent()) {
|
|
|
if(one.get().getPrice() > min.get().getPrice()){
|
|
if(one.get().getPrice() > min.get().getPrice()){
|
|
|
hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
|
|
hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
|
|
@@ -279,8 +282,14 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
|
|
|
}
|
|
}
|
|
|
AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
|
|
AdminManager adminManager = adminManagerService.getById(hotel.getManagerId());
|
|
|
hotel.setType(String.valueOf(adminManager.getType()));
|
|
hotel.setType(String.valueOf(adminManager.getType()));
|
|
|
- Optional<HotelPriceOneDataVo> one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
- Optional<PriceHotelDataVo> min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
|
|
+ Optional<HotelPriceOneDataVo> one = null;
|
|
|
|
|
+ if (newOneDatas!=null){
|
|
|
|
|
+ one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
+ }
|
|
|
|
|
+ Optional<PriceHotelDataVo> min = null;
|
|
|
|
|
+ if (mins!=null){
|
|
|
|
|
+ min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
|
|
|
|
|
+ }
|
|
|
if (one != null && one.isPresent() && min != null && min.isPresent()) {
|
|
if (one != null && one.isPresent() && min != null && min.isPresent()) {
|
|
|
if(one.get().getPrice() > min.get().getPrice()){
|
|
if(one.get().getPrice() > min.get().getPrice()){
|
|
|
hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
|
|
hotel.setMin_price(decimalFormat.format(min.get().getPrice()));
|
|
@@ -498,22 +507,28 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
|
|
|
dateStrs.add(date);
|
|
dateStrs.add(date);
|
|
|
}
|
|
}
|
|
|
List<House> houseList = hotel.getHouseList();
|
|
List<House> houseList = hotel.getHouseList();
|
|
|
- for (House houseData : houseList) {
|
|
|
|
|
- BigDecimal todayPrice = BigDecimal.ZERO;
|
|
|
|
|
- for (String dateStr : dateStrs) {
|
|
|
|
|
- Optional<HousePriceOneDataVo> oneData = oneDatas.stream().filter(e -> e.getHouseId().toString().equals(houseData.getId()) && e.getSetDate().equals(dateStr)).sorted(Comparator.comparing(HousePriceOneDataVo::getCreateDate, Comparator.reverseOrder())).findFirst();
|
|
|
|
|
- if (oneData != null && oneData.isPresent()) {
|
|
|
|
|
- todayPrice = todayPrice.add(BigDecimal.valueOf(oneData.get().getPrice()));
|
|
|
|
|
- } else {
|
|
|
|
|
- todayPrice = todayPrice.add(BigDecimal.valueOf(houseData.getPrice()));
|
|
|
|
|
|
|
+ if (houseList!=null && !houseList.isEmpty()) {
|
|
|
|
|
+ for (House houseData : houseList) {
|
|
|
|
|
+ BigDecimal todayPrice = BigDecimal.ZERO;
|
|
|
|
|
+ for (String dateStr : dateStrs) {
|
|
|
|
|
+ Optional<HousePriceOneDataVo> oneData = null;
|
|
|
|
|
+ if (!oneDatas.isEmpty()){
|
|
|
|
|
+ oneData = oneDatas.stream().filter(e -> e.getHouseId().toString().equals(houseData.getId()) && e.getSetDate().equals(dateStr)).sorted(Comparator.comparing(HousePriceOneDataVo::getCreateDate, Comparator.reverseOrder())).findFirst();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (oneData != null && oneData.isPresent()) {
|
|
|
|
|
+ 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(todayPrice.doubleValue());
|
|
|
|
|
+ if (dateStrs.size() > 0) {
|
|
|
// houseData.setPrice(houseData.getPrice() == 0.0 ? 0.0 : (new BigDecimal(houseData.getPrice()).divide(new BigDecimal(dateStrs.size())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
|
// houseData.setPrice(houseData.getPrice() == 0.0 ? 0.0 : (new BigDecimal(houseData.getPrice()).divide(new BigDecimal(dateStrs.size())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
|
|
- houseData.setPrice(houseData.getPrice() == 0.0 ? 0.0 : (new BigDecimal(houseData.getPrice()).divide(new BigDecimal(dateStrs.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
|
|
|
|
|
|
+ houseData.setPrice(houseData.getPrice() == 0.0 ? 0.0 : (new BigDecimal(houseData.getPrice()).divide(new BigDecimal(dateStrs.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
// 通过时间区间查询房间信息,并带好是否有房标识给前台
|
|
// 通过时间区间查询房间信息,并带好是否有房标识给前台
|