|
|
@@ -8,14 +8,21 @@ import com.oms.dto.OrderFilterDTO;
|
|
|
import com.oms.dto.OrderItemDTO;
|
|
|
import com.oms.dto.OrdersDTO;
|
|
|
import com.oms.entity.*;
|
|
|
+import com.oms.enums.*;
|
|
|
import com.oms.mapper.OrdersMapper;
|
|
|
+import com.oms.mapper.ProductSkuMapper;
|
|
|
+import com.oms.mapper.ChannelMapper;
|
|
|
+import com.oms.mapper.WarehouseMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
@@ -28,18 +35,24 @@ public class OrdersService {
|
|
|
private final OrderStatusEventService eventService;
|
|
|
private final OrderOperationLogService logService;
|
|
|
private final InventoryService inventoryService;
|
|
|
-
|
|
|
- private static final Map<String, Set<String>> ALLOWED = Map.of(
|
|
|
- "CREATED", Set.of("PAID", "CANCELLED"),
|
|
|
- "PAID", Set.of("ALLOCATED", "CANCELLED"),
|
|
|
- "ALLOCATED", Set.of("SHIPPED", "CANCELLED"),
|
|
|
- "SHIPPED", Set.of("DELIVERED"),
|
|
|
- "DELIVERED", Set.of("COMPLETED"),
|
|
|
- "COMPLETED", Set.of("REFUNDED")
|
|
|
+ private final ChannelMapper channelMapper;
|
|
|
+ private final WarehouseMapper warehouseMapper;
|
|
|
+ private final ProductSkuMapper productSkuMapper;
|
|
|
+
|
|
|
+ private static final AtomicLong ORDER_SEQ = new AtomicLong(System.currentTimeMillis() % 10000);
|
|
|
+ private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
+
|
|
|
+ private static final Map<OrderStatus, Set<OrderStatus>> ALLOWED = Map.of(
|
|
|
+ OrderStatus.CREATED, Set.of(OrderStatus.PAID, OrderStatus.CANCELLED),
|
|
|
+ OrderStatus.PAID, Set.of(OrderStatus.ALLOCATED, OrderStatus.CANCELLED),
|
|
|
+ OrderStatus.ALLOCATED, Set.of(OrderStatus.SHIPPED, OrderStatus.CANCELLED),
|
|
|
+ OrderStatus.SHIPPED, Set.of(OrderStatus.DELIVERED),
|
|
|
+ OrderStatus.DELIVERED, Set.of(OrderStatus.COMPLETED),
|
|
|
+ OrderStatus.COMPLETED, Set.of(OrderStatus.REFUNDED)
|
|
|
);
|
|
|
|
|
|
- private void validateTransition(String current, String target) {
|
|
|
- if ("CANCELLED".equals(target)) return;
|
|
|
+ private void validateTransition(OrderStatus current, OrderStatus target) {
|
|
|
+ if (OrderStatus.CANCELLED == target) return;
|
|
|
if (!ALLOWED.getOrDefault(current, Set.of()).contains(target))
|
|
|
throw new IllegalStateException("Cannot transition from " + current + " to " + target);
|
|
|
}
|
|
|
@@ -96,7 +109,47 @@ public class OrdersService {
|
|
|
return e == null ? null : converter.toDto(e);
|
|
|
}
|
|
|
|
|
|
- public Long save(Orders entity) { mapper.insert(entity); return entity.getId(); }
|
|
|
+ @Transactional
|
|
|
+ public Long save(Orders entity) {
|
|
|
+ // 校验渠道
|
|
|
+ if (entity.getChannelId() != null) {
|
|
|
+ Channel channel = channelMapper.selectById(entity.getChannelId());
|
|
|
+ if (channel == null) throw new IllegalStateException("渠道不存在: " + entity.getChannelId());
|
|
|
+ }
|
|
|
+ // 校验仓库
|
|
|
+ if (entity.getWarehouseId() != null) {
|
|
|
+ Warehouse wh = warehouseMapper.selectById(entity.getWarehouseId());
|
|
|
+ if (wh == null) throw new IllegalStateException("仓库不存在: " + entity.getWarehouseId());
|
|
|
+ }
|
|
|
+ // 自动生成订单号
|
|
|
+ if (entity.getOrderNo() == null || entity.getOrderNo().isEmpty()) {
|
|
|
+ entity.setOrderNo(generateOrderNo(entity.getChannelId()));
|
|
|
+ }
|
|
|
+ // 设置默认状态
|
|
|
+ if (entity.getOrderStatus() == null) entity.setOrderStatus(OrderStatus.CREATED);
|
|
|
+ if (entity.getShippingStatus() == null) entity.setShippingStatus(ShippingStatus.UNSHIPPED);
|
|
|
+ if (entity.getPaymentStatus() == null) entity.setPaymentStatus(PaymentStatus.UNPAID);
|
|
|
+ if (entity.getRefundStatus() == null) entity.setRefundStatus(RefundStatus.NONE);
|
|
|
+ if (entity.getCurrency() == null) entity.setCurrency("USD");
|
|
|
+ if (entity.getExchangeRate() == null) entity.setExchangeRate(BigDecimal.ONE);
|
|
|
+ entity.setCreatedAt(LocalDateTime.now());
|
|
|
+ entity.setUpdatedAt(LocalDateTime.now());
|
|
|
+ mapper.insert(entity);
|
|
|
+ return entity.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String generateOrderNo(Long channelId) {
|
|
|
+ String channelCode = "OMS";
|
|
|
+ if (channelId != null) {
|
|
|
+ Channel ch = channelMapper.selectById(channelId);
|
|
|
+ if (ch != null && ch.getChannelCode() != null) {
|
|
|
+ channelCode = ch.getChannelCode().toUpperCase();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String date = LocalDate.now().format(DATE_FMT);
|
|
|
+ long seq = ORDER_SEQ.incrementAndGet() % 100000;
|
|
|
+ return channelCode + "-" + date + "-" + String.format("%05d", seq);
|
|
|
+ }
|
|
|
|
|
|
public void update(Orders entity) { mapper.updateById(entity); }
|
|
|
|
|
|
@@ -105,86 +158,151 @@ public class OrdersService {
|
|
|
@Transactional
|
|
|
public void confirmPayment(Long id, String operator) {
|
|
|
Orders o = mapper.selectById(id);
|
|
|
- String prev = o.getOrderStatus();
|
|
|
- validateTransition(prev, "PAID");
|
|
|
- o.setOrderStatus("PAID");
|
|
|
- o.setPaymentStatus("PAID");
|
|
|
+ OrderStatus prev = o.getOrderStatus();
|
|
|
+ validateTransition(prev, OrderStatus.PAID);
|
|
|
+ o.setOrderStatus(OrderStatus.PAID);
|
|
|
+ o.setPaymentStatus(PaymentStatus.PAID);
|
|
|
o.setPaidAt(LocalDateTime.now());
|
|
|
mapper.updateById(o);
|
|
|
- eventService.logEvent(o.getId(), "PAID", "支付确认", "状态 " + prev + " → PAID", "primary", operator);
|
|
|
- logService.log(o.getId(), "ORDER", "支付确认", "金额 " + o.getOrderAmount(), operator);
|
|
|
+ eventService.logEvent(o.getId(), OrderStatus.PAID.name(), "支付确认", "状态 " + prev + " → PAID", "primary", operator);
|
|
|
+ logService.log(o.getId(), "ORDER", "支付确认", "金额 " + o.getActualPaid(), operator);
|
|
|
allocateOrder(id, operator);
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ public void confirmPayment(Long id, BigDecimal paidAmount, String transactionId, String operator) {
|
|
|
+ Orders o = mapper.selectById(id);
|
|
|
+ OrderStatus prev = o.getOrderStatus();
|
|
|
+ validateTransition(prev, OrderStatus.PAID);
|
|
|
+ // 校验支付金额
|
|
|
+ if (paidAmount != null && o.getActualPaid() != null) {
|
|
|
+ int cmp = paidAmount.compareTo(o.getActualPaid());
|
|
|
+ if (cmp < 0) {
|
|
|
+ o.setPaymentStatus(PaymentStatus.PARTIAL_PAID);
|
|
|
+ } else {
|
|
|
+ o.setPaymentStatus(PaymentStatus.PAID);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ o.setPaymentStatus(PaymentStatus.PAID);
|
|
|
+ }
|
|
|
+ o.setOrderStatus(OrderStatus.PAID);
|
|
|
+ o.setPaidAt(LocalDateTime.now());
|
|
|
+ if (transactionId != null && !transactionId.isEmpty()) {
|
|
|
+ o.setTransactionId(transactionId);
|
|
|
+ }
|
|
|
+ mapper.updateById(o);
|
|
|
+ eventService.logEvent(o.getId(), OrderStatus.PAID.name(), "支付确认", "状态 " + prev + " → " + o.getOrderStatus() + ", 金额 " + paidAmount, "primary", operator);
|
|
|
+ logService.log(o.getId(), "ORDER", "支付确认", "金额 " + paidAmount + ", 流水号 " + transactionId, operator);
|
|
|
+ if (PaymentStatus.PAID == o.getPaymentStatus()) {
|
|
|
+ allocateOrder(id, operator);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
public void allocateOrder(Long id, String operator) {
|
|
|
Orders o = mapper.selectById(id);
|
|
|
- validateTransition(o.getOrderStatus(), "ALLOCATED");
|
|
|
+ validateTransition(o.getOrderStatus(), OrderStatus.ALLOCATED);
|
|
|
List<OrderItem> items = orderItemService.getByOrderId(id);
|
|
|
+ // 校验库存是否充足
|
|
|
+ for (OrderItem item : items) {
|
|
|
+ List<Inventory> invList = inventoryService.getBySkuId(item.getSkuId());
|
|
|
+ if (invList.isEmpty() || invList.get(0).getAvailable() < item.getQty()) {
|
|
|
+ throw new IllegalStateException("SKU " + item.getSkuId() + " 库存不足,无法分配");
|
|
|
+ }
|
|
|
+ }
|
|
|
for (OrderItem item : items) {
|
|
|
inventoryService.lockInventoryBySku(item.getSkuId(), item.getQty(), operator);
|
|
|
}
|
|
|
- o.setOrderStatus("ALLOCATED");
|
|
|
+ o.setOrderStatus(OrderStatus.ALLOCATED);
|
|
|
mapper.updateById(o);
|
|
|
- eventService.logEvent(o.getId(), "ALLOCATED", "库存锁定完成", items.size() + " 个SKU已锁定", "success", operator);
|
|
|
+ eventService.logEvent(o.getId(), OrderStatus.ALLOCATED.name(), "库存锁定完成", items.size() + " 个SKU已锁定", "success", operator);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public void cancelOrder(Long id, String reason, String operator) {
|
|
|
Orders o = mapper.selectById(id);
|
|
|
- if ("CANCELLED".equals(o.getOrderStatus())) throw new IllegalStateException("Already cancelled");
|
|
|
- if ("ALLOCATED".equals(o.getOrderStatus())) {
|
|
|
+ if (OrderStatus.CANCELLED == o.getOrderStatus()) throw new IllegalStateException("Already cancelled");
|
|
|
+ if (OrderStatus.ALLOCATED == o.getOrderStatus()) {
|
|
|
for (OrderItem item : orderItemService.getByOrderId(id)) {
|
|
|
inventoryService.unlockInventoryBySku(item.getSkuId(), item.getQty(), operator);
|
|
|
}
|
|
|
}
|
|
|
- o.setOrderStatus("CANCELLED");
|
|
|
+ o.setOrderStatus(OrderStatus.CANCELLED);
|
|
|
mapper.updateById(o);
|
|
|
- eventService.logEvent(o.getId(), "CANCELLED", "订单已取消", reason, "danger", operator);
|
|
|
+ eventService.logEvent(o.getId(), OrderStatus.CANCELLED.name(), "订单已取消", reason, "danger", operator);
|
|
|
logService.log(o.getId(), "ORDER", "取消订单", reason, operator);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public void confirmShipped(Long id, String operator) {
|
|
|
Orders o = mapper.selectById(id);
|
|
|
- validateTransition(o.getOrderStatus(), "SHIPPED");
|
|
|
- o.setOrderStatus("SHIPPED");
|
|
|
- o.setShippingStatus("SHIPPED");
|
|
|
+ validateTransition(o.getOrderStatus(), OrderStatus.SHIPPED);
|
|
|
+ // 扣减锁定库存
|
|
|
+ List<OrderItem> items = orderItemService.getByOrderId(id);
|
|
|
+ for (OrderItem item : items) {
|
|
|
+ inventoryService.shipInventoryBySku(item.getSkuId(), item.getQty(), operator);
|
|
|
+ }
|
|
|
+ o.setOrderStatus(OrderStatus.SHIPPED);
|
|
|
+ o.setShippingStatus(ShippingStatus.SHIPPED);
|
|
|
o.setShippedAt(LocalDateTime.now());
|
|
|
mapper.updateById(o);
|
|
|
- eventService.logEvent(o.getId(), "SHIPPED", "已发货", "物流信息已录入", "primary", operator);
|
|
|
+ eventService.logEvent(o.getId(), OrderStatus.SHIPPED.name(), "已发货", "物流信息已录入", "primary", operator);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public void confirmDelivered(Long id, String operator) {
|
|
|
Orders o = mapper.selectById(id);
|
|
|
- validateTransition(o.getOrderStatus(), "DELIVERED");
|
|
|
- o.setOrderStatus("DELIVERED");
|
|
|
+ validateTransition(o.getOrderStatus(), OrderStatus.DELIVERED);
|
|
|
+ o.setOrderStatus(OrderStatus.DELIVERED);
|
|
|
o.setDeliveredAt(LocalDateTime.now());
|
|
|
mapper.updateById(o);
|
|
|
- eventService.logEvent(o.getId(), "DELIVERED", "已签收", "买家已确认收货", "success", operator);
|
|
|
+ eventService.logEvent(o.getId(), OrderStatus.DELIVERED.name(), "已签收", "买家已确认收货", "success", operator);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public void completeOrder(Long id, String operator) {
|
|
|
Orders o = mapper.selectById(id);
|
|
|
- validateTransition(o.getOrderStatus(), "COMPLETED");
|
|
|
- o.setOrderStatus("COMPLETED");
|
|
|
+ validateTransition(o.getOrderStatus(), OrderStatus.COMPLETED);
|
|
|
+ o.setOrderStatus(OrderStatus.COMPLETED);
|
|
|
mapper.updateById(o);
|
|
|
- eventService.logEvent(o.getId(), "COMPLETED", "订单完成", "订单已完结", "success", operator);
|
|
|
+ eventService.logEvent(o.getId(), OrderStatus.COMPLETED.name(), "订单完成", "订单已完结", "success", operator);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public Long splitOrder(Long id, List<Map<String, Object>> splits, String operator) {
|
|
|
Orders orig = mapper.selectById(id);
|
|
|
List<OrderItem> origItems = orderItemService.getByOrderId(id);
|
|
|
+ // 校验原订单状态:只有已支付/已分配的订单可以拆单
|
|
|
+ if (!Set.of(OrderStatus.PAID, OrderStatus.ALLOCATED).contains(orig.getOrderStatus())) {
|
|
|
+ throw new IllegalStateException("只有已支付或已分配的订单可以拆单");
|
|
|
+ }
|
|
|
+ // 校验拆单数量不超过原订单
|
|
|
+ for (Map<String, Object> s : splits) {
|
|
|
+ Long skuId = Long.valueOf(s.get("skuId").toString());
|
|
|
+ int splitQty = Integer.parseInt(s.get("qty").toString());
|
|
|
+ OrderItem origItem = origItems.stream().filter(i -> i.getSkuId().equals(skuId)).findFirst().orElse(null);
|
|
|
+ if (origItem == null) throw new IllegalStateException("SKU " + skuId + " 不在原订单中");
|
|
|
+ if (splitQty <= 0 || splitQty >= origItem.getQty()) {
|
|
|
+ throw new IllegalStateException("拆单数量必须大于0且小于原数量");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 校验库存是否足够分别履约
|
|
|
+ for (Map<String, Object> s : splits) {
|
|
|
+ Long skuId = Long.valueOf(s.get("skuId").toString());
|
|
|
+ int splitQty = Integer.parseInt(s.get("qty").toString());
|
|
|
+ List<Inventory> invList = inventoryService.getBySkuId(skuId);
|
|
|
+ if (invList.isEmpty() || invList.get(0).getAvailable() < splitQty) {
|
|
|
+ throw new IllegalStateException("SKU " + skuId + " 库存不足,无法拆单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Orders child = new Orders();
|
|
|
child.setOrderNo(orig.getOrderNo() + "-S");
|
|
|
child.setChannelOrderNo(orig.getChannelOrderNo());
|
|
|
child.setChannelId(orig.getChannelId());
|
|
|
- child.setOrderStatus("CREATED");
|
|
|
+ child.setOrderStatus(OrderStatus.CREATED);
|
|
|
child.setPaymentStatus(orig.getPaymentStatus());
|
|
|
- child.setShippingStatus("UNSHIPPED");
|
|
|
+ child.setShippingStatus(ShippingStatus.UNSHIPPED);
|
|
|
child.setBuyer(orig.getBuyer());
|
|
|
child.setBuyerId(orig.getBuyerId());
|
|
|
child.setReceiverName(orig.getReceiverName());
|
|
|
@@ -193,6 +311,8 @@ public class OrdersService {
|
|
|
child.setCurrency(orig.getCurrency());
|
|
|
child.setParentOrderId(orig.getId());
|
|
|
child.setWarehouseId(orig.getWarehouseId());
|
|
|
+ child.setCreatedAt(LocalDateTime.now());
|
|
|
+ child.setUpdatedAt(LocalDateTime.now());
|
|
|
mapper.insert(child);
|
|
|
|
|
|
BigDecimal amount = BigDecimal.ZERO;
|
|
|
@@ -213,19 +333,50 @@ public class OrdersService {
|
|
|
orderItemService.save(ci);
|
|
|
amount = amount.add(ci.getSubtotal());
|
|
|
count += qty;
|
|
|
+ // 原订单减少数量
|
|
|
+ oi.setQty(oi.getQty() - qty);
|
|
|
+ oi.setSubtotal(oi.getPrice().multiply(BigDecimal.valueOf(oi.getQty())));
|
|
|
+ orderItemService.update(oi);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
child.setOrderAmount(amount);
|
|
|
child.setItemCount(count);
|
|
|
+ // 按比例分摊运费和税
|
|
|
+ BigDecimal ratio = amount.divide(orig.getOrderAmount(), 4, java.math.RoundingMode.HALF_UP);
|
|
|
+ child.setShippingFee(orig.getShippingFee().multiply(ratio).setScale(2, java.math.RoundingMode.HALF_UP));
|
|
|
+ child.setTaxAmount(orig.getTaxAmount().multiply(ratio).setScale(2, java.math.RoundingMode.HALF_UP));
|
|
|
+ child.setActualPaid(amount.add(child.getShippingFee()).add(child.getTaxAmount()));
|
|
|
mapper.updateById(child);
|
|
|
+
|
|
|
+ // 更新原订单金额
|
|
|
+ orderItemService.calculateTotals(id);
|
|
|
+ orig.setActualPaid(orig.getOrderAmount().add(orig.getShippingFee()).add(orig.getTaxAmount()));
|
|
|
+ mapper.updateById(orig);
|
|
|
+
|
|
|
eventService.logEvent(orig.getId(), "SPLIT", "拆单完成", "子订单 " + child.getOrderNo(), "primary", operator);
|
|
|
return child.getId();
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public void mergeOrders(Long sourceId, Long targetId, String operator) {
|
|
|
+ Orders source = mapper.selectById(sourceId);
|
|
|
+ Orders target = mapper.selectById(targetId);
|
|
|
+ // 合单校验:同买家、同仓库、同币种、均未发货
|
|
|
+ if (OrderStatus.CREATED != source.getOrderStatus() && OrderStatus.PAID != source.getOrderStatus()) {
|
|
|
+ throw new IllegalStateException("来源订单状态不允许合单");
|
|
|
+ }
|
|
|
+ if (OrderStatus.CREATED != target.getOrderStatus() && OrderStatus.PAID != target.getOrderStatus()) {
|
|
|
+ throw new IllegalStateException("目标订单状态不允许合单");
|
|
|
+ }
|
|
|
+ if (source.getWarehouseId() != null && !source.getWarehouseId().equals(target.getWarehouseId())) {
|
|
|
+ throw new IllegalStateException("不同仓库的订单不能合并");
|
|
|
+ }
|
|
|
+ if (source.getCurrency() != null && !source.getCurrency().equals(target.getCurrency())) {
|
|
|
+ throw new IllegalStateException("不同币种的订单不能合并");
|
|
|
+ }
|
|
|
+
|
|
|
for (OrderItem item : orderItemService.getByOrderId(sourceId)) {
|
|
|
OrderItem moved = new OrderItem();
|
|
|
moved.setOrderId(targetId);
|
|
|
@@ -237,11 +388,18 @@ public class OrdersService {
|
|
|
moved.setSubtotal(item.getSubtotal());
|
|
|
orderItemService.save(moved);
|
|
|
}
|
|
|
- Orders source = mapper.selectById(sourceId);
|
|
|
- source.setOrderStatus("CANCELLED");
|
|
|
+ source.setOrderStatus(OrderStatus.CANCELLED);
|
|
|
source.setMergeOrderId(targetId);
|
|
|
+ source.setUpdatedAt(LocalDateTime.now());
|
|
|
mapper.updateById(source);
|
|
|
orderItemService.calculateTotals(targetId);
|
|
|
+ // 合单后重新计算运费(简单策略:取两者较大值)
|
|
|
+ target = mapper.selectById(targetId);
|
|
|
+ BigDecimal newShipping = source.getShippingFee().max(target.getShippingFee());
|
|
|
+ target.setShippingFee(newShipping);
|
|
|
+ target.setActualPaid(target.getOrderAmount().add(newShipping).add(target.getTaxAmount()));
|
|
|
+ target.setUpdatedAt(LocalDateTime.now());
|
|
|
+ mapper.updateById(target);
|
|
|
eventService.logEvent(targetId, "MERGED", "合单完成", "合并来源 " + source.getOrderNo(), "primary", operator);
|
|
|
}
|
|
|
|
|
|
@@ -268,12 +426,12 @@ public class OrdersService {
|
|
|
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.setOrderStatus(OrderStatus.CREATED);
|
|
|
+ order.setShippingStatus(ShippingStatus.UNSHIPPED);
|
|
|
+ order.setPaymentStatus(PaymentStatus.UNPAID);
|
|
|
+ order.setRefundStatus(RefundStatus.NONE);
|
|
|
order.setExceptionTag(Math.random() > 0.85 ? "地址需复核" : null);
|
|
|
- order.setPriority(Math.random() > 0.9 ? "URGENT" : "NORMAL");
|
|
|
+ order.setPriority(Math.random() > 0.9 ? Priority.URGENT : Priority.NORMAL);
|
|
|
|
|
|
int buyerIdx = (int) (Math.random() * BUYERS.length);
|
|
|
order.setBuyer(BUYERS[buyerIdx]);
|