update
This commit is contained in:
@@ -34,7 +34,7 @@ import com.mgm.mcrm.common.dtos.BaseApiResponse;
|
||||
import com.mgm.mcrm.common.dtos.http_util.HttpResponseResult;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.*;
|
||||
import com.mgm.mcrm.common.services.HttpService;
|
||||
import com.mgm.mcrm.common.services.MGMApiService;
|
||||
import com.mgm.mcrm.common.services.MGMEsbApiService;
|
||||
import com.mgm.mcrm.common.utils.DateTimeUtil;
|
||||
import com.mgm.mcrm.common.utils.LogUtil;
|
||||
import com.mgm.mcrm.common.utils.SendEmail;
|
||||
@@ -67,7 +67,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class TodoService {
|
||||
|
||||
@Resource
|
||||
private MGMApiService mgmApiService;
|
||||
private MGMEsbApiService mgmEsbApiService;
|
||||
|
||||
@Resource
|
||||
private SysSettingService sysSettingService;
|
||||
@@ -129,7 +129,7 @@ public class TodoService {
|
||||
GetDashboardResponse result = new GetDashboardResponse();
|
||||
|
||||
try {
|
||||
HttpResponseResult httpResult = mgmApiService.invokeGetTodoDashboard(userId, 0);
|
||||
HttpResponseResult httpResult = mgmEsbApiService.invokeGetTodoDashboard(userId, 0);
|
||||
try {
|
||||
TodoDashboardResult resultObj = JSONObject.parseObject(httpResult.getResponseContent(), TodoDashboardResult.class, Feature.SupportNonPublicField, Feature.IgnoreNotMatch);
|
||||
if (Strings.CI.equals(resultObj.getStatusCode(), "OK")) {
|
||||
@@ -159,7 +159,7 @@ public class TodoService {
|
||||
public GetTodoDetailResponse getTodoDetail(String playerId, String todoCategory, String todoSegment, String date) throws Exception {
|
||||
GetTodoDetailResponse result = new GetTodoDetailResponse();
|
||||
try {
|
||||
HttpResponseResult httpResult = mgmApiService.invokeGetTodoDetail(playerId, todoCategory, todoSegment, date, 1);
|
||||
HttpResponseResult httpResult = mgmEsbApiService.invokeGetTodoDetail(playerId, todoCategory, todoSegment, date, 1);
|
||||
try {
|
||||
TodoDetailResult resultObj = JSONObject.parseObject(httpResult.getResponseContent(), TodoDetailResult.class, Feature.SupportNonPublicField, Feature.IgnoreNotMatch);
|
||||
if (Strings.CI.equals(resultObj.getStatusCode(), "OK")) {
|
||||
@@ -185,66 +185,74 @@ public class TodoService {
|
||||
if ("Inhouse".equalsIgnoreCase(todoCategory) || "Arrival".equalsIgnoreCase(todoCategory)) {
|
||||
Bookings bookings = bookingDao.findFirstByConfirmationNoAndPropertyIdIsNotNull(confNum);
|
||||
|
||||
CfgProperties property = propertyDao.findById(bookings.getPropertyId()).orElse(null);
|
||||
if (Objects.nonNull(bookings)) {
|
||||
CfgProperties property = propertyDao.findById(bookings.getPropertyId()).orElse(null);
|
||||
|
||||
if (Objects.nonNull(property)) {
|
||||
if (Objects.nonNull(property)) {
|
||||
|
||||
if ("Inhouse".equalsIgnoreCase(todoCategory)) {
|
||||
// Parse checkinDate from recordDesc (e.g., "Jun 25 – Jul 1 ...")
|
||||
LocalDate ciDate = null;
|
||||
try {
|
||||
String ciDatePart = recordDesc.split("–")[0].trim();
|
||||
// Use the year from the 'date' parameter
|
||||
int year = Integer.parseInt(date.substring(0, 4));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM d yyyy", Locale.US);
|
||||
ciDate = LocalDate.parse(ciDatePart + " " + year, formatter);
|
||||
} catch (Exception e) {
|
||||
LogUtil.warn(TodoService.class, "Parse checkinDate error: " + e.getMessage() + ", recordDesc: " + recordDesc);
|
||||
}
|
||||
|
||||
if (ciDate != null) {
|
||||
LocalDate today = LocalDate.now();
|
||||
if (ciDate.isAfter(today)) {
|
||||
// 当checkindate大于今天不用拿room number 和room ready
|
||||
continue;
|
||||
if ("Inhouse".equalsIgnoreCase(todoCategory)) {
|
||||
// Parse checkinDate from recordDesc (e.g., "Jun 25 – Jul 1 ...")
|
||||
LocalDate ciDate = null;
|
||||
try {
|
||||
String ciDatePart = recordDesc.split("–")[0].trim();
|
||||
// Use the year from the 'date' parameter
|
||||
int year = Integer.parseInt(date.substring(0, 4));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM d yyyy", Locale.US);
|
||||
ciDate = LocalDate.parse(ciDatePart + " " + year, formatter);
|
||||
} catch (Exception e) {
|
||||
LogUtil.warn(TodoService.class, "Parse checkinDate error: " + e.getMessage() + ", recordDesc: " + recordDesc);
|
||||
}
|
||||
|
||||
BaseApiResponse<ReservationDoorKeyResponse> doorKeyResult =
|
||||
dlService.getReservationDoorKeyByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationDoorKeyResponse doorKeyData = doorKeyResult.getData();
|
||||
|
||||
if (doorKeyResult.isSuccess() && doorKeyData != null) {
|
||||
String replaceStr = "Conf#" + confNum;
|
||||
if (StringUtils.isNotBlank(doorKeyData.getRoomNumber())) {
|
||||
detailRecord.setRoomNumber(doorKeyData.getRoomNumber());
|
||||
replaceStr += " [Rm #" + doorKeyData.getRoomNumber() + "]";
|
||||
if (ciDate != null) {
|
||||
LocalDate today = LocalDate.now();
|
||||
if (ciDate.isAfter(today)) {
|
||||
// 当checkindate大于今天不用拿room number 和room ready
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ciDate.isEqual(today)) {
|
||||
// 当今天的时候要检查room ready
|
||||
boolean isRoomReady = StringUtils.isNotBlank(doorKeyData.getId())
|
||||
&& !doorKeyData.isHasKey();
|
||||
if (isRoomReady) {
|
||||
replaceStr += " [Rm Ready]";
|
||||
BaseApiResponse<ReservationDoorKeyResponse> doorKeyResult =
|
||||
dlService.getReservationDoorKeyByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationDoorKeyResponse doorKeyData = doorKeyResult.getData();
|
||||
|
||||
if (doorKeyResult.isSuccess() && doorKeyData != null) {
|
||||
String replaceStr = "Conf#" + confNum;
|
||||
if (StringUtils.isNotBlank(doorKeyData.getRoomNumber())) {
|
||||
detailRecord.setRoomNumber(doorKeyData.getRoomNumber());
|
||||
replaceStr += " [Rm #" + doorKeyData.getRoomNumber() + "]";
|
||||
}
|
||||
|
||||
if (ciDate.isEqual(today)) {
|
||||
// 当今天的时候要检查room ready
|
||||
boolean isRoomReady = StringUtils.isNotBlank(doorKeyData.getId())
|
||||
&& !doorKeyData.isHasKey();
|
||||
if (isRoomReady) {
|
||||
replaceStr += " [Rm Ready]";
|
||||
}
|
||||
}
|
||||
|
||||
if (!replaceStr.equals("Conf#" + confNum)) {
|
||||
detailRecord.setItemRecordDescription(recordDesc.replace("Conf#" + confNum, replaceStr));
|
||||
}
|
||||
}
|
||||
|
||||
if (!replaceStr.equals("Conf#" + confNum)) {
|
||||
detailRecord.setItemRecordDescription(recordDesc.replace("Conf#" + confNum, replaceStr));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
BaseApiResponse<ReservationQueueResponse> queueResult =
|
||||
dlService.getReservationQueueByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationQueueResponse queueData = queueResult.getData();
|
||||
boolean isQueue = queueResult.isSuccess()
|
||||
&& queueData != null
|
||||
&& queueData.isQueue();
|
||||
if (isQueue) {
|
||||
detailRecord.setItemRecordDescription(recordDesc.replace("Conf#" + confNum, "Conf#" + confNum + " [In Queue]"));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
BaseApiResponse<ReservationQueueResponse> queueResult =
|
||||
dlService.getReservationQueueByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationQueueResponse queueData = queueResult.getData();
|
||||
boolean isQueue = queueResult.isSuccess()
|
||||
&& queueData != null
|
||||
&& queueData.isQueue();
|
||||
if (isQueue) {
|
||||
detailRecord.setItemRecordDescription(recordDesc.replace("Conf#" + confNum, "Conf#" + confNum + " [In Queue]"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// result.setSuccess(false);
|
||||
// result.setErrorCode("BOOKING NOT FOUND");
|
||||
// result.setErrorMessage("BOOKING NOT FOUND");
|
||||
// LogUtil.warn(TodoService.class, "[GetTodoDetail] BOOKING NOT FOUND");
|
||||
// return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,7 +483,7 @@ public class TodoService {
|
||||
HttpResponseResult httpResult;
|
||||
try {
|
||||
// TODO 这里现在写死只拿daylight的todolist,后面会要拿到Opera的todoList,这个时候要改成两个都拿 by Mauve
|
||||
httpResult = mgmApiService.invokeGetTodoList(userId, category, type, startDate, endDate, 1);
|
||||
httpResult = mgmEsbApiService.invokeGetTodoList(userId, category, type, startDate, endDate, 1);
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setCode("INVOKE_TODOLISTDETAIL_API_ERROR");
|
||||
@@ -534,31 +542,34 @@ public class TodoService {
|
||||
|
||||
if (StringUtils.isNotBlank(confNum)) {
|
||||
if ("Inhouse".equalsIgnoreCase(category) || "Arrival".equalsIgnoreCase(category)) {
|
||||
List<CfgProperties> daylightProperties = propertyDao.findByCategory("DAYLIGHT");
|
||||
if (CollectionUtils.isNotEmpty(daylightProperties)) {
|
||||
CfgProperties property = daylightProperties.get(0);
|
||||
if ("Inhouse".equalsIgnoreCase(category)) {
|
||||
BaseApiResponse<ReservationDoorKeyResponse> doorKeyResult =
|
||||
dlService.getReservationDoorKeyByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationDoorKeyResponse doorKeyData = doorKeyResult.getData();
|
||||
boolean isRoomReady = doorKeyResult.isSuccess()
|
||||
&& doorKeyData != null
|
||||
&& StringUtils.isNotBlank(doorKeyData.getId())
|
||||
&& !doorKeyData.isHasKey();
|
||||
if (isRoomReady) {
|
||||
record.setRoomReady(true);
|
||||
updateTodoRecordDescription(record, confNum, "[Rm Ready]");
|
||||
}
|
||||
} else {
|
||||
BaseApiResponse<ReservationQueueResponse> queueResult =
|
||||
dlService.getReservationQueueByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationQueueResponse queueData = queueResult.getData();
|
||||
boolean isQueue = queueResult.isSuccess()
|
||||
&& queueData != null
|
||||
&& queueData.isQueue();
|
||||
if (isQueue) {
|
||||
record.setIsQueue(true);
|
||||
updateTodoRecordDescription(record, confNum, "[In Queue]");
|
||||
Bookings bookings = bookingDao.findFirstByConfirmationNoAndPropertyIdIsNotNull(confNum);
|
||||
|
||||
if (Objects.nonNull(bookings)) {
|
||||
CfgProperties property = propertyDao.findById(bookings.getPropertyId()).orElse(null);
|
||||
if (Objects.nonNull(property)) {
|
||||
if ("Inhouse".equalsIgnoreCase(category)) {
|
||||
BaseApiResponse<ReservationDoorKeyResponse> doorKeyResult =
|
||||
dlService.getReservationDoorKeyByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationDoorKeyResponse doorKeyData = doorKeyResult.getData();
|
||||
boolean isRoomReady = doorKeyResult.isSuccess()
|
||||
&& doorKeyData != null
|
||||
&& StringUtils.isNotBlank(doorKeyData.getId())
|
||||
&& !doorKeyData.isHasKey();
|
||||
if (isRoomReady) {
|
||||
record.setRoomReady(true);
|
||||
updateTodoRecordDescription(record, confNum, "[Rm Ready]");
|
||||
}
|
||||
} else {
|
||||
BaseApiResponse<ReservationQueueResponse> queueResult =
|
||||
dlService.getReservationQueueByConfirmationNumber(property.getDlPropertyId(), confNum);
|
||||
ReservationQueueResponse queueData = queueResult.getData();
|
||||
boolean isQueue = queueResult.isSuccess()
|
||||
&& queueData != null
|
||||
&& queueData.isQueue();
|
||||
if (isQueue) {
|
||||
record.setIsQueue(true);
|
||||
updateTodoRecordDescription(record, confNum, "[In Queue]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user