merge limo to daylight
This commit is contained in:
@@ -42,6 +42,7 @@ public class SysCommon {
|
||||
public static String defaultRouter = "welcome";
|
||||
public static String runtimeName="crm_mobile_runtime";
|
||||
public static int postTimeOut = 20;
|
||||
|
||||
//for stress test
|
||||
public static int tokenExpMin = 5;
|
||||
public static int refreshTokenExpDay = 30;
|
||||
|
||||
@@ -24,6 +24,8 @@ public class SysConstants {
|
||||
public static final String PERMISSION_APP_TODO_LIST="10001_03";
|
||||
public static final String PERMISSION_APP_DASHBOARD="10001_04";
|
||||
public static final String PERMISSION_APP_APPROVAL="10001_05";
|
||||
public static final String PERMISSION_APP_VIEW_NOTIFICATION="10001_06";
|
||||
public static final String PERMISSION_APP_CALENDAR="10001_07";
|
||||
public static final String PERMISSION_APP_VIEW_LIMO="10001_08";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mgm.mcrm.common.dtos.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class APIConfig {
|
||||
|
||||
private boolean isLoaded = false;
|
||||
@@ -9,6 +12,11 @@ public class APIConfig {
|
||||
private String apiSecret_ESB="";
|
||||
private int timeout_ESB=0;
|
||||
|
||||
|
||||
private String limoService_ESB="";
|
||||
private String limoApp_id="";
|
||||
private String limoApp_key="";
|
||||
|
||||
private String serverUrl_ESB_Daylight="";
|
||||
private String apiKey_ESB_Daylight="";
|
||||
private String apiSecret_ESB_Daylight="";
|
||||
@@ -52,225 +60,4 @@ public class APIConfig {
|
||||
private String password_SMTP= "";
|
||||
private String send_to_SMTP= "";
|
||||
|
||||
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
public void setLoaded(boolean isLoaded) {
|
||||
this.isLoaded = isLoaded;
|
||||
}
|
||||
|
||||
public String getServerUrl_ESB() {
|
||||
return serverUrl_ESB;
|
||||
}
|
||||
public void setServerUrl_ESB(String serverUrl_ESB) {
|
||||
this.serverUrl_ESB = serverUrl_ESB;
|
||||
}
|
||||
public String getApiKey_ESB() {
|
||||
return apiKey_ESB;
|
||||
}
|
||||
public void setApiKey_ESB(String apiKey_ESB) {
|
||||
this.apiKey_ESB = apiKey_ESB;
|
||||
}
|
||||
public String getApiSecret_ESB() {
|
||||
return apiSecret_ESB;
|
||||
}
|
||||
public void setApiSecret_ESB(String apiSecret_ESB) {
|
||||
this.apiSecret_ESB = apiSecret_ESB;
|
||||
}
|
||||
public int getTimeout_ESB() {
|
||||
return timeout_ESB;
|
||||
}
|
||||
public void setTimeout_ESB(int timeout_ESB) {
|
||||
this.timeout_ESB = timeout_ESB;
|
||||
}
|
||||
public String getServerLoginUrl_RPA() {
|
||||
return serverLoginUrl_RPA;
|
||||
}
|
||||
public void setServerLoginUrl_RPA(String serverLoginUrl_RPA) {
|
||||
this.serverLoginUrl_RPA = serverLoginUrl_RPA;
|
||||
}
|
||||
public String getApiAccessName_RPA() {
|
||||
return apiAccessName_RPA;
|
||||
}
|
||||
public void setApiAccessName_RPA(String apiAccessName_RPA) {
|
||||
this.apiAccessName_RPA = apiAccessName_RPA;
|
||||
}
|
||||
public String getApiAccessPassword_RPA() {
|
||||
return apiAccessPassword_RPA;
|
||||
}
|
||||
public void setApiAccessPassword_RPA(String apiAccessPassword_RPA) {
|
||||
this.apiAccessPassword_RPA = apiAccessPassword_RPA;
|
||||
}
|
||||
public String getApiAccessKey_RPA() {
|
||||
return apiAccessKey_RPA;
|
||||
}
|
||||
public void setApiAccessKey_RPA(String apiAccessKey_RPA) {
|
||||
this.apiAccessKey_RPA = apiAccessKey_RPA;
|
||||
}
|
||||
public String getServerAddUrl_RPA() {
|
||||
return serverAddUrl_RPA;
|
||||
}
|
||||
public void setServerAddUrl_RPA(String serverAddUrl_RPA) {
|
||||
this.serverAddUrl_RPA = serverAddUrl_RPA;
|
||||
}
|
||||
public String getServerExtensionUrl_RPA() {
|
||||
return serverExtensionUrl_RPA;
|
||||
}
|
||||
public void setServerExtensionUrl_RPA(String serverExtensionUrl_RPA) {
|
||||
this.serverExtensionUrl_RPA = serverExtensionUrl_RPA;
|
||||
}
|
||||
public int getTimeout_RPA() {
|
||||
return timeout_RPA;
|
||||
}
|
||||
public void setTimeout_RPA(int timeout_RPA) {
|
||||
this.timeout_RPA = timeout_RPA;
|
||||
}
|
||||
public String getServerUrl_SSO() {
|
||||
return serverUrl_SSO;
|
||||
}
|
||||
public void setServerUrl_SSO(String serverUrl_SSO) {
|
||||
this.serverUrl_SSO = serverUrl_SSO;
|
||||
}
|
||||
|
||||
public String getClientId_SSO() {
|
||||
return clientId_SSO;
|
||||
}
|
||||
public void setClientId_SSO(String clientId_SSO) {
|
||||
this.clientId_SSO = clientId_SSO;
|
||||
}
|
||||
public String getClientSecret_SSO() {
|
||||
return clientSecret_SSO;
|
||||
}
|
||||
public void setClientSecret_SSO(String clientSecret_SSO) {
|
||||
this.clientSecret_SSO = clientSecret_SSO;
|
||||
}
|
||||
public int getTimeout_SSO() {
|
||||
return timeout_SSO;
|
||||
}
|
||||
public void setTimeout_SSO(int timeout_SSO) {
|
||||
this.timeout_SSO = timeout_SSO;
|
||||
}
|
||||
public String getServerUrl_CallCenter() {
|
||||
return serverUrl_CallCenter;
|
||||
}
|
||||
public void setServerUrl_CallCenter(String serverUrl_CallCenter) {
|
||||
this.serverUrl_CallCenter = serverUrl_CallCenter;
|
||||
}
|
||||
public int getTimeout_CallCenter() {
|
||||
return timeout_CallCenter;
|
||||
}
|
||||
public void setTimeout_CallCenter(int timeout_CallCenter) {
|
||||
this.timeout_CallCenter = timeout_CallCenter;
|
||||
}
|
||||
public String getTokenUrl_SMS() {
|
||||
return tokenUrl_SMS;
|
||||
}
|
||||
public void setTokenUrl_SMS(String tokenUrl_SMS) {
|
||||
this.tokenUrl_SMS = tokenUrl_SMS;
|
||||
}
|
||||
public String getSendUrl_SMS() {
|
||||
return sendUrl_SMS;
|
||||
}
|
||||
public void setSendUrl_SMS(String sendUrl_SMS) {
|
||||
this.sendUrl_SMS = sendUrl_SMS;
|
||||
}
|
||||
public String getUsername_SMS() {
|
||||
return username_SMS;
|
||||
}
|
||||
public void setUsername_SMS(String username_SMS) {
|
||||
this.username_SMS = username_SMS;
|
||||
}
|
||||
public String getPassword_SMS() {
|
||||
return password_SMS;
|
||||
}
|
||||
public void setPassword_SMS(String password_SMS) {
|
||||
this.password_SMS = password_SMS;
|
||||
}
|
||||
public String getAccount_SMS() {
|
||||
return account_SMS;
|
||||
}
|
||||
public void setAccount_SMS(String account_SMS) {
|
||||
this.account_SMS = account_SMS;
|
||||
}
|
||||
public String getPriority_SMS() {
|
||||
return priority_SMS;
|
||||
}
|
||||
public void setPriority_SMS(String priority_SMS) {
|
||||
this.priority_SMS = priority_SMS;
|
||||
}
|
||||
public String getServerUrl_OWS() {
|
||||
return serverUrl_OWS;
|
||||
}
|
||||
public void setServerUrl_OWS(String serverUrl_OWS) {
|
||||
this.serverUrl_OWS = serverUrl_OWS;
|
||||
}
|
||||
public int getTimeout_OWS() {
|
||||
return timeout_OWS;
|
||||
}
|
||||
public void setTimeout_OWS(int timeout_OWS) {
|
||||
this.timeout_OWS = timeout_OWS;
|
||||
}
|
||||
public String getPort_SMTP() {
|
||||
return port_SMTP;
|
||||
}
|
||||
public void setPort_SMTP(String port_SMTP) {
|
||||
this.port_SMTP = port_SMTP;
|
||||
}
|
||||
public String getHost_SMTP() {
|
||||
return host_SMTP;
|
||||
}
|
||||
public void setHost_SMTP(String host_SMTP) {
|
||||
this.host_SMTP = host_SMTP;
|
||||
}
|
||||
public String getUsername_SMTP() {
|
||||
return username_SMTP;
|
||||
}
|
||||
public void setUsername_SMTP(String username_SMTP) {
|
||||
this.username_SMTP = username_SMTP;
|
||||
}
|
||||
public String getPassword_SMTP() {
|
||||
return password_SMTP;
|
||||
}
|
||||
public void setPassword_SMTP(String password_SMTP) {
|
||||
this.password_SMTP = password_SMTP;
|
||||
}
|
||||
public String getSend_to_SMTP() {
|
||||
return send_to_SMTP;
|
||||
}
|
||||
public void setSend_to_SMTP(String send_to_SMTP) {
|
||||
this.send_to_SMTP = send_to_SMTP;
|
||||
}
|
||||
|
||||
public String getServerUrl_ESB_Daylight() {
|
||||
return serverUrl_ESB_Daylight;
|
||||
}
|
||||
|
||||
public void setServerUrl_ESB_Daylight(String serverUrl_ESB_Daylight) {
|
||||
this.serverUrl_ESB_Daylight = serverUrl_ESB_Daylight;
|
||||
}
|
||||
|
||||
public String getApiKey_ESB_Daylight() {
|
||||
return apiKey_ESB_Daylight;
|
||||
}
|
||||
|
||||
public void setApiKey_ESB_Daylight(String apiKey_ESB_Daylight) {
|
||||
this.apiKey_ESB_Daylight = apiKey_ESB_Daylight;
|
||||
}
|
||||
|
||||
public String getApiSecret_ESB_Daylight() {
|
||||
return apiSecret_ESB_Daylight;
|
||||
}
|
||||
|
||||
public void setApiSecret_ESB_Daylight(String apiSecret_ESB_Daylight) {
|
||||
this.apiSecret_ESB_Daylight = apiSecret_ESB_Daylight;
|
||||
}
|
||||
|
||||
public int getTimeout_ESB_Daylight() {
|
||||
return timeout_ESB_Daylight;
|
||||
}
|
||||
|
||||
public void setTimeout_ESB_Daylight(int timeout_ESB_Daylight) {
|
||||
this.timeout_ESB_Daylight = timeout_ESB_Daylight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetLimoAccessTokenRequest {
|
||||
|
||||
private String LoginId;
|
||||
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetLimoFlightDetailsRequest {
|
||||
private String flightNo;
|
||||
private String pickupDateTime;
|
||||
private String pickupAirportCode;
|
||||
private String dropOffAirportCode;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetLimoOverriderRequest {
|
||||
|
||||
private String OverriderIdOrName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetLimoTotalAmountRequest {
|
||||
private String pickupPOIId;
|
||||
private String dropoffPOIIds;
|
||||
private String singleTripPrices;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetPlayerInfoRequest {
|
||||
|
||||
private String playerId;
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetSimpleLimoBookingQualificationStatusRequest {
|
||||
|
||||
private String playerId;
|
||||
|
||||
private String bookingType;
|
||||
|
||||
private String bookingDate;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class InternalCreateLimoBookingRequest {
|
||||
|
||||
private int createNotConfirmBooking;
|
||||
private String bookingType;
|
||||
private String greetType;
|
||||
private String otherGreetType;
|
||||
private String guestType;
|
||||
private String tripType;
|
||||
|
||||
private String playerId;
|
||||
private String ranking;
|
||||
private String overrideBy;
|
||||
private String complexOverrider;
|
||||
|
||||
private String roomNo;
|
||||
private String employeeId;
|
||||
|
||||
private String lastName;
|
||||
private String salution;
|
||||
private String chineseLastName;
|
||||
|
||||
private String bookerContact;
|
||||
private String tripContact;
|
||||
|
||||
private int adHoc;
|
||||
|
||||
private LocalDateTime pickupDatetime;
|
||||
|
||||
private Long carTypeId;
|
||||
private Integer passengerNo;
|
||||
|
||||
private Long pickupPOIID;
|
||||
private String pickup;
|
||||
private Long pickupTripPriceId;
|
||||
private String pickupRegion;
|
||||
|
||||
private Long dropoffPOIID;
|
||||
private String dropoff;
|
||||
private Long dropoffTripPriceId;
|
||||
private String dropoffRegion;
|
||||
|
||||
private Long extraDropoffPOIID1;
|
||||
private String extraDropoff1;
|
||||
private Long extraDropoffTripPriceID1;
|
||||
private String extraDropoffRegion1;
|
||||
|
||||
private Long extraDropoffPOIID2;
|
||||
private String extraDropoff2;
|
||||
private Long extraDropoffTripPriceID2;
|
||||
private String extraDropoffRegion2;
|
||||
|
||||
private Long extraDropoffPOIID3;
|
||||
private String extraDropoff3;
|
||||
private Long extraDropoffTripPriceID3;
|
||||
private String extraDropoffRegion3;
|
||||
|
||||
private Long extraDropoffPOIID4;
|
||||
private String extraDropoff4;
|
||||
private Long extraDropoffTripPriceID4;
|
||||
private String extraDropoffRegion4;
|
||||
|
||||
private Long extraDropoffPOIID5;
|
||||
private String extraDropoff5;
|
||||
private Long extraDropoffTripPriceID5;
|
||||
private String extraDropoffRegion5;
|
||||
|
||||
private Long extraDropoffPOIID6;
|
||||
private String extraDropoff6;
|
||||
private Long extraDropoffTripPriceID6;
|
||||
private String extraDropoffRegion6;
|
||||
|
||||
private Long extraDropoffPOIID7;
|
||||
private String extraDropoff7;
|
||||
private Long extraDropoffTripPriceID7;
|
||||
private String extraDropoffRegion7;
|
||||
|
||||
private Long extraDropoffPOIID8;
|
||||
private String extraDropoff8;
|
||||
private Long extraDropoffTripPriceID8;
|
||||
private String extraDropoffRegion8;
|
||||
|
||||
private Long extraDropoffPOIID9;
|
||||
private String extraDropoff9;
|
||||
private Long extraDropoffTripPriceID9;
|
||||
private String extraDropoffRegion9;
|
||||
|
||||
private Long extraDropoffPOIID10;
|
||||
private String extraDropoff10;
|
||||
private Long extraDropoffTripPriceID10;
|
||||
private String extraDropoffRegion10;
|
||||
|
||||
private BigDecimal singleTripPrice;
|
||||
private BigDecimal defaultTripPrice;
|
||||
private BigDecimal defaultPublishTripPrice;
|
||||
|
||||
private BigDecimal hourlyRate;
|
||||
private BigDecimal hourlyWaitingFee;
|
||||
|
||||
private Integer hour;
|
||||
private Integer hourlyWaiting;
|
||||
|
||||
private BigDecimal extraDropoffPrice1;
|
||||
private BigDecimal extraDropoffPrice2;
|
||||
private BigDecimal extraDropoffPrice3;
|
||||
private BigDecimal extraDropoffPrice4;
|
||||
private BigDecimal extraDropoffPrice5;
|
||||
private BigDecimal extraDropoffPrice6;
|
||||
private BigDecimal extraDropoffPrice7;
|
||||
private BigDecimal extraDropoffPrice8;
|
||||
private BigDecimal extraDropoffPrice9;
|
||||
private BigDecimal extraDropoffPrice10;
|
||||
|
||||
private String otherPriceRemark;
|
||||
private BigDecimal otherPrice;
|
||||
|
||||
private String paymentMethod;
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
private Boolean highImportance;
|
||||
private Boolean tenOut;
|
||||
private Boolean butlerGreet;
|
||||
|
||||
private String bookedBy;
|
||||
private String approvedBy;
|
||||
|
||||
private String bookingRemark;
|
||||
private String driverRemark;
|
||||
private String limoInternalRemark;
|
||||
private String systemRemark;
|
||||
|
||||
private Boolean limoGreet;
|
||||
private Boolean hostGreet;
|
||||
private Boolean vipMeetNGreet;
|
||||
|
||||
private String otherGreet;
|
||||
private String flightDetails;
|
||||
private String signage;
|
||||
|
||||
public int getCreateNotConfirmBooking() {
|
||||
return createNotConfirmBooking;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class InternalUpdateLimoBookingRequest {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Boolean createNotConfirmBooking;
|
||||
private String bookingType;
|
||||
private String greetType;
|
||||
private String otherGreetType;
|
||||
private String guestType;
|
||||
private String tripType;
|
||||
|
||||
private String playerId;
|
||||
private String ranking;
|
||||
private String overrideBy;
|
||||
private String complexOverrider;
|
||||
|
||||
private String roomNo;
|
||||
private String employeeId;
|
||||
|
||||
private String lastName;
|
||||
private String salution;
|
||||
private String chineseLastName;
|
||||
|
||||
private String bookerContact;
|
||||
private String tripContact;
|
||||
|
||||
private String adHoc;
|
||||
|
||||
private LocalDateTime pickupDatetime;
|
||||
|
||||
private Long carTypeId;
|
||||
private Integer passengerNo;
|
||||
|
||||
private Long pickupPOIID;
|
||||
private String pickup;
|
||||
private Long pickupTripPriceID;
|
||||
private String pickupRegion;
|
||||
|
||||
private Long dropoffPOIID;
|
||||
private String dropoff;
|
||||
private Long dropoffTripPriceID;
|
||||
private String dropoffRegion;
|
||||
|
||||
private Long extraDropoffPOIID1;
|
||||
private String extraDropoff1;
|
||||
private Long extraDropoffTripPriceID1;
|
||||
private String extraDropoffRegion1;
|
||||
|
||||
private Long extraDropoffPOIID2;
|
||||
private String extraDropoff2;
|
||||
private Long extraDropoffTripPriceID2;
|
||||
private String extraDropoffRegion2;
|
||||
|
||||
private Long extraDropoffPOIID3;
|
||||
private String extraDropoff3;
|
||||
private Long extraDropoffTripPriceID3;
|
||||
private String extraDropoffRegion3;
|
||||
|
||||
private Long extraDropoffPOIID4;
|
||||
private String extraDropoff4;
|
||||
private Long extraDropoffTripPriceID4;
|
||||
private String extraDropoffRegion4;
|
||||
|
||||
private Long extraDropoffPOIID5;
|
||||
private String extraDropoff5;
|
||||
private Long extraDropoffTripPriceID5;
|
||||
private String extraDropoffRegion5;
|
||||
|
||||
private Long extraDropoffPOIID6;
|
||||
private String extraDropoff6;
|
||||
private Long extraDropoffTripPriceID6;
|
||||
private String extraDropoffRegion6;
|
||||
|
||||
private Long extraDropoffPOIID7;
|
||||
private String extraDropoff7;
|
||||
private Long extraDropoffTripPriceID7;
|
||||
private String extraDropoffRegion7;
|
||||
|
||||
private Long extraDropoffPOIID8;
|
||||
private String extraDropoff8;
|
||||
private Long extraDropoffTripPriceID8;
|
||||
private String extraDropoffRegion8;
|
||||
|
||||
private Long extraDropoffPOIID9;
|
||||
private String extraDropoff9;
|
||||
private Long extraDropoffTripPriceID9;
|
||||
private String extraDropoffRegion9;
|
||||
|
||||
private Long extraDropoffPOIID10;
|
||||
private String extraDropoff10;
|
||||
private Long extraDropoffTripPriceID10;
|
||||
private String extraDropoffRegion10;
|
||||
|
||||
private BigDecimal singleTripPrice;
|
||||
private BigDecimal defaultTripPrice;
|
||||
private BigDecimal defaultPublishTripPrice;
|
||||
|
||||
private BigDecimal hourlyRate;
|
||||
private BigDecimal hourlyWaitingFee;
|
||||
|
||||
private Integer hour;
|
||||
private Integer hourlyWaiting;
|
||||
|
||||
private BigDecimal extraDropoffPrice1;
|
||||
private BigDecimal extraDropoffPrice2;
|
||||
private BigDecimal extraDropoffPrice3;
|
||||
private BigDecimal extraDropoffPrice4;
|
||||
private BigDecimal extraDropoffPrice5;
|
||||
private BigDecimal extraDropoffPrice6;
|
||||
private BigDecimal extraDropoffPrice7;
|
||||
private BigDecimal extraDropoffPrice8;
|
||||
private BigDecimal extraDropoffPrice9;
|
||||
private BigDecimal extraDropoffPrice10;
|
||||
|
||||
private String otherPriceRemark;
|
||||
private BigDecimal otherPrice;
|
||||
|
||||
private String paymentMethod;
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
private Boolean highImportance;
|
||||
private Boolean tenOut;
|
||||
private Boolean butlerGreet;
|
||||
|
||||
private String bookedBy;
|
||||
private String approvedBy;
|
||||
|
||||
private String bookingRemark;
|
||||
private String driverRemark;
|
||||
private String limoInternalRemark;
|
||||
private String systemRemark;
|
||||
|
||||
private Boolean limoGreet;
|
||||
private Boolean hostGreet;
|
||||
private Boolean vipMeetNGreet;
|
||||
|
||||
private String otherGreet;
|
||||
private String flightDetails;
|
||||
private String signage;
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PlayerProfileApiResult {
|
||||
|
||||
private String statusCode = null;
|
||||
private String statusDescription="";
|
||||
private String playerId;
|
||||
private String userId;
|
||||
private String tierName;
|
||||
private String tierId;
|
||||
private String chineseName;
|
||||
private String englishName;
|
||||
private String salutation;
|
||||
private Integer codedFlag;
|
||||
private String name;
|
||||
private String playerPhone;
|
||||
private String phoneType;
|
||||
private String birthday;
|
||||
private String country;
|
||||
private String state;
|
||||
private String passport;
|
||||
private String language;
|
||||
private List<Integer> nameIds=new ArrayList<Integer>();
|
||||
|
||||
public PlayerProfileApiResult() {
|
||||
|
||||
}
|
||||
|
||||
public String getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(String statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public String getStatusDescription() {
|
||||
return statusDescription;
|
||||
}
|
||||
|
||||
public void setStatusDescription(String statusDescription) {
|
||||
this.statusDescription = statusDescription;
|
||||
}
|
||||
|
||||
public String getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public void setPlayerId(String playerId) {
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTierName() {
|
||||
return tierName;
|
||||
}
|
||||
|
||||
public void setTierName(String tierName) {
|
||||
this.tierName = tierName;
|
||||
}
|
||||
|
||||
public String getTierId() {
|
||||
return tierId;
|
||||
}
|
||||
|
||||
public void setTierId(String tierId) {
|
||||
this.tierId = tierId;
|
||||
}
|
||||
|
||||
public String getChineseName() {
|
||||
return chineseName;
|
||||
}
|
||||
|
||||
public void setChineseName(String chineseName) {
|
||||
this.chineseName = chineseName;
|
||||
}
|
||||
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
|
||||
public void setEnglishName(String englishName) {
|
||||
this.englishName = englishName;
|
||||
}
|
||||
|
||||
public String getSalutation() {
|
||||
return salutation;
|
||||
}
|
||||
|
||||
public void setSalutation(String salutation) {
|
||||
this.salutation = salutation;
|
||||
}
|
||||
|
||||
public List<Integer> getNameIds() {
|
||||
return nameIds;
|
||||
}
|
||||
|
||||
public void setNameIds(List<Integer> nameIds) {
|
||||
this.nameIds = nameIds;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getCodedFlag() {
|
||||
return codedFlag;
|
||||
}
|
||||
|
||||
public void setCodedFlag(Integer codedFlag) {
|
||||
this.codedFlag = codedFlag;
|
||||
}
|
||||
|
||||
public String getPlayerPhone() {
|
||||
return playerPhone;
|
||||
}
|
||||
|
||||
public void setPlayerPhone(String playerPhone) {
|
||||
this.playerPhone = playerPhone;
|
||||
}
|
||||
|
||||
public String getPhoneType() {
|
||||
return phoneType;
|
||||
}
|
||||
|
||||
public void setPhoneType(String phoneType) {
|
||||
this.phoneType = phoneType;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getPassport() {
|
||||
return passport;
|
||||
}
|
||||
|
||||
public void setPassport(String passport) {
|
||||
this.passport = passport;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mgm.mcrm.common.dtos.mgm_api;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RequestPlayerLimoBookerRequest {
|
||||
private String playerId;
|
||||
private String userId;
|
||||
}
|
||||
@@ -21,12 +21,15 @@ public class UserInfoApiRecord {
|
||||
private Long sectionId;
|
||||
private Long blockId;
|
||||
private Long teamStructureId;
|
||||
private String paymentMethod;
|
||||
private boolean canViewBooking=false;
|
||||
private boolean canNewBooking=false;
|
||||
private boolean canViewTodoList=false;
|
||||
private boolean canViewDashboard=false;
|
||||
private boolean canViewApproval=false;
|
||||
private boolean canViewCalendar=false;
|
||||
private boolean canViewNotification=false;
|
||||
private boolean canViewLimo=false;
|
||||
private String groupName;
|
||||
private String phone;
|
||||
private boolean loginTag;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HttpService {
|
||||
.client(httpClient);
|
||||
|
||||
String result = HttpClientExecutor.get(getConfig, headers);
|
||||
log.info("GET request result size={}", result);
|
||||
log.info("GET request result size={}", result.length());
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class HttpService {
|
||||
.client(httpClient);
|
||||
HttpResult result = HttpClientExecutor.sendAndPostResp(postConfig, headers);
|
||||
// System.out.println("POST 请求结果:\n" + result);
|
||||
log.info("POST request result={}", result);
|
||||
log.info("POST request result size={}", result.getResult().length());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class MGMApiService {
|
||||
private static final String API_GET_APPROVER="/RequestRoomBookingApprovalRouting";
|
||||
private static final String API_GET_TODO_LIST = "/GetTodolist";
|
||||
private static final String API_REQUEST_ROOM_CALENDAR = "/RequestRoomCalendar";
|
||||
private static final String API_GET_LIMO_BOOKING_FROM_LEGACY = "/GetLimoBookingFromLegacy";
|
||||
|
||||
|
||||
public HttpResponseResult invokeRequestRoomCalendar(
|
||||
@@ -339,6 +340,26 @@ public class MGMApiService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeGetLimoBookingFromLegacy(
|
||||
String playerId
|
||||
) throws Exception {
|
||||
HttpResponseResult result = null;
|
||||
String apiLink = API_GET_LIMO_BOOKING_FROM_LEGACY;
|
||||
|
||||
JSONObject requestObj = new JSONObject();
|
||||
Map<String, String> requestHeader = new HashMap<>();
|
||||
|
||||
String token = getAccessToken();
|
||||
|
||||
requestHeader.put("Authorization", token);
|
||||
|
||||
requestObj.put("PlayerId", playerId);
|
||||
|
||||
result = this.invokeESBAPI(ESB_Server, apiLink, requestObj, "POST", requestHeader);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public HttpResponseResult invokeGetTodoList(
|
||||
String userId,
|
||||
String category,
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
package com.mgm.mcrm.common.services;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.mgm.mcrm.common.constants.SysCommon;
|
||||
import com.mgm.mcrm.common.dtos.http_util.HttpRequestDefine;
|
||||
import com.mgm.mcrm.common.dtos.http_util.HttpResponseResult;
|
||||
import com.mgm.mcrm.common.utils.DateTimeUtil;
|
||||
import com.mgm.mcrm.common.utils.HttpUtil;
|
||||
import com.mgm.mcrm.common.utils.LogUtil;
|
||||
import com.mgm.mcrm.common.utils.mockup.HttpUtilMockup;
|
||||
import com.mgm.mcrm.limo.dtos.request.RequestPlayerEsbBookerRequest;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class MGMEsbApiService {
|
||||
|
||||
public static String LIMO_ESB_APP_ID = "";
|
||||
public static String LIMO_ESB_APP_SECRET = "";
|
||||
public static String LIMO_ESB_SERVER = "";
|
||||
public static String LIMO_ESB_ACCESS_TOKEN = "";
|
||||
public static Date LIMO_ESB_EXPIRED_TIME = new Date();
|
||||
|
||||
private static final String API_GET_ACCESS_TOKEN = "/RequestAccessToken";
|
||||
private static final String API_GET_LIMO_OVERRIDER = "/RequestLimoOverrider";
|
||||
private static final String API_CHECK_SIMPLE_LIMO_BOOKING_QUALIFICATION_STATUS = "/RequestSimpleLimoBookingQualificationStatus";
|
||||
private static final String API_CHECK_COMPLEX_LIMO_BOOKING_QUALIFICATION_STATUS = "/RequestComplexLimoBookingQualificationStatus";
|
||||
private static final String API_REQUEST_EMPLOYEE_INFO = "/RequestEmployeeInfo";
|
||||
private static final String API_REQUEST_PLAYER_LIMO_BOOKER = "/RequestPlayerLimoBooker";
|
||||
private static final String API_REQUEST_PLAYER_INFO = "/RequestPlayerInfo";
|
||||
|
||||
|
||||
public HttpResponseResult invokeRequestPlayerLimoBooker(RequestPlayerEsbBookerRequest request) throws Exception {
|
||||
|
||||
String apiLink = API_REQUEST_PLAYER_LIMO_BOOKER;
|
||||
|
||||
JSONObject requestObj = new JSONObject();
|
||||
Map<String, String> requestHeader = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestHeader.put("Authorization", token);
|
||||
|
||||
requestObj.put("EmployeeIdOrName", request.getUserId());
|
||||
requestObj.put("PlayerId", request.getPlayerId());
|
||||
|
||||
return this.invokeESBAPI(LIMO_ESB_SERVER, apiLink, requestObj, "POST", requestHeader);
|
||||
|
||||
}
|
||||
|
||||
public String getLimoAccessToken() throws Exception {
|
||||
|
||||
String token = LIMO_ESB_ACCESS_TOKEN;
|
||||
|
||||
if (SysCommon.mgmApiMockup)
|
||||
return token;
|
||||
|
||||
LIMO_ESB_APP_ID = SysCommon.apiConfig.getLimoApp_id();
|
||||
LIMO_ESB_APP_SECRET = SysCommon.apiConfig.getLimoApp_key();
|
||||
LIMO_ESB_SERVER = SysCommon.apiConfig.getLimoService_ESB();
|
||||
|
||||
|
||||
if (token == null || LIMO_ESB_EXPIRED_TIME.getTime() < new Date().getTime()) {
|
||||
|
||||
String apiLink = API_GET_ACCESS_TOKEN;
|
||||
|
||||
JSONObject requestObj = new JSONObject();
|
||||
Map<String, String> requestHeader = new HashMap<>();
|
||||
|
||||
requestObj.put("AppId", LIMO_ESB_APP_ID);
|
||||
requestObj.put("AppSecret", LIMO_ESB_APP_SECRET);
|
||||
|
||||
HttpResponseResult result =
|
||||
this.invokeESBAPI(LIMO_ESB_SERVER, apiLink, requestObj, "POST", requestHeader);
|
||||
|
||||
if (result.getStatusCode() == 200) {
|
||||
JSONObject resultObj = JSONObject.parseObject(result.getResponseContent());
|
||||
String status = resultObj.getString("StatusCode");
|
||||
|
||||
if (Strings.CI.equals("OK", status)) {
|
||||
token = resultObj.getString("Token");
|
||||
LIMO_ESB_EXPIRED_TIME =
|
||||
DateTimeUtil.getDateFromString(resultObj.getString("ExpireTime"), "yyyy-MM-dd HH:mm:ss");
|
||||
LIMO_ESB_ACCESS_TOKEN = token;
|
||||
} else {
|
||||
token = null;
|
||||
LIMO_ESB_ACCESS_TOKEN = null;
|
||||
LIMO_ESB_EXPIRED_TIME = new Date();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeLimoOverrider(
|
||||
String overriderIdOrName
|
||||
) throws Exception {
|
||||
|
||||
String apiLink = API_GET_LIMO_OVERRIDER;
|
||||
|
||||
JSONObject requestObj = new JSONObject();
|
||||
Map<String, String> requestHeader = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestHeader.put("Authorization", token);
|
||||
|
||||
requestObj.put("OverriderIdOrName", "%");
|
||||
|
||||
return this.invokeESBAPI(LIMO_ESB_SERVER, apiLink, requestObj, "POST", requestHeader);
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeLimoPlayerInfo(
|
||||
Integer playerId
|
||||
) throws Exception {
|
||||
|
||||
String apiLink = API_REQUEST_PLAYER_INFO;
|
||||
|
||||
JSONObject requestObj = new JSONObject();
|
||||
Map<String, String> requestHeader = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestHeader.put("Authorization", token);
|
||||
|
||||
requestObj.put("PlayerId", playerId);
|
||||
|
||||
return this.invokeESBAPI(LIMO_ESB_SERVER, apiLink, requestObj, "POST", requestHeader);
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeSimpleLimoBookingQualificationStatus(
|
||||
Integer playerId,
|
||||
String bookingType,
|
||||
String bookingDate
|
||||
) throws Exception {
|
||||
|
||||
String apiLink = API_CHECK_SIMPLE_LIMO_BOOKING_QUALIFICATION_STATUS;
|
||||
|
||||
JSONObject requestObj = new JSONObject();
|
||||
Map<String, String> requestHeader = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestHeader.put("Authorization", token);
|
||||
|
||||
requestObj.put("PlayerId", playerId);
|
||||
requestObj.put("BookingType", bookingType);
|
||||
requestObj.put("BookingDate", bookingDate);
|
||||
|
||||
return this.invokeESBAPI(LIMO_ESB_SERVER, apiLink, requestObj, "POST", requestHeader);
|
||||
}
|
||||
|
||||
|
||||
public HttpResponseResult invokeRequestEmployeeInfo(String employeeId) throws Exception {
|
||||
|
||||
String apiLink = API_REQUEST_EMPLOYEE_INFO;
|
||||
|
||||
JSONObject requestObj = new JSONObject();
|
||||
Map<String, String> requestHeader = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestHeader.put("Authorization", token);
|
||||
|
||||
requestObj.put("EmployeeId", employeeId);
|
||||
|
||||
return this.invokeESBAPI(LIMO_ESB_SERVER, apiLink, requestObj, "POST", requestHeader);
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeESBAPI(
|
||||
String serverType,
|
||||
String requestLink,
|
||||
JSONObject requestContent,
|
||||
String requestMethod,
|
||||
Map<String, String> requestHeader) throws Exception {
|
||||
|
||||
String serverUrl;
|
||||
int timeoutTime;
|
||||
|
||||
//Get Spend Time
|
||||
Gson gson = new Gson();
|
||||
|
||||
HttpRequestDefine requestDef = new HttpRequestDefine();
|
||||
|
||||
LogUtil.info(MGMEsbApiService.class,"Request Url = "+gson.toJson(requestDef.getRequestUrl())+"serverType: " + serverType+"LIMO_ESB_SERVER"+LIMO_ESB_SERVER);
|
||||
|
||||
if (Strings.CS.equals(serverType, LIMO_ESB_SERVER)) {
|
||||
serverUrl = SysCommon.apiConfig.getLimoService_ESB();
|
||||
timeoutTime = SysCommon.apiConfig.getTimeout_ESB();
|
||||
} else {
|
||||
throw new Exception("Invalid server type");
|
||||
}
|
||||
|
||||
String requestUrl = serverUrl + requestLink;
|
||||
|
||||
requestDef.setRequestUrl(requestUrl);
|
||||
requestDef.setRequestMethod(requestMethod);
|
||||
requestDef.setTimeout(timeoutTime);
|
||||
|
||||
requestHeader.put("Content-type", "application/json;charset=utf-8");
|
||||
|
||||
requestDef.setHeaders(requestHeader);
|
||||
|
||||
if (requestContent != null)
|
||||
requestDef.setEntityContent(requestContent.toString());
|
||||
else
|
||||
requestDef.setEntityContent("");
|
||||
|
||||
//Get Start,EndTime
|
||||
long spanTime;
|
||||
Date startTime = new Date();
|
||||
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeESBAPI] start request:");
|
||||
|
||||
HttpResponseResult httpResult = (SysCommon.mgmApiMockup ?
|
||||
HttpUtilMockup.processHttpRequest(requestDef)
|
||||
: HttpUtil.processHttpRequest(requestDef));
|
||||
|
||||
httpResult.setRequestContent(requestDef.getEntityContent());
|
||||
|
||||
//RefreshEndTime
|
||||
Date endTime = new Date();
|
||||
|
||||
spanTime = DateTimeUtil.getTimeSpanSSS(startTime, endTime);
|
||||
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]getRequestUrl:" + gson.toJson(requestDef.getRequestUrl()));
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]getHeaders:" + gson.toJson(requestDef.getHeaders()));
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]getRequestMethod:" + gson.toJson(requestDef.getRequestMethod()));
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]getEntityContent:" + gson.toJson(requestContent));
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]getStatusCode:" + gson.toJson(httpResult.getStatusCode()));
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]getErrorMessage:" + gson.toJson(httpResult.getErrorMessage()));
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]getResponseContent:" + gson.toJson(httpResult.getResponseContent()));
|
||||
|
||||
//Log Spend Time
|
||||
LogUtil.info(MGMEsbApiService.class, "[invokeLimoESBAPI]SpendTime:" + spanTime + "ms");
|
||||
|
||||
return httpResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,643 @@
|
||||
package com.mgm.mcrm.common.services;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mgm.mcrm.common.constants.SysCommon;
|
||||
import com.mgm.mcrm.common.dtos.http_util.HttpRequestDefine;
|
||||
import com.mgm.mcrm.common.dtos.http_util.HttpResponseResult;
|
||||
import com.mgm.mcrm.common.utils.HttpUtil;
|
||||
import com.mgm.mcrm.common.utils.LogUtil;
|
||||
import com.mgm.mcrm.common.utils.mockup.HttpUtilMockup;
|
||||
import com.mgm.mcrm.limo.dtos.request.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MGMLimoApiService {
|
||||
|
||||
public static String ESB_LIMO_SERVER = "";
|
||||
public static String ESB_LIMO_ACCESS_TOKEN = null;
|
||||
public static String ESB_LIMO_APP_ID;
|
||||
public static String ESB_LIMO_APP_SECRET;
|
||||
public static Date ESB_LIMO_EXPIRED_TIME = new Date();
|
||||
|
||||
private static final String API_GET_ACCESS_TOKEN = "GetAccessToken";
|
||||
private static final String API_GET_TRIP_PRICE = "GetTripPrice";
|
||||
private static final String API_GET_LOCATION = "GetLocation";
|
||||
private static final String API_GET_CAR_TYPE = "GetCarType";
|
||||
private static final String API_GET_GREET_TYPE = "GetGreetType";
|
||||
private static final String API_GET_BOOKING = "GetBooking";
|
||||
private static final String API_CREATE_BOOKING = "CreateBooking";
|
||||
private static final String API_UPDATE_BOOKING = "UpdateBooking";
|
||||
private static final String API_UPDATE_BOOKING_STATUS = "UpdateBookingStatus";
|
||||
private static final String API_GET_FLIGHT_DETAILS= "GetFlightDetails";
|
||||
private static final String API_GET_TOTAL_AMOUNT = "GetTotalAmount";
|
||||
|
||||
// private static final String API_MAIN_HANDLER_HANDLER = "http://mmlimodevapp01/MCRMAPI/API/MainHandler.ashx ";
|
||||
|
||||
|
||||
@Value("${limo_address}")
|
||||
private String API_MAIN_HANDLER;
|
||||
@Value("${limo_getAccessToken_Id}")
|
||||
private String apiGetAccessTokenId;
|
||||
@Value("${limo_getAccessToken_pwd}")
|
||||
private String apiGetAccessTokenPwd;
|
||||
|
||||
|
||||
public HttpResponseResult invokeGetTripPrice() throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestObj.put("action", API_GET_TRIP_PRICE);
|
||||
requestObj.put("token", token);
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeGetLocation(String location) throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestObj.put("action", API_GET_LOCATION);
|
||||
requestObj.put("token", token);
|
||||
requestObj.put("Location", "%");
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeGetCarType() throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestObj.put("action", API_GET_CAR_TYPE);
|
||||
requestObj.put("token", token);
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public HttpResponseResult invokeGetGreetType() throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
requestObj.put("action", API_GET_GREET_TYPE);
|
||||
requestObj.put("token", token);
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeGetBooking(String bookingId) throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
if(bookingId != null) requestObj.put("Id",bookingId);
|
||||
|
||||
requestObj.put("action", API_GET_BOOKING);
|
||||
requestObj.put("token", token);
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
public HttpResponseResult getFlightDetails(GetLimoFlightDetailsRequest request) throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
JSONObject itemObject = new JSONObject();
|
||||
itemObject.put("FlightNo", request.getFlightNo());
|
||||
itemObject.put("PickupDatetime", request.getPickupDateTime());
|
||||
itemObject.put("PickupAirportCode", request.getPickupAirportCode());
|
||||
itemObject.put("DropoffAirportCode", request.getDropOffAirportCode() != null ? request.getDropOffAirportCode() : "");
|
||||
|
||||
requestObj.put("action", API_GET_FLIGHT_DETAILS);
|
||||
requestObj.put("token", token);
|
||||
requestObj.put("itemObject", itemObject.toJSONString());
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
public HttpResponseResult getTotalAmount(GetLimoTotalAmountRequest request) throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
JSONObject itemObject = new JSONObject();
|
||||
itemObject.put("PickupPOIID", blankToZero(request.getPickupPOIId()));
|
||||
|
||||
List<String> dropoffPoiIds = splitSemicolonValues(request.getDropoffPOIIds());
|
||||
itemObject.put("DropoffPOIID", valueAtOrZero(dropoffPoiIds, 0));
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
itemObject.put("ExtraDropoffPOIID" + i, valueAtOrZero(dropoffPoiIds, i));
|
||||
}
|
||||
|
||||
List<String> tripPrices = splitSemicolonValues(request.getSingleTripPrices());
|
||||
itemObject.put("SingleTripPrice", valueAtOrZero(tripPrices, 0));
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
itemObject.put("ExtraDropoffPrice" + i, valueAtOrZero(tripPrices, i));
|
||||
}
|
||||
|
||||
requestObj.put("action", API_GET_TOTAL_AMOUNT);
|
||||
requestObj.put("token", token);
|
||||
requestObj.put("itemObject", itemObject.toJSONString());
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
/** 按 {@code ;} 拆分,去掉空白段;例如 {@code 1;2;3} → [1,2,3] */
|
||||
private static List<String> splitSemicolonValues(String value) {
|
||||
if (!StringUtils.isNotBlank(value)) {
|
||||
return List.of();
|
||||
}
|
||||
return Arrays.stream(value.split(";"))
|
||||
.map(String::trim)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static String valueAtOrZero(List<String> values, int index) {
|
||||
if (values == null || index >= values.size()) {
|
||||
return "0";
|
||||
}
|
||||
return values.get(index);
|
||||
}
|
||||
|
||||
private static String blankToZero(String value) {
|
||||
return StringUtils.isNotBlank(value) ? value.trim() : "0";
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeCreateBooking(InternalCreateLimoBookingRequest r) throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{'CreateNotConfirmBooking':'").append(r.getCreateNotConfirmBooking()).append("'");
|
||||
sb.append(",'BookingType':'").append(s(r.getBookingType())).append("'");
|
||||
sb.append(",'GreetType':'").append(s(r.getGreetType())).append("'");
|
||||
sb.append(",'OtherGreetType':'").append(s(r.getOtherGreetType())).append("'");
|
||||
sb.append(",'GuestType':'").append(s(r.getGuestType())).append("'");
|
||||
sb.append(",'TripType':'").append(s(r.getTripType())).append("'");
|
||||
|
||||
sb.append(",'PlayerID':'").append(s(r.getPlayerId())).append("'");
|
||||
sb.append(",'Ranking':'").append(s(r.getRanking())).append("'");
|
||||
sb.append(",'MaskedTier':'").append(s(r.getMaskedTier())).append("'");
|
||||
sb.append(",'OverrideBy':'").append(s(r.getOverrideBy())).append("'");
|
||||
sb.append(",'ComplexOverrider':'").append(s(r.getComplexOverrider())).append("'");
|
||||
|
||||
sb.append(",'RoomNo':'").append(s(r.getRoomNo())).append("'");
|
||||
sb.append(",'EmployeeID':'").append(s(r.getEmployeeId())).append("'");
|
||||
sb.append(",'CreateBy':'").append(s(r.getCreateBy())).append("'");
|
||||
|
||||
sb.append(",'LastName':'").append(s(r.getLastName())).append("'");
|
||||
sb.append(",'FirstName':'").append(s(r.getFirstName())).append("'");
|
||||
sb.append(",'Salution':'").append(s(r.getSalution())).append("'");
|
||||
sb.append(",'ChineseLastName':'").append(s(r.getChineseLastName())).append("'");
|
||||
sb.append(",'ChineseFirstName':'").append(s(r.getChineseFirstName())).append("'");;
|
||||
|
||||
sb.append(",'BookerContact':'").append(s(r.getBookerContact())).append("'");
|
||||
sb.append(",'BookingContact':'").append(s(r.getBookingContact())).append("'");;
|
||||
sb.append(",'TenOutContact':'").append(s(r.getTenOutContact())).append("'");;
|
||||
sb.append(",'GuestContact':'").append(s(r.getGuestContact())).append("'");;
|
||||
sb.append(",'MAContact':'").append(s(r.getBookerContact())).append("'");
|
||||
sb.append(",'TripContact':'").append(s(r.getTripContact())).append("'");
|
||||
|
||||
sb.append(",'AdHoc':'").append(r.getAdHoc()).append("'");
|
||||
sb.append(",'PickupDatetime':'")
|
||||
.append(r.getPickupDatetime() != null ? r.getPickupDatetime().format(dtf) : "")
|
||||
.append("'");
|
||||
sb.append(",'CarTypeID':").append(n(r.getCarTypeId()));
|
||||
sb.append(",'PassengerNo':").append(n(r.getPassengerNo()));
|
||||
|
||||
sb.append(",'PickupPOIID':").append(n(r.getPickupPOIID()));
|
||||
sb.append(",'Pickup':'").append(s(r.getPickup())).append("'");
|
||||
sb.append(",'PickupTripPriceId':").append(n(r.getPickupTripPriceId()));
|
||||
sb.append(",'PickupRegion':'").append(s(r.getPickupRegion())).append("'");
|
||||
|
||||
sb.append(",'DropoffPOIID':").append(n(r.getDropoffPOIID()));
|
||||
sb.append(",'Dropoff':'").append(s(r.getDropoff())).append("'");
|
||||
sb.append(",'DropoffTripPriceID':").append(n(r.getDropoffTripPriceId()));
|
||||
sb.append(",'DropoffRegion':'").append(s(r.getDropoffRegion())).append("'");
|
||||
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
sb.append(",'ExtraDropoffPOIID").append(i).append("':").append(n(extraDropoffPOIID(r, i)));
|
||||
sb.append(",'ExtraDropoff").append(i).append("':'").append(s(extraDropoff(r, i))).append("'");
|
||||
sb.append(",'ExtraDropoffTripPriceID").append(i).append("':").append(n(extraDropoffTripPriceID(r, i)));
|
||||
sb.append(",'ExtraDropoffRegion").append(i).append("':'").append(s(extraDropoffRegion(r, i))).append("'");
|
||||
}
|
||||
|
||||
sb.append(",'SingleTripPrice':'").append(bd(r.getSingleTripPrice())).append("'");
|
||||
sb.append(",'DefaultTripPrice':'").append(bd(r.getDefaultTripPrice())).append("'");
|
||||
sb.append(",'DefaultPublishTripPrice':'").append(bd(r.getDefaultPublishTripPrice())).append("'");
|
||||
|
||||
sb.append(",'HourlyRate':'").append(bd(r.getHourlyRate())).append("'");
|
||||
sb.append(",'HourlyWaitingFee':'").append(bd(r.getHourlyWaitingFee())).append("'");
|
||||
sb.append(",'Hour':").append(n(r.getHour()));
|
||||
sb.append(",'HourlyWaiting':").append(n(r.getHourlyWaiting()));
|
||||
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
sb.append(",'ExtraDropoffPrice").append(i).append("':'").append(bd(extraDropoffPrice(r, i))).append("'");
|
||||
}
|
||||
|
||||
sb.append(",'HotelLimoPrice':'0.00'");
|
||||
sb.append(",'OtherPriceRemark':'").append(s(r.getOtherPriceRemark())).append("'");
|
||||
sb.append(",'OtherPrice':'").append(bd(r.getOtherPrice())).append("'");
|
||||
|
||||
sb.append(",'PaymentMethod':'").append(s(r.getPaymentMethod())).append("'");
|
||||
sb.append(",'TotalAmount':'").append(bd(r.getTotalAmount())).append("'");
|
||||
|
||||
sb.append(",'HighImportance':").append(b(r.getHighImportance()));
|
||||
sb.append(",'TenOut':").append(b(r.getTenOut()));
|
||||
sb.append(",'ButlerGreet':").append(b(r.getButlerGreet()));
|
||||
|
||||
sb.append(",'BookedBy':'").append(s(r.getBookedBy())).append("'");
|
||||
sb.append(",'ApprovedBy':'").append(s(r.getApprovedBy())).append("'");
|
||||
|
||||
sb.append(",'BookingRemark':'").append(s(r.getBookingRemark())).append("'");
|
||||
sb.append(",'DriverRemark':'").append(s(r.getDriverRemark())).append("'");
|
||||
sb.append(",'LimoInternalRemark':'").append(s(r.getLimoInternalRemark())).append("'");
|
||||
sb.append(",'SystemRemark':'").append(s(r.getSystemRemark())).append("'");
|
||||
|
||||
sb.append(",'LimoGreet':").append(b(r.getLimoGreet()));
|
||||
sb.append(",'HostGreet':").append(b(r.getHostGreet()));
|
||||
sb.append(",'VIPMeetNGreet':").append(b(r.getVipMeetNGreet()));
|
||||
|
||||
sb.append(",'OtherGreet':'").append(s(r.getOtherGreet())).append("'");
|
||||
sb.append(",'FlightDetails':'").append(s(r.getFlightDetails())).append("'");
|
||||
sb.append(",'ETA':'").append(r.getPickupDatetime() != null ? r.getPickupDatetime().format(dtf) : "2000-01-01 00:00:00").append("'");
|
||||
sb.append(",'Signage':'").append(s(r.getSignage())).append("'");
|
||||
sb.append(",'FlightStatus':''");
|
||||
sb.append(",'CancelReason':''}");
|
||||
|
||||
requestObj.put("action", API_CREATE_BOOKING);
|
||||
requestObj.put("itemObject", sb.toString());
|
||||
requestObj.put("token", token);
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
// ---- Limo format helpers: single-quote + PascalCase + 1/0 for booleans ----
|
||||
|
||||
private static String s(String v) { return v != null ? v : ""; }
|
||||
private static String n(Integer v) { return v != null ? String.valueOf(v) : "0"; }
|
||||
private static String n(Long v) { return v != null ? String.valueOf(v) : "0"; }
|
||||
private static String b(Boolean v) { return v != null && v ? "1" : "0"; }
|
||||
private static String bd(java.math.BigDecimal v) {
|
||||
return v != null ? v.toPlainString() : "0.00";
|
||||
}
|
||||
|
||||
private static Long extraDropoffPOIID(InternalCreateLimoBookingRequest r, int i) {
|
||||
return switch (i) {
|
||||
case 1 -> r.getExtraDropoffPOIID1();
|
||||
case 2 -> r.getExtraDropoffPOIID2();
|
||||
case 3 -> r.getExtraDropoffPOIID3();
|
||||
case 4 -> r.getExtraDropoffPOIID4();
|
||||
case 5 -> r.getExtraDropoffPOIID5();
|
||||
case 6 -> r.getExtraDropoffPOIID6();
|
||||
case 7 -> r.getExtraDropoffPOIID7();
|
||||
case 8 -> r.getExtraDropoffPOIID8();
|
||||
case 9 -> r.getExtraDropoffPOIID9();
|
||||
case 10 -> r.getExtraDropoffPOIID10();
|
||||
default -> 0L;
|
||||
};
|
||||
}
|
||||
private static String extraDropoff(InternalCreateLimoBookingRequest r, int i) {
|
||||
return switch (i) {
|
||||
case 1 -> r.getExtraDropoff1();
|
||||
case 2 -> r.getExtraDropoff2();
|
||||
case 3 -> r.getExtraDropoff3();
|
||||
case 4 -> r.getExtraDropoff4();
|
||||
case 5 -> r.getExtraDropoff5();
|
||||
case 6 -> r.getExtraDropoff6();
|
||||
case 7 -> r.getExtraDropoff7();
|
||||
case 8 -> r.getExtraDropoff8();
|
||||
case 9 -> r.getExtraDropoff9();
|
||||
case 10 -> r.getExtraDropoff10();
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
private static Long extraDropoffTripPriceID(InternalCreateLimoBookingRequest r, int i) {
|
||||
return switch (i) {
|
||||
case 1 -> r.getExtraDropoffTripPriceID1();
|
||||
case 2 -> r.getExtraDropoffTripPriceID2();
|
||||
case 3 -> r.getExtraDropoffTripPriceID3();
|
||||
case 4 -> r.getExtraDropoffTripPriceID4();
|
||||
case 5 -> r.getExtraDropoffTripPriceID5();
|
||||
case 6 -> r.getExtraDropoffTripPriceID6();
|
||||
case 7 -> r.getExtraDropoffTripPriceID7();
|
||||
case 8 -> r.getExtraDropoffTripPriceID8();
|
||||
case 9 -> r.getExtraDropoffTripPriceID9();
|
||||
case 10 -> r.getExtraDropoffTripPriceID10();
|
||||
default -> 0L;
|
||||
};
|
||||
}
|
||||
private static String extraDropoffRegion(InternalCreateLimoBookingRequest r, int i) {
|
||||
return switch (i) {
|
||||
case 1 -> r.getExtraDropoffRegion1();
|
||||
case 2 -> r.getExtraDropoffRegion2();
|
||||
case 3 -> r.getExtraDropoffRegion3();
|
||||
case 4 -> r.getExtraDropoffRegion4();
|
||||
case 5 -> r.getExtraDropoffRegion5();
|
||||
case 6 -> r.getExtraDropoffRegion6();
|
||||
case 7 -> r.getExtraDropoffRegion7();
|
||||
case 8 -> r.getExtraDropoffRegion8();
|
||||
case 9 -> r.getExtraDropoffRegion9();
|
||||
case 10 -> r.getExtraDropoffRegion10();
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
private static java.math.BigDecimal extraDropoffPrice(InternalCreateLimoBookingRequest r, int i) {
|
||||
return switch (i) {
|
||||
case 1 -> r.getExtraDropoffPrice1();
|
||||
case 2 -> r.getExtraDropoffPrice2();
|
||||
case 3 -> r.getExtraDropoffPrice3();
|
||||
case 4 -> r.getExtraDropoffPrice4();
|
||||
case 5 -> r.getExtraDropoffPrice5();
|
||||
case 6 -> r.getExtraDropoffPrice6();
|
||||
case 7 -> r.getExtraDropoffPrice7();
|
||||
case 8 -> r.getExtraDropoffPrice8();
|
||||
case 9 -> r.getExtraDropoffPrice9();
|
||||
case 10 -> r.getExtraDropoffPrice10();
|
||||
default -> java.math.BigDecimal.ZERO;
|
||||
};
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeUpdateBooking(InternalUpdateLimoBookingRequest request) throws Exception {
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{'ID':'").append(s(request.getId())).append("'");
|
||||
appendBooleanUpdate(sb, "CreateNotConfirmBooking", request.getCreateNotConfirmBooking());
|
||||
|
||||
if (request.getPickupDatetime() != null) {
|
||||
appendStringUpdate(sb, "PickupDatetime", request.getPickupDatetime().format(dateFormat));
|
||||
}
|
||||
appendNumberUpdate(sb, "PickupPOIID", request.getPickupPOIID());
|
||||
appendStringUpdate(sb, "Pickup", request.getPickup());
|
||||
appendStringUpdate(sb, "BookingType", request.getBookingType());
|
||||
appendStringUpdate(sb, "PickupRegion", request.getPickupRegion());
|
||||
appendStringUpdate(sb, "EditBy", request.getEditBy());
|
||||
|
||||
appendNumberUpdate(sb, "DropoffPOIID", request.getDropoffPOIID());
|
||||
appendStringUpdate(sb, "Dropoff", request.getDropoff());
|
||||
appendStringUpdate(sb, "DropoffRegion", request.getDropoffRegion());
|
||||
|
||||
appendExtraDropoffLocationUpdate(sb, 1, request.getExtraDropoffPOIID1(), request.getExtraDropoff1());
|
||||
appendExtraDropoffLocationUpdate(sb, 2, request.getExtraDropoffPOIID2(), request.getExtraDropoff2());
|
||||
appendExtraDropoffLocationUpdate(sb, 3, request.getExtraDropoffPOIID3(), request.getExtraDropoff3());
|
||||
appendExtraDropoffLocationUpdate(sb, 4, request.getExtraDropoffPOIID4(), request.getExtraDropoff4());
|
||||
appendExtraDropoffLocationUpdate(sb, 5, request.getExtraDropoffPOIID5(), request.getExtraDropoff5());
|
||||
appendExtraDropoffLocationUpdate(sb, 6, request.getExtraDropoffPOIID6(), request.getExtraDropoff6());
|
||||
appendExtraDropoffLocationUpdate(sb, 7, request.getExtraDropoffPOIID7(), request.getExtraDropoff7());
|
||||
appendExtraDropoffLocationUpdate(sb, 8, request.getExtraDropoffPOIID8(), request.getExtraDropoff8());
|
||||
appendExtraDropoffLocationUpdate(sb, 9, request.getExtraDropoffPOIID9(), request.getExtraDropoff9());
|
||||
appendExtraDropoffLocationUpdate(sb, 10, request.getExtraDropoffPOIID10(), request.getExtraDropoff10());
|
||||
|
||||
appendDecimalUpdate(sb, "SingleTripPrice", request.getSingleTripPrice());
|
||||
appendDecimalUpdate(sb, "DefaultTripPrice", request.getDefaultTripPrice());
|
||||
appendDecimalUpdate(sb, "DefaultPublishTripPrice", request.getDefaultPublishTripPrice());
|
||||
appendDecimalUpdate(sb, "HourlyRate", request.getHourlyRate());
|
||||
appendDecimalUpdate(sb, "HourlyWaitingFee", request.getHourlyWaitingFee());
|
||||
appendIntegerUpdate(sb, "Hour", request.getHour());
|
||||
appendIntegerUpdate(sb, "HourlyWaiting", request.getHourlyWaiting());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice1", request.getExtraDropoffPrice1());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice2", request.getExtraDropoffPrice2());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice3", request.getExtraDropoffPrice3());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice4", request.getExtraDropoffPrice4());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice5", request.getExtraDropoffPrice5());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice6", request.getExtraDropoffPrice6());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice7", request.getExtraDropoffPrice7());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice8", request.getExtraDropoffPrice8());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice9", request.getExtraDropoffPrice9());
|
||||
appendDecimalUpdate(sb, "ExtraDropoffPrice10", request.getExtraDropoffPrice10());
|
||||
appendDecimalUpdate(sb, "TotalAmount", request.getTotalAmount());
|
||||
|
||||
appendStringUpdate(sb, "BookingRemark", request.getBookingRemark());
|
||||
sb.append("}");
|
||||
|
||||
requestObj.put("action", API_UPDATE_BOOKING);
|
||||
requestObj.put("itemObject", sb.toString());
|
||||
requestObj.put("token", token);
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
private static void appendStringUpdate(StringBuilder sb, String fieldName, String value) {
|
||||
if (value != null) {
|
||||
sb.append(",'").append(fieldName).append("':'").append(s(value)).append("'");
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendNumberUpdate(StringBuilder sb, String fieldName, Long value) {
|
||||
if (value != null) {
|
||||
sb.append(",'").append(fieldName).append("':").append(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendIntegerUpdate(StringBuilder sb, String fieldName, Integer value) {
|
||||
if (value != null) {
|
||||
sb.append(",'").append(fieldName).append("':").append(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendDecimalUpdate(
|
||||
StringBuilder sb, String fieldName, java.math.BigDecimal value) {
|
||||
if (value != null) {
|
||||
sb.append(",'").append(fieldName).append("':'").append(value.toPlainString()).append("'");
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendBooleanUpdate(StringBuilder sb, String fieldName, Boolean value) {
|
||||
if (value != null) {
|
||||
sb.append(",'").append(fieldName).append("':'").append(value ? "1" : "0").append("'");
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendExtraDropoffLocationUpdate(StringBuilder sb, int i, Long poiId, String name) {
|
||||
appendNumberUpdate(sb, "ExtraDropoffPOIID" + i, poiId);
|
||||
appendStringUpdate(sb, "ExtraDropoff" + i, name);
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeCancelLimoBooking(InternalCancelLimoBookingRequest request) throws Exception{
|
||||
|
||||
Map<String, String> requestObj = new HashMap<>();
|
||||
|
||||
String token = getLimoAccessToken();
|
||||
|
||||
JSONObject itemObject = new JSONObject();
|
||||
|
||||
itemObject.put("ID", request.getBookingId());
|
||||
itemObject.put("EditBy", request.getEditBy());
|
||||
itemObject.put("BookingStatus", "Cancel");
|
||||
|
||||
requestObj.put("token", token);
|
||||
requestObj.put("itemObject", itemObject.toJSONString());
|
||||
requestObj.put("action", API_UPDATE_BOOKING_STATUS);
|
||||
|
||||
|
||||
return this.invokeESBFormUrlEncodedAPI(ESB_LIMO_SERVER, API_MAIN_HANDLER, requestObj, "POST", null);
|
||||
}
|
||||
|
||||
private String getLimoAccessToken() throws Exception {
|
||||
|
||||
String token = ESB_LIMO_ACCESS_TOKEN;
|
||||
|
||||
if (SysCommon.mgmApiMockup)
|
||||
return token;
|
||||
|
||||
|
||||
ESB_LIMO_APP_ID = SysCommon.apiConfig.getApiKey_ESB();
|
||||
ESB_LIMO_APP_SECRET = SysCommon.apiConfig.getApiSecret_ESB();
|
||||
ESB_LIMO_SERVER = SysCommon.apiConfig.getServerUrl_ESB();
|
||||
|
||||
if (token == null || ESB_LIMO_EXPIRED_TIME.getTime() < new Date().getTime()) {
|
||||
|
||||
String itemObject = String.format(
|
||||
"{'LoginID':'%s','Password':'%s'}",
|
||||
apiGetAccessTokenId,
|
||||
apiGetAccessTokenPwd);
|
||||
|
||||
Map<String, String> formData = new HashMap<>();
|
||||
formData.put("action", API_GET_ACCESS_TOKEN);
|
||||
formData.put("itemObject", itemObject);
|
||||
|
||||
HttpResponseResult result = this.invokeESBFormUrlEncodedAPI(
|
||||
ESB_LIMO_SERVER,
|
||||
API_MAIN_HANDLER,
|
||||
formData,
|
||||
"POST",
|
||||
null);
|
||||
|
||||
if (result.getStatusCode() == 200) {
|
||||
JSONObject resultObj = JSONObject.parseObject(result.getResponseContent());
|
||||
String status = resultObj.getString("result");
|
||||
|
||||
if (Strings.CI.equals("200", status)) {
|
||||
token = resultObj.getString("token");
|
||||
ESB_LIMO_ACCESS_TOKEN = token;
|
||||
} else {
|
||||
token = null;
|
||||
ESB_LIMO_ACCESS_TOKEN = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public HttpResponseResult invokeESBFormUrlEncodedAPI(
|
||||
String serverUrl,
|
||||
String requestLink,
|
||||
Map<String, String> formData,
|
||||
String requestMethod,
|
||||
Map<String, String> requestHeader) throws Exception {
|
||||
|
||||
HttpRequestDefine requestDef = new HttpRequestDefine();
|
||||
String requestUrl = requestLink;
|
||||
Map<String, String> headers = (requestHeader == null ? new HashMap<>() : new HashMap<>(requestHeader));
|
||||
String requestBody = buildFormUrlEncodedBody(formData);
|
||||
|
||||
requestDef.setRequestUrl(requestUrl);
|
||||
requestDef.setRequestMethod(requestMethod);
|
||||
requestDef.setHeaders(headers);
|
||||
requestDef.setEntityContent(requestBody);
|
||||
|
||||
headers.put("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
|
||||
|
||||
LogUtil.info(MGMLimoApiService.class, "[invokeFormUrlEncodedAPI] Limo RequestUrl:" + requestUrl);
|
||||
LogUtil.info(MGMLimoApiService.class, "[invokeFormUrlEncodedAPI] Limo RequestBody:" + requestBody);
|
||||
|
||||
HttpResponseResult httpResult = (SysCommon.mgmApiMockup ? HttpUtilMockup.processHttpRequest(requestDef)
|
||||
: HttpUtil.processHttpRequest(requestDef));
|
||||
|
||||
JSONObject resultObj = JSONObject.parseObject(httpResult.getResponseContent());
|
||||
String status = (resultObj == null ? null : resultObj.getString("result"));
|
||||
|
||||
if (Strings.CS.equals("201", status)) {
|
||||
formData.put("token", this.getLimoAccessToken());
|
||||
requestDef.setEntityContent(buildFormUrlEncodedBody(formData));
|
||||
|
||||
LogUtil.info(MGMLimoApiService.class, "[invokeFormUrlEncodedAPI] Token expired Retry Limo RequestUrl:" + requestUrl);
|
||||
LogUtil.info(MGMLimoApiService.class, "[invokeFormUrlEncodedAPI] Token expired Retry Limo RequestBody:" + requestBody);
|
||||
|
||||
httpResult = (SysCommon.mgmApiMockup ? HttpUtilMockup.processHttpRequest(requestDef)
|
||||
: HttpUtil.processHttpRequest(requestDef));
|
||||
}
|
||||
|
||||
String responseContent = httpResult.getResponseContent();
|
||||
int responseLength = (responseContent == null ? 0 : responseContent.length());
|
||||
LogUtil.info(MGMLimoApiService.class, "[invokeFormUrlEncodedAPI] Limo action:" + (formData == null ? null : formData.get("action"))
|
||||
+ " Limo ResponseLength:" + responseLength
|
||||
+ " Status=" + httpResult.getStatusCode());
|
||||
|
||||
httpResult.setRequestContent(requestBody);
|
||||
return httpResult;
|
||||
}
|
||||
|
||||
private String buildFormUrlEncodedBody(Map<String, String> formData) {
|
||||
if (formData == null || formData.isEmpty())
|
||||
return "";
|
||||
|
||||
StringBuilder body = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : formData.entrySet()) {
|
||||
if (!body.isEmpty())
|
||||
body.append("&");
|
||||
|
||||
body.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8));
|
||||
body.append("=");
|
||||
body.append(encodeFormValue(entry.getValue()));
|
||||
}
|
||||
|
||||
return body.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 form value 做最小化编码,只转义会破坏 form-urlencoded 结构的字符,
|
||||
* 保留 JSON 结构符号 ({ } " : , [ ]) 原样,与 Postman 行为一致。
|
||||
*/
|
||||
private String encodeFormValue(String value) {
|
||||
if (value == null)
|
||||
return "";
|
||||
|
||||
StringBuilder sb = new StringBuilder(value.length());
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
switch (c) {
|
||||
case '&': sb.append("%26"); break;
|
||||
case '=': sb.append("%3D"); break;
|
||||
// case ' ': sb.append("+"); break;
|
||||
case '%': sb.append("%25"); break;
|
||||
case '\n': sb.append("%0A"); break;
|
||||
case '\r': sb.append("%0D"); break;
|
||||
default: sb.append(c); break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import com.mgm.mcrm.common.dtos.http_util.HttpRequestDefine;
|
||||
import com.mgm.mcrm.common.dtos.http_util.HttpResponseResult;
|
||||
import com.mgm.mcrm.common.utils.LogUtil;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -29,6 +31,67 @@ public class HttpUtilMockup {
|
||||
return mockupConfig;
|
||||
}
|
||||
|
||||
private static boolean isApiLinkMatch(String requestLink, String requestContent, String apiLink) {
|
||||
if (apiLink == null || apiLink.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (requestLink != null && requestLink.contains(apiLink)) {
|
||||
return true;
|
||||
}
|
||||
JSONObject formObj = parseFormUrlEncoded(requestContent);
|
||||
return formObj != null && apiLink.equals(formObj.getString("action"));
|
||||
}
|
||||
|
||||
private static JSONObject parseRequestObject(String requestContent) {
|
||||
if (requestContent == null || requestContent.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
JSONObject requestObj = JSONObject.parseObject(requestContent);
|
||||
if (requestObj != null) {
|
||||
return requestObj;
|
||||
}
|
||||
} catch (Exception err) {
|
||||
}
|
||||
return parseFormUrlEncoded(requestContent);
|
||||
}
|
||||
|
||||
private static JSONObject parseFormUrlEncoded(String requestContent) {
|
||||
if (requestContent == null || requestContent.isEmpty() || requestContent.indexOf('=') < 0) {
|
||||
return null;
|
||||
}
|
||||
String trimmed = requestContent.trim();
|
||||
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
||||
return null;
|
||||
}
|
||||
JSONObject formObj = new JSONObject();
|
||||
String[] pairs = requestContent.split("&");
|
||||
for (int i = 0; i < pairs.length; i++) {
|
||||
String pair = pairs[i];
|
||||
int eqIndex = pair.indexOf('=');
|
||||
if (eqIndex <= 0) {
|
||||
continue;
|
||||
}
|
||||
String key = urlDecode(pair.substring(0, eqIndex));
|
||||
String value = urlDecode(pair.substring(eqIndex + 1));
|
||||
if (!key.isEmpty()) {
|
||||
formObj.put(key, value);
|
||||
}
|
||||
}
|
||||
return formObj.isEmpty() ? null : formObj;
|
||||
}
|
||||
|
||||
private static String urlDecode(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
return URLDecoder.decode(value, StandardCharsets.UTF_8);
|
||||
} catch (Exception err) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private static String findMockResultByLink(String requestLink,String requestContent) {
|
||||
String result ="";
|
||||
JSONArray configData = getMockupConfig();
|
||||
@@ -36,13 +99,8 @@ public class HttpUtilMockup {
|
||||
JSONObject checkItem = configData.getJSONObject(i);
|
||||
if(checkItem.containsKey("apiLink") && checkItem.containsKey("resultFiles")) {
|
||||
String apiLink = checkItem.getString("apiLink");
|
||||
if(requestLink.contains(apiLink)) {
|
||||
JSONObject requestObj = null;
|
||||
try {
|
||||
requestObj = JSONObject.parseObject(requestContent);
|
||||
}catch(Exception err) {
|
||||
|
||||
}
|
||||
if(isApiLinkMatch(requestLink, requestContent, apiLink)) {
|
||||
JSONObject requestObj = parseRequestObject(requestContent);
|
||||
int resultIndex =0;
|
||||
if(checkItem.containsKey("resultIndex")) {
|
||||
resultIndex=checkItem.getIntValue("resultIndex");
|
||||
|
||||
Reference in New Issue
Block a user