
const statusMap = {
  pending: "待处理",
  processing: "处理中",
  cancelled: "已取消",
  completed: "已完成",
  finished: "已结束",
};

export const colorMap = {
  pending: "red",
  processing: "red",
  cancelled: "#666",
  completed: "#4cd964",
  finished: "#4cd964",
};

export const statusOptions = Object.keys(statusMap).reduce((acc, key) => {
  acc.push({
    label: statusMap[key],
    value: key,
  });
  return acc;
}, []);

export function getStatus(item) {
  const { orderStatus, payStatus, payExpireTime } = item;
  if (orderStatus === 'pending' && payStatus === 'pending' && payExpireTime > Date.now()) {
    return { text: '待支付', color: 'red' };
  } else if (orderStatus === 'pending' && payStatus === 'pending' && payExpireTime <= Date.now()) {
    return { text: '已取消', color: '#666' };
  }
  const color = colorMap[orderStatus] || '';
  const text = statusMap[orderStatus] || '';
  return { text, color }
}