|
|
@@ -1,73 +1,59 @@
|
|
|
package org.jeecg.modules.bus.controller;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
-import com.alibaba.druid.support.json.JSONUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import net.sf.json.JSON;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.annotation.ApiLogin;
|
|
|
import org.jeecg.com.util.ThirdSessionHolder;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
-import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
-import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
-import org.jeecg.common.system.util.JwtUtil;
|
|
|
-import org.jeecg.common.system.vo.LoginUser;
|
|
|
-import org.jeecg.common.util.RedisUtil;
|
|
|
import org.jeecg.common.util.TenantContextHolder;
|
|
|
-import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.config.ApiVersion;
|
|
|
import org.jeecg.config.ApiVersionConstant;
|
|
|
import org.jeecg.config.WebConfig;
|
|
|
+import org.jeecg.modules.bus.vo.CesStockTypeVo;
|
|
|
import org.jeecg.modules.business.dto.BookingLayoutRoomsDto;
|
|
|
import org.jeecg.modules.business.dto.BookingOrderSaveDto;
|
|
|
import org.jeecg.modules.business.entity.*;
|
|
|
+import org.jeecg.modules.business.enums.CheckInTypeEnum;
|
|
|
import org.jeecg.modules.business.service.*;
|
|
|
-import org.jeecg.modules.business.util.MapUtil;
|
|
|
import org.jeecg.modules.business.vo.KeLiItemVo;
|
|
|
import org.jeecg.modules.mall.entity.MallHotelOrder;
|
|
|
+import org.jeecg.modules.mall.entity.MallOrderGoods;
|
|
|
+import org.jeecg.modules.mall.entity.MallOrderGoodsDetail;
|
|
|
import org.jeecg.modules.mall.service.IMallHotelOrderService;
|
|
|
+import org.jeecg.modules.mall.service.IMallOrderGoodsDetailService;
|
|
|
+import org.jeecg.modules.mall.service.IMallOrderGoodsService;
|
|
|
import org.jeecg.modules.order.entity.CesOrderComment;
|
|
|
import org.jeecg.modules.order.service.impl.CesOrderCommentServiceImpl;
|
|
|
import org.jeecg.modules.rooms.DTO.CanUseRequestParamDto;
|
|
|
import org.jeecg.modules.rooms.Vo.CanUseResultVo;
|
|
|
-import org.jeecg.modules.rooms.entity.CesRoomLayout;
|
|
|
-import org.jeecg.modules.rooms.entity.CesRoomLayoutPrice;
|
|
|
-import org.jeecg.modules.rooms.entity.CesRooms;
|
|
|
-import org.jeecg.modules.rooms.service.CesRoomLayoutPriceServiceImpl;
|
|
|
-import org.jeecg.modules.rooms.service.CesRoomLayoutServiceImpl;
|
|
|
-import org.jeecg.modules.rooms.service.CesRoomsServiceImpl;
|
|
|
-import org.jeecg.modules.rooms.service.ICesRoomLayoutPriceDateService;
|
|
|
-import org.jeecg.modules.system.entity.SysTenant;
|
|
|
-import org.jeecg.modules.system.service.ISysTenantService;
|
|
|
-import org.jeecg.modules.wxuser.entity.MallUserInfo;
|
|
|
-import org.jeecg.modules.wxuser.entity.ThirdSession;
|
|
|
+import org.jeecg.modules.rooms.entity.*;
|
|
|
+import org.jeecg.modules.rooms.service.*;
|
|
|
+import org.jeecg.modules.mall.entity.MallUserInfo;
|
|
|
import org.jeecg.modules.wxuser.service.IUserInfoService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
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.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 酒店列表
|
|
|
@@ -106,6 +92,18 @@ public class HotelController extends WebConfig {
|
|
|
private IUserInfoService userInfoService;
|
|
|
@Resource
|
|
|
private IBusDictItemService busDictItemService;
|
|
|
+ @Resource
|
|
|
+ private CesHourRoomRuleServiceImpl cesHourRoomRuleService;
|
|
|
+ @Resource
|
|
|
+ private CesGoodsServiceImpl cesGoodsService;
|
|
|
+ @Resource
|
|
|
+ private CesStockTypeServiceImpl cesStockTypeService;
|
|
|
+ @Resource
|
|
|
+ private IMallOrderGoodsService mallOrderGoodsService;
|
|
|
+ @Resource
|
|
|
+ private IMallOrderGoodsDetailService mallOrderGoodsDetailService;
|
|
|
+ @Resource
|
|
|
+ private IBusMemberBalanceLogService busMemberBalanceLogService;
|
|
|
/**
|
|
|
* 酒店列表查询
|
|
|
*
|
|
|
@@ -200,6 +198,15 @@ public class HotelController extends WebConfig {
|
|
|
throw new JeecgBootException("参数错误");
|
|
|
if (param.getEndOf() == null || param.getStartOf() == null)
|
|
|
throw new JeecgBootException("请传入时间范围");
|
|
|
+ if (param.getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
|
|
|
+ LambdaQueryWrapper<CesHourRoomRule> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(CesHourRoomRule::getHotelId, param.getHotelId());
|
|
|
+ lambdaQueryWrapper.orderByAsc(CesHourRoomRule::getAfterOpenRoom).last("limit 1");
|
|
|
+ CesHourRoomRule cesHourRoomRule = cesHourRoomRuleService.getOne(lambdaQueryWrapper);
|
|
|
+ if (cesHourRoomRule != null) {
|
|
|
+ param.setHourRoomRuleId(cesHourRoomRule.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
return Result.ok(cesRoomsService.getCanUseRooms(param));
|
|
|
}
|
|
|
|
|
|
@@ -227,38 +234,39 @@ public class HotelController extends WebConfig {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 酒店预定订单添加
|
|
|
- *
|
|
|
- * @param busRoomBookingOrders
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "酒店预定订单-添加")
|
|
|
- @ApiOperation(value = "酒店预定订单-添加", notes = "酒店预定订单-添加")
|
|
|
- @PostMapping(value = "/hotel-room-booking")
|
|
|
- @ApiLogin
|
|
|
- @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
- public Result<String> hotelRoomBookingAdd(@RequestBody BookingOrderSaveDto busRoomBookingOrders) {
|
|
|
- Boolean isTeam = busRoomBookingOrders.getOrderInfo().getBookingOrdersType().equals(2);
|
|
|
- busRoomBookingOrders.getOrderInfo().setBookingOrdersType(1);
|
|
|
- String tenantId = TenantContextHolder.getTenantId();
|
|
|
- String userId = ThirdSessionHolder.getUserId();
|
|
|
- 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);
|
|
|
- }
|
|
|
- return Result.OK("预定成功", busRoomBookingOrdersService.bookingOrderSave(busRoomBookingOrders, isTeam));
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 酒店预定订单添加
|
|
|
+// *
|
|
|
+// * @param busRoomBookingOrders
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// @AutoLog(value = "酒店预定订单-添加")
|
|
|
+// @ApiOperation(value = "酒店预定订单-添加", notes = "酒店预定订单-添加")
|
|
|
+// @PostMapping(value = "/hotel-room-booking")
|
|
|
+// @ApiLogin
|
|
|
+// @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+// public Result<String> hotelRoomBookingAdd(@RequestBody BookingOrderSaveDto busRoomBookingOrders) {
|
|
|
+// Boolean isTeam = busRoomBookingOrders.getOrderInfo().getBookingOrdersType().equals(2);
|
|
|
+// busRoomBookingOrders.getOrderInfo().setBookingOrdersType(1);
|
|
|
+// String tenantId = TenantContextHolder.getTenantId();
|
|
|
+// String userId = ThirdSessionHolder.getUserId();
|
|
|
+// 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);
|
|
|
+// }
|
|
|
+// return Result.OK("预定成功", busRoomBookingOrdersService.bookingOrderSave(busRoomBookingOrders, isTeam));
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 生成16位数字+prefix
|
|
|
+ *
|
|
|
* @param prefix
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -294,6 +302,7 @@ public class HotelController extends WebConfig {
|
|
|
if (ObjectUtils.isEmpty(coupons)) {
|
|
|
return Result.error("优惠券活动不存在");
|
|
|
}
|
|
|
+ mallHotelOrder.setCouponMoney(coupons.getCost());
|
|
|
busMarketCouponsCashUsed.setStatus(2);
|
|
|
busMarketCouponsCashUsed.setUsedTime(DateTime.now());
|
|
|
busMarketCouponsCashUsedService.updateById(busMarketCouponsCashUsed);
|
|
|
@@ -306,6 +315,27 @@ public class HotelController extends WebConfig {
|
|
|
mallHotelOrder.setCode(randomNumber(prefix));
|
|
|
mallHotelOrder.setPayType(1);
|
|
|
mallHotelOrder.setStatus(5);
|
|
|
+
|
|
|
+ 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()) + " " + mallHotelOrder.getArriveTime());
|
|
|
+ mallHotelOrder.setStartDate(four);
|
|
|
+ } catch (ParseException e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ CesHourRoomRule cesHourRoomRule = null;
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ if (mallHotelOrder.getBookingType().equals(2)) {
|
|
|
+ CesRoomLayoutPrice cesRoomLayoutPrice = cesRoomLayoutPriceService.getById(mallHotelOrder.getRoomLayoutPriceId());
|
|
|
+ cesHourRoomRule = cesHourRoomRuleService.getById(cesRoomLayoutPrice.getSellerId());
|
|
|
+ calendar.setTime(mallHotelOrder.getStartDate());
|
|
|
+ calendar.add(Calendar.MINUTE, cesHourRoomRule.getAfterOpenRoom());
|
|
|
+ mallHotelOrder.setEndDate(calendar.getTime());
|
|
|
+ }
|
|
|
+ log.info("getStartDate---------------" + mallHotelOrder.getStartDate());
|
|
|
+ log.info("getEndDate---------------" + mallHotelOrder.getEndDate());
|
|
|
mallHotelOrderService.save(mallHotelOrder);
|
|
|
|
|
|
//增加临时坑位预定单
|
|
|
@@ -317,7 +347,10 @@ public class HotelController extends WebConfig {
|
|
|
List<BusBookingLayoutDayPrice> layoutDayPrices = new ArrayList<>();
|
|
|
long getTime = mallHotelOrder.getEndDate().getTime() - mallHotelOrder.getStartDate().getTime();
|
|
|
long day = getTime / (1000 * 60 * 60 * 24);
|
|
|
- Calendar calendar = new GregorianCalendar();
|
|
|
+ if (day == 0) {
|
|
|
+ day = 1;
|
|
|
+ }
|
|
|
+ log.info("day---------------" + day);
|
|
|
BigDecimal sCouponMoney = couponMoney;
|
|
|
for (Integer i = 0; i < day; i++) {
|
|
|
calendar.setTime(mallHotelOrder.getStartDate());
|
|
|
@@ -338,15 +371,7 @@ public class HotelController extends WebConfig {
|
|
|
busRoomBookingOrders.setLayoutDayPrices(layoutDayPrices);
|
|
|
|
|
|
BusRoomBookingOrders bookingOrders = new BusRoomBookingOrders();
|
|
|
- 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);
|
|
|
+ bookingOrders.setArrivalTime(mallHotelOrder.getStartDate());
|
|
|
LambdaQueryWrapper<BusDictItem> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper2.eq(BusDictItem::getHotelId, mallHotelOrder.getHotelId());
|
|
|
lambdaQueryWrapper2.eq(BusDictItem::getDictId, "1639544187093995521");
|
|
|
@@ -376,6 +401,9 @@ public class HotelController extends WebConfig {
|
|
|
bookingOrders.setOuterOrdersNo(mallHotelOrder.getCode());
|
|
|
bookingOrders.setBookingStatus(3);
|
|
|
bookingOrders.setBookingType(mallHotelOrder.getBookingType());
|
|
|
+ if (mallHotelOrder.getBookingType().equals(2)) {
|
|
|
+ bookingOrders.setHourRoomId(cesHourRoomRule.getId());
|
|
|
+ }
|
|
|
busRoomBookingOrders.setOrderInfo(bookingOrders);
|
|
|
|
|
|
List<BookingLayoutRoomsDto> roomIds = new ArrayList<>();
|
|
|
@@ -474,4 +502,357 @@ public class HotelController extends WebConfig {
|
|
|
List<CesRoomLayoutPrice> list = cesRoomLayoutPriceService.list(lambdaQueryWrapper);
|
|
|
return Result.ok(list);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 酒店预定订单列表
|
|
|
+ *
|
|
|
+ * @param mallHotelOrder
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "酒店预定订单列表", notes = "酒店预定订单列表")
|
|
|
+ @GetMapping(value = "/hotel_order-list")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<IPage<MallHotelOrder>> getHotelOrderPageList(MallHotelOrder mallHotelOrder,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ String tenantId = TenantContextHolder.getTenantId();
|
|
|
+ String userId = ThirdSessionHolder.getUserId();
|
|
|
+ LambdaQueryWrapper<MallHotelOrder> queryWrapper = QueryGenerator.initQueryWrapper(mallHotelOrder, req.getParameterMap()).lambda();
|
|
|
+ queryWrapper.eq(MallHotelOrder::getTenantId, tenantId);
|
|
|
+ queryWrapper.eq(MallHotelOrder::getMallUserId, userId);
|
|
|
+ Page<MallHotelOrder> page = new Page<MallHotelOrder>(pageNo, pageSize);
|
|
|
+ IPage<MallHotelOrder> pageList = mallHotelOrderService.page(page, queryWrapper);
|
|
|
+ pageList.getRecords().forEach(t -> {
|
|
|
+ if (t.getStatus().equals(1)) {
|
|
|
+ t.setStatusName("未付款");
|
|
|
+ } else if (t.getStatus().equals(2)) {
|
|
|
+ t.setStatusName("已付款");
|
|
|
+ } else if (t.getStatus().equals(3)) {
|
|
|
+ t.setStatusName("已取消");
|
|
|
+ } else if (t.getStatus().equals(4)) {
|
|
|
+ t.setStatusName("已完成");
|
|
|
+ } else if (t.getStatus().equals(5)) {
|
|
|
+ t.setStatusName("待入住");
|
|
|
+ } else if (t.getStatus().equals(6)) {
|
|
|
+ t.setStatusName("已入住");
|
|
|
+ } else if (t.getStatus().equals(7)) {
|
|
|
+ t.setStatusName("退款中");
|
|
|
+ }
|
|
|
+ BusHotel hotel = busHotelService.getById(t.getHotelId());
|
|
|
+ if (hotel != null) {
|
|
|
+ t.setHotelName(hotel.getName());
|
|
|
+ }
|
|
|
+ CesRoomLayout layout = cesRoomLayoutService.getById(t.getLayoutId());
|
|
|
+ if (layout != null) {
|
|
|
+ t.setLayoutName(layout.getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "酒店订单确认入住", notes = "酒店订单确认入住")
|
|
|
+ @PostMapping(value = "/confirm-move")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<String> confirmMove(@RequestBody MallHotelOrder mallHotelOrder) {
|
|
|
+ MallHotelOrder order = mallHotelOrderService.getById(mallHotelOrder.getId());
|
|
|
+ if (!order.getStatus().equals(5)) {
|
|
|
+ return Result.error("订单不是待入住状态");
|
|
|
+ }
|
|
|
+ order.setStatus(6);
|
|
|
+ mallHotelOrderService.updateById(order);
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<BusRoomBookingOrders> updateWrapper = new UpdateWrapper().lambda();
|
|
|
+ updateWrapper.set(BusRoomBookingOrders::getBookingStatus, 1);
|
|
|
+ updateWrapper.eq(BusRoomBookingOrders::getOuterOrdersNo, order.getCode());
|
|
|
+ busRoomBookingOrdersService.update(updateWrapper);
|
|
|
+ return Result.OK("确认入住成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "酒店订单取消", notes = "酒店订单取消")
|
|
|
+ @PostMapping(value = "/confirm-cancel")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<String> confirmCancel(@RequestBody MallHotelOrder mallHotelOrder) {
|
|
|
+ MallHotelOrder order = mallHotelOrderService.getById(mallHotelOrder.getId());
|
|
|
+ if (order.getStatus().equals(4) || order.getStatus().equals(6)) {
|
|
|
+ return Result.error("订单已完成/已入住状态");
|
|
|
+ }
|
|
|
+ order.setStatus(3);
|
|
|
+ mallHotelOrderService.updateById(order);
|
|
|
+ return Result.OK("取消成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询酒店预定订单详情
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "通过id查询酒店预定订单详情", notes = "通过id查询酒店预定订单详情")
|
|
|
+ @GetMapping(value = "/hotel_order-info")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<MallHotelOrder> getHotelOrderInfo(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ MallHotelOrder mallHotelOrder = mallHotelOrderService.getById(id);
|
|
|
+ if (mallHotelOrder == null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ log.info("mallHotelOrder--------" + mallHotelOrder.toString());
|
|
|
+ String userId = ThirdSessionHolder.getUserId();
|
|
|
+ log.info("userId--------" + userId);
|
|
|
+ if (!mallHotelOrder.getMallUserId().equals(userId)) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ BusHotel hotel = busHotelService.getById(mallHotelOrder.getHotelId());
|
|
|
+ mallHotelOrder.setHotel(hotel);
|
|
|
+ if (mallHotelOrder.getStatus().equals(1)) {
|
|
|
+ mallHotelOrder.setStatusName("未付款");
|
|
|
+ } else if (mallHotelOrder.getStatus().equals(2)) {
|
|
|
+ mallHotelOrder.setStatusName("已付款");
|
|
|
+ } else if (mallHotelOrder.getStatus().equals(3)) {
|
|
|
+ mallHotelOrder.setStatusName("已取消");
|
|
|
+ } else if (mallHotelOrder.getStatus().equals(4)) {
|
|
|
+ mallHotelOrder.setStatusName("已完成");
|
|
|
+ } else if (mallHotelOrder.getStatus().equals(5)) {
|
|
|
+ mallHotelOrder.setStatusName("待入住");
|
|
|
+ } else if (mallHotelOrder.getStatus().equals(6)) {
|
|
|
+ mallHotelOrder.setStatusName("已入住");
|
|
|
+ } else if (mallHotelOrder.getStatus().equals(7)) {
|
|
|
+ mallHotelOrder.setStatusName("退款中");
|
|
|
+ }
|
|
|
+ CesRoomLayout layout = cesRoomLayoutService.getById(mallHotelOrder.getLayoutId());
|
|
|
+ if (layout != null) {
|
|
|
+ mallHotelOrder.setLayoutName(layout.getName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(mallHotelOrder.getCouponId())) {
|
|
|
+ BusMarketCouponsCash busMarketCouponsCash = busMarketCouponsCashService.getById(mallHotelOrder.getCouponId());
|
|
|
+ if (busMarketCouponsCash != null) {
|
|
|
+ mallHotelOrder.setCouponName(busMarketCouponsCash.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.OK(mallHotelOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据类型分组外卖商品列表
|
|
|
+ *
|
|
|
+ * @param cesGoods
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "根据类型分组外卖商品列表", notes = "根据类型分组外卖商品列表")
|
|
|
+ @GetMapping(value = "/type_group_goods_list")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<List<CesStockTypeVo>> queryPageList(CesGoods cesGoods) {
|
|
|
+ List<CesStockType> list = cesStockTypeService.list(Wrappers.<CesStockType>lambdaQuery()
|
|
|
+ .eq(CesStockType::getHotelId, cesGoods.getHotelId())
|
|
|
+ .eq(CesStockType::getInvalid, false)
|
|
|
+ .like(CesStockType::getApplyScope, "1"));
|
|
|
+ List<CesStockTypeVo> voList = new ArrayList<>();
|
|
|
+ List<CesStockType> pList = list.stream().filter(t -> StringUtils.isBlank(t.getParentId()) || t.getParentId().equals("0")).collect(Collectors.toList());
|
|
|
+ pList.forEach(t -> {
|
|
|
+ CesStockTypeVo vo = new CesStockTypeVo();
|
|
|
+ vo.setName(t.getName());
|
|
|
+ LambdaQueryWrapper<CesGoods> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(CesGoods::getInvalid, false);
|
|
|
+ queryWrapper.eq(CesGoods::getIsTemp, false);
|
|
|
+
|
|
|
+ queryWrapper.and(j -> {
|
|
|
+ List<CesStockType> stockTypeList = list.stream().filter(t2 -> t2.getParentId().equals(t.getId())).collect(Collectors.toList());
|
|
|
+ if (ObjectUtils.isNotEmpty(stockTypeList)) {
|
|
|
+ for (int z = 0; z < stockTypeList.size(); z++) {
|
|
|
+ j = j.or().eq(CesGoods::getGoodType, stockTypeList.get(z).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ j = j.or().eq(CesGoods::getGoodType, t.getId());
|
|
|
+ });
|
|
|
+ List<CesGoods> cesGoodsList = cesGoodsService.list(queryWrapper);
|
|
|
+ vo.setList(cesGoodsList);
|
|
|
+ voList.add(vo);
|
|
|
+ });
|
|
|
+ return Result.OK(voList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对应酒店用户绑定会员卡信息
|
|
|
+ *
|
|
|
+ * @param memberCard
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "对应酒店用户绑定会员卡信息", notes = "对应酒店用户绑定会员卡信息")
|
|
|
+ @GetMapping(value = "/memeber-card-info")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<BusMemberCard> getMemeberCard(BusMemberCard memberCard) {
|
|
|
+ String tenantId = TenantContextHolder.getTenantId();
|
|
|
+ String userId = ThirdSessionHolder.getUserId();
|
|
|
+ LambdaQueryWrapper<BusMemberCard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(BusMemberCard::getUserId, userId);
|
|
|
+ lambdaQueryWrapper.eq(BusMemberCard::getHotelId, memberCard.getHotelId()).last("limit 1");
|
|
|
+ BusMemberCard busMemberCard = busMemberCardService.getOne(lambdaQueryWrapper);
|
|
|
+ return Result.ok(busMemberCard);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交外卖订单
|
|
|
+ *
|
|
|
+ * @param mallOrderGoods
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "提交外卖订单", notes = "提交外卖订单")
|
|
|
+ @PostMapping(value = "/save-goods-order")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Result<BusMemberCard> saveGoodsOrder(@RequestBody MallOrderGoods mallOrderGoods) {
|
|
|
+ String tenantId = TenantContextHolder.getTenantId();
|
|
|
+ String userId = ThirdSessionHolder.getUserId();
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(mallOrderGoods.getDetailList())) {
|
|
|
+ return Result.error("订单商品列表不能为空");
|
|
|
+ }
|
|
|
+ if (mallOrderGoods.getIsBalancePay()) {
|
|
|
+ if (StringUtils.isBlank(mallOrderGoods.getBalancePwd())) {
|
|
|
+ return Result.error("请输入会员卡密码");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(mallOrderGoods.getMemberId())) {
|
|
|
+ return Result.error("启用余额支付时,会员卡不能为空");
|
|
|
+ }
|
|
|
+ BusMemberCard busMemberCard = busMemberCardService.getById(mallOrderGoods.getMemberId());
|
|
|
+ if (busMemberCard == null) {
|
|
|
+ return Result.error("会员卡不存在");
|
|
|
+ }
|
|
|
+ if (!busMemberCard.getConsumePassword().equals(mallOrderGoods.getBalancePwd())) {
|
|
|
+ return Result.error("会员卡密码不对");
|
|
|
+ }
|
|
|
+ if (busMemberCard.getBalance().compareTo(mallOrderGoods.getMoney()) < 0) {
|
|
|
+ return Result.error("会员卡余额不够");
|
|
|
+ }
|
|
|
+ BusMemberBalanceLog busMemberBalanceLog = new BusMemberBalanceLog();
|
|
|
+ busMemberBalanceLog.setMoney(mallOrderGoods.getMoney());
|
|
|
+ busMemberBalanceLog.setMemberId(mallOrderGoods.getMemberId());
|
|
|
+ busMemberBalanceLog.setHotelId(mallOrderGoods.getHotelId());
|
|
|
+ busMemberBalanceLog.setPaymentMethod("");
|
|
|
+ busMemberBalanceLog.setType(2);
|
|
|
+ busMemberBalanceLog.setGiveMoney(BigDecimal.ZERO);
|
|
|
+ busMemberBalanceLog.setPayMoney(BigDecimal.ZERO);
|
|
|
+ busMemberBalanceLogService.saveBalance(busMemberBalanceLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ mallOrderGoods.setTenantId(tenantId);
|
|
|
+ mallOrderGoods.setMallUserId(userId);
|
|
|
+ mallOrderGoods.setCreateTime(DateTime.now());
|
|
|
+ mallOrderGoods.setPayStatus(0);
|
|
|
+ mallOrderGoods.setStatus(1);
|
|
|
+ mallOrderGoods.setPaymentMethod(1);
|
|
|
+ mallOrderGoods.setIntegralPayMoney(BigDecimal.ZERO);
|
|
|
+ String prefix = "WM";
|
|
|
+ mallOrderGoods.setCode(randomNumber(prefix));
|
|
|
+ mallOrderGoodsService.save(mallOrderGoods);
|
|
|
+ mallOrderGoods.getDetailList().forEach(t -> {
|
|
|
+ t.setHotelId(mallOrderGoods.getHotelId());
|
|
|
+ t.setTenantId(mallOrderGoods.getTenantId());
|
|
|
+ t.setOrderCode(mallOrderGoods.getCode());
|
|
|
+ });
|
|
|
+ mallOrderGoodsDetailService.saveBatch(mallOrderGoods.getDetailList());
|
|
|
+
|
|
|
+ return Result.ok("提交成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 酒店外卖订单列表
|
|
|
+ * @param mallOrderGoods
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "酒店外卖订单列表", notes = "酒店外卖订单列表")
|
|
|
+ @GetMapping(value = "/hotel-goods-order-list")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<IPage<MallOrderGoods>> getHotelGoodsOrderPageList(MallOrderGoods mallOrderGoods,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ String tenantId = TenantContextHolder.getTenantId();
|
|
|
+ String userId = ThirdSessionHolder.getUserId();
|
|
|
+ LambdaQueryWrapper<MallOrderGoods> queryWrapper = QueryGenerator.initQueryWrapper(mallOrderGoods, req.getParameterMap()).lambda();
|
|
|
+ queryWrapper.eq(MallOrderGoods::getTenantId, tenantId);
|
|
|
+ queryWrapper.eq(MallOrderGoods::getMallUserId, userId);
|
|
|
+ Page<MallOrderGoods> page = new Page<MallOrderGoods>(pageNo, pageSize);
|
|
|
+ IPage<MallOrderGoods> pageList = mallOrderGoodsService.page(page, queryWrapper);
|
|
|
+ pageList.getRecords().forEach(t -> {
|
|
|
+ if (t.getStatus().equals(1)) {
|
|
|
+ t.setStatusName("待发货");
|
|
|
+ } else if (t.getStatus().equals(2)) {
|
|
|
+ t.setStatusName("待收货");
|
|
|
+ } else if (t.getStatus().equals(3)) {
|
|
|
+ t.setStatusName("已完成");
|
|
|
+ } else if (t.getStatus().equals(4)) {
|
|
|
+ t.setStatusName("已拒绝");
|
|
|
+ } else if (t.getStatus().equals(5)) {
|
|
|
+ t.setStatusName("已取消");
|
|
|
+ }
|
|
|
+ BusHotel hotel = busHotelService.getById(t.getHotelId());
|
|
|
+ if (hotel != null) {
|
|
|
+ t.setHotelName(hotel.getName());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<MallOrderGoodsDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(MallOrderGoodsDetail::getOrderCode, t.getCode());
|
|
|
+ List<MallOrderGoodsDetail> list=mallOrderGoodsDetailService.list(lambdaQueryWrapper);
|
|
|
+ if(ObjectUtils.isNotEmpty(list)){
|
|
|
+ list.forEach(i->{
|
|
|
+ i.setGoodsInfo(cesGoodsService.getById(i.getGoodsId()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ t.setDetailList(list);
|
|
|
+ });
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询酒店外卖订单列表
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "通过id查询酒店外卖订单列表", notes = "通过id查询酒店外卖订单列表")
|
|
|
+ @GetMapping(value = "/hotel-goods-order-info")
|
|
|
+ @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
|
|
|
+ @ApiLogin
|
|
|
+ public Result<MallOrderGoods> getHotelGoodsOrderInfo(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ MallOrderGoods mallOrderGoods = mallOrderGoodsService.getById(id);
|
|
|
+ if (mallOrderGoods.getStatus().equals(1)) {
|
|
|
+ mallOrderGoods.setStatusName("待发货");
|
|
|
+ } else if (mallOrderGoods.getStatus().equals(2)) {
|
|
|
+ mallOrderGoods.setStatusName("待收货");
|
|
|
+ } else if (mallOrderGoods.getStatus().equals(3)) {
|
|
|
+ mallOrderGoods.setStatusName("已完成");
|
|
|
+ } else if (mallOrderGoods.getStatus().equals(4)) {
|
|
|
+ mallOrderGoods.setStatusName("已拒绝");
|
|
|
+ } else if (mallOrderGoods.getStatus().equals(5)) {
|
|
|
+ mallOrderGoods.setStatusName("已取消");
|
|
|
+ }
|
|
|
+ BusHotel hotel = busHotelService.getById(mallOrderGoods.getHotelId());
|
|
|
+ if (hotel != null) {
|
|
|
+ mallOrderGoods.setHotelName(hotel.getName());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<MallOrderGoodsDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(MallOrderGoodsDetail::getOrderCode, mallOrderGoods.getCode());
|
|
|
+ List<MallOrderGoodsDetail> list=mallOrderGoodsDetailService.list(lambdaQueryWrapper);
|
|
|
+ if(ObjectUtils.isNotEmpty(list)){
|
|
|
+ list.forEach(i->{
|
|
|
+ i.setGoodsInfo(cesGoodsService.getById(i.getGoodsId()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ mallOrderGoods.setDetailList(list);
|
|
|
+ return Result.OK(mallOrderGoods);
|
|
|
+ }
|
|
|
}
|