<?php

declare(strict_types=1);

namespace Kylin\Retail\Enums;

/**
 * 零售系统错误码枚举
 */
enum RetailErrorCode: int
{
    // 商品 10xxx
    case ProductNotFound      = 10001;
    case ProductSkuDuplicate  = 10002;
    case ProductBarcodeDuplicate = 10003;
    case ProductOffShelf      = 10004;

    // 库存 11xxx
    case StockInsufficient    = 11001;
    case StockNotFound        = 11002;

    // 订单 12xxx
    case OrderNotFound        = 12001;
    case OrderCannotRefund    = 12002;
    case OrderAlreadyPaid     = 12003;

    // 会员 13xxx
    case MemberNotFound       = 13001;
    case MemberPhoneDuplicate = 13002;
    case MemberBalanceLow     = 13003;
    case MemberPointsLow      = 13004;

    public function message(): string
    {
        return match ($this) {
            self::ProductNotFound        => '商品不存在',
            self::ProductSkuDuplicate    => '商品编码已存在',
            self::ProductBarcodeDuplicate => '条码已存在',
            self::ProductOffShelf        => '商品已下架',
            self::StockInsufficient      => '库存不足',
            self::StockNotFound          => '库存记录不存在',
            self::OrderNotFound          => '订单不存在',
            self::OrderCannotRefund      => '订单不可退款',
            self::OrderAlreadyPaid       => '订单已支付',
            self::MemberNotFound         => '会员不存在',
            self::MemberPhoneDuplicate   => '手机号已注册',
            self::MemberBalanceLow       => '会员余额不足',
            self::MemberPointsLow        => '会员积分不足',
        };
    }
}
