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