init
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
package com.mgm.mcrm.player.controllers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.mgm.mcrm.authorization.dtos.LoginUserInfo;
|
||||
import com.mgm.mcrm.booking.dtos.search.CheckSecondTPDRequest;
|
||||
import com.mgm.mcrm.booking.dtos.search.CheckTPDRequest;
|
||||
import com.mgm.mcrm.booking.dtos.search.DateRange;
|
||||
import com.mgm.mcrm.common.constants.SysCommon;
|
||||
import com.mgm.mcrm.common.dtos.BaseApiResponse;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.PlayerTPDApiResult;
|
||||
import com.mgm.mcrm.player.dtos.request.WebCheckPlayerTPDRequest;
|
||||
import com.mgm.mcrm.player.dtos.request.WebPlayerLookupRequest;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.PlayerProfileEntry;
|
||||
import com.mgm.mcrm.player.services.PlayerService;
|
||||
import com.mgm.mcrm.appsetting.services.SysSettingService;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("/api")
|
||||
public class PlayerController {
|
||||
|
||||
@Resource
|
||||
private PlayerService playerService;
|
||||
|
||||
@Resource
|
||||
private SysSettingService sysSettingService;
|
||||
|
||||
@RequestMapping(value = "/app/mgm/player_lookup", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public BaseApiResponse<PlayerProfileEntry> getPlayerProfileByPlayerId(HttpServletRequest request, @RequestBody(required=false) Map<String,String> params) {
|
||||
String playerId = params.get("playerId");
|
||||
// String userId = params.get("userId");
|
||||
String token = request.getHeader("Authorization");
|
||||
String userId = JWT.decode(token).getClaim("login_id").asString();
|
||||
|
||||
if(StringUtils.isNotEmpty(userId)) {
|
||||
userId = Strings.CS.replace(userId, "@mgm.mo", "");
|
||||
}
|
||||
|
||||
BaseApiResponse<PlayerProfileEntry> result = playerService.findPlayerProfileByPlayerIdAndUserId(playerId, userId);
|
||||
//result = AjaxResultMockup.mockupResult("\\mockup\\app\\playerProfile.json");
|
||||
if(result.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setData(result.getData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setMessage(result.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/mgm/check_tpd_by_playerId_room_dates", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<PlayerTPDApiResult>> checkTPDByPlayerIdAndRoomCatAndDates(HttpServletRequest request,
|
||||
@RequestBody(required=true) CheckTPDRequest params) {
|
||||
String playerId = params.getPlayerId();
|
||||
String roomCat = params.getRoomCat();
|
||||
String bookingType = params.getBookingType();
|
||||
String property = params.getProperty();
|
||||
List<String> dates = params.getDates();
|
||||
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
|
||||
BaseApiResponse<PlayerTPDApiResult> result = new BaseApiResponse<>();
|
||||
BaseApiResponse<PlayerTPDApiResult> checkTPDResult = new BaseApiResponse<>();
|
||||
String userId = loginUser.getLoginId();
|
||||
BaseApiResponse<PlayerProfileEntry> findPlayerResult = playerService.findPlayerProfileByPlayerIdAndUserId(playerId, userId);
|
||||
if(findPlayerResult.isSuccess()) {
|
||||
PlayerProfileEntry profile = findPlayerResult.getData();
|
||||
Integer code = profile.getCodedFlag();
|
||||
if(code==1) {
|
||||
checkTPDResult = playerService.checkTPDByPlayerIdAndRoomAndDates(playerId,roomCat,dates,bookingType,property);
|
||||
result.setMessage(checkTPDResult.getMessage());
|
||||
}else {
|
||||
result.setMessage("No permission to view");
|
||||
}
|
||||
}else {
|
||||
result.setMessage(findPlayerResult.getMessage());
|
||||
}
|
||||
|
||||
//result = AjaxResultMockup.mockupResult("\\mockup\\app\\playerProfile.json");
|
||||
if(checkTPDResult.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setData(checkTPDResult.getData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/mgm/check_second_tpd_by_playerId_room_dates", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<PlayerTPDApiResult>> checkSecondRoomTPDByPlayerIdAndRoomCatAndDates(HttpServletRequest request,
|
||||
@RequestBody(required=true) CheckSecondTPDRequest params) {
|
||||
String playerId = params.getPlayerId();
|
||||
String roomCat = params.getRoomCat();
|
||||
String bookingType = params.getBookingType();
|
||||
String property = params.getProperty();
|
||||
List<String> dates = params.getDates();
|
||||
List<DateRange> dateRange = params.getDateRange();
|
||||
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
|
||||
String userId = loginUser.getLoginId();
|
||||
|
||||
boolean isMock = sysSettingService.isAPPMock();
|
||||
BaseApiResponse<PlayerTPDApiResult> result = new BaseApiResponse<>();
|
||||
BaseApiResponse<PlayerTPDApiResult> checkTPDResult = new BaseApiResponse<>();
|
||||
BaseApiResponse<PlayerProfileEntry> findPlayerResult = playerService.findPlayerProfileByPlayerIdAndUserId(playerId, userId);
|
||||
if(findPlayerResult.isSuccess()) {
|
||||
PlayerProfileEntry profile = findPlayerResult.getData();
|
||||
Integer code = profile.getCodedFlag();
|
||||
if(code==1) {
|
||||
if(isMock) {
|
||||
checkTPDResult = playerService.checkTPDByPlayerIdAndRoomAndDates(playerId,roomCat,dates,bookingType,property);
|
||||
}else {
|
||||
checkTPDResult = playerService.checkSecondTPDByPlayerIdAndRoomAndDates(playerId, roomCat, dateRange, dates, bookingType,property);
|
||||
}
|
||||
result.setMessage(checkTPDResult.getMessage());
|
||||
}else {
|
||||
result.setMessage("No permission to view");
|
||||
}
|
||||
}else {
|
||||
result.setMessage(findPlayerResult.getMessage());
|
||||
}
|
||||
|
||||
if(checkTPDResult.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setData(checkTPDResult.getData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/web/player/lookup", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<PlayerProfileEntry>> lookupPlayer(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody WebPlayerLookupRequest params) throws Exception {
|
||||
BaseApiResponse<PlayerProfileEntry> processResult = new BaseApiResponse<>();
|
||||
String playerId = params.getPlayerId();
|
||||
String userId = params.getUserId();
|
||||
|
||||
if (StringUtils.isEmpty(playerId)) {
|
||||
response.sendError(422, "Miss parameter player_id");
|
||||
return null;
|
||||
}
|
||||
if(StringUtils.isNotEmpty(userId)) {
|
||||
userId = userId.replace("@mgm.mo", "");
|
||||
}
|
||||
BaseApiResponse<PlayerProfileEntry> serviceResult = playerService.findWebPlayerProfileByPlayerId(playerId);
|
||||
if(serviceResult.isSuccess()) {
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(serviceResult.getData());
|
||||
}else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setMessage(serviceResult.getMessage());
|
||||
}
|
||||
//--
|
||||
return ResponseEntity.status(HttpStatus.OK).body(processResult);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/web/mgm/check_tpd_by_playerId_room_dates", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<PlayerTPDApiResult>> checkFirstRoomCriteria(HttpServletRequest request,
|
||||
@RequestBody WebCheckPlayerTPDRequest params) {
|
||||
String playerId = params.getPlayerId();
|
||||
String roomCat = params.getRoomCat();
|
||||
String bookingType = params.getBookingType();
|
||||
String property = params.getProperty();
|
||||
List<String> dates = params.getDates();
|
||||
|
||||
BaseApiResponse<PlayerTPDApiResult> result = playerService.checkTPDByPlayerIdAndRoomAndDates(playerId, roomCat,dates, bookingType, property);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/web/mgm/check_second_tpd_by_playerId_room_dates", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<PlayerTPDApiResult>> checkSecondRoomCriteria(HttpServletRequest request,
|
||||
@RequestBody WebCheckPlayerTPDRequest params) {
|
||||
String playerId = params.getPlayerId();
|
||||
String roomCat = params.getRoomCat();
|
||||
String bookingType = params.getBookingType();
|
||||
String property = params.getProperty();
|
||||
List<String> dates = params.getDates();
|
||||
List<DateRange> dateRange = params.getDateRange();
|
||||
|
||||
boolean isMock = sysSettingService.isAPPMock();
|
||||
BaseApiResponse<PlayerTPDApiResult> result = new BaseApiResponse<>();
|
||||
if(isMock) {
|
||||
result = playerService.checkTPDByPlayerIdAndRoomAndDates(playerId, roomCat, dates, bookingType, property);
|
||||
}else {
|
||||
result = playerService.checkSecondTPDByPlayerIdAndRoomAndDates(playerId, roomCat, dateRange, dates, bookingType, property);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package com.mgm.mcrm.player.controllers;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mgm.mcrm.authorization.dtos.LoginUserInfo;
|
||||
import com.mgm.mcrm.authorization.models.SysRouterPermission;
|
||||
import com.mgm.mcrm.authorization.services.SysGroupPermissionService;
|
||||
import com.mgm.mcrm.booking.dtos.BookingDto;
|
||||
import com.mgm.mcrm.booking.models.Bookings;
|
||||
import com.mgm.mcrm.common.constants.SysCommon;
|
||||
import com.mgm.mcrm.common.dtos.BaseApiResponse;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.TodoDashboardResult;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.TodoDateListResult;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.TodoDetailResult;
|
||||
import com.mgm.mcrm.logging.models.SysLogETA;
|
||||
import com.mgm.mcrm.player.dtos.request.*;
|
||||
import com.mgm.mcrm.player.dtos.response.GetDashboardResponse;
|
||||
import com.mgm.mcrm.player.dtos.response.GetTodoDetailResponse;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.PlayerProfileEntry;
|
||||
import com.mgm.mcrm.player.services.PlayerService;
|
||||
import com.mgm.mcrm.player.services.TodoService;
|
||||
import com.mgm.mcrm.logging.services.SysLogETAService;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("/api")
|
||||
public class TodoController {
|
||||
|
||||
@Resource
|
||||
private TodoService todoService;
|
||||
|
||||
@Resource
|
||||
private PlayerService playerService;
|
||||
|
||||
@Resource
|
||||
private SysLogETAService sysLogETAService;
|
||||
|
||||
@Resource
|
||||
private SysGroupPermissionService sysGroupPermissionService;
|
||||
|
||||
@RequestMapping(value = "/app/todo/get_dashboard_data", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<TodoDashboardResult>> getTodoDashboard(HttpServletRequest request, @RequestBody GetDashboardRequest getDashboardRequest) throws Exception {
|
||||
|
||||
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
|
||||
String userId = loginUser.getLoginId();
|
||||
String groupName = loginUser.getGroupName();
|
||||
|
||||
BaseApiResponse<TodoDashboardResult> result = new BaseApiResponse<>();
|
||||
boolean viewTodoDashboard = sysGroupPermissionService.checkGroupPermission(groupName, "10001_04");
|
||||
viewTodoDashboard = true;
|
||||
if(viewTodoDashboard) {
|
||||
GetDashboardResponse getDashboardResponse = todoService.getTodoDashboard(userId);
|
||||
if(getDashboardResponse.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setData(getDashboardResponse.getReturnData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setMessage(getDashboardResponse.getErrorMessage());
|
||||
result.setCode(getDashboardResponse.getErrorCode());
|
||||
}
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode("NO_PERMISSION");
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/todo/get_todolist_details", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<TodoDetailResult>> getTodoDetail(HttpServletRequest request, @RequestBody GetTodoDetailRequest getTodoDetailRequest) throws Exception {
|
||||
String playerId = getTodoDetailRequest.getPlayerId();
|
||||
String todoSegment = getTodoDetailRequest.getTodosegment();
|
||||
String todoCategory = getTodoDetailRequest.getTodoCategory();
|
||||
String date = getTodoDetailRequest.getDate();
|
||||
date = date.split("T")[0];
|
||||
|
||||
BaseApiResponse<TodoDetailResult> result = new BaseApiResponse<>();
|
||||
|
||||
GetTodoDetailResponse getTodoDetailResponse = todoService.getTodoDetail(playerId,todoCategory,todoSegment,date);
|
||||
if(getTodoDetailResponse.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setData(getTodoDetailResponse.getReturnData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode(getTodoDetailResponse.getErrorCode());
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/todo/get_todolist", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<TodoDateListResult>> getTodoList(HttpServletRequest request, @RequestBody GetTodoListRequest params) throws Exception {
|
||||
|
||||
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
|
||||
String type = params.getTodoSegment();
|
||||
String category = params.getTodoCategory();
|
||||
Date startDate = Date.valueOf(params.getStartDate());
|
||||
Date endDate = Date.valueOf(params.getEndDate());
|
||||
|
||||
String userId = loginUser.getLoginId();
|
||||
String groupName = loginUser.getGroupName();
|
||||
boolean viewTodoList = sysGroupPermissionService.checkGroupPermission(groupName, "10001_03");
|
||||
|
||||
BaseApiResponse<TodoDateListResult> result = new BaseApiResponse<>();
|
||||
viewTodoList = true;
|
||||
if(viewTodoList) {
|
||||
BaseApiResponse<TodoDateListResult> serviceResult = todoService.getTodoList(userId,category,type,startDate,endDate);
|
||||
if(serviceResult.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setData(serviceResult.getData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode(serviceResult.getCode());
|
||||
}
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode("NO_PERMISSION");
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/todo/change_date", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<BookingDto>> changeDate(HttpServletRequest request, @RequestBody TodoChangeDateRequest bookingParams) throws Exception {
|
||||
BaseApiResponse<BookingDto> result = new BaseApiResponse<>();
|
||||
result.setRequestData(bookingParams);
|
||||
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
|
||||
String userId = loginUser.getLoginId();
|
||||
String groupName = loginUser.getGroupName();
|
||||
//--get group permissions
|
||||
boolean cancelBooking = true;
|
||||
List<SysRouterPermission> userPermissions = new ArrayList<SysRouterPermission>();
|
||||
userPermissions = sysGroupPermissionService.getRouterPermissionsByGroupName(groupName);
|
||||
if(userPermissions!=null && !userPermissions.isEmpty()) {
|
||||
for(SysRouterPermission per:userPermissions) {
|
||||
if(Strings.CS.equals(per.getId(), "10001_02") ) cancelBooking = true;
|
||||
}
|
||||
}
|
||||
String playerId = bookingParams.getPlayerId()!=null? bookingParams.getPlayerId():null;
|
||||
BaseApiResponse<PlayerProfileEntry> findPlayerProfileResult = playerService.findPlayerProfileByPlayerIdAndUserId(playerId, userId);
|
||||
if(findPlayerProfileResult.isSuccess()) {
|
||||
PlayerProfileEntry profile = findPlayerProfileResult.getData();
|
||||
Integer code = profile.getCodedFlag();
|
||||
if(code==1 && cancelBooking) {
|
||||
BaseApiResponse<BookingDto> changeDateResult = todoService.changeBookingDate(bookingParams,request);
|
||||
if(changeDateResult.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setMessage(!StringUtils.isEmpty(changeDateResult.getMessage())?changeDateResult.getMessage():"Edit Success");
|
||||
result.setData(changeDateResult.getData());
|
||||
result.setRequestData(changeDateResult.getData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setMessage(changeDateResult.getMessage());
|
||||
result.setCode(changeDateResult.getCode());
|
||||
}
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode("NO_PERMISSION");
|
||||
result.setMessage("No permission to cancel");
|
||||
}
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode("CALL_API_ERROR");
|
||||
result.setMessage(findPlayerProfileResult.getMessage());
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/todo/submit_ETA", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<Bookings>> submitETA(HttpServletRequest request,
|
||||
@RequestBody TodoSubmitETARequest params) throws Exception {
|
||||
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
|
||||
String userId = loginUser.getLoginId();
|
||||
String playerId = params.getPlayerId();
|
||||
String etaTime = params.getEtaTime();
|
||||
Long id = params.getId();
|
||||
List<EtaRecordInfo> recordInfos = params.getRecordInfo();
|
||||
BaseApiResponse<Bookings> result = new BaseApiResponse<>();
|
||||
|
||||
if(StringUtils.isNotEmpty(etaTime)) {
|
||||
// 18:34 -> 18:34:00
|
||||
// 18:34:00 -> 18:34:00
|
||||
String[] split = etaTime.split(":");
|
||||
if (split.length < 3) {
|
||||
etaTime = etaTime + ":00";
|
||||
} else {
|
||||
etaTime = split[0] + ":" + split[1] + ":" + split[2];
|
||||
}
|
||||
}
|
||||
BaseApiResponse<Bookings> submitResult = todoService.submitETA(etaTime, recordInfos, id);
|
||||
|
||||
SysLogETA sysLogETA = new SysLogETA();
|
||||
java.util.Date now = new java.util.Date();
|
||||
|
||||
if(submitResult.isSuccess()) {
|
||||
sysLogETA.setStatus(1);
|
||||
result.setSuccess(true);
|
||||
// result.setData(submitResult.getData());
|
||||
}else {
|
||||
sysLogETA.setStatus(0);
|
||||
result.setSuccess(false);
|
||||
result.setCode(submitResult.getCode());
|
||||
}
|
||||
|
||||
sysLogETA.setUserId(userId);
|
||||
sysLogETA.setPlayerId(playerId);
|
||||
sysLogETA.setInputDateTime(etaTime.substring(0, 5));
|
||||
sysLogETA.setCreatedAt(now);
|
||||
sysLogETA.setUpdatedAt(now);
|
||||
sysLogETAService.save(sysLogETA);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/todo/cancel_booking", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<BaseApiResponse<Object>> cancelBooking(HttpServletRequest request,
|
||||
@RequestBody TodoCancelBookingRequest cancelRequest) throws Exception {
|
||||
LoginUserInfo loginUser = SysCommon.parseUserFromToken(request);
|
||||
BaseApiResponse<Object> result = new BaseApiResponse<>();
|
||||
//--
|
||||
result.setRequestData(cancelRequest);
|
||||
String userId = loginUser.getLoginId();
|
||||
String groupName = loginUser.getGroupName();
|
||||
//--get group permissions
|
||||
boolean cancelBooking = true;
|
||||
List<SysRouterPermission> userPermissions = sysGroupPermissionService.getRouterPermissionsByGroupName(groupName);
|
||||
if(!userPermissions.isEmpty()) {
|
||||
for(SysRouterPermission per:userPermissions) {
|
||||
if(Strings.CS.equals(per.getId(), "10001_02") ) cancelBooking = true;
|
||||
}
|
||||
}
|
||||
String playerId = cancelRequest.getPlayerId();
|
||||
BaseApiResponse<PlayerProfileEntry> findPlayerProfileResult = playerService.findPlayerProfileByPlayerIdAndUserId(playerId, userId);
|
||||
if(findPlayerProfileResult.isSuccess()) {
|
||||
PlayerProfileEntry profile = findPlayerProfileResult.getData();
|
||||
Integer code = profile.getCodedFlag();
|
||||
if(code==1 && cancelBooking) {
|
||||
BaseApiResponse<Object> cancelResult = todoService.cancelBooking(cancelRequest,request);
|
||||
if(cancelResult.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setMessage(!StringUtils.isEmpty(cancelResult.getMessage())?cancelResult.getMessage():"Cancel Success");
|
||||
result.setData(cancelResult.getData());
|
||||
result.setRequestData(cancelResult.getData());
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setMessage(cancelResult.getMessage());
|
||||
result.setCode(cancelResult.getCode());
|
||||
}
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode("NO_PERMISSION");
|
||||
result.setMessage("No permission to cancel");
|
||||
}
|
||||
}else {
|
||||
result.setSuccess(false);
|
||||
result.setCode("CALL_API_ERROR");
|
||||
result.setMessage(findPlayerProfileResult.getMessage());
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BasePricePerDay {
|
||||
|
||||
private Float amount;
|
||||
private String currency;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CancellationReasonResult {
|
||||
|
||||
private String id;
|
||||
private Long version;
|
||||
private String zoneId;
|
||||
private String code;
|
||||
private Object description;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PlayerProfile {
|
||||
|
||||
private String playerId;
|
||||
private String name;
|
||||
private String chineseName;
|
||||
private String englishName;
|
||||
private String tier;
|
||||
private String salutation;
|
||||
private boolean coded;
|
||||
private List<Integer> nameIds=new ArrayList<Integer>();
|
||||
|
||||
public PlayerProfile() {
|
||||
|
||||
}
|
||||
|
||||
public String getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
public void setPlayerId(String playerId) {
|
||||
this.playerId = playerId;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getTier() {
|
||||
return tier;
|
||||
}
|
||||
public void setTier(String tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
public String getSalutation() {
|
||||
return salutation;
|
||||
}
|
||||
public void setSalutation(String salutation) {
|
||||
this.salutation = salutation;
|
||||
}
|
||||
|
||||
public String getChineseName() {
|
||||
return chineseName;
|
||||
}
|
||||
public void setChineseName(String chineseName) {
|
||||
this.chineseName = chineseName;
|
||||
}
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
public void setEnglishName(String englishName) {
|
||||
this.englishName = englishName;
|
||||
}
|
||||
|
||||
public boolean isCoded() {
|
||||
return coded;
|
||||
}
|
||||
|
||||
public void setCoded(boolean coded) {
|
||||
this.coded = coded;
|
||||
}
|
||||
|
||||
public List<Integer> getNameIds() {
|
||||
return nameIds;
|
||||
}
|
||||
|
||||
public void setNameIds(List<Integer> nameIds) {
|
||||
this.nameIds = nameIds;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
|
||||
public class PlayerTPD {
|
||||
|
||||
private String playerId;
|
||||
private String roomCategory;
|
||||
private String bookingDate;
|
||||
private Integer bookingDateQualificationFlag;
|
||||
|
||||
|
||||
public PlayerTPD() {
|
||||
|
||||
}
|
||||
|
||||
public String getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public void setPlayerId(String playerId) {
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public String getRoomCategory() {
|
||||
return roomCategory;
|
||||
}
|
||||
|
||||
public void setRoomCategory(String roomCategory) {
|
||||
this.roomCategory = roomCategory;
|
||||
}
|
||||
|
||||
public String getBookingDate() {
|
||||
return bookingDate;
|
||||
}
|
||||
|
||||
public void setBookingDate(String bookingDate) {
|
||||
this.bookingDate = bookingDate;
|
||||
}
|
||||
|
||||
public Integer getBookingDateQualificationFlag() {
|
||||
return bookingDateQualificationFlag;
|
||||
}
|
||||
|
||||
public void setBookingDateQualificationFlag(Integer bookingDateQualificationFlag) {
|
||||
this.bookingDateQualificationFlag = bookingDateQualificationFlag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProjectedRevenue {
|
||||
private String amount;
|
||||
private String currency;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProjectedRevenueAmount {
|
||||
private boolean isConfidential;
|
||||
private Long gross;
|
||||
private Long net;
|
||||
private String currency;
|
||||
private String basePriceType;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RatePricingDetail {
|
||||
|
||||
private String roomTypeToChargeId;
|
||||
private String ratePlanId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StatusCode {
|
||||
private String code;
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.mgm.mcrm.player.dtos;
|
||||
|
||||
public class UserInfo {
|
||||
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String property;
|
||||
private String division;
|
||||
private String department;
|
||||
private String section;
|
||||
private String block;
|
||||
private Long propertyId;
|
||||
private Long divisionId;
|
||||
private Long departmentId;
|
||||
private Long sectionId;
|
||||
private Long blockId;
|
||||
private Long teamStructureId;
|
||||
private boolean loginTag;
|
||||
|
||||
public UserInfo() {
|
||||
this.loginTag = false;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public Long getPropertyId() {
|
||||
return propertyId;
|
||||
}
|
||||
|
||||
public void setPropertyId(Long propertyId) {
|
||||
this.propertyId = propertyId;
|
||||
}
|
||||
|
||||
public Long getDivisionId() {
|
||||
return divisionId;
|
||||
}
|
||||
|
||||
public void setDivisionId(Long divisionId) {
|
||||
this.divisionId = divisionId;
|
||||
}
|
||||
|
||||
public Long getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(Long departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public Long getSectionId() {
|
||||
return sectionId;
|
||||
}
|
||||
|
||||
public void setSectionId(Long sectionId) {
|
||||
this.sectionId = sectionId;
|
||||
}
|
||||
|
||||
public Long getBlockId() {
|
||||
return blockId;
|
||||
}
|
||||
|
||||
public void setBlockId(Long blockId) {
|
||||
this.blockId = blockId;
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
public String getDivision() {
|
||||
return division;
|
||||
}
|
||||
|
||||
public void setDivision(String division) {
|
||||
this.division = division;
|
||||
}
|
||||
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public String getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(String team) {
|
||||
this.section = team;
|
||||
}
|
||||
|
||||
public String getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(String block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public boolean isLoginTag() {
|
||||
return loginTag;
|
||||
}
|
||||
|
||||
public void setLoginTag(boolean loginTag) {
|
||||
this.loginTag = loginTag;
|
||||
}
|
||||
|
||||
public Long getTeamStructureId() {
|
||||
return teamStructureId;
|
||||
}
|
||||
|
||||
public void setTeamStructureId(Long teamStructureId) {
|
||||
this.teamStructureId = teamStructureId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EtaRecordInfo {
|
||||
private String hotelName;
|
||||
private String confNo;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetDashboardRequest {
|
||||
private String playerId;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetTodoDetailRequest {
|
||||
|
||||
@JsonProperty("PlayerId")
|
||||
private String playerId;
|
||||
|
||||
@JsonProperty("TodoSegment")
|
||||
private String todosegment;
|
||||
|
||||
@JsonProperty("TodoCategory")
|
||||
private String todoCategory;
|
||||
|
||||
@JsonProperty("Date")
|
||||
private String date;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetTodoListRequest {
|
||||
|
||||
@JsonProperty("TodoSegment")
|
||||
private String todoSegment;
|
||||
|
||||
@JsonProperty("TodoCategory")
|
||||
private String todoCategory;
|
||||
|
||||
@JsonProperty("StartDate")
|
||||
private String startDate;
|
||||
|
||||
@JsonProperty("EndDate")
|
||||
private String endDate;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TodoCancelBookingRequest {
|
||||
private Long id;
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String propertyName;
|
||||
private String dlReservationId;
|
||||
private String playerId;
|
||||
private String confirmationNo;
|
||||
|
||||
private List<String> dlSharerIds;
|
||||
private Long dlVersion;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import com.mgm.mcrm.booking.dtos.BookingDateEntry;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TodoChangeDateRequest {
|
||||
private Long id;
|
||||
private String confirmationNo;
|
||||
private Date checkinDate;
|
||||
private Date checkoutDate;
|
||||
private Date checkInDate;
|
||||
private Date checkOutDate;
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String playerId;
|
||||
private String sharer;
|
||||
private String remark;
|
||||
private Long segmentId;
|
||||
private List<BookingDateEntry> dateList;
|
||||
private List<BookingDateEntry> extendDate;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TodoSubmitETARequest {
|
||||
|
||||
@JsonProperty("ETATime")
|
||||
private String etaTime;
|
||||
private String playerId;
|
||||
private List<EtaRecordInfo> recordInfo;
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import com.mgm.mcrm.booking.dtos.search.DateRange;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WebCheckPlayerTPDRequest {
|
||||
private String playerId;
|
||||
private String roomCat;
|
||||
private String bookingType;
|
||||
private String property;
|
||||
private List<String> dates;
|
||||
private List<DateRange> dateRange;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mgm.mcrm.player.dtos.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WebPlayerLookupRequest {
|
||||
private String playerId;
|
||||
private String userId;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.mgm.mcrm.player.dtos.response;
|
||||
|
||||
import com.mgm.mcrm.player.dtos.CancellationReasonResult;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 对应外层返回的 JSON:
|
||||
* {
|
||||
* \"results\": { \"PropertyType\": [ ... ] },
|
||||
* \"paging\": { ... }
|
||||
* }
|
||||
*/
|
||||
@Data
|
||||
public class CancelReasonResultResponse {
|
||||
|
||||
private ResultsWrapper results;
|
||||
|
||||
private PagingResponse paging;
|
||||
|
||||
@Data
|
||||
public static class ResultsWrapper {
|
||||
private List<CancellationReasonResult> cancelReason;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class PagingResponse {
|
||||
private Integer pageNumber;
|
||||
private Integer pageSize;
|
||||
private Integer totalCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.mgm.mcrm.player.dtos.response;
|
||||
|
||||
import com.mgm.mcrm.player.dtos.ProjectedRevenue;
|
||||
import com.mgm.mcrm.player.dtos.ProjectedRevenueAmount;
|
||||
import com.mgm.mcrm.player.dtos.StatusCode;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DaylightReservationResponse {
|
||||
private String id;
|
||||
private String profileId;
|
||||
private StatusCode statusCode;
|
||||
private String confirmationNumber;
|
||||
private String eta;
|
||||
private String etd;
|
||||
private String arrivalDate;
|
||||
private String departureDate;
|
||||
private String roomTypeId;
|
||||
private String roomTypeToChargeId;
|
||||
private String guaranteeTypeId;
|
||||
private String sourceId;
|
||||
private String channelId;
|
||||
private boolean isRoomFixed;
|
||||
private ProjectedRevenue projectedRevenue;
|
||||
private Object transportations;
|
||||
private String bookingDate;
|
||||
private String accountId;
|
||||
private Long version;
|
||||
private String createdAt;
|
||||
private String updatedAt;
|
||||
private String updatedAtUtc;
|
||||
private String createdAtUtc;
|
||||
private ProjectedRevenueAmount projectedRevenueAmount;
|
||||
private String bookingTimestamp;
|
||||
private boolean walkInIntention;
|
||||
private Object relations;
|
||||
private boolean isRatePriceHidden;
|
||||
private String blockId;
|
||||
private List<String> accompanyingGuestProfileIds;
|
||||
|
||||
private List<ExternalId> externalIds;
|
||||
|
||||
@Data
|
||||
public static class ExternalId {
|
||||
|
||||
private String systemId;
|
||||
private String number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mgm.mcrm.player.dtos.response;
|
||||
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.TodoDashboardResult;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetDashboardResponse {
|
||||
private String errorCode;
|
||||
private boolean isSuccess=false;
|
||||
private String errorMessage="";
|
||||
private TodoDashboardResult returnData =null;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mgm.mcrm.player.dtos.response;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.TodoDetailResult;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetTodoDetailResponse {
|
||||
|
||||
private String errorCode;
|
||||
private boolean isSuccess=false;
|
||||
private String errorMessage="";
|
||||
private TodoDetailResult returnData =null;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.mgm.mcrm.player.dtos.response;
|
||||
|
||||
public class GetTodoListResponse {
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mgm.mcrm.player.dtos.response;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.mgm.mcrm.basesetting.property.dtos.response.DayLightProfileResponse;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 对应外层返回的 JSON:
|
||||
* {
|
||||
* \"results\": { \"PropertyType\": [ ... ] },
|
||||
* \"paging\": { ... }
|
||||
* }
|
||||
*/
|
||||
@Data
|
||||
public class ReservationResultResponse {
|
||||
|
||||
private ResultsWrapper results;
|
||||
|
||||
private PagingResponse paging;
|
||||
|
||||
@Data
|
||||
public static class ResultsWrapper {
|
||||
private DaylightReservationResponse reservation;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class PagingResponse {
|
||||
private Integer pageNumber;
|
||||
private Integer pageSize;
|
||||
private Integer totalCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
package com.mgm.mcrm.player.services;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.mgm.mcrm.appsetting.services.SysSettingService;
|
||||
import com.mgm.mcrm.booking.dtos.search.DateRange;
|
||||
import com.mgm.mcrm.booking.services.OperaDBBookingService;
|
||||
import com.mgm.mcrm.common.constants.SysCommon;
|
||||
import com.mgm.mcrm.common.dtos.BaseApiResponse;
|
||||
import com.mgm.mcrm.common.dtos.http_util.HttpResponseResult;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.PlayerProfileEntry;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.PlayerTPDApiResult;
|
||||
import com.mgm.mcrm.common.services.MGMApiService;
|
||||
import com.mgm.mcrm.player.dtos.PlayerTPD;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PlayerService {
|
||||
|
||||
@Resource
|
||||
private MGMApiService mgmApiService;
|
||||
|
||||
@Resource
|
||||
private SysSettingService sysSettingService;
|
||||
|
||||
@Resource
|
||||
private OperaDBBookingService operaDBBookingService;
|
||||
|
||||
public BaseApiResponse<PlayerProfileEntry> findPlayerProfileByPlayerIdAndUserId(String playerId, String userId) {
|
||||
BaseApiResponse<PlayerProfileEntry> result = new BaseApiResponse<>();
|
||||
HttpResponseResult httpResult;
|
||||
try {
|
||||
// Daylight profile 调用不再需要 token,这里直接调用 MGM API
|
||||
httpResult = mgmApiService.invokeGetPlayerProfile(playerId, userId);
|
||||
|
||||
if (httpResult.getStatusCode() != 200) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke find player profile Failed:[" + httpResult.getStatusCode() + "] " + httpResult.getErrorMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke find player profile API error:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
PlayerProfileEntry resultObj;
|
||||
try {
|
||||
resultObj = JSONObject.parseObject(
|
||||
httpResult.getResponseContent(),
|
||||
PlayerProfileEntry.class,
|
||||
Feature.SupportNonPublicField,
|
||||
Feature.IgnoreNotMatch
|
||||
);
|
||||
|
||||
if (resultObj == null || resultObj.getStatusCode() == null) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invalid return data");
|
||||
return result;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Parse return data failed:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
String resultCode = resultObj.getStatusCode();
|
||||
if (!"OK".equals(resultCode)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage(resultObj.getStatusDescription());
|
||||
return result;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(resultObj.getPlayerId())) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Player not found");
|
||||
return result;
|
||||
}
|
||||
|
||||
resultObj.setName(resultObj.getEnglishName());
|
||||
this.supplementProfileNameIds(resultObj);
|
||||
if (resultObj.getCodedFlag() == 0) {
|
||||
resultObj = new PlayerProfileEntry();
|
||||
resultObj.setCodedFlag(0);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setData(resultObj);
|
||||
return result;
|
||||
}
|
||||
|
||||
public BaseApiResponse<PlayerProfileEntry> findWebPlayerProfileByPlayerId(String playerId) {
|
||||
BaseApiResponse<PlayerProfileEntry> result = new BaseApiResponse<>();
|
||||
|
||||
HttpResponseResult httpResult;
|
||||
try {
|
||||
httpResult = mgmApiService.invokeGetAllPlayerProfile(playerId);
|
||||
|
||||
if (httpResult.getStatusCode() != 200) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke find player profile Failed:[" + httpResult.getStatusCode() + "] " + httpResult.getErrorMessage());
|
||||
return result;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke find player profile API error:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
PlayerProfileEntry resultObj;
|
||||
try {
|
||||
resultObj = JSONObject.parseObject(
|
||||
httpResult.getResponseContent(),
|
||||
PlayerProfileEntry.class,
|
||||
Feature.SupportNonPublicField,
|
||||
Feature.IgnoreNotMatch
|
||||
);
|
||||
|
||||
if (resultObj == null || resultObj.getStatusCode() == null) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invalid return data");
|
||||
return result;
|
||||
}
|
||||
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Parse return data failed:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
String resultCode = resultObj.getStatusCode();
|
||||
if (!"OK".equals(resultCode)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage(resultObj.getStatusDescription());
|
||||
return result;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(resultObj.getPlayerId())) {
|
||||
resultObj.setName(resultObj.getEnglishName());
|
||||
this.supplementProfileNameIds(resultObj);
|
||||
result.setSuccess(true);
|
||||
result.setData(resultObj);
|
||||
} else {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Player not found");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public BaseApiResponse<PlayerTPDApiResult> checkTPDByPlayerIdAndRoomAndDates(
|
||||
String playerId,
|
||||
String roomCate,
|
||||
List<String> dates,
|
||||
String bookingType,
|
||||
String property) {
|
||||
BaseApiResponse<PlayerTPDApiResult> result = new BaseApiResponse<>();
|
||||
|
||||
HttpResponseResult httpResult;
|
||||
try {
|
||||
httpResult = mgmApiService.invokeCheckPlayerTPD(playerId, roomCate, dates, bookingType, property);
|
||||
|
||||
if (httpResult.getStatusCode() != 200) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke check player TPD Failed:[" + httpResult.getStatusCode() + "] " + httpResult.getErrorMessage());
|
||||
return result;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke check player TPD API error:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
PlayerTPDApiResult resultObj;
|
||||
try {
|
||||
resultObj = JSONObject.parseObject(
|
||||
httpResult.getResponseContent(),
|
||||
PlayerTPDApiResult.class,
|
||||
Feature.SupportNonPublicField,
|
||||
Feature.IgnoreNotMatch
|
||||
);
|
||||
if (resultObj == null) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invalid return data");
|
||||
return result;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Parse return data failed:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
String resultCode = resultObj.getStatusCode();
|
||||
if (!"OK".equals(resultCode)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("CheckPlayerTPD API return error:[" + resultCode + "] " + resultObj.getStatusDescription());
|
||||
return result;
|
||||
}
|
||||
|
||||
List<PlayerTPD> tpd = resultObj.getRecords();
|
||||
if (tpd == null) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Player TPD not found");
|
||||
return result;
|
||||
}
|
||||
|
||||
int dateNum = tpd.size();
|
||||
int qualifyNum = 0;
|
||||
int unQualifyNum = 0;
|
||||
List<JSONObject> resultList = new ArrayList<>();
|
||||
for (PlayerTPD t : tpd) {
|
||||
if (t.getBookingDateQualificationFlag() == 1) {
|
||||
++qualifyNum;
|
||||
} else {
|
||||
++unQualifyNum;
|
||||
}
|
||||
JSONObject obj = new JSONObject();
|
||||
String getDate = t.getBookingDate().replace("/", "-");
|
||||
obj.put("date", getDate);
|
||||
obj.put("status", t.getBookingDateQualificationFlag() == 1 ? 0 : 1);
|
||||
resultList.add(obj);
|
||||
|
||||
}
|
||||
if (dateNum == qualifyNum) {
|
||||
resultObj.setStatus(0);
|
||||
} else if (dateNum == unQualifyNum) {
|
||||
resultObj.setStatus(1);
|
||||
} else {
|
||||
resultObj.setStatus(2);
|
||||
}
|
||||
int status = resultObj.getStatus();
|
||||
if (status == 2) {
|
||||
if (dates.size() == 1) {
|
||||
resultObj.setStatus(1);
|
||||
resultObj.setDates(null);
|
||||
} else if (dates.size() >= 2) {
|
||||
if (SysCommon.mgmApiMockup) {
|
||||
resultList = new ArrayList<>();
|
||||
for (int i = 0; i < dates.size(); i++) {
|
||||
String date = dates.get(i);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("date", date);
|
||||
|
||||
if (i == 0) {
|
||||
obj.put("status", 0);
|
||||
} else if (i == 1) {
|
||||
obj.put("status", 1);
|
||||
} else {
|
||||
Random rand = new Random();
|
||||
int randomStatus = rand.nextInt(2);
|
||||
obj.put("status", randomStatus);
|
||||
}
|
||||
resultList.add(obj);
|
||||
}
|
||||
}
|
||||
resultObj.setDates(resultList);
|
||||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setData(resultObj);
|
||||
return result;
|
||||
}
|
||||
|
||||
public BaseApiResponse<PlayerTPDApiResult> checkSecondTPDByPlayerIdAndRoomAndDates(
|
||||
String playerId,
|
||||
String roomCate,
|
||||
List<DateRange> dateRange,
|
||||
List<String> dates,
|
||||
String bookingType,
|
||||
String property) {
|
||||
BaseApiResponse<PlayerTPDApiResult> result = new BaseApiResponse<>();
|
||||
|
||||
HttpResponseResult httpResult;
|
||||
try {
|
||||
httpResult = mgmApiService.invokeCheckPlayerSecondTPD(playerId, roomCate, dateRange, bookingType, property);
|
||||
if (httpResult.getStatusCode() != 200) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke check player second TPD Failed:[" + httpResult.getStatusCode() + "] " + httpResult.getErrorMessage());
|
||||
return result;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invoke check player second TPD API error:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
PlayerTPDApiResult resultObj;
|
||||
try {
|
||||
resultObj = JSONObject.parseObject(
|
||||
httpResult.getResponseContent(),
|
||||
PlayerTPDApiResult.class,
|
||||
Feature.SupportNonPublicField,
|
||||
Feature.IgnoreNotMatch
|
||||
);
|
||||
|
||||
if (resultObj == null) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Invalid return data");
|
||||
return result;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Parse return data failed:" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
String resultCode = resultObj.getStatusCode();
|
||||
if (!"OK".equals(resultCode)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("CheckPlayerSecondTPD API return error:[" + resultCode + "] " + resultObj.getStatusDescription());
|
||||
return result;
|
||||
}
|
||||
|
||||
List<PlayerTPD> tpd = resultObj.getRecords();
|
||||
if (tpd == null) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("Player Second TPD not found");
|
||||
return result;
|
||||
}
|
||||
|
||||
int dateNum = tpd.size();
|
||||
int qualifyNum = 0;
|
||||
int unQualifyNum = 0;
|
||||
List<JSONObject> resultList = new ArrayList<>();
|
||||
for (PlayerTPD t : tpd) {
|
||||
if (t.getBookingDateQualificationFlag() == 1) {
|
||||
++qualifyNum;
|
||||
} else {
|
||||
++unQualifyNum;
|
||||
}
|
||||
JSONObject obj = new JSONObject();
|
||||
String getDate = t.getBookingDate().replace("/", "-");
|
||||
obj.put("date", getDate);
|
||||
obj.put("status", t.getBookingDateQualificationFlag() == 1 ? 0 : 1);
|
||||
resultList.add(obj);
|
||||
}
|
||||
if (dateNum == qualifyNum) {
|
||||
resultObj.setStatus(0);
|
||||
} else if (dateNum == unQualifyNum) {
|
||||
resultObj.setStatus(1);
|
||||
} else {
|
||||
resultObj.setStatus(2);
|
||||
}
|
||||
int status = resultObj.getStatus();
|
||||
if (status == 2) {
|
||||
if (dates != null && dates.size() == 1) {
|
||||
resultObj.setStatus(1);
|
||||
resultObj.setDates(null);
|
||||
} else if (dates != null && dates.size() >= 2) {
|
||||
if (SysCommon.mgmApiMockup) {
|
||||
resultList = new ArrayList<>();
|
||||
for (int i = 0; i < dates.size(); i++) {
|
||||
String date = dates.get(i);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("date", date);
|
||||
|
||||
if (i == 0) {
|
||||
obj.put("status", 0);
|
||||
} else if (i == 1) {
|
||||
obj.put("status", 1);
|
||||
} else {
|
||||
Random rand = new Random();
|
||||
int randomStatus = rand.nextInt(2);
|
||||
obj.put("status", randomStatus);
|
||||
}
|
||||
resultList.add(obj);
|
||||
}
|
||||
}
|
||||
resultObj.setDates(resultList);
|
||||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setData(resultObj);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void supplementProfileNameIds(PlayerProfileEntry profile) {
|
||||
boolean isMock = sysSettingService.isMockReplicate();
|
||||
if (isMock) {
|
||||
List<Integer> lists = new ArrayList<>();
|
||||
lists.add(710825);
|
||||
profile.setNameIds(lists);
|
||||
} else {
|
||||
List<String> lists = operaDBBookingService.getOperaNameIDByPlayerID(profile.getPlayerId());
|
||||
List<Integer> nameList = new ArrayList<>();
|
||||
if (lists != null && !lists.isEmpty()) {
|
||||
nameList.add(Integer.valueOf(lists.getFirst()));
|
||||
}
|
||||
profile.setNameIds(nameList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,989 @@
|
||||
package com.mgm.mcrm.player.services;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.google.gson.Gson;
|
||||
import com.mgm.mcrm.appsetting.models.CfgSettings;
|
||||
import com.mgm.mcrm.appsetting.services.SettingService;
|
||||
import com.mgm.mcrm.appsetting.services.SysSettingService;
|
||||
import com.mgm.mcrm.authorization.dtos.LoginUserInfo;
|
||||
import com.mgm.mcrm.basesetting.daylight.dtos.response.ReservationDoorKeyResponse;
|
||||
import com.mgm.mcrm.basesetting.daylight.dtos.response.ReservationQueueResponse;
|
||||
import com.mgm.mcrm.basesetting.daylight.services.DaylightService;
|
||||
import com.mgm.mcrm.basesetting.property.models.CfgProperties;
|
||||
import com.mgm.mcrm.basesetting.property.repositories.PropertyDao;
|
||||
import com.mgm.mcrm.basesetting.room.models.CfgOtherRoomStatus;
|
||||
import com.mgm.mcrm.basesetting.room.repositories.OtherRoomStatusDao;
|
||||
import com.mgm.mcrm.basesetting.room.services.OtherRoomStatusService;
|
||||
import com.mgm.mcrm.booking.controllers.BookingController;
|
||||
import com.mgm.mcrm.booking.dtos.BookingDto;
|
||||
import com.mgm.mcrm.booking.dtos.opera.CancelBookingRequest;
|
||||
import com.mgm.mcrm.booking.dtos.opera.FetchBookingRequest;
|
||||
import com.mgm.mcrm.booking.dtos.opera.GuestRequestsRequest;
|
||||
import com.mgm.mcrm.booking.dtos.opera.ModifyBookingRequest;
|
||||
import com.mgm.mcrm.booking.mappers.BookingMapper;
|
||||
import com.mgm.mcrm.booking.models.Bookings;
|
||||
import com.mgm.mcrm.booking.models.BookingsView;
|
||||
import com.mgm.mcrm.booking.repositories.BookingDao;
|
||||
import com.mgm.mcrm.booking.repositories.BookingViewDao;
|
||||
import com.mgm.mcrm.booking.services.*;
|
||||
import com.mgm.mcrm.common.constants.SysCommon;
|
||||
import com.mgm.mcrm.common.constants.SysConstants;
|
||||
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.utils.DateTimeUtil;
|
||||
import com.mgm.mcrm.common.utils.LogUtil;
|
||||
import com.mgm.mcrm.common.utils.SendEmail;
|
||||
import com.mgm.mcrm.logging.models.SysLogBooking;
|
||||
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.EtaRecordInfo;
|
||||
import com.mgm.mcrm.player.dtos.request.TodoCancelBookingRequest;
|
||||
import com.mgm.mcrm.player.dtos.request.TodoChangeDateRequest;
|
||||
import com.mgm.mcrm.player.dtos.response.GetDashboardResponse;
|
||||
import com.mgm.mcrm.player.dtos.response.GetTodoDetailResponse;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TodoService {
|
||||
|
||||
@Resource
|
||||
private MGMApiService mgmApiService;
|
||||
|
||||
@Resource
|
||||
private SysSettingService sysSettingService;
|
||||
|
||||
@Resource
|
||||
private OperaDBBookingService operaDBBookingService;
|
||||
|
||||
@Resource
|
||||
private BookingDao bookingDao;
|
||||
|
||||
@Resource
|
||||
private BookingViewDao bookingViewDao;
|
||||
|
||||
@Resource
|
||||
private PropertyDao propertyDao;
|
||||
|
||||
@Resource
|
||||
private OtherRoomStatusDao otherRoomStatusDao;
|
||||
|
||||
@Resource
|
||||
OperaService operaService;
|
||||
|
||||
@Resource
|
||||
private NonMGMBookingService otherBookingService;
|
||||
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
|
||||
@Resource
|
||||
private EmailDao emailDao;
|
||||
|
||||
@Resource
|
||||
private OtherRoomStatusService otherRoomStatusService;
|
||||
|
||||
@Resource
|
||||
private SysLogBookingService sysLogBookingService;
|
||||
|
||||
@Resource
|
||||
private OtherRoomStatusDao roomStatusDao;
|
||||
|
||||
@Resource
|
||||
private WaitlistBookingService waitlistBookingService;
|
||||
|
||||
@Resource
|
||||
private PlayerService playerService;
|
||||
|
||||
@Resource
|
||||
private HttpService httpService;
|
||||
@Resource
|
||||
private BookingService bookingService;
|
||||
|
||||
@Resource
|
||||
private DaylightService dlService;
|
||||
|
||||
@Resource
|
||||
private BookingMapper bookingMapper;
|
||||
|
||||
public GetDashboardResponse getTodoDashboard(String userId) throws Exception {
|
||||
GetDashboardResponse result = new GetDashboardResponse();
|
||||
|
||||
try {
|
||||
HttpResponseResult httpResult = mgmApiService.invokeGetTodoDashboard(userId, 0);
|
||||
try {
|
||||
TodoDashboardResult resultObj = JSONObject.parseObject(httpResult.getResponseContent(), TodoDashboardResult.class, Feature.SupportNonPublicField, Feature.IgnoreNotMatch);
|
||||
if (Strings.CI.equals(resultObj.getStatusCode(), "OK")) {
|
||||
result.setSuccess(true);
|
||||
result.setReturnData(resultObj);
|
||||
} else {
|
||||
result.setSuccess(false);
|
||||
result.setErrorCode(resultObj.getStatusDescription());
|
||||
LogUtil.info(TodoService.class, "[GetDashboardData Error]" + resultObj.getStatusDescription());
|
||||
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setErrorCode("RETURN_DATA_ERROR");
|
||||
LogUtil.info(TodoService.class, "[GetDashboardData Error]" + err.getMessage());
|
||||
}
|
||||
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setErrorCode("INVOKE_TODODASHBOARD_API_ERROR");
|
||||
LogUtil.info(TodoService.class, "[GetDashboardData Error]" + err.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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);
|
||||
try {
|
||||
TodoDetailResult resultObj = JSONObject.parseObject(httpResult.getResponseContent(), TodoDetailResult.class, Feature.SupportNonPublicField, Feature.IgnoreNotMatch);
|
||||
if (Strings.CI.equals(resultObj.getStatusCode(), "OK")) {
|
||||
|
||||
|
||||
// TODO daylight专用,后面要改 by Mauve
|
||||
if (1 == 1) {
|
||||
if (resultObj.getDescriptions() != null) {
|
||||
for (TodoDetailDescription detailRecord : resultObj.getDescriptions()) {
|
||||
if ("Room".equalsIgnoreCase(detailRecord.getItemRecordType())) {
|
||||
String recordDesc = detailRecord.getItemRecordDescription();
|
||||
if (StringUtils.isNotBlank(recordDesc)) {
|
||||
String confNum = null;
|
||||
int index = recordDesc.indexOf("Conf#");
|
||||
if (index != -1) {
|
||||
String sub = recordDesc.substring(index + 5);
|
||||
int pipeIndex = sub.indexOf("|");
|
||||
if (pipeIndex != -1) {
|
||||
confNum = sub.substring(0, pipeIndex).trim();
|
||||
} else {
|
||||
confNum = sub.trim();
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(confNum)) {
|
||||
if ("Inhouse".equalsIgnoreCase(todoCategory) || "Arrival".equalsIgnoreCase(todoCategory)) {
|
||||
List<CfgProperties> daylightProperties = propertyDao.findByCategory("DAYLIGHT");
|
||||
if (CollectionUtils.isNotEmpty(daylightProperties)) {
|
||||
CfgProperties property = daylightProperties.get(0);
|
||||
if ("Inhouse".equalsIgnoreCase(todoCategory)) {
|
||||
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) {
|
||||
detailRecord.setItemRecordDescription(recordDesc.replace("Conf#" + confNum, "Conf#" + 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) {
|
||||
detailRecord.setItemRecordDescription(recordDesc.replace("Conf#" + confNum, "Conf#" + confNum + " [In Queue]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setReturnData(resultObj);
|
||||
} else {
|
||||
result.setSuccess(false);
|
||||
result.setErrorCode(resultObj.getStatusDescription());
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setErrorCode("RETURN_DATA_ERROR");
|
||||
LogUtil.info(TodoService.class, "[GetTodoDetail Error]" + err.getMessage());
|
||||
}
|
||||
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setErrorCode("INVOKE_TODOLISTDETAIL_API_ERROR");
|
||||
LogUtil.info(TodoService.class, "[GetTodoDetail Error]" + err.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public BaseApiResponse<Object> cancelBooking(TodoCancelBookingRequest param, HttpServletRequest request) throws Exception {
|
||||
BaseApiResponse<Object> processResult= new BaseApiResponse<>();
|
||||
Long bookId = param.getId();
|
||||
String oStatus = "";
|
||||
|
||||
if (bookId == null) {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setMessage("No Booking Id.");
|
||||
processResult.setData(param);
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
BookingsView bookingView = bookingViewDao.findById(bookId).orElse(null);
|
||||
boolean isMock =sysSettingService.isMockReplicate();
|
||||
String userId = param.getUserId();
|
||||
String userName = param.getUserName();
|
||||
String category = bookingView.getPropertyCategory();
|
||||
boolean isOpera = Strings.CS.equals("OPERA", category);
|
||||
boolean isDaylight = Strings.CS.equals("DAYLIGHT", category);
|
||||
boolean isOther = Strings.CS.equals("OTHER", category);
|
||||
|
||||
CfgProperties property = propertyDao.getByName(param.getPropertyName());
|
||||
|
||||
String dlReservationId = null;
|
||||
|
||||
if (Strings.CS.equals(category,"DAYLIGHT")) {
|
||||
dlReservationId = param.getDlReservationId();
|
||||
}
|
||||
|
||||
if (isOther) {
|
||||
// CancelOtherBooking Flow
|
||||
// 获取setting表Cancel状态和时间区间
|
||||
CfgSettings enAbleCancel = settingService.getSettingByKey("CAN_CANCEL_OTHERBOOKING");
|
||||
|
||||
// 判断状态是否启用
|
||||
if(Strings.CS.equals(enAbleCancel.getKeyValues(), "1")) {
|
||||
// 方法启用(==1),判断时间
|
||||
// 状态启用判断现在时间是否再时间区间内
|
||||
if(isPassTimeNow()) {
|
||||
//Cancel Non MGM Booking
|
||||
Bookings obooking = cancelOtherBooking(bookId,request);
|
||||
if(obooking != null) {
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(bookingView);
|
||||
}else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("SYSTEM_ERROR");
|
||||
processResult.setMessage("System error");
|
||||
}
|
||||
}else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("ERR_CANCEL_TIME");
|
||||
processResult.setData(param);
|
||||
}
|
||||
}else{
|
||||
// 如果enAbleCancel方法没有启用(==0)直接cancelbooking
|
||||
//Cancel Non MGM Booking
|
||||
Bookings obooking = cancelOtherBooking(bookId,request);
|
||||
if(obooking != null) {
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(bookingView);
|
||||
}else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("SYSTEM_ERROR");
|
||||
processResult.setMessage("System error");
|
||||
}
|
||||
}
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
// 如果是模拟数据
|
||||
if(isMock) {
|
||||
Bookings booking = bookingDao.findById(bookId).orElse(null);
|
||||
booking.setApproveStatus("C");
|
||||
booking.setLastOperaStatus("CANCELED");
|
||||
booking.setChangeCheckinDate(null);
|
||||
booking.setChangeCheckoutDate(null);
|
||||
bookingDao.save(booking);
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(booking);
|
||||
TimeUnit.SECONDS.sleep(1L);
|
||||
if (isDaylight) {
|
||||
dlService.daylightCancelReservationNew(
|
||||
dlReservationId,
|
||||
property.getDlPropertyId(),
|
||||
param.getDlSharerIds(),
|
||||
param.getDlVersion()
|
||||
);
|
||||
}
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
if (isDaylight) {
|
||||
Date newDate = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss");
|
||||
Bookings booking = bookingDao.findById(bookId).orElse(null);
|
||||
|
||||
booking.setApproveStatus("C");
|
||||
booking.setLastOperaStatus("CANCELED");
|
||||
booking.setCancelledBy(userId);
|
||||
booking.setCancelledAt(newDate);
|
||||
booking.setUpdatedAt(newDate);
|
||||
booking.setUpdatedBy(userId);
|
||||
bookingDao.save(booking);
|
||||
|
||||
BaseApiResponse<String> cancelResult =
|
||||
dlService.daylightCancelReservationNew(
|
||||
dlReservationId,
|
||||
property.getDlPropertyId(),
|
||||
param.getDlSharerIds(),
|
||||
param.getDlVersion()
|
||||
);
|
||||
|
||||
if (cancelResult.isSuccess()) {
|
||||
LogUtil.info(TodoService.class, "[Cancel Booking] Cancel Success, bookingId=" + bookId);
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(dlReservationId);
|
||||
}else {
|
||||
LogUtil.warn(TodoService.class, "[Cancel Booking] Cancel Fail");
|
||||
booking.setUpdatedAt(newDate);
|
||||
booking.setCreatedAt(newDate);
|
||||
booking.setApproveStatus("F");
|
||||
booking.setErrorMessage("Call Daylight CANCEL_RESERVATION fail,Fail reason: "+cancelResult.getMessage());
|
||||
bookingDao.save(booking);
|
||||
processResult.setSuccess(false);
|
||||
processResult.setData(cancelResult.getMessage());
|
||||
}
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
if (isOpera) {
|
||||
boolean hasShare = false;
|
||||
List shareConfList = new ArrayList();
|
||||
JSONObject fetchResponse = new JSONObject();
|
||||
FetchBookingRequest owsReq = new FetchBookingRequest();
|
||||
owsReq.setConfirmationNo(bookingView.getConfirmationNo());
|
||||
fetchResponse = operaService.fetchBooking(owsReq);
|
||||
if(fetchResponse.containsKey("shareConfList")) {
|
||||
shareConfList = (List) fetchResponse.get("shareConfList");
|
||||
hasShare = true;
|
||||
}
|
||||
CancelBookingRequest cancelRequest = new CancelBookingRequest();
|
||||
JSONObject cancelResponse = new JSONObject();
|
||||
cancelRequest.setHotelCode(bookingView.getHotelCode());
|
||||
cancelRequest.setConfirmationNo(bookingView.getConfirmationNo());
|
||||
LogUtil.info(BookingController.class, "[cancelBooking] cancelRequest begin" + gson.toJson(cancelRequest));
|
||||
cancelResponse = operaService.cancelBooking(cancelRequest);
|
||||
LogUtil.info(BookingController.class,
|
||||
"[cancelBooking] Cancel Booking res" + gson.toJson(cancelResponse));
|
||||
JSONObject errors = new JSONObject();
|
||||
|
||||
//cancel share booking
|
||||
if (shareConfList!=null) {
|
||||
for (int a = 0; a < shareConfList.size(); a++) {
|
||||
String shareConfirmationNo = String.valueOf(shareConfList.get(a));
|
||||
if(!StringUtils.isEmpty(shareConfirmationNo)) {
|
||||
cancelRequest = new CancelBookingRequest();
|
||||
cancelResponse = new JSONObject();
|
||||
cancelRequest.setHotelCode(bookingView.getHotelCode());
|
||||
cancelRequest.setConfirmationNo(shareConfirmationNo);
|
||||
cancelResponse = operaService.cancelBooking(cancelRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cancelResponse != null) {
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(bookingView);
|
||||
}else {
|
||||
Date newDate = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss");
|
||||
Bookings booking = bookingDao.findById(bookId).orElse(null);
|
||||
errors = cancelResponse;
|
||||
booking.setUpdatedAt(newDate);
|
||||
booking.setCreatedAt(newDate);
|
||||
booking.setApproveStatus("F");
|
||||
booking.setErrorMessage(errors.getString("message"));
|
||||
processResult.setSuccess(false);
|
||||
processResult.setMessage(errors.getString("message")!=null?errors.getString("message"):"System Error");
|
||||
processResult.setCode("SYSTEM_ERROR");
|
||||
processResult.setData(bookingView);
|
||||
}
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
processResult.setSuccess(false);
|
||||
processResult.setMessage("Cancel booking fail, invalid property");
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public BaseApiResponse<TodoDateListResult> getTodoList(String userId, String category, String type, Date startDate, Date endDate) throws Exception {
|
||||
BaseApiResponse<TodoDateListResult> result = new BaseApiResponse<>();
|
||||
|
||||
HttpResponseResult httpResult;
|
||||
try {
|
||||
// TODO 这里现在写死只拿daylight的todolist,后面会要拿到Opera的todoList,这个时候要改成两个都拿 by Mauve
|
||||
httpResult = mgmApiService.invokeGetTodoList(userId, category, type, startDate, endDate, 1);
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setCode("INVOKE_TODOLISTDETAIL_API_ERROR");
|
||||
LogUtil.info(TodoService.class, "[GetTodoList Error]" + err.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
TodoListResult resultObj = JSONObject.parseObject(
|
||||
httpResult.getResponseContent(),
|
||||
TodoListResult.class,
|
||||
Feature.SupportNonPublicField,
|
||||
Feature.IgnoreNotMatch
|
||||
);
|
||||
if ("OK".equals(resultObj.getStatusCode())) {
|
||||
List<TodoListRecord> recordList = resultObj.getRecords();
|
||||
TodoDateListResult dateResult = new TodoDateListResult();
|
||||
Map<String, TodoDateListRecord> dateMap = new LinkedHashMap<>();
|
||||
for (TodoListRecord record : recordList) {
|
||||
if (!dateMap.containsKey(record.getDate())) {
|
||||
TodoDateListRecord dateRecord = new TodoDateListRecord();
|
||||
dateRecord.setDate(record.getDate());
|
||||
dateRecord.setDateRecords(new ArrayList<>());
|
||||
dateMap.put(record.getDate(), dateRecord);
|
||||
}
|
||||
dateMap.get(record.getDate()).getDateRecords().add(record);
|
||||
}
|
||||
List<TodoDateListRecord> dateList = new ArrayList<>(dateMap.values());
|
||||
|
||||
// TODO daylight专用,后面要改 by Mauve
|
||||
if (1 == 1) {
|
||||
for (TodoDateListRecord todoDateListRecord : dateList) {
|
||||
|
||||
List<TodoListRecord> dateRecords = todoDateListRecord.getDateRecords();
|
||||
|
||||
for (TodoListRecord record : dateRecords) {
|
||||
String daylightConfirmationNo = record.getOperaConfirmationNo();
|
||||
|
||||
try {
|
||||
String[] split = daylightConfirmationNo.split(",");
|
||||
|
||||
for (String temp2 : split) {
|
||||
String[] split1 = temp2.split(";");
|
||||
|
||||
String confNum = split1[split1.length - 1];
|
||||
|
||||
List<BookingsView> bookingByConfirmationNo = bookingService.getBookingByDaylightConf(confNum);
|
||||
|
||||
for (BookingsView bookingsView : bookingByConfirmationNo) {
|
||||
if (StringUtils.isNotBlank(bookingsView.getEta())) {
|
||||
String[] split2 = bookingsView.getEta().split(":");
|
||||
record.setETA(split2[0] + ":" + split2[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to set ETA, operaConfirmationNo={}", daylightConfirmationNo, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
dateResult.setRecords(dateList);
|
||||
}
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setData(dateResult);
|
||||
} else {
|
||||
result.setSuccess(false);
|
||||
result.setCode(resultObj.getStatusDescription());
|
||||
}
|
||||
} catch (Exception err) {
|
||||
result.setSuccess(false);
|
||||
result.setCode("RETURN_DATA_ERROR");
|
||||
LogUtil.info(TodoService.class, "[GetTodoList Error]" + err.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public BaseApiResponse<Bookings> submitETA(String etaTime, List<EtaRecordInfo> recordInfos, Long id) throws Exception {
|
||||
|
||||
BaseApiResponse<Bookings> result = new BaseApiResponse<>();
|
||||
boolean isMock = sysSettingService.isMockReplicate();
|
||||
if (StringUtils.isBlank(etaTime) || CollectionUtils.isEmpty(recordInfos)) {
|
||||
return missParameter(result);
|
||||
}
|
||||
|
||||
for (EtaRecordInfo recordInfo : recordInfos) {
|
||||
result = handleSingleRecord(etaTime, recordInfo, isMock, id); // 保持原逻辑:最终返回最后一条
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private BaseApiResponse<Bookings> handleSingleRecord(
|
||||
String etaTime,
|
||||
EtaRecordInfo recordInfo,
|
||||
boolean isMock,
|
||||
Long id) throws Exception {
|
||||
|
||||
BaseApiResponse<Bookings> result = new BaseApiResponse<>();
|
||||
|
||||
String hotelName = StringUtils.trim(recordInfo.getHotelName());
|
||||
String confNo = StringUtils.trim(recordInfo.getConfNo());
|
||||
|
||||
if (StringUtils.isBlank(hotelName) || StringUtils.isBlank(confNo)) {
|
||||
return missParameter(result);
|
||||
}
|
||||
|
||||
CfgProperties property = propertyDao.getByLikeName(hotelName);
|
||||
if (property == null) {
|
||||
return noRecord(result);
|
||||
}
|
||||
|
||||
String category = property.getCategory();
|
||||
|
||||
if (Strings.CI.equals("DAYLIGHT", category)) {
|
||||
return handleDaylightETA(etaTime, confNo, property, id);
|
||||
}
|
||||
|
||||
if (Strings.CI.equals("OPERA", category)) {
|
||||
return handleOperaETA(etaTime, confNo, property, isMock);
|
||||
}
|
||||
|
||||
if (Strings.CI.equals("OTHER", category)) {
|
||||
return handleOtherETA(etaTime, confNo, property);
|
||||
}
|
||||
|
||||
return noRecord(result);
|
||||
}
|
||||
|
||||
private BaseApiResponse<Bookings> handleOperaETA(
|
||||
String etaTime,
|
||||
String confNo,
|
||||
CfgProperties property,
|
||||
boolean isMock) throws Exception {
|
||||
|
||||
BaseApiResponse<Bookings> result = new BaseApiResponse<>();
|
||||
Gson gson = new Gson();
|
||||
|
||||
Bookings booking = new Bookings();
|
||||
booking.setConfirmationNo(confNo);
|
||||
booking.setHotelCode(property.getHotelCode());
|
||||
booking.setCategory("OPERA");
|
||||
|
||||
ModifyBookingRequest request = new ModifyBookingRequest();
|
||||
request.setEta(etaTime);
|
||||
request.setBooking(booking);
|
||||
|
||||
LogUtil.info(TodoService.class,
|
||||
"[submitETA] OPERA submit begin " + gson.toJson(request));
|
||||
|
||||
if (isMock) {
|
||||
// mock 环境:直接操作 DB
|
||||
Bookings editBooking = bookingDao.getByConfNoForETA(confNo, property.getId());
|
||||
if (editBooking == null) {
|
||||
return noRecord(result);
|
||||
}
|
||||
|
||||
editBooking.setEta(etaTime);
|
||||
bookingDao.save(editBooking);
|
||||
result.setSuccess(true);
|
||||
result.setData(editBooking);
|
||||
return result;
|
||||
}
|
||||
|
||||
// dev / prod:调用 OPERA 接口
|
||||
JSONObject response = operaService.modifyETA(request);
|
||||
|
||||
LogUtil.info(TodoService.class,
|
||||
"[submitETA] OPERA submit res " + gson.toJson(response));
|
||||
|
||||
if (!response.containsKey("message")) {
|
||||
result.setSuccess(true);
|
||||
result.setData(booking);
|
||||
} else {
|
||||
result.setSuccess(false);
|
||||
result.setCode(response.getString("message"));
|
||||
result.setData(booking);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private BaseApiResponse<Bookings> handleDaylightETA(
|
||||
String etaTime,
|
||||
String confNo,
|
||||
CfgProperties property,
|
||||
Long id) throws Exception {
|
||||
|
||||
BaseApiResponse<Bookings> result = new BaseApiResponse<>();
|
||||
|
||||
Bookings booking;
|
||||
if (id != null) {
|
||||
booking = bookingDao.findById(id).orElse(null);
|
||||
} else {
|
||||
booking = bookingDao.getByConfNoForETA(confNo, property.getId());
|
||||
}
|
||||
|
||||
booking.setEta(etaTime);
|
||||
|
||||
bookingDao.save(booking);
|
||||
|
||||
if (StringUtils.isNotBlank(confNo)) {
|
||||
|
||||
LogUtil.info(TodoService.class, "[submitETA] DAYLIGHT submit res");
|
||||
|
||||
BaseApiResponse<List<Bookings>> submitEta =
|
||||
bookingService.callDaylightUpsertReservation(booking, "SUBMIT_ETA");
|
||||
|
||||
if (submitEta.isSuccess()) {
|
||||
result.setSuccess(true);
|
||||
result.setMessage(submitEta.getMessage());
|
||||
} else {
|
||||
result.setSuccess(false);
|
||||
result.setMessage(submitEta.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return noRecord(result);
|
||||
}
|
||||
|
||||
private BaseApiResponse<Bookings> handleOtherETA(
|
||||
String etaTime,
|
||||
String confNo,
|
||||
CfgProperties property) {
|
||||
|
||||
BaseApiResponse<Bookings> result = new BaseApiResponse<>();
|
||||
|
||||
Bookings editBooking = bookingDao.getByConfNoForETA(confNo, property.getId());
|
||||
if (editBooking == null) {
|
||||
return noRecord(result);
|
||||
}
|
||||
|
||||
LogUtil.info(TodoService.class, "[submitETA] OTHER submit res");
|
||||
|
||||
editBooking.setEta(etaTime);
|
||||
editBooking.setCategory("OTHER");
|
||||
bookingDao.save(editBooking);
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setData(editBooking);
|
||||
return result;
|
||||
}
|
||||
|
||||
private BaseApiResponse<Bookings> missParameter(BaseApiResponse<Bookings> result) {
|
||||
result.setSuccess(false);
|
||||
result.setCode("MISS_PARAMETER");
|
||||
result.setMessage("Miss Parameter");
|
||||
return result;
|
||||
}
|
||||
|
||||
private BaseApiResponse<Bookings> noRecord(BaseApiResponse<Bookings> result) {
|
||||
result.setSuccess(false);
|
||||
result.setCode("NO_RECORD");
|
||||
result.setMessage("There are no corresponding booking records.");
|
||||
return result;
|
||||
}
|
||||
|
||||
public BaseApiResponse<BookingDto> changeBookingDate(TodoChangeDateRequest param, HttpServletRequest request) throws Exception {
|
||||
BaseApiResponse<BookingDto> processResult = new BaseApiResponse<>();
|
||||
Long bookId = param.getId();
|
||||
String confNo = param.getConfirmationNo();
|
||||
String ciDate = DateTimeUtil.getDateByFormat(param.getCheckinDate(), "yyyy-MM-dd");
|
||||
String coDate = DateTimeUtil.getDateByFormat(param.getCheckoutDate(), "yyyy-MM-dd");
|
||||
String userId = param.getUserId();
|
||||
String userName = param.getUserName();
|
||||
String playerId = param.getPlayerId();
|
||||
PlayerProfileEntry profile = null;
|
||||
BaseApiResponse<PlayerProfileEntry> res = playerService.findPlayerProfileByPlayerIdAndUserId(playerId, userId);
|
||||
if (res.isSuccess()) {
|
||||
profile = res.getData();
|
||||
}
|
||||
if (bookId != null) {
|
||||
Gson gson = new Gson();
|
||||
BookingsView bookingView;
|
||||
if (confNo != null) {
|
||||
List<BookingsView> bookingsViews = bookingViewDao.findByConfirmationNo(confNo);
|
||||
bookingView = bookingsViews.getFirst();
|
||||
} else {
|
||||
bookingView = bookingViewDao.findById(bookId).orElse(null);
|
||||
}
|
||||
if (bookingView == null) {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setMessage("Booking not found");
|
||||
log.warn("booking not found");
|
||||
return processResult;
|
||||
}
|
||||
Bookings booking = bookingDao.findById(bookingView.getId()).orElse(null);
|
||||
boolean isMock = sysSettingService.isMockReplicate();
|
||||
Date checkinDate = DateTimeUtil.getDateFromString(ciDate, "yyyy-MM-dd");
|
||||
Date checkoutDate = DateTimeUtil.getDateFromString(coDate, "yyyy-MM-dd");
|
||||
|
||||
if ("DAYLIGHT".equals(bookingView.getPropertyCategory())) {
|
||||
//Change Daylight Booking
|
||||
|
||||
booking.setCheckinDate(checkinDate);
|
||||
booking.setCheckoutDate(checkoutDate);
|
||||
bookingDao.save(booking);
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(bookingMapper.entityToDto(booking));
|
||||
bookingService.daylightReservationChangeDate(param, profile, false);
|
||||
|
||||
LogUtil.info(TodoService.class, "[ChangeBookingDate] ID:"+bookingView.getDlReservationId());
|
||||
|
||||
return processResult;
|
||||
|
||||
} else if ("OPERA".equalsIgnoreCase(bookingView.getPropertyCategory())) {
|
||||
boolean hasShare = false;
|
||||
JSONObject fetchResponse = new JSONObject();
|
||||
FetchBookingRequest owsReq = new FetchBookingRequest();
|
||||
owsReq.setConfirmationNo(bookingView.getConfirmationNo());
|
||||
fetchResponse = operaService.fetchBooking(owsReq);
|
||||
if (fetchResponse.containsKey("shareConfList")) {
|
||||
hasShare = true;
|
||||
}
|
||||
if (hasShare) {
|
||||
//sendEmail
|
||||
Email email = new Email();
|
||||
email.setBookId(booking.getId());
|
||||
email.setCreatedAt(DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss"));
|
||||
email.setCreatedBy(userId);
|
||||
booking.setChangeCheckinDate(ciDate);
|
||||
booking.setChangeCheckoutDate(coDate);
|
||||
bookingView = this.getEmailInfo(bookingView, userId);
|
||||
CfgSettings emailAddress = settingService.getSettingByKey(SysConstants.MGM_EMAIL_ADDRESS);
|
||||
email = SendEmail.sendCancelEmail(booking, bookingView, email, userId, userName, emailAddress.getKeyValues());
|
||||
if (email.getStatus() == 1) {
|
||||
processResult.setSuccess(true);
|
||||
} else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("Send Email Failed.");
|
||||
}
|
||||
emailDao.save(email);
|
||||
processResult.setData(bookingMapper.entityToDto(booking));
|
||||
return processResult;
|
||||
}
|
||||
ModifyBookingRequest modifyBookingRequest = new ModifyBookingRequest();
|
||||
JSONObject modifyBookingResponse = new JSONObject();
|
||||
booking.setCheckinDate(checkinDate);
|
||||
booking.setCheckoutDate(checkoutDate);
|
||||
modifyBookingRequest.setBooking(booking);
|
||||
LogUtil.info(TodoService.class, "[changeBookingDate] changeBookingDate begin" + gson.toJson(modifyBookingRequest));
|
||||
modifyBookingResponse = operaService.changeBookingDate(modifyBookingRequest);
|
||||
LogUtil.info(TodoService.class,
|
||||
"[changeBookingDate] Change Booking res" + gson.toJson(modifyBookingResponse));
|
||||
JSONObject errors = new JSONObject();
|
||||
if (!modifyBookingResponse.containsKey("message")) {
|
||||
String bookComment = operaService.makeChangeDateComment(booking);
|
||||
CfgProperties property = propertyDao.getById(booking.getPropertyId());
|
||||
GuestRequestsRequest changeDateCommentRequest = new GuestRequestsRequest();
|
||||
JSONObject changeDateCommentResponse = new JSONObject();
|
||||
changeDateCommentRequest.setActionType("ADD");
|
||||
changeDateCommentRequest.setProperty(property);
|
||||
changeDateCommentRequest.setComment(bookComment);
|
||||
changeDateCommentRequest.setConfirmationNo(booking.getConfirmationNo());
|
||||
changeDateCommentRequest.setCommentType("CASHIER");
|
||||
changeDateCommentResponse = operaService.guestRequests(changeDateCommentRequest);
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(bookingMapper.entityToDto(booking));
|
||||
} else {
|
||||
Date newDate = DateTimeUtil.getCurrentDateTime("yyyy-MM-dd HH:mm:ss");
|
||||
String errorMsg = errors.getString("message") != null ? errors.getString("message") : "System Error";
|
||||
errors = modifyBookingResponse;
|
||||
booking.setUpdatedAt(newDate);
|
||||
booking.setCreatedAt(newDate);
|
||||
booking.setApproveStatus("F");
|
||||
booking.setTryTime(5);
|
||||
booking.setErrorMessage("Cancel booking fail.Error Message [ " + errorMsg + " ] ");
|
||||
bookingDao.save(booking);
|
||||
processResult.setSuccess(false);
|
||||
processResult.setMessage(errors.getString("message") != null ? errors.getString("message") : "System Error");
|
||||
processResult.setCode("SYSTEM_ERROR");
|
||||
processResult.setData(bookingMapper.entityToDto(booking));
|
||||
}
|
||||
} else {
|
||||
// 获取setting表Cancel状态和时间区间
|
||||
CfgSettings enAbleCancel = settingService.getSettingByKey("CAN_CANCEL_OTHERBOOKING");
|
||||
// 判断状态是否启用
|
||||
if (Strings.CS.equals(enAbleCancel.getKeyValues(), "1")) {
|
||||
// 方法启用(==1),判断时间
|
||||
// 状态启用判断现在时间是否再时间区间内
|
||||
if (isPassTimeNow()) {
|
||||
//Change Non MGM Booking
|
||||
Bookings obooking = changeOtherBooking(bookId, ciDate, coDate, request);
|
||||
if (obooking != null) {
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(bookingMapper.entityToDto(obooking));
|
||||
} else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("SYSTEM_ERROR");
|
||||
processResult.setMessage("System error");
|
||||
}
|
||||
} else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("ERR_CANCEL_TIME");
|
||||
processResult.setData(bookingMapper.changeDateRequestToDto(param));
|
||||
}
|
||||
} else {
|
||||
// 如果enAbleCancel方法没有启用(==0)直接changedate
|
||||
//Change Non MGM Booking
|
||||
Bookings obooking = changeOtherBooking(bookId, ciDate, coDate, request);
|
||||
if (obooking != null) {
|
||||
processResult.setSuccess(true);
|
||||
processResult.setData(bookingMapper.entityToDto(obooking));
|
||||
} else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("SYSTEM_ERROR");
|
||||
processResult.setMessage("System error");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
processResult.setSuccess(false);
|
||||
processResult.setCode("No Booking Id.");
|
||||
processResult.setData(bookingMapper.changeDateRequestToDto(param));
|
||||
}
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
private Bookings cancelOtherBooking(Long bookId, HttpServletRequest request) {
|
||||
Bookings oBooking = bookingDao.findById(bookId).orElse(null);
|
||||
CfgOtherRoomStatus roomStatus = roomStatusDao.findByStatusName("Pending Cancel");
|
||||
SysLogBooking logBooking = new SysLogBooking();
|
||||
LoginUserInfo userInfo = SysCommon.parseUserFromToken(request);
|
||||
String oStatus = oBooking.getLastOperaStatus();
|
||||
Date now = new Date();
|
||||
// CfgOtherRoomStatus roomStatus =
|
||||
// oBooking.setCheckinDate(checkinDate);
|
||||
// oBooking.setCheckinDate(checkoutDate);
|
||||
oBooking.setOtherRoomStatusId(roomStatus.getId());
|
||||
oBooking.setLastOperaStatus("Pending Cancel");
|
||||
oBooking.setOtherFollowUpStatusId(Long.valueOf("5"));
|
||||
LogUtil.info(BookingController.class,
|
||||
"[changeBookingDate] Start Cancel Other Booking BookingId = " + oBooking.getId());
|
||||
bookingDao.save(oBooking);
|
||||
// 写入Audit Trail
|
||||
logBooking.setOccurTime(now);
|
||||
logBooking.setBookId(oBooking.getId());
|
||||
logBooking.setEventCode("Room Status");
|
||||
logBooking.setChangeFrom(oStatus);
|
||||
logBooking.setChangeTo("Pending Cancel(CANCEL BOOKING)");
|
||||
logBooking.setLoginId(userInfo.getLoginId());
|
||||
logBooking.setLoginName(userInfo.getLoginId());
|
||||
sysLogBookingService.save(logBooking);
|
||||
|
||||
// otherBookingService.processOtherAllotment(oBooking.getRoomId(), checkoutDate,
|
||||
// checkinDate, oBooking.getPropertyId(), oBooking.getSegmentId());
|
||||
return oBooking;
|
||||
}
|
||||
|
||||
private Bookings changeOtherBooking(Long bookId, String checkInDate, String checkOutDate, HttpServletRequest request) throws Exception {
|
||||
Bookings oBooking = bookingDao.findById(bookId).orElse(null);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
CfgOtherRoomStatus roomStatus = otherRoomStatusDao.findByStatusName("Pending Cancel");
|
||||
CfgOtherRoomStatus oRoomStatus = otherRoomStatusService.getOtherRoomStatusById(oBooking.getOtherRoomStatusId());
|
||||
String oStatus = oBooking.getLastOperaStatus();
|
||||
SysLogBooking logBooking = new SysLogBooking();
|
||||
Date now = new Date();
|
||||
LoginUserInfo userInfo = SysCommon.parseUserFromToken(request);
|
||||
|
||||
// 将String转换为Date
|
||||
Date checkIn = dateFormat.parse(checkInDate);
|
||||
Date checkOut = dateFormat.parse(checkOutDate);
|
||||
oBooking.setChangeCheckinDate(checkInDate);
|
||||
oBooking.setChangeCheckoutDate(checkOutDate);
|
||||
oBooking.setLastOperaStatus("Pending Cancel");
|
||||
oBooking.setOtherRoomStatusId(roomStatus.getId());
|
||||
oBooking.setOtherFollowUpStatusId(Long.valueOf("5"));
|
||||
LogUtil.info(BookingController.class,
|
||||
"[changeBookingDate] Start Change Other Booking BookingId = " + oBooking.getId());
|
||||
bookingDao.save(oBooking);
|
||||
// 写入Audit Trail
|
||||
logBooking.setOccurTime(now);
|
||||
logBooking.setBookId(oBooking.getId());
|
||||
logBooking.setEventCode("Status");
|
||||
logBooking.setChangeFrom(oStatus);
|
||||
logBooking.setChangeTo("Pending Cancel(CHANGE DATE)");
|
||||
logBooking.setLoginId(userInfo.getLoginId());
|
||||
logBooking.setLoginName(userInfo.getLoginId());
|
||||
sysLogBookingService.save(logBooking);
|
||||
otherBookingService.processOtherAllotment(oBooking.getRoomId(), checkOut,
|
||||
checkIn, oBooking.getPropertyId(), oBooking.getSegmentId());
|
||||
return oBooking;
|
||||
}
|
||||
|
||||
private BookingsView getEmailInfo(BookingsView bookView, String userId) {
|
||||
if (bookView != null) {
|
||||
JSONArray dynList = !StringUtils.isEmpty(bookView.getSharer()) && !Strings.CS.equals("[]", bookView.getSharer()) ?
|
||||
JSONArray.parseArray(bookView.getSharer()) : new JSONArray();
|
||||
String sharerString = "";
|
||||
if (!dynList.isEmpty()) {
|
||||
for (int a = 0; a < dynList.size(); a++) {
|
||||
Gson gson = new Gson();
|
||||
JSONObject shareObj = (JSONObject) dynList.get(a);
|
||||
String sharePlayerId = shareObj.getString("playerId");
|
||||
String shareName = shareObj.getString("name");
|
||||
LogUtil.info(BookingService.class,
|
||||
"[editBooking] sharePlayerId " + gson.toJson(sharePlayerId));
|
||||
LogUtil.info(BookingService.class,
|
||||
"[editBooking] shareName " + gson.toJson(shareName));
|
||||
if (!StringUtils.isEmpty(sharePlayerId)) {
|
||||
sharerString += (sharePlayerId + " " + shareName) + " ";
|
||||
} else if (!StringUtils.isEmpty(shareName)) {
|
||||
sharerString += (shareName) + " ";
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
bookView.setSharerName(sharerString);
|
||||
String playerId = bookView.getPlayerId() != null ? bookView.getPlayerId() : null;
|
||||
BaseApiResponse<PlayerProfileEntry> findWebPlayerResult = playerService.findWebPlayerProfileByPlayerId(playerId);
|
||||
if (findWebPlayerResult.isSuccess()) {
|
||||
try {
|
||||
PlayerProfileEntry profile = findWebPlayerResult.getData();
|
||||
bookView.setMemberTier(profile.getTierName());
|
||||
bookView.setMemberLastName(profile.getName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return bookView;
|
||||
}
|
||||
|
||||
// 判断时间是否超过viewYesterday Range
|
||||
private boolean isPassTimeNow() {
|
||||
boolean isPass = false;
|
||||
CfgSettings cancelStart = settingService.getSettingByKey("OTHERBOOKING_CANCEL_START");
|
||||
CfgSettings cancelEnd = settingService.getSettingByKey("OTHERBOOKING_CANCEL_END");
|
||||
int startMinute = Integer.parseInt(cancelStart.getKeyValues().split(":")[0]) * 60
|
||||
+ Integer.parseInt(cancelStart.getKeyValues().split(":")[1]);
|
||||
int endMinute = Integer.parseInt(cancelEnd.getKeyValues().split(":")[0]) * 60
|
||||
+ Integer.parseInt(cancelEnd.getKeyValues().split(":")[1]);
|
||||
// 获跟当就的日期和时间
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
int currentMinute = currentDateTime.getMinute() + currentDateTime.getHour() * 60;
|
||||
if (currentMinute > startMinute && currentMinute < endMinute) {
|
||||
isPass = true;
|
||||
}
|
||||
return isPass;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user