package com.hzs.common.core.enums;

import com.hzs.common.core.constant.EnumsPrefixConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description: 交易类型
 * @Author: sui q
 * @Time: 2022/9/1 16:35
 * @Classname: ETradeType
 * @PackageName: com.hzs.common.core.enums
 */
@AllArgsConstructor
@Getter
public enum ETradeType {
    /**
     * 消费类
     */
    REGISTER_ORDER(101, 0, "报单订单", 0, EnumsPrefixConstants.TRADE_TYPE + 101, EOrderType.REGISTER_ORDER.getValue()),
    UPGRADE_ORDER(102, 0, "消费订单", 0, EnumsPrefixConstants.TRADE_TYPE + 102, EOrderType.UPGRADE_ORDER.getValue()),
    REPURCHASE_ORDER(103, 0, "复购订单", 0, EnumsPrefixConstants.TRADE_TYPE + 103, EOrderType.REPURCHASE_ORDER.getValue()),
    PICK_ORDER(108, 0, "提货订单", 0, EnumsPrefixConstants.TRADE_TYPE + 108, EOrderType.PICK_ORDER.getValue()),
    EXCHANGE_ORDER(111, 0, "积分订单", 0, EnumsPrefixConstants.TRADE_TYPE + 111, EOrderType.EXCHANGE_ORDER.getValue()),
    FICTITIOUS_ORDER(120, 0, "虚拟订单", 0, EnumsPrefixConstants.TRADE_TYPE + 120, EOrderType.FICTITIOUS_ORDER.getValue()),
    SECOND_ORDER(123, 0, "二次发货", 0, EnumsPrefixConstants.TRADE_TYPE + 123, EOrderType.SECOND_ORDER.getValue()),

    EXCHANGE_ANNUITY(124, 0, "兑换奖金年金", 0, EnumsPrefixConstants.TRADE_TYPE + 124, EOrderType.SECOND_ORDER.getValue()),

    RESALE_ORDER(130, 0, "复消订单", 0, EnumsPrefixConstants.TRADE_TYPE + 130, EOrderType.RESALE_ORDER.getValue()),

    YEAR_ORDER(133, 0, "年包订单", 0, EnumsPrefixConstants.TRADE_TYPE + 133, EOrderType.RENEWAL_ORDER.getValue()),

    EMPTY_ORDER(190, 190, "空单注册", 0, EnumsPrefixConstants.TRADE_TYPE + 190, EOrderType.REGISTER_ORDER.getValue()),

    /**
     * 提现
     */
    WITHDRAW(200, 301, "提现", 0, EnumsPrefixConstants.TRADE_TYPE + 200, -99),
    WITHDRAWAL_REFUSED(201, 0, "提现充正", 0, EnumsPrefixConstants.TRADE_TYPE + 201, -99),

    /**
     * 转账
     */
    TRANSFER(300, 0, "转账", 0, EnumsPrefixConstants.TRADE_TYPE + 300, -99),

    /**
     * 充值
     */
    OFF_LINE_RECHARGE(400, 300, "后台充值", 0, EnumsPrefixConstants.TRADE_TYPE + 400, -99),
    ON_LINE_RECHARGE(401, 0, "线上充值", 0, EnumsPrefixConstants.TRADE_TYPE + 401, -99),
    REDEED_POINTS(402, 0, "复消积分兑换", 0, EnumsPrefixConstants.TRADE_TYPE + 402, -99),

    // 活动赠送政策币
    GIVE_POLICY(411, 0, "活动赠送政策币", 0, EnumsPrefixConstants.TRADE_TYPE + 411, EOrderType.REGISTER_ORDER.getValue()),

