import type {
  MemberPointMallExchangeType,
  MemberPointMallNotifyChannel,
  MemberPointMallPickupMethod,
  MemberPointMallProductStatus,
  MemberPointMallRecordStatus,
  MemberPointMallRedeemType,
  MemberPointMallVerifyMethod,
} from '#/api/member/points-mall';
import type { PointMallTabKey } from '#/views/member/points-mall/types';

/** 积分商城查看权限。 */
export const MEMBER_POINTS_MALL_VIEW_PERMISSION =
  'tenant:member:points-mall:view';

/** 积分商城管理权限。 */
export const MEMBER_POINTS_MALL_MANAGE_PERMISSION =
  'tenant:member:points-mall:manage';

/** 页面 Tab 选项。 */
export const POINTS_MALL_TAB_OPTIONS: Array<{
  label: string;
  value: PointMallTabKey;
}> = [
  { label: '积分规则', value: 'rules' },
  { label: '兑换商品', value: 'products' },
  { label: '兑换记录', value: 'records' },
];

/** 商品状态筛选。 */
export const POINTS_MALL_PRODUCT_STATUS_FILTER_OPTIONS: Array<{
  label: string;
  value: '' | MemberPointMallProductStatus;
}> = [
  { label: '全部状态', value: '' },
  { label: '上架', value: 'enabled' },
  { label: '下架', value: 'disabled' },
];

/** 记录类型筛选。 */
export const POINTS_MALL_RECORD_REDEEM_FILTER_OPTIONS: Array<{
  label: string;
  value: '' | MemberPointMallRedeemType;
}> = [
  { label: '全部类型', value: '' },
  { label: '兑换商品', value: 'product' },
  { label: '兑换优惠券', value: 'coupon' },
  { label: '兑换实物', value: 'physical' },
];

/** 记录状态筛选。 */
export const POINTS_MALL_RECORD_STATUS_FILTER_OPTIONS: Array<{
  label: string;
  value: '' | MemberPointMallRecordStatus;
}> = [
  { label: '全部状态', value: '' },
  { label: '待领取', value: 'pending_pickup' },
  { label: '已发放', value: 'issued' },
  { label: '已完成', value: 'completed' },
  { label: '已取消', value: 'canceled' },
];

/** 兑换类型选项。 */
export const POINTS_MALL_REDEEM_TYPE_OPTIONS: Array<{
  label: string;
  value: MemberPointMallRedeemType;
}> = [
  { label: '兑换商品', value: 'product' },
  { label: '兑换优惠券', value: 'coupon' },
  { label: '兑换实物', value: 'physical' },
];

/** 兑换类型提示。 */
export const POINTS_MALL_REDEEM_TYPE_HINT_MAP: Record<
  MemberPointMallRedeemType,
  string
> = {
  product: '顾客兑换后系统自动发放商品兑换券，下单时该商品免费',
  coupon: '顾客兑换后优惠券直接发到券包',
  physical: '实物商品需到店自提，不走线上履约',
};

/** 领取方式选项。 */
export const POINTS_MALL_PICKUP_METHOD_OPTIONS: Array<{
  label: string;
  value: MemberPointMallPickupMethod;
}> = [
  { label: '到店自提', value: 'store_pickup' },
  { label: '快递配送', value: 'delivery' },
];

/** 兑换方式选项。 */
export const POINTS_MALL_EXCHANGE_TYPE_OPTIONS: Array<{
  label: string;
  value: MemberPointMallExchangeType;
}> = [
  { label: '纯积分', value: 'points' },
  { label: '积分 + 现金', value: 'mixed' },
];

/** 通知渠道选项。 */
export const POINTS_MALL_NOTIFY_CHANNEL_OPTIONS: Array<{
  label: string;
  value: MemberPointMallNotifyChannel;
}> = [
  { label: '站内消息', value: 'in_app' },
  { label: '短信通知', value: 'sms' },
];

/** 核销方式选项。 */
export const POINTS_MALL_VERIFY_METHOD_OPTIONS: Array<{
  label: string;
  value: MemberPointMallVerifyMethod;
}> = [
  { label: '扫码核销', value: 'scan' },
  { label: '手动核销', value: 'manual' },
];

/** 商品状态文案。 */
export const POINTS_MALL_PRODUCT_STATUS_TEXT_MAP: Record<
  MemberPointMallProductStatus,
  string
> = {
  enabled: '上架',
  disabled: '下架',
};

/** 类型 Tag 样式。 */
export const POINTS_MALL_REDEEM_TYPE_CLASS_MAP: Record<
  MemberPointMallRedeemType,
  'is-blue' | 'is-green' | 'is-orange'
> = {
  product: 'is-blue',
  coupon: 'is-green',
  physical: 'is-orange',
};

/** 记录状态样式。 */
export const POINTS_MALL_RECORD_STATUS_CLASS_MAP: Record<
  MemberPointMallRecordStatus,
  'is-gray' | 'is-green' | 'is-orange' | 'is-red'
> = {
  pending_pickup: 'is-orange',
  issued: 'is-green',
  completed: 'is-green',
  canceled: 'is-gray',
};
