first commit
This commit is contained in:
@@ -0,0 +1,750 @@
|
||||
package com.mgm.mcrm.reservation.services;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mgm.mcrm.admin.repositories.SysUserDao;
|
||||
import com.mgm.mcrm.admin.services.SysGroupService;
|
||||
import com.mgm.mcrm.admin.services.SysSettingService;
|
||||
import com.mgm.mcrm.allotment.repositories.AppChannelDao;
|
||||
import com.mgm.mcrm.allotment.repositories.RoomCriteriaDao;
|
||||
import com.mgm.mcrm.basesetting.daylight.models.CfgBlocks;
|
||||
import com.mgm.mcrm.basesetting.daylight.models.CfgItemInventory;
|
||||
import com.mgm.mcrm.basesetting.daylight.models.CfgDaylightView;
|
||||
import com.mgm.mcrm.basesetting.daylight.models.CfgTiers;
|
||||
import com.mgm.mcrm.basesetting.daylight.repositories.BlockDao;
|
||||
import com.mgm.mcrm.basesetting.daylight.repositories.DaylightViewDao;
|
||||
import com.mgm.mcrm.basesetting.daylight.repositories.ItemInventoryDao;
|
||||
import com.mgm.mcrm.basesetting.daylight.repositories.TierDao;
|
||||
import com.mgm.mcrm.basesetting.property.models.CfgProperties;
|
||||
import com.mgm.mcrm.basesetting.property.repositories.PropertyDao;
|
||||
import com.mgm.mcrm.basesetting.property.services.PropertyService;
|
||||
import com.mgm.mcrm.basesetting.room.models.CfgRoomFeatures;
|
||||
import com.mgm.mcrm.basesetting.room.models.CfgRoomTypes;
|
||||
import com.mgm.mcrm.basesetting.room.models.CfgRooms;
|
||||
import com.mgm.mcrm.basesetting.room.repositories.*;
|
||||
import com.mgm.mcrm.basesetting.team.repositories.AppUserDao;
|
||||
import com.mgm.mcrm.common.dtos.DataTableResult;
|
||||
import com.mgm.mcrm.common.dtos.QueryFilter;
|
||||
import com.mgm.mcrm.common.dtos.ServiceResult;
|
||||
import com.mgm.mcrm.common.utils.LogUtil;
|
||||
import com.mgm.mcrm.logging.services.SysLogBookingService;
|
||||
import com.mgm.mcrm.reservation.dtos.BookingsDto;
|
||||
import com.mgm.mcrm.reservation.dtos.BookingsViewDto;
|
||||
import com.mgm.mcrm.reservation.dtos.request.BookingGetFollowUpNumRequest;
|
||||
import com.mgm.mcrm.reservation.dtos.request.OtherPropertyPageRequest;
|
||||
import com.mgm.mcrm.reservation.dtos.response.BookingGetFollowUpNumResponse;
|
||||
import com.mgm.mcrm.reservation.mappers.BookingMapper;
|
||||
import com.mgm.mcrm.reservation.models.Bookings;
|
||||
import com.mgm.mcrm.reservation.models.BookingsView;
|
||||
import com.mgm.mcrm.reservation.repositories.BookingDao;
|
||||
import com.mgm.mcrm.reservation.repositories.BookingViewDao;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.auth0.jwt.JWT;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.mgm.mcrm.common.utils.DaoUtil;
|
||||
import com.mgm.mcrm.common.utils.DateTimeUtil;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
public class BookingService {
|
||||
|
||||
@Resource
|
||||
private BookingDao bookingDao;
|
||||
@Resource
|
||||
private BookingViewDao bookingViewDao;
|
||||
@Resource
|
||||
private BlockDao blockDao;
|
||||
@Resource
|
||||
private RoomDao roomDao;
|
||||
@Resource
|
||||
private RoomTypeDao roomTypeDao;
|
||||
@Resource
|
||||
private AppUserDao appUserDao;
|
||||
@Resource
|
||||
private DaylightViewDao daylightViewDao;
|
||||
@Resource
|
||||
private SysUserDao userDao;
|
||||
@Resource
|
||||
private TierDao tierDao;
|
||||
@Resource
|
||||
private ItemInventoryDao itemDao;
|
||||
@Resource
|
||||
private PropertyDao propertyDao;
|
||||
@Resource
|
||||
private SysSettingService sysSettingService;
|
||||
@Resource
|
||||
private AppChannelDao appChannelDao;
|
||||
@Resource
|
||||
private RoomCriteriaDao criteriaDao;
|
||||
@Resource
|
||||
private RoomRoomTypeDao roomRoomTypeDao;
|
||||
@Resource
|
||||
private RoomFeatureDao roomFeatureDao;
|
||||
@Resource
|
||||
private BedTypeMappingDao bedTypeMappingDao;
|
||||
@Resource
|
||||
private PropertyService propertyService;
|
||||
@Resource
|
||||
private SysLogBookingService sysLogBookingService;
|
||||
@Resource
|
||||
private SysGroupService sysGroupService;
|
||||
@Resource
|
||||
private BookingMapper bookingMapper;
|
||||
|
||||
public ServiceResult createBooking(Map<String,Object> param, HttpServletRequest request) {
|
||||
ServiceResult processResult= new ServiceResult();
|
||||
LocalDateTime createDate = LocalDateTime.now();
|
||||
Bookings booking = new Bookings();
|
||||
String playerId = String.valueOf(param.get("playerId"));
|
||||
Long blockId = Long.valueOf(String.valueOf(param.get("blockId")));
|
||||
Long propertyId = Long.valueOf(String.valueOf(param.get("propertyId")));
|
||||
Long roomId = Long.valueOf(String.valueOf(param.get("roomId")));
|
||||
Long roomTypeId = Long.valueOf(String.valueOf(param.get("roomTypeId")));
|
||||
String special = param.get("specialIds")!=null?String.valueOf(param.get("specialIds")):null;
|
||||
String sharer = param.get("sharer")!=null?String.valueOf(param.get("sharer")):null;
|
||||
String remark = param.get("remark")!=null?String.valueOf(param.get("remark")):null;
|
||||
Boolean isWaitlist = Boolean.valueOf(String.valueOf(param.get("isWaitlist")));
|
||||
HashMap member = (HashMap)param.get("member");
|
||||
List operaId = (List)member.get("nameId");
|
||||
List selectDate = (List)param.get("selectDate");
|
||||
LocalDateTime checkinDate = DateTimeUtil.getDateFromString(String.valueOf(selectDate.get(0)), "yyyy-MM-dd");
|
||||
LocalDateTime checkoutDate = DateTimeUtil.getDateFromString(String.valueOf(selectDate.get(1)), "yyyy-MM-dd");
|
||||
String numOfNight = DateTimeUtil.getDiffDate(checkinDate, checkoutDate, "day");
|
||||
CfgProperties property = propertyDao.findById(propertyId).orElse(null);
|
||||
CfgBlocks block = blockDao.getById(blockId);
|
||||
CfgRooms room = roomDao.getById(roomId);
|
||||
CfgRoomTypes roomType = roomTypeDao.getById(roomTypeId);
|
||||
CfgTiers tier = tierDao.findByTierName(String.valueOf(member.get("tier")));
|
||||
CfgItemInventory item = new CfgItemInventory();
|
||||
if(tier!=null&&blockId!=null&&roomTypeId!=null) {
|
||||
item = itemDao.findByTierIdAndRoomId(Long.valueOf(tier.getId()),roomId);
|
||||
}
|
||||
String oldToken = request.getHeader("Authorization");
|
||||
// oldToken = oldToken.substring(6);
|
||||
String userId = JWT.decode(oldToken).getClaim("login_id").asString();
|
||||
Long sectionId = 2L;
|
||||
|
||||
List<CfgDaylightView> operas = daylightViewDao.findByPropertyIdAndBookingTypeId(propertyId,blockId);
|
||||
List<CfgDaylightView> teamOpera = new ArrayList();
|
||||
CfgDaylightView opera = new CfgDaylightView();
|
||||
for(CfgDaylightView o :operas) {
|
||||
for(CfgRoomTypes r :o.getDaylightRoomType()) {
|
||||
if(Objects.equals(r.getId(), roomTypeId)) {
|
||||
teamOpera.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String blockCode = null;
|
||||
for(CfgDaylightView o :teamOpera) {
|
||||
LocalDateTime startTime = o.getStartDate();
|
||||
LocalDateTime endTime = o.getEndDate();
|
||||
if((startTime.isBefore(checkinDate) || startTime.isEqual(checkinDate))
|
||||
&& (endTime.isAfter(checkoutDate) || endTime.isEqual(checkoutDate))) {
|
||||
blockCode = o.getBlockCodeName();
|
||||
opera = o;
|
||||
}
|
||||
}
|
||||
|
||||
booking.setId(null);
|
||||
booking.setPlayerId(playerId);
|
||||
booking.setMemberTitle(String.valueOf(member.get("salutation")));
|
||||
// booking.setMemberFirstName(memberFirstName);
|
||||
booking.setMemberLastName(String.valueOf(member.get("name")));
|
||||
booking.setCheckinDate(checkinDate);
|
||||
booking.setCheckoutDate(checkoutDate);
|
||||
booking.setPropertyId(propertyId);
|
||||
booking.setHotelCode(property.getCode());
|
||||
booking.setRoomTypeId(roomTypeId);
|
||||
// booking.setOperaProfileId(Long.valueOf(String.valueOf(operaId.get(0))));
|
||||
booking.setDlBlockId(blockCode);
|
||||
booking.setRatePlanCode(opera.getRateCode().getCode());
|
||||
booking.setRoomTypeCode(roomType.getCode());
|
||||
booking.setMarketCode(opera.getMarketCode().getCode());
|
||||
booking.setDlSourceId(opera.getSourceCode().getDlSourceId());
|
||||
booking.setSourceCode(opera.getSourceCode().getCode());
|
||||
booking.setCreatedAt(createDate);
|
||||
booking.setCreatedBy(JWT.decode(oldToken).getSubject());
|
||||
booking.setSectionId(sectionId);
|
||||
booking.setApproveStatus(isWaitlist?"W":"PN");
|
||||
booking.setRemark(remark);
|
||||
booking.setBookType("0");
|
||||
booking.setBlock(block.getName());
|
||||
booking.setNumOfNight(Integer.valueOf(numOfNight));
|
||||
// booking.setTeamName(team.getCode());
|
||||
booking.setBooker(userId);
|
||||
booking.setSharer(sharer);
|
||||
booking.setItemCode(item.getId()!=null?item.getDlCode():null);
|
||||
booking.setFeatureCode(special);
|
||||
booking.setRoom(room.getName());
|
||||
|
||||
booking.setCategory(property.getCategory());
|
||||
|
||||
Bookings newBooking= bookingDao.save(booking);
|
||||
|
||||
processResult.setSuccess(true);
|
||||
processResult.setReturnData(booking);
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public ServiceResult updateBooking(Bookings booking) {
|
||||
ServiceResult processResult= new ServiceResult();
|
||||
Bookings existsType = bookingDao.findById(booking.getId()).orElse(null);
|
||||
if(existsType==null) {
|
||||
processResult.setErrorCode("ERR_OBJECT_NOT_FOUND");
|
||||
processResult.setErrorMessage("Can't find Booking by Id");
|
||||
}else {
|
||||
String[] ignoreProperties = new String[] {"id","createdAt",
|
||||
"createdBy","updatedAt","updatedBy"};
|
||||
BeanUtils.copyProperties(booking, existsType, ignoreProperties);
|
||||
booking.setCreatedAt(existsType.getCreatedAt());
|
||||
booking.setUpdatedAt( DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"));
|
||||
bookingDao.save(booking);
|
||||
processResult.setReturnData(existsType);
|
||||
processResult.setSuccess(true);
|
||||
}
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public ServiceResult updateFailedBooking(Bookings booking) {
|
||||
ServiceResult processResult= new ServiceResult();
|
||||
Bookings existsType = bookingDao.findById(booking.getId()).orElse(null);
|
||||
if(existsType==null) {
|
||||
processResult.setErrorCode("ERR_OBJECT_NOT_FOUND");
|
||||
processResult.setErrorMessage("Can't find Booking by Id");
|
||||
}else {
|
||||
existsType.setApproveStatus(booking.getApproveStatus());
|
||||
existsType.setMscRemark(booking.getMscRemark());
|
||||
existsType.setUpdatedAt( DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"));
|
||||
existsType.setUpdatedBy(booking.getUpdatedBy());
|
||||
bookingDao.save(existsType);
|
||||
processResult.setReturnData(existsType);
|
||||
processResult.setSuccess(true);
|
||||
}
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public ServiceResult updateWaitlistBookingStatus(Bookings booking) {
|
||||
ServiceResult processResult= new ServiceResult();
|
||||
Bookings existsType = bookingDao.findById(booking.getId()).orElse(null);
|
||||
if(existsType==null) {
|
||||
processResult.setErrorCode("ERR_OBJECT_NOT_FOUND");
|
||||
processResult.setErrorMessage("Can't find Booking by Id");
|
||||
}else {
|
||||
if("W".equals(booking.getApproveStatus())) {
|
||||
existsType.setApproveStatus("WA");
|
||||
existsType.setApprovedBy(booking.getUpdatedBy());
|
||||
existsType.setApprovedAt( DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"));
|
||||
}else if("WA".equals(booking.getApproveStatus())) {
|
||||
existsType.setApproveStatus("WR");
|
||||
existsType.setApprovedBy(booking.getUpdatedBy());
|
||||
existsType.setApprovedAt( DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"));
|
||||
}else if("WR".equals(booking.getApproveStatus())) {
|
||||
existsType.setApproveStatus("W");
|
||||
existsType.setApprovedBy(null);
|
||||
existsType.setApprovedAt(null);
|
||||
}
|
||||
|
||||
existsType.setUpdatedAt( DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"));
|
||||
existsType.setUpdatedBy(booking.getUpdatedBy());
|
||||
|
||||
bookingDao.save(existsType);
|
||||
processResult.setReturnData(existsType);
|
||||
processResult.setSuccess(true);
|
||||
}
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public ServiceResult updateWaitlistBookingRemark(Bookings booking) {
|
||||
ServiceResult processResult= new ServiceResult();
|
||||
Bookings existsType = bookingDao.findById(booking.getId()).orElse(null);
|
||||
if(existsType==null) {
|
||||
processResult.setErrorCode("ERR_OBJECT_NOT_FOUND");
|
||||
processResult.setErrorMessage("Can't find Booking by Id");
|
||||
}else {
|
||||
existsType.setMscRemark(booking.getMscRemark());
|
||||
existsType.setUpdatedAt( DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"));
|
||||
existsType.setUpdatedBy(booking.getUpdatedBy());
|
||||
|
||||
bookingDao.save(existsType);
|
||||
processResult.setReturnData(existsType);
|
||||
processResult.setSuccess(true);
|
||||
}
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public ServiceResult updateBatchWaitlistBookingStatus(String[]bookIds,String status,String approver) {
|
||||
ServiceResult processResult= new ServiceResult();
|
||||
String approvedBy = null;
|
||||
LocalDateTime approvedAt = null;
|
||||
|
||||
bookingDao.updateBatchStatus(status,bookIds);
|
||||
if("W".equals(status)) {
|
||||
bookingDao.updateBatchApprover(approvedBy,approvedAt,bookIds);
|
||||
}else if("WA".equals(status)) {
|
||||
approvedBy = approver;
|
||||
approvedAt = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss");
|
||||
bookingDao.updateBatchApprover(approvedBy,approvedAt,bookIds);
|
||||
}else if("WR".equals(status)) {
|
||||
approvedBy = approver;
|
||||
approvedAt = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss");
|
||||
bookingDao.updateBatchApprover(approvedBy,approvedAt,bookIds);
|
||||
}
|
||||
processResult.setReturnData(bookIds);
|
||||
processResult.setSuccess(true);
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public BookingsDto getBookingById(long id) {
|
||||
BookingsDto booking = bookingMapper.toBookingDto(bookingDao.findById(id).orElse(null));
|
||||
return booking;
|
||||
}
|
||||
|
||||
public BookingGetFollowUpNumResponse getFollowUpBookingNum(BookingGetFollowUpNumRequest bookingGetFollowUpNumRequest) {
|
||||
|
||||
BookingGetFollowUpNumResponse response = new BookingGetFollowUpNumResponse();
|
||||
|
||||
String marketCode = bookingGetFollowUpNumRequest.getSearchMarketCode();
|
||||
|
||||
if (StringUtils.isNotBlank(marketCode)) {
|
||||
response.setNewBooking(bookingDao.getFollowUpNewBookingByMarketCode(1,marketCode));
|
||||
response.setExtendBooking(bookingDao.getFollowUpNewBookingByMarketCode(2,marketCode));
|
||||
response.setPendingBooking(bookingDao.getFollowUpNewBookingByMarketCode(3,marketCode));
|
||||
response.setDoneBooking(bookingDao.getFollowUpNewBookingByMarketCode(4,marketCode));
|
||||
response.setCancelBooking(bookingDao.getFollowUpNewBookingByMarketCode(5,marketCode));
|
||||
}else {
|
||||
response.setNewBooking(bookingDao.getFollowUpNewBooking(1));
|
||||
response.setExtendBooking(bookingDao.getFollowUpNewBooking(2));
|
||||
response.setPendingBooking(bookingDao.getFollowUpNewBooking(3));
|
||||
response.setDoneBooking(bookingDao.getFollowUpNewBooking(4));
|
||||
response.setCancelBooking(bookingDao.getFollowUpNewBooking(5));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public Bookings save(Bookings booking) {
|
||||
return bookingDao.save(booking);
|
||||
}
|
||||
|
||||
public DataTableResult<BookingsView> getBookingByPage(OtherPropertyPageRequest otherPropertyPageRequest) {
|
||||
|
||||
LogUtil.info(BookingService.class, "otherPropertyPageRequest body: " + JSON.toJSONString(otherPropertyPageRequest));
|
||||
|
||||
// 先验证分页参数
|
||||
otherPropertyPageRequest.validatePageInfo();
|
||||
Specification<BookingsView> listSpec = buildSpecificationViewByQueryFilter(otherPropertyPageRequest);
|
||||
int pageSize = otherPropertyPageRequest.getPageSize();
|
||||
int pageStart = otherPropertyPageRequest.getStartRow()/pageSize;
|
||||
String sortProperties = otherPropertyPageRequest.getSortOrder()!=null?otherPropertyPageRequest.getSortOrder():"";
|
||||
sortProperties = sortProperties.replace("1-asc", "-asc");
|
||||
sortProperties = sortProperties.replace("1-desc", "-desc");
|
||||
otherPropertyPageRequest.setSortOrder(sortProperties);
|
||||
Sort sort = DaoUtil.buildSortByString(otherPropertyPageRequest.getSortOrder(), "id");
|
||||
Pageable pageable = PageRequest.of(pageStart, pageSize, sort);
|
||||
Page<BookingsView> resultPage = bookingViewDao.findAll(listSpec, pageable);
|
||||
|
||||
// LogUtil.info(BookingService.class, "resultPage:"+resultPage.getContent());
|
||||
|
||||
DataTableResult<BookingsView> dataResult = new DataTableResult<BookingsView>();
|
||||
dataResult.setTotalRecords(resultPage.getTotalElements());
|
||||
dataResult.setPageSize(pageSize);
|
||||
List<BookingsView> resultList = resultPage.getContent();
|
||||
dataResult.setRowData(resultList);
|
||||
return dataResult;
|
||||
}
|
||||
public List<BookingsView> listBookingView(QueryFilter queryFilter) {
|
||||
OtherPropertyPageRequest otherPropertyPageRequest = new OtherPropertyPageRequest();
|
||||
Specification<BookingsView> listSpec = buildSpecificationViewByQueryFilter(otherPropertyPageRequest);
|
||||
Sort sort = DaoUtil.buildSortByFilter(queryFilter, "id");
|
||||
return bookingViewDao.findAll(listSpec,sort);
|
||||
}
|
||||
public List<Bookings> listBooking(QueryFilter queryFilter) {
|
||||
Specification<Bookings> listSpec = buildSpecificationByQueryFilter(queryFilter);
|
||||
Sort sort = DaoUtil.buildSortByFilter(queryFilter, "id");
|
||||
return bookingDao.findAll(listSpec,sort);
|
||||
}
|
||||
public List<BookingsViewDto> listBookingViewToExport(QueryFilter queryFilter) {
|
||||
OtherPropertyPageRequest otherPropertyPageRequest = queryFilter.convertToRequest(OtherPropertyPageRequest.class);
|
||||
if(otherPropertyPageRequest == null) {
|
||||
otherPropertyPageRequest = new OtherPropertyPageRequest();
|
||||
}
|
||||
Specification<BookingsView> listSpec = buildSpecificationViewByQueryFilter(otherPropertyPageRequest);
|
||||
Sort sort = DaoUtil.buildSortByFilter(queryFilter, "id");
|
||||
String sortProperties = queryFilter.getString("sortOrder");
|
||||
List<BookingsViewDto> resultList = bookingMapper.toBookingViewDtoList(bookingViewDao.findAll(listSpec,sort));
|
||||
if(resultList!=null) {
|
||||
List<CfgRoomFeatures> features = roomFeatureDao.findAll();
|
||||
int key = 1;
|
||||
for(BookingsViewDto booking:resultList) {
|
||||
String statusName="";
|
||||
if("W".equals(booking.getApproveStatus())) {
|
||||
statusName="Pending";
|
||||
}else if("WC".equals(booking.getApproveStatus())) {
|
||||
statusName="Cancelled";
|
||||
}else if("WF".equals(booking.getApproveStatus())) {
|
||||
statusName="Reserved";
|
||||
}else if("WE".equals(booking.getApproveStatus())) {
|
||||
statusName="Expired";
|
||||
}else if("F".equals(booking.getApproveStatus())) {
|
||||
statusName="Failed";
|
||||
}else if("FC".equals( booking.getApproveStatus())) {
|
||||
statusName="Completed";
|
||||
}else if("WA".equals(booking.getApproveStatus())) {
|
||||
statusName="Approved";
|
||||
}else if("WR".equals(booking.getApproveStatus())) {
|
||||
statusName="Reject";
|
||||
}
|
||||
|
||||
booking.setApproveStatusName(statusName);
|
||||
booking.setBookTypeName("1".equals(booking.getBookType())?"Extension":"New");
|
||||
if(booking.getSegment()!=null) {
|
||||
booking.setSegmentName(booking.getSegment().getSegmentName());
|
||||
}
|
||||
if(booking.getOtherRoomStatus()!=null) {
|
||||
booking.setRoomStatusName(booking.getOtherRoomStatus().getStatusName());
|
||||
}
|
||||
if(booking.getOtherFollowUpStatus()!=null) {
|
||||
booking.setFollowUpStatusName(booking.getOtherFollowUpStatus().getName());
|
||||
}
|
||||
|
||||
booking.setMemberFullName(booking.getMemberLastName());
|
||||
String nameStr = Strings.CS.replace(booking.getMemberLastName(), ", ", ";");
|
||||
String[] nameArr = StringUtils.split(nameStr, ";");
|
||||
if(nameArr!=null&&nameArr.length>1) {
|
||||
booking.setMemberFirstName(nameArr[1]);
|
||||
booking.setMemberLastName(nameArr[0]);
|
||||
}else {
|
||||
booking.setMemberFirstName(booking.getMemberLastName());
|
||||
}
|
||||
|
||||
if(booking.getFeatureCode()!=null && !booking.getFeatureCode().isEmpty()) {
|
||||
String[] arrSpecialCode = booking.getFeatureCode().split(",");
|
||||
String specialStr = "";
|
||||
if(arrSpecialCode.length>0)
|
||||
{
|
||||
for (String s : arrSpecialCode) {
|
||||
if (!s.isEmpty()) {
|
||||
for (CfgRoomFeatures feature : features) {
|
||||
if (feature.getDlAttributeId() != null && feature.getDlAttributeId().equals(s)) {
|
||||
if ("".equals(specialStr)) {
|
||||
specialStr = feature.getDescription();
|
||||
} else {
|
||||
specialStr = specialStr + ", " + feature.getDescription();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isEmpty(specialStr)) {
|
||||
booking.setSpecialName(booking.getFeatureCode());
|
||||
}else {
|
||||
booking.setSpecialName(specialStr);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(booking.getSharer()!=null&&!"[]".equals(booking.getSharer())
|
||||
&&!StringUtils.isEmpty(booking.getSharer())) {
|
||||
JSONArray sharerArr = JSONArray.parseArray(booking.getSharer());
|
||||
List<String> sharerId = new ArrayList<String>();
|
||||
List<String> sharerName = new ArrayList<String>();
|
||||
for(Object sharer : sharerArr) {
|
||||
JSONObject sharerObj = (JSONObject) sharer;
|
||||
if(sharerObj.containsKey("playerId")) {
|
||||
sharerId.add(sharerObj.get("playerId").toString());
|
||||
}
|
||||
if(sharerObj.containsKey("name")) {
|
||||
sharerName.add(sharerObj.get("name").toString());
|
||||
}
|
||||
}
|
||||
booking.setSharer(String.join(";", sharerId));
|
||||
booking.setSharerName(String.join(";", sharerName));
|
||||
}else {
|
||||
booking.setSharer("");
|
||||
booking.setSharerName("");
|
||||
}
|
||||
|
||||
if(sortProperties!=null && sortProperties.contains("dailyTheoProfit-asc")) {
|
||||
booking.setRankingByPlayer(resultList.size()-key-1+"");
|
||||
}else {
|
||||
booking.setRankingByPlayer(key+"");
|
||||
}
|
||||
key++;
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
private Specification<Bookings> buildSpecificationByQueryFilter(QueryFilter queryfilter) {
|
||||
Specification<Bookings> Bookingpec = new Specification<Bookings>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<Bookings> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
|
||||
List<Predicate> list = new ArrayList<>();
|
||||
Map query = queryfilter.getFilterParas();
|
||||
if (StringUtils.isNotBlank(queryfilter.getString("searchName"))) {
|
||||
list.add(cb.like(cb.upper(root.get("id")),
|
||||
"%" + queryfilter.getString("searchName").toUpperCase() + "%"));
|
||||
}
|
||||
if (StringUtils.isNotBlank(queryfilter.getString("searchPlayerId"))) {
|
||||
list.add(cb.like(cb.upper(root.get("playerId")),
|
||||
"%" + queryfilter.getString("searchPlayerId").toUpperCase() + "%"));
|
||||
}
|
||||
if (StringUtils.isNotBlank(queryfilter.getString("searchConfirmationNo"))) {
|
||||
list.add(cb.like(cb.upper(root.get("confirmationNo")),
|
||||
"%" + queryfilter.getString("searchConfirmationNo").toUpperCase() + "%"));
|
||||
}
|
||||
if (StringUtils.isNotBlank(queryfilter.getString("searchStatus"))) {
|
||||
list.add(cb.like(cb.upper(root.get("approveStatus")),
|
||||
"%" + queryfilter.getString("searchStatus").toUpperCase() + "%"));
|
||||
}
|
||||
if(StringUtils.isNotBlank(queryfilter.getString("permissionId"))) {
|
||||
String routerId=queryfilter.getString("permissionId");
|
||||
String paraGroup=queryfilter.getString("permissionGroup");
|
||||
String groupName = StringUtils.isNotBlank(paraGroup)?paraGroup:"NO_GROUP";
|
||||
List<Long> accessRoomIds = sysGroupService.getGroupAccessRoomIds(routerId, groupName);
|
||||
list.add(root.get("roomId").in(accessRoomIds));
|
||||
}
|
||||
if (query.get("searchPropertyCode")!=null&&((ArrayList) query.get("searchPropertyCode")).size()>0) {
|
||||
CriteriaBuilder.In<String> in = cb.in(root.get("hotelCode"));
|
||||
List<Long> qu = (ArrayList) query.get("searchPropertyCode");
|
||||
for(int i=0;i<qu.size();i++){
|
||||
in.value((String.valueOf(qu.get(i))));
|
||||
}
|
||||
list.add(cb.and(cb.and(in)));
|
||||
}
|
||||
Predicate[] predicates = new Predicate[list.size()];
|
||||
criteriaQuery.where(list.toArray(predicates));
|
||||
return cb.and(list.toArray(predicates));
|
||||
}
|
||||
};
|
||||
return Bookingpec;
|
||||
}
|
||||
|
||||
private Specification<BookingsView> buildSpecificationViewByQueryFilter(OtherPropertyPageRequest otherPropertyPageRequest) {
|
||||
Specification<BookingsView> Bookingpec = new Specification<BookingsView>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<BookingsView> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
|
||||
List<Predicate> list = new ArrayList<>();
|
||||
if (otherPropertyPageRequest.getSearchId() != null) {
|
||||
list.add(cb.equal(root.get("id"), otherPropertyPageRequest.getSearchId()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchName())) {
|
||||
list.add(cb.like(cb.upper(root.get("id")),
|
||||
"%" + otherPropertyPageRequest.getSearchName().toUpperCase() + "%"));
|
||||
}
|
||||
if(StringUtils.isNotBlank(otherPropertyPageRequest.getSearchBookerId())) {
|
||||
list.add(cb.like(cb.upper(root.get("createdBy")),
|
||||
"%" + otherPropertyPageRequest.getSearchBookerId().toUpperCase() + "%"));
|
||||
}
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchBookerName())) {
|
||||
list.add(cb.like(cb.upper(root.get("booker")),
|
||||
"%" + otherPropertyPageRequest.getSearchBookerName().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchBookerTeam())) {
|
||||
list.add(cb.like(cb.upper(root.get("bookerTeam")),
|
||||
"%" + otherPropertyPageRequest.getSearchBookerTeam().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchPlayerId())) {
|
||||
list.add(cb.like(cb.upper(root.get("playerId")),
|
||||
"%" + otherPropertyPageRequest.getSearchPlayerId().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchLastName())) {
|
||||
list.add(cb.like(cb.upper(root.get("memberLastName")),
|
||||
"%" + otherPropertyPageRequest.getSearchLastName().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchFirstName())) {
|
||||
list.add(cb.like(cb.upper(root.get("memberLastName")),
|
||||
"%" + ", " + otherPropertyPageRequest.getSearchFirstName().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchConfirmationNo())) {
|
||||
list.add(cb.like(cb.upper(root.get("confirmationNo")),
|
||||
"%" + otherPropertyPageRequest.getSearchConfirmationNo().toUpperCase() + "%"));
|
||||
}
|
||||
if(StringUtils.isNotBlank(otherPropertyPageRequest.getSearchStatus())) {
|
||||
List<String> searchStatus = DaoUtil.parseMultipleFilter(otherPropertyPageRequest.getSearchStatus());
|
||||
if(searchStatus.size() == 1) {
|
||||
list.add(cb.equal(root.get("approveStatus"), searchStatus.get(0)));
|
||||
} else if(searchStatus.size() > 1) {
|
||||
list.add(root.get("approveStatus").in(searchStatus));
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(otherPropertyPageRequest.getSearchTryTime())) {
|
||||
try {
|
||||
int tryTime = Integer.parseInt(otherPropertyPageRequest.getSearchTryTime());
|
||||
if(tryTime > 0) {
|
||||
list.add(cb.greaterThanOrEqualTo(root.get("tryTime"), tryTime));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
if(otherPropertyPageRequest.getSearchPropertyId() != null && !otherPropertyPageRequest.getSearchPropertyId().isEmpty()) {
|
||||
List<Long> propertyIds = otherPropertyPageRequest.getSearchPropertyId();
|
||||
if(!propertyIds.isEmpty()) {
|
||||
if(!propertyIds.contains(0L)) {
|
||||
list.add(root.get("propertyId").in(propertyIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(otherPropertyPageRequest.getSearchBookDate() != null && !otherPropertyPageRequest.getSearchBookDate().isEmpty()) {
|
||||
List<String> date = otherPropertyPageRequest.getSearchBookDate();
|
||||
if(date.size() >= 2) {
|
||||
list.add(cb.greaterThanOrEqualTo(root.get("createdAt"),
|
||||
DateTimeUtil.getDateFromString(date.get(0) + " 00:00:00", "yyyy-MM-dd HH:mm:ss")));
|
||||
list.add(cb.lessThanOrEqualTo(root.get("createdAt"),
|
||||
DateTimeUtil.getDateFromString(date.get(1) + " 23:59:59", "yyyy-MM-dd HH:mm:ss")));
|
||||
}
|
||||
}
|
||||
if(otherPropertyPageRequest.getSearchCheckInDate() != null && !otherPropertyPageRequest.getSearchCheckInDate().isEmpty()) {
|
||||
List<String> searchCheckInDate = otherPropertyPageRequest.getSearchCheckInDate();
|
||||
if(searchCheckInDate.size() >= 1) {
|
||||
list.add(cb.greaterThanOrEqualTo(root.get("checkoutDate"),
|
||||
DateTimeUtil.getDateFromString(searchCheckInDate.get(0), "yyyy-MM-dd")));
|
||||
if(searchCheckInDate.size() >= 2) {
|
||||
list.add(cb.lessThanOrEqualTo(root.get("checkinDate"),
|
||||
DateTimeUtil.getDateFromString(searchCheckInDate.get(1), "yyyy-MM-dd")));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchWaitlistCheckInDate())) {
|
||||
String searchWaitlistCheckInDate = otherPropertyPageRequest.getSearchWaitlistCheckInDate();
|
||||
String[] date = searchWaitlistCheckInDate.split(",");
|
||||
if(date.length >= 1) {
|
||||
list.add(cb.greaterThanOrEqualTo(root.get("checkinDate"),
|
||||
DateTimeUtil.getDateFromString(date[0], "yyyy-MM-dd")));
|
||||
if(date.length >= 2) {
|
||||
list.add(cb.lessThanOrEqualTo(root.get("checkinDate"),
|
||||
DateTimeUtil.getDateFromString(date[1], "yyyy-MM-dd")));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(otherPropertyPageRequest.getPermissionId())) {
|
||||
String routerId = otherPropertyPageRequest.getPermissionId();
|
||||
String paraGroup = otherPropertyPageRequest.getPermissionGroup();
|
||||
String groupName = StringUtils.isNotBlank(paraGroup) ? paraGroup : "NO_GROUP";
|
||||
List<Long> accessRoomIds = sysGroupService.getGroupAccessRoomIds(routerId, groupName);
|
||||
list.add(root.get("roomId").in(accessRoomIds));
|
||||
}
|
||||
if(otherPropertyPageRequest.getSearchRoomId() != null && !otherPropertyPageRequest.getSearchRoomId().isEmpty()) {
|
||||
List<Long> roomIds = otherPropertyPageRequest.getSearchRoomId();
|
||||
if(!roomIds.isEmpty()) {
|
||||
list.add(root.get("roomId").in(roomIds));
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(otherPropertyPageRequest.getSearchRoomTypeId())) {
|
||||
try {
|
||||
String[] roomTypeIdArray = otherPropertyPageRequest.getSearchRoomTypeId().split(",");
|
||||
List<Long> roomTypeIds = new ArrayList<>();
|
||||
for (String id : roomTypeIdArray) {
|
||||
roomTypeIds.add(Long.parseLong(id.trim()));
|
||||
}
|
||||
if(!roomTypeIds.isEmpty()) {
|
||||
list.add(root.get("roomTypeId").in(roomTypeIds));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
if(otherPropertyPageRequest.getSearchOtherRoomStatusId() != null &&
|
||||
!otherPropertyPageRequest.getSearchOtherRoomStatusId().isEmpty()) {
|
||||
List<Long> otherRoomStatusIds = otherPropertyPageRequest.getSearchOtherRoomStatusId();
|
||||
if(!otherRoomStatusIds.isEmpty()) {
|
||||
if(!otherRoomStatusIds.contains(0L)) {
|
||||
list.add(root.get("otherRoomStatusId").in(otherRoomStatusIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchPropertyCategory())) {
|
||||
list.add(cb.like(cb.upper(root.get("propertyCategory")),
|
||||
"%" + otherPropertyPageRequest.getSearchPropertyCategory().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (otherPropertyPageRequest.getSearchFollowUpStatusId() != null) {
|
||||
list.add(cb.equal(root.get("otherFollowUpStatusId"),
|
||||
otherPropertyPageRequest.getSearchFollowUpStatusId()));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchMarketCode())) {
|
||||
list.add(cb.equal(cb.upper(root.get("marketCode")),
|
||||
otherPropertyPageRequest.getSearchMarketCode().toUpperCase()));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getSearchSourceCode())) {
|
||||
list.add(cb.equal(cb.upper(root.get("dlSourceId")),
|
||||
otherPropertyPageRequest.getSearchSourceCode().toUpperCase()));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getPropertyName())) {
|
||||
list.add(cb.like(cb.upper(root.get("propertyName")),
|
||||
"%" + otherPropertyPageRequest.getPropertyName().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getRoomStatusName())) {
|
||||
list.add(cb.like(cb.upper(root.get("roomStatusName")),
|
||||
"%" + otherPropertyPageRequest.getRoomStatusName().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(otherPropertyPageRequest.getRoomTypeName())) {
|
||||
list.add(cb.like(cb.upper(root.get("roomTypeName")),
|
||||
"%" + otherPropertyPageRequest.getRoomTypeName().toUpperCase() + "%"));
|
||||
}
|
||||
|
||||
Predicate[] predicates = new Predicate[list.size()];
|
||||
criteriaQuery.where(list.toArray(predicates));
|
||||
return cb.and(list.toArray(predicates));
|
||||
}
|
||||
};
|
||||
return Bookingpec;
|
||||
}
|
||||
public DataTableResult<BookingsView> getMockupBookingByPage() throws Exception {
|
||||
List<BookingsView> bookList = bookingViewDao.findMockupOtherPropertyBooking();
|
||||
DataTableResult<BookingsView> dataResult = new DataTableResult<>();
|
||||
dataResult.setTotalRecords(bookList.size());
|
||||
dataResult.setPageSize(0);
|
||||
dataResult.setRowData(bookList);
|
||||
return dataResult;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user