diff --git a/src/main/java/com/mgm/mcrm/TestRun.java b/src/main/java/com/mgm/mcrm/TestRun.java index 6a7af41..cd0701d 100644 --- a/src/main/java/com/mgm/mcrm/TestRun.java +++ b/src/main/java/com/mgm/mcrm/TestRun.java @@ -1,11 +1,8 @@ package com.mgm.mcrm; -import java.util.UUID; - public class TestRun { public static void main(String[] args) { - - System.out.println(UUID.randomUUID()); + } } \ No newline at end of file diff --git a/src/main/java/com/mgm/mcrm/approval/service/ApprovalService.java b/src/main/java/com/mgm/mcrm/approval/service/ApprovalService.java index e4bf0e4..6303f98 100644 --- a/src/main/java/com/mgm/mcrm/approval/service/ApprovalService.java +++ b/src/main/java/com/mgm/mcrm/approval/service/ApprovalService.java @@ -187,7 +187,7 @@ public class ApprovalService { return response; } - try { + try { HttpResponseResult httpResult = mgmApiService.invokeGetApprover(playerId,bookingType,propertyName,roomCategory,checkInDate,checkOutDate,userId); try { ApproverResult resultObj = JSONObject.parseObject(httpResult.getResponseContent(), ApproverResult.class, Feature.SupportNonPublicField,Feature.IgnoreNotMatch); @@ -328,7 +328,7 @@ public class ApprovalService { // 已超过入住日(不含当天),且当前时间不在配置的 HH:mm 窗口内 → AE if (checkinDateOnly.isBefore(today) && !isCurrentTimeWithinCutoffWindowGmt8(cutoffStartTimeValue, cutoffEndTimeValue)) { - Bookings entity = bookingDao.getById(booking.getId()); + Bookings entity = bookingDao.findById(booking.getId()).orElse(null); if (entity != null) { entity.setApproveStatus("AE"); entity.setUpdatedAt(now); @@ -374,8 +374,8 @@ public class ApprovalService { Date createDate = new Date(); Bookings booking = new Bookings(); Long bookId = Long.valueOf(String.valueOf(param.get("id"))); - ArrayList booksList = new ArrayList(); - booking = bookingDao.getById(bookId); + ArrayList booksList = new ArrayList<>(); + booking = bookingDao.findById(bookId).orElse(null); String status = booking.getApproveStatus(); if (Strings.CS.equals(booking.getCreatedBy(),userId)){ @@ -539,7 +539,7 @@ public class ApprovalService { cfgApprovalRouting.setUpdatedBy(userId); approvalRoutingDao.save(cfgApprovalRouting); - Bookings entity = bookingDao.getById(cfgApprovalRouting.getBookingId()); + Bookings entity = bookingDao.findById(cfgApprovalRouting.getBookingId()).orElse(null); if (entity != null) { entity.setApproveStatus("AE"); entity.setUpdatedAt(now); @@ -642,7 +642,7 @@ public class ApprovalService { return response; } - Bookings booking = bookingDao.getById(approvalRouting.getBookingId()); + Bookings booking = bookingDao.findById(approvalRouting.getBookingId()).orElse(null); booking.setApprovedId(Long.valueOf(userId)); booking.setApprovedAt(now); booking.setApproveStatus("AR"); @@ -708,8 +708,8 @@ public class ApprovalService { public BaseApiResponse submitApproval(String bookingId,String checkinDate,String checkoutDate,String userId,HttpServletRequest request) throws Exception { BaseApiResponse response = new BaseApiResponse<>(); - SysLogBooking sysLogBooking = new SysLogBooking(); - ArrayList addList = new ArrayList(); + + ArrayList addList = new ArrayList<>(); Gson gson = new Gson(); CfgApprovalRouting approvalRouting = approvalRoutingDao.getByBookingId(Long.valueOf(bookingId)); LogUtil.info(ApprovalService.class,"Submitting Approval.UserId:"+userId+"BookingId"+bookingId @@ -720,7 +720,6 @@ public class ApprovalService { if (approvalRouting != null && isCurrentUserInApproverList(approvalRouting.getApproverId(), userId) && "AP".equals(approvalRouting.getBookingStatus())) { LogUtil.info(ApprovalService.class,"Submit Approval.UserId:"+userId); - System.out.println("Version = "+approvalRouting.getVersion()); //相同 处理approvalRouting记录 并调用 Call OWS createbooking approvalRouting.setBookingStatus("AA"); CfgApprovalRouting changeRecord = approvalRoutingDao.save(approvalRouting); @@ -755,7 +754,7 @@ public class ApprovalService { } Date creatdDate = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"); - Bookings originBooking = bookingDao.getById(approvalRouting.getBookingId()); + Bookings originBooking = bookingDao.findById(approvalRouting.getBookingId()).orElse(null); originBooking.setApproveStatus("AA"); originBooking.setApprovedAt(now); originBooking.setApprovedBy(userName); @@ -763,7 +762,7 @@ public class ApprovalService { originBooking.setApprovedId(Long.valueOf(userId)); } if (!Strings.CS.equals(originBooking.getCheckinDate().toString(),checkinDate)){ - SysLogBooking newLogBooking = gson.fromJson(gson.toJson(sysLogBooking), SysLogBooking.class); + SysLogBooking newLogBooking = new SysLogBooking(); newLogBooking.setOccurTime(now); newLogBooking.setBookId(Long.valueOf(bookingId)); newLogBooking.setEventCode("Check In Date"); @@ -776,7 +775,7 @@ public class ApprovalService { originBooking.setCheckinDate(checkin); } if(!Strings.CS.equals(originBooking.getCheckoutDate().toString(),checkoutDate)){ - SysLogBooking newLogBooking = gson.fromJson(gson.toJson(sysLogBooking), SysLogBooking.class); + SysLogBooking newLogBooking = new SysLogBooking(); newLogBooking.setOccurTime(now); newLogBooking.setBookId(Long.valueOf(bookingId)); newLogBooking.setEventCode("Check Out Date"); @@ -790,8 +789,7 @@ public class ApprovalService { } BookingsView bookingView = bookingViewDao.findById(Long.parseLong(bookingId)); // 获取Property - CfgProperties properties = propertyDao.getById(originBooking.getPropertyId()); - + CfgProperties properties = propertyDao.findById(originBooking.getPropertyId()).orElse(null); Boolean isOverBook = this.checkIsOverbook(bookingView.getRoomId(), bookingView.getCheckinDate(), bookingView.getCheckoutDate(), bookingView.getPropertyId(), bookingView.getBlockId()); diff --git a/src/main/java/com/mgm/mcrm/appsetting/services/ConfigService.java b/src/main/java/com/mgm/mcrm/appsetting/services/ConfigService.java index c13ece2..37a6c59 100644 --- a/src/main/java/com/mgm/mcrm/appsetting/services/ConfigService.java +++ b/src/main/java/com/mgm/mcrm/appsetting/services/ConfigService.java @@ -216,7 +216,7 @@ public class ConfigService { Long bedTypeMasterGroupId = queryParas.getBedTypeId(); //check opera criteria or other criteria - CfgProperties property = propertyDao.getById(propertyId); + CfgProperties property = propertyDao.findById(propertyId).orElse(null); CfgRooms room = roomDao.findById(roomId).orElse(null); boolean isOpera = false; boolean isWaitlist = false; @@ -511,7 +511,7 @@ public class ConfigService { private Map checkCriteriaBooking(Map resultList,String playerId,String userId,String userName) throws Exception{ Date today = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd"); String maxDay = settingDao.getByKeys(SysConstants.MAX_ADVANCE_BOOKING_DAYS).getKeyValues(); - boolean enableProtection = Strings.CS.equals("1", settingDao.getByKeys(SysConstants.PROTECT_PERIOD_ENABLE).getKeyValues())?true:false; + boolean enableProtection = Strings.CS.equals("1", settingDao.getByKeys(SysConstants.PROTECT_PERIOD_ENABLE).getKeyValues()); String checkinProtection = settingDao.getByKeys(SysConstants.PROTECTION_PERIOD_CHECKIN).getKeyValues(); String checkoutProtection = settingDao.getByKeys(SysConstants.PROTECTION_PERIOD_CHECKOUT).getKeyValues(); Date endDate = DateTimeUtil.addDay(today, Integer.valueOf(maxDay)); diff --git a/src/main/java/com/mgm/mcrm/authorization/controllers/MobileLoginController.java b/src/main/java/com/mgm/mcrm/authorization/controllers/MobileLoginController.java index ab92c38..5fdabe5 100644 --- a/src/main/java/com/mgm/mcrm/authorization/controllers/MobileLoginController.java +++ b/src/main/java/com/mgm/mcrm/authorization/controllers/MobileLoginController.java @@ -323,11 +323,11 @@ public class MobileLoginController { String roomType = params.getRoomType(); String property = params.getProperty(); - if(!StringUtils.isEmpty(userId)) { + if(StringUtils.isNotEmpty(userId)) { userId = userId.replace("@mgm.mo", ""); } - if ((StringUtils.isEmpty(userId)&&StringUtils.isEmpty(userName))||StringUtils.isEmpty(roomType)||StringUtils.isEmpty(property)) { + if (StringUtils.isAnyEmpty(userId, userName, roomType, property)) { result.setSuccess(false); result.setMessage("Miss parameter"); return ResponseEntity.status(HttpStatus.OK).body(result); diff --git a/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightService.java b/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightService.java index 8cb0cf2..a710a13 100644 --- a/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightService.java +++ b/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightService.java @@ -88,7 +88,7 @@ public class DaylightService { @Resource private CompPresetDao compPresetDao; - @Value("${mcrm.daylight-system-id}") + @Value("${daylight.system-id}") private String dlSystemId; public BaseApiResponse daylightUpsertReservationNew(ReservationRequestDTO requestDTO, String dlPropertyId) { @@ -1039,7 +1039,7 @@ public class DaylightService { // String currentDate = DateTimeUtil.getCurrentDate("yyyy-MM-dd"); - String url = "/api-gateway/aggregator/v1/reservations?pageNumber=1&pageSize=50&filter=profileId==" + profileId + String url = "/api-gateway/aggregator/v1/reservations?pageNumber=1&pageSize=40&filter=profileId==" + profileId + ";(statusCode.code==DI,statusCode.code==RS,statusCode.code==DO,statusCode.code==IH,statusCode.code==CX)" // + ";departureDate=ge=" + currentDate + "&extend=PurchaseElements,CustomFields,Breakdown,DoorKeys&sort=-createdAt"; @@ -1056,7 +1056,7 @@ public class DaylightService { .ac_property_id(dlPropertyId) .build(); log.info("[getBookingRecordByProfileId_Optimize] Querying property dlPropertyId={}", dlPropertyId); - String responseData = httpService.sslGetNoLog(url, headers, map); + String responseData = httpService.sslGet(url, headers, map); JSONObject res = JSON.parseObject(responseData); JSONArray bookings = res.getJSONArray("results"); log.info("[getBookingRecordByProfileId_Optimize] Property dlPropertyId={}, bookings array size={}", dlPropertyId, bookings != null ? bookings.size() : 0); @@ -1137,6 +1137,9 @@ public class DaylightService { booking.setLastOperaStatus(EnumBookingStatus.getStatusByDaylightStatus(sc.getString("description").toUpperCase())); + String approveStatus = "CANCELED".equalsIgnoreCase(booking.getLastOperaStatus()) ? "C" : "N"; + booking.setApproveStatus(approveStatus); + JSONObject embedded = bookingRes.getJSONObject("_embedded"); if (embedded == null) { log.warn("[convertBookingDtoList] _embedded is null for reservation id={}, confirmationNo={}, dlPropertyId={}", diff --git a/src/main/java/com/mgm/mcrm/basesetting/property/repositories/PropertyDao.java b/src/main/java/com/mgm/mcrm/basesetting/property/repositories/PropertyDao.java index 2b8e6be..dffd981 100644 --- a/src/main/java/com/mgm/mcrm/basesetting/property/repositories/PropertyDao.java +++ b/src/main/java/com/mgm/mcrm/basesetting/property/repositories/PropertyDao.java @@ -14,8 +14,6 @@ import java.util.Collection; import java.util.List; public interface PropertyDao extends JpaRepository { - @Query(value="select * from cfg_properties with (nolock) where id=?1",nativeQuery=true) - CfgProperties getById(long id); @Query(value="select * from cfg_properties with (nolock) where name=?1",nativeQuery=true) CfgProperties getByName(String name); diff --git a/src/main/java/com/mgm/mcrm/booking/models/CfgCompRule.java b/src/main/java/com/mgm/mcrm/booking/models/CfgCompRule.java new file mode 100644 index 0000000..b84b9f1 --- /dev/null +++ b/src/main/java/com/mgm/mcrm/booking/models/CfgCompRule.java @@ -0,0 +1,42 @@ +package com.mgm.mcrm.booking.models; + +import jakarta.persistence.*; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +@Data +@Entity +@Table(name = "cfg_comp_rule") +public class CfgCompRule implements Serializable { + + @Id + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "dl_reservation_id") + private String dlReservationId; + + @Column(name = "comp_rule_id", nullable = false, unique = true) + private String compRuleId; + + @Column(name = "account_id") + private String accountId; + + @Column(name = "is_send_soft_limit", nullable = false) + private Integer isSendSoftLimit = 0; + + @Column(name = "is_send_total_limit", nullable = false) + private Integer isSendTotalLimit = 0; + + @Column(name = "created_at") + private Date createdAt; + + @Column(name = "updated_at") + private Date updatedAt; + + @Column(name = "category") + private Integer category; +} \ No newline at end of file diff --git a/src/main/java/com/mgm/mcrm/booking/repositories/CfgCompRuleDao.java b/src/main/java/com/mgm/mcrm/booking/repositories/CfgCompRuleDao.java new file mode 100644 index 0000000..1a5e68b --- /dev/null +++ b/src/main/java/com/mgm/mcrm/booking/repositories/CfgCompRuleDao.java @@ -0,0 +1,7 @@ +package com.mgm.mcrm.booking.repositories; + +import com.mgm.mcrm.booking.models.CfgCompRule; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface CfgCompRuleDao extends JpaRepository { +} diff --git a/src/main/java/com/mgm/mcrm/booking/services/BookingService.java b/src/main/java/com/mgm/mcrm/booking/services/BookingService.java index 140d133..de04ca5 100644 --- a/src/main/java/com/mgm/mcrm/booking/services/BookingService.java +++ b/src/main/java/com/mgm/mcrm/booking/services/BookingService.java @@ -44,6 +44,7 @@ import com.mgm.mcrm.booking.models.*; import com.mgm.mcrm.booking.repositories.BookingDao; import com.mgm.mcrm.booking.repositories.BookingTypeDao; import com.mgm.mcrm.booking.repositories.BookingViewDao; +import com.mgm.mcrm.booking.repositories.CfgCompRuleDao; import com.mgm.mcrm.common.constants.SysCommon; import com.mgm.mcrm.common.constants.SysConstants; import com.mgm.mcrm.common.dtos.BaseApiResponse; @@ -170,11 +171,13 @@ public class BookingService { private SysGroupPermissionService sysGroupPermissionService; @Resource private BookingTypeDao bookingTypeDao; + @Resource + private CfgCompRuleDao cfgCompRuleDao; @Autowired private BookingMapper bookingMapper; - @Value("${mcrm.daylight-system-id}") + @Value("${daylight.system-id}") private String daylightSystemId; @Resource @@ -208,7 +211,7 @@ public class BookingService { HttpServletRequest request, UserInfoApiRecord userInfo ) throws Exception { - CfgProperties property = propertyDao.getById(param.getPropertyId()); + CfgProperties property = propertyDao.findById(param.getPropertyId()).orElse(null); return otherBookingService.createOtherBooking(param, request, userInfo, property); } @@ -243,7 +246,7 @@ public class BookingService { Integer depositType = param.getDepositType(); Integer isPost = param.getIsPost(); Long roomTypeId = null; - CfgProperties property = propertyDao.getById(propertyId); + CfgProperties property = propertyDao.findById(propertyId).orElse(null); String miscCharge = param.getMiscCharge(); String etaTime = param.getEtaTime(); String sectionName = param.getSectionName(); @@ -494,9 +497,9 @@ public class BookingService { BaseApiResponse approver = approvalService.getApprover(request, approverRequest); List returnData = approver.getData().getRecords(); LogUtil.info(BookingService.class, "RoutingReason Befor:" + routingReason); - if (StringUtils.isEmpty(routingReason)) { - routingReason = approver.getData().getStatusDescription(); - } +// if (StringUtils.isEmpty(routingReason)) { +// routingReason = approver.getData().getStatusDescription(); +// } LogUtil.info(BookingService.class, "RoutingReason After:" + routingReason); } @@ -583,7 +586,7 @@ public class BookingService { Long roomTypeId; String sectionName = param.getSectionName(); - CfgProperties property = propertyDao.getById(propertyId); + CfgProperties property = propertyDao.findById(propertyId).orElse(null); if (property == null) { JSONObject exption = new JSONObject(); @@ -865,9 +868,9 @@ public class BookingService { BaseApiResponse approver = approvalService.getApprover(request, approverRequest); List returnData = approver.getData().getRecords(); LogUtil.info(BookingService.class, "RoutingReason Befor:" + routingReason); - if (StringUtils.isEmpty(routingReason)) { - routingReason = approver.getData().getStatusDescription(); - } +// if (StringUtils.isEmpty(routingReason)) { +// routingReason = approver.getData().getStatusDescription(); +// } LogUtil.info(BookingService.class, "RoutingReason After:" + routingReason); } @@ -912,38 +915,38 @@ public class BookingService { return result; } - public BaseApiResponse> callDaylightUpsertReservation(Bookings bookings, String type) throws Exception { + public BaseApiResponse> callDaylightUpsertReservation(Bookings booking, String type) throws Exception { BaseApiResponse> processResult = new BaseApiResponse<>(); ReservationRequestDTO reservationRequestDTO = - this.buildUpsertReservationRequest(bookings); + this.buildUpsertReservationRequest(booking); ReservationDTO reservationDTO = new ReservationDTO(); reservationDTO.setRefId("res_1"); - List result = bookingMapper.convertJsonToDateList(bookings.getDateList()); - String userId = bookings.getCreatedBy(); - Long roomTypeId = bookings.getRoomTypeId(); - CfgProperties property = propertyDao.getById(bookings.getPropertyId()); + List result = bookingMapper.convertJsonToDateList(booking.getDateList()); + String userId = booking.getCreatedBy(); + Long roomTypeId = booking.getRoomTypeId(); + CfgProperties property = propertyDao.findById(booking.getPropertyId()).orElse(null); - Long bookingTypeId = bookings.getBookingTypeId(); + Long bookingTypeId = booking.getBookingTypeId(); CfgBookingTypes bookingType = bookingTypeDao.findById(bookingTypeId).orElse(null); String bookingTypeName = bookingType.getName(); - CfgBlockCodes blockCodeById = blockCodeDao.findById(bookings.getBlockId()).orElse(null); + CfgBlockCodes blockCodeById = blockCodeDao.findById(booking.getBlockId()).orElse(null); // if (blockCodeById == null) { -// bookings.setApproveStatus("F"); -// bookings.setErrorMessage("Block code not found"); -// bookings.setTryTime(5); -// bookingDao.save(bookings); +// booking.setApproveStatus("F"); +// booking.setErrorMessage("Block code not found"); +// booking.setTryTime(5); +// bookingDao.save(booking); // processResult.setSuccess(false); // processResult.setMessage("[BookingService][createBooking]BlockCode not found."); // return processResult; // } reservationDTO.setBlockId(blockCodeById.getDlBlockId()); - List resultBookings = new ArrayList<>(); +// List resultBookings = new ArrayList<>(); BookingDateEntry dateEntry = result.getFirst(); @@ -953,10 +956,10 @@ public class BookingService { Integer depositTypeIM = dateEntry.getDepositType(); // if (!submitTag) { -// bookings.setApproveStatus("F"); -// bookings.setErrorMessage("Submit is false"); -// bookings.setTryTime(5); -// bookingDao.save(bookings); +// booking.setApproveStatus("F"); +// booking.setErrorMessage("Submit is false"); +// booking.setTryTime(5); +// bookingDao.save(booking); // processResult.setSuccess(false); // processResult.setMessage("[BookingService][callDaylightCreateReservationNew]SubmitTag is false"); // processResult.setData(resultBookings); @@ -974,8 +977,8 @@ public class BookingService { reservationDTO.setDepartureDate(checkoutDateStr); List preferences = new ArrayList<>(); - if (bookings.getFeatureCode() != null) { - String[] list = bookings.getFeatureCode().split(","); + if (booking.getFeatureCode() != null) { + String[] list = booking.getFeatureCode().split(","); for (String code : list) { ReservationDTO.PreferenceDTO pref = new ReservationDTO.PreferenceDTO(); CfgRoomFeatures roomFeatures = roomFeatureDao.getByDaylightCode(code); @@ -990,9 +993,9 @@ public class BookingService { List guaranteeTypeResult = dlService.dayLightGetGuaranteeType(property.getDlPropertyId()); if (CollectionUtils.isEmpty(guaranteeTypeResult)) { - bookings.setApproveStatus("F"); - bookings.setErrorMessage("Guarantee type not found."); - bookingDao.save(bookings); + booking.setApproveStatus("F"); + booking.setErrorMessage("Guarantee type not found."); + bookingDao.save(booking); processResult.setSuccess(false); processResult.setMessage("Guarantee Type not found"); return processResult; @@ -1001,14 +1004,14 @@ public class BookingService { for (GuaranteeTypeResponse guaranteeType : guaranteeTypeResult) { if ("CGTD".equalsIgnoreCase(guaranteeType.getCode())) { guaranteeTypeId = guaranteeType.getId(); - bookings.setDlGuaranteeTypeId(guaranteeTypeId); + booking.setDlGuaranteeTypeId(guaranteeTypeId); break; } } if (StringUtils.isBlank(guaranteeTypeId)) { guaranteeTypeId = guaranteeTypeResult.getFirst().getId(); - bookings.setDlGuaranteeTypeId(guaranteeTypeId); + booking.setDlGuaranteeTypeId(guaranteeTypeId); } reservationDTO.setGuaranteeTypeId(guaranteeTypeId); @@ -1017,9 +1020,9 @@ public class BookingService { List channelResult = dlService.dayLightGetDistributeChannel(property.getDlPropertyId()); if (CollectionUtils.isEmpty(channelResult)) { - bookings.setApproveStatus("F"); - bookings.setErrorMessage("Channel not found"); - bookingDao.save(bookings); + booking.setApproveStatus("F"); + booking.setErrorMessage("Channel not found"); + bookingDao.save(booking); processResult.setSuccess(false); processResult.setMessage("Channel not found"); return processResult; @@ -1029,30 +1032,30 @@ public class BookingService { for (DistributionChannelResponse distributionChannel : channelResult) { if ("MCRM".equalsIgnoreCase(distributionChannel.getCode())) { channelId = distributionChannel.getId(); - bookings.setDlChannelId(channelId); + booking.setDlChannelId(channelId); break; } } if (StringUtils.isBlank(channelId)) { channelId = channelResult.getFirst().getId(); - bookings.setDlChannelId(channelId); + booking.setDlChannelId(channelId); } } reservationDTO.setChannelId(channelId); List daylightViewList = daylightViewDao.findBySectionPropertyBookingTypeRoomType( - bookings.getSectionId(), - bookings.getPropertyId(), - bookings.getBookingTypeId(), + booking.getSectionId(), + booking.getPropertyId(), + booking.getBookingTypeId(), roomTypeId ); // if (CollectionUtils.isEmpty(daylightViewList)) { -// bookings.setApproveStatus("F"); -// bookings.setErrorMessage("Daylight view not found"); -// bookingDao.save(bookings); +// booking.setApproveStatus("F"); +// booking.setErrorMessage("Daylight view not found"); +// bookingDao.save(booking); // log.warn("Not Found DaylightView, sectionId={}, propertyId={}, bookingTypeId={}, roomTypeId={}", -// bookings.getSectionId(), bookings.getPropertyId(), bookings.getBookingTypeId(), roomTypeId); +// booking.getSectionId(), booking.getPropertyId(), booking.getBookingTypeId(), roomTypeId); // processResult.setSuccess(false); // processResult.setMessage("Not Found DaylightView"); // processResult.setData(resultBookings); @@ -1063,19 +1066,19 @@ public class BookingService { CfgRateCodes rateCode = rateCodeDao.findById(daylightView.getRateCodeId()).orElse(null); // if (rateCode == null) { -// bookings.setApproveStatus("F"); -// bookings.setErrorMessage("Rate Code not found"); -// bookingDao.save(bookings); +// booking.setApproveStatus("F"); +// booking.setErrorMessage("Rate Code not found"); +// bookingDao.save(booking); // processResult.setSuccess(false); // processResult.setMessage("Not Found Rate Code"); // return processResult; // } - bookings.setRatePlanCode(rateCode.getCode()); + booking.setRatePlanCode(rateCode.getCode()); - PlayerProfileEntry memberItem = bookingMapper.convertJsonToMember(bookings.getMember()); + PlayerProfileEntry memberItem = bookingMapper.convertJsonToMember(booking.getMember()); BaseApiResponse> profileListResponse = - dlService.dayLightGetProfileByPlayerId(bookings.getPlayerId()); + dlService.dayLightGetProfileByPlayerId(booking.getPlayerId()); ProfileDetailResponse profileDetailResponse; ProfileMemberships profileMemberships; @@ -1085,7 +1088,7 @@ public class BookingService { if (CollectionUtils.isNotEmpty(profileListResponse.getData())) { profileDetailResponse = profileListResponse.getData().getFirst(); - bookings.setDlProfileId(profileDetailResponse.getId()); + booking.setDlProfileId(profileDetailResponse.getId()); profileMemberships = profileDetailResponse.getMemberships().getFirst(); ReservationMembershipDTO rmDto = new ReservationMembershipDTO(); @@ -1101,7 +1104,7 @@ public class BookingService { // 并set 一个 embedded 进去 } else { IndividualDTO guestIndividual = IndividualDTO.buildNewProfileWithPlayerId( - bookings.getPlayerId(), + booking.getPlayerId(), memberItem.getName(), "gusmem_1", "gus_1", @@ -1141,12 +1144,12 @@ public class BookingService { if (byDaylightTier != null && byDaylightTier.getId() != null) { byTierIdAndRoomIdAndPropertyId = itemDao.findByTierIdAndRoomIdAndPropertyId( byDaylightTier.getId(), - bookings.getRoomId(), - bookings.getPropertyId() + booking.getRoomId(), + booking.getPropertyId() ); } if (byTierIdAndRoomIdAndPropertyId != null && byTierIdAndRoomIdAndPropertyId.getDlPurchaseElementId() != null) { - bookings.setDlPurchaseElementId(byTierIdAndRoomIdAndPropertyId.getDlPurchaseElementId()); + booking.setDlPurchaseElementId(byTierIdAndRoomIdAndPropertyId.getDlPurchaseElementId()); PurchaseElementsWithInventoryItemsDTO.PurchaseElementDTO.PurchaseBreakdownDTO purchaseBreakdownDTO = new PurchaseElementsWithInventoryItemsDTO.PurchaseElementDTO.PurchaseBreakdownDTO(); @@ -1157,8 +1160,10 @@ public class BookingService { PurchaseElementsWithInventoryItemsDTO purchaseElementsWithInventoryItemsDTO = new PurchaseElementsWithInventoryItemsDTO(); + String nextDateFromCheckInStr = DateTimeUtil.getDateByFormatPlusOneDay(checkinDate, "yyyy-MM-dd"); + purchaseBreakdownDTO.setFrom(checkinDateStr); - purchaseBreakdownDTO.setTo(checkinDateStr); + purchaseBreakdownDTO.setTo(nextDateFromCheckInStr); purchaseBreakdownDTO.setGuestCount(1); purchaseBreakdownDTO.setQuantity(1); @@ -1171,7 +1176,7 @@ public class BookingService { reservationDTO.setPurchaseElementsWithInventoryItems(purchaseElementsWithInventoryItemsDTO); } - String etaTime = bookings.getEta(); + String etaTime = booking.getEta(); if (StringUtils.isNotBlank(etaTime)) { String[] splitETATime = etaTime.split(":"); @@ -1188,11 +1193,11 @@ public class BookingService { } } - CfgRoomTypes roomType = roomTypeDao.findById(bookings.getRoomTypeId()).orElse(null); + CfgRoomTypes roomType = roomTypeDao.findById(booking.getRoomTypeId()).orElse(null); // if (roomType == null) { -// bookings.setApproveStatus("F"); -// bookings.setErrorMessage("Room Type not found"); -// bookingDao.save(bookings); +// booking.setApproveStatus("F"); +// booking.setErrorMessage("Room Type not found"); +// bookingDao.save(booking); // processResult.setSuccess(false); // processResult.setMessage("Room Type not found"); // return processResult; @@ -1204,33 +1209,33 @@ public class BookingService { CfgSourceCodes sourceCode = sourceCodeDao.findById(daylightView.getSourceCodeId()).orElse(null); // if (sourceCode == null) { -// bookings.setApproveStatus("F"); -// bookings.setErrorMessage("Source code not found"); -// bookingDao.save(bookings); +// booking.setApproveStatus("F"); +// booking.setErrorMessage("Source code not found"); +// bookingDao.save(booking); // processResult.setSuccess(false); // processResult.setMessage("Source code not found"); // return processResult; // } reservationDTO.setSourceId(sourceCode.getDlSourceId()); - bookings.setDlSourceId(sourceCode.getDlSourceId()); + booking.setDlSourceId(sourceCode.getDlSourceId()); if ("IM".equalsIgnoreCase(bookingTypeName) && isPostIM == 0) { reservationDTO.setNoPost(true); } else { - reservationDTO.setNoPost(StringUtils.isBlank(bookings.getMiscCharge())); + reservationDTO.setNoPost(StringUtils.isBlank(booking.getMiscCharge())); } CfgMarketCodes marketCode = marketCodeDao.findById(daylightView.getMarketCodeId()).orElse(null); // if (marketCode == null) { -// bookings.setApproveStatus("F"); -// bookings.setErrorMessage("Market code not found"); -// bookingDao.save(bookings); +// booking.setApproveStatus("F"); +// booking.setErrorMessage("Market code not found"); +// bookingDao.save(booking); // processResult.setSuccess(false); // processResult.setMessage("marketCode not found"); // return processResult; // } - bookings.setMarketCode(marketCode.getCode()); + booking.setMarketCode(marketCode.getCode()); ReservationDTO.BreakdownDTO breakdownDTO = new ReservationDTO.BreakdownDTO(); breakdownDTO.setFromDate(checkinDateStr); @@ -1261,12 +1266,12 @@ public class BookingService { customFields.put("WAIVEDEPOSIT", true); } - if (bookings.getWaitlistId() != null) { + if (booking.getWaitlistId() != null) { customFields.put("App_Rea", "APP"); - customFields.put("Approver", bookings.getApprovedBy()); + customFields.put("Approver", booking.getApprovedBy()); } - String sharerString = bookings.getSharer(); + String sharerString = booking.getSharer(); JSONArray sharers = JSONArray.parseArray(sharerString); if (CollectionUtils.isNotEmpty(sharers)) { @@ -1362,26 +1367,26 @@ public class BookingService { String operaComment; String stayDateForOpera = DateTimeUtil.formatOperaCommentStayDateRange( - checkinDate, checkoutDate, bookings.getNumOfNight()); + checkinDate, checkoutDate, booking.getNumOfNight()); if ("CREATE_BOOKING".equalsIgnoreCase(type)) { if ("IM".equalsIgnoreCase(bookingTypeName)) { - operaComment = buildIMComment(bookings); + operaComment = buildIMComment(booking); } else { - String miscCharge = bookings.getMiscCharge(); + String miscCharge = booking.getMiscCharge(); // 生成给 OPERA 的 comment:根据 miscCharge 是否为空决定是否包含 INC.CHRG$ 相关信息 if (miscCharge == null || miscCharge.trim().isEmpty()) { operaComment = "(RM)COMP ..APP\n\n"+ stayDateForOpera+",OD,"+userId; } else { // 这里 *** 替换为 miscCharge 的实际值 operaComment = "(RM+INC$" + miscCharge + ")COMP ..APP\n\n" - + "INC.CHRG$" + miscCharge + "COMP BY "+bookings.getBooker()+" ..APP\n" + + "INC.CHRG$" + miscCharge + "COMP BY "+booking.getBooker()+" ..APP\n" + stayDateForOpera+",OD,"+userId; } } - bookings.setOperaComment(operaComment); + booking.setOperaComment(operaComment); ReservationDTO.ReservationEmbeddedDTO.NoteDTO noteDto = new ReservationDTO.ReservationEmbeddedDTO.NoteDTO(); @@ -1389,7 +1394,7 @@ public class BookingService { new ReservationDTO.ReservationEmbeddedDTO(); noteDto.setRefId("not_1"); - noteDto.setTypeCode("RES"); + noteDto.setTypeCode("CAS"); noteDto.setContent(operaComment); reservationEmbeddedDTO.setNotes(List.of(noteDto)); @@ -1397,30 +1402,32 @@ public class BookingService { reservationDTO.setEmbedded(reservationEmbeddedDTO); } - bookingDao.save(bookings); + bookingDao.save(booking); reservationRequestDTO.setReservations(List.of(reservationDTO)); - if ("CREATE_BOOKING".equalsIgnoreCase(type) && !bookings.getApproveStatus().contains("W")) { + if ("CREATE_BOOKING".equalsIgnoreCase(type) && !booking.getApproveStatus().contains("W")) { BaseApiResponse createResponse = dlService.daylightUpsertReservationNew(reservationRequestDTO, property.getDlPropertyId()); if (!createResponse.isSuccess()) { - Integer trytime = bookings.getTryTime()==null?0:(bookings.getTryTime()+1); - bookings.setApproveStatus("F"); - bookings.setTryTime(trytime); - bookings.setErrorMessage(createResponse.getMessage()); - bookings.setFailedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); - bookings.setProcessStatus(0); + Integer trytime = booking.getTryTime()==null?0:(booking.getTryTime()+1); + booking.setApproveStatus("F"); + booking.setTryTime(trytime); + booking.setErrorMessage(createResponse.getMessage()); + booking.setFailedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); + booking.setProcessStatus(0); - bookingDao.save(bookings); + bookingDao.save(booking); - if(bookings.getWaitlistId() != null) { - Bookings waitlistBooking = bookingDao.findById(bookings.getWaitlistId()).orElse(null); - waitlistBooking.setConfirmationNo(bookings.getConfirmationNo()); - waitlistBooking.setApproveStatus("WF"); - waitlistBooking.setUpdatedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); - bookingDao.save(waitlistBooking); + if(booking.getWaitlistId() != null) { + bookingDao.findById(booking.getWaitlistId()).ifPresent( + b -> { + b.setApproveStatus("WF"); + b.setUpdatedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); + bookingDao.save(b); + } + ); } processResult.setSuccess(false); @@ -1436,13 +1443,13 @@ public class BookingService { DaylightReservationResponse daylightReservationByDlId = dlService.getDaylightReservationByDlId(reservationId, property.getDlPropertyId()); -// bookings.setDlAccountId(daylightReservationByDlId.getAccountId()); -// bookings.setDlReservationId(reservationId); -// bookings.setConfirmationNo(confirmationNumber); -// bookings.setLastOperaStatus("RESERVED"); -// bookings.setApproveStatus("N"); + booking.setDlAccountId(daylightReservationByDlId.getAccountId()); +// booking.setDlReservationId(reservationId); +// booking.setConfirmationNo(confirmationNumber); +// booking.setLastOperaStatus("RESERVED"); +// booking.setApproveStatus("N"); // -// bookingDao.save(bookings); +// bookingDao.save(booking); dlService.createDaylightCompRule( daylightReservationByDlId.getAccountId(), @@ -1452,24 +1459,59 @@ public class BookingService { checkinDateStr, checkoutDateStr, daylightViewList, - bookings.getMiscCharge() + booking.getMiscCharge() ); + //TODO For CCJ 这里create Comp rule之后需要通过 AC ID 去拿到 Comp Rule ID然后将Comp Rule Id 插入到Comp rule表中 + //1.通过AC Id 拿到Comp rule ids 拿到compRuleIds 之后只需要复制给compRuleIds即可,后面逻辑已经写完 + List compRuleIds = new ArrayList<>(); + BaseApiResponse compRuleListResponse = + dlService.daylightGetCompRulesByAccount(property.getDlPropertyId(), daylightReservationByDlId.getAccountId()); + + if (compRuleListResponse.isSuccess()) { + + JSONArray compRules = compRuleListResponse.getData(); + + for (int i = 0; i < compRules.size(); i++) { + JSONObject compRule = compRules.getJSONObject(i); + + compRuleIds.add(compRule.getString("id")); + } + } + + //2.循环Comp rule ids 插入每一条comp rule + for (String compRuleId :compRuleIds){ + Date now = new Date(); + CfgCompRule cfgCompRule = new CfgCompRule(); + cfgCompRule.setCompRuleId(compRuleId); + cfgCompRule.setDlReservationId(reservationId); + cfgCompRule.setAccountId(daylightReservationByDlId.getAccountId()); + cfgCompRule.setCreatedAt(now); + + cfgCompRuleDao.save(cfgCompRule); + } + //Create Reservation 后处理WaitListBooking - if (bookings.getWaitlistId() != null) { - Bookings waitlistBooking = bookingDao.findById(bookings.getWaitlistId()).orElse(null); -// waitlistBooking.setConfirmationNo(bookings.getConfirmationNo()); - waitlistBooking.setApproveStatus("WF"); - waitlistBooking.setUpdatedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); - bookingDao.save(waitlistBooking); + if (booking.getWaitlistId() != null) { + bookingDao.findById(booking.getWaitlistId()).ifPresent( + b -> { + b.setConfirmationNo(confirmationNumber); + b.setApproveStatus("WF"); + b.setUpdatedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); + bookingDao.save(b); + } + ); } //update Approval Booking - if(bookings.getApprovalBookingId()!=null) { - Bookings approvalBooking = bookingDao.findById(Long.valueOf(bookings.getApprovalBookingId())).orElse(null); - approvalBooking.setConfirmationNo(bookings.getConfirmationNo()); - approvalBooking.setUpdatedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); - bookingDao.save(approvalBooking); + if (booking.getApprovalBookingId() != null) { + bookingDao.findById(Long.valueOf(booking.getApprovalBookingId())).ifPresent( + b -> { + b.setConfirmationNo(confirmationNumber); + b.setUpdatedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss")); + bookingDao.save(b); + } + ); } processResult.setSuccess(true); @@ -1516,7 +1558,7 @@ public class BookingService { bookingDao.save(bookings); } - CfgProperties byId = propertyDao.getById(bookings.getPropertyId()); + CfgProperties byId = propertyDao.findById(bookings.getPropertyId()).orElse(null); BaseApiResponse> listBaseApiResponse = dlService.daylightGetCancelReasonList(byId.getDlPropertyId()); @@ -1625,10 +1667,13 @@ public class BookingService { return daylightStatus; } - private String resolveDaylightExtendApproveStatus(boolean isWaitlist, Bookings booking) { - if (isWaitlist) { + private String resolveDaylightExtendApproveStatus(boolean isWaitlist,boolean isApproval, Bookings booking) { + if (isWaitlist&&!isApproval) { return "W"; } + if (isApproval) { + return "AP"; + } if (booking != null && "CHECKED_IN".equalsIgnoreCase(booking.getLastOperaStatus())) { return "N"; } @@ -1980,7 +2025,7 @@ public class BookingService { return response; } - private BaseApiResponse> editOperaOtherBooking(BookingDto param, HttpServletRequest request, PlayerProfileEntry player) { + private BaseApiResponse> editOperaOtherBooking(BookingDto param, HttpServletRequest request, PlayerProfileEntry player) throws Exception { BaseApiResponse> processResult = new BaseApiResponse<>(); Date createDate = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"); @@ -1995,6 +2040,12 @@ public class BookingService { BookingDateEntry extendDate = extendDateList.getFirst(); boolean isWaitlist = extendDate.getStatus() != null && extendDate.getStatus() == 1; + boolean isApproval = param.getIsApproval() != null && isWaitlist && param.getIsApproval() == 1; + String requestReason = param.getRequestReasonId()!=null?param.getRequestReasonId():null; + String routerToApprover = param.getRouterToApproverId()!=null?param.getRouterToApproverId():null; + String routerToApproverName = param.getRouterToApproverName()!=null?param.getRouterToApproverName():null; + String routingReason = param.getRoutingReason()!=null?param.getRoutingReason():null; + boolean submitTag = extendDate.isSubmit(); String bookingStatus = extendDate.getBookingStatus(); Date originCheckinDate = DateTimeUtil.getDateFromString( @@ -2015,7 +2066,7 @@ public class BookingService { } Bookings booking; - if (isWaitlist) { + if (isWaitlist || isApproval) { booking = new Bookings(); BeanUtils.copyProperties(originalBooking, booking, "id"); booking.setId(null); @@ -2039,10 +2090,19 @@ public class BookingService { EumnApprovalStatus.getApprovalStatusByDBValue( booking.getApproveStatus()); + String ApprovalStatus; + if(isApproval) { + ApprovalStatus = "AP"; + }else if(isWaitlist && !isApproval){ + ApprovalStatus = "W"; + }else{ + ApprovalStatus = "PN"; + } + booking.setRevisionOf(bookId); booking.setCheckinDate(originCheckinDate); booking.setCheckoutDate(checkoutDate); - booking.setApproveStatus(isWaitlist ? "W" : "PN"); + booking.setApproveStatus(ApprovalStatus); booking.setRemark(remark); booking.setBookType("1"); booking.setNumOfNight(Integer.valueOf(numOfNight)); @@ -2052,7 +2112,7 @@ public class BookingService { booking.setUpdatedBy(userId); booking.setCreatedAt(createDate); - if (isWaitlist) { + if (isWaitlist || isApproval) { booking.setCheckinDate(checkinDate); booking.setRevisionOf(null); } @@ -2151,6 +2211,27 @@ public class BookingService { processResult.setData(resultBookings); } + }else if (isApproval){ + booking.setCheckinDate( + originBook.getCheckoutDate() + ); + booking.setCheckoutDate( + DateTimeUtil.getDateFromString(param.getChangeCheckoutDate(),"yyyy-MM-dd")); + booking.setApprovalBookingId(String.valueOf(originBook.getId())); + booking.setOtherFollowUpStatusId(2L); + Bookings newBooking = bookingDao.save(booking); + ArrayList booksList = new ArrayList(); + booksList.add(booking); + resultBookings.add(newBooking); +// bookingDao.save(booking); + sysLogBookingService.saveLogBooking(booksList, request, "", "", "Create Extension Booking",""); + + if (booking.getId()!=null && isApproval){ + approvalService.createApprovalRouting(booking, routerToApprover, routerToApproverName, requestReason, routingReason); + } + + processResult.setSuccess(true); + processResult.setData(resultBookings); } else { booking.setWaitlistId(originBook.getId()); booking.setOtherFollowUpStatusId(2L); @@ -2190,6 +2271,12 @@ public class BookingService { List extendDateList = param.getExtendDate(); BookingDateEntry extendDate = extendDateList.getFirst(); boolean isWaitlist = extendDate.getStatus()!=null && extendDate.getStatus()==1; + boolean isApproval = param.getIsApproval() != null && isWaitlist && param.getIsApproval() == 1; + String requestReason = param.getRequestReasonId()!=null?param.getRequestReasonId():null; + String routerToApprover = param.getRouterToApproverId()!=null?param.getRouterToApproverId():null; + String routerToApproverName = param.getRouterToApproverName()!=null?param.getRouterToApproverName():null; + String routingReason = param.getRoutingReason()!=null?param.getRoutingReason():null; + boolean submitTag = extendDate.isSubmit(); String bookingStatus = extendDate.getBookingStatus(); Date originCheckinDate = DateTimeUtil.getDateFromString(String.valueOf(dateArr.getFirst()), "yyyy-MM-dd");; @@ -2207,7 +2294,7 @@ public class BookingService { } Bookings booking; - if (isWaitlist) { + if (isWaitlist||isApproval) { booking = new Bookings(); BeanUtils.copyProperties(originalBooking, booking, "id"); booking.setId(null); @@ -2217,7 +2304,7 @@ public class BookingService { booking.setCheckinDate(originCheckinDate); booking.setCheckoutDate(checkoutDate); - booking.setApproveStatus(resolveDaylightExtendApproveStatus(isWaitlist, booking)); + booking.setApproveStatus(resolveDaylightExtendApproveStatus(isWaitlist,isApproval, booking)); booking.setRemark(remark); booking.setBookType("1"); booking.setNumOfNight(Integer.valueOf(numOfNight)); @@ -2226,7 +2313,7 @@ public class BookingService { booking.setUpdatedAt(createDate); booking.setUpdatedBy(userId); booking.setCreatedAt(createDate); - if(isWaitlist) { + if(isWaitlist||isApproval) { booking.setCheckinDate(checkinDate); booking.setRevisionOf(null); } @@ -2280,7 +2367,27 @@ public class BookingService { processResult.setSuccess(false); processResult.setCode(result.getMessage()); } - } else if (isWaitlist) { + }else if (isApproval){ + booking.setCheckinDate( + originBook.getCheckoutDate() + ); + booking.setCheckoutDate( + DateTimeUtil.getDateFromString(param.getChangeCheckoutDate(),"yyyy-MM-dd")); + booking.setApprovalBookingId(String.valueOf(originBook.getId())); + booking.setOtherFollowUpStatusId(2L); + Bookings newBooking = bookingDao.save(booking); + ArrayList booksList = new ArrayList(); + booksList.add(booking); + resultBookings.add(newBooking); + sysLogBookingService.saveLogBooking(booksList, request, "", "", "Create Extension Booking",""); + + if (booking.getId()!=null && isApproval){ + approvalService.createApprovalRouting(booking, routerToApprover, routerToApproverName, requestReason, routingReason); + } + + processResult.setSuccess(true); + processResult.setData(resultBookings); + } else if (isWaitlist) { booking.setWaitlistId(originBook.getId()); booking.setOtherFollowUpStatusId(2L); booking.setCheckinDate(originBook.getCheckoutDate()); @@ -2322,7 +2429,7 @@ public class BookingService { extendDateList = param.getExtendDate(); BookingDateEntry extDateEntry = extendDateList.getFirst(); boolean isWaitlist = (extDateEntry.getStatus() != null && extDateEntry.getStatus() == 1); - booking.setApproveStatus(resolveDaylightExtendApproveStatus(isWaitlist, booking)); + booking.setApproveStatus(resolveDaylightExtendApproveStatus(isWaitlist,false, booking)); List extendDateListTemp = extDateEntry.getDate(); @@ -2431,7 +2538,7 @@ public class BookingService { Bookings newBooking = bookingDao.save(booking); resultBookings.add(newBooking); - CfgProperties property = propertyDao.getById(booking.getPropertyId()); + CfgProperties property = propertyDao.findById(booking.getPropertyId()).orElse(null); BaseApiResponse result = dlService.daylightChangeReservationByDlId(bookId, checkinDateStr, checkoutDateStr, property.getDlPropertyId()); @@ -3586,7 +3693,7 @@ public class BookingService { int res = bookingDao.deleteDuplicateBooking(booking.getId(),booking.getConfirmationNo()); //share booking - CfgProperties property = propertyDao.getById(booking.getPropertyId()); + CfgProperties property = propertyDao.findById(booking.getPropertyId()).orElse(null); //计算allotment this.processAllotment(viewBook.getRoomId(), viewBook.getCheckinDate(), viewBook.getCheckoutDate(), viewBook.getPropertyId(), viewBook.getBlockId()); @@ -3702,7 +3809,7 @@ public class BookingService { "[Reservation] New Booking " + createBookResponse.get("internal_id") + " made. PlayerId=" + booking.getPlayerId() + " username=" + booking.getCreatedBy()); - CfgProperties property = propertyDao.getById(booking.getPropertyId()); + CfgProperties property = propertyDao.findById(booking.getPropertyId()).orElse(null); GuestRequestsRequest cashCommentRequest = new GuestRequestsRequest(); JSONObject cashCommentResponse = new JSONObject(); cashCommentRequest.setActionType("ADD"); @@ -3882,7 +3989,7 @@ public class BookingService { "[Reservation] New Booking " + modifyBookingResponse.get("internal_id") + " made. PlayerId=" + booking.getPlayerId() + " username=" + booking.getCreatedBy()); - CfgProperties property = propertyDao.getById(booking.getPropertyId()); + CfgProperties property = propertyDao.findById(booking.getPropertyId()).orElse(null); GuestRequestsRequest cashCommentRequest = new GuestRequestsRequest(); JSONObject cashCommentResponse = new JSONObject(); cashCommentRequest.setActionType("ADD"); @@ -4754,7 +4861,11 @@ public class BookingService { // Daylight 的 RESERVED 是当前权威状态。原 booking(非 revision)若因直接延期被错误标记为 PN, // 搜索同步时应恢复为已确认的 N;真正的 pending revision 保持 PN。 - if ("RESERVED".equalsIgnoreCase(mergedDaylightStatus) + if ( + ("RESERVED".equalsIgnoreCase(mergedDaylightStatus) + || "CHECKED_IN".equalsIgnoreCase(mergedDaylightStatus) + || "DUE_IN".equalsIgnoreCase(mergedDaylightStatus) + ) && "PN".equalsIgnoreCase(daylightBooking.getApproveStatus()) && dbBooking.getRevisionOf() == null) { daylightBooking.setApproveStatus("N"); @@ -5022,7 +5133,7 @@ public class BookingService { List dbBookingViews = !dlExternalNos.isEmpty() ? bookingViewDao.findByDlExternalNoIn(dlExternalNos) : new ArrayList<>(); Map existDlExternalNoDbBookingMap = new HashMap<>(); for (BookingsView dbBooking : dbBookingViews) { - if (StringUtils.isNotBlank(dbBooking.getDlExternalNo())) { + if (StringUtils.isNotBlank(dbBooking.getDlExternalNo())&& dbBooking.getApproveStatus().equals("N")) { existDlExternalNoDbBookingMap.put(dbBooking.getDlExternalNo().trim(), dbBooking); } } @@ -5555,6 +5666,10 @@ public class BookingService { continue; // 找不到记录直接跳过当前循环 } + if ("PN".equalsIgnoreCase(currentBooking.getApproveStatus()) && "N".equalsIgnoreCase(mergedBooking.getApproveStatus())) { + currentBooking.setApproveStatus("N"); + } + if ("N".equalsIgnoreCase(currentBooking.getApproveStatus())) { insertCommentAndMiscChargeFromDaylight(mergeBookingDto); mergedBooking.setOperaComment(mergeBookingDto.getOperaComment()); @@ -5716,7 +5831,7 @@ public class BookingService { String miscChargeValue = miscCharge == null ? "" : miscCharge.trim(); // 2. 根据 Property 的 Category 区分 OPERA / DAYLIGHT 流程 - CfgProperties property = propertyDao.getById(bookings.getPropertyId()); + CfgProperties property = propertyDao.findById(bookings.getPropertyId()).orElse(null); if ("DAYLIGHT".equalsIgnoreCase(property.getCategory())) { // ==================== DAYLIGHT 流程 ==================== @@ -6060,11 +6175,12 @@ public class BookingService { LogUtil.info(BookingService.class, "OPERA misCharge modified. New Comment: " + newOperaComment); // 2. 同步修改 OperaComment - CfgProperties property = propertyDao.getById(bookings.getPropertyId()); + CfgProperties property = propertyDao.findById(bookings.getPropertyId()).orElse(null); GuestRequestsRequest cashCommentRequest = new GuestRequestsRequest(); cashCommentRequest.setProperty(property); cashCommentRequest.setComment(newOperaComment); cashCommentRequest.setConfirmationNo(bookings.getConfirmationNo()); + LogUtil.info(getClass(), "CommentId=" + bookings.getOperaCommentId() + ", CommentType=" + commentType); if (bookings.getOperaCommentId() != null) { cashCommentRequest.setActionType("UPDATE"); @@ -6077,13 +6193,13 @@ public class BookingService { cashCommentRequest.setCommentType("CASHIER"); } - LogUtil.info(BookingService.class, "Start opera change comment, Action Type: " + cashCommentRequest.getActionType()); + LogUtil.info(BookingService.class, "Start opera change comment, Action Type=" + cashCommentRequest.getActionType()); JSONObject cashCommentResponse = operaService.guestRequests(cashCommentRequest); LogUtil.info(BookingService.class, "End opera change comment"); if (cashCommentResponse != null && cashCommentResponse.get("commentId") != null) { Long newCommentId = cashCommentResponse.getLong("commentId"); - if (!Objects.isNull(newCommentId)) { + if (Objects.nonNull(newCommentId)) { bookings.setOperaCommentId(newCommentId); } } diff --git a/src/main/java/com/mgm/mcrm/booking/services/NonMGMBookingService.java b/src/main/java/com/mgm/mcrm/booking/services/NonMGMBookingService.java index 31eff52..95b4772 100644 --- a/src/main/java/com/mgm/mcrm/booking/services/NonMGMBookingService.java +++ b/src/main/java/com/mgm/mcrm/booking/services/NonMGMBookingService.java @@ -210,7 +210,7 @@ public class NonMGMBookingService { Date checkoutDate = DateTimeUtil.getDateFromString(String.valueOf(dateArr.getLast()), "yyyy-MM-dd"); String numOfNight = String.valueOf(dateItem.getNumOfNight()); String bookRemark = String.valueOf(dateItem.getRemark()); - if(!StringUtils.isEmpty(bookRemark)) booking.setRemark(bookRemark); + if(StringUtils.isNotEmpty(bookRemark)) booking.setRemark(bookRemark); String bookingStatus = dateItem.getBookingStatus(); @@ -251,9 +251,9 @@ public class NonMGMBookingService { BaseApiResponse approver = approvalService.getApprover(request, approverRequest); List returnData = approver.getData().getRecords(); LogUtil.info(BookingService.class, "RoutingReason Befor:" + routingReason); - if (StringUtils.isEmpty(routingReason)) { - routingReason = approver.getData().getStatusDescription(); - } +// if (StringUtils.isEmpty(routingReason)) { +// routingReason = approver.getData().getStatusDescription(); +// } LogUtil.info(BookingService.class, "RoutingReason After:" + routingReason); } diff --git a/src/main/java/com/mgm/mcrm/booking/services/OperaService.java b/src/main/java/com/mgm/mcrm/booking/services/OperaService.java index ec8044a..e238443 100644 --- a/src/main/java/com/mgm/mcrm/booking/services/OperaService.java +++ b/src/main/java/com/mgm/mcrm/booking/services/OperaService.java @@ -1113,9 +1113,9 @@ public class OperaService { return comment; } - public JSONObject modifyMiscCharge(ModifyBookingRequest obj)throws Exception{ + public JSONObject modifyMiscCharge(ModifyBookingRequest obj) throws Exception{ JSONObject booking = new JSONObject(); - Boolean owsLog = settingService.isDBDbugLog();; + Boolean owsLog = settingService.isDBDbugLog(); String returnStr = ""; long spanTime = 0; @@ -1134,23 +1134,23 @@ public class OperaService { sendSoapString = obj.getRequestMisChargeString(); Date startTime = new Date(); - Date endTime = new Date(); + returnStr = SOAPUtil.getWebServiceSOAP(SysCommon.apiConfig.getServerUrl_OWS() + "/OWS_WS_51/Reservation.asmx?wsdl", "http://webservices.micros.com/ows/5.1/Reservation.wsdl#ModifyBooking", sendSoapString); LogUtil.info(OperaService.class, "[OperaService modifyBooking URL:]" + SysCommon.apiConfig.getServerUrl_OWS() + "/OWS_WS_51/Reservation.asmx?wsdl http://webservices.micros.com/ows/5.1/Reservation.wsdl#ModifyBooking"); - endTime = new Date(); + Date endTime = new Date(); spanTime = DateTimeUtil.getTimeSpanSSS(startTime, endTime); if (StringUtils.isNotBlank(returnStr)) { SOAPMessage soapMessage = SOAPUtil.getSOAPMessageFromXMLString(returnStr); - String bodyContent = ""; + DOMSource source = new DOMSource( soapMessage.getSOAPBody().getElementsByTagName("ModifyBookingResponse").item(0)); StringWriter stringResult = new StringWriter(); TransformerFactory factory = TransformerFactory.newInstance(); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); factory.newTransformer().transform(source, new StreamResult(stringResult)); - bodyContent = XMLBuliderUtil.removeXmlPrefix(stringResult.toString(), new String[] { "r", "hc", "c" }); + String bodyContent = XMLBuliderUtil.removeXmlPrefix(stringResult.toString(), new String[] { "r", "hc", "c" }); ModifyBookingResponse resp = (ModifyBookingResponse) XMLBuliderUtil.toObject(ModifyBookingResponse.class, bodyContent); diff --git a/src/main/java/com/mgm/mcrm/booking/services/WaitlistBookingService.java b/src/main/java/com/mgm/mcrm/booking/services/WaitlistBookingService.java index 009c818..4ea16a6 100644 --- a/src/main/java/com/mgm/mcrm/booking/services/WaitlistBookingService.java +++ b/src/main/java/com/mgm/mcrm/booking/services/WaitlistBookingService.java @@ -386,7 +386,7 @@ public class WaitlistBookingService { boolean isOtherOverBook = this.checkOtherIsOverbook(originBooking.getRoomId(), originBooking.getCheckoutDate(), originBooking.getCheckinDate(), originBooking.getPropertyId(), originBooking.getSegmentId()); - CfgProperties newBookingProperty = propertyDao.getById(originBooking.getPropertyId()); + CfgProperties newBookingProperty = propertyDao.findById(originBooking.getPropertyId()).orElse(null); if (originBooking.getWaitlistId() != null) { if (Strings.CS.equals(newBookingProperty.getCategory(), "OTHER")) { //send email instead of sync other booking diff --git a/src/main/java/com/mgm/mcrm/common/services/HttpService.java b/src/main/java/com/mgm/mcrm/common/services/HttpService.java index 6dc02fa..a40bc3a 100644 --- a/src/main/java/com/mgm/mcrm/common/services/HttpService.java +++ b/src/main/java/com/mgm/mcrm/common/services/HttpService.java @@ -5,6 +5,7 @@ import com.mgm.mcrm.common.dtos.HttpResult; import com.mgm.mcrm.common.enums.HttpMethods; import com.mgm.mcrm.common.httpclient.HttpClientExecutor; import com.mgm.mcrm.common.httpclient.HttpRequestOptions; +import com.mgm.mcrm.notification.dtos.request.SendNotificationRequest; import jakarta.annotation.Resource; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; @@ -39,10 +40,13 @@ public class HttpService { @Value("${daylight.url}") private String daylightUrl; + @Value("${notification_proxy.url}") + private String notificationProxyUrl; + public String sslGet(String url, Header[] headers, Map map) throws Exception { // todo 在這裏需要把請求頭的信息插入到數據庫裏 - log.info("======sslGet======url:{}===========headers:{} =============== map:{}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(map)); + log.info("GET method, url={}, headers={}, map={}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(map)); // 使用 HttpConfig 配置 GET 请求(带参数) HttpRequestOptions getConfig = HttpRequestOptions.create() .url(daylightUrl + url) @@ -52,25 +56,7 @@ public class HttpService { .client(httpClient); String result = HttpClientExecutor.get(getConfig, headers); - log.info("====== GET request result:{}", result); - - return result; - } - - public String sslGetNoLog(String url, Header[] headers, Map map) throws Exception { - - // todo 在這裏需要把請求頭的信息插入到數據庫裏 - log.info("======sslGet======url:{}===========headers:{} =============== map:{}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(map)); - // 使用 HttpConfig 配置 GET 请求(带参数) - HttpRequestOptions getConfig = HttpRequestOptions.create() - .url(daylightUrl + url) - .timeout(requestConfig) - .map(map) - .encoding("utf-8") - .client(httpClient); - - String result = HttpClientExecutor.get(getConfig, headers); - log.info("====== GET request result size={}", result.length()); + log.info("GET request result size={}", result); return result; } @@ -78,7 +64,7 @@ public class HttpService { public HttpResult sslGetHttpResult(String url, Header[] headers, Map map) throws Exception { // todo 在這裏需要把請求頭的信息插入到數據庫裏 - log.info("======sslGet======url:{}===========headers:{} =============== map:{}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(map)); + log.info("GET method, url={}, headers={}, map={}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(map)); // 使用 HttpConfig 配置 GET 请求(带参数) HttpRequestOptions getConfig = HttpRequestOptions.create() .url(daylightUrl + url) @@ -88,7 +74,7 @@ public class HttpService { .client(httpClient); HttpResult result = HttpClientExecutor.sendAndGetResp(getConfig, headers); - log.info("====== GET request result:{}", result.getResult()); + log.info("GET request result size={}", result.getResult().length()); return result; } @@ -103,7 +89,7 @@ public class HttpService { * @throws Exception 異常 */ public String sslPut(String url, Header[] headers, Map map) throws Exception { - log.info("======sslPut======url:{}===========headers:{} =============== map:{}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(map)); + log.info("PUT method, url={}, headers={}, map={}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(map)); HttpRequestOptions putConfig = HttpRequestOptions.create() .url(daylightUrl + url) .timeout(requestConfig) @@ -112,7 +98,7 @@ public class HttpService { .encoding("utf-8") .client(httpClient); String result = HttpClientExecutor.send(putConfig, headers); - log.info("====== PUT request result:{}", result); + log.info("PUT request result={}", result); return result; } @@ -127,7 +113,7 @@ public class HttpService { * @throws Exception 異常 */ public String sslDelete(String url, Header[] headers, Object requestBody) throws Exception { - log.info("======sslDelete======url:{}===========headers:{} =============== map:{}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(requestBody)); + log.info("DELETE method, url={}, headers={}, map={}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(requestBody)); HttpRequestOptions deleteConfig = HttpRequestOptions.create() .url(daylightUrl + url) .timeout(requestConfig) @@ -135,7 +121,7 @@ public class HttpService { .method(HttpMethods.DELETE) .client(httpClient); String result = HttpClientExecutor.send(deleteConfig, headers); - log.info("====== DELETE request result:{}", result); + log.info("DELETE request result={}", result); return result; } @@ -149,7 +135,7 @@ public class HttpService { * @throws Exception 異常 */ public HttpResult sslPost(String url, Header[] headers, Object requestBody) throws Exception { - log.info("======sslCreatePost======url:{}===========headers:{}", daylightUrl + url, JSON.toJSONString(headers)); + log.info("POST method, url={}, headers={}, map={}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(requestBody)); HttpRequestOptions postConfig = HttpRequestOptions.create() .url(daylightUrl + url) .timeout(requestConfig) @@ -158,7 +144,7 @@ public class HttpService { .client(httpClient); HttpResult result = HttpClientExecutor.sendAndPostResp(postConfig, headers); // System.out.println("POST 请求结果:\n" + result); - log.info("====== POST request result:{}", result); + log.info("POST request result={}", result); return result; } @@ -172,7 +158,7 @@ public class HttpService { * @throws Exception 異常 */ public HttpResult sslPatch(String url, Header[] headers, Object requestBody) throws Exception { - log.info("======sslCreatePatch======url:{}===========headers:{}", daylightUrl + url, JSON.toJSONString(headers)); + log.info("PATCH method, url={}, headers={}, map={}", daylightUrl + url, JSON.toJSONString(headers), JSON.toJSONString(requestBody)); HttpRequestOptions patchConfig = HttpRequestOptions.create() .url(daylightUrl + url) .timeout(requestConfig) @@ -181,30 +167,20 @@ public class HttpService { .encoding("utf-8") .client(httpClient); HttpResult result = HttpClientExecutor.sendAndPatchResp(patchConfig, headers); - log.info("====== PATCH request result:{}", result); + log.info("PATCH request result={}", result); return result; } - /** - * 使用 HttpConfig 配置 Delete 请求 - * - * @param url 請求路徑 - * @param headers 請求頭 - * @param map Cancel数据 - * @return 接口結果的json數據 - * @throws Exception 異常 - */ - public HttpResult sslCancelPost(String url, Header[] headers, Map map) throws Exception { - log.info("======sslCancelPost======url:{}===========headers:{}", daylightUrl + url, JSON.toJSONString(headers)); + public HttpResult sslSendNotification(String url, Header[] headers, SendNotificationRequest request) throws Exception { + log.info("POST method, send notification, url={}, headers={}, map={}", notificationProxyUrl + url, JSON.toJSONString(headers), JSON.toJSONString(request)); HttpRequestOptions postConfig = HttpRequestOptions.create() - .url(daylightUrl + url) + .url(notificationProxyUrl + url) .timeout(requestConfig) - .json(JSON.toJSONString(map)) + .json(JSON.toJSONString(request)) .method(HttpMethods.POST) .client(httpClient); HttpResult result = HttpClientExecutor.sendAndPostResp(postConfig, headers); -// System.out.println("POST 请求结果:\n" + result); - log.info("====== POST request result:{}", result); + log.info("POST request result={}", result); return result; } } diff --git a/src/main/java/com/mgm/mcrm/common/utils/DateTimeUtil.java b/src/main/java/com/mgm/mcrm/common/utils/DateTimeUtil.java index 59595ef..86ae4ce 100644 --- a/src/main/java/com/mgm/mcrm/common/utils/DateTimeUtil.java +++ b/src/main/java/com/mgm/mcrm/common/utils/DateTimeUtil.java @@ -287,4 +287,21 @@ public class DateTimeUtil { } return returnDate; } + + public static String getDateByFormatPlusOneDay(Date dtDateTime, String strFormat) { + + if (dtDateTime == null) { + return null; + } + + try { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dtDateTime); + calendar.add(Calendar.DAY_OF_MONTH, 1); + + return new SimpleDateFormat(strFormat).format(calendar.getTime()); + } catch (Exception err) { + return null; + } + } } diff --git a/src/main/java/com/mgm/mcrm/notification/controllers/NotificationController.java b/src/main/java/com/mgm/mcrm/notification/controllers/NotificationController.java index ffb6a6a..b47350f 100644 --- a/src/main/java/com/mgm/mcrm/notification/controllers/NotificationController.java +++ b/src/main/java/com/mgm/mcrm/notification/controllers/NotificationController.java @@ -92,7 +92,7 @@ public class NotificationController { @Parameter(description = "Notification request info", required = true) @Valid @RequestBody SendNotificationRequest requestData) { LoginUserInfo requestUser = SysCommon.parseUserFromToken(request); if(requestUser!=null){ - BaseApiResponse responseData = notificationService.sendNotificationByRequest(requestData, requestUser.getLoginId()); + BaseApiResponse responseData = notificationService.sendNotificationByRequest(request,requestData); return ResponseEntity.status(HttpStatus.OK).body(responseData); }else{ return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(null); diff --git a/src/main/java/com/mgm/mcrm/notification/services/NotificationService.java b/src/main/java/com/mgm/mcrm/notification/services/NotificationService.java index e66b3be..31ea395 100644 --- a/src/main/java/com/mgm/mcrm/notification/services/NotificationService.java +++ b/src/main/java/com/mgm/mcrm/notification/services/NotificationService.java @@ -1,8 +1,14 @@ package com.mgm.mcrm.notification.services; +import com.alibaba.fastjson.JSON; import com.mgm.mcrm.authorization.models.SysRouterPermission; import com.mgm.mcrm.authorization.services.SysGroupPermissionService; +import com.mgm.mcrm.basesetting.daylight.dtos.response.ProfileDetailResponse; +import com.mgm.mcrm.basesetting.property.models.CfgProperties; import com.mgm.mcrm.common.dtos.BaseApiResponse; +import com.mgm.mcrm.common.dtos.HttpResult; +import com.mgm.mcrm.common.httpclient.HttpHeaderBuilder; +import com.mgm.mcrm.common.services.HttpService; import com.mgm.mcrm.common.utils.LogUtil; import com.mgm.mcrm.logging.models.SysLogDeviceToken; import com.mgm.mcrm.logging.repositories.SysLogDeviceTokenDao; @@ -13,28 +19,24 @@ import com.mgm.mcrm.notification.dtos.response.GetNotificationResponse; import com.mgm.mcrm.notification.models.SysLogNotification; import com.mgm.mcrm.notification.repositories.SysLogNotificationRepository; import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.hc.core5.http.Header; import org.springframework.stereotype.Service; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; +@Slf4j @Service public class NotificationService { @Resource private SysLogNotificationRepository sysLogNotificationRepository; - @Resource - private ApnNotificationService apnNotificationService; - @Resource - private SysLogDeviceTokenDao sysLogDeviceTokenDao; -// @Resource -// private ApprovalRoutingDao approvalRoutingDao; @Resource private SysGroupPermissionService sysGroupPermissionService; - + @Resource + private HttpService httpService; public GetNotificationResponse getNotificationByUserId(String userId){ GetNotificationResponse response = new GetNotificationResponse(); @@ -58,10 +60,6 @@ public class NotificationService { } } -// if (viewApprovalRouting) { -// response.setApprovalRoutingCount( approvalRoutingDao.countApprovalList(userId)); -// count+=approvalRoutingDao.countApprovalList(userId); -// } if (viewNotification) { response.setNotificationCount(sysLogNotificationRepository.countByUserIdAndStatus(userId, 0)); count+=sysLogNotificationRepository.countByUserIdAndStatus(userId, 0); @@ -98,104 +96,23 @@ public class NotificationService { } - public BaseApiResponse sendNotificationByRequest(SendNotificationRequest requestData, String senderId) { - BaseApiResponse result = new BaseApiResponse<>(); - String[] userIds = requestData.getEmployeeId().split("[;,]"); - String transactionId = requestData.getTransactionId(); - if(StringUtils.isBlank(transactionId)){ - transactionId = UUID.randomUUID().toString(); - } - result.setData(transactionId); - if(userIds.length>0){ - int successCount =0; - for(String userId:userIds){ - if(StringUtils.isNotBlank(userId)){ - userId = userId.trim(); - SysLogDeviceToken deviceToken = sysLogDeviceTokenDao.findByUserId(userId); - String deviceTokenValue =null; - if(deviceToken!=null){ - deviceTokenValue = deviceToken.getDeviceToken(); - } + public BaseApiResponse sendNotificationByRequest(HttpServletRequest request, SendNotificationRequest requestData) { + BaseApiResponse response = new BaseApiResponse<>(); - Integer useLanguage = deviceToken == null ? null : deviceToken.getUseLanguageType(); - String notificationTitle = resolveNotificationText(requestData.getTitle(), useLanguage); - String notificationContent = resolveNotificationText(requestData.getContent(), useLanguage); - - //这里需要加上判断,判断deviceToken中的UseLanguage是什么语言 0:英文 1:中文 根据不同的Language来推送不同语言的通知 - - SysLogNotification notificationLog = createNotificationLogByRequest(requestData,transactionId,senderId,userId,deviceTokenValue,notificationTitle,notificationContent); - if(StringUtils.isBlank(deviceTokenValue)){ - notificationLog.setStatus(-1); - notificationLog.setResultMessage("No APN token is setup for user:"+userId); - notificationLog.setUpdatedAt(LocalDateTime.now()); - } - sysLogNotificationRepository.save(notificationLog); - //-- Process APN sending - BaseApiResponse sendResult = apnNotificationService.pushApnMessage( - transactionId, - deviceTokenValue, - notificationTitle, - notificationContent, - true, - requestData.getConfirmationNumber()); - if(sendResult.isSuccess()){ - successCount++; - } - } - } - if(successCount>0){ - result.setSuccess(true); - }else{ - result.setSuccess(false); - result.setMessage("No message was success processed"); - } - }else{ - result.setSuccess(false); - result.setMessage("employeeId list is empty"); - } - return result; + try { + String url = "/send_notification"; + // 获取对应的值 + Header[] headers = HttpHeaderBuilder.custom() + .authorization(request.getHeader("Authorization")) + .contentType("application/json") + .build(); + HttpResult responseData = httpService.sslSendNotification(url, headers, requestData); + response.setSuccess(responseData.getStatusCode()==200); + response.setCode(String.valueOf(responseData.getStatusCode())); + } catch (Exception e) { + log.info("invoke api gateway send notification request failed, ERROR MSG:{}",e.getMessage()); + } + return response; } - private SysLogNotification createNotificationLogByRequest(SendNotificationRequest requestData,String transactionId, String senderId, String userId, String deviceToken, String title, String content){ - SysLogNotification notificationLog = new SysLogNotification(); - notificationLog.setUserId(userId); - notificationLog.setDeviceToken(deviceToken); - notificationLog.setSenderId(senderId); - notificationLog.setStatus(0); - notificationLog.setConfirmationNo(requestData.getConfirmationNumber()); - notificationLog.setBookingType(requestData.getType()); - notificationLog.setTitle(title); - notificationLog.setContent(content); - notificationLog.setTransactionId(transactionId); - notificationLog.setCreatedAt(LocalDateTime.now()); - return notificationLog; - } - - private static String resolveNotificationText(String text, Integer useLanguage) { - if (StringUtils.isBlank(text)) { - return text; - } - String preferredTag = Integer.valueOf(1).equals(useLanguage) ? "CN" : "EN"; - String fallbackTag = Integer.valueOf(1).equals(useLanguage) ? "EN" : "CN"; - String preferredText = extractNotificationText(text, preferredTag); - if (StringUtils.isNotBlank(preferredText)) { - return preferredText; - } - String fallbackText = extractNotificationText(text, fallbackTag); - return StringUtils.isNotBlank(fallbackText) ? fallbackText : text; - } - - private static String extractNotificationText(String text, String tag) { - String marker = "#" + tag + "#"; - int start = text.indexOf(marker); - if (start < 0) { - return null; - } - start += marker.length(); - int end = text.indexOf(marker, start); - if (end < 0) { - return null; - } - return text.substring(start, end).trim(); - } } diff --git a/src/main/java/com/mgm/mcrm/player/services/TodoService.java b/src/main/java/com/mgm/mcrm/player/services/TodoService.java index a37a649..6b78062 100644 --- a/src/main/java/com/mgm/mcrm/player/services/TodoService.java +++ b/src/main/java/com/mgm/mcrm/player/services/TodoService.java @@ -865,7 +865,7 @@ public class TodoService { JSONObject errors = new JSONObject(); if (!modifyBookingResponse.containsKey("message")) { String bookComment = operaService.makeChangeDateComment(booking); - CfgProperties property = propertyDao.getById(booking.getPropertyId()); + CfgProperties property = propertyDao.findById(booking.getPropertyId()).orElse(null); GuestRequestsRequest changeDateCommentRequest = new GuestRequestsRequest(); JSONObject changeDateCommentResponse = new JSONObject(); changeDateCommentRequest.setActionType("ADD"); diff --git a/src/main/java/com/mgm/mcrm/roomcalendar/services/CalendarMockData.java b/src/main/java/com/mgm/mcrm/roomcalendar/services/CalendarMockData.java index b2adb02..a25d63e 100644 --- a/src/main/java/com/mgm/mcrm/roomcalendar/services/CalendarMockData.java +++ b/src/main/java/com/mgm/mcrm/roomcalendar/services/CalendarMockData.java @@ -16,7 +16,7 @@ public final class CalendarMockData { private static GetPropertyRoomTypeResponse hotel(String code, String name, String... rooms) { var hotel = new GetPropertyRoomTypeResponse(); - hotel.setCode(code); hotel.setName(name + " [MOCK]"); hotel.setDisplayName(name + " [MOCK]"); + hotel.setCode(code); hotel.setName(name); hotel.setDisplayName(name); var types = new ArrayList(); for (int i=0; it.getCode()).toList()); var rows=CalendarMockData.records("",hotel.getCode(),rooms,"2026-09-28","2026-10-03"); assertEquals(hotel.getRoomTypes().size()*6,rows.size());