package com.yidian.shenghuoquan.buserorder.manager

/**
 * author: yinjiacheng
 * date: 2021/8/21 12:43
 * description: 订单状态管理
 */
object OrderStatusManager {

  /**
   * 获取订单状态
   */
  fun getOrderStatus(status: Int): OrderStatus {
    return when (status) {
      1 -> OrderStatus.ORDER_STATUS_WAIT_PAY
      2 -> OrderStatus.ORDER_STATUS_PAID
      3 -> OrderStatus.ORDER_STATUS_WAIT_REFUND
      4 -> OrderStatus.ORDER_STATUS_REFUNDED
      5 -> OrderStatus.ORDER_STATUS_ON_REFUND
      6 -> OrderStatus.ORDER_STATUS_REFUSE_REFUND
      8 -> OrderStatus.ORDER_STATUS_PART_REFUND
      else -> OrderStatus.ORDER_STATUS_UNKNOWN
    }
  }
}

/**
 * 订单状态
 * e.g. 未知、确认中、未支付、已支付、待退款、退款中、已退款、拒绝退款、部分退款
 */
enum class OrderStatus(val code: Int, val text: String) {
  ORDER_STATUS_UNKNOWN(-1, "未知"),
  ORDER_STATUS_WAIT_PAY(1, "未支付"),
  ORDER_STATUS_PAID(2, "已支付"),
  ORDER_STATUS_WAIT_REFUND(3, "待退款"),
  ORDER_STATUS_REFUNDED(4, "已退款"),
  ORDER_STATUS_ON_REFUND(5, "退款中"),
  ORDER_STATUS_REFUSE_REFUND(6, "已拒绝退款"),
  ORDER_STATUS_PART_REFUND(8, "部分退款")
}