    /**
     * 收益
     */
    INCOME_GRANT(500, 0, "收益发放", 0, EnumsPrefixConstants.TRADE_TYPE + 500, -99),
    ENCOURAGE_GRANT(501, 0, "鼓励金", 0, EnumsPrefixConstants.TRADE_TYPE + 501, -99),
    RECOIL_INCOME_GRANT(502, 0, "复销收益发放", 0, EnumsPrefixConstants.TRADE_TYPE + 502, -99),
    /**
     * 直播代金券 抽奖发放
     */
    DRAW_REWARD(550, 0, "抽奖发放", 0, EnumsPrefixConstants.TRADE_TYPE + 550, -99),
    RECHARGE_DRAW_PAY_NUMBER(551, 0, "购买抽奖次数-充值", 0, EnumsPrefixConstants.TRADE_TYPE + 551, -99),
    DRAW_PAY_NUMBER(552, 0, "购买抽奖次数-支付", 0, EnumsPrefixConstants.TRADE_TYPE + 552, -99),

    /**
     * 退款
     */
    CANCELLATION_ORDER_REFUND(600, 0, "撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 600, -99),
    RETURN_MONEY(601, 0, "返还本金", 0, EnumsPrefixConstants.TRADE_TYPE + 601, -99),
    REVOKE_REGISTER_ORDER(602, 0, "报单订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 602, -EOrderType.REGISTER_ORDER.getValue()),
    REVOKE_UPGRADE_ORDER(603, 0, "消费订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 603, -EOrderType.UPGRADE_ORDER.getValue()),
    REVOKE_REPURCHASE_ORDER(604, 0, "复购订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 604, -EOrderType.REPURCHASE_ORDER.getValue()),
    REVOKE_PICK_ORDER(609, 0, "提货订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 609, -EOrderType.PICK_ORDER.getValue()),

    BACK_GIVE_POLICY(611, 0, "撤单回退赠送政策币", 0, EnumsPrefixConstants.TRADE_TYPE + 611, -EOrderType.REGISTER_ORDER.getValue()),

    REVOKE_EXCHANGE_ORDER(612, 0, "积分订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 612, -EOrderType.EXCHANGE_ORDER.getValue()),
    REVOKE_FICTITIOUS_ORDER(618, 0, "虚拟订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 618, -EOrderType.FICTITIOUS_ORDER.getValue()),
    REVOKE_SECOND_ORDER(621, 0, "二次发货撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 621, -EOrderType.SECOND_ORDER.getValue()),

    REVOKE_RESALE_ORDER(630, 0, "复消订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 630, -EOrderType.RESALE_ORDER.getValue()),

    REVOKE_YEAR_ORDER(533, 0, "年包订单撤单返钱", 0, EnumsPrefixConstants.TRADE_TYPE + 633, EOrderType.RENEWAL_ORDER.getValue()),
    REVOKE_REDEED_POINTS(632, 0, "复消积分兑换撤单", 0, EnumsPrefixConstants.TRADE_TYPE + 632, -EOrderType.RESALE_INTEGRAL_ORDER.getValue()),

    ORDER_REFUND_ADJUST(690, 0, "退单金额补差", 0, EnumsPrefixConstants.TRADE_TYPE + 690, -99),

    /**
     * 办理业务
     */
    CHANGE_NAME(800, 100, "变更会员姓名", 0, EnumsPrefixConstants.TRADE_TYPE + 800, -99),
    CHANGE_CONTACT_INFORMATION(801, 101, "变更联系方式", 0, EnumsPrefixConstants.TRADE_TYPE + 801, -99),
    RESET_PASSWORDS(802, 103, "重置密码", 0, EnumsPrefixConstants.TRADE_TYPE + 802, -99),
    RESET_BANK_INFORMATION(803, 112, "重置银行信息", 0, EnumsPrefixConstants.TRADE_TYPE + 803, -99),
    MODIFY_REGISTRATION_LEVEL(804, 106, "修改注册等级", 0, EnumsPrefixConstants.TRADE_TYPE + 804, -99),
    MODIFY_SETTLEMENT_LEVEL(805, 113, "修改结算等级", 0, EnumsPrefixConstants.TRADE_TYPE + 805, -99),
    MODIFY_REAL_AWARDS(806, 107, "修改真实奖衔", 0, EnumsPrefixConstants.TRADE_TYPE + 806, -99),
    MODIFY_SETTLEMENT_COUNTRY(807, 124, "修改结算国家", 0, EnumsPrefixConstants.TRADE_TYPE + 807, -99),
    MODIFY_NATURAL_COUNTRY(808, 115, "修改自然国家", 0, EnumsPrefixConstants.TRADE_TYPE + 808, -99),
    MODIFY_LOGIN_STATUS(809, 116, "修改登录状态", 0, EnumsPrefixConstants.TRADE_TYPE + 809, -99),
    MODIFY_EARNINGS_STATUS(810, 117, "修改收益状态", 0, EnumsPrefixConstants.TRADE_TYPE + 810, -99),
    MODIFY_WALLET_STATUS(811, 118, "修改钱包状态", 0, EnumsPrefixConstants.TRADE_TYPE + 811, -99),
    MODIFY_EXAMINATION_STATUS(812, 119, "修改免考状态", 0, EnumsPrefixConstants.TRADE_TYPE + 812, -99),
    MEMBER_ACHIEVE(816, 123, "注水业绩", 0, EnumsPrefixConstants.TRADE_TYPE + 816, -99),
    POLICY_CURRENCY_YES_NO(817, 125, "办理政策币", 0, EnumsPrefixConstants.TRADE_TYPE + 817, -99),
    AWARDS_CONTROL_SAVE(818, 128, "新增真实奖衔控制", 0, EnumsPrefixConstants.TRADE_TYPE + 818, -99),
    AWARDS_CONTROL_MODIFY(819, 129, "修改真实奖衔控制", 0, EnumsPrefixConstants.TRADE_TYPE + 819, -99),
    AWARDS_CONTROL_DELETE(820, 130, "删除真实奖衔控制", 0, EnumsPrefixConstants.TRADE_TYPE + 820, -99),
    MEMBER_PARENT(823, 111, "修改直推", 0, EnumsPrefixConstants.TRADE_TYPE + 823, -99),
    MEMBER_PLACE_PARENT(824, 110, "修改安置", 0, EnumsPrefixConstants.TRADE_TYPE + 824, -99),
    RESET_EMAIL(825, 114, "修改邮箱", 0, EnumsPrefixConstants.TRADE_TYPE + 825, -99),
    /**
     * 订单修改地址
     */
    ORDER_CHANGE_ADDRESS(830, 231, "修改地址", 0, EnumsPrefixConstants.TRADE_TYPE + "830", -99),
    /**
     * 订单调换货物
     */
    ORDER_CHANGE_PRODUCT(831, 232, "调换货物", 0, EnumsPrefixConstants.TRADE_TYPE + "831", -99),

    /**
     * 订单撤销订单
     */
    ORDER_CANCEL(832, 234, "撤销订单", 0, EnumsPrefixConstants.TRADE_TYPE + "832", -99),
    /**
     * 订单撤销产品
     */
    ORDER_CANCEL_PRODUCT(833, 235, "撤销产品", 0, EnumsPrefixConstants.TRADE_TYPE + "833", -99),

    /**
     * 订单退单
     */
    ORDER_RETURN(834, 233, "退单", 0, EnumsPrefixConstants.TRADE_TYPE + "834", -99),

    ;

    /**
     * 实际值
     */
    private final int value;

    /**
     * 审核对应的值
     */
    private final int approvalValue;
    /**
     * 显示标签
     */
    private final String label;
    /**
     * 是否启用（0=是,1=否） -- 来源EYesNo
     */
    private final int enable;

    /**
     * 国际化翻译key值
     */
    private final String key;

    private final int orderType;


    /**
     * 获取字典标签值
     *
     * @param value
     * @return String
     */
    public static String getTradeLabel(int value) {
        for (ETradeType type : ETradeType.values()) {
            if (type.getValue() == value) {
                return type.getLabel();
            }
        }
        return "";
    }


    /**
     * 根据审批值查询value值
     *
     * @param value 审批值
     * @return int
     */
    public static int getValueByApprovalValue(int value) {
        for (ETradeType type : ETradeType.values()) {
            if (type.approvalValue == value) {
                return type.getValue();
            }
        }
        return 0;
    }

    /**
     * 根据KEY获取枚举
     *
     * @param key
     * @return
     */
    public static ETradeType getEnumByKey(String key) {
        for (ETradeType type : ETradeType.values()) {
            if (type.getKey().equals(key)) {
                return type;
            }
        }
        return null;
    }

}
