|
@@ -28,6 +28,7 @@ import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.config.ApiVersion;
|
|
import org.jeecg.config.ApiVersion;
|
|
|
import org.jeecg.config.ApiVersionConstant;
|
|
import org.jeecg.config.ApiVersionConstant;
|
|
|
import org.jeecg.config.WebConfig;
|
|
import org.jeecg.config.WebConfig;
|
|
|
|
|
+import org.jeecg.modules.business.dto.BookingLayoutRoomsDto;
|
|
|
import org.jeecg.modules.business.dto.BookingOrderSaveDto;
|
|
import org.jeecg.modules.business.dto.BookingOrderSaveDto;
|
|
|
import org.jeecg.modules.business.entity.*;
|
|
import org.jeecg.modules.business.entity.*;
|
|
|
import org.jeecg.modules.business.service.*;
|
|
import org.jeecg.modules.business.service.*;
|
|
@@ -50,7 +51,9 @@ import org.jeecg.modules.system.entity.SysTenant;
|
|
|
import org.jeecg.modules.system.service.ISysTenantService;
|
|
import org.jeecg.modules.system.service.ISysTenantService;
|
|
|
import org.jeecg.modules.wxuser.entity.MallUserInfo;
|
|
import org.jeecg.modules.wxuser.entity.MallUserInfo;
|
|
|
import org.jeecg.modules.wxuser.entity.ThirdSession;
|
|
import org.jeecg.modules.wxuser.entity.ThirdSession;
|
|
|
|
|
+import org.jeecg.modules.wxuser.service.IUserInfoService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
@@ -58,6 +61,12 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.text.DateFormat;
|
|
|
|
|
+import java.text.ParseException;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
|
|
+import java.time.temporal.Temporal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -89,6 +98,14 @@ public class HotelController extends WebConfig {
|
|
|
private CesRoomLayoutPriceServiceImpl cesRoomLayoutPriceService;
|
|
private CesRoomLayoutPriceServiceImpl cesRoomLayoutPriceService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private IMallHotelOrderService mallHotelOrderService;
|
|
private IMallHotelOrderService mallHotelOrderService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusMarketCouponsCashUsedService busMarketCouponsCashUsedService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusMarketCouponsCashService busMarketCouponsCashService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IUserInfoService userInfoService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusDictItemService busDictItemService;
|
|
|
/**
|
|
/**
|
|
|
* 酒店列表查询
|
|
* 酒店列表查询
|
|
|
*
|
|
*
|
|
@@ -259,9 +276,26 @@ public class HotelController extends WebConfig {
|
|
|
@PostMapping(value = "/hotel-order")
|
|
@PostMapping(value = "/hotel-order")
|
|
|
@ApiLogin
|
|
@ApiLogin
|
|
|
@ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
@ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Result<String> hotelOrderAdd(@RequestBody MallHotelOrder mallHotelOrder) {
|
|
public Result<String> hotelOrderAdd(@RequestBody MallHotelOrder mallHotelOrder) {
|
|
|
String tenantId = TenantContextHolder.getTenantId();
|
|
String tenantId = TenantContextHolder.getTenantId();
|
|
|
String userId = ThirdSessionHolder.getUserId();
|
|
String userId = ThirdSessionHolder.getUserId();
|
|
|
|
|
+ MallUserInfo mallUserInfo = userInfoService.getById(userId);
|
|
|
|
|
+ BigDecimal couponMoney = BigDecimal.ZERO;
|
|
|
|
|
+ if (StringUtils.isNotBlank(mallHotelOrder.getCouponId())) {
|
|
|
|
|
+ BusMarketCouponsCashUsed busMarketCouponsCashUsed = busMarketCouponsCashUsedService.getById(mallHotelOrder.getCouponId());
|
|
|
|
|
+ if (ObjectUtils.isEmpty(busMarketCouponsCashUsed)) {
|
|
|
|
|
+ return Result.error("优惠券不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!busMarketCouponsCashUsed.getUserid().equals(userId) && !busMarketCouponsCashUsed.getMobile().equals(mallUserInfo.getMobile())) {
|
|
|
|
|
+ return Result.error("优惠券非法使用");
|
|
|
|
|
+ }
|
|
|
|
|
+ BusMarketCouponsCash coupons = busMarketCouponsCashService.getById(busMarketCouponsCashUsed.getCouponsId());
|
|
|
|
|
+ if (ObjectUtils.isEmpty(coupons)) {
|
|
|
|
|
+ return Result.error("优惠券活动不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ couponMoney = coupons.getCost();
|
|
|
|
|
+ }
|
|
|
mallHotelOrder.setTenantId(tenantId);
|
|
mallHotelOrder.setTenantId(tenantId);
|
|
|
mallHotelOrder.setMallUserId(userId);
|
|
mallHotelOrder.setMallUserId(userId);
|
|
|
mallHotelOrder.setCreateTime(DateTime.now());
|
|
mallHotelOrder.setCreateTime(DateTime.now());
|
|
@@ -270,6 +304,97 @@ public class HotelController extends WebConfig {
|
|
|
mallHotelOrder.setPayType(1);
|
|
mallHotelOrder.setPayType(1);
|
|
|
mallHotelOrder.setStatus(5);
|
|
mallHotelOrder.setStatus(5);
|
|
|
mallHotelOrderService.save(mallHotelOrder);
|
|
mallHotelOrderService.save(mallHotelOrder);
|
|
|
|
|
+
|
|
|
|
|
+ //增加临时坑位预定单
|
|
|
|
|
+ BookingOrderSaveDto busRoomBookingOrders = new BookingOrderSaveDto();
|
|
|
|
|
+ busRoomBookingOrders.setContactName(mallHotelOrder.getContactName());
|
|
|
|
|
+ busRoomBookingOrders.setHotelId(mallHotelOrder.getHotelId());
|
|
|
|
|
+ busRoomBookingOrders.setPhone(mallHotelOrder.getMobile());
|
|
|
|
|
+
|
|
|
|
|
+ List<BusBookingLayoutDayPrice> layoutDayPrices = new ArrayList<>();
|
|
|
|
|
+ long getTime = mallHotelOrder.getStartDate().getTime() - mallHotelOrder.getEndDate().getTime();
|
|
|
|
|
+ long day = getTime / (1000 * 60 * 60 * 24);
|
|
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
|
|
+ BigDecimal sCouponMoney = couponMoney;
|
|
|
|
|
+ for (Integer i = 0; i <= day; i++) {
|
|
|
|
|
+ calendar.setTime(mallHotelOrder.getStartDate());
|
|
|
|
|
+ calendar.add(Calendar.DATE, i);
|
|
|
|
|
+
|
|
|
|
|
+ BusBookingLayoutDayPrice busBookingLayoutDayPrice = new BusBookingLayoutDayPrice();
|
|
|
|
|
+ busBookingLayoutDayPrice.setBookingType(1);
|
|
|
|
|
+ busBookingLayoutDayPrice.setDayTime(calendar.getTime());
|
|
|
|
|
+ BigDecimal sum = mallHotelOrder.getDayMoney().subtract(sCouponMoney);
|
|
|
|
|
+ if (sum.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
+ sCouponMoney = sum;
|
|
|
|
|
+ sum = BigDecimal.ZERO;
|
|
|
|
|
+ }
|
|
|
|
|
+ busBookingLayoutDayPrice.setPrice(sum);
|
|
|
|
|
+ busBookingLayoutDayPrice.setRoomLayoutId(mallHotelOrder.getLayoutId());
|
|
|
|
|
+ layoutDayPrices.add(busBookingLayoutDayPrice);
|
|
|
|
|
+ }
|
|
|
|
|
+ busRoomBookingOrders.setLayoutDayPrices(layoutDayPrices);
|
|
|
|
|
+
|
|
|
|
|
+ BusRoomBookingOrders bookingOrders = new BusRoomBookingOrders();
|
|
|
|
|
+
|
|
|
|
|
+// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
|
+ Date four = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ four = formatter2.parse(formatter.format(mallHotelOrder.getStartDate()) + " 16:50");
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ bookingOrders.setArrivalTime(four);
|
|
|
|
|
+ LambdaQueryWrapper<BusDictItem> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
|
+ lambdaQueryWrapper2.eq(BusDictItem::getHotelId, mallHotelOrder.getHotelId());
|
|
|
|
|
+ lambdaQueryWrapper2.eq(BusDictItem::getDictId, "1639544187093995521");
|
|
|
|
|
+ List<BusDictItem> busDictItems = busDictItemService.list(lambdaQueryWrapper2);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(busDictItems)) {
|
|
|
|
|
+ bookingOrders.setBookingDicWay(busDictItems.get(0).getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ bookingOrders.setBookingOrdersType(1);
|
|
|
|
|
+ bookingOrders.setBreakfastNum(0);
|
|
|
|
|
+
|
|
|
|
|
+ lambdaQueryWrapper2.eq(BusDictItem::getDictId, "1639538915239743490");
|
|
|
|
|
+ busDictItems = busDictItemService.list(lambdaQueryWrapper2);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(busDictItems)) {
|
|
|
|
|
+ Optional<BusDictItem> busDictItemOptional = busDictItems.stream().filter(t -> t.getItemText().equals("微信订房")).findFirst();
|
|
|
|
|
+ if (busDictItemOptional.isPresent()) {
|
|
|
|
|
+ bookingOrders.setCustomerSource(busDictItemOptional.get().getId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ bookingOrders.setCustomerSource(busDictItems.get(0).getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ bookingOrders.setCustomerType(1);
|
|
|
|
|
+ bookingOrders.setDayCount(mallHotelOrder.getDay());
|
|
|
|
|
+ bookingOrders.setDueOutTime(mallHotelOrder.getEndDate());
|
|
|
|
|
+ bookingOrders.setWarrantType(1);
|
|
|
|
|
+ bookingOrders.setOuterOrdersNo(mallHotelOrder.getCode());
|
|
|
|
|
+ bookingOrders.setBookingStatus(3);
|
|
|
|
|
+ busRoomBookingOrders.setOrderInfo(bookingOrders);
|
|
|
|
|
+
|
|
|
|
|
+ List<BookingLayoutRoomsDto> roomIds = new ArrayList<>();
|
|
|
|
|
+ BookingLayoutRoomsDto bookingLayoutRoomsDto = new BookingLayoutRoomsDto();
|
|
|
|
|
+ bookingLayoutRoomsDto.setLayoutId(mallHotelOrder.getLayoutId());
|
|
|
|
|
+ bookingLayoutRoomsDto.setRoomId(null);
|
|
|
|
|
+ roomIds.add(bookingLayoutRoomsDto);
|
|
|
|
|
+ busRoomBookingOrders.setRoomIds(roomIds);
|
|
|
|
|
+
|
|
|
|
|
+ Boolean isTeam = busRoomBookingOrders.getOrderInfo().getBookingOrdersType().equals(2);
|
|
|
|
|
+ busRoomBookingOrders.getOrderInfo().setBookingOrdersType(1);
|
|
|
|
|
+ busRoomBookingOrders.getOrderInfo().setThirdLoginUserId(userId);
|
|
|
|
|
+ LambdaQueryWrapper<BusMemberCard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ lambdaQueryWrapper.eq(BusMemberCard::getUserId, userId);
|
|
|
|
|
+ lambdaQueryWrapper.eq(BusMemberCard::getHotelId, busRoomBookingOrders.getHotelId()).last("limit 1");
|
|
|
|
|
+ BusMemberCard busMemberCard = busMemberCardService.getOne(lambdaQueryWrapper);
|
|
|
|
|
+ if (busMemberCard != null) {
|
|
|
|
|
+ busRoomBookingOrders.getOrderInfo().setCustomerType(2);
|
|
|
|
|
+ busRoomBookingOrders.getOrderInfo().setVipCustomerId(busMemberCard.getId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ busRoomBookingOrders.getOrderInfo().setCustomerType(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ busRoomBookingOrdersService.bookingOrderSave(busRoomBookingOrders, isTeam);
|
|
|
return Result.OK("预定成功");
|
|
return Result.OK("预定成功");
|
|
|
}
|
|
}
|
|
|
|
|
|