This commit is contained in:
Mauve
2026-09-28 10:28:04 +08:00
parent 5ad104bdd7
commit 3b6f0495a3
94 changed files with 2941 additions and 2975 deletions
@@ -50,11 +50,12 @@ import com.mgm.mcrm.common.dtos.BaseApiResponse;
import com.mgm.mcrm.common.dtos.EumnApprovalStatus;
import com.mgm.mcrm.common.dtos.http_util.HttpResponseResult;
import com.mgm.mcrm.common.dtos.mgm_api.ApprovalGamingDataResult;
import com.mgm.mcrm.common.dtos.mgm_api.ApproverRecordResult;
import com.mgm.mcrm.common.dtos.mgm_api.ApproverResult;
import com.mgm.mcrm.common.dtos.mgm_api.PlayerProfileEntry;
import com.mgm.mcrm.common.dtos.mgm_api.UserInfoApiRecord;
import com.mgm.mcrm.common.jms.BookingControlMsgSender;
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;
@@ -63,6 +64,7 @@ import com.mgm.mcrm.logging.repositories.SysLogBookingDao;
import com.mgm.mcrm.logging.services.SysLogBookingService;
import com.mgm.mcrm.notification.models.Email;
import com.mgm.mcrm.notification.repositories.EmailDao;
import com.mgm.mcrm.player.dtos.request.TodoChangeDateRequest;
import com.mgm.mcrm.player.services.PlayerService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
@@ -100,7 +102,7 @@ public class ApprovalService {
@Resource
private RequestReasonDao requestReasonDao;
@Resource
private MGMApiService mgmApiService;
private MGMEsbApiService mgmEsbApiService;
@Resource
private PropertyDao propertyDao;
@Resource
@@ -188,9 +190,11 @@ public class ApprovalService {
}
try {
HttpResponseResult httpResult = mgmApiService.invokeGetApprover(playerId,bookingType,propertyName,roomCategory,checkInDate,checkOutDate,userId);
HttpResponseResult httpResult = mgmEsbApiService.invokeGetApprover(playerId,bookingType,propertyName,roomCategory,checkInDate,checkOutDate,userId);
try {
JSONObject rawResult = JSONObject.parseObject(httpResult.getResponseContent());
ApproverResult resultObj = JSONObject.parseObject(httpResult.getResponseContent(), ApproverResult.class, Feature.SupportNonPublicField,Feature.IgnoreNotMatch);
fillApproverListFromRawJson(resultObj, rawResult);
if(Strings.CS.equals(resultObj.getStatusCode(), "OK")) {
if (resultObj.getRecords() != null && !resultObj.getRecords().isEmpty()) {
response.setSuccess(true);
@@ -222,11 +226,39 @@ public class ApprovalService {
return response;
}
private void fillApproverListFromRawJson(ApproverResult resultObj, JSONObject rawResult) {
if (resultObj == null || resultObj.getRecords() == null || rawResult == null) {
return;
}
JSONArray rawRecords = rawResult.getJSONArray("Records");
if (rawRecords == null) {
return;
}
List<ApproverRecordResult> records = resultObj.getRecords();
int size = Math.min(records.size(), rawRecords.size());
for (int i = 0; i < size; i++) {
JSONObject rawRecord = rawRecords.getJSONObject(i);
if (rawRecord == null) {
continue;
}
records.get(i).setApproverList(rawRecord.get("ApproverList"));
}
}
public BaseApiResponse<ApprovalGamingDataResult> getApprovalData(String bookingId) throws Exception {
BaseApiResponse<ApprovalGamingDataResult> response = new BaseApiResponse<>();
ApprovalGamingDataResult approvalGamingData = new ApprovalGamingDataResult();
ApprovalGamingDataResult approvalGamingData;
try {
HttpResponseResult httpResult = mgmApiService.invokeGetApprovalData(bookingId);
// String bookingCategory = bookingDao.findCategoryById(Long.valueOf(bookingId));
// HttpResponseResult httpResult;
// if ("DAYLIGHT".equalsIgnoreCase(bookingCategory)) {
// httpResult = mgmApiService.invokeGetApprovalData(bookingId, 1);
// } else {
// httpResult = mgmApiService.invokeGetApprovalData(bookingId, 0);
// }
HttpResponseResult httpResult = mgmEsbApiService.invokeGetApprovalData(bookingId, 1);
try {
approvalGamingData = JSONObject.parseObject(httpResult.getResponseContent(), ApprovalGamingDataResult.class, Feature.SupportNonPublicField,Feature.IgnoreNotMatch);
if(StringUtils.equalsIgnoreCase(approvalGamingData.getStatusCode(),"OK")) {
@@ -722,7 +754,7 @@ public class ApprovalService {
LogUtil.info(ApprovalService.class,"Submit Approval.UserId:"+userId);
//相同 处理approvalRouting记录 并调用 Call OWS createbooking
approvalRouting.setBookingStatus("AA");
CfgApprovalRouting changeRecord = approvalRoutingDao.save(approvalRouting);
approvalRoutingDao.save(approvalRouting);
//处理Pending Approval Booking 记录
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -791,8 +823,14 @@ public class ApprovalService {
// 获取Property
CfgProperties properties = propertyDao.findById(originBooking.getPropertyId()).orElse(null);
Boolean isOverBook = this.checkIsOverbook(bookingView.getRoomId(), bookingView.getCheckinDate(),
bookingView.getCheckoutDate(), bookingView.getPropertyId(), bookingView.getBlockId());
Boolean isOverBook;
if ("DAYLIGHT".equalsIgnoreCase(bookingView.getPropertyCategory())) {
isOverBook = false;
} else {
isOverBook = this.checkIsOverbook(bookingView.getRoomId(), bookingView.getCheckinDate(),
bookingView.getCheckoutDate(), bookingView.getPropertyId(), bookingView.getBlockId());
}
Boolean isOtherOverBook = this.checkOtherIsOverbook(Math.toIntExact(originBooking.getRoomId()), originBooking.getCheckoutDate(),
originBooking.getCheckinDate(), originBooking.getPropertyId(), originBooking.getSegmentId());
@@ -812,6 +850,7 @@ public class ApprovalService {
// BookingsView 中 roomId/blockId 为 Long,Bookings 为 Integer,copyProperties 会跳过;View 无 bookingTypeId
newBooking.setApprovalBookingId(String.valueOf(originBooking.getId()));
newBooking.setCategory("OPERA");
if (originBookingView.getRoomId() != null) {
newBooking.setRoomId(originBookingView.getRoomId());
@@ -850,6 +889,7 @@ public class ApprovalService {
newBooking.setApprovalBookingId(String.valueOf(originBooking.getId()));
newBooking.setDateList(originBooking.getDateList());
newBooking.setMember(originBooking.getMember());
newBooking.setCategory("DAYLIGHT");
if (originBookingView.getRoomId() != null) {
newBooking.setRoomId(originBookingView.getRoomId());
@@ -889,6 +929,7 @@ public class ApprovalService {
email.setBookId(originBooking.getId());
email.setCreatedAt(creatdDate);
email.setCreatedBy(originBooking.getCreatedBy());
emailBook.setCategory("OTHER");
email = SendEmail.sendApprovalNewEmail(emailBook, originBookingView,email,userId,userName,true,false,emailAddress.getKeyValues());
if(email.getStatus()==1) {
originBooking.setApproveStatus("AA");
@@ -905,6 +946,7 @@ public class ApprovalService {
newBooking.setLastOperaStatus("PENDING");
newBooking.setApprovedBy(userName);
newBooking.setApprovedId(Long.valueOf(userId));
newBooking.setCategory("OTHER");
//获取other room status
CfgOtherRoomStatus roomStatus = roomStatusDao.findByStatusName("Pending");
if(roomStatus!=null) {
@@ -960,6 +1002,35 @@ public class ApprovalService {
response.setLogMessage("Send Email Failed");
response.setMessage("Send Email Failed");
}
}else if (Strings.CS.equals(properties.getCategory(),"DAYLIGHT")) {
//调用daylight接口去Extend Booking
BaseApiResponse<PlayerProfileEntry> findPlayerResult = playerService.findPlayerProfileByPlayerIdAndUserId(originBooking.getPlayerId(), userId);
if(findPlayerResult.isSuccess()) {
originBooking.setApproveStatus("AA");
bookingDao.save(originBooking);
}else{
response.setSuccess(false);
response.setCode("Player Profile Not Found");
}
//Directly send email when submit Approval Routing for daylight
BookingsView originBookingView = bookingViewDao.findById(Long.parseLong(originBooking.getApprovalBookingId()));
originBookingView = this.getEmailInfo(originBookingView,originBookingView.getCreatedBy()).getData();
Email email = new Email();
email.setBookId(originBooking.getId());
email.setCreatedAt(creatdDate);
email.setCreatedBy(originBooking.getCreatedBy());
email = SendEmail.sendApprovalExtendEmail(originBooking, originBookingView,email,userId,userName,bookingView,isOtherOverBook,emailAddress.getKeyValues());
if(email.getStatus()==1) {
emailDao.save(email);
response.setSuccess(true);
response.setData(approvalMapper.toSubmitApprovalResponse(originBooking));
}else{
response.setSuccess(false);
response.setMessage("Send Email Failed");
response.setLogMessage("Send Email Failed");
}
}else{
//send email instead of sync other booking
BookingsView originBookingView = bookingViewDao.findById(Long.parseLong(originBooking.getApprovalBookingId()));