完善携程酒店结算代码
This commit is contained in:
parent
1d71d772a9
commit
49d27cfcec
|
@ -26,6 +26,7 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
private String envMark;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public RouteOrder createRoute(OrderSaveData orderData) {
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
|
@ -84,6 +85,7 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
@Override
|
||||
public RouteRequest createRequestByRoute(RouteOrder routeOrder) {
|
||||
RouteRequest routeRequest = new RouteRequest();
|
||||
routeRequest.setRouteRequestNo(OrderNo.generateRouteRequestNo(routeOrder.getRouteOrderNo()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.Random;
|
||||
|
||||
public class OrderNo {
|
||||
|
||||
private static final String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
public static String generate() {
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
@ -33,4 +36,23 @@ public class OrderNo {
|
|||
// 拼接最终的订单号
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue