<?php

namespace app\enum;

enum BalanceType: int
{
    /**
     * 充值
     */
    case RECHARGE = 100;
    /**
     * 充值卡密
     */
    case RECHARGE_CARD = 101;

    /**
     * 提现
     */
    case WITHDRAWAL = 200;

    /**
     * 提现退回
     */
    case WITHDRAWAL_REJECT = 201; 

    /**
     * 购买卡密
     */
    case CDKEY = 202;


    /**
     * 站内转账
     */
    case TRANSFER = 300;
    /**
     * 兑换
     */
    case EXCHANGE = 301;
    /**
     * 领取问卷
     */
    case CLAIM = 306;
    /**
     * 签到
     */
    case SIGNIN = 302;
    /**
     * 发布朋友圈
     */
    case POSTPYQ = 303;
    /**
     * 发布QQ群
     */
    case POSTGROUP = 304;
    /**
     * 邀请新用户注册
     */
    case INVITE_NEW_USER = 305;

    /**
     * 购买产品
     */
    case PRODUCT_BUY = 401;
    /**
     * 购买角色
     */
    case PURCHASE_ROLE = 402;
    /**
     * VIP奖励
     */
    case OUTPUT_REWARD = 403;
    /**
     * 渠道商奖励
     */
    case WITHDRAW_REWARD = 404;
    /**
     * 会员奖励
     */
    case MEMBER_REWARD = 405;
    /**
     * 销售奖励
     */
    case SALES_REWARD = 406;
    /**
     * 购买积分卡
     */
    case GIFT_BUY = 407;


    /**
     * 问卷收益
     */
    case PRODUCT_INCOME = 501;

    /**
     * 分配问卷指标
     */
    case ASSIGN_QUOTA=502;

    /**
     * 问卷A收益:购买产品后代理收益
     */
    case AGENT_COMMISSION=504;
    /**
     * 问卷B收益:购买产品后级差佣金
     */
    case DIFFERENTIAL_COMMISSION=505;
    /**
     * 添加算力
     */
    case POWER_ADD = 600;
    /**
     * 算力减少
     */
    case POWER_SUB = 601;
    /**
     * 算力失效
     */
    case POWER_EXPRIS = 602;
    /**
     * 算力释放
     */
    case POWER_REALESE = 603;
    /**
     * 工作室奖励
     */
    case STUDIO_REWARD = 700;
    /**
     * 工作室奖励结算
     */
    case STUDIO_REALESE = 703;

    /**
     * 获取所有类型映射数组
     */
    public static function toArray(): array
    {
        return [
            self::RECHARGE->value => __('充值'),
            self::RECHARGE_CARD->value => __('充值卡密'),
            self::WITHDRAWAL->value => __('提现'),
            self::WITHDRAWAL_REJECT->value => __('提现退回'),
            self::CDKEY->value  =>  __('购买卡密'),
            self::TRANSFER->value => __('站内转账'),
            self::EXCHANGE->value => __('兑换'),
            self::CLAIM->value => __('领取问卷'),
            self::SIGNIN->value => __('签到'),
            self::POSTPYQ->value => __('发布朋友圈'),
            self::POSTGROUP->value => __('发布QQ群'),
            self::INVITE_NEW_USER->value => __('邀请新用户注册'),
            self::PRODUCT_BUY->value => __('购买产品'),
            self::PRODUCT_INCOME->value => __('问卷收益'),
            self::ASSIGN_QUOTA->value => __('分配问卷指标'),
            self::AGENT_COMMISSION->value => __('问卷A收益'),
            self::DIFFERENTIAL_COMMISSION->value => __('问卷B收益'),

            self::PURCHASE_ROLE->value => __('购买角色'),
            self::OUTPUT_REWARD->value => __('产值奖励'),
            self::WITHDRAW_REWARD->value => __('提现奖励'),
            self::SALES_REWARD->value => __('销售奖励'),
            self::MEMBER_REWARD->value => __('会员奖励'),
            self::GIFT_BUY->value => __('购买积分卡'),

            self::POWER_ADD->value => __('添加算力'),
            self::POWER_SUB->value => __('算力减少'),
            self::POWER_EXPRIS->value => __('算力过期'),
            self::POWER_REALESE->value => __('算力释放'),
            
            self::STUDIO_REWARD->value => __('工作室奖励'),
            self::STUDIO_REALESE->value => __('工作室奖励结算'),

        ];
    }

    /**
     * 获取当前类型的描述文本
     */
    public function getDescription(): string
    {
        return self::toArray()[$this->value];
    }

    /**
     * 安全地从值创建枚举实例
     */
    public static function tryFromValue(int $value): ?self
    {
        return self::tryFrom($value);
    }
}