order-constants.js 3.5 KB
// 订单来源, 接口对应查询参数: tabType
export const ownType = {
  BUY: 'buy', // 买家
  SELL: 'sell', // 卖家
};

// 卖家订单状态, 接口对应查询参数: type
export const sellerOrderStatus = {
  IN_SALE: 1, // 出售中
  TO_BE_DELIVERED: 2, // 待发货
  SHIPPED: 3, // 已发货
  DONE: 5, // 交易完成
  FAILED: 6, // 交易失败
};

// 买家订单状态,接口对应查询参数: type
export const buyerOrderStatus = {
  ALL: 1, // 全部
  UNPAID: 2, // 未付款
  TO_BE_DELIVERED: 3, // 待发货
  PENDING_RECEIPT: 4, // 待收货
  DONE: 5, // 交易成功
  FAILED: 6, // 交易失败
};

// 卖家订单状态, 接口对应查询参数: type
export const sellerOrderStatusList = [
  {
    value: 2,
    text: '待发货',
  },
  {
    value: 3,
    text: '已发货',
  },
  {
    value: 5,
    text: '交易成功',
  },
  {
    value: 6,
    text: '交易失败',
  },
];

// 买家订单状态,接口对应查询参数: type
export const buyerOrderStatusList = [
  {
    value: 1,
    text: '全部',
  },

  {
    value: 7,
    text: '求购',
  },
  {
    value: 2,
    text: '待付款',
  },
  {
    value: 3,
    text: '待发货',
  },
  {
    value: 4,
    text: '待收货',
  },
];

/**
 * helper: 生成状态key
 * @param type ownType buy|sell
 * @param status sellerOrderStatus|buyerOrderStatus
 * @returns {string}
 */
export function orderStatusKey(type, status) {
  return `${type}-${status}`;
}

/**
 * 根据owner计算status状态,如果status未设置,取对应订单类型的第一个状态
 * @param owner
 * @param status
 * @returns {number}
 */
export function getOrderStatus(owner, status) {
  status = parseInt(status, 10);
  if (isNaN(status)) {
    status = (owner === 'buy' ? buyerOrderStatusList : sellerOrderStatusList)[0].value;
  }

  return status;
}

// 订单操作
// ts IOrderAction[]
export const orderActionsMap = {
  DEL_ORDER: {
    code: 'del_order',
    name: 'DEL_ORDER',
    text: '删除',
  },
  BUY_AGAIN: { code: 'buy_again', name: 'BUY_AGAIN', text: '再次购买' },
  SHOW_DETAIL: {
    code: 'show_detail',
    name: 'SHOW_DETAIL',
    text: '查看详情',
  },
  SHOW_EXPRESS: {
    code: 'show_express',
    name: 'SHOW_EXPRESS',
    text: '查看物流',
  },

  SOLD_AGAIN: {
    code: 'sold_again',
    name: 'SOLD_AGAIN',
    text: '再次出售',
  },
  NOT_SOLD: {
    code: 'not_sold',
    confirmTips: '您确定不卖此商品吗?',
    name: 'NOT_SOLD',
    text: '不卖了',
  },
  PAY_EARNESTMONEY: {
    code: 'pay_earnestMoney',
    name: 'PAY_EARNESTMONEY',
    text: '支付保证金',
  },

  CANCEL_ORDER: {
    code: 'cancel_order',
    name: 'CANCEL_ORDER',
    text: '取消订单',
  },

  NOT_ENTRY_CHANGE_PRICE: {
    code: 'not_entry_change_price',
    name: 'NOT_ENTRY_CHANGE_PRICE',
    text: '调价',
  },
  STORAGE_MANAGE: {
    code: 'storage_manage',
    name: 'STORAGE_MANAGE',
    text: '管理库存',
  },

  // Todo
  NOW_BUY: {
    code: 'now_buy',
    name: 'NOW_BUY',
    text: '立即支付',
  },
  CONFIRM_DELIVERY: {
    code: 'confirm_delivery',
    name: 'CONFIRM_DELIVERY',
    text: '确认收货',
  },
  PAY_DEPOSIT: { code: 'pay_deposit', name: 'PAY_DEPOSIT', text: '支付定金' },
  DELIVER_GOODS: {
    code: 'deliver_goods',
    name: 'DELIVER_GOODS',
    text: '我要发货',
  },
  MODIFY_ADDRESS: {
    code: 'modify_address',
    name: 'MODIFY_ADDRESS',
    text: '修改地址',
  },
  CHANGE_BID_PRICE: {
    code: 'change_bid_price',
    name: 'CHANGE_BID_PRICE',
    text: '调价',
  },
};