|
|
@@ -58,6 +58,11 @@ public class OrdersService {
|
|
|
return mapper.selectOne(new LambdaQueryWrapper<Orders>().eq(Orders::getOrderNo, orderNo));
|
|
|
}
|
|
|
|
|
|
+ public OrdersDTO getDtoByOrderNo(String orderNo) {
|
|
|
+ Orders e = getByOrderNo(orderNo);
|
|
|
+ return e == null ? null : converter.toDto(e);
|
|
|
+ }
|
|
|
+
|
|
|
public Long save(Orders entity) { mapper.insert(entity); return entity.getId(); }
|
|
|
|
|
|
public void update(Orders entity) { mapper.updateById(entity); }
|
|
|
@@ -219,4 +224,73 @@ public class OrdersService {
|
|
|
o.setWarehouseId(warehouseId);
|
|
|
mapper.updateById(o);
|
|
|
}
|
|
|
+
|
|
|
+ private final String[] COUNTRIES = {"US", "UK", "JP", "DE", "FR", "CA"};
|
|
|
+ private final String[] BUYERS = {"Olivia Zhang", "Noah Smith", "Liam Chen", "Emma Wilson", "Sophie Brown", "James Wang", "Lisa Johnson", "David Lee"};
|
|
|
+ private final String[] WAREHOUSES = {"深圳南山仓", "义乌商贸仓", "洛杉矶海外仓"};
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public Orders createRandomOrder() {
|
|
|
+ Orders order = new Orders();
|
|
|
+ order.setOrderNo("OMS-" + System.currentTimeMillis());
|
|
|
+ order.setChannelOrderNo("CH" + System.currentTimeMillis());
|
|
|
+ order.setChannelId((long) (Math.random() * 3 + 1));
|
|
|
+ order.setOrderStatus("CREATED");
|
|
|
+ order.setShippingStatus("UNSHIPPED");
|
|
|
+ order.setPaymentStatus("UNPAID");
|
|
|
+ order.setRefundStatus("NONE");
|
|
|
+ order.setExceptionTag(Math.random() > 0.85 ? "地址需复核" : null);
|
|
|
+ order.setPriority(Math.random() > 0.9 ? "URGENT" : "NORMAL");
|
|
|
+
|
|
|
+ int buyerIdx = (int) (Math.random() * BUYERS.length);
|
|
|
+ order.setBuyer(BUYERS[buyerIdx]);
|
|
|
+ order.setBuyerId("buyer-" + System.currentTimeMillis());
|
|
|
+ order.setBuyerEmail(BUYERS[buyerIdx].toLowerCase().replace(" ", ".") + "@mail.com");
|
|
|
+ order.setBuyerPhone("+1" + (int)(Math.random() * 9000000000L + 1000000000L));
|
|
|
+
|
|
|
+ int countryIdx = (int) (Math.random() * COUNTRIES.length);
|
|
|
+ order.setBuyerCountry(COUNTRIES[countryIdx]);
|
|
|
+ order.setReceiverCountry(COUNTRIES[countryIdx]);
|
|
|
+ order.setReceiverName(BUYERS[buyerIdx]);
|
|
|
+ order.setReceiverPhone("+1" + (int)(Math.random() * 9000000000L + 1000000000L));
|
|
|
+ order.setReceiverCity("City-" + countryIdx);
|
|
|
+ order.setReceiverState("State-" + countryIdx);
|
|
|
+ order.setReceiverPostalCode(String.valueOf(10000 + (int)(Math.random() * 90000)));
|
|
|
+ order.setReceiverAddress("123 Main Street, City " + countryIdx + ", Country " + COUNTRIES[countryIdx]);
|
|
|
+
|
|
|
+ order.setBuyerLevel(new String[]{"VIP", "黄金", "普通"}[(int)(Math.random() * 3)]);
|
|
|
+ order.setBuyerOrderCount((int)(Math.random() * 50));
|
|
|
+ order.setBuyerTotalSpent(BigDecimal.valueOf(Math.random() * 5000));
|
|
|
+
|
|
|
+ order.setCurrency("USD");
|
|
|
+ order.setExchangeRate(BigDecimal.ONE);
|
|
|
+ order.setPaymentMethod(new String[]{"PayPal", "Credit Card", "Bank Transfer"}[(int)(Math.random() * 3)]);
|
|
|
+
|
|
|
+ BigDecimal orderAmount = BigDecimal.valueOf(Math.random() * 200 + 20);
|
|
|
+ order.setOrderAmount(orderAmount);
|
|
|
+ order.setOrderAmountCny(orderAmount.multiply(BigDecimal.valueOf(7.2)));
|
|
|
+ order.setTaxAmount(orderAmount.multiply(BigDecimal.valueOf(0.08)));
|
|
|
+ order.setShippingFee(BigDecimal.valueOf(Math.random() * 15 + 5));
|
|
|
+ order.setDiscountAmount(BigDecimal.ZERO);
|
|
|
+ order.setActualPaid(orderAmount.add(order.getTaxAmount()).add(order.getShippingFee()));
|
|
|
+
|
|
|
+ order.setChannelId((long) (Math.random() * 5 + 1));
|
|
|
+ order.setWarehouseId((long) (Math.random() * 3 + 1));
|
|
|
+ order.setWarehouseLocation(WAREHOUSES[(int)(Math.random() * WAREHOUSES.length)]);
|
|
|
+
|
|
|
+ order.setDevice(new String[]{"Mobile", "Desktop", "Tablet"}[(int)(Math.random() * 3)]);
|
|
|
+ order.setIp("192.168." + (int)(Math.random() * 255) + "." + (int)(Math.random() * 255));
|
|
|
+ order.setIpCountry(COUNTRIES[countryIdx]);
|
|
|
+
|
|
|
+ order.setItemCount(1);
|
|
|
+ order.setTotalAmount(order.getActualPaid());
|
|
|
+
|
|
|
+ order.setCreatedAt(LocalDateTime.now());
|
|
|
+ order.setUpdatedAt(LocalDateTime.now());
|
|
|
+ order.setTenantId("DEFAULT");
|
|
|
+ order.setDeleted(0);
|
|
|
+
|
|
|
+ mapper.insert(order);
|
|
|
+ return order;
|
|
|
+ }
|
|
|
}
|