package com.honghan.trade.statemachine;
import com.honghan.common.core.enums.OrderStatus;
import com.honghan.trade.enums.PaymentMethod;
import java.util.HashMap;
import java.util.Map;
public class OrderStateMachine {
private final Map<PaymentMethod, Map<OrderStatus, OrderStatus>> transitions;
private OrderStatus currentStatus;
public OrderStateMachine() {
this.transitions = new HashMap<>();
initializeTransitions();
}
//这里规定好订单的每步状态流向
private void initializeTransitions() {
// 先款后货状态转换
Map<OrderStatus, OrderStatus> prepayTransitions = new HashMap<>();
prepayTransitions.put(OrderStatus.WAIT_TALK, OrderStatus.CONFIRMED);
prepayTransitions.put(OrderStatus.CONFIRMED, OrderStatus.OFFLINE_CONFIRMED);
prepayTransitions.put(OrderStatus.OFFLINE_CONFIRMED, OrderStatus.PAYED);
prepayTransitions.put(OrderStatus.PAYED, OrderStatus.SENDING);
prepayTransitions.put(OrderStatus.SENDING, OrderStatus.RECEIVE);
prepayTransitions.put(OrderStatus.RECEIVE, OrderStatus.COUNT);
transitions.put(PaymentMethod.PREPAY, prepayTransitions);
// 先付订金后付尾款状态转换 / 多次付款状态转换
Map<OrderStatus, OrderStatus> depositTransitions = new HashMap<>();
depositTransitions.put(OrderStatus.WAIT_TALK, OrderStatus.CONFIRMED);
depositTransitions.put(OrderStatus.CONFIRMED, OrderStatus.OFFLINE_CONFIRMED);
depositTransitions.put(OrderStatus.OFFLINE_CONFIRMED, OrderStatus.PAYED);
depositTransitions.put(OrderStatus.PAYED, OrderStatus.SENDING);
depositTransitions.put(OrderStatus.SENDING, OrderStatus.RECEIVE);
depositTransitions.put(OrderStatus.RECEIVE, OrderStatus.COUNT);
transitions.put(PaymentMethod.DEPOSIT, depositTransitions);
transitions.put(PaymentMethod.MULTI_PAY, depositTransitions);
// 先货后款状态转换
Map<OrderStatus, OrderStatus> postpayTransitions = new HashMap<>();
postpayTransitions.put(OrderStatus.WAIT_TALK, OrderStatus.PARTIAL_SHIPMENTS);
postpayTransitions.put(OrderStatus.PARTIAL_SHIPMENTS, OrderStatus.COUNT);
transitions.put(PaymentMethod.POSTPAY, postpayTransitions);
}
public OrderStatus getNextStatus(OrderStatus currentStatus, PaymentMethod method) {
return getNextStatus(currentStatus, method, false); // 如果没有找到对应的状态转换
}
public OrderStatus getNextStatus(OrderStatus currentStatus, PaymentMethod method, boolean userWantsToCompleteOrder) {
if (currentStatus == OrderStatus.RECEIVE) {
return userWantsToCompleteOrder ? OrderStatus.COUNT : OrderStatus.REFUNDING;
}
Map<OrderStatus, OrderStatus> methodTransitions = transitions.get(method);
if (methodTransitions != null) {
return methodTransitions.get(currentStatus);
}
return null; // 如果没有找到对应的状态转换
}
public OrderStatus getCurrentStatus() {
return currentStatus;
}
public void setCurrentStatus(OrderStatus newStatus) {
this.currentStatus = newStatus;
}
}
【投诉】皇家美素佳儿2段奶粉里面有异物
和大佬学的
//设置Excel head高度
@HeadRowHeight(30)
//设置Excel默认列宽
@ColumnWidth(14)
//设置Excel 正文字体样式
@ContentFontStyle(fontName = "宋体", fontHeightInPoints = 12)
docker pull 报错Get “https://registry-1.docker.io/v2/“: net/http: request canceled while waiting for c
报错 :Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
解决方法