完善携程酒店结算代码

This commit is contained in:
lulz1 2024-04-07 17:26:10 +08:00
parent 1d71d772a9
commit 49d27cfcec
2 changed files with 24 additions and 0 deletions

View File

@ -26,6 +26,7 @@ public class RouteOrderFactory implements OrderFactory {
private String envMark; private String envMark;
@Override @Override
public RouteOrder createRoute(OrderSaveData orderData) { public RouteOrder createRoute(OrderSaveData orderData) {
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
@ -84,6 +85,7 @@ public class RouteOrderFactory implements OrderFactory {
@Override @Override
public RouteRequest createRequestByRoute(RouteOrder routeOrder) { public RouteRequest createRequestByRoute(RouteOrder routeOrder) {
RouteRequest routeRequest = new RouteRequest(); RouteRequest routeRequest = new RouteRequest();
routeRequest.setRouteRequestNo(OrderNo.generateRouteRequestNo(routeOrder.getRouteOrderNo()));
return null; return null;
} }
} }

View File

@ -5,6 +5,9 @@ import java.time.format.DateTimeFormatter;
import java.util.Random; import java.util.Random;
public class OrderNo { public class OrderNo {
private static final String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public static String generate() { public static String generate() {
// 获取当前时间 // 获取当前时间
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
@ -33,4 +36,23 @@ public class OrderNo {
// 拼接最终的订单号 // 拼接最终的订单号
return "L" + datePart + randomPart; return "L" + datePart + randomPart;
} }
public static String generateRouteRequestNo(String routeOrderNo) {
return routeOrderNo + "#" + randomStr(6);
}
private static String randomStr(Integer length) {
StringBuilder sb = new StringBuilder();
Random random = new Random();
// 生成六位随机字符串
for (int i = 0; i < length; i++) {
// 生成一个随机索引
int index = random.nextInt(chars.length());
// 从chars中获取字符
char randomChar = chars.charAt(index);
// 将字符添加到StringBuilder中
sb.append(randomChar);
}
return sb.toString();
}
} }