package com.ltkj.mall.mallOrderUtils;
|
|
import com.ltkj.mall.domain.MallOrder;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/*
|
* 订单流程:下单成功-》支付订单-》核销-》完成
|
* 订单状态:
|
* 101 订单生成,未支付;
|
* 102,下单未支付用户取消;
|
* 103,下单未支付超期系统自动取消
|
* 201 支付完成,商家未核销;
|
* 202,订单生产,已付款未核销,用户申请退款;
|
* 203,管理员执行退款操作,确认退款成功;
|
* 204 支付完成,商家未核销,管理员强制取消订单,确认退款成功
|
* 301 商家核销,订单结束;
|
*
|
* 当101用户未付款时,此时用户可以进行的操作是取消或者付款
|
* 当201支付完成而商家未核销时,此时用户可以退款
|
* 当301商家已核销时,此时用户可以可以删除、或者再次购买。
|
*/
|
public class OrderUtil {
|
|
public static final Short STATUS_CREATE = 101; //订单生成,未支付;
|
public static final Short STATUS_PAY = 201; //201 支付完成,商家未核销;
|
public static final Short STATUS_SHIP = 301; //商家核销,订单结束;
|
public static final Short STATUS_CANCEL = 102; //下单未支付用户取消;
|
public static final Short STATUS_AUTO_CANCEL = 103; //下单未支付超期系统自动取消
|
public static final Short STATUS_REFUND = 202; //已付款未核销,用户申请退款
|
public static final Short STATUS_REFUND_CONFIRM = 203; //管理员执行退款操作,确认退款成功
|
public static final Short STATUS_ADMIN_CANCEL = 204; //支付完成,商家未核销,管理员强制取消订单,并退款
|
|
|
public static String orderStatusText(MallOrder order) {
|
int status = order.getOrderStatus().intValue();
|
|
if (status == 101) {
|
return "未付款";
|
}
|
|
if (status == 102) {
|
return "已取消";
|
}
|
|
if (status == 103) {
|
return "已取消(系统)";
|
}
|
|
|
if (status == 201) {
|
return "已付款";
|
}
|
|
if (status == 202) {
|
return "订单取消,退款中";
|
}
|
|
if (status == 203) {
|
return "已退款";
|
}
|
|
if (status == 204) {
|
return "已退款(商家)";
|
}
|
|
if (status == 301) {
|
return "已核销";
|
}
|
|
if (status == 207) {
|
return "已售后";
|
}
|
|
throw new IllegalStateException("orderStatus不支持");
|
}
|
|
|
public static OrderHandleOption build(MallOrder order) {
|
int status = order.getOrderStatus().intValue();
|
OrderHandleOption handleOption = new OrderHandleOption();
|
|
if (status == 101) {
|
// 如果订单没有被取消,且没有支付,则可支付,可取消
|
handleOption.setCancel(true);
|
handleOption.setPay(true);
|
} else if (status == 102 || status == 103) {
|
// 如果订单已经取消或是已完成,则可删除
|
handleOption.setDelete(true);
|
} else if (status == 201) {
|
// 如果订单已付款,可核销,可退款
|
handleOption.setRefund(true);
|
handleOption.setConfirm(true);
|
} else if (status == 202) {
|
// 如果订单申请退款中,没有相关操作
|
} else if (status == 203|| status == 204) {
|
// 如果订单已经退款,则可删除
|
handleOption.setDelete(true);
|
} else if (status == 301) {
|
// 如果订单已核销,则可删除和再次购买
|
handleOption.setDelete(true);
|
handleOption.setRebuy(true);
|
handleOption.setAftersale(true);
|
} else {
|
throw new IllegalStateException("status不支持");
|
}
|
|
return handleOption;
|
}
|
|
public static List<Integer> orderStatus(Integer showType) {
|
// 全部订单
|
if (showType == 0) {
|
return null;
|
}
|
|
List<Integer> status = new ArrayList<Integer>(2);
|
|
if (showType.equals(1)) {
|
// 待付款订单
|
status.add(101);
|
} else if (showType.equals(2)) {
|
// 待核销订单
|
status.add(201);
|
} else if (showType.equals(3)) {
|
// 已完成订单
|
status.add(301);
|
} else {
|
return null;
|
}
|
return status;
|
}
|
|
|
public static boolean isCreateStatus(MallOrder mallOrder) {
|
return OrderUtil.STATUS_CREATE == mallOrder.getOrderStatus().shortValue();
|
}
|
|
public static boolean hasPayed(MallOrder order) {
|
return OrderUtil.STATUS_CREATE != order.getOrderStatus().shortValue()
|
&& OrderUtil.STATUS_CANCEL != order.getOrderStatus().shortValue()
|
&& OrderUtil.STATUS_AUTO_CANCEL != order.getOrderStatus().shortValue();
|
}
|
|
public static boolean isPayStatus(MallOrder mallOrder) {
|
return OrderUtil.STATUS_PAY == mallOrder.getOrderStatus().shortValue();
|
}
|
|
public static boolean isShipStatus(MallOrder mallOrder) {
|
return OrderUtil.STATUS_SHIP == mallOrder.getOrderStatus().shortValue();
|
}
|
|
|
public static boolean isCancelStatus(MallOrder mallOrder) {
|
return OrderUtil.STATUS_CANCEL == mallOrder.getOrderStatus().shortValue();
|
}
|
|
public static boolean isAutoCancelStatus(MallOrder mallOrder) {
|
return OrderUtil.STATUS_AUTO_CANCEL == mallOrder.getOrderStatus().shortValue();
|
}
|
|
public static boolean isRefundStatus(MallOrder mallOrder) {
|
return OrderUtil.STATUS_REFUND == mallOrder.getOrderStatus().shortValue();
|
}
|
|
public static boolean isRefundConfirmStatus(MallOrder mallOrder) {
|
return OrderUtil.STATUS_REFUND_CONFIRM == mallOrder.getOrderStatus().shortValue();
|
}
|
|
public static boolean isAdminCancel(MallOrder mallOrder) {
|
return OrderUtil.STATUS_ADMIN_CANCEL == mallOrder.getOrderStatus().shortValue();
|
}
|
|
}
|