diff --git a/pom.xml b/pom.xml
index e347e1f..0c1164f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,14 +13,14 @@
org.springframework.boot
spring-boot-starter-parent
- 4.2.0-M1
+ 4.2.0-M2
UTF-8
21
- 11.0.25
+ 11.0.26
4.2.18.Final
5.6.4
5.2.3
@@ -29,6 +29,8 @@
2.22.3
3.2.3
2.26.1
+ 9.2.0.Beta1
+ 4.0.9
${java.version}
${java.version}
@@ -93,6 +95,11 @@
org.springframework.boot
spring-boot-starter-mail
+
+ jakarta.validation
+ jakarta.validation-api
+ 4.0.0-M1
+
org.springframework.boot
spring-boot-starter-validation
@@ -115,7 +122,6 @@
org.springframework.boot
spring-boot-starter-aop
4.0.0-M2
- compile
org.springframework.boot
@@ -195,7 +201,7 @@
com.auth0
java-jwt
- 4.5.0
+ 4.6.2
org.jsmpp
diff --git a/src/main/java/com/mgm/mcrm/TestRun.java b/src/main/java/com/mgm/mcrm/TestRun.java
index cd0701d..127824d 100644
--- a/src/main/java/com/mgm/mcrm/TestRun.java
+++ b/src/main/java/com/mgm/mcrm/TestRun.java
@@ -3,6 +3,21 @@ package com.mgm.mcrm;
public class TestRun {
public static void main(String[] args) {
-
+
+ Object[] arr = {"asdas", "null", 23, "asd", 's', 90L, 3.4F, 3.3};
+
+ System.out.println(nonNullAll(arr));
+
}
-}
\ No newline at end of file
+
+ static boolean nonNullAll(Object ...arr) {
+ if (arr == null) return false;
+
+ if (arr.length == 0) return false;
+
+ for (Object o : arr) {
+ if (o == null) return false;
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/com/mgm/mcrm/adfs/controllers/SSORestProcessController.java b/src/main/java/com/mgm/mcrm/adfs/controllers/SSORestProcessController.java
index c55d1d8..67805b7 100644
--- a/src/main/java/com/mgm/mcrm/adfs/controllers/SSORestProcessController.java
+++ b/src/main/java/com/mgm/mcrm/adfs/controllers/SSORestProcessController.java
@@ -2,6 +2,7 @@ package com.mgm.mcrm.adfs.controllers;
import com.mgm.mcrm.adfs.config.HttpClientContextRequestFactory;
import com.mgm.mcrm.common.constants.SysCommon;
+import com.mgm.mcrm.common.services.ConfigurableTrustHandler;
import com.mgm.mcrm.common.utils.AESUtil;
import com.mgm.mcrm.common.utils.LogUtil;
import com.mgm.mcrm.common.utils.NetworkUtil;
@@ -45,6 +46,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.HtmlUtils;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
import java.io.*;
import java.net.InetAddress;
import java.net.URI;
@@ -75,6 +77,8 @@ public class SSORestProcessController {
private String adfsDomain;
@Value("${adfs_secret_key}")
private String adfsSecretKey;
+ @Value("${adfs_skip_ssl_validation:true}")
+ private boolean skipSslValidation=true;
@Value("${adfs_request_timeout}")
private int adfsRequestTimeout=10000;
@@ -208,11 +212,15 @@ public class SSORestProcessController {
credentials = createNtlmCredentials(adUserName, password, adDomain, null);
credentialsProvider.setCredentials(authScope, credentials);
- SSLContext sslContext = SSLContexts.custom()
- .loadTrustMaterial((chain, authType) -> true) // 信任所有证书
- .build();
- NoopHostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
- DefaultClientTlsStrategy tlsStrategy = new DefaultClientTlsStrategy(sslContext, hostnameVerifier);
+ ConfigurableTrustHandler trustHandler = new ConfigurableTrustHandler(skipSslValidation, SysCommon.getDefaultTrustManager(), SysCommon.getHttpApiServers());
+
+ SSLContext sslContext = null;
+ try {
+ sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, new TrustManager[]{trustHandler}, null);
+ } catch (Exception ignored) {
+ }
+ DefaultClientTlsStrategy tlsStrategy = new DefaultClientTlsStrategy(sslContext, trustHandler);
PoolingHttpClientConnectionManager connectionManager =
PoolingHttpClientConnectionManagerBuilder.create()
.setTlsSocketStrategy(tlsStrategy)
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 001bb84..065e4f3 100644
--- a/src/main/java/com/mgm/mcrm/approval/service/ApprovalService.java
+++ b/src/main/java/com/mgm/mcrm/approval/service/ApprovalService.java
@@ -828,19 +828,46 @@ public class ApprovalService {
if ("DAYLIGHT".equalsIgnoreCase(bookingView.getPropertyCategory())) {
isOverBook = false;
} else {
- isOverBook = this.checkIsOverbook(bookingView.getRoomId(), bookingView.getCheckinDate(),
- bookingView.getCheckoutDate(), bookingView.getPropertyId(), bookingView.getBlockId());
+ isOverBook = this.checkIsOverbook(bookingView.getRoomId(), originBooking.getCheckinDate(),
+ originBooking.getCheckoutDate(), bookingView.getPropertyId(), bookingView.getBlockId());
}
Boolean isOtherOverBook = this.checkOtherIsOverbook(Math.toIntExact(originBooking.getRoomId()), originBooking.getCheckoutDate(),
originBooking.getCheckinDate(), originBooking.getPropertyId(), originBooking.getSegmentId());
+ if (bookingView != null) {
+ bookingView.setCheckinDate(originBooking.getCheckinDate());
+ bookingView.setCheckoutDate(originBooking.getCheckoutDate());
+ Integer numOfNight = Integer.valueOf(DateTimeUtil.getDiffDate(
+ bookingView.getCheckinDate(), bookingView.getCheckoutDate(), "day"));
+ List dates = new ArrayList<>();
+ List dateList = new ArrayList<>();
+ JSONObject obj = new JSONObject();
+ for (int j = 0; j < numOfNight + 1; j++) {
+ dates.add(DateTimeUtil.getDateByFormat(DateTimeUtil.addDay(bookingView.getCheckinDate(), j), "yyyy-MM-dd"));
+ }
+ obj.put("date", dates);
+ obj.put("numOfNight", numOfNight);
+ obj.put("numOfRoom", 1);
+ obj.put("checked", true);
+ dateList.add(obj);
+ bookingView.setDateList(dateList);
+ bookingView.setNumOfNight(numOfNight);
+ originBooking.setDateList(JSONArray.toJSONString(dateList));
+ originBooking.setNumOfNight(numOfNight);
+ bookingView.setApproveStatus(originBooking.getApproveStatus());
+ bookingView.setApprovedAt(originBooking.getApprovedAt());
+ bookingView.setApprovedBy(originBooking.getApprovedBy());
+ bookingView.setApprovedId(originBooking.getApprovedId());
+ }
+ bookingDao.saveAndFlush(originBooking);
+ LogUtil.info(ApprovalService.class,"Submitting Approval.BookingID:"+bookingId+"|Save CheckinDate = "+originBooking.getCheckinDate()+" Save CheckoutDate = "+originBooking.getCheckoutDate());
+
if (Strings.CS.equals(originBooking.getBookType(),"0")){
//create 的情况
LogUtil.info(ApprovalService.class,"Submitting Approval.BookingID:"+bookingId+"|bookingType:Create");
- bookingDao.save(originBooking);
- BookingsView originBookingView = bookingViewDao.findById(Long.parseLong(bookingId));
+ BookingsView originBookingView = bookingView;
originBookingView = this.getEmailInfo(originBookingView,originBookingView.getCreatedBy()).getData();
// 判断是OPETA或OTHER Property
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 4648e49..6b6b2f2 100644
--- a/src/main/java/com/mgm/mcrm/appsetting/services/ConfigService.java
+++ b/src/main/java/com/mgm/mcrm/appsetting/services/ConfigService.java
@@ -567,7 +567,7 @@ public class ConfigService {
while(checkInDate.getTime()=today.getTime()) {
resultList.put(getDate,newCalendarEntry(getDate));
}
if(resultList.containsKey(getDate)){
@@ -613,7 +613,7 @@ public class ConfigService {
}
for(Date period:protectionPeriod) {
String date = DateTimeUtil.getDateByFormat(period, "yyyy-MM-dd");
- if(checkMode==2&&!resultList.containsKey(date)) {
+ if(checkMode==2 && !resultList.containsKey(date) && period.getTime()>=today.getTime()) {
resultList.put(date,newCalendarEntry(date));
}
if(resultList.containsKey(date)){
diff --git a/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightApiService.java b/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightApiService.java
index 8c85f70..7317fcf 100644
--- a/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightApiService.java
+++ b/src/main/java/com/mgm/mcrm/basesetting/daylight/services/DaylightApiService.java
@@ -169,7 +169,7 @@ public class DaylightApiService {
}
}
- JSONObject jsonObject = this.daylightCallOperationUrl(operationUrl, dlPropertyId);
+ JSONObject jsonObject = this.daylightCallMultiOperationUrl(operationUrl, dlPropertyId);
if (jsonObject.isEmpty()) {
result.setSuccess(false);
@@ -502,9 +502,6 @@ public class DaylightApiService {
BaseApiResponse result = new BaseApiResponse<>();
try {
- if (CollectionUtils.isNotEmpty(dlSharerIds)) {
- daylightRemoveAccompanyingGuest(dlReservationId, dlPropertyId, dlSharerIds, version);
- }
String url = "/api-gateway/aggregator/v1/integrations/reservation/multiroom/cancel";
@@ -538,7 +535,7 @@ public class DaylightApiService {
}
}
- JSONObject jsonObject = this.daylightCallOperationUrl(operationUrl, dlPropertyId);
+ JSONObject jsonObject = this.daylightCallMultiOperationUrl(operationUrl, dlPropertyId);
if (jsonObject.isEmpty()) {
result.setSuccess(false);
@@ -585,7 +582,7 @@ public class DaylightApiService {
return result;
}
- private JSONObject daylightCallOperationUrl(String operationUrl, String dlPropertyId) {
+ private JSONObject daylightCallMultiOperationUrl(String operationUrl, String dlPropertyId) {
JSONObject jsonObject = new JSONObject();
try {
@@ -599,6 +596,9 @@ public class DaylightApiService {
int notRunCount = 0;
int inProgressCount = 0;
do {
+ // 让进程暂停1.5秒 by Mauve 20260909
+ TimeUnit.MILLISECONDS.sleep(2000L);
+
responseData = httpService.sslGet(operationUrl, headers, new HashMap<>());
JSONObject jsonObject1 = JSON.parseObject(responseData);
@@ -616,9 +616,6 @@ public class DaylightApiService {
if (string.contains("InProgress")) {
inProgressCount++;
}
-
- // 让进程暂停1.5秒 by Mauve 20260909
- TimeUnit.MILLISECONDS.sleep(1500L);
} while ((responseData.contains("InProgress") || responseData.contains("NotRun")) && notRunCount < 20 && inProgressCount < 50);
jsonObject = JSON.parseObject(responseData);
@@ -630,6 +627,60 @@ public class DaylightApiService {
return jsonObject;
}
+ private Boolean daylightCallOperationUrl(String operationUrl, String dlPropertyId) {
+
+ try {
+ Header[] headers = HttpHeaderBuilder.custom()
+ .contentType("application/json")
+ .ac_property_id(dlPropertyId)
+ .build();
+
+ String responseData;
+ Boolean result = false;
+
+ int notRunCount = 0;
+ int inProgressCount = 0;
+ do {
+ // 让进程暂停2秒 by Mauve 20260909
+ TimeUnit.MILLISECONDS.sleep(2000);
+
+ responseData = httpService.sslGet(operationUrl, headers, new HashMap<>());
+
+ JSONObject jsonObject1 = JSON.parseObject(responseData);
+
+ String string =
+ jsonObject1.getJSONObject("status").getString("operationStatus");
+
+ if (string.contains("Completed")) {
+
+ String string1 = jsonObject1.getJSONObject("data").getString("result");
+
+ if (string1.equals("Succeeded")) {
+ result = true;
+ }
+ break;
+ }
+
+ if (string.contains("Fail")) break;
+
+ if (string.contains("NotRun")) {
+ notRunCount++;
+ continue;
+ }
+
+ if (string.contains("InProgress")) {
+ inProgressCount++;
+ }
+ } while ((responseData.contains("InProgress") || responseData.contains("NotRun")) && notRunCount < 20 && inProgressCount < 50);
+
+ return result;
+ } catch (Exception e) {
+ log.error("Call operation url failed: {}", operationUrl, e);
+ }
+
+ return false;
+ }
+
private JSONObject buildCancelReservationRequest(String dlReservationId, String dlPropertyId) {
JSONObject json = new JSONObject();
@@ -679,13 +730,18 @@ public class DaylightApiService {
public DaylightReservationResponse getDaylightReservationByDlId(
String dlReservationId,
- String dlPropertyId
+ String dlPropertyId,
+ boolean needExtend
) {
DaylightReservationResponse resultResponse;
try {
- String url = "/api-gateway/booking/v1/reservations/" + dlReservationId
- + "?extend=PurchaseElements,CustomFields";
+ String url = "/api-gateway/booking/v1/reservations/" + dlReservationId;
+
+ if (needExtend) {
+ url = url + "?extend=PurchaseElements,CustomFields";
+ }
+
// 获取对应的值
Header[] headers = HttpHeaderBuilder.custom()
.contentType("application/json")
@@ -698,6 +754,8 @@ public class DaylightApiService {
resultResponse = JSON.parseObject(responseData, DaylightReservationResponse.class);
} catch (Exception e) {
+ log.error("[DL-RESV-DEBUG] getDaylightReservationByDlId exception, dlReservationId={}, dlPropertyId={}",
+ dlReservationId, dlPropertyId, e);
throw new RuntimeException(e);
}
@@ -1065,12 +1123,15 @@ public class DaylightApiService {
}
log.info("[getBookingRecordByProfileId_Optimize] totalProperties={}, profileId={}", properties.size(), profileId);
-// String currentDate = DateTimeUtil.getCurrentDate("yyyy-MM-dd");
+ String month3 = DateTimeUtil.addDay(new Date(), -90, "yyyy-MM-dd");
+ String currentDate = DateTimeUtil.getCurrentDate("yyyy-MM-dd");
- 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
+ String url = "/api-gateway/aggregator/v1/reservations?pageNumber=1&pageSize=50&filter=profileId==" + profileId
+ + ";(statusCode.code==DI,statusCode.code==RS,statusCode.code==DO,statusCode.code==IH,statusCode.code==NS,"
+ + "statusCode.code==CX"+ ";arrivalDate=ge=" + month3+ ")"
+ + ";departureDate=ge=" + currentDate
+ "&extend=PurchaseElements,CustomFields,Breakdown,DoorKeys,Notes&sort=-createdAt";
+
Map map = new HashMap<>();
try {
for (CfgProperties property : properties) {
@@ -1370,66 +1431,6 @@ public class DaylightApiService {
return result;
}
- public BaseApiResponse updateDaylightCompRule(
- String dlAccountId,
- String dlPropertyId,
- String dlCompRuleId,
- String version,
- UpdateCompRuleRequest request
- ) {
- try {
- String url = "/api-gateway/cashiering/v1/accounts/" + dlAccountId + "/complimentary-rules/" + dlCompRuleId;
-
- Header[] headers = HttpHeaderBuilder.custom()
- .contentType("application/json")
- .ac_property_id(dlPropertyId)
- .ifMatch(String.valueOf(version))
- .build();
-
- return updateCompRule(url, headers, request);
- } catch (Exception e) {
- BaseApiResponse response = new BaseApiResponse<>();
- response.setSuccess(false);
- response.setMessage(e.getMessage());
- LogUtil.error(DaylightApiService.class, e.getMessage());
-
- return response;
- }
- }
-
- public BaseApiResponse getDaylightCompRule(
- String dlPropertyId,
- String dlAccountId,
- String dlCompRuleId
- ) {
- BaseApiResponse response = new BaseApiResponse<>();
-
- try {
- String url = "/api-gateway/cashiering/v1/accounts/" + dlAccountId + "/complimentary-rules/" + dlCompRuleId;
-
- Header[] headers = HttpHeaderBuilder.custom()
- .contentType("application/json")
- .ac_property_id(dlPropertyId)
- .build();
-
- Map map = new HashMap<>();
-
- HttpResult httpResult = httpService.sslGetHttpResult(url, headers, map);
-
- if (httpResult.getStatusCode() == 200) {
- CompRuleResponse crr = JSON.parseObject(httpResult.getResult(), CompRuleResponse.class);
- response.setSuccess(true);
- response.setData(crr);
- }
- } catch (Exception e) {
- response.setSuccess(false);
- response.setMessage(e.getMessage());
- LogUtil.error(DaylightApiService.class, e.getMessage());
- }
-
- return response;
- }
-
public BaseApiResponse updateDaylightCompRule(
String dlAccountId,
String dlPropertyId,
@@ -1520,7 +1521,7 @@ public class DaylightApiService {
return result;
}
- public BaseApiResponse createDaylightCompRule(
+ public BaseApiResponse> createDaylightCompRule(
String dlAccountId,
String profileId,
String dlPropertyId,
@@ -1532,8 +1533,29 @@ public class DaylightApiService {
List exceptionDaylightViewList,
String miscCharge
) {
+ return createDaylightCompRule(dlAccountId, profileId, dlPropertyId, userId, roomName,
+ startDate, endDate, daylightViewList, exceptionDaylightViewList, miscCharge, false);
+ }
- BaseApiResponse result = new BaseApiResponse<>();
+ /**
+ * @param isNewBooking true only for the first comp rule initialization after booking creation
+ */
+ public BaseApiResponse> createDaylightCompRule(
+ String dlAccountId,
+ String profileId,
+ String dlPropertyId,
+ String userId,
+ String roomName,
+ String startDate,
+ String endDate,
+ List daylightViewList,
+ List exceptionDaylightViewList,
+ String miscCharge,
+ boolean isNewBooking
+ ) {
+
+ BaseApiResponse> result = new BaseApiResponse<>();
+ result.setData(new ArrayList<>());
log.info("Start to create complimentary rule");
@@ -1553,15 +1575,20 @@ public class DaylightApiService {
return result;
}
- BaseApiResponse jsonArrayBaseApiResponse = daylightGetCompRulesByAccount(dlPropertyId, dlAccountId);
- if (!jsonArrayBaseApiResponse.isSuccess() || jsonArrayBaseApiResponse.getData() == null) {
- result.setSuccess(false);
- result.setMessage(jsonArrayBaseApiResponse.getMessage());
- return result;
+ int compRuleCount = 0;
+ if (isNewBooking) {
+ log.info("Skip comp rule query for newly created booking, accountId={}", dlAccountId);
+ } else {
+ BaseApiResponse jsonArrayBaseApiResponse = daylightGetCompRulesByAccount(dlPropertyId, dlAccountId);
+ if (!jsonArrayBaseApiResponse.isSuccess() || jsonArrayBaseApiResponse.getData() == null) {
+ result.setSuccess(false);
+ result.setMessage(jsonArrayBaseApiResponse.getMessage());
+ return result;
+ }
+ compRuleCount = jsonArrayBaseApiResponse.getData().size();
}
- int compRuleCount = jsonArrayBaseApiResponse.getData().size();
- boolean hasMiscCharge = miscCharge != null;
+ boolean hasMiscCharge = StringUtils.isNotBlank(miscCharge);
boolean createRoomOnlyCompRule = compRuleCount == 0;
boolean createDaylightViewCompRule = hasMiscCharge && compRuleCount <= 1;
@@ -1601,8 +1628,14 @@ public class DaylightApiService {
if (compRuleCount >= 2) {
try {
- return updateDaylightCompRule(dlAccountId, dlPropertyId, startDate, endDate,
+ BaseApiResponse response
+ = updateDaylightCompRule(dlAccountId, dlPropertyId, startDate, endDate,
daylightView, exceptionDaylightView, miscCharge);
+
+ result.setMessage(response.getMessage());
+ result.setSuccess(response.isSuccess());
+
+ return result;
} catch (Exception e) {
result.setSuccess(false);
result.setMessage(e.getMessage());
@@ -1660,8 +1693,13 @@ public class DaylightApiService {
daylightViewRoomOnly, exceptionDaylightViewRoomOnly, false);
BaseApiResponse createDefaultResult = createCompRule(url, headers, roomOnlyCompRuleRequest);
if (!createDefaultResult.isSuccess()) {
- return createDefaultResult;
+
+ result.setSuccess(false);
+ result.setMessage(createDefaultResult.getMessage());
+
+ return result;
}
+ result.getData().add(createDefaultResult.getData());
}
if (createDaylightViewCompRule) {
@@ -1675,8 +1713,14 @@ public class DaylightApiService {
BaseApiResponse createDaylightViewResult = createCompRule(url, headers, daylightViewCompRuleRequest.getData());
if (!createDaylightViewResult.isSuccess()) {
- return createDaylightViewResult;
+
+ result.setSuccess(false);
+ result.setMessage(createDaylightViewResult.getMessage());
+
+ return result;
}
+
+ result.getData().add(createDaylightViewResult.getData());
}
result.setSuccess(true);
@@ -1757,6 +1801,7 @@ public class DaylightApiService {
result.setSuccess(true);
result.setMessage("Create CompRule success");
+ result.setData(createDefaultResult.getData());
} catch (Exception e) {
result.setSuccess(false);
@@ -1947,6 +1992,16 @@ public class DaylightApiService {
if (httpResult.getStatusCode() == 201) {
result.setSuccess(true);
result.setMessage("Create CompRule success");
+
+ Header[] respHeaders = httpResult.getRespHeaders();
+ for (Header header : respHeaders) {
+ String name = header.getName();
+ if ("Location".equalsIgnoreCase(name)) {
+ String[] split = header.getValue().split("/");
+ String compRuleId = split[split.length - 1];
+ result.setData(compRuleId);
+ }
+ }
} else {
result.setSuccess(false);
result.setMessage("Create CompRule failed");
@@ -2021,32 +2076,41 @@ public class DaylightApiService {
log.info("getDaylightRequestorApproverByUserId, propertyId: {}, userId: {}", propertyId, userId);
- try {
- String url = "/api-gateway/resource-management/v1/resource?filter=(isActive==true;code==" + userId + ")";
- // 获取对应的值
- Header[] headers = HttpHeaderBuilder.custom()
- .contentType("application/json")
- .ac_property_id(propertyId)
- .build();
- // 参数设置
- Map map = new HashMap<>();
- String responseData = httpService.sslGet(url, headers, map);
- JSONObject res = JSON.parseObject(responseData);
- JSONArray raJson = res.getJSONArray("results");
+ CfgDaylightConfiguration requestor = dlConfigurationDao.findByDlPropertyIdAndConfigName(propertyId, "ResourceRequestor");
- RequestorApproverResponse result = convertRequestorApprover(raJson);
+ String configValue = requestor.getConfigValue();
- if (result != null) {
- serviceResult.setSuccess(true);
- serviceResult.setData(result);
- } else {
- serviceResult.setSuccess(false);
- serviceResult.setMessage("Convert failed");
+ JSONArray object = JSONArray.parseArray(configValue);
+
+ for (int i = 0; i < object.size(); i++) {
+ JSONObject jsonObject = object.getJSONObject(i);
+
+ boolean isActive = jsonObject.getBoolean("isActive");
+
+ if (!isActive) {
+ continue;
}
- } catch (Exception e) {
+
+ String code = jsonObject.getString("code");
+
+ if (Objects.equals(code, userId)) {
+ RequestorApproverResponse resp = new RequestorApproverResponse();
+ resp.setVersion(jsonObject.getInteger("version"));
+ resp.setCode(code);
+ resp.setId(jsonObject.getString("id"));
+ resp.setFirstName(jsonObject.getString("firstName"));
+ resp.setLastName(jsonObject.getString("lastName"));
+
+ serviceResult.setData(resp);
+ serviceResult.setSuccess(true);
+
+ return serviceResult;
+ }
+ }
+
+ if (Objects.isNull(serviceResult.getData())) {
serviceResult.setSuccess(false);
- serviceResult.setMessage("Get requestor approver by userId failed");
- LogUtil.error(DaylightApiService.class, e.getMessage());
+ serviceResult.setMessage("Requestor data is empty");
}
return serviceResult;
@@ -2085,7 +2149,7 @@ public class DaylightApiService {
.ac_property_id(propertyId)
.build();
- DaylightReservationResponse daylightReservationByDlId = getDaylightReservationByDlId(reservationId, propertyId);
+ DaylightReservationResponse daylightReservationByDlId = getDaylightReservationByDlId(reservationId, propertyId, false);
Long version = daylightReservationByDlId.getVersion();
Map map = new HashMap<>();
@@ -2273,9 +2337,11 @@ public class DaylightApiService {
if (responseData.getStatusCode() >= 200 && responseData.getStatusCode() < 300) {
response.setSuccess(true);
response.setMessage("Set post success");
+ log.info("Set post success");
} else {
response.setSuccess(false);
response.setMessage("Set post failed");
+ log.warn("Set post failed: {}", responseData.getResult());
}
} catch (Exception e) {
@@ -2343,7 +2409,7 @@ public class DaylightApiService {
String dlReservationId = bookings.getDlReservationId();
String url = "/api-gateway/booking/v1/reservations/" + dlReservationId + "/change-dates";
- DaylightReservationResponse daylightReservationByDlId = getDaylightReservationByDlId(dlReservationId, dlPropertyId);
+ DaylightReservationResponse daylightReservationByDlId = getDaylightReservationByDlId(dlReservationId, dlPropertyId, false);
Long version = daylightReservationByDlId.getVersion();
Breakdown breakdown = new Breakdown();
@@ -2398,6 +2464,24 @@ public class DaylightApiService {
result.setData(bookings);
} else if (submitResult.getStatusCode() == 202) {
+ String operationUrl = "";
+ Header[] changeDateHeader = submitResult.getRespHeaders();
+ for (Header header : changeDateHeader) {
+ if (header.getName().equals("Location")) {
+ operationUrl = header.getValue();
+ break;
+ }
+ }
+
+ Boolean b = daylightCallOperationUrl(operationUrl, dlPropertyId);
+ if (b) {
+ result.setSuccess(true);
+ result.setData(bookings);
+ } else {
+ result.setSuccess(false);
+ result.setMessage("Change date failed, reservationId=" + dlReservationId);
+ log.warn("Change date failed, reservationId={}", dlReservationId);
+ }
} else {
JSONObject rootNode = JSON.parseObject(responseBody);
String errorStr;
diff --git a/src/main/java/com/mgm/mcrm/booking/controllers/BookingController.java b/src/main/java/com/mgm/mcrm/booking/controllers/BookingController.java
index b6ddc2e..8f47f54 100644
--- a/src/main/java/com/mgm/mcrm/booking/controllers/BookingController.java
+++ b/src/main/java/com/mgm/mcrm/booking/controllers/BookingController.java
@@ -167,6 +167,7 @@ public class BookingController {
@RequestBody GetOperaBookingRequest params) throws Exception {
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
String conf = params.getConf();
+ Boolean isRefresh = Boolean.TRUE.equals(params.getRefresh());
BaseApiResponse> result = new BaseApiResponse<>();
@@ -177,7 +178,7 @@ public class BookingController {
sysGroupPermissionService.checkGroupPermission(groupName, SysConstants.PERMISSION_APP_VIEW_BOOKING);
List list;
- list = bookingService.getBookingByConfirmationNo(conf);
+ list = bookingService.getBookingByConfirmationNo(conf,isRefresh);
if(!list.isEmpty() && StringUtils.isNotEmpty(userId)) {
BaseApiResponse findPlayerResult =
playerService.findPlayerProfileByPlayerIdAndUserId(list.getFirst().getPlayerId(), userId);
@@ -399,7 +400,9 @@ public class BookingController {
processResult.setData(processResult.getData());
}else {
processResult.setSuccess(false);
- processResult.setMessage("Change MiscCharge Failed");
+// processResult.setMessage("Change MiscCharge Failed");
+ processResult.setCode(serviceResult.getCode());
+ processResult.setMessage(serviceResult.getMessage());
}
return processResult;
}
@@ -465,7 +468,6 @@ public class BookingController {
String checkOutDate = bookingService.getSearchRecordCheckOutDate(currentDay);
List operaResult = new ArrayList<>();
List daylightResult = new ArrayList<>();
- boolean isLoadDaylightFromCache = sysBookingCacheService.isDaylightBookingCacheValid(playerId);
String daylightProfileId = sysBookingCacheService.getDaylightProfileMappingFromCache(playerId);
if(StringUtils.isBlank(daylightProfileId)){
//去Daylight查ProfileId
@@ -483,14 +485,9 @@ public class BookingController {
LogUtil.warn(BookingService.class, "[recordSearch] Daylight profile lookup failed, message=" + profileResult.getMessage() + ", playerId=" + playerId);
}
}
- if(StringUtils.isNotBlank(daylightProfileId) && !isLoadDaylightFromCache){
+ if(StringUtils.isNotBlank(daylightProfileId)){
LogUtil.info(BookingService.class, "[recordSearch] Load Daylight booking by call API, playerId=" + playerId +" profile Id:"+daylightProfileId);
daylightResult = daylightApiService.getBookingRecordByProfileId_Optimize(daylightProfileId, playerId);
- sysBookingCacheService.updateDaylightBookingCacheLog(playerId);
- }else if(isLoadDaylightFromCache){
- //-- 查找出user 在DB 里的所有daylight类型的 DB booking
- LogUtil.info(BookingService.class, "[recordSearch] Load Daylight booking from cache DB, playerId=" + playerId +" profile Id:"+daylightProfileId);
- daylightResult = bookingService.getSearchPlayerDaylightDbRecord(startDate, checkOutDate, playerId);
}
LogUtil.info(BookingService.class, "[recordSearch] getBookingsByNameID:");
LogUtil.info(BookingController.class, "[recordSearch] getDaylightBookings resultSize:" + daylightResult.size() + " spendTime:" + (System.currentTimeMillis() - stepStartTime) + "ms");
@@ -512,21 +509,17 @@ public class BookingController {
LogUtil.info(BookingController.class, "[recordSearch] getBookingsByNameID resultSize:" + operaResult.size() + " spendTime:" + (System.currentTimeMillis() - stepStartTime) + "ms");
if (!daylightResult.isEmpty()) {
- if(!isLoadDaylightFromCache){
- //将Daylight Result 合并至DB
- LogUtil.info(BookingService.class,"[recordSearch] before mergeDaylightRecordFromDB_Optimize, playerId="
- + playerId + ", daylightResult.size=" + daylightResult.size());
- stepStartTime = System.currentTimeMillis();
- List dbDaylightResults = bookingService.mergeDaylightRecordFromDB_Optimize(daylightResult,memberInfo,userId);
- LogUtil.info(BookingController.class, "[recordSearch] mergeDaylightDatabaseInfo resultSize:" + dbDaylightResults.size() + " spendTime:" + (System.currentTimeMillis() - stepStartTime) + "ms");
- stepStartTime = System.currentTimeMillis();
- bookingService.syncDaylightMergeBookingToDbAndPopulateIds_Optimize(dbDaylightResults);
- LogUtil.info(BookingController.class, "[recordSearch] syncDaylightDatabase resultSize:" + dbDaylightResults.size() + " spendTime:" + (System.currentTimeMillis() - stepStartTime) + "ms");
- dbDaylightResults.removeIf(item -> "CANCELED".equalsIgnoreCase(item.getLastOperaStatus()));
- allPropertiesResults.addAll(dbDaylightResults);
- } else{
- allPropertiesResults.addAll(daylightResult);
- }
+ //将Daylight Result 合并至DB
+ LogUtil.info(BookingService.class,"[recordSearch] before mergeDaylightRecordFromDB_Optimize, playerId="
+ + playerId + ", daylightResult.size=" + daylightResult.size());
+ stepStartTime = System.currentTimeMillis();
+ List dbDaylightResults = bookingService.mergeDaylightRecordFromDB_Optimize(daylightResult,memberInfo,userId);
+ LogUtil.info(BookingController.class, "[recordSearch] mergeDaylightDatabaseInfo resultSize:" + dbDaylightResults.size() + " spendTime:" + (System.currentTimeMillis() - stepStartTime) + "ms");
+ stepStartTime = System.currentTimeMillis();
+ bookingService.syncDaylightMergeBookingToDbAndPopulateIds_Optimize(dbDaylightResults);
+ LogUtil.info(BookingController.class, "[recordSearch] syncDaylightDatabase resultSize:" + dbDaylightResults.size() + " spendTime:" + (System.currentTimeMillis() - stepStartTime) + "ms");
+ dbDaylightResults.removeIf(item -> "CANCELED".equalsIgnoreCase(item.getLastOperaStatus()));
+ allPropertiesResults.addAll(dbDaylightResults);
} else {
LogUtil.warn(BookingService.class,"[recordSearch] daylightResult is empty, skipping Daylight merge");
}
@@ -724,7 +717,7 @@ public class BookingController {
return allPropertiesResults;
}
- @VerifyPermission(permissionId = {"00501_01", "00401_01"})
+ @VerifyPermission(permissionId = {"00401_01", "00601_01"})
@RequestMapping(value = "/web/booking/get_page", produces = "application/json;charset=UTF-8",consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity>> getBookingByPage(
HttpServletRequest request,
diff --git a/src/main/java/com/mgm/mcrm/booking/dtos/search/GetOperaBookingRequest.java b/src/main/java/com/mgm/mcrm/booking/dtos/search/GetOperaBookingRequest.java
index 55c937d..97f97d5 100644
--- a/src/main/java/com/mgm/mcrm/booking/dtos/search/GetOperaBookingRequest.java
+++ b/src/main/java/com/mgm/mcrm/booking/dtos/search/GetOperaBookingRequest.java
@@ -5,4 +5,5 @@ import lombok.Data;
@Data
public class GetOperaBookingRequest {
private String conf;
+ private Boolean refresh;
}
diff --git a/src/main/java/com/mgm/mcrm/booking/repositories/BookingViewDao.java b/src/main/java/com/mgm/mcrm/booking/repositories/BookingViewDao.java
index 6c65d46..ca1c66f 100644
--- a/src/main/java/com/mgm/mcrm/booking/repositories/BookingViewDao.java
+++ b/src/main/java/com/mgm/mcrm/booking/repositories/BookingViewDao.java
@@ -98,7 +98,7 @@ public interface BookingViewDao extends JpaRepository {
@Query(value="update bookings set last_opera_status='DUE_IN' where cast(checkin_date as date)=cast(getdate() as date) "
+ " and CAST(GETDATE() AS TIME) <'12:00:00'"
+ " and cast(checkout_date as date)>cast(getdate() as date) "
- + " and (last_opera_status is null or last_opera_status='RESERVED') and approve_status='N'",nativeQuery=true)
+ + " and (last_opera_status is null or last_opera_status='RESERVED') and approve_status='N' and category != 'DAYLIGHT'",nativeQuery=true)
void changeDueIn();
@Transactional
@@ -106,25 +106,25 @@ public interface BookingViewDao extends JpaRepository {
@Query(value="update bookings set last_opera_status='CHECKED_IN' where cast(checkin_date as date)=cast(getdate() as date) "
+ " and CAST(GETDATE() AS TIME) >= '12:00:00'"
+ " and cast(checkout_date as date)>cast(getdate() as date) "
- + " and (last_opera_status is null or last_opera_status='DUE_IN' or last_opera_status='RESERVED') and approve_status='N'",nativeQuery=true)
+ + " and (last_opera_status is null or last_opera_status='DUE_IN' or last_opera_status='RESERVED') and approve_status='N' and category != 'DAYLIGHT'",nativeQuery=true)
void changeCheckedIn();
@Transactional
@Modifying
@Query(value="update bookings set last_opera_status='DUE_OUT' where cast(checkout_date as date)=cast(getdate() as date)"
- + " and (last_opera_status is null or last_opera_status='CHECKED_IN') and approve_status='N'",nativeQuery=true)
+ + " and (last_opera_status is null or last_opera_status='CHECKED_IN') and approve_status='N' and category != 'DAYLIGHT'",nativeQuery=true)
void changeDueOut();
@Transactional
@Modifying
@Query(value="update bookings set last_opera_status='CHECKED_OUT' where cast(checkout_date as date)> serviceResult = dlService.dayLightGetProfileByPlayerId(sharerId);
List returnData = serviceResult.getData();
@@ -1504,12 +1524,16 @@ public class BookingService {
String confirmationNumber = createResponse.getData().getString("confirmationNumber");
DaylightReservationResponse daylightReservationByDlId =
- dlService.getDaylightReservationByDlId(reservationId, property.getDlPropertyId());
+ dlService.getDaylightReservationByDlId(reservationId, property.getDlPropertyId(), false);
booking.setDlAccountId(daylightReservationByDlId.getAccountId());
booking.setDlReservationId(reservationId);
booking.setConfirmationNo(confirmationNumber);
- booking.setLastOperaStatus("RESERVED");
+
+ String description = daylightReservationByDlId.getStatusCode().getDescription();
+ String statusByDaylightStatus = EnumBookingStatus.getStatusByDaylightStatus(description);
+
+ booking.setLastOperaStatus(statusByDaylightStatus);
booking.setApproveStatus("N");
//
bookingDao.save(booking);
@@ -1537,7 +1561,7 @@ public class BookingService {
}
}
- dlService.createDaylightCompRule(
+ BaseApiResponse> daylightCompRule = dlService.createDaylightCompRule(
daylightReservationByDlId.getAccountId(),
daylightReservationByDlId.getProfileId(),
property.getDlPropertyId(),
@@ -1547,24 +1571,11 @@ public class BookingService {
checkoutDateStr,
daylightViewList,
exceptionDaylightViewList,
- booking.getMiscCharge()
+ booking.getMiscCharge(),
+ true
);
- //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"));
- }
- }
+ List compRuleIds = daylightCompRule.getData();
//2.循环Comp rule ids 插入每一条comp rule
for (String compRuleId :compRuleIds){
@@ -1632,6 +1643,19 @@ public class BookingService {
processResult.setMessage("Change date fail");
log.warn("Change date fail");
}
+ } else if ("SET_POST".equalsIgnoreCase(type)) {
+ BaseApiResponse createResponse =
+ dlService.daylightUpsertReservationNew(reservationRequestDTO, property.getDlPropertyId());
+
+ if (createResponse.isSuccess()) {
+ processResult.setSuccess(true);
+ processResult.setMessage("Set post success");
+ log.info("Set post success");
+ } else {
+ processResult.setSuccess(false);
+ processResult.setMessage("Set post fail");
+ log.warn("Set post fail");
+ }
}
return processResult;
@@ -2730,7 +2754,7 @@ public class BookingService {
}
DaylightReservationResponse daylightReservationByDlId =
- dlService.getDaylightReservationByDlId(booking.getDlReservationId(), property.getDlPropertyId());
+ dlService.getDaylightReservationByDlId(booking.getDlReservationId(), property.getDlPropertyId(), false);
BaseApiResponse compRuleListResponse = dlService.daylightGetCompRulesByAccount(property.getDlPropertyId(),daylightReservationByDlId.getAccountId());
if(compRuleListResponse.isSuccess()&&daylightViewRoomOnly!=null&&userId!=null){
@@ -2756,6 +2780,10 @@ public class BookingService {
}
}
+ if (!isExtend && result.isSuccess()) {
+ booking.setCheckinDate(checkinDate);
+ newBooking.setCheckinDate(checkinDate);
+ }
bookingDao.save(booking);
if (result.isSuccess()) {
@@ -3544,8 +3572,7 @@ public class BookingService {
return list;
}
- public List getBookingByConfirmationNo(String conf) throws Exception {
-
+ public List getBookingByConfirmationNo(String conf,Boolean isRefresh) throws Exception {
List list = bookingViewDao.findBookingByConfirmationNo(conf);
if (CollectionUtils.isEmpty(list)) {
@@ -3553,13 +3580,17 @@ public class BookingService {
}
if ("DAYLIGHT".equalsIgnoreCase(list.getFirst().getPropertyCategory())) {
- return getBookingDaylight(list);
+ if(isRefresh){
+ return getBookingDaylight(list);
+ }else{
+ return getBookingDaylightFromDB(list);
+ }
}
return getBookingOperaOther(list, conf);
}
- private List getBookingOperaOther(List list, String conf) {
+ private List getBookingOperaOther(List list, String conf) throws Exception {
List operaList = operaDBService.getBookingsByConfirmationNo(conf);
for(int i=0;i shareOperaList = operaDBService.getBookingsByConfirmationNo(shareConfirmationNoFromOws);
+ if (shareOperaList != null && shareOperaList.size() > 0) {
+ BookingsView sharerOperaBooking = shareOperaList.get(0);
+ String shareProfileExpDate = sharerOperaBooking.getProfieExpDate();
+ LogUtil.info(BookingService.class,
+ "[getBookingByConfirmationNo] shareProfileExpDate " + sharerOperaBooking.getProfieExpDate());
+ if (StringUtils.isEmpty(shareProfileExpDate)) {
+ expDate = shareProfileExpDate;
+ } else if (StringUtils.contains(shareProfileExpDate, "FORM")) {
+
+ } else {
+ if (!StringUtils.isEmpty(expDate) && !StringUtils.contains(expDate, "FORM")) {
+ Date edateTime = DateTimeUtil.getDateFromString(expDate, "yyyy-MM-dd");
+ Date proShareEdateTime = DateTimeUtil.getDateFromString(shareProfileExpDate, "yyyy-MM-dd");
+ if (proShareEdateTime.getTime() < edateTime.getTime())
+ expDate = shareProfileExpDate;
+ } else if (StringUtils.contains(expDate, "FORM")) {
+ expDate = shareProfileExpDate;
+ }
+
+ }
+ }
+ }
+ }
+ }
+
if(booking.getSharer()!=null && !booking.getSharer().equals("") && !booking.getSharer().equals("[]")) {
booking.setSharerList(JSONArray.parseArray(booking.getSharer()));
@@ -3706,28 +3777,25 @@ public class BookingService {
return list;
}
- String dlReservationId = list.stream()
- .map(BookingsView::getDlReservationId)
- .filter(Objects::nonNull)
+ BookingsView dlView = list.stream()
+ .filter(view -> view.getDlReservationId() != null)
.findFirst()
.orElse(null);
-
- propertyCache.refresh();
+ String dlReservationId = dlView == null ? null : dlView.getDlReservationId();
DaylightReservationResponse daylightResultBooking = null;
String dlPropertyId = null;
if (dlReservationId != null) {
- for (CfgProperties cfgProperties : propertyCache.getProperties()) {
+ CfgProperties cfgProperties = propertyDao.findById(dlView.getPropertyId()).orElse(null);
+ if (cfgProperties != null) {
+ dlPropertyId = cfgProperties.getDlPropertyId();
daylightResultBooking = dlService.getDaylightReservationByDlId(
dlReservationId,
- cfgProperties.getDlPropertyId()
+ cfgProperties.getDlPropertyId(),
+ false
);
- if (daylightResultBooking != null) {
- dlPropertyId = cfgProperties.getDlPropertyId();
- break;
- }
}
}
@@ -3736,14 +3804,14 @@ public class BookingService {
}
if (CollectionUtils.isEmpty(daylightResultBooking.getExternalIds())) {
- String dlExternalNo = "UP2-" + UUID.randomUUID().toString().replace("-", "");
+// String dlExternalNo = "UP2-" + UUID.randomUUID().toString().replace("-", "");
- dlService.daylightSetExternalNo(
- dlPropertyId,
- dlReservationId,
- dlExternalNo,
- daylightResultBooking.getVersion()
- );
+// dlService.daylightSetExternalNo(
+// dlPropertyId,
+// dlReservationId,
+// dlExternalNo,
+// daylightResultBooking.getVersion()
+// );
}
for (BookingsView view : list) {
@@ -3795,9 +3863,8 @@ public class BookingService {
}
}
- if (StringUtils.isNotBlank(expDate)
- && hasSharer
- && CollectionUtils.isNotEmpty(view.getDlSharerIds())) {
+ if (StringUtils.isNotBlank(expDate)&&
+ CollectionUtils.isNotEmpty(view.getDlSharerIds())) {
for (String dlSharerId : view.getDlSharerIds()) {
ProfileDetailResponse profileDetailResponse
= dlService.dayLightGetProfileByProfileId(dlSharerId);
@@ -3858,6 +3925,65 @@ public class BookingService {
return list;
}
+ private List getBookingDaylightFromDB(List list) {
+ if (list == null || list.isEmpty()) {
+ return list;
+ }
+
+ for (BookingsView view : list) {
+ if ("FC".equals(view.getApproveStatus()) && view.getConfirmationNo() != null) {
+ view.setApproveStatus("N");
+ }
+
+ if (StringUtils.isNotBlank(view.getFeatureCode())) {
+ String specialName = Arrays.stream(view.getFeatureCode().split(","))
+ .filter(StringUtils::isNotBlank)
+ .map(roomFeatureDao::getByDaylightCode)
+ .filter(Objects::nonNull)
+ .map(CfgRoomFeatures::getDescription)
+ .collect(Collectors.joining(", "));
+ view.setSpecialName(specialName);
+ }
+
+ boolean hasSharer = StringUtils.isNotBlank(view.getSharer())
+ && !"[]".equals(view.getSharer());
+ if (hasSharer) {
+ JSONArray sharerList = JSONArray.parseArray(view.getSharer());
+ view.setSharerList(sharerList);
+ }
+
+ int numOfNight = Integer.parseInt(
+ DateTimeUtil.getDiffDate(
+ view.getCheckinDate(),
+ view.getCheckoutDate(),
+ "day"
+ )
+ );
+
+ view.setNumOfNight(numOfNight);
+
+ ArrayList dates = new ArrayList<>();
+ for (int j = 0; j <= numOfNight; j++) {
+ dates.add(DateTimeUtil.getDateByFormat(
+ DateTimeUtil.addDay(view.getCheckinDate(), j),
+ "yyyy-MM-dd"
+ ));
+ }
+
+ JSONObject dateObj = new JSONObject();
+ dateObj.put("date", dates);
+ dateObj.put("numOfNight", numOfNight);
+ dateObj.put("numOfRoom", 1);
+ dateObj.put("checked", true);
+
+ ArrayList dateList = new ArrayList<>();
+ dateList.add(dateObj);
+ view.setDateList(dateList);
+ }
+
+ return list;
+ }
+
public List getBookingById(long id) {
List list = bookingViewDao.findBookingById(id);
@@ -5669,6 +5795,7 @@ public class BookingService {
view.setDlAccountId(booking.getDlAccountId());
view.setDlReservationId(booking.getDlReservationId());
view.setDlExternalNo(booking.getDlExternalNo());
+ view.setApproveStatus(booking.getApproveStatus());
if (Objects.isNull(properties.get(booking.getPropertyId()))) {
propertyDao.findById(booking.getPropertyId()).ifPresent(
@@ -6231,19 +6358,25 @@ public class BookingService {
checkoutDate, nowStr));
}
- public BaseApiResponse changeMiscCharge(Long bookingId, String miscCharge, String userId) throws Exception {
+ public BaseApiResponse changeMiscCharge(Long bookingId, @NotNull String miscCharge, String userId) throws Exception {
BaseApiResponse processResult = new BaseApiResponse<>();
// 1. 基础数据获取与准备
Bookings bookings = bookingDao.findById(bookingId).orElse(null);
+ boolean needSetPost = StringUtils.isNotEmpty(miscCharge) && StringUtils.isEmpty(bookings.getMiscCharge());
+
if (bookings == null) {
processResult.setMessage("Misc charge not found");
processResult.setSuccess(false);
return processResult;
}
- boolean needSetPost = StringUtils.isEmpty(bookings.getMiscCharge());
+ if (bookings.getBookingTypeId() == null) {
+ processResult.setMessage("Booking type id not found");
+ processResult.setSuccess(false);
+ return processResult;
+ }
CfgBookingTypes cfgBookingTypes = bookingTypeDao.findById(bookings.getBookingTypeId()).orElse(null);
String bookingTypeName = cfgBookingTypes.getName();
@@ -6266,6 +6399,30 @@ public class BookingService {
String comment = response.getData().getContent();
comment = comment.replaceAll("(?i)
", "\n");
bookings.setOperaComment(comment);
+
+ Matcher miscChargeMatcher = Pattern
+ .compile("(?:\\$|$)\\s*([0-9]+(?:\\.[0-9]+)?)", Pattern.CASE_INSENSITIVE)
+ .matcher(comment);
+ if (miscChargeMatcher.find()) {
+ String miscChargeFromDaylight = miscChargeMatcher.group(1);
+
+ if ("CHECKED_IN".equalsIgnoreCase(bookings.getLastOperaStatus())) {
+
+ int newMisc = Integer.parseInt(miscCharge);
+ int fromDaylight = Integer.parseInt(miscChargeFromDaylight);
+
+ if (fromDaylight > newMisc) {
+
+ bookings.setMiscCharge(miscChargeFromDaylight);
+ bookingDao.save(bookings);
+
+ processResult.setMessage("Amount cannot be less than original:" + miscChargeFromDaylight);
+ processResult.setSuccess(false);
+ processResult.setLogMessage("Amount cannot be less than original:" + miscChargeFromDaylight);
+ return processResult;
+ }
+ }
+ }
}
ReservationNoteResponse noteResponse = response.getData();
@@ -6305,8 +6462,8 @@ public class BookingService {
Date checkOutDate = bookings.getCheckoutDate();
String checkinDateStr = DateTimeUtil.getDateByFormat(checkInDate, "yyyy-MM-dd");
String checkoutDateStr = DateTimeUtil.getDateByFormat(checkOutDate, "yyyy-MM-dd");
- DaylightReservationResponse daylightReservationByDlId =
- dlService.getDaylightReservationByDlId(bookings.getDlReservationId(), property.getDlPropertyId());
+// DaylightReservationResponse daylightReservationByDlId =
+// dlService.getDaylightReservationByDlId(bookings.getDlReservationId(), property.getDlPropertyId());
List exceptionDaylightViewList = exceptionDaylightViewDao.findByUserPropertyBookingTypeRoomType(
bookings.getCreatedBy(), bookings.getPropertyId(), bookings.getBookingTypeId(), bookings.getRoomTypeId()
);
@@ -6319,8 +6476,8 @@ public class BookingService {
if (CollectionUtils.isNotEmpty(exceptionDaylightViewList) || CollectionUtils.isNotEmpty(daylightViewList)) {
dlService.createDaylightCompRule(
- daylightReservationByDlId.getAccountId(),
- daylightReservationByDlId.getProfileId(),
+ bookings.getDlAccountId(),
+ bookings.getDlProfileId(),
property.getDlPropertyId(),
userId,
bookings.getRoom(),
@@ -6914,10 +7071,23 @@ public class BookingService {
String playerId) {
List bookingsViews = bookingViewDao.findDaylightDbRecord(playerId, checkinDate,checkoutDate);
List bookingDtos = bookingMapper.viewToBookingDtoList(bookingsViews);
+
+ Map propertiesMap = new HashMap<>();
+
Date currentTime = new Date();
for(BookingDto booking:bookingDtos){
+
+ Long propertyId = booking.getPropertyId();
+
+ if (!propertiesMap.containsKey(propertyId)) {
+ propertyDao.findById(propertyId).ifPresent(byId -> propertiesMap.put(propertyId, byId));
+ }
+
booking.setDataTime(currentTime);
}
+
+ bookingDtos.removeIf(item -> item.getPropertyId() != null && Objects.equals(propertiesMap.get(item.getPropertyId()).getDisplayType(), 0));
+
return bookingDtos;
}
}
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 f663d8e..67deba0 100644
--- a/src/main/java/com/mgm/mcrm/booking/services/WaitlistBookingService.java
+++ b/src/main/java/com/mgm/mcrm/booking/services/WaitlistBookingService.java
@@ -441,7 +441,7 @@ public class WaitlistBookingService {
email.setCreatedAt(creatdDate);
email.setCreatedBy(originBooking.getCreatedBy());
- email = sendEmailService.sendApprovalExtendEmail(originBooking, originBookingView,email,userId,userName,bookingView,isOtherOverBook,emailAddress.getKeyValues());
+ email = sendEmailService.sendApprovalExtendEmail(originBooking, originBookingView,email,userId,userName,bookingView,false,emailAddress.getKeyValues());
if(email.getStatus()==1) {
emailDao.save(email);
}
diff --git a/src/main/java/com/mgm/mcrm/common/dtos/EumnApprovalStatus.java b/src/main/java/com/mgm/mcrm/common/dtos/EumnApprovalStatus.java
index 0e61f31..64c4387 100644
--- a/src/main/java/com/mgm/mcrm/common/dtos/EumnApprovalStatus.java
+++ b/src/main/java/com/mgm/mcrm/common/dtos/EumnApprovalStatus.java
@@ -15,7 +15,11 @@ public enum EumnApprovalStatus {
WReject("Reject","WR"),
WApproved("Approved","WA"),
WReserved("Reserved","WF"),
- WCancelled("Cancelled","WC");
+ WCancelled("Cancelled","WC"),
+ AApproval("Approved","AA"),
+ ACancelled("Cancelled","AC"),
+ AReject("Reject","AR"),
+ APending("Pending","AP");
private String key;
private String value;
diff --git a/src/main/java/com/mgm/mcrm/common/services/MGMEsbApiService.java b/src/main/java/com/mgm/mcrm/common/services/MGMEsbApiService.java
index eaddacc..2e3b40a 100644
--- a/src/main/java/com/mgm/mcrm/common/services/MGMEsbApiService.java
+++ b/src/main/java/com/mgm/mcrm/common/services/MGMEsbApiService.java
@@ -2,6 +2,8 @@ package com.mgm.mcrm.common.services;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
+import com.mgm.mcrm.basesetting.property.models.CfgProperties;
+import com.mgm.mcrm.basesetting.property.repositories.PropertyDao;
import com.mgm.mcrm.booking.dtos.search.DateRange;
import com.mgm.mcrm.common.constants.SysCommon;
import com.mgm.mcrm.common.dtos.config.ApiGatewaySetting;
@@ -49,6 +51,20 @@ public class MGMEsbApiService {
@Autowired
private ApiGatewaySetting apiGatewaySetting;
+ @Autowired
+ private PropertyDao propertyDao;
+
+ /**
+ * 根据 property 解析 ESB 调用类型:DAYLIGHT 属性返回 1,其他返回 0
+ */
+ private int resolveTypeByProperty(String property) {
+ if (StringUtils.isBlank(property)) {
+ return 0;
+ }
+ CfgProperties properties = propertyDao.queryByName(property);
+ return (properties != null && "DAYLIGHT".equalsIgnoreCase(properties.getCategory())) ? 1 : 0;
+ }
+
public HttpResponseResult invokeRequestRoomCalendar(
String playerId,
@@ -125,7 +141,7 @@ public class MGMEsbApiService {
requestObj.put("roomCategory", roomCate);
requestObj.put("startDate", dates.getFirst());
requestObj.put("endDate", dates.getLast());
- result = this.invokeESBAPI(ESB_MCRM_API_TYPE, API_CHECK_PLAYER_TPD, requestObj, "GET", requestHeader, 1);
+ result = this.invokeESBAPI(ESB_MCRM_API_TYPE, API_CHECK_PLAYER_TPD, requestObj, "GET", requestHeader, resolveTypeByProperty(property));
return result;
}
@@ -142,7 +158,7 @@ public class MGMEsbApiService {
requestObj.put("UserId", userId);
- result = this.invokeESBAPI(ESB_MCRM_API_TYPE, API_GET_APPROVER, requestObj, "POST", requestHeader, 1);
+ result = this.invokeESBAPI(ESB_MCRM_API_TYPE, API_GET_APPROVER, requestObj, "POST", requestHeader, resolveTypeByProperty(property));
return result;
}
@@ -242,7 +258,7 @@ public class MGMEsbApiService {
requestObj.put("BookingType", bookingType);
requestObj.put("Property", property);
requestObj.put("DateRange", dateRange);
- result = this.invokeESBAPI(ESB_MCRM_API_TYPE, API_CHECK_SECOND_ROOM_TPD, requestObj, "POST", requestHeader);
+ result = this.invokeESBAPI(ESB_MCRM_API_TYPE, API_CHECK_SECOND_ROOM_TPD, requestObj, "POST", requestHeader, resolveTypeByProperty(property));
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 86ae4ce..ec06d6a 100644
--- a/src/main/java/com/mgm/mcrm/common/utils/DateTimeUtil.java
+++ b/src/main/java/com/mgm/mcrm/common/utils/DateTimeUtil.java
@@ -127,6 +127,14 @@ public class DateTimeUtil {
Date newTime = ca.getTime();
return newTime;
}
+
+ public static String addDay(Date currdate, Integer days, String strFormat) {
+ if (currdate == null || days == null) {
+ return null;
+ }
+ return getDateByFormat(addDay(currdate, days), strFormat);
+ }
+
public static Date addMonth(Date currdate,Integer months) {
Calendar ca = Calendar.getInstance();
ca.setTime(currdate);
diff --git a/src/main/java/com/mgm/mcrm/logging/repositories/SysBookingProfileMappingDao.java b/src/main/java/com/mgm/mcrm/logging/repositories/SysBookingProfileMappingDao.java
index c97bbd0..d8d2a05 100644
--- a/src/main/java/com/mgm/mcrm/logging/repositories/SysBookingProfileMappingDao.java
+++ b/src/main/java/com/mgm/mcrm/logging/repositories/SysBookingProfileMappingDao.java
@@ -1,6 +1,5 @@
package com.mgm.mcrm.logging.repositories;
-import com.mgm.mcrm.logging.models.SysBookingCacheLog;
import com.mgm.mcrm.logging.models.SysBookingProfileMapping;
import org.springframework.data.jpa.repository.JpaRepository;
diff --git a/src/main/java/com/mgm/mcrm/player/controllers/TodoController.java b/src/main/java/com/mgm/mcrm/player/controllers/TodoController.java
index 53eb14f..33a6572 100644
--- a/src/main/java/com/mgm/mcrm/player/controllers/TodoController.java
+++ b/src/main/java/com/mgm/mcrm/player/controllers/TodoController.java
@@ -137,8 +137,8 @@ public class TodoController {
String userId = loginUser.getLoginId();
String groupName = loginUser.getGroupName();
//--get group permissions
- boolean cancelBooking = true;
- List userPermissions = new ArrayList();
+ boolean cancelBooking = false;
+ List userPermissions;
userPermissions = sysGroupPermissionService.getRouterPermissionsByGroupName(groupName);
if(userPermissions!=null && !userPermissions.isEmpty()) {
for(SysRouterPermission per:userPermissions) {
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 6f8e9a8..c029ff5 100644
--- a/src/main/java/com/mgm/mcrm/player/services/TodoService.java
+++ b/src/main/java/com/mgm/mcrm/player/services/TodoService.java
@@ -898,8 +898,14 @@ public class TodoService {
errors = modifyBookingResponse;
booking.setUpdatedAt(newDate);
booking.setCreatedAt(newDate);
- booking.setApproveStatus("F");
- booking.setTryTime(5);
+ if (booking.getTryTime()==null){
+ booking.setTryTime(1);
+ } else if (booking.getTryTime()<4) {
+ booking.setTryTime(booking.getTryTime()+1);
+ } else {
+ booking.setTryTime(booking.getTryTime()+1);
+ booking.setApproveStatus("F");
+ }
booking.setErrorMessage("Cancel booking fail.Error Message [ " + errorMsg + " ] ");
bookingDao.save(booking);
processResult.setSuccess(false);
diff --git a/src/main/java/com/mgm/mcrm/roomcalendar/dtos/response/GetPropertyRoomTypeResponse.java b/src/main/java/com/mgm/mcrm/roomcalendar/dtos/response/GetPropertyRoomTypeResponse.java
index 6e026f9..4921b87 100644
--- a/src/main/java/com/mgm/mcrm/roomcalendar/dtos/response/GetPropertyRoomTypeResponse.java
+++ b/src/main/java/com/mgm/mcrm/roomcalendar/dtos/response/GetPropertyRoomTypeResponse.java
@@ -14,4 +14,5 @@ public class GetPropertyRoomTypeResponse {
private List defaultRoomTypes;
private List roomTypes;
private List otherProperties;
+ private String category;
}
diff --git a/src/main/java/com/mgm/mcrm/roomcalendar/services/RoomCalendarService.java b/src/main/java/com/mgm/mcrm/roomcalendar/services/RoomCalendarService.java
index c7c215f..db4e51c 100644
--- a/src/main/java/com/mgm/mcrm/roomcalendar/services/RoomCalendarService.java
+++ b/src/main/java/com/mgm/mcrm/roomcalendar/services/RoomCalendarService.java
@@ -41,6 +41,7 @@ public class RoomCalendarService {
String roomType;
String startDate;
String endDate;
+ String category = params.get("category").toString();
try {
playerId = getOptionalString(params, "playerId", "PlayerId");
@@ -67,7 +68,7 @@ public class RoomCalendarService {
return result;
}
- CalendarVisibilityCheck visibility = validateCalendarVisibility(property, roomType);
+ CalendarVisibilityCheck visibility = validateCalendarVisibility(property, roomType, category);
if (visibility.errorCode != null) {
result.setSuccess(false);
result.setMessage(visibility.errorMessage);
@@ -131,14 +132,14 @@ public class RoomCalendarService {
return result;
}
- private CalendarVisibilityCheck validateCalendarVisibility(String property, String roomType) {
+ private CalendarVisibilityCheck validateCalendarVisibility(String property, String roomType, String category) {
List propertyNames = parseDelimitedValues(property);
List roomTypeNames = parseDelimitedValues(roomType);
List properties = propertyDao.findByCalendarNameIn(propertyNames);
List visibleProperties = new ArrayList<>();
for (String propertyName : propertyNames) {
- CfgProperties cfgProperty = findByCalendarName(properties, propertyName);
+ CfgProperties cfgProperty = findByCalendarName(properties, propertyName, category);
if (isShowCalendar(cfgProperty)) {
visibleProperties.add(cfgProperty);
}
@@ -168,14 +169,14 @@ public class RoomCalendarService {
List otherIds = new ArrayList<>();
List otherCodes = new ArrayList<>();
for (CfgProperties cfgProperty : visibleProperties) {
- String category = cfgProperty.getCategory();
- if (StringUtils.equalsIgnoreCase(category, "OPERA")) {
+ String propertyCategory = cfgProperty.getCategory();
+ if (StringUtils.equalsIgnoreCase(propertyCategory, "OPERA")) {
operaIds.add(String.valueOf(cfgProperty.getId()));
operaCodes.add(cfgProperty.getCode());
- } else if (StringUtils.equalsIgnoreCase(category, "DAYLIGHT")) {
+ } else if (StringUtils.equalsIgnoreCase(propertyCategory, "DAYLIGHT")) {
daylightIds.add(String.valueOf(cfgProperty.getId()));
daylightCodes.add(cfgProperty.getCode());
- } else if (StringUtils.equalsIgnoreCase(category, "OTHER")) {
+ } else if (StringUtils.equalsIgnoreCase(propertyCategory, "OTHER")) {
otherIds.add(String.valueOf(cfgProperty.getId()));
otherCodes.add(cfgProperty.getCode());
}
@@ -232,19 +233,19 @@ public class RoomCalendarService {
String calendarName = StringUtils.defaultIfBlank(property.getCalendarName(), property.getName());
if (StringUtils.equalsIgnoreCase(property.getCategory(), "OPERA")
|| StringUtils.equalsIgnoreCase(property.getCategory(), "DAYLIGHT")) {
- propertyList.add(buildPropertyRoomTypeResponse(calendarName, calendarName, null, roomTypes));
+ propertyList.add(buildPropertyRoomTypeResponse(calendarName, calendarName, null, roomTypes, property.getCategory()));
} else if (StringUtils.equalsIgnoreCase(property.getCategory(), "OTHER")) {
otherProperties.add(buildPropertyRoomTypeResponse(
calendarName,
calendarName,
StringUtils.defaultIfBlank(property.getName(), property.getCalendarName()),
- roomTypes));
+ roomTypes, "OTHER"));
}
}
if (!otherProperties.isEmpty()) {
GetPropertyRoomTypeResponse otherGroup = buildPropertyRoomTypeResponse(
- "OTHER", "Other Property", null, new ArrayList<>());
+ "OTHER", "Other Property", null, new ArrayList<>(), "OTHER");
otherGroup.setDefaultRoomTypes(buildDefaultProperties(otherProperties));
otherGroup.setOtherProperties(otherProperties);
propertyList.add(otherGroup);
@@ -307,13 +308,14 @@ public class RoomCalendarService {
}
private static GetPropertyRoomTypeResponse buildPropertyRoomTypeResponse(
- String code, String name, String displayName, List roomTypes) {
+ String code, String name, String displayName, List roomTypes, String category) {
GetPropertyRoomTypeResponse item = new GetPropertyRoomTypeResponse();
item.setCode(StringUtils.defaultString(code));
item.setName(StringUtils.defaultString(name));
item.setDisplayName(displayName);
item.setRoomTypes(roomTypes);
item.setDefaultRoomTypes(buildDefaultRoomTypes(roomTypes));
+ item.setCategory(category);
return item;
}
@@ -388,8 +390,11 @@ public class RoomCalendarService {
return new ArrayList<>(visible);
}
- private static CfgProperties findByCalendarName(List properties, String name) {
+ private static CfgProperties findByCalendarName(List properties, String name, String category) {
for (CfgProperties property : properties) {
+ if (!property.getCategory().equals(category)) {
+ continue;
+ }
if (StringUtils.equals(property.getCalendarName(), name)) {
return property;
}
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index 90eeef0..d22c3cc 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -154,7 +154,7 @@ host_name: mcrm
adfs_request_timeout: 10000
adfs_login_timeout: 60000
-allow_origin: "http://localhost:5173,http://127.0.0.1:5173,http://localhost:8080,MGM_CRM_APP,MGM_CRM_CMS,https://localhost:9085,http://localhost:8081,http://127.0.0.1:8081,https://localhost:9087,https://localhost:9086,https://127.0.0.1:9086"
+allow_origin: "http://localhost:5173,http://127.0.0.1:5173,http://localhost:8080,MGM_CRM_APP,MGM_MCRM_APP,MGM_CRM_CMS,https://dlahcadev.mcmsapoc.com,https://localhost:9085,http://localhost:8081,http://127.0.0.1:8081,https://localhost:9087,https://localhost:9086,https://127.0.0.1:9086"
soap_servers: "http://localhost:5173,http://127.0.0.1:5173"
http_api_servers: "http://localhost:5173,http://127.0.0.1:5173,http://localhost:9087"
allow_ip: "0:0:0:0:0:0:0:1,127.0.0.1"